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

If GLViewer use an orthographic projection and the view direction is aligned...

If GLViewer use an orthographic projection and the view direction is aligned with one of the axes, display the grid and axes corresponding to the other two.
parent 7a67efee
......@@ -205,12 +205,14 @@ void MetricGrid::display( GLViewer *viewer )
// Determine the current grid spacing wrt. the distance between the viewpoint and the focus point.
double log10Dist = std::log10( 1.75*viewer->distToFocusPoint() );
int log10DistI = (int) std::floor( log10Dist );
double scaleFactor = std::pow( 10.0, (double)log10DistI );
// Determine the alpha value for smooth transitions between successive grid scales.
GLubyte alpha;
if( log10Dist-log10DistI < 0.5 )
{
......@@ -222,7 +224,34 @@ void MetricGrid::display( GLViewer *viewer )
alpha = 0;
// If the viewer use an orthographic projection and the view direction is aligned with one of the axes, display the grid and axes corresponding to the other two.
int gridsBackup = m_EnabledGrids;
int axisBackup = m_EnabledAxis;
if( viewer->isProjectionOrthographic() )
{
QVector3D front = viewer->frontAxis();
if( std::abs(front.x()) == 1.0f )
{
m_EnabledGrids = YZ;
m_EnabledAxis = Y | Z;
}
else if( std::abs(front.y()) == 1.0f )
{
m_EnabledGrids = ZX;
m_EnabledAxis = Z | X;
}
else if( std::abs(front.z()) == 1.0f )
{
m_EnabledGrids = XY;
m_EnabledAxis = X | Y;
}
}
// Display the grid using three different grid spacings.
glDisable( GL_LIGHTING );
glEnable( GL_LINE_SMOOTH );
glHint( GL_LINE_SMOOTH_HINT, GL_NICEST );
......@@ -239,5 +268,13 @@ void MetricGrid::display( GLViewer *viewer )
displayGrid( viewer, 0.1*scaleFactor, alpha );
// Restore the previously backed up state.
if( viewer->isProjectionOrthographic() )
{
m_EnabledGrids = gridsBackup;
m_EnabledAxis = axisBackup;
}
glPopAttrib();
}
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