// $Id: fgl_xyzdata.h $ // ================================================================= // This code is distributed under the terms and conditions of the // CCP4 Program Suite Licence Agreement as 'Part 2' (Annex 2) // software. A copy of the CCP4 licence can be obtained by writing // to CCP4, Research Complex at Harwell, Rutherford Appleton // Laboratory, Didcot OX11 0FA, UK, or from // http://www.ccp4.ac.uk/ccp4license.php. // ================================================================= // // 14.10.13 <-- Date of Last Modification. // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // ---------------------------------------------------------------- // // **** Module : fgl_xyzdata // ~~~~~~~~~ // **** Project : QtLibs/FGL - plotting in Qt // ~~~~~~~~~ // **** Classes : fgl::XYZData // ~~~~~~~~~ // // (C) E. Krissinel 2012-2013 // // ================================================================= // #ifndef FGL_XYZDATA_H #define FGL_XYZDATA_H #include #include QT_BEGIN_NAMESPACE class QPainter; QT_END_NAMESPACE namespace fgl { class Scene; class XYFrame; class XYZData { public: enum LEVEL_KEY { Linear,Log2,Log10 }; XYZData (); virtual ~XYZData(); void clear(); inline void clearCache() { lines.clear(); } void setXY ( const qreal *xvector, const int nx, const qreal *yvector, const int ny ); void setXY ( const QVector & xvector, const QVector & yvector ); inline void addZ ( const int ix, const int iy, const qreal zv ) { z[iy*x.count()+ix] = zv; } inline void addLevel ( const qreal h ) { level.append(h); } inline void addLevels ( const QVector & h ) { level = h; } void makeLevels ( LEVEL_KEY key, int nLevels ); /// \brief Returns Z-value in node [ix,iy] or 0.0 if [ix,iy] /// is outside given XY space qreal getZ ( const int ix, const int iy ); /// \brief Returns interpolated Z-value at (xpoint,ypoint). /// \param[in] xpoint x-point /// \param[in] ypoint x-point /// \param[in] zvalue variable to receive z-value /// \return true if Z-value is properly calculated /// \return false if (xpoint,ypoint) is outside given XY range, /// in which case Z-value is set to 0.0 bool zvalue ( const qreal xpoint, const qreal ypoint, qreal & zvalue ); inline int xsize() { return x.size(); } inline int ysize() { return y.size(); } inline void setLineWidth ( const qreal lw ) { lineWidth = lw; } inline QVector & getX() { return x; } inline QVector & getY() { return y; } inline qreal getXMin() { return xMin; } inline qreal getXMax() { return xMax; } inline qreal getYMin() { return yMin; } inline qreal getYMax() { return yMax; } inline qreal getZMin() { return zMin; } inline qreal getZMax() { return zMax; } inline QPen & getPen() { return pen; } inline qreal getLineWidth() { return lineWidth; } void calcRange(); void paintData ( QPainter *painter, Scene *scene, XYFrame *frame ); protected: QVector x; //!< x-nodes QVector y; //!< y-nodes QVector z; //!< z-values of xy-nodes QVector level; //!< contour levels qreal xMin; //!< minimal x qreal xMax; //!< maximal x qreal yMin; //!< minimal y qreal yMax; //!< maximal y qreal zMin; //!< minimal z qreal zMax; //!< maximal z QPen pen; //!< pen properties qreal lineWidth; //!< relative line width virtual qreal calcZ ( const qreal xpoint, const qreal ypoint ); private: // Isolines' data QList lines; QVector il_Bzx; QVector il_Bzy; qreal il_Height, il_d11,il_d21,il_d12,il_d22; qreal il_dist, il_clX,il_clY, il_closeX,il_closeY; int il_ix,il_iy,il_iz, il_Nx,il_Ny; int il_xsize,il_ysize; bool il_Done; void crossLine ( qreal & uu, qreal & vv, int HV, XYFrame * frame ); void computeTops ( XYFrame *frame ); void paintContour ( int Fx, int Fy, int Fz, int Key, QPainter *painter, Scene *scene, XYFrame *frame ); void paintLevel ( qreal Height, QPainter *painter, Scene *scene, XYFrame *frame, qreal *closestX, qreal *closestY ); }; } #endif // FGL_XYZDATA_H