// $Id: fgl_axisdata.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. // ================================================================= // // 05.011.13 <-- Date of Last Modification. // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // ---------------------------------------------------------------- // // **** Module : fgl_axisdata // ~~~~~~~~~ // **** Project : QtLibs/FGL - plotting in Qt // ~~~~~~~~~ // **** Classes : fgl::AxisData // ~~~~~~~~~ // // (C) E. Krissinel 2012-2013 // // ================================================================= // #ifndef FGL_AXISDATA_H #define FGL_AXISDATA_H #include #include namespace fgl { #define ALGN_Left 0x01 #define ALGN_Right 0x02 #define ALGN_HCentre 0x04 #define ALGN_Top 0x10 #define ALGN_Bottom 0x20 #define ALGN_VCentre 0x40 class Scene; class Range; class AxisData { public: enum Format { FMT_Auto, FMT_Fixed, FMT_Exponent }; enum Direction { DIRECTION_Min2Max, DIRECTION_Max2Min }; enum Scale { SCALE_Native, SCALE_Log, SCALE_Inverse }; enum LabelHash { LHASH_None, LHASH_Sqrt }; AxisData (); ~AxisData(); void setRange ( qreal c1, qreal c2, qreal u1, qreal u2 ); void setDirection ( Direction d ); inline void setQ1 ( const qreal q ) { q1 = q; } inline void setQ2 ( const qreal q ) { q2 = q; } inline void setQRange ( const qreal v1, const qreal v2 ) { q1 = v1; q2 = v2; } inline void setSRange ( const qreal v1, const qreal v2 ) { s1 = v1; s2 = v2; } inline void setScaleKey ( const Scale sk ) { keyScale = sk; } inline void setHashLabel ( const LabelHash lh ) { labelHash = lh; } inline void setLogBreak ( const qreal lbk ) { logBreak = lbk; } inline void setForceInt ( const bool fint ) { forceInt = fint; } inline qreal getQ1 () { return q1; } inline qreal getQ2 () { return q2; } inline qreal getS1 () { return s1; } inline qreal getS2 () { return s2; } inline qreal getF1 () { return f1; } inline qreal getF2 () { return f2; } inline Scale getScaleKey() { return keyScale; } inline qreal getLogBreak() { return logBreak; } inline int getFormatBase() { return format_base; } void invertSRange(); void calcScale (); void calcScale ( qreal ts ); qreal calcTick ( bool adjustTicks, qreal charMeasure ); qreal coord ( qreal value ); //!< returns screen coordinate qreal value ( qreal coord ); //!< inverse to coord(value) void calcFormat ( qreal dq ); //!< calculates output format void getNumOut ( qreal q, QString & N, QString & E ); void getSize ( QString N, QString E, qreal & width, qreal & height, QFont & font ); void getSize ( qreal q, qreal & width, qreal & height, QFont & font ); void putNumber ( qreal q, qreal posX, qreal posY, int align, Scene *scene, QFont & font ); qreal toScale ( qreal R ); qreal fromScale ( qreal R ); qreal toHash ( qreal R ); qreal fromHash ( qreal R ); qreal fromScaleToHash ( qreal R ); void Copy ( AxisData *axisData ); //!< copies from axisData protected: qreal s1,s2; //!< logical coordinates of frame qreal q1,q2; //!< physical coordinates of working area qreal f1,f2; //!< physical coordinates of frame qreal scale; //!< conversion between coordinates bool autoTicks; //!< flag to make auto ticking bool forceInt; //!< flag to force integer ticking qreal tick; //!< tick step when not auto Scale keyScale; //!< indicator of logarithmic etc scale LabelHash labelHash; //!< hash function to recalculate labels qreal logBreak; //!< value to break logarithmic scale Format format_key; //!< format key int format_prec; //!< format precision parameter int format_base; //!< base number of significant digits int fmt_prec,fmt_len; }; } #endif // FGL_AXISDATA_H