From b28749ce34a46b7a4260b2842081d823e9dd1687 Mon Sep 17 00:00:00 2001 From: ana Date: Fri, 4 May 2012 12:16:09 +0000 Subject: [PATCH] "0021179: EDF 1654 SMESH GEOM: better look'n'feel" issue. Material Properties. --- .../GEOMToolsGUI_MaterialPropertiesDlg.cxx | 37 +++++++++---------- .../GEOMToolsGUI_MaterialPropertiesDlg.h | 12 +++--- src/OBJECT/GEOM_AISShape.cxx | 8 +++- 3 files changed, 29 insertions(+), 28 deletions(-) diff --git a/src/GEOMToolsGUI/GEOMToolsGUI_MaterialPropertiesDlg.cxx b/src/GEOMToolsGUI/GEOMToolsGUI_MaterialPropertiesDlg.cxx index ba9876064..63ab5af82 100644 --- a/src/GEOMToolsGUI/GEOMToolsGUI_MaterialPropertiesDlg.cxx +++ b/src/GEOMToolsGUI/GEOMToolsGUI_MaterialPropertiesDlg.cxx @@ -28,6 +28,7 @@ #include "GEOMBase.h" #include +#include #include #include #include @@ -52,17 +53,11 @@ #include #include #include -#include #include #define MARGIN 9 // layout spacing #define SPACING 6 // layout margin -// convert floating point value to the integer equivalent -#define COEF2INT(val) (int)(val*100.) -// convert integer value to the floating point equivalent -#define INT2COEF(val) (val/100.) - /*! \class GEOMToolsGUI_MaterialList \brief Internal class, used to handle context menu event from materials list @@ -145,10 +140,11 @@ GEOMToolsGUI_MaterialPropertiesDlg::GEOMToolsGUI_MaterialPropertiesDlg( QWidget* refl.color = new QtxColorButton( propWidget ); //refl.color->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); - refl.coef = new QSlider( Qt::Horizontal, propWidget ); - refl.coef->setRange( 0, 100 ); - refl.coef->setSingleStep( 1 ); - refl.coef->setPageStep( 10 ); + refl.coef = new QtxDoubleSpinBox( propWidget ); + refl.coef->setPrecision( 4 ); + refl.coef->setDecimals( 4 ); + refl.coef->setRange( 0., 1. ); + refl.coef->setSingleStep( 0.05 ); refl.enabled = new QCheckBox( tr( "ENABLED" ), propWidget ); @@ -157,10 +153,11 @@ GEOMToolsGUI_MaterialPropertiesDlg::GEOMToolsGUI_MaterialPropertiesDlg( QWidget* // shininess widgets QLabel* shininessLab = new QLabel( tr( "SHININESS" ), propWidget ); - myShininess = new QSlider( Qt::Horizontal, propWidget ); - myShininess->setRange( 0, 100 ); - myShininess->setSingleStep( 1 ); - myShininess->setPageStep( 10 ); + myShininess = new QtxDoubleSpinBox( propWidget ); + myShininess->setPrecision( 4 ); + myShininess->setDecimals( 4 ); + myShininess->setRange( 0., 1. ); + myShininess->setSingleStep( 0.05 ); // separator widgets QFrame* line1 = new QFrame( propWidget ); @@ -236,10 +233,10 @@ GEOMToolsGUI_MaterialPropertiesDlg::GEOMToolsGUI_MaterialPropertiesDlg( QWidget* connect( myPhysical, SIGNAL( toggled( bool ) ), this, SIGNAL( changed() ) ); for ( int i = Material_Model::Ambient; i <= Material_Model::Emissive; i++ ) { connect( myReflection[i].color, SIGNAL( changed( QColor ) ), this, SIGNAL( changed() ) ); - connect( myReflection[i].coef, SIGNAL( valueChanged( int ) ), this, SIGNAL( changed() ) ); + connect( myReflection[i].coef, SIGNAL( valueChanged( double ) ), this, SIGNAL( changed() ) ); connect( myReflection[i].enabled, SIGNAL( toggled( bool ) ), this, SIGNAL( changed() ) ); } - connect( myShininess, SIGNAL( valueChanged( int ) ), this, SIGNAL( changed() ) ); + connect( myShininess, SIGNAL( valueChanged( double ) ), this, SIGNAL( changed() ) ); connect( myMaterials, SIGNAL( itemSelectionChanged() ), this, SLOT( onMaterialChanged() ) ); connect( myMaterials, SIGNAL( itemChanged( QListWidgetItem* ) ), @@ -326,12 +323,12 @@ void GEOMToolsGUI_MaterialPropertiesDlg::fromModel( const Material_Model& model for ( int i = Material_Model::Ambient; i <= Material_Model::Emissive; i++ ) { myReflection[i].color->setColor( model.color( (Material_Model::ReflectionType)i ) ); - myReflection[i].coef->setValue( COEF2INT( model.reflection( (Material_Model::ReflectionType)i ) ) ); + myReflection[i].coef->setValue( model.reflection( (Material_Model::ReflectionType)i ) ); myReflection[i].enabled->setChecked( model.hasReflection( (Material_Model::ReflectionType)i ) ); } // shininess - myShininess->setValue( COEF2INT( model.shininess() ) ); + myShininess->setValue( model.shininess() ); // type (physical or no) myPhysical->setChecked( model.isPhysical() ); @@ -347,13 +344,13 @@ void GEOMToolsGUI_MaterialPropertiesDlg::toModel( Material_Model& model ) const model.setPhysical( myPhysical->isChecked() ); // shininess - model.setShininess( INT2COEF( myShininess->value() ) ); + model.setShininess( myShininess->value() ); // reflection components for ( int i = Material_Model::Ambient; i <= Material_Model::Emissive; i++ ) { model.setColor ( (Material_Model::ReflectionType)i, myReflection[i].color->color() ); - model.setReflection( (Material_Model::ReflectionType)i, INT2COEF( myReflection[i].coef->value() ) ); + model.setReflection( (Material_Model::ReflectionType)i, myReflection[i].coef->value() ); model.setReflection( (Material_Model::ReflectionType)i, myReflection[i].enabled->isChecked() ); } } diff --git a/src/GEOMToolsGUI/GEOMToolsGUI_MaterialPropertiesDlg.h b/src/GEOMToolsGUI/GEOMToolsGUI_MaterialPropertiesDlg.h index 328f5f99a..1e2a7c6f7 100644 --- a/src/GEOMToolsGUI/GEOMToolsGUI_MaterialPropertiesDlg.h +++ b/src/GEOMToolsGUI/GEOMToolsGUI_MaterialPropertiesDlg.h @@ -33,7 +33,7 @@ class QCheckBox; class QLabel; class QPushButton; -class QSlider; +class QtxDoubleSpinBox; class QtxColorButton; class GEOMToolsGUI_MaterialList; @@ -76,16 +76,16 @@ private slots: private: typedef struct { - QLabel* label; - QtxColorButton* color; - QSlider* coef; - QCheckBox* enabled; + QLabel* label; + QtxColorButton* color; + QtxDoubleSpinBox* coef; + QCheckBox* enabled; } Reflection; GEOMToolsGUI_MaterialList* myMaterials; QCheckBox* myPhysical; QList myReflection; - QSlider* myShininess; + QtxDoubleSpinBox* myShininess; QLabel* myColorLab; QtxColorButton* myColor; QPushButton* myAddButton; diff --git a/src/OBJECT/GEOM_AISShape.cxx b/src/OBJECT/GEOM_AISShape.cxx index 5d4422acb..a50c92c23 100644 --- a/src/OBJECT/GEOM_AISShape.cxx +++ b/src/OBJECT/GEOM_AISShape.cxx @@ -398,8 +398,12 @@ void GEOM_AISShape::shadingMode(const Handle(PrsMgr_PresentationManager3d)& aPre //a4bis->SetInteriorColor(myShadingColor); if( isTopLevel() ) myDrawer->ShadingAspect()->SetColor( topLevelColor() ); - else if(myDrawer->ShadingAspect()->Aspect()->FrontMaterial().MaterialType( Graphic3d_MATERIAL_ASPECT )) - myDrawer->ShadingAspect()->SetColor(myShadingColor); + else { + if(myDrawer->ShadingAspect()->Aspect()->FrontMaterial().MaterialType( Graphic3d_MATERIAL_ASPECT )) + myDrawer->ShadingAspect()->SetColor(myShadingColor); + else + myDrawer->ShadingAspect()->SetColor(myDrawer->ShadingAspect()->Aspect()->FrontMaterial().AmbientColor()); + } // PAL12113: AIS_Shape::Compute() works correctly with shapes containing no faces //StdPrs_ShadedShape::Add(aPrs,myshape,myDrawer); -- 2.39.2