Commit a3de4319 authored by Frédéric Larue's avatar Frédéric Larue

Possibility added to GLViewer to set a suffix to the metric grid (for...

Possibility added to GLViewer to set a suffix to the metric grid (for instance, to specify a length unit).
parent 6d1f8c89
...@@ -37,6 +37,10 @@ float GLViewer::Specular = 0.5f; ...@@ -37,6 +37,10 @@ float GLViewer::Specular = 0.5f;
float GLViewer::Shininess = 80.0f; float GLViewer::Shininess = 80.0f;
QString GLViewer::s_MetricGrid2DSuffix;
QString GLViewer::s_MetricGrid3DSuffix;
void GLViewer::DisplayableInfo::Initialize( DisplayableInterface *displayable, void GLViewer::DisplayableInfo::Initialize( DisplayableInterface *displayable,
...@@ -163,6 +167,9 @@ void GLViewer::initMetricGrids() ...@@ -163,6 +167,9 @@ void GLViewer::initMetricGrids()
m_View.metricGrid3D.enableAxis( MetricGrid::ALL ); m_View.metricGrid3D.enableAxis( MetricGrid::ALL );
m_View.metricGrid3D.enableGrid( MetricGrid::ZX ); m_View.metricGrid3D.enableGrid( MetricGrid::ZX );
m_View.metricGrid2D.setSuffix( &s_MetricGrid2DSuffix );
m_View.metricGrid3D.setSuffix( &s_MetricGrid3DSuffix );
} }
......
...@@ -127,6 +127,9 @@ protected: ...@@ -127,6 +127,9 @@ protected:
static const char* s_ZBufferVPG; static const char* s_ZBufferVPG;
static const char* s_ZBufferFPG; static const char* s_ZBufferFPG;
static QString s_MetricGrid2DSuffix;
static QString s_MetricGrid3DSuffix;
public: public:
static QVector3D BgTopColor; static QVector3D BgTopColor;
static QVector3D BgBottomColor; static QVector3D BgBottomColor;
...@@ -142,7 +145,6 @@ public: ...@@ -142,7 +145,6 @@ public:
static float Specular; static float Specular;
static float Shininess; static float Shininess;
/********************\ /********************\
| Member variable(s) | | Member variable(s) |
\********************/ \********************/
...@@ -447,6 +449,9 @@ public slots: ...@@ -447,6 +449,9 @@ public slots:
inline void registerAnimation( DisplayableInterface *anim ) { m_AnimationStartingQueue.push_back( anim ); update(); } inline void registerAnimation( DisplayableInterface *anim ) { m_AnimationStartingQueue.push_back( anim ); update(); }
inline void unregisterAnimation( DisplayableInterface *anim ) { m_AnimationStoppingQueue .push_back( anim ); update(); } inline void unregisterAnimation( DisplayableInterface *anim ) { m_AnimationStoppingQueue .push_back( anim ); update(); }
inline void setMetricGrid2DSuffix( const QString& suffix ) { s_MetricGrid2DSuffix = suffix; }
inline void setMetricGrid3DSuffix( const QString& suffix ) { s_MetricGrid3DSuffix = suffix; }
}; };
......
...@@ -179,7 +179,7 @@ void MetricGrid::displayGrid( GLViewer *viewer, ...@@ -179,7 +179,7 @@ void MetricGrid::displayGrid( GLViewer *viewer,
{ {
std::stringstream strStream; std::stringstream strStream;
strStream << spacing; strStream << spacing;
QString spacingStr = QString::fromStdString( strStream.str() ); QString spacingStr = QString::fromStdString( strStream.str() ) + " " + m_Suffix;
if( isAxisEnabled(X) && QVector3D::dotProduct( QVector3D(spacing,0,0)-camCenter, camFront ) < 0.0f ) if( isAxisEnabled(X) && QVector3D::dotProduct( QVector3D(spacing,0,0)-camCenter, camFront ) < 0.0f )
{ {
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
class GLViewer; class GLViewer;
#include <QtCore>
class MetricGrid class MetricGrid
...@@ -41,11 +42,12 @@ public: ...@@ -41,11 +42,12 @@ public:
| Member variable(s) | | Member variable(s) |
\********************/ \********************/
private: private:
int m_EnabledGrids; int m_EnabledGrids;
int m_EnabledAxis; int m_EnabledAxis;
bool m_EnableLabels; bool m_EnableLabels;
int m_EnableAxisOnAlignedOrtho; int m_EnableAxisOnAlignedOrtho;
int m_EnableGridsOnAlignedOrtho; int m_EnableGridsOnAlignedOrtho;
const QString* m_Suffix;
/*****************************\ /*****************************\
| Constructor(s) / destructor | | Constructor(s) / destructor |
...@@ -97,6 +99,9 @@ public: ...@@ -97,6 +99,9 @@ public:
inline bool areGridsOnAlignedOrthoEnabled() const { return m_EnableGridsOnAlignedOrtho != 0; } inline bool areGridsOnAlignedOrthoEnabled() const { return m_EnableGridsOnAlignedOrtho != 0; }
void display( GLViewer *viewer ); void display( GLViewer *viewer );
inline void setSuffix( const QString *suffix ) { m_Suffix = suffix; }
inline QString suffix() const { return *m_Suffix; }
}; };
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment