MetricGrid.h 3.48 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
/*
 *	(c) LSIIT, UMR CNRS/UdS
 *	Authors: O. Gnevaux, F. Larue.
 *
 *	See licence.txt for additional information.
 */


#ifndef METRICGRID_H
#define METRICGRID_H




class GLViewer;
16
#include <QtCore>
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44


class MetricGrid
{
    /******************\
    | Internal type(s) |
    \******************/
public:
    enum GridPlane
    {
        NONE    = 0x0000,
        XY      = 0x0001,
        YZ      = 0x0002,
        ZX      = 0x0004,
        ALL     = 0x0007,
    };

    enum Axis
    {
        X       = 0x0001,
        Y       = 0x0002,
        Z       = 0x0004,
    };

    /********************\
    | Member variable(s) |
    \********************/
private:
45 46 47 48 49
    int             m_EnabledGrids;
    int             m_EnabledAxis;
    bool            m_EnableLabels;
    int             m_EnableAxisOnAlignedOrtho;
    int             m_EnableGridsOnAlignedOrtho;
50
    double          m_CurrentScale;
51
    const QString*  m_Suffix;
52 53 54 55 56 57 58

    /*****************************\
    | Constructor(s) / destructor |
    \*****************************/
public:
    inline  MetricGrid() :
        m_EnabledGrids(NONE),
59 60
        m_EnabledAxis(ALL),
        m_EnableLabels(true),
61 62
        m_EnableAxisOnAlignedOrtho(1),
        m_EnableGridsOnAlignedOrtho(1)
63
    {}
64 65 66
    inline  MetricGrid( int enabledGrids,
                        int enabledAxis ) :
        m_EnabledGrids(enabledGrids),
67 68
        m_EnabledAxis(enabledAxis),
        m_EnableLabels(true),
69 70
        m_EnableAxisOnAlignedOrtho(1),
        m_EnableGridsOnAlignedOrtho(1)
71
    {}
72 73 74 75 76 77 78 79 80 81

    /********************\
    | Member function(s) |
    \********************/
private:
    void            displayGrid( GLViewer *viewer,
                                 const double spacing,
                                 const GLubyte alpha );

public:
82 83 84 85 86 87 88 89 90 91 92 93
    inline void     enableGrid( int gridsToEnable )         { m_EnabledGrids |= gridsToEnable; }
    inline void     disableGrid( int gridsToDisable )       { m_EnabledGrids &= ~gridsToDisable; }
    inline bool     isGridEnabled( GridPlane g ) const      { return (m_EnabledGrids & g) != 0; }

    inline void     enableAxis( int axisToEnable )          { m_EnabledAxis |= axisToEnable; }
    inline void     disableAxis( int axisToDisable )        { m_EnabledAxis &= ~axisToDisable; }
    inline bool     isAxisEnabled( Axis a ) const           { return (m_EnabledAxis & a) != 0; }

    inline void     enableLabels()                          { m_EnableLabels = true;  }
    inline void     disableLabels()                         { m_EnableLabels = false; }
    inline bool     areLabelsEnabled() const                { return m_EnableLabels;  }

94 95 96
    inline void     enableAxisOnAlignedOrtho()              { m_EnableAxisOnAlignedOrtho = 1; }
    inline void     disableAxisOnAlignedOrtho()             { m_EnableAxisOnAlignedOrtho = 0; }
    inline bool     areAxisOnAlignedOrthoEnabled() const    { return m_EnableAxisOnAlignedOrtho != 0; }
97

98 99 100
    inline void     enableGridsOnAlignedOrtho()             { m_EnableGridsOnAlignedOrtho = 1; }
    inline void     disableGridsOnAlignedOrtho()            { m_EnableGridsOnAlignedOrtho = 0; }
    inline bool     areGridsOnAlignedOrthoEnabled() const   { return m_EnableGridsOnAlignedOrtho != 0; }
101 102

    void            display( GLViewer *viewer );
103 104 105

    inline void     setSuffix( const QString *suffix )      { m_Suffix = suffix; }
    inline QString  suffix() const                          { return *m_Suffix; }
106 107

    inline double   currentScale() const                    { return m_CurrentScale; }
108 109 110 111 112 113
};




#endif //METRICGRID_H