Commit 4da2dc4f authored by Frédéric Larue's avatar Frédéric Larue

Line width in GLViewer set as a render option in the GUI.

parent 8d729fb7
......@@ -36,6 +36,8 @@ float GLViewer::Ambient = 0.1f;
float GLViewer::Specular = 0.5f;
float GLViewer::Shininess = 80.0f;
float GLViewer::LineWidth = 0.5f;
QString GLViewer::s_MetricGrid2DSuffix;
QString GLViewer::s_MetricGrid3DSuffix;
......
......@@ -156,6 +156,8 @@ public:
static float Specular;
static float Shininess;
static float LineWidth;
/********************\
| Member variable(s) |
\********************/
......
......@@ -2123,6 +2123,9 @@ bool UIMainWindow::initRenderOptions()
if( settings->contains( "RenderOptions/shininess") )
GLViewer::Shininess = settings->value( "RenderOptions/shininess" ).toFloat();
if( settings->contains( "RenderOptions/lineWidth") )
GLViewer::LineWidth = settings->value( "RenderOptions/lineWidth" ).toFloat();
GLViewer::AmbientColor = GLViewer::LightColor * GLViewer::Ambient;
GLViewer::SpecularColor = GLViewer::LightColor * GLViewer::Specular;
......@@ -2153,6 +2156,8 @@ bool UIMainWindow::updateRenderOptions()
settings->setValue( "specular" , QVariant( GLViewer::Specular ) );
settings->setValue( "shininess" , QVariant( GLViewer::Shininess ) );
settings->setValue( "lineWidth" , QVariant( GLViewer::LineWidth ) );
settings->endGroup();
GLViewer::AmbientColor = GLViewer::LightColor * GLViewer::Ambient;
......@@ -2175,7 +2180,8 @@ void UIMainWindow::showRenderingOptionDialog()
QVector3D specularColorBackup = GLViewer::SpecularColor;
float ambientBackup = GLViewer::Ambient;
float specularBackup = GLViewer::Specular;
float shininessBackup = GLViewer::Shininess;;
float shininessBackup = GLViewer::Shininess;
float lineWidthBackup = GLViewer::LineWidth;
UIParamDialog dlg( "Render options", this );
int thisScreenId = QApplication::desktop()->screenNumber( this );
......@@ -2192,6 +2198,8 @@ void UIMainWindow::showRenderingOptionDialog()
dlg.Add( new UIParamSlider("spec", "Specular", "Strength of the light specular component (as a factor of the light color).", 1000*GLViewer::Specular, 0, 1000, 50) );
dlg.Add( new UIParamSlider("shin", "Shininess", "Thickness of the specular lobe.", GLViewer::Shininess, 0, 200, 10) );
dlg.AddSeparator();
dlg.Add( new UIParamSlider("line", "Wireframe width", "Line thickness when meshes are displayed in wireframe mode.", 2*GLViewer::LineWidth, 1, 10, 1) );
dlg.AddSeparator();
dlg.Add( new UIParamGradient("grad", "Default color map", "Default color map.",QColor(0,0,0), QColor(255,255,255)) );
dlg.AddSeparator();
dlg.Add( new UIParamAction("default", "Restore default values", "Restore default values.") );
......@@ -2210,6 +2218,7 @@ void UIMainWindow::showRenderingOptionDialog()
GLViewer::Ambient = ambientBackup;
GLViewer::Specular = specularBackup;
GLViewer::Shininess = shininessBackup;
GLViewer::LineWidth = lineWidthBackup;
updateRenderOptions();
}
......@@ -2237,6 +2246,8 @@ void UIMainWindow::renderOptionParameterModified( UIParam *p )
GLViewer::Specular = ((UIParamSlider*) p)->Value() * 0.001f;
else if( p->Id() == "shin" )
GLViewer::Shininess = ((UIParamSlider*) p)->Value();
else if( p->Id() == "line" )
GLViewer::LineWidth = ((UIParamSlider*) p)->Value() * 0.5f;
else if( p->Id() == "default" )
{
UIParamSet *params = p->Group();
......@@ -2248,6 +2259,7 @@ void UIMainWindow::renderOptionParameterModified( UIParam *p )
params->GetSlider("amb")->SetValue( 1000*0.1f );
params->GetSlider("spec")->SetValue( 1000*0.5f );
params->GetSlider("shin")->SetValue( 80.0f );
params->GetSlider("line")->SetValue( 1 );
}
updateRenderOptions();
......
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