Commit 25f90a57 authored by Frédéric Larue's avatar Frédéric Larue

Button for restoring default values added to the render option dialog.

parent edb867ba
......@@ -2113,6 +2113,8 @@ void UIMainWindow::showRenderingOptionDialog()
dlg.Add( new UIParamSlider("amb", "Ambient", "Strength of the light ambient component (as a factor of the light color).", 1000*GLViewer::Ambient, 0, 1000, 50) );
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 UIParamAction("default", "Restore default values", "Restore default values.") );
connect( &dlg.GetParameters(), SIGNAL(parameterUpdated(UIParam*)), this, SLOT(renderOptionParameterModified(UIParam*)) );
......@@ -2137,6 +2139,7 @@ void UIMainWindow::showRenderingOptionDialog()
void UIMainWindow::renderOptionParameterModified( UIParam *p )
{
std::function<QVector3D(const QColor&)> ColorToVector = []( const QColor &col ) { return QVector3D( col.red(), col.green(), col.blue() ) / 255.0f; };
std::function<QColor(const QVector3D&)> VectorToColor = []( const QVector3D &vec ) { return QColor( int(255.0f*vec.x()), int(255.0f*vec.y()), int(255.0f*vec.z()) ); };
if( p->Id() == "bgTop" )
GLViewer::BgTopColor = ColorToVector( ((UIParamColorRGB*) p)->Value() );
......@@ -2154,8 +2157,19 @@ 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() == "default" )
{
UIParamSet *params = p->Group();
params->GetColorRGB("bgTop")->SetValue( palette().color(QPalette::Light) );
params->GetColorRGB("bgBottom")->SetValue( palette().color(QPalette::Dark) );
params->GetColorRGB("cool")->SetValue( VectorToColor(QVector3D(0.5f, 0.0f, 1.0f)) );
params->GetColorRGB("warm")->SetValue( VectorToColor(QVector3D(1.0f, 0.8f, 0.0f)) );
params->GetColorRGB("diff")->SetValue( VectorToColor(QVector3D(1.0f, 1.0f, 1.0f)) );
params->GetSlider("amb")->SetValue( 1000*0.1f );
params->GetSlider("spec")->SetValue( 1000*0.5f );
params->GetSlider("shin")->SetValue( 80.0f );
}
updateRenderOptions();
getCurrentViewer()->update();
}
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