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

More control added to the display of the metric grid.

parent 47448b77
......@@ -33,6 +33,8 @@ void MetricGrid::displayGrid( GLViewer *viewer,
alphaZ = std::max( 0.0f, std::min( 1.0f, (alphaZ-0.025f)*10.0f ) );
// Display the points representing the current grid scale.
if( m_EnableLabels )
{
glPointSize( 5.0f );
glBegin( GL_POINTS );
if( isAxisEnabled(X) )
......@@ -54,6 +56,7 @@ void MetricGrid::displayGrid( GLViewer *viewer,
glVertex3d( 0, 0, -spacing );
}
glEnd();
}
// display the lines corresponding to the colored axis.
glLineWidth( 1.5f );
......@@ -172,6 +175,8 @@ void MetricGrid::displayGrid( GLViewer *viewer,
glEnd();
// Display labels representing the current grid scale.
if( m_EnableLabels )
{
std::stringstream strStream;
strStream << spacing;
QString spacingStr = QString::fromStdString( strStream.str() );
......@@ -191,6 +196,7 @@ void MetricGrid::displayGrid( GLViewer *viewer,
glColor4ub( 130, 130, 255, alpha*alphaZ );
viewer->renderText( spacing/40.0, spacing/40.0, spacing, "Z = "+spacingStr, QApplication::font() );
}
}
}
......@@ -234,18 +240,18 @@ void MetricGrid::display( GLViewer *viewer )
QVector3D front = viewer->frontAxis();
if( std::abs(front.x()) == 1.0f )
{
m_EnabledGrids = YZ;
m_EnabledAxis = Y | Z;
m_EnabledGrids = m_EnableGridsOnAlignedOrtho? YZ : NONE;
m_EnabledAxis = m_EnableAxisOnAlignedOrtho? Y|Z : NONE;
}
else if( std::abs(front.y()) == 1.0f )
{
m_EnabledGrids = ZX;
m_EnabledAxis = Z | X;
m_EnabledGrids = m_EnableGridsOnAlignedOrtho? ZX : NONE;
m_EnabledAxis = m_EnableAxisOnAlignedOrtho? Z|X : NONE;
}
else if( std::abs(front.z()) == 1.0f )
{
m_EnabledGrids = XY;
m_EnabledAxis = X | Y;
m_EnabledGrids = m_EnableGridsOnAlignedOrtho? XY : NONE;
m_EnabledAxis = m_EnableAxisOnAlignedOrtho? X|Y : NONE;
}
}
......
......@@ -12,15 +12,9 @@
//#if _WIN32
//#include <windows.h>
//#endif
//#include <GL/gl.h>
class GLViewer;
class MetricGrid
{
/******************\
......@@ -49,6 +43,9 @@ public:
private:
int m_EnabledGrids;
int m_EnabledAxis;
bool m_EnableLabels;
bool m_EnableAxisOnAlignedOrtho;
bool m_EnableGridsOnAlignedOrtho;
/*****************************\
| Constructor(s) / destructor |
......@@ -56,12 +53,18 @@ private:
public:
inline MetricGrid() :
m_EnabledGrids(NONE),
m_EnabledAxis(ALL)
m_EnabledAxis(ALL),
m_EnableLabels(true),
m_EnableAxisOnAlignedOrtho(true),
m_EnableGridsOnAlignedOrtho(true)
{}
inline MetricGrid( int enabledGrids,
int enabledAxis ) :
m_EnabledGrids(enabledGrids),
m_EnabledAxis(enabledAxis)
m_EnabledAxis(enabledAxis),
m_EnableLabels(true),
m_EnableAxisOnAlignedOrtho(true),
m_EnableGridsOnAlignedOrtho(true)
{}
/********************\
......@@ -81,6 +84,18 @@ public:
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; }
inline void enableAxisOnAlignedOrtho() { m_EnableAxisOnAlignedOrtho = true; }
inline void disableAxisOnAlignedOrtho() { m_EnableAxisOnAlignedOrtho = false; }
inline bool areAxisOnAlignedOrthoEnabled() const { return m_EnableAxisOnAlignedOrtho; }
inline void enableGridsOnAlignedOrtho() { m_EnableGridsOnAlignedOrtho = true; }
inline void disableGridsOnAlignedOrtho() { m_EnableGridsOnAlignedOrtho = false; }
inline bool areGridsOnAlignedOrthoEnabled() const { return m_EnableGridsOnAlignedOrtho; }
void display( GLViewer *viewer );
};
......
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