Fix for the "0021179: EDF 1654 SMESH GEOM: better look'n'feel" issue:

- Material Properties
This commit is contained in:
ana 2012-04-13 11:09:23 +00:00
parent 46c866d149
commit 2e342cb5f3
22 changed files with 469 additions and 800 deletions

View File

@ -56,8 +56,7 @@
<parameter name="base_vectors_length" value="1" /> <parameter name="base_vectors_length" value="1" />
<parameter name="marker_scale" value="1" /> <parameter name="marker_scale" value="1" />
<parameter name="geom_preview" value="false" /> <parameter name="geom_preview" value="false" />
<parameter name="front_material" value="Gold" /> <parameter name="material" value="Plastic" />
<parameter name="back_material" value="Gold" />
<parameter name="edge_width" value="1" /> <parameter name="edge_width" value="1" />
<parameter name="isolines_width" value="1" /> <parameter name="isolines_width" value="1" />
<parameter name="preview_edge_width" value="1" /> <parameter name="preview_edge_width" value="1" />

View File

@ -28,6 +28,8 @@
#include "GeometryGUI.h" #include "GeometryGUI.h"
#include "GEOM_Displayer.h" #include "GEOM_Displayer.h"
#include "Material_Model.h"
#include <GEOM_Constants.h> #include <GEOM_Constants.h>
#include <SalomeApp_Application.h> #include <SalomeApp_Application.h>
@ -54,11 +56,16 @@
#include <GEOMImpl_Types.hxx> #include <GEOMImpl_Types.hxx>
#include <GEOM_AISShape.hxx> #include <GEOM_AISShape.hxx>
#include <GEOM_VTKPropertyMaterial.hxx>
// OCCT Includes // OCCT Includes
#include <AIS.hxx> #include <AIS.hxx>
#include <AIS_InteractiveObject.hxx> #include <AIS_InteractiveObject.hxx>
#include <AIS_ListOfInteractive.hxx> #include <AIS_ListOfInteractive.hxx>
#include <AIS_GraphicTool.hxx>
#include <AIS_Drawer.hxx>
#include <Prs3d_ShadingAspect.hxx>
#include<Graphic3d_MaterialAspect.hxx>
// VTK Includes // VTK Includes
#include <vtkActorCollection.h> #include <vtkActorCollection.h>
@ -159,6 +166,8 @@ QVariant GEOMGUI_Selection::parameter( const int idx, const QString& p ) const
v = compoundOfVertices( idx ); v = compoundOfVertices( idx );
else if ( p == "imported" ) else if ( p == "imported" )
v = isImported( idx ); v = isImported( idx );
else if ( p == "isPhysicalMaterial" )
v = isPhysicalMaterial(idx);
else else
v = LightApp_Selection::parameter( idx, p ); v = LightApp_Selection::parameter( idx, p );
@ -313,7 +322,7 @@ QString GEOMGUI_Selection::displayMode( const int index ) const
} }
} }
} }
else if ( viewType == SVTK_Viewer::Type() ) { // assuming VTK else if ( viewType == SVTK_Viewer::Type() ) { // assuming VTK
SVTK_Prs* vtkPrs = dynamic_cast<SVTK_Prs*>( prs ); SVTK_Prs* vtkPrs = dynamic_cast<SVTK_Prs*>( prs );
vtkActorCollection* lst = vtkPrs ? vtkPrs->GetObjects() : 0; vtkActorCollection* lst = vtkPrs ? vtkPrs->GetObjects() : 0;
if ( lst ) { if ( lst ) {
@ -517,7 +526,7 @@ QString GEOMGUI_Selection::selectionMode() const
bool GEOMGUI_Selection::topLevel( const int index ) const { bool GEOMGUI_Selection::topLevel( const int index ) const {
bool res = false; bool res = false;
#ifdef USE_VISUAL_PROP_MAP #ifdef USE_VISUAL_PROP_MAP
bool found = false; bool found = false;
QVariant v = visibleProperty( entry( index ), TOP_LEVEL_PROP ); QVariant v = visibleProperty( entry( index ), TOP_LEVEL_PROP );
@ -551,3 +560,57 @@ bool GEOMGUI_Selection::topLevel( const int index ) const {
} }
return res; return res;
} }
bool GEOMGUI_Selection::isPhysicalMaterial( const int idx ) const{
bool res = false;
#ifdef USE_VISUAL_PROP_MAP
bool found = false;
QVariant v = visibleProperty( entry( idx ), MATERIAL_PROP );
if ( v.canConvert<QString>() ) {
Material_Model* aModel = Material_Model::getMaterialModel( v.toString().split(DIGIT_SEPARATOR) );
res = aModel->isPhysical();
found = true;
}
if ( !found ) {
#endif
SALOME_View* view = GEOM_Displayer::GetActiveView();
QString viewType = activeViewType();
if ( view ) {
SALOME_Prs* prs = view->CreatePrs( entry( idx ).toLatin1().constData() );
if ( prs ) {
if ( viewType == OCCViewer_Viewer::Type() ) { // assuming OCC
SOCC_Prs* occPrs = (SOCC_Prs*) prs;
AIS_ListOfInteractive lst;
occPrs->GetObjects( lst );
if ( lst.Extent() ) {
Handle(AIS_InteractiveObject) io = lst.First();
if ( !io.IsNull() ) {
Handle(GEOM_AISShape) aSh = Handle(GEOM_AISShape)::DownCast(io);
if ( !aSh.IsNull() )
res =(bool) aSh->Attributes()->ShadingAspect()->
Material(Aspect_TypeOfFacingModel::Aspect_TOFM_BOTH_SIDE).MaterialType( Graphic3d_MATERIAL_PHYSIC );
}
}
}
else if ( viewType == SVTK_Viewer::Type() ) { // assuming VTK
SVTK_Prs* vtkPrs = dynamic_cast<SVTK_Prs*>( prs );
vtkActorCollection* lst = vtkPrs ? vtkPrs->GetObjects() : 0;
if ( lst ) {
lst->InitTraversal();
vtkActor* actor = lst->GetNextActor();
if ( actor ) {
GEOM_Actor* aGeomGActor = GEOM_Actor::SafeDownCast( actor );
if ( aGeomGActor ) {
GEOM_VTKPropertyMaterial* mat = GEOM_VTKPropertyMaterial::SafeDownCast(aGeomGActor->GetProperty());
res = mat->GetPhysical();
} // if ( salome actor )
} // if ( actor )
} // if ( lst == vtkPrs->GetObjects() )
}
}
}
}
return res;
}

View File

@ -70,6 +70,7 @@ private:
bool hasShownChildren( const int ) const; bool hasShownChildren( const int ) const;
bool compoundOfVertices( const int ) const; bool compoundOfVertices( const int ) const;
bool topLevel( const int ) const; bool topLevel( const int ) const;
bool isPhysicalMaterial( const int ) const;
bool isComponent( const int ) const; bool isComponent( const int ) const;
GEOM::GEOM_Object_ptr getObject( const int ) const; GEOM::GEOM_Object_ptr getObject( const int ) const;

View File

@ -42,6 +42,7 @@
#include <GEOM_AISVector.hxx> #include <GEOM_AISVector.hxx>
#include <GEOM_AISTrihedron.hxx> #include <GEOM_AISTrihedron.hxx>
#include <GEOM_VTKTrihedron.hxx> #include <GEOM_VTKTrihedron.hxx>
#include <GEOM_VTKPropertyMaterial.hxx>
#include <Material_Model.h> #include <Material_Model.h>
@ -810,7 +811,7 @@ void GEOM_Displayer::Update( SALOME_OCCPrs* prs )
anAspect = AISShape->Attributes()->UnFreeBoundaryAspect(); anAspect = AISShape->Attributes()->UnFreeBoundaryAspect();
anAspect->SetColor( aColor ); anAspect->SetColor( aColor );
AISShape->Attributes()->SetUnFreeBoundaryAspect( anAspect ); AISShape->Attributes()->SetUnFreeBoundaryAspect( anAspect );
AISShape->storeBoundaryColors(); AISShape->storeBoundaryColors();
// Set free boundaries aspect // Set free boundaries aspect
col = aResMgr->colorValue( "Geometry", "free_bound_color", QColor( 0, 255, 0 ) ); col = aResMgr->colorValue( "Geometry", "free_bound_color", QColor( 0, 255, 0 ) );
@ -828,10 +829,10 @@ void GEOM_Displayer::Update( SALOME_OCCPrs* prs )
anAspect->SetColor( aColor ); anAspect->SetColor( aColor );
AISShape->Attributes()->SetWireAspect( anAspect ); AISShape->Attributes()->SetWireAspect( anAspect );
// Set color for edges in shading // Set color for edges in shading
col = aResMgr->colorValue( "Geometry", "edges_in_shading_color", QColor( 255, 255, 0 ) ); col = aResMgr->colorValue( "Geometry", "edges_in_shading_color", QColor( 255, 255, 0 ) );
aColor = SalomeApp_Tools::color( col ); aColor = SalomeApp_Tools::color( col );
AISShape->SetEdgesInShadingColor( aColor ); AISShape->SetEdgesInShadingColor( aColor );
// bug [SALOME platform 0019868] // bug [SALOME platform 0019868]
// Set deviation angle. Default one is 12 degrees (Prs3d_Drawer.cxx:18) // Set deviation angle. Default one is 12 degrees (Prs3d_Drawer.cxx:18)
@ -841,8 +842,8 @@ void GEOM_Displayer::Update( SALOME_OCCPrs* prs )
double aDC = 0; double aDC = 0;
if(useStudy) { if(useStudy) {
aDC = aPropMap.value(DEFLECTION_COEFF_PROP).toDouble(); aDC = aPropMap.value(DEFLECTION_COEFF_PROP).toDouble();
SetWidth(aPropMap.value(EDGE_WIDTH_PROP).toInt()); SetWidth(aPropMap.value(EDGE_WIDTH_PROP).toInt());
SetIsosWidth(aPropMap.value(ISOS_WIDTH_PROP).toInt()); SetIsosWidth(aPropMap.value(ISOS_WIDTH_PROP).toInt());
} }
else { else {
aDC = aResMgr->doubleValue("Geometry", "deflection_coeff", 0.001); aDC = aResMgr->doubleValue("Geometry", "deflection_coeff", 0.001);
@ -961,62 +962,30 @@ void GEOM_Displayer::Update( SALOME_OCCPrs* prs )
// get material properties, set material // get material properties, set material
Material_Model* aModelF = 0; Material_Model* aModelF = 0;
Material_Model* aModelB = 0;
if ( useStudy ) { if ( useStudy ) {
// Get front material property from study and construct front material model // Get material property from study and construct material model
QString aMaterialF = aPropMap.value(FRONT_MATERIAL_PROP).toString(); QString aMaterialF = aPropMap.value(MATERIAL_PROP).toString();
QStringList aProps = aMaterialF.split(DIGIT_SEPARATOR); QStringList aProps = aMaterialF.split(DIGIT_SEPARATOR);
aModelF = Material_Model::getMaterialModel( aProps ); aModelF = Material_Model::getMaterialModel( aProps );
// Get back material property from study and construct back material model
QString aMaterialB = aPropMap.value(BACK_MATERIAL_PROP).toString();
if ( !aMaterialB.isEmpty() ) {
QStringList aPropsB = aMaterialB.split(DIGIT_SEPARATOR);
aModelB = Material_Model::getMaterialModel( aPropsB );
}
else
aModelB = aModelF;
} else { } else {
// Get front material property from study and construct front material model // Get material property from study and construct material model
aModelF = new Material_Model(); aModelF = new Material_Model();
aModelF->fromResources( aResMgr, "Geometry", true ); aModelF->fromResources( aResMgr, "Geometry" );
// Get back material property from study and construct back material model
aModelB = new Material_Model();
aModelB->fromResources( aResMgr, "Geometry", false );
} }
// Set front material property // Set material property
QString aMaterialPropF = aModelF->getMaterialProperty(); QString aMaterialPropF = aModelF->getMaterialProperty();
aStudy->setObjectProperty( aMgrId, anIO->getEntry(), FRONT_MATERIAL_PROP, aMaterialPropF ); aStudy->setObjectProperty( aMgrId, anIO->getEntry(), MATERIAL_PROP, aMaterialPropF );
// Set back material property // Get material properties from the model
QString aMaterialPropB = aModelB->getMaterialProperty();
aStudy->setObjectProperty( aMgrId, anIO->getEntry(), BACK_MATERIAL_PROP, aMaterialPropB );
// Get front material properties from the model
Graphic3d_MaterialAspect aMatF = aModelF->getMaterialOCCAspect(); Graphic3d_MaterialAspect aMatF = aModelF->getMaterialOCCAspect();
// Get back material properties from the model // Set material for the selected shape
Graphic3d_MaterialAspect aMatB = aModelB->getMaterialOCCAspect(); AISShape->SetMaterial(aMatF);
// Set front material for the selected shape
AISShape->SetCurrentFacingModel(Aspect_TOFM_FRONT_SIDE);
AISShape->SetMaterial(aMatF);
// Set back material for the selected shape
AISShape->SetCurrentFacingModel(Aspect_TOFM_BACK_SIDE);
AISShape->SetMaterial(aMatB);
// Return to the default facing mode
AISShape->SetCurrentFacingModel(Aspect_TOFM_BOTH_SIDE);
// Release memory // Release memory
if ( aModelF ) if ( aModelF )
delete aModelF; delete aModelF;
if ( aModelB )
delete aModelB;
if(HasWidth()) if(HasWidth())
aStudy->setObjectProperty( aMgrId, anIO->getEntry(), EDGE_WIDTH_PROP, GetWidth() ); aStudy->setObjectProperty( aMgrId, anIO->getEntry(), EDGE_WIDTH_PROP, GetWidth() );
@ -1205,52 +1174,21 @@ void GEOM_Displayer::Update( SALOME_VTKPrs* prs )
aGeomGActor->setDisplayMode(aDispModeId); aGeomGActor->setDisplayMode(aDispModeId);
aGeomGActor->SetDeflection(aPropMap.value(DEFLECTION_COEFF_PROP).toDouble()); aGeomGActor->SetDeflection(aPropMap.value(DEFLECTION_COEFF_PROP).toDouble());
// Get front material property of the object stored in the study // Get material property of the object stored in the study
QString aMaterialF = aPropMap.value(FRONT_MATERIAL_PROP).toString(); QString aMaterialF = aPropMap.value(MATERIAL_PROP).toString();
QStringList aPropsF = aMaterialF.split(DIGIT_SEPARATOR); QStringList aPropsF = aMaterialF.split(DIGIT_SEPARATOR);
// Create front material model // Create material model
Material_Model* aModelF = Material_Model::getMaterialModel( aPropsF ); Material_Model* aModelF = Material_Model::getMaterialModel( aPropsF );
// Set front material properties for the object // Set material properties for the object
QString aMaterialPropF = aModelF->getMaterialProperty(); QString aMaterialPropF = aModelF->getMaterialProperty();
aStudy->setObjectProperty( aMgrId, anEntry, FRONT_MATERIAL_PROP, aMaterialPropF ); aStudy->setObjectProperty( aMgrId, anEntry, MATERIAL_PROP, aMaterialPropF );
// Get material properties from the front model // Get material properties from the model
vtkProperty* aMatPropF = aModelF->getMaterialVTKProperty(); GEOM_VTKPropertyMaterial* aMatPropF = aModelF->getMaterialVTKProperty();
// Set the same front and back materials for the selected shape
std::vector<vtkProperty*> aProps;
aProps.push_back( (vtkProperty*) aMatPropF );
aGeomGActor->SetMaterial(aProps);
// Get back material property of the object stored in the study
QString aMaterialB = aPropMap.value(BACK_MATERIAL_PROP).toString();
if ( !aMaterialB.isEmpty() ) {
QStringList aPropsB = aMaterialB.split(DIGIT_SEPARATOR);
// Create back material model
Material_Model* aModelB = Material_Model::getMaterialModel( aPropsB );
// Set back material properties for the object
QString aMaterialPropB = aModelB->getMaterialProperty();
aStudy->setObjectProperty( aMgrId, anEntry, BACK_MATERIAL_PROP, aMaterialPropB );
// Get material properties from the back model
vtkProperty* aMatPropB = aModelB->getMaterialVTKProperty();
// Set front and back materials for the selected shape
std::vector<vtkProperty*> aProps;
aProps.push_back(aMatPropF);
aProps.push_back(aMatPropB);
aGeomGActor->SetMaterial(aProps);
// Release memory
delete aModelB;
if(HasWidth())
aStudy->setObjectProperty( aMgrId, anEntry, EDGE_WIDTH_PROP, GetWidth() );
if(HasIsosWidth())
aStudy->setObjectProperty( aMgrId, anEntry, ISOS_WIDTH_PROP, GetIsosWidth() );
}
else {
// Set the same front and back materials for the selected shape
std::vector<vtkProperty*> aProps;
aProps.push_back(aMatPropF);
aGeomGActor->SetMaterial(aProps);
}
// Release memory // Release memory
delete aModelF; delete aModelF;
@ -1284,37 +1222,26 @@ void GEOM_Displayer::Update( SALOME_VTKPrs* prs )
} }
} }
} }
aGeomGActor->SetColor(aColor[0],aColor[1],aColor[2]); if ( !aMatPropF->GetPhysical() )
aGeomGActor->SetColor(aColor[0],aColor[1],aColor[2]);
} }
else { else {
SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr(); SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
if ( aResMgr ) { if ( aResMgr ) {
// Create front material model // Create material model
Material_Model aModelF; Material_Model aModelF;
// Get front material name from resources // Get material name from resources
aModelF.fromResources( aResMgr, "Geometry", true ); aModelF.fromResources( aResMgr, "Geometry" );
// Set front material properties for the object // Set material properties for the object
QString aMaterialPropF = aModelF.getMaterialProperty(); QString aMaterialPropF = aModelF.getMaterialProperty();
aStudy->setObjectProperty( aMgrId, anEntry, FRONT_MATERIAL_PROP, aMaterialPropF ); aStudy->setObjectProperty( aMgrId, anEntry, MATERIAL_PROP, aMaterialPropF );
// Get material properties from the front model // Get material properties from the model
vtkProperty* aMatPropF = aModelF.getMaterialVTKProperty(); GEOM_VTKPropertyMaterial* aMatPropF = aModelF.getMaterialVTKProperty();
// Create back material model
Material_Model aModelB;
// Get back material name from resources
aModelB.fromResources( aResMgr, "Geometry", false );
// Set back material properties for the object
QString aMaterialPropB = aModelB.getMaterialProperty();
aStudy->setObjectProperty( aMgrId, anEntry, BACK_MATERIAL_PROP, aMaterialPropB );
// Get material properties from the back model
vtkProperty* aMatPropB = aModelB.getMaterialVTKProperty();
// Set material for the selected shape // Set material for the selected shape
std::vector<vtkProperty*> aProps; std::vector<vtkProperty*> aProps;
aProps.push_back(aMatPropF); aProps.push_back( (vtkProperty*) aMatPropF );
aProps.push_back(aMatPropB); aGeomGActor->SetMaterial(aProps); }
aGeomGActor->SetMaterial(aProps);
}
} }
} }
@ -2010,23 +1937,16 @@ PropMap GEOM_Displayer::getDefaultPropertyMap(const QString& viewer_type) {
aDefaultMap.insert( DEFLECTION_COEFF_PROP , aDC); aDefaultMap.insert( DEFLECTION_COEFF_PROP , aDC);
//8. Material //8. Material
// Front material
Material_Model aModelF; Material_Model aModelF;
aModelF.fromResources( aResMgr, "Geometry", true ); aModelF.fromResources( aResMgr, "Geometry" );
QString aMaterialF = aModelF.getMaterialProperty(); QString aMaterialF = aModelF.getMaterialProperty();
aDefaultMap.insert( FRONT_MATERIAL_PROP , aMaterialF ); aDefaultMap.insert( MATERIAL_PROP , aMaterialF );
//9. Back material //9. Width of the edges
Material_Model aModelB;
aModelB.fromResources( aResMgr, "Geometry", false );
QString aMaterialB = aModelB.getMaterialProperty();
aDefaultMap.insert( BACK_MATERIAL_PROP , aMaterialB );
//10. Width of the edges
aDefaultMap.insert( EDGE_WIDTH_PROP , aResMgr->integerValue("Geometry", "edge_width", 1)); aDefaultMap.insert( EDGE_WIDTH_PROP , aResMgr->integerValue("Geometry", "edge_width", 1));
//11. Width of iso-lines //10. Width of iso-lines
aDefaultMap.insert( ISOS_WIDTH_PROP , aResMgr->integerValue("Geometry", "isolines_width", 1)); aDefaultMap.insert( ISOS_WIDTH_PROP , aResMgr->integerValue("Geometry", "isolines_width", 1));
if(viewer_type == SOCC_Viewer::Type()) { if(viewer_type == SOCC_Viewer::Type()) {
@ -2063,12 +1983,8 @@ bool GEOM_Displayer::MergePropertyMaps(PropMap& theOrigin, PropMap& theDefault)
theOrigin.insert(DEFLECTION_COEFF_PROP, theDefault.value(DEFLECTION_COEFF_PROP)); theOrigin.insert(DEFLECTION_COEFF_PROP, theDefault.value(DEFLECTION_COEFF_PROP));
nbInserted++; nbInserted++;
} }
if(!theOrigin.contains(FRONT_MATERIAL_PROP)) { if(!theOrigin.contains(MATERIAL_PROP)) {
theOrigin.insert(FRONT_MATERIAL_PROP, theDefault.value(FRONT_MATERIAL_PROP)); theOrigin.insert(MATERIAL_PROP, theDefault.value(MATERIAL_PROP));
nbInserted++;
}
if(!theOrigin.contains(BACK_MATERIAL_PROP)) {
theOrigin.insert(BACK_MATERIAL_PROP, theDefault.value(BACK_MATERIAL_PROP));
nbInserted++; nbInserted++;
} }
@ -2082,6 +1998,11 @@ bool GEOM_Displayer::MergePropertyMaps(PropMap& theOrigin, PropMap& theDefault)
nbInserted++; nbInserted++;
} }
if(!theOrigin.contains(COLOR_PROP)) {
theOrigin.insert(COLOR_PROP, theDefault.value(COLOR_PROP));
nbInserted++;
}
return (nbInserted > 0); return (nbInserted > 0);
} }

View File

@ -3015,12 +3015,8 @@ Please, select face, shell or solid and try again</translation>
<translation>Default wireframe color</translation> <translation>Default wireframe color</translation>
</message> </message>
<message> <message>
<source>PREF_FRONT_MATERIAL</source> <source>PREF_MATERIAL</source>
<translation>Default front material</translation> <translation>Default material</translation>
</message>
<message>
<source>PREF_BACK_MATERIAL</source>
<translation>Default back material</translation>
</message> </message>
<message> <message>
<source>PREF_EDGE_WIDTH</source> <source>PREF_EDGE_WIDTH</source>
@ -5274,6 +5270,10 @@ Would you like to continue?</translation>
<source>SHININESS</source> <source>SHININESS</source>
<translation>Shininess:</translation> <translation>Shininess:</translation>
</message> </message>
<message>
<source>PHYSICAL</source>
<translation>Physical:</translation>
</message>
<message> <message>
<source>CUSTOM_MATERIAL</source> <source>CUSTOM_MATERIAL</source>
<translation>Custom material</translation> <translation>Custom material</translation>

View File

@ -5274,6 +5274,10 @@ Voulez-vous continuer?</translation>
<source>SHININESS</source> <source>SHININESS</source>
<translation>Shininess:</translation> <translation>Shininess:</translation>
</message> </message>
<message>
<source>PHYSICAL</source>
<translation>Physical:</translation>
</message>
<message> <message>
<source>CUSTOM_MATERIAL</source> <source>CUSTOM_MATERIAL</source>
<translation>Matériau personnalisé</translation> <translation>Matériau personnalisé</translation>

View File

@ -591,10 +591,7 @@ void GeometryGUI::OnGUIEvent( int id )
if ( pref ) { if ( pref ) {
Material_ResourceMgr aMatResMgr; Material_ResourceMgr aMatResMgr;
QStringList aPerfMatNames = aMatResMgr.getPreferenceMaterialsNames(); QStringList aPerfMatNames = aMatResMgr.getPreferenceMaterialsNames();
setPreferenceProperty( pref->rootItem()->findItem( tr( "PREF_FRONT_MATERIAL" ), true )->id(), setPreferenceProperty( pref->rootItem()->findItem( tr( "PREF_MATERIAL" ), true )->id(),
"strings",
aPerfMatNames );
setPreferenceProperty( pref->rootItem()->findItem( tr( "PREF_BACK_MATERIAL" ), true )->id(),
"strings", "strings",
aPerfMatNames ); aPerfMatNames );
} }
@ -1250,7 +1247,7 @@ void GeometryGUI::initialize( CAM_Application* app )
mgr->setRule( action( GEOMOp::OpVectors ), clientOCCorVTK + " and isVectorsMode", QtxPopupMgr::ToggleRule ); mgr->setRule( action( GEOMOp::OpVectors ), clientOCCorVTK + " and isVectorsMode", QtxPopupMgr::ToggleRule );
mgr->insert( separator(), -1, -1 ); // ----------- mgr->insert( separator(), -1, -1 ); // -----------
mgr->insert( action( GEOMOp::OpColor ), -1, -1 ); // color mgr->insert( action( GEOMOp::OpColor ), -1, -1 ); // color
mgr->setRule( action( GEOMOp::OpColor ), clientOCCorVTKorOB_AndSomeVisible + " and ($component={'GEOM'})", QtxPopupMgr::VisibleRule ); mgr->setRule( action( GEOMOp::OpColor ), clientOCCorVTKorOB_AndSomeVisible + " and ($component={'GEOM'})" + "and isPhysicalMaterial=false", QtxPopupMgr::VisibleRule );
mgr->insert( action( GEOMOp::OpTransparency ), -1, -1 ); // transparency mgr->insert( action( GEOMOp::OpTransparency ), -1, -1 ); // transparency
mgr->setRule( action( GEOMOp::OpTransparency ), clientOCCorVTK_AndSomeVisible, QtxPopupMgr::VisibleRule ); mgr->setRule( action( GEOMOp::OpTransparency ), clientOCCorVTK_AndSomeVisible, QtxPopupMgr::VisibleRule );
mgr->insert( action( GEOMOp::OpIsos ), -1, -1 ); // isos mgr->insert( action( GEOMOp::OpIsos ), -1, -1 ); // isos
@ -1719,14 +1716,10 @@ void GeometryGUI::createPreferences()
int defl = addPreference( tr( "PREF_DEFLECTION" ), genGroup, int defl = addPreference( tr( "PREF_DEFLECTION" ), genGroup,
LightApp_Preferences::DblSpin, "Geometry", "deflection_coeff" ); LightApp_Preferences::DblSpin, "Geometry", "deflection_coeff" );
int front_material = addPreference( tr( "PREF_FRONT_MATERIAL" ), genGroup, int material = addPreference( tr( "PREF_MATERIAL" ), genGroup,
LightApp_Preferences::Selector, LightApp_Preferences::Selector,
"Geometry", "front_material" ); "Geometry", "material" );
int back_material = addPreference( tr( "PREF_BACK_MATERIAL" ), genGroup,
LightApp_Preferences::Selector,
"Geometry", "back_material" );
const int nb = 4; const int nb = 4;
int wd[nb]; int wd[nb];
int iter=0; int iter=0;
@ -1816,8 +1809,7 @@ void GeometryGUI::createPreferences()
// Set property for default material // Set property for default material
Material_ResourceMgr aMatResMgr; Material_ResourceMgr aMatResMgr;
QStringList aPrefMatNames = aMatResMgr.getPreferenceMaterialsNames(); QStringList aPrefMatNames = aMatResMgr.getPreferenceMaterialsNames();
setPreferenceProperty( front_material, "strings", aPrefMatNames ); setPreferenceProperty( material, "strings", aPrefMatNames );
setPreferenceProperty( back_material, "strings", aPrefMatNames );
// Set property vertex marker type // Set property vertex marker type
QList<QVariant> aMarkerTypeIndicesList; QList<QVariant> aMarkerTypeIndicesList;
@ -2014,17 +2006,11 @@ void GeometryGUI::storeVisualParameters (int savePoint)
ip->setParameter(entry, param, aProps.value(MARKER_TYPE_PROP).toString().toLatin1().data()); ip->setParameter(entry, param, aProps.value(MARKER_TYPE_PROP).toString().toLatin1().data());
} }
if(aProps.contains(FRONT_MATERIAL_PROP)) { if(aProps.contains(MATERIAL_PROP)) {
param = occParam + FRONT_MATERIAL_PROP; param = occParam + MATERIAL_PROP;
ip->setParameter(entry, param, aProps.value(FRONT_MATERIAL_PROP).toString().toLatin1().data()); ip->setParameter(entry, param, aProps.value(MATERIAL_PROP).toString().toLatin1().data());
} }
if(aProps.contains(BACK_MATERIAL_PROP)) {
param = occParam + BACK_MATERIAL_PROP;
ip->setParameter(entry, param, aProps.value(BACK_MATERIAL_PROP).toString().toLatin1().data());
}
if(aProps.contains( EDGE_WIDTH_PROP )) { if(aProps.contains( EDGE_WIDTH_PROP )) {
param = occParam + EDGE_WIDTH_PROP; param = occParam + EDGE_WIDTH_PROP;
ip->setParameter(entry, param, aProps.value(EDGE_WIDTH_PROP).toString().toLatin1().data()); ip->setParameter(entry, param, aProps.value(EDGE_WIDTH_PROP).toString().toLatin1().data());
@ -2144,10 +2130,8 @@ void GeometryGUI::restoreVisualParameters (int savePoint)
aListOfMap[viewIndex].insert( DEFLECTION_COEFF_PROP, val.toDouble()); aListOfMap[viewIndex].insert( DEFLECTION_COEFF_PROP, val.toDouble());
} else if(paramNameStr == MARKER_TYPE_PROP) { } else if(paramNameStr == MARKER_TYPE_PROP) {
aListOfMap[viewIndex].insert( MARKER_TYPE_PROP, val); aListOfMap[viewIndex].insert( MARKER_TYPE_PROP, val);
} else if(paramNameStr == FRONT_MATERIAL_PROP) { } else if(paramNameStr == MATERIAL_PROP) {
aListOfMap[viewIndex].insert( FRONT_MATERIAL_PROP, val); aListOfMap[viewIndex].insert( MATERIAL_PROP, val);
} else if(paramNameStr == BACK_MATERIAL_PROP) {
aListOfMap[viewIndex].insert( BACK_MATERIAL_PROP, val);
} else if(paramNameStr == EDGE_WIDTH_PROP) { } else if(paramNameStr == EDGE_WIDTH_PROP) {
aListOfMap[viewIndex].insert( EDGE_WIDTH_PROP , val); aListOfMap[viewIndex].insert( EDGE_WIDTH_PROP , val);
} else if(paramNameStr == ISOS_WIDTH_PROP) { } else if(paramNameStr == ISOS_WIDTH_PROP) {

View File

@ -34,6 +34,7 @@
#include "GEOMToolsGUI_PublishDlg.h" #include "GEOMToolsGUI_PublishDlg.h"
#include "GEOMToolsGUI_MaterialPropertiesDlg.h" #include "GEOMToolsGUI_MaterialPropertiesDlg.h"
#include "GEOMToolsGUI_LineWidthDlg.h" #include "GEOMToolsGUI_LineWidthDlg.h"
#include "Material_Model.h"
#include <GeometryGUI.h> #include <GeometryGUI.h>
#include <GeometryGUI_Operations.h> #include <GeometryGUI_Operations.h>
@ -293,22 +294,35 @@ void GEOMToolsGUI::OnColor()
if ( c.isValid() ) { if ( c.isValid() ) {
SUIT_OverrideCursor(); SUIT_OverrideCursor();
for ( SALOME_ListIteratorOfListIO It( selected ); It.More(); It.Next() ) { for ( SALOME_ListIteratorOfListIO It( selected ); It.More(); It.Next() ) {
aView->SetColor( It.Value(), c ); QString defMatProp;
appStudy->setObjectProperty(mgrId,It.Value()->getEntry(),COLOR_PROP, c); QVariant mp = appStudy->getObjectProperty(mgrId,It.Value()->getEntry(), MATERIAL_PROP, defMatProp);
QString matProp = mp.value<QString>();
QStringList aProps = matProp.split(DIGIT_SEPARATOR);
Material_Model* aModelF = Material_Model::getMaterialModel( aProps );
bool aPhys = false;
if ( aModelF ) {
aPhys = aModelF->isPhysical();
// Release memory
delete aModelF;
}
if ( !aPhys ) {
aView->SetColor( It.Value(), c );
appStudy->setObjectProperty(mgrId,It.Value()->getEntry(),COLOR_PROP, c);
}
} }
GeometryGUI::Modified(); GeometryGUI::Modified();
} }
} // if ( isVTK ) } // if ( isVTK )
else if ( isOCC ) { else if ( isOCC ) {
Handle(AIS_InteractiveObject) io = GEOMBase::GetAIS( selected.First() ); Handle(AIS_InteractiveObject) io = GEOMBase::GetAIS( selected.First() );
if ( !io.IsNull() ) { if ( !io.IsNull() ) {
Quantity_Color aColor; Quantity_Color aColor;
io->Color( aColor ); io->Color( aColor );
QColor ic = QColor((int )( aColor.Red() * 255.0 ), QColor ic = QColor((int )( aColor.Red() * 255.0 ),
(int)( aColor.Green() * 255.0 ), (int)( aColor.Green() * 255.0 ),
(int)( aColor.Blue() * 255.0 )); (int)( aColor.Blue() * 255.0 ));
QVariant v = appStudy->getObjectProperty(mgrId,selected.First()->getEntry(), COLOR_PROP, ic); QVariant v = appStudy->getObjectProperty(mgrId,selected.First()->getEntry(), COLOR_PROP, ic);
QColor initcolor = v.value<QColor>(); QColor initcolor = v.value<QColor>();
QColor c = QColorDialog::getColor( initcolor, app->desktop() ); QColor c = QColorDialog::getColor( initcolor, app->desktop() );
@ -318,8 +332,19 @@ void GEOMToolsGUI::OnColor()
OCCViewer_Viewer* vm = dynamic_cast<OCCViewer_Viewer*> ( window->getViewManager()->getViewModel() ); OCCViewer_Viewer* vm = dynamic_cast<OCCViewer_Viewer*> ( window->getViewManager()->getViewModel() );
Handle (AIS_InteractiveContext) ic = vm->getAISContext(); Handle (AIS_InteractiveContext) ic = vm->getAISContext();
for ( SALOME_ListIteratorOfListIO It( selected ); It.More(); It.Next() ) { for ( SALOME_ListIteratorOfListIO It( selected ); It.More(); It.Next() ) {
QString defMatProp;
QVariant mp = appStudy->getObjectProperty(mgrId,It.Value()->getEntry(), MATERIAL_PROP, defMatProp);
QString matProp = mp.value<QString>();
QStringList aProps = matProp.split(DIGIT_SEPARATOR);
Material_Model* aModelF = Material_Model::getMaterialModel( aProps );
bool aPhys = false;
if ( aModelF ) {
aPhys = aModelF->isPhysical();
// Release memory
delete aModelF;
}
io = GEOMBase::GetAIS( It.Value(), true ); io = GEOMBase::GetAIS( It.Value(), true );
if ( !io.IsNull() ) { if ( !io.IsNull() && !aPhys ) { // change color only for shapes with not physical type of material
if ( io->IsKind( STANDARD_TYPE(AIS_Shape) ) ) { if ( io->IsKind( STANDARD_TYPE(AIS_Shape) ) ) {
TopoDS_Shape theShape = Handle(AIS_Shape)::DownCast( io )->Shape(); TopoDS_Shape theShape = Handle(AIS_Shape)::DownCast( io )->Shape();
@ -351,14 +376,14 @@ void GEOMToolsGUI::OnColor()
ic->SetLocalAttributes(io, aCurDrawer, Standard_False); ic->SetLocalAttributes(io, aCurDrawer, Standard_False);
} }
} }
io->SetColor( aColor ); io->SetColor( aColor );
if ( io->IsKind( STANDARD_TYPE(GEOM_AISShape) ) ) { if ( io->IsKind( STANDARD_TYPE(GEOM_AISShape) ) ) {
Handle(GEOM_AISShape) aGAISShape = Handle(GEOM_AISShape)::DownCast( io ); Handle(GEOM_AISShape) aGAISShape = Handle(GEOM_AISShape)::DownCast( io );
aGAISShape->SetShadingColor( aColor ); aGAISShape->SetShadingColor( aColor );
aGAISShape->storeBoundaryColors(); aGAISShape->storeBoundaryColors();
} }
appStudy->setObjectProperty(mgrId,It.Value()->getEntry(), COLOR_PROP, c); appStudy->setObjectProperty(mgrId,It.Value()->getEntry(), COLOR_PROP, c);
io->Redisplay( Standard_True ); io->Redisplay( Standard_True );
@ -375,7 +400,7 @@ void GEOMToolsGUI::OnColor()
aSColor.G = (double)c.green() / 255.0; aSColor.G = (double)c.green() / 255.0;
aSColor.B = (double)c.blue() / 255.0; aSColor.B = (double)c.blue() / 255.0;
anObject->SetColor( aSColor ); anObject->SetColor( aSColor );
anObject->SetAutoColor( false ); anObject->SetAutoColor( false );
} }
} // for } // for
ic->UpdateCurrentViewer(); ic->UpdateCurrentViewer();

View File

@ -123,11 +123,9 @@ GEOMToolsGUI_MaterialPropertiesDlg::GEOMToolsGUI_MaterialPropertiesDlg( QWidget*
main->setMargin( 0 ); main->setSpacing( SPACING ); main->setMargin( 0 ); main->setSpacing( SPACING );
// Create main widgets // Create main widgets
myBackMaterialCheck = new QCheckBox( tr( "MATERIAL_BACK_CHK" ), this );
QFrame* fr = new QFrame( this ); QFrame* fr = new QFrame( this );
fr->setFrameStyle( QFrame::Box | QFrame::Sunken ); fr->setFrameStyle( QFrame::Box | QFrame::Sunken );
main->addWidget( myBackMaterialCheck );
main->addWidget( fr ); main->addWidget( fr );
// Create editor widgets // Create editor widgets
@ -141,7 +139,7 @@ GEOMToolsGUI_MaterialPropertiesDlg::GEOMToolsGUI_MaterialPropertiesDlg( QWidget*
frLayout->setStretchFactor( myMaterialList, 1 ); frLayout->setStretchFactor( myMaterialList, 1 );
frLayout->setStretchFactor( myMaterialTab, 2 ); frLayout->setStretchFactor( myMaterialTab, 2 );
// ======================= Create a tab for front material ======================= // ======================= Create a tab for material =======================
QWidget* w1 = new QWidget( myMaterialTab ); QWidget* w1 = new QWidget( myMaterialTab );
QVBoxLayout* vLayout1 = new QVBoxLayout( w1 ); QVBoxLayout* vLayout1 = new QVBoxLayout( w1 );
@ -262,166 +260,34 @@ GEOMToolsGUI_MaterialPropertiesDlg::GEOMToolsGUI_MaterialPropertiesDlg( QWidget*
gLayout1->addWidget( mySpecularGroupF, 1, 0 ); gLayout1->addWidget( mySpecularGroupF, 1, 0 );
gLayout1->addWidget( myEmissionGroupF, 1, 1 ); gLayout1->addWidget( myEmissionGroupF, 1, 1 );
// Shininess // Shininess and type
QLabel* shininessLab1 = new QLabel( tr( "SHININESS" ), w1 ); QLabel* shininessLab1 = new QLabel( tr( "SHININESS" ), w1 );
myShininessF = new QtxDoubleSpinBox( w1 ); myShininessF = new QtxDoubleSpinBox( w1 );
myShininessF->setMaximum(1); myShininessF->setMaximum(1);
myShininessF->setSingleStep(0.05); myShininessF->setSingleStep(0.05);
connect( myShininessF, SIGNAL( valueChanged( double ) ), this, SIGNAL( materialChanged() ) ); connect( myShininessF, SIGNAL( valueChanged( double ) ), this, SIGNAL( materialChanged() ) );
QLabel* physicalLab1 = new QLabel( tr( "PHYSICAL" ), w1 );
myMaterialPhysicalCheck = new QCheckBox( w1 );
myMaterialPhysicalCheck->setCheckable( true );
connect( myMaterialPhysicalCheck, SIGNAL( toggled( bool ) ), this, SLOT( onReflectionTypeToggled( bool ) ) );
// Shininess layout // Shininess and type layout
QHBoxLayout* shLayout1 = new QHBoxLayout( w1 ); QGridLayout* shLayout1 = new QGridLayout( w1 );
shLayout1->setMargin( MARGIN ); shLayout1->setSpacing( SPACING ); shLayout1->setMargin( MARGIN ); shLayout1->setSpacing( SPACING );
shLayout1->addWidget( shininessLab1 ); shLayout1->addWidget( shininessLab1, 0, 0 );
shLayout1->addWidget( myShininessF ); shLayout1->addWidget( myShininessF, 0, 1 );
shLayout1->addWidget( physicalLab1, 1, 0 );
shLayout1->addWidget( myMaterialPhysicalCheck, 1, 1 );
// Fill initial vertical layout of the reflection type group box // Fill initial vertical layout of the reflection type group box
vLayout1->addLayout( gLayout1 ); vLayout1->addLayout( gLayout1 );
vLayout1->addLayout( shLayout1 ); vLayout1->addLayout( shLayout1 );
vLayout1->addStretch(); vLayout1->addStretch();
// ======================= Create a tab for back material =======================
myMaterialBWidget = new QWidget( myMaterialTab );
QVBoxLayout* vLayout2 = new QVBoxLayout( myMaterialBWidget );
QGridLayout* gLayout2 = new QGridLayout( myMaterialBWidget );
gLayout2->setMargin( MARGIN ); gLayout2->setSpacing( SPACING );
// ----------------- "Ambient" reflection type group box -----------------
myAmbientGroupB = new QGroupBox( tr( "AMBIENT_GRP" ), myMaterialBWidget );
myAmbientGroupB->setCheckable(true);
connect( myAmbientGroupB, SIGNAL( toggled( bool ) ), this, SLOT( onReflectionTypeToggled( bool ) ) );
// Ambient color
QLabel* ambColorLab2 = new QLabel( tr( "COLOR" ), myAmbientGroupB );
myAmbientColorB = new QtxColorButton( myAmbientGroupB );
myAmbientColorB->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
connect( myAmbientColorB, SIGNAL( changed( QColor ) ), this, SIGNAL( changed() ) );
// Ambient coefficient
QLabel* ambCoefficientLab2 = new QLabel( tr( "COEFFICIENT" ), myAmbientGroupB );
myAmbientCoefntB = new QtxDoubleSpinBox( myAmbientGroupB );
myAmbientCoefntB->setMaximum(1);
myAmbientCoefntB->setSingleStep(0.05);
connect( myAmbientCoefntB, SIGNAL( valueChanged( double ) ), this, SIGNAL( materialChanged() ) );
// Ambient group box layout
QGridLayout* ambientLayout2 = new QGridLayout( myAmbientGroupB );
ambientLayout2->setMargin( MARGIN ); ambientLayout2->setSpacing( SPACING );
ambientLayout2->addWidget( ambColorLab2, 0, 0 );
ambientLayout2->addWidget( myAmbientColorB, 0, 1 );
ambientLayout2->addWidget( ambCoefficientLab2, 1, 0 );
ambientLayout2->addWidget( myAmbientCoefntB, 1, 1 );
// ----------------- "Diffuse" reflection type group box -----------------
myDiffuseGroupB = new QGroupBox( tr( "DIFFUSE_GRP" ), myMaterialBWidget );
myDiffuseGroupB->setCheckable(true);
connect( myDiffuseGroupB, SIGNAL( toggled( bool ) ), this, SLOT( onReflectionTypeToggled( bool ) ) );
// Diffuse color
QLabel* difColorLab2 = new QLabel( tr( "COLOR" ), myDiffuseGroupB );
myDiffuseColorB = new QtxColorButton( myDiffuseGroupB );
myDiffuseColorB->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
connect( myDiffuseColorB, SIGNAL( changed( QColor ) ), this, SIGNAL( changed() ) );
// Diffuse coefficient
QLabel* difCoefficientLab2 = new QLabel( tr( "COEFFICIENT" ), myDiffuseGroupB );
myDiffuseCoefntB = new QtxDoubleSpinBox( myDiffuseGroupB );
myDiffuseCoefntB->setMaximum(1);
myDiffuseCoefntB->setSingleStep(0.05);
connect( myDiffuseCoefntB, SIGNAL( valueChanged( double ) ), this, SIGNAL( materialChanged() ) );
// Diffuse group box layout
QGridLayout* diffuseLayout2 = new QGridLayout( myDiffuseGroupB );
diffuseLayout2->setMargin( MARGIN ); diffuseLayout2->setSpacing( SPACING );
diffuseLayout2->addWidget( difColorLab2, 0, 0 );
diffuseLayout2->addWidget( myDiffuseColorB, 0, 1 );
diffuseLayout2->addWidget( difCoefficientLab2, 1, 0 );
diffuseLayout2->addWidget( myDiffuseCoefntB, 1, 1 );
// ----------------- "Specular" reflection type group box -----------------
mySpecularGroupB = new QGroupBox( tr( "SPECULAR_GRP" ), myMaterialBWidget );
mySpecularGroupB->setCheckable(true);
connect( mySpecularGroupB, SIGNAL( toggled( bool ) ), this, SLOT( onReflectionTypeToggled( bool ) ) );
// Specular color
QLabel* specColorLab2 = new QLabel( tr( "COLOR" ), mySpecularGroupB );
mySpecularColorB = new QtxColorButton( mySpecularGroupB );
mySpecularColorB->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
connect( mySpecularColorB, SIGNAL( changed( QColor ) ), this, SIGNAL( changed() ) );
// Specular coefficient
QLabel* specCoefficientLab2 = new QLabel( tr( "COEFFICIENT" ), mySpecularGroupB );
mySpecularCoefntB = new QtxDoubleSpinBox( mySpecularGroupB );
mySpecularCoefntB->setMaximum(1);
mySpecularCoefntB->setSingleStep(0.05);
connect( mySpecularCoefntB, SIGNAL( valueChanged( double ) ), this, SIGNAL( materialChanged() ) );
// Specular group box layout
QGridLayout* specularLayout2 = new QGridLayout( mySpecularGroupB );
specularLayout2->setMargin( MARGIN ); specularLayout2->setSpacing( SPACING );
specularLayout2->addWidget( specColorLab2, 0, 0 );
specularLayout2->addWidget( mySpecularColorB, 0, 1 );
specularLayout2->addWidget( specCoefficientLab2, 1, 0 );
specularLayout2->addWidget( mySpecularCoefntB, 1, 1 );
// ----------------- "Emission" reflection type group box -----------------
myEmissionGroupB = new QGroupBox( tr( "EMISSION_GRP" ), myMaterialBWidget );
myEmissionGroupB->setCheckable(true);
connect( myEmissionGroupB, SIGNAL( toggled( bool ) ), this, SLOT( onReflectionTypeToggled( bool ) ) );
// Emission color
QLabel* emisColorLab2 = new QLabel( tr( "COLOR" ), myEmissionGroupB );
myEmissionColorB = new QtxColorButton( myEmissionGroupB );
myEmissionColorB->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
connect( myEmissionColorB, SIGNAL( changed( QColor ) ), this, SIGNAL( changed() ) );
// Emission coefficient
QLabel* emisCoefficientLab2 = new QLabel( tr( "COEFFICIENT" ), myEmissionGroupB );
myEmissionCoefntB = new QtxDoubleSpinBox( myEmissionGroupB );
myEmissionCoefntB->setMaximum(1);
myEmissionCoefntB->setSingleStep(0.05);
connect( myEmissionCoefntB, SIGNAL( valueChanged( double ) ), this, SIGNAL( materialChanged() ) );
// Emission group box layout
QGridLayout* emissionLayout2 = new QGridLayout( myEmissionGroupB );
emissionLayout2->setMargin( MARGIN ); emissionLayout2->setSpacing( SPACING );
emissionLayout2->addWidget( emisColorLab2, 0, 0 );
emissionLayout2->addWidget( myEmissionColorB, 0, 1 );
emissionLayout2->addWidget( emisCoefficientLab2, 1, 0 );
emissionLayout2->addWidget( myEmissionCoefntB, 1, 1 );
// Erase emission group in case of VTK viewer
if ( myViewerType == VTK )
myEmissionGroupB->hide();
// Add group boxes to the main grid layout of the frame with material properties
gLayout2->addWidget( myAmbientGroupB, 0, 0 );
gLayout2->addWidget( myDiffuseGroupB, 0, 1 );
gLayout2->addWidget( mySpecularGroupB, 1, 0 );
gLayout2->addWidget( myEmissionGroupB, 1, 1 );
// Shininess
QLabel* shininessLab2 = new QLabel( tr( "SHININESS" ), myMaterialBWidget );
myShininessB = new QtxDoubleSpinBox( myMaterialBWidget );
myShininessB->setMaximum(1);
myShininessB->setSingleStep(0.05);
connect( myShininessB, SIGNAL( valueChanged( double ) ), this, SIGNAL( materialChanged() ) );
// Shininess layout
QHBoxLayout* shLayout2 = new QHBoxLayout( myMaterialBWidget );
shLayout2->setMargin( MARGIN ); shLayout2->setSpacing( SPACING );
shLayout2->addWidget( shininessLab2 );
shLayout2->addWidget( myShininessB );
// Fill initial vertical layout of the reflection type group box
vLayout2->addLayout( gLayout2 );
vLayout2->addLayout( shLayout2 );
vLayout2->addStretch();
// Add tabs to material tab widget // Add tabs to material tab widget
myMaterialTab->addTab( w1, tr( "Front material" ) ); myMaterialTab->addTab( w1, tr( "Material" ) );
myMaterialTab->addTab( myMaterialBWidget, tr( "Back material" ) );
// Initialize dialog box // Initialize dialog box
setFocusProxy( fr ); setFocusProxy( fr );
@ -466,11 +332,6 @@ GEOMToolsGUI_MaterialPropertiesDlg::GEOMToolsGUI_MaterialPropertiesDlg( QWidget*
} }
// Connect signals // Connect signals
connect( myMaterialTab, SIGNAL( currentChanged( int ) ),
this, SLOT( onCurrentTabChanged( int ) ) );
connect( myBackMaterialCheck, SIGNAL( toggled( bool ) ),
this, SLOT( onBackMaterialChecked( bool ) ) );
connect( myMaterialList, SIGNAL( itemSelectionChanged() ), connect( myMaterialList, SIGNAL( itemSelectionChanged() ),
this, SLOT( onMaterialChanged() ) ); this, SLOT( onMaterialChanged() ) );
connect( myMaterialList, SIGNAL( itemChanged( QListWidgetItem* ) ), connect( myMaterialList, SIGNAL( itemChanged( QListWidgetItem* ) ),
@ -484,7 +345,7 @@ GEOMToolsGUI_MaterialPropertiesDlg::GEOMToolsGUI_MaterialPropertiesDlg( QWidget*
connect( this, SIGNAL( dlgApply() ), this, SLOT( onApply() ) ); connect( this, SIGNAL( dlgApply() ), this, SLOT( onApply() ) );
connect( this, SIGNAL( dlgHelp() ), this, SLOT( onHelp() ) ); connect( this, SIGNAL( dlgHelp() ), this, SLOT( onHelp() ) );
// Initialize current fornt and back material models of the selected shape // Initialize current material models of the selected shape
if ( app ) { if ( app ) {
LightApp_SelectionMgr* aSelMgr = app->selectionMgr(); LightApp_SelectionMgr* aSelMgr = app->selectionMgr();
if ( aSelMgr ) { if ( aSelMgr ) {
@ -499,33 +360,18 @@ GEOMToolsGUI_MaterialPropertiesDlg::GEOMToolsGUI_MaterialPropertiesDlg( QWidget*
int aMgrId = window->getViewManager()->getGlobalId(); int aMgrId = window->getViewManager()->getGlobalId();
QString aMaterialF; QString aMaterialF;
QString aMaterialB;
for ( SALOME_ListIteratorOfListIO It( selected ); It.More(); It.Next() ) { for ( SALOME_ListIteratorOfListIO It( selected ); It.More(); It.Next() ) {
PropMap aPropMap = aStudy->getObjectPropMap( aMgrId, It.Value()->getEntry() ); PropMap aPropMap = aStudy->getObjectPropMap( aMgrId, It.Value()->getEntry() );
aMaterialF = aPropMap.value(FRONT_MATERIAL_PROP).toString(); aMaterialF = aPropMap.value(MATERIAL_PROP).toString();
aMaterialB = aPropMap.value(BACK_MATERIAL_PROP).toString();
if ( !aMaterialF.isEmpty() ) { if ( !aMaterialF.isEmpty() ) {
QStringList aPropsF = aMaterialF.split(DIGIT_SEPARATOR); QStringList aPropsF = aMaterialF.split(DIGIT_SEPARATOR);
myCurrentModelF = Material_Model::getMaterialModel( aPropsF ); myCurrentModelF = Material_Model::getMaterialModel( aPropsF );
if ( !aMaterialB.isEmpty() ) {
QStringList aPropsB = aMaterialB.split(DIGIT_SEPARATOR);
myCurrentModelB = Material_Model::getMaterialModel( aPropsB );
myBackMaterialCheck->setChecked( true );
}
else {
myCurrentModelB = Material_Model::getMaterialModel( aPropsF );
myBackMaterialCheck->setChecked( false );
myMaterialTab->removeTab( 1 );
}
break; break;
} }
} }
@ -533,20 +379,14 @@ GEOMToolsGUI_MaterialPropertiesDlg::GEOMToolsGUI_MaterialPropertiesDlg( QWidget*
if ( aMaterialF.isEmpty() ) { if ( aMaterialF.isEmpty() ) {
myCurrentModelF = new Material_Model(); myCurrentModelF = new Material_Model();
myCurrentModelF->fromResources( SUIT_Session::session()->resourceMgr(), "Geometry" ); myCurrentModelF->fromResources( SUIT_Session::session()->resourceMgr(), "Geometry" );
}
myCurrentModelB = new Material_Model(); }
myCurrentModelB->fromResources( SUIT_Session::session()->resourceMgr(), "Geometry", false );
}
}
} }
} }
} }
myMaterialList->setCurrentRow( 0 ); myMaterialList->setCurrentRow( 0 );
myMaterialListFId = 0; myMaterialListFId = 0;
myMaterialListBId = 0;
myIsBTabWasActivated = false;
myHelpFileName = "material_page.html"; myHelpFileName = "material_page.html";
} }
@ -558,9 +398,6 @@ GEOMToolsGUI_MaterialPropertiesDlg::~GEOMToolsGUI_MaterialPropertiesDlg()
{ {
if ( myCurrentModelF ) if ( myCurrentModelF )
delete myCurrentModelF; delete myCurrentModelF;
if ( myCurrentModelB )
delete myCurrentModelB;
} }
/*! /*!
@ -617,125 +454,63 @@ Material_ResourceMgr* GEOMToolsGUI_MaterialPropertiesDlg::resourceMgr()
void GEOMToolsGUI_MaterialPropertiesDlg::fromModel( Material_Model* model) void GEOMToolsGUI_MaterialPropertiesDlg::fromModel( Material_Model* model)
{ {
if ( !model ) return; if ( !model ) return;
bool isReflectionTypeActive;
bool isReflectionTypeActive; // Ambient reflection type
isReflectionTypeActive = model->hasAmbientReflection();
if ( isFrontTabActive() ) { // Fill in front material tab myAmbientGroupF->setChecked( isReflectionTypeActive );
if ( isReflectionTypeActive ) {
// Ambient reflection type // Load ambient color
isReflectionTypeActive = model->hasAmbientReflection(); myAmbientColorF->setColor( model->color(Material_Model::Ambient) );
myAmbientGroupF->setChecked( isReflectionTypeActive ); // Load ambient coefficient
if ( isReflectionTypeActive ) { myAmbientCoefntF->setValue( model->coefficient(Material_Model::Ambient) );
// Load ambient color
myAmbientColorF->setColor( model->color(Material_Model::Ambient) );
// Load ambient coefficient
myAmbientCoefntF->setValue( model->coefficient(Material_Model::Ambient) );
}
// Diffuse reflection type
isReflectionTypeActive = model->hasDiffuseReflection();
myDiffuseGroupF->setChecked( isReflectionTypeActive );
if ( isReflectionTypeActive ) {
// Load diffuse color
myDiffuseColorF->setColor( model->color(Material_Model::Diffuse) );
// Load diffuse coefficient
myDiffuseCoefntF->setValue( model->coefficient(Material_Model::Diffuse) );
}
// Specular reflection type
isReflectionTypeActive = model->hasSpecularReflection();
mySpecularGroupF->setChecked( isReflectionTypeActive );
if ( isReflectionTypeActive ) {
// Load specular color
mySpecularColorF->setColor( model->color(Material_Model::Specular) );
// Load specular coefficient
mySpecularCoefntF->setValue( model->coefficient(Material_Model::Specular) );
}
// Emission reflection type
isReflectionTypeActive = model->hasEmissionReflection();
myEmissionGroupF->setChecked( isReflectionTypeActive );
if ( isReflectionTypeActive ) {
// Load emission color
myEmissionColorF->setColor( model->color(Material_Model::Emission) );
// Load emission coefficient
myEmissionCoefntF->setValue( model->coefficient(Material_Model::Emission) );
}
// Shininess
myShininessF->setValue( model->shininess() );
} }
else { // Fill in back material tab
// Diffuse reflection type
// Ambient reflection type isReflectionTypeActive = model->hasDiffuseReflection();
isReflectionTypeActive = model->hasAmbientReflection(); myDiffuseGroupF->setChecked( isReflectionTypeActive );
myAmbientGroupB->setChecked( isReflectionTypeActive ); if ( isReflectionTypeActive ) {
if ( isReflectionTypeActive ) { // Load diffuse color
// Load ambient color myDiffuseColorF->setColor( model->color(Material_Model::Diffuse) );
myAmbientColorB->setColor( model->color(Material_Model::Ambient) ); // Load diffuse coefficient
// Load ambient coefficient myDiffuseCoefntF->setValue( model->coefficient(Material_Model::Diffuse) );
myAmbientCoefntB->setValue( model->coefficient(Material_Model::Ambient) );
}
// Diffuse reflection type
isReflectionTypeActive = model->hasDiffuseReflection();
myDiffuseGroupB->setChecked( isReflectionTypeActive );
if ( isReflectionTypeActive ) {
// Load diffuse color
myDiffuseColorB->setColor( model->color(Material_Model::Diffuse) );
// Load diffuse coefficient
myDiffuseCoefntB->setValue( model->coefficient(Material_Model::Diffuse) );
}
// Specular reflection type
isReflectionTypeActive = model->hasSpecularReflection();
mySpecularGroupB->setChecked( isReflectionTypeActive );
if ( isReflectionTypeActive ) {
// Load specular color
mySpecularColorB->setColor( model->color(Material_Model::Specular) );
// Load specular coefficient
mySpecularCoefntB->setValue( model->coefficient(Material_Model::Specular) );
}
// Emission reflection type
isReflectionTypeActive = model->hasEmissionReflection();
myEmissionGroupB->setChecked( isReflectionTypeActive );
if ( isReflectionTypeActive ) {
// Load emission color
myEmissionColorB->setColor( model->color(Material_Model::Emission) );
// Load emission coefficient
myEmissionCoefntB->setValue( model->coefficient(Material_Model::Emission) );
}
// Shininess
myShininessB->setValue( model->shininess() );
} }
// Specular reflection type
isReflectionTypeActive = model->hasSpecularReflection();
mySpecularGroupF->setChecked( isReflectionTypeActive );
if ( isReflectionTypeActive ) {
// Load specular color
mySpecularColorF->setColor( model->color(Material_Model::Specular) );
// Load specular coefficient
mySpecularCoefntF->setValue( model->coefficient(Material_Model::Specular) );
}
// Emission reflection type
isReflectionTypeActive = model->hasEmissionReflection();
myEmissionGroupF->setChecked( isReflectionTypeActive );
if ( isReflectionTypeActive ) {
// Load emission color
myEmissionColorF->setColor( model->color(Material_Model::Emission) );
// Load emission coefficient
myEmissionCoefntF->setValue( model->coefficient(Material_Model::Emission) );
}
// Shininess
myShininessF->setValue( model->shininess() );
//Physical
myMaterialPhysicalCheck->setChecked( model->isPhysical() );
} }
/*! /*!
\brief Save values from dialog box fields to material model \brief Save values from dialog box fields material model
\param model material model \param model material model to be filled
*/ */
void GEOMToolsGUI_MaterialPropertiesDlg::toModel( Material_Model* model ) const void GEOMToolsGUI_MaterialPropertiesDlg::toModel( Material_Model* model ) const
{ {
if ( !model ) return; if ( !model ) return;
if ( isFrontTabActive() )
toFrontModel( model );
else
toBackModel( model );
}
/*!
\brief Save values from dialog box fields to front material model
\param model front material model to be filled
*/
void GEOMToolsGUI_MaterialPropertiesDlg::toFrontModel( Material_Model* model ) const
{
if ( !model ) return;
// "Ambient" reflection type // "Ambient" reflection type
if ( myAmbientGroupF->isChecked() ) { if ( myAmbientGroupF->isChecked() ) {
model->setColor( Material_Model::Ambient, myAmbientColorF->color() ); model->setColor( Material_Model::Ambient, myAmbientColorF->color() );
@ -778,59 +553,9 @@ void GEOMToolsGUI_MaterialPropertiesDlg::toFrontModel( Material_Model* model ) c
// Shininess // Shininess
model->setShininess( myShininessF->value() ); model->setShininess( myShininessF->value() );
}
/*! //Type
\brief Save values from dialog box fields to back material model model->setPhysical( myMaterialPhysicalCheck->isChecked()? true : false );
\param model back material model to be filled
*/
void GEOMToolsGUI_MaterialPropertiesDlg::toBackModel( Material_Model* model ) const
{
if ( !model )
return;
// "Ambient" reflection type
if ( myAmbientGroupB->isChecked() ) {
model->setColor( Material_Model::Ambient, myAmbientColorB->color() );
model->setCoefficient( Material_Model::Ambient, myAmbientCoefntB->value() );
}
else {
model->removeColor( Material_Model::Ambient );
model->removeCoefficient( Material_Model::Ambient );
}
// "Diffuse" reflection type
if ( myDiffuseGroupB->isChecked() ) {
model->setColor( Material_Model::Diffuse, myDiffuseColorB->color() );
model->setCoefficient( Material_Model::Diffuse, myDiffuseCoefntB->value() );
}
else {
model->removeColor( Material_Model::Diffuse );
model->removeCoefficient( Material_Model::Diffuse );
}
// "Specular" reflection type
if ( mySpecularGroupB->isChecked() ) {
model->setColor( Material_Model::Specular, mySpecularColorB->color() );
model->setCoefficient( Material_Model::Specular, mySpecularCoefntB->value() );
}
else {
model->removeColor( Material_Model::Specular );
model->removeCoefficient( Material_Model::Specular );
}
// "Emission" reflection type
if ( myEmissionGroupB->isChecked() ) {
model->setColor( Material_Model::Emission, myEmissionColorB->color() );
model->setCoefficient( Material_Model::Emission, myEmissionCoefntB->value() );
}
else {
model->removeColor( Material_Model::Emission );
model->removeCoefficient( Material_Model::Emission );
}
// Shininess
model->setShininess( myShininessB->value() );
} }
/*! /*!
@ -861,15 +586,6 @@ QString GEOMToolsGUI_MaterialPropertiesDlg::findUniqueName( const QString& name,
return found || addSuffix ? QString( "%1 %2" ).arg( name ).arg( idx+1 ) : name; return found || addSuffix ? QString( "%1 %2" ).arg( name ).arg( idx+1 ) : name;
} }
/*!
\brief Check if tab with front material properties is currently active
\return true if front material tab is active
*/
bool GEOMToolsGUI_MaterialPropertiesDlg::isFrontTabActive() const
{
return ( myMaterialTab->currentIndex() == 0 ? true : false );
}
/*! /*!
\brief Called when "Apply" button is pressed \brief Called when "Apply" button is pressed
*/ */
@ -878,9 +594,7 @@ void GEOMToolsGUI_MaterialPropertiesDlg::onApply()
// save user materials // save user materials
resourceMgr()->save(); resourceMgr()->save();
toFrontModel( myCurrentModelF ); toModel( myCurrentModelF );
if ( myBackMaterialCheck->isChecked() && myIsBTabWasActivated )
toBackModel( myCurrentModelB );
SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() ); SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
if ( !app ) if ( !app )
@ -908,10 +622,7 @@ void GEOMToolsGUI_MaterialPropertiesDlg::onApply()
// Parse material properties and form a string for persistent purpose // Parse material properties and form a string for persistent purpose
QString aMaterialF = myCurrentModelF->getMaterialProperty(); QString aMaterialF = myCurrentModelF->getMaterialProperty();
QString aMaterialB;
if ( myBackMaterialCheck->isChecked() )
aMaterialB = myCurrentModelB->getMaterialProperty();
if ( myViewerType == VTK ) { if ( myViewerType == VTK ) {
// Get material properties from the current model // Get material properties from the current model
/* /*
@ -919,10 +630,7 @@ void GEOMToolsGUI_MaterialPropertiesDlg::onApply()
if ( !unsetMaterial ) if ( !unsetMaterial )
aPropertyF = myCurrentModelF->getMaterialVTKProperty(); aPropertyF = myCurrentModelF->getMaterialVTKProperty();
*/ */
vtkProperty* aPropertyF = myCurrentModelF->getMaterialVTKProperty(); GEOM_VTKPropertyMaterial* aPropertyF = myCurrentModelF->getMaterialVTKProperty();
vtkProperty* aPropertyB = aPropertyF;
if ( myBackMaterialCheck->isChecked() )
aPropertyB = myCurrentModelB->getMaterialVTKProperty();
SVTK_ViewWindow* vtkVW = dynamic_cast<SVTK_ViewWindow*>( window ); SVTK_ViewWindow* vtkVW = dynamic_cast<SVTK_ViewWindow*>( window );
if ( !vtkVW ) if ( !vtkVW )
@ -939,11 +647,18 @@ void GEOMToolsGUI_MaterialPropertiesDlg::onApply()
else else
// Set material for the selected shape // Set material for the selected shape
*/ */
aView->SetMaterial( It.Value(), aPropertyF, aPropertyB ); aView->SetMaterial( It.Value(), (vtkProperty*) aPropertyF );
// Restore color for not physical materials
PropMap aPropMap = aStudy->getObjectPropMap( aMgrId, It.Value()->getEntry() );
if( !myMaterialPhysicalCheck->isChecked() && aPropMap.contains(COLOR_PROP) ) {
aView->SetColor(It.Value(), aPropMap.value(COLOR_PROP).value<QColor>());
}
int aDispModeId = aPropMap.value(DISPLAY_MODE_PROP).toInt();
aView->SetDisplayMode(aDispModeId);
// eWireframe - 0, eShading - 1, eShadingWithEdges - 3
// Persistent // Persistent
aStudy->setObjectProperty( aMgrId, It.Value()->getEntry(), FRONT_MATERIAL_PROP, aMaterialF ); aStudy->setObjectProperty( aMgrId, It.Value()->getEntry(), MATERIAL_PROP, aMaterialF );
aStudy->setObjectProperty( aMgrId, It.Value()->getEntry(), BACK_MATERIAL_PROP, aMaterialB );
} // for... } // for...
aView->Repaint(); aView->Repaint();
GeometryGUI::Modified(); GeometryGUI::Modified();
@ -957,9 +672,6 @@ void GEOMToolsGUI_MaterialPropertiesDlg::onApply()
aMatF = myCurrentModelF->getMaterialOCCAspect(); aMatF = myCurrentModelF->getMaterialOCCAspect();
*/ */
Graphic3d_MaterialAspect aMatF = myCurrentModelF->getMaterialOCCAspect(); Graphic3d_MaterialAspect aMatF = myCurrentModelF->getMaterialOCCAspect();
Graphic3d_MaterialAspect aMatB = aMatF;
if ( myBackMaterialCheck->isChecked() )
aMatB = myCurrentModelB->getMaterialOCCAspect();
Handle(GEOM_AISShape) aisShape; Handle(GEOM_AISShape) aisShape;
@ -984,27 +696,13 @@ void GEOMToolsGUI_MaterialPropertiesDlg::onApply()
aisShape->UnsetMaterial(); aisShape->UnsetMaterial();
else else
*/ */
if ( myBackMaterialCheck->isChecked() ) { aisShape->SetMaterial(aMatF);
// Set front material for the selected shape
aisShape->SetCurrentFacingModel(Aspect_TOFM_FRONT_SIDE);
aisShape->SetMaterial(aMatF);
// Set back material for the selected shape
aisShape->SetCurrentFacingModel(Aspect_TOFM_BACK_SIDE);
aisShape->SetMaterial(aMatB);
// Return to the default facing mode
aisShape->SetCurrentFacingModel(Aspect_TOFM_BOTH_SIDE);
}
else {
// Set the same front and back (is equal to front) materials for the selected shape
aisShape->SetMaterial(aMatF);
}
if (aisShape->DisplayMode() != AIS_Shaded/*aisShape->DisplayMode() == GEOM_AISShape::ShadingWithEdges*/) if (aisShape->DisplayMode() != AIS_Shaded/*aisShape->DisplayMode() == GEOM_AISShape::ShadingWithEdges*/)
ic->RecomputePrsOnly( aisShape, Standard_False ); ic->RecomputePrsOnly( aisShape, Standard_False );
// Persistent // Persistent
aStudy->setObjectProperty( aMgrId, It.Value()->getEntry(), FRONT_MATERIAL_PROP, aMaterialF ); aStudy->setObjectProperty( aMgrId, It.Value()->getEntry(), MATERIAL_PROP, aMaterialF );
aStudy->setObjectProperty( aMgrId, It.Value()->getEntry(), BACK_MATERIAL_PROP, aMaterialB );
} }
} // for... } // for...
ic->UpdateCurrentViewer(); ic->UpdateCurrentViewer();
@ -1036,58 +734,6 @@ void GEOMToolsGUI_MaterialPropertiesDlg::onHelp()
} }
} }
/*!
\brief Called when user check/uncheck "Enable back material" check box
\param theIsChecked the check state of the check box
*/
void GEOMToolsGUI_MaterialPropertiesDlg::onBackMaterialChecked( bool theIsChecked )
{
if ( theIsChecked ) {
// Tab with back material properties is displayed
myMaterialTab->addTab( myMaterialBWidget, tr( "Back material" ) );
// Create a current model of back material
if ( !myCurrentModelB ) {
myCurrentModelB = new Material_Model();
myCurrentModelB->fromResources( SUIT_Session::session()->resourceMgr(), "Geometry", false );
}
myMaterialListBId = 0;
}
else {
// Tab with back material properties is hidden
myMaterialTab->removeTab( 1 );
// Remove the current model for back material
if ( myCurrentModelB ) {
delete myCurrentModelB;
myCurrentModelB = 0;
}
}
}
/*!
\brief Called when user activates material tab
\param theIndex the index of the tab which was activated by the user
*/
void GEOMToolsGUI_MaterialPropertiesDlg::onCurrentTabChanged(int theIndex)
{
blockSignals( true );
// Change selection in the list of materials
if ( isFrontTabActive() )
myMaterialList->setCurrentRow( myMaterialListFId );
else if ( myBackMaterialCheck->isChecked() )
myMaterialList->setCurrentRow( myMaterialListBId );
if ( theIndex == 1 )
myIsBTabWasActivated = true;
blockSignals( false );
onMaterialChanged();
}
/*! /*!
\brief Called when user selects any material item in the materials list \brief Called when user selects any material item in the materials list
*/ */
@ -1100,22 +746,17 @@ void GEOMToolsGUI_MaterialPropertiesDlg::onMaterialChanged()
Material_Model* model = 0; Material_Model* model = 0;
bool isFrontTab = isFrontTabActive(); myMaterialListFId = myMaterialList->currentRow();
if ( isFrontTab )
myMaterialListFId = myMaterialList->currentRow();
else
myMaterialListBId = myMaterialList->currentRow();
switch ( type ) { switch ( type ) {
case Current: case Current:
// current material // current material
model = ( isFrontTab ? myCurrentModelF : myCurrentModelB ); model = myCurrentModelF;
break; break;
case Default: case Default:
// default material // default material
model = new Material_Model(); model = new Material_Model();
model->fromResources( SUIT_Session::session()->resourceMgr(), "Geometry", ( isFrontTab ? true : false ) ); model->fromResources( SUIT_Session::session()->resourceMgr(), "Geometry" );
break; break;
case Global: case Global:
case User: case User:
@ -1142,13 +783,11 @@ void GEOMToolsGUI_MaterialPropertiesDlg::onChanged()
QListWidgetItem* item = myMaterialList->currentItem(); QListWidgetItem* item = myMaterialList->currentItem();
int type = item->data( TypeRole ).toInt(); int type = item->data( TypeRole ).toInt();
bool isFrontTab = isFrontTabActive();
// for the current and user schemas do not perform any actions // for the current and user schemas do not perform any actions
if ( type == Current ) { if ( type == Current ) {
Material_Model model = ( isFrontTab ? *( myCurrentModelF ) : *( myCurrentModelB ) ); Material_Model model = *(myCurrentModelF);
toModel( &model ); toModel( &model );
model.save( 0, QString(), isFrontTab ); model.save( 0, QString() );
blockSignals( true ); blockSignals( true );
fromModel( &model ); fromModel( &model );
blockSignals( false ); blockSignals( false );
@ -1158,11 +797,11 @@ void GEOMToolsGUI_MaterialPropertiesDlg::onChanged()
toModel( &model ); toModel( &model );
QString oldName = item->data( NameRole ).toString(), newName = item->text(); QString oldName = item->data( NameRole ).toString(), newName = item->text();
if ( oldName == newName ) { if ( oldName == newName ) {
model.save( resourceMgr(), oldName, isFrontTab ); model.save( resourceMgr(), oldName );
} }
else { else {
resourceMgr()->remove( oldName ); resourceMgr()->remove( oldName );
model.save( resourceMgr(), newName, isFrontTab ); model.save( resourceMgr(), newName );
item->setData( NameRole, newName ); item->setData( NameRole, newName );
} }
blockSignals( true ); blockSignals( true );
@ -1181,15 +820,11 @@ void GEOMToolsGUI_MaterialPropertiesDlg::onChanged()
Material_Model model; Material_Model model;
toModel( &model ); toModel( &model );
model.save( resourceMgr(), newName, isFrontTab ); model.save( resourceMgr(), newName );
myMaterialList->setCurrentItem( item ); myMaterialList->setCurrentItem( item );
if ( isFrontTab ) myMaterialListFId = myMaterialList->currentRow();
myMaterialListFId = myMaterialList->currentRow();
else
myMaterialListBId = myMaterialList->currentRow();
} }
} }
@ -1220,7 +855,7 @@ void GEOMToolsGUI_MaterialPropertiesDlg::onReflectionTypeToggled( bool theIsOn )
QColor c; QColor c;
// Make changes on front material tab // Make changes on material tab
if ( anObj == myAmbientGroupF ) { if ( anObj == myAmbientGroupF ) {
myAmbientColorF->setColor( c ); myAmbientColorF->setColor( c );
myAmbientCoefntF->setValue( 0.0 ); myAmbientCoefntF->setValue( 0.0 );
@ -1237,24 +872,6 @@ void GEOMToolsGUI_MaterialPropertiesDlg::onReflectionTypeToggled( bool theIsOn )
myEmissionColorF->setColor( c ); myEmissionColorF->setColor( c );
myEmissionCoefntF->setValue( 0.0 ); myEmissionCoefntF->setValue( 0.0 );
} }
// Make changes on back material tab
if ( anObj == myAmbientGroupB ) {
myAmbientColorB->setColor( c );
myAmbientCoefntB->setValue( 0.0 );
}
else if ( anObj == myDiffuseGroupB ) {
myDiffuseColorB->setColor( c );
myDiffuseCoefntB->setValue( 0.0 );
}
else if ( anObj == mySpecularGroupB ) {
mySpecularColorB->setColor( c );
mySpecularCoefntB->setValue( 0.0 );
}
else if ( anObj == myEmissionGroupB ) {
myEmissionColorB->setColor( c );
myEmissionCoefntB->setValue( 0.0 );
}
emit( changed() ); emit( changed() );
} }

View File

@ -70,15 +70,11 @@ private:
void fromModel( Material_Model* ); void fromModel( Material_Model* );
void toModel( Material_Model* ) const; void toModel( Material_Model* ) const;
void toFrontModel( Material_Model* ) const;
void toBackModel( Material_Model* ) const;
QString findUniqueName( const QString&, QString findUniqueName( const QString&,
QListWidgetItem* = 0, QListWidgetItem* = 0,
bool = false ); bool = false );
bool isFrontTabActive() const;
signals: signals:
void materialChanged(); void materialChanged();
void changed(); void changed();
@ -88,8 +84,6 @@ private slots:
void onApply(); void onApply();
void onHelp(); void onHelp();
void onBackMaterialChecked( bool );
void onCurrentTabChanged( int );
void onMaterialChanged(); void onMaterialChanged();
void onChanged(); void onChanged();
void onItemChanged( QListWidgetItem* ); void onItemChanged( QListWidgetItem* );
@ -99,23 +93,17 @@ private:
Material_ResourceMgr* myResMgr; Material_ResourceMgr* myResMgr;
QCheckBox* myBackMaterialCheck; QCheckBox* myMaterialPhysicalCheck;
//! Current material model for front material //! Current material model for material
Material_Model* myCurrentModelF; Material_Model* myCurrentModelF;
//! Current material model for back material
Material_Model* myCurrentModelB;
QListWidget* myMaterialList; QListWidget* myMaterialList;
int myMaterialListFId; int myMaterialListFId;
int myMaterialListBId;
QTabWidget* myMaterialTab; QTabWidget* myMaterialTab;
QWidget* myMaterialBWidget;
bool myIsBTabWasActivated;
//! Controls defining front material properties //! Controls defining material properties
QGroupBox* myAmbientGroupF; QGroupBox* myAmbientGroupF;
QtxColorButton* myAmbientColorF; QtxColorButton* myAmbientColorF;
QtxDoubleSpinBox* myAmbientCoefntF; QtxDoubleSpinBox* myAmbientCoefntF;
@ -134,25 +122,6 @@ private:
QtxDoubleSpinBox* myShininessF; QtxDoubleSpinBox* myShininessF;
//! Controls defining back material properties
QGroupBox* myAmbientGroupB;
QtxColorButton* myAmbientColorB;
QtxDoubleSpinBox* myAmbientCoefntB;
QGroupBox* myDiffuseGroupB;
QtxColorButton* myDiffuseColorB;
QtxDoubleSpinBox* myDiffuseCoefntB;
QGroupBox* mySpecularGroupB;
QtxColorButton* mySpecularColorB;
QtxDoubleSpinBox* mySpecularCoefntB;
QGroupBox* myEmissionGroupB;
QtxColorButton* myEmissionColorB;
QtxDoubleSpinBox* myEmissionCoefntB;
QtxDoubleSpinBox* myShininessB;
QString myHelpFileName; QString myHelpFileName;
ViewerType myViewerType; ViewerType myViewerType;

View File

@ -46,6 +46,7 @@ libMaterial_la_CPPFLAGS = \
-I$(srcdir)/../OBJECT -I$(srcdir)/../OBJECT
libMaterial_la_LDFLAGS = -lVTKViewer -lOCCViewer -lsuit -lSalomeApp \ libMaterial_la_LDFLAGS = -lVTKViewer -lOCCViewer -lsuit -lSalomeApp \
../OBJECT/libGEOMObject.la \
$(GUI_LDFLAGS) -lqtx \ $(GUI_LDFLAGS) -lqtx \
$(QT_MT_LIBS) \ $(QT_MT_LIBS) \
$(CAS_LDFLAGS) -lTKV3d -lTKGeomBase \ $(CAS_LDFLAGS) -lTKV3d -lTKGeomBase \

View File

@ -24,6 +24,7 @@
#include "Material_Model.h" #include "Material_Model.h"
#include "Material_ResourceMgr.h" #include "Material_ResourceMgr.h"
#include "GEOM_VTKPropertyMaterial.hxx"
#include <GEOM_Constants.h> #include <GEOM_Constants.h>
#include <QtxResourceMgr.h> #include <QtxResourceMgr.h>
@ -33,9 +34,6 @@
// OCCT Includes // OCCT Includes
#include <Graphic3d_AspectFillArea3d.hxx> #include <Graphic3d_AspectFillArea3d.hxx>
// VTK includes
#include <vtkProperty.h>
/*! /*!
\brief Constructor \brief Constructor
@ -45,6 +43,7 @@ Material_Model::Material_Model()
: myResourceMgr( 0 ) : myResourceMgr( 0 )
{ {
myShininess = 0.0; myShininess = 0.0;
myIsPhysical = false;
} }
/*! /*!
@ -96,8 +95,18 @@ Material_Model* Material_Model::getMaterialModel( QStringList theProps )
bool ok; bool ok;
double aCoef = aProp.right( aProp.length() - (anId+aPropName.length()) ).toDouble(&ok); double aCoef = aProp.right( aProp.length() - (anId+aPropName.length()) ).toDouble(&ok);
if ( ok ) if ( ok )
aModel->setShininess( aCoef ); aModel->setShininess( aCoef );
} }
// Set current material type: physical or artificial
aPropName = "Physical=";
anId = aProp.indexOf(aPropName);
if ( anId != -1 ) {
bool ok;
bool aFlag = aProp.right( aProp.length() - (anId+aPropName.length()) ).toInt( &ok );
if ( ok )
aModel->setPhysical( aFlag );
}
} }
return aModel; return aModel;
@ -171,6 +180,11 @@ QString Material_Model::getMaterialProperty()
aMaterial += "%1Shininess=%2"; aMaterial += "%1Shininess=%2";
aMaterial = aMaterial.arg( DIGIT_SEPARATOR ); aMaterial = aMaterial.arg( DIGIT_SEPARATOR );
aMaterial = aMaterial.arg( shininess() ); aMaterial = aMaterial.arg( shininess() );
// Type: physical - True, artificial - False
// Insert properties into persistent string
aMaterial += "%1Physical=%2";
aMaterial = aMaterial.arg( DIGIT_SEPARATOR );
aMaterial = aMaterial.arg( isPhysical() );
} }
return aMaterial; return aMaterial;
@ -228,6 +242,7 @@ Graphic3d_MaterialAspect Material_Model::getMaterialOCCAspect()
} }
// Shininess // Shininess
aMat.SetShininess( shininess() ); aMat.SetShininess( shininess() );
aMat.SetMaterialType(isPhysical() ? Graphic3d_MATERIAL_PHYSIC : Graphic3d_MATERIAL_ASPECT);
return aMat; return aMat;
} }
@ -237,10 +252,10 @@ Graphic3d_MaterialAspect Material_Model::getMaterialOCCAspect()
\return VTK property with correspondent material properties \return VTK property with correspondent material properties
*/ */
vtkProperty* Material_Model::getMaterialVTKProperty() GEOM_VTKPropertyMaterial* Material_Model::getMaterialVTKProperty()
{ {
// Get material properties from the current model // Get material properties from the current model
vtkProperty* aProperty = vtkProperty::New(); GEOM_VTKPropertyMaterial* aProperty = GEOM_VTKPropertyMaterial::New();
bool isReflectionTypeActive; bool isReflectionTypeActive;
QColor c; QColor c;
@ -272,6 +287,8 @@ vtkProperty* Material_Model::getMaterialVTKProperty()
} }
// Shininess // Shininess
aProperty->SetSpecularPower( shininess()*100.0 ); aProperty->SetSpecularPower( shininess()*100.0 );
//Type
aProperty->SetPhysical( isPhysical() );
return aProperty; return aProperty;
} }
@ -298,6 +315,9 @@ void Material_Model::initDefaults()
// Set default shininess // Set default shininess
setShininess( 0.039 ); setShininess( 0.039 );
// Set default type - artificial
setPhysical( false );
} }
/*! /*!
@ -308,6 +328,7 @@ void Material_Model::clearModel()
myColors.clear(); myColors.clear();
myCoefficients.clear(); myCoefficients.clear();
myShininess = 0.0; myShininess = 0.0;
myIsPhysical = false;
} }
/*! /*!
@ -319,12 +340,10 @@ void Material_Model::clearModel()
\param theResMgr resources manager \param theResMgr resources manager
\param theResSection resources section name \param theResSection resources section name
\param theIsFront if True, it is front material, else it is back material
\sa save() \sa save()
*/ */
void Material_Model::fromResources( QtxResourceMgr* theResMgr, void Material_Model::fromResources( QtxResourceMgr* theResMgr,
const QString& theResSection, const QString& theResSection/*, bool theIsFront*/ )
bool theIsFront )
{ {
// Clear current content of the model // Clear current content of the model
// before setting properties from resources // before setting properties from resources
@ -338,19 +357,11 @@ void Material_Model::fromResources( QtxResourceMgr* theResMgr,
return; return;
if ( theResSection.compare( "Geometry" ) == 0 ) { if ( theResSection.compare( "Geometry" ) == 0 ) {
if ( theIsFront ) { myResourceSection = theResMgr->stringValue("Geometry", "material", "Gold");
myResourceSection = theResMgr->stringValue("Geometry", "front_material", "Gold");
}
else {
myResourceSection = theResMgr->stringValue("Geometry", "back_material", "");
if ( myResourceSection.isEmpty() )
myResourceSection = theResMgr->stringValue("Geometry", "front_material", "Gold");
}
myResourceMgr = new Material_ResourceMgr(); myResourceMgr = new Material_ResourceMgr();
} }
QString section = resourceSection( theIsFront ); QString section = resourceSection();
// If there is no material preference in XML files, // If there is no material preference in XML files,
// use the default material hardcoded in material model // use the default material hardcoded in material model
@ -399,6 +410,11 @@ void Material_Model::fromResources( QtxResourceMgr* theResMgr,
if ( resourceMgr()->hasValue( section, "shininess" ) ) { if ( resourceMgr()->hasValue( section, "shininess" ) ) {
setShininess( resourceMgr()->doubleValue( section, "shininess" ) ); setShininess( resourceMgr()->doubleValue( section, "shininess" ) );
} }
// Set type: physical or artificial
if ( resourceMgr()->hasValue( section, "physical" ) ) {
setPhysical( resourceMgr()->booleanValue( section, "physical" ) );
}
} }
/*! /*!
@ -409,19 +425,17 @@ void Material_Model::fromResources( QtxResourceMgr* theResMgr,
\param theResMgr resources manager \param theResMgr resources manager
\param theResSection resources section name \param theResSection resources section name
\param theIsFront if True, it is front material, else it is back material
\sa fromResources() \sa fromResources()
*/ */
void Material_Model::save( QtxResourceMgr* theResMgr, void Material_Model::save( QtxResourceMgr* theResMgr,
const QString& theResSection, const QString& theResSection)
bool theIsFront )
{ {
if ( !theResMgr ) if ( !theResMgr )
theResMgr = resourceMgr(); theResMgr = resourceMgr();
if ( !theResMgr ) if ( !theResMgr )
return; return;
QString section = theResSection.isEmpty() ? resourceSection( theIsFront ) : theResSection; QString section = theResSection.isEmpty() ? resourceSection() : theResSection;
myResourceSection = section; myResourceSection = section;
if ( hasAmbientReflection() ) { if ( hasAmbientReflection() ) {
@ -478,6 +492,9 @@ void Material_Model::save( QtxResourceMgr* theResMgr,
// Save shininess // Save shininess
theResMgr->setValue( section, "shininess", shininess() ); theResMgr->setValue( section, "shininess", shininess() );
// Save type: physical or artificial
theResMgr->setValue( section, "physical", isPhysical() );
} }
/*! /*!
@ -495,20 +512,15 @@ QtxResourceMgr* Material_Model::resourceMgr() const
\brief Get resources section name \brief Get resources section name
If section name is empty, default material name from "Geometry" section If section name is empty, default material name from "Geometry" section
is returned ("front_material" or "back_material" is used depending on is returned.
the parameter value)
\param theIsFront the flag indicating that section of front or back material
is required
\return resource section name passed previously to the fromResources() method \return resource section name passed previously to the fromResources() method
\sa fromResources(), resourceMgr() \sa fromResources(), resourceMgr()
*/ */
QString Material_Model::resourceSection( bool theIsFront ) const QString Material_Model::resourceSection() const
{ {
return !myResourceSection.isEmpty() ? myResourceSection : return !myResourceSection.isEmpty() ? myResourceSection :
SUIT_Session::session()->resourceMgr()->stringValue("Geometry", SUIT_Session::session()->resourceMgr()->stringValue("Geometry", "material", "Gold");
( theIsFront ? "front_material" : "back_material" ),
"Gold");
} }
/*! /*!
@ -682,3 +694,25 @@ void Material_Model::setShininess( double theShininess)
{ {
myShininess = theShininess; myShininess = theShininess;
} }
/*!
\brief Get type value: physical or artificial
\return True if the material is physical and False if the material is artificial
\sa setShininess()
*/
bool Material_Model::isPhysical() const
{
return myIsPhysical;
}
/*!
\brief Set type: physical or artificial
\param theFlag True if the material is physical and False if the material is artificial
\sa isPhysical()
*/
void Material_Model::setPhysical( bool theFlag)
{
myIsPhysical = theFlag;
}

View File

@ -31,7 +31,7 @@
class Graphic3d_MaterialAspect; class Graphic3d_MaterialAspect;
class vtkProperty; class GEOM_VTKPropertyMaterial;
class QtxResourceMgr; class QtxResourceMgr;
@ -57,14 +57,14 @@ public:
QString getMaterialProperty(); QString getMaterialProperty();
Graphic3d_MaterialAspect getMaterialOCCAspect(); Graphic3d_MaterialAspect getMaterialOCCAspect();
vtkProperty* getMaterialVTKProperty(); GEOM_VTKPropertyMaterial* getMaterialVTKProperty();
void initDefaults(); void initDefaults();
void fromResources( QtxResourceMgr*, const QString& = QString(), bool theIsFront = true ); void fromResources( QtxResourceMgr*, const QString& = QString());
void save( QtxResourceMgr* = 0, const QString& = QString(), bool theIsFront = true ); void save( QtxResourceMgr* = 0, const QString& = QString() );
QtxResourceMgr* resourceMgr() const; QtxResourceMgr* resourceMgr() const;
QString resourceSection( bool theIsFront ) const; QString resourceSection() const;
bool hasAmbientReflection(); bool hasAmbientReflection();
bool hasDiffuseReflection(); bool hasDiffuseReflection();
@ -74,20 +74,23 @@ public:
QColor color( ReflectionType ) const; QColor color( ReflectionType ) const;
void setColor( ReflectionType, const QColor& ); void setColor( ReflectionType, const QColor& );
void setColor( QString, void setColor( QString,
QString, QString,
ReflectionType ); ReflectionType );
void removeColor( ReflectionType ); void removeColor( ReflectionType );
double coefficient( ReflectionType ) const; double coefficient( ReflectionType ) const;
void setCoefficient( ReflectionType, double ); void setCoefficient( ReflectionType, double );
void setCoefficient( QString, void setCoefficient( QString,
QString, QString,
ReflectionType ); ReflectionType );
void removeCoefficient( ReflectionType ); void removeCoefficient( ReflectionType );
double shininess() const; double shininess() const;
void setShininess( double ); void setShininess( double );
bool isPhysical() const;
void setPhysical( bool );
private: private:
void clearModel(); void clearModel();
@ -103,6 +106,8 @@ private:
double myShininess; double myShininess;
bool myIsPhysical;
}; };
#endif // MATERIAL_MODEL_H #endif // MATERIAL_MODEL_H

View File

@ -30,6 +30,7 @@
<parameter name="specular-color" value="#ffffff" /> <parameter name="specular-color" value="#ffffff" />
<parameter name="specular-coefficient" value="0.06" /> <parameter name="specular-coefficient" value="0.06" />
<parameter name="shininess" value="0.0078125" /> <parameter name="shininess" value="0.0078125" />
<parameter name="physical" value="false" />
</section> </section>
<section name="Shiny plastic" > <section name="Shiny plastic" >
<parameter name="ambient-color" value="#333333" /> <parameter name="ambient-color" value="#333333" />
@ -39,6 +40,7 @@
<parameter name="specular-color" value="#ffffff" /> <parameter name="specular-color" value="#ffffff" />
<parameter name="specular-coefficient" value="1.0" /> <parameter name="specular-coefficient" value="1.0" />
<parameter name="shininess" value="1.0" /> <parameter name="shininess" value="1.0" />
<parameter name="physical" value="false" />
</section> </section>
<section name="Satin" > <section name="Satin" >
<parameter name="ambient-color" value="#333333" /> <parameter name="ambient-color" value="#333333" />
@ -48,6 +50,7 @@
<parameter name="specular-color" value="#ffffff" /> <parameter name="specular-color" value="#ffffff" />
<parameter name="specular-coefficient" value="0.44" /> <parameter name="specular-coefficient" value="0.44" />
<parameter name="shininess" value="0.09375" /> <parameter name="shininess" value="0.09375" />
<parameter name="physical" value="false" />
</section> </section>
<section name="Metal" > <section name="Metal" >
<parameter name="diffuse-color" value="#000000" /> <parameter name="diffuse-color" value="#000000" />
@ -55,6 +58,7 @@
<parameter name="specular-color" value="#ffffff" /> <parameter name="specular-color" value="#ffffff" />
<parameter name="specular-coefficient" value="0.45" /> <parameter name="specular-coefficient" value="0.45" />
<parameter name="shininess" value="0.13" /> <parameter name="shininess" value="0.13" />
<parameter name="physical" value="false" />
</section> </section>
<section name="Brass"> <section name="Brass">
<parameter name="ambient-color" value="#543907" /> <parameter name="ambient-color" value="#543907" />
@ -64,6 +68,7 @@
<parameter name="specular-color" value="#fdf0ce" /> <parameter name="specular-color" value="#fdf0ce" />
<parameter name="specular-coefficient" value="1.0" /> <parameter name="specular-coefficient" value="1.0" />
<parameter name="shininess" value="0.21794844" /> <parameter name="shininess" value="0.21794844" />
<parameter name="physical" value="true" />
</section> </section>
<section name="Bronze"> <section name="Bronze">
<parameter name="ambient-color" value="#36200d" /> <parameter name="ambient-color" value="#36200d" />
@ -73,6 +78,7 @@
<parameter name="specular-color" value="#64452a" /> <parameter name="specular-color" value="#64452a" />
<parameter name="specular-coefficient" value="1.0" /> <parameter name="specular-coefficient" value="1.0" />
<parameter name="shininess" value="0.2" /> <parameter name="shininess" value="0.2" />
<parameter name="physical" value="true" />
</section> </section>
<section name="Copper" > <section name="Copper" >
<parameter name="ambient-color" value="#54423a" /> <parameter name="ambient-color" value="#54423a" />
@ -82,6 +88,7 @@
<parameter name="specular-color" value="#f3ba00" /> <parameter name="specular-color" value="#f3ba00" />
<parameter name="specular-coefficient" value="1.0" /> <parameter name="specular-coefficient" value="1.0" />
<parameter name="shininess" value="0.93" /> <parameter name="shininess" value="0.93" />
<parameter name="physical" value="true" />
</section> </section>
<section name="Gold" > <section name="Gold" >
<parameter name="ambient-color" value="#ffc451" /> <parameter name="ambient-color" value="#ffc451" />
@ -91,6 +98,7 @@
<parameter name="specular-color" value="#fffac7" /> <parameter name="specular-color" value="#fffac7" />
<parameter name="specular-coefficient" value="0.9" /> <parameter name="specular-coefficient" value="0.9" />
<parameter name="shininess" value="0.0625" /> <parameter name="shininess" value="0.0625" />
<parameter name="physical" value="true" />
</section> </section>
<section name="Pewter" > <section name="Pewter" >
<parameter name="ambient-color" value="#1b0f1d" /> <parameter name="ambient-color" value="#1b0f1d" />
@ -100,6 +108,7 @@
<parameter name="specular-color" value="#555585" /> <parameter name="specular-color" value="#555585" />
<parameter name="specular-coefficient" value="1.0" /> <parameter name="specular-coefficient" value="1.0" />
<parameter name="shininess" value="0.076923047" /> <parameter name="shininess" value="0.076923047" />
<parameter name="physical" value="true" />
</section> </section>
<section name="Plaster" > <section name="Plaster" >
<parameter name="ambient-color" value="#313131" /> <parameter name="ambient-color" value="#313131" />
@ -109,6 +118,7 @@
<parameter name="specular-color" value="#828282" /> <parameter name="specular-color" value="#828282" />
<parameter name="specular-coefficient" value="0.06" /> <parameter name="specular-coefficient" value="0.06" />
<parameter name="shininess" value="0.0078125" /> <parameter name="shininess" value="0.0078125" />
<parameter name="physical" value="true" />
</section> </section>
<section name="Silver" > <section name="Silver" >
<parameter name="ambient-color" value="#313131" /> <parameter name="ambient-color" value="#313131" />
@ -118,6 +128,7 @@
<parameter name="specular-color" value="#828282" /> <parameter name="specular-color" value="#828282" />
<parameter name="specular-coefficient" value="1.0" /> <parameter name="specular-coefficient" value="1.0" />
<parameter name="shininess" value="0.2" /> <parameter name="shininess" value="0.2" />
<parameter name="physical" value="true" />
</section> </section>
<section name="Steel" > <section name="Steel" >
<parameter name="ambient-color" value="#333333" /> <parameter name="ambient-color" value="#333333" />
@ -127,6 +138,7 @@
<parameter name="specular-color" value="#ffffff" /> <parameter name="specular-color" value="#ffffff" />
<parameter name="specular-coefficient" value="0.98" /> <parameter name="specular-coefficient" value="0.98" />
<parameter name="shininess" value="0.06" /> <parameter name="shininess" value="0.06" />
<parameter name="physical" value="true" />
</section> </section>
<section name="Stone" > <section name="Stone" >
<parameter name="ambient-color" value="#ffcc9e" /> <parameter name="ambient-color" value="#ffcc9e" />
@ -136,6 +148,7 @@
<parameter name="specular-color" value="#faff99" /> <parameter name="specular-color" value="#faff99" />
<parameter name="specular-coefficient" value="0.08" /> <parameter name="specular-coefficient" value="0.08" />
<parameter name="shininess" value="0.17" /> <parameter name="shininess" value="0.17" />
<parameter name="physical" value="true" />
</section> </section>
<section name="Chrome" > <section name="Chrome" >
<parameter name="ambient-color" value="#595959" /> <parameter name="ambient-color" value="#595959" />
@ -145,6 +158,7 @@
<parameter name="specular-color" value="#f9f9f9" /> <parameter name="specular-color" value="#f9f9f9" />
<parameter name="specular-coefficient" value="1.0" /> <parameter name="specular-coefficient" value="1.0" />
<parameter name="shininess" value="0.1" /> <parameter name="shininess" value="0.1" />
<parameter name="physical" value="true" />
</section> </section>
<section name="Neon" > <section name="Neon" >
<parameter name="ambient-color" value="#ffffff" /> <parameter name="ambient-color" value="#ffffff" />
@ -156,6 +170,7 @@
<parameter name="emission-color" value="#00ff75" /> <parameter name="emission-color" value="#00ff75" />
<parameter name="emission-coefficient" value="0.9" /> <parameter name="emission-coefficient" value="0.9" />
<parameter name="shininess" value="0.05" /> <parameter name="shininess" value="0.05" />
<parameter name="physical" value="true" />
</section> </section>
<section name="Aluminium" > <section name="Aluminium" >
<parameter name="ambient-color" value="#4c4c4c" /> <parameter name="ambient-color" value="#4c4c4c" />
@ -165,6 +180,7 @@
<parameter name="specular-color" value="#b3b3cc" /> <parameter name="specular-color" value="#b3b3cc" />
<parameter name="specular-coefficient" value="1.0" /> <parameter name="specular-coefficient" value="1.0" />
<parameter name="shininess" value="0.09" /> <parameter name="shininess" value="0.09" />
<parameter name="physical" value="true" />
</section> </section>
<section name="Obsidian" > <section name="Obsidian" >
<parameter name="ambient-color" value="#0d0c10" /> <parameter name="ambient-color" value="#0d0c10" />
@ -174,6 +190,7 @@
<parameter name="specular-color" value="#555458" /> <parameter name="specular-color" value="#555458" />
<parameter name="specular-coefficient" value="1.0" /> <parameter name="specular-coefficient" value="1.0" />
<parameter name="shininess" value="0.3" /> <parameter name="shininess" value="0.3" />
<parameter name="physical" value="true" />
</section> </section>
<section name="Jade" > <section name="Jade" >
<parameter name="ambient-color" value="#223828" /> <parameter name="ambient-color" value="#223828" />
@ -183,5 +200,6 @@
<parameter name="specular-color" value="#505050" /> <parameter name="specular-color" value="#505050" />
<parameter name="specular-coefficient" value="1.0" /> <parameter name="specular-coefficient" value="1.0" />
<parameter name="shininess" value="0.1" /> <parameter name="shininess" value="0.1" />
<parameter name="physical" value="true" />
</section> </section>
</document> </document>

View File

@ -113,8 +113,7 @@ GEOM_Actor::GEOM_Actor():
myHighlightProp(vtkProperty::New()), myHighlightProp(vtkProperty::New()),
myPreHighlightProp(vtkProperty::New()), myPreHighlightProp(vtkProperty::New()),
myShadingFaceProp(vtkProperty::New()), myShadingFaceProp(vtkProperty::New())
myShadingBackFaceProp(vtkProperty::New())
{ {
#ifdef MYDEBUG #ifdef MYDEBUG
MESSAGE (this<< " GEOM_Actor::GEOM_Actor"); MESSAGE (this<< " GEOM_Actor::GEOM_Actor");
@ -203,7 +202,6 @@ GEOM_Actor::~GEOM_Actor()
myHighlightProp->Delete(); myHighlightProp->Delete();
myPreHighlightProp->Delete(); myPreHighlightProp->Delete();
myShadingFaceProp->Delete(); myShadingFaceProp->Delete();
myShadingBackFaceProp->Delete();
} }
GEOM_Actor* GEOM_Actor*
@ -548,6 +546,7 @@ void GEOM_Actor::Render(vtkRenderer *ren, vtkMapper *theMapper)
case eShadingWithEdges://shading with edges case eShadingWithEdges://shading with edges
myPreHighlightProp->SetRepresentationToSurface(); myPreHighlightProp->SetRepresentationToSurface();
myHighlightProp->SetRepresentationToSurface(); myHighlightProp->SetRepresentationToSurface();
myShadingFaceProp->SetRepresentationToSurface();
break; break;
} }
@ -555,17 +554,14 @@ void GEOM_Actor::Render(vtkRenderer *ren, vtkMapper *theMapper)
if(myIsPreselected){ if(myIsPreselected){
this->myHighlightActor->SetProperty(myPreHighlightProp.GetPointer()); this->myHighlightActor->SetProperty(myPreHighlightProp.GetPointer());
myShadingFaceActor->SetProperty(myPreHighlightProp.GetPointer()); myShadingFaceActor->SetProperty(myPreHighlightProp.GetPointer());
myShadingFaceActor->SetBackfaceProperty(myPreHighlightProp.GetPointer());
} else { } else {
this->myHighlightActor->SetProperty(myShadingFaceProp.GetPointer()); this->myHighlightActor->SetProperty(myShadingFaceProp.GetPointer());
myShadingFaceActor->SetProperty(myShadingFaceProp.GetPointer()); myShadingFaceActor->SetProperty(myShadingFaceProp.GetPointer());
myShadingFaceActor->SetBackfaceProperty(myShadingBackFaceProp.GetPointer());
} }
} }
else{ else{
this->myHighlightActor->SetProperty(myHighlightProp.GetPointer()); this->myHighlightActor->SetProperty(myHighlightProp.GetPointer());
myShadingFaceActor->SetProperty(myHighlightProp.GetPointer()); myShadingFaceActor->SetProperty(myHighlightProp.GetPointer());
myShadingFaceActor->SetBackfaceProperty(myHighlightProp.GetPointer());
} }
this->Property->Render(this, ren); this->Property->Render(this, ren);
@ -676,7 +672,6 @@ void GEOM_Actor::SetOpacity(vtkFloatingPointType opa)
{ {
// enk:tested OK // enk:tested OK
myShadingFaceProp->SetOpacity(opa); myShadingFaceProp->SetOpacity(opa);
myShadingBackFaceProp->SetOpacity(opa);
myHighlightProp->SetOpacity(opa); myHighlightProp->SetOpacity(opa);
myPreHighlightProp->SetOpacity(opa); myPreHighlightProp->SetOpacity(opa);
myVertexActor->GetProperty()->SetOpacity(opa); myVertexActor->GetProperty()->SetOpacity(opa);
@ -692,7 +687,6 @@ void GEOM_Actor::SetColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloat
{ {
// enk:tested OK // enk:tested OK
myShadingFaceProp->SetColor(r,g,b); // shading color (Shading) myShadingFaceProp->SetColor(r,g,b); // shading color (Shading)
myShadingBackFaceProp->SetColor(r,g,b); // back face shading color (Shading)
myVertexActor->GetProperty()->SetColor(r,g,b); // vertex actor (Shading/Wireframe) myVertexActor->GetProperty()->SetColor(r,g,b); // vertex actor (Shading/Wireframe)
if ( myDisplayMode != (int)eShadingWithEdges ) { if ( myDisplayMode != (int)eShadingWithEdges ) {
myIsolatedEdgeActor->GetProperty()->SetColor(r,g,b); // standalone edge color (Wireframe) myIsolatedEdgeActor->GetProperty()->SetColor(r,g,b); // standalone edge color (Wireframe)
@ -715,42 +709,23 @@ void GEOM_Actor::GetColor(vtkFloatingPointType& r,vtkFloatingPointType& g,vtkFlo
void GEOM_Actor::SetMaterial(std::vector<vtkProperty*> theProps) void GEOM_Actor::SetMaterial(std::vector<vtkProperty*> theProps)
{ {
int aSize = theProps.size(); // we set material properties as back and front material
if ( aSize < 1 || aSize > 2)
return;
// theProps[0] -- front material properties
// theProps[1] -- back material properties (if exist)
// If there are no back material properties,
// we get front material properties as back material
double aCoefnt; double aCoefnt;
// Set reflection coefficients // Set reflection coefficients
aCoefnt = theProps[0]->GetAmbient(); aCoefnt = theProps[0]->GetAmbient();
myShadingFaceProp->SetAmbient(aCoefnt); myShadingFaceProp->SetAmbient(aCoefnt);
myVertexActor->GetProperty()->SetAmbient(aCoefnt); myVertexActor->GetProperty()->SetAmbient(aCoefnt);
if ( aSize == 2 )
aCoefnt = theProps[1]->GetAmbient();
myShadingBackFaceProp->SetAmbient(aCoefnt);
// Set diffuse coefficients // Set diffuse coefficients
aCoefnt = theProps[0]->GetDiffuse(); aCoefnt = theProps[0]->GetDiffuse();
myShadingFaceProp->SetDiffuse(aCoefnt); myShadingFaceProp->SetDiffuse(aCoefnt);
myVertexActor->GetProperty()->SetDiffuse(aCoefnt); myVertexActor->GetProperty()->SetDiffuse(aCoefnt);
if ( aSize == 2 )
aCoefnt = theProps[1]->GetDiffuse();
myShadingBackFaceProp->SetDiffuse(aCoefnt);
// Set specular coefficients // Set specular coefficients
aCoefnt = theProps[0]->GetSpecular(); aCoefnt = theProps[0]->GetSpecular();
myShadingFaceProp->SetSpecular(aCoefnt); myShadingFaceProp->SetSpecular(aCoefnt);
myVertexActor->GetProperty()->SetSpecular(aCoefnt); myVertexActor->GetProperty()->SetSpecular(aCoefnt);
if ( aSize == 2 )
aCoefnt = theProps[1]->GetSpecular();
myShadingBackFaceProp->SetSpecular(aCoefnt);
double* aColor; double* aColor;
@ -758,48 +733,28 @@ void GEOM_Actor::SetMaterial(std::vector<vtkProperty*> theProps)
aColor = theProps[0]->GetAmbientColor(); aColor = theProps[0]->GetAmbientColor();
myShadingFaceProp->SetAmbientColor(aColor[0], aColor[1], aColor[2]); myShadingFaceProp->SetAmbientColor(aColor[0], aColor[1], aColor[2]);
myVertexActor->GetProperty()->SetAmbientColor(aColor[0], aColor[1], aColor[2]); myVertexActor->GetProperty()->SetAmbientColor(aColor[0], aColor[1], aColor[2]);
if ( aSize == 2 )
aColor = theProps[1]->GetAmbientColor();
myShadingBackFaceProp->SetAmbientColor(aColor[0], aColor[1], aColor[2]);
// Set diffuse colors // Set diffuse colors
aColor = theProps[0]->GetDiffuseColor(); aColor = theProps[0]->GetDiffuseColor();
myShadingFaceProp->SetDiffuseColor(aColor[0], aColor[1], aColor[2]); myShadingFaceProp->SetDiffuseColor(aColor[0], aColor[1], aColor[2]);
myVertexActor->GetProperty()->SetDiffuseColor(aColor[0], aColor[1], aColor[2]); myVertexActor->GetProperty()->SetDiffuseColor(aColor[0], aColor[1], aColor[2]);
if ( aSize == 2 )
aColor = theProps[1]->GetDiffuseColor();
myShadingBackFaceProp->SetDiffuseColor(aColor[0], aColor[1], aColor[2]);
// Set specular colors // Set specular colors
aColor = theProps[0]->GetSpecularColor(); aColor = theProps[0]->GetSpecularColor();
myShadingFaceProp->SetSpecularColor(aColor[0], aColor[1], aColor[2]); myShadingFaceProp->SetSpecularColor(aColor[0], aColor[1], aColor[2]);
myVertexActor->GetProperty()->SetSpecularColor(aColor[0], aColor[1], aColor[2]); myVertexActor->GetProperty()->SetSpecularColor(aColor[0], aColor[1], aColor[2]);
if ( aSize == 2 )
aColor = theProps[1]->GetSpecularColor();
myShadingBackFaceProp->SetSpecularColor(aColor[0], aColor[1], aColor[2]);
// Set shininess // Set shininess
aCoefnt = theProps[0]->GetSpecularPower(); aCoefnt = theProps[0]->GetSpecularPower();
myShadingFaceProp->SetSpecularPower(aCoefnt); myShadingFaceProp->SetSpecularPower(aCoefnt);
myVertexActor->GetProperty()->SetSpecularPower(aCoefnt); myVertexActor->GetProperty()->SetSpecularPower(aCoefnt);
if ( aSize == 2 )
aCoefnt = theProps[1]->GetSpecularPower();
myShadingBackFaceProp->SetSpecularPower(aCoefnt);
// Set back face material property
myShadingFaceActor->SetBackfaceProperty(myShadingBackFaceProp.GetPointer());
} }
vtkProperty* GEOM_Actor::GetFrontMaterial() vtkProperty* GEOM_Actor::GetMaterial()
{ {
return myShadingFaceProp; return myShadingFaceProp;
} }
vtkProperty* GEOM_Actor::GetBackMaterial()
{
return myShadingBackFaceProp;
}
bool GEOM_Actor::IsInfinitive() bool GEOM_Actor::IsInfinitive()
{ {
return ((bool)myShape.Infinite() || isOnlyVertex); return ((bool)myShape.Infinite() || isOnlyVertex);

View File

@ -127,8 +127,7 @@ public:
// Material // Material
void SetMaterial(std::vector<vtkProperty*> theProps); void SetMaterial(std::vector<vtkProperty*> theProps);
vtkProperty* GetFrontMaterial(); vtkProperty* GetMaterial();
vtkProperty* GetBackMaterial();
virtual bool IsInfinitive(); virtual bool IsInfinitive();
@ -244,7 +243,6 @@ private:
vtkSmartPointer<vtkProperty> myHighlightProp; vtkSmartPointer<vtkProperty> myHighlightProp;
vtkSmartPointer<vtkProperty> myPreHighlightProp; vtkSmartPointer<vtkProperty> myPreHighlightProp;
vtkSmartPointer<vtkProperty> myShadingFaceProp; vtkSmartPointer<vtkProperty> myShadingFaceProp;
vtkSmartPointer<vtkProperty> myShadingBackFaceProp;
PAppendFilter myAppendFilter; PAppendFilter myAppendFilter;
PPolyGeomPainterDataMapper myPolyDataMapper; PPolyGeomPainterDataMapper myPolyDataMapper;

View File

@ -43,8 +43,7 @@
#define VECTOR_MODE_PROP "VectorMode" //Vector mode property #define VECTOR_MODE_PROP "VectorMode" //Vector mode property
#define DEFLECTION_COEFF_PROP "DeflectionCoeff" //Deflection coeff property #define DEFLECTION_COEFF_PROP "DeflectionCoeff" //Deflection coeff property
#define MARKER_TYPE_PROP "MarkerType" //Marker type property #define MARKER_TYPE_PROP "MarkerType" //Marker type property
#define FRONT_MATERIAL_PROP "FrontMaterial" //Object front material property #define MATERIAL_PROP "Material" //Object material property
#define BACK_MATERIAL_PROP "BackMaterial" //Object back material property
#define EDGE_WIDTH_PROP "EdgeWidth" //Width of the edge #define EDGE_WIDTH_PROP "EdgeWidth" //Width of the edge
#define ISOS_WIDTH_PROP "IsosWidth" //Width of the iso-lines #define ISOS_WIDTH_PROP "IsosWidth" //Width of the iso-lines
#define TOP_LEVEL_PROP "TopLevelFlag" //Top level flag #define TOP_LEVEL_PROP "TopLevelFlag" //Top level flag

View File

@ -73,20 +73,6 @@ GetProperty()
return myActor->GetProperty(); return myActor->GetProperty();
} }
void
GEOM_DeviceActor::
SetBackfaceProperty(vtkProperty* theProperty)
{
myActor->SetBackfaceProperty(theProperty);
}
vtkProperty*
GEOM_DeviceActor::
GetBackfaceProperty()
{
return myActor->GetBackfaceProperty();
}
void void
GEOM_DeviceActor:: GEOM_DeviceActor::
SetVisibility(int theVisibility) SetVisibility(int theVisibility)

View File

@ -52,9 +52,6 @@ public:
void SetProperty(vtkProperty* theProperty); void SetProperty(vtkProperty* theProperty);
vtkProperty* GetProperty(); vtkProperty* GetProperty();
void SetBackfaceProperty(vtkProperty* theProperty);
vtkProperty* GetBackfaceProperty();
void SetVisibility(int theVisibility); void SetVisibility(int theVisibility);
int GetVisibility(); int GetVisibility();

View File

@ -0,0 +1,39 @@
// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE
//
// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
// SALOME GEOM :
// File : GEOM_VTKPropertyMaterial.cxx
#include "GEOM_VTKPropertyMaterial.hxx"
#include <vtkObjectFactory.h>
vtkStandardNewMacro( GEOM_VTKPropertyMaterial );
GEOM_VTKPropertyMaterial::GEOM_VTKPropertyMaterial()
{
Physical = false;
}
GEOM_VTKPropertyMaterial::~GEOM_VTKPropertyMaterial()
{
}

View File

@ -0,0 +1,52 @@
// Copyright (C) 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE
//
// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
// SALOME GEOM :
// File : GEOM_VTKPropertyMaterial.hxx
#ifndef GEOM_VTKPropertyMaterial_H
#define GEOM_VTKPropertyMaterial_H
#include "GEOM_OBJECT_defs.hxx"
#include <vtkProperty.h>
class GEOM_OBJECT_EXPORT GEOM_VTKPropertyMaterial : public vtkProperty
{
protected:
GEOM_VTKPropertyMaterial();
virtual ~GEOM_VTKPropertyMaterial();
public:
vtkTypeMacro(GEOM_VTKPropertyMaterial, vtkProperty);
vtkSetMacro(Physical, bool);
vtkGetMacro(Physical, bool);
static GEOM_VTKPropertyMaterial* New();
protected:
bool Physical;
};
#endif

View File

@ -38,6 +38,7 @@ salomeinclude_HEADERS = \
Handle_GEOM_InteractiveObject.hxx \ Handle_GEOM_InteractiveObject.hxx \
GEOM_AISTrihedron.hxx \ GEOM_AISTrihedron.hxx \
GEOM_VTKTrihedron.hxx \ GEOM_VTKTrihedron.hxx \
GEOM_VTKPropertyMaterial.hxx \
GEOM_AISVector.hxx \ GEOM_AISVector.hxx \
GEOM_OBJECT_defs.hxx \ GEOM_OBJECT_defs.hxx \
GEOM_OCCReader.h \ GEOM_OCCReader.h \
@ -56,6 +57,7 @@ dist_libGEOMObject_la_SOURCES = \
GEOM_InteractiveObject.cxx \ GEOM_InteractiveObject.cxx \
GEOM_AISTrihedron.cxx \ GEOM_AISTrihedron.cxx \
GEOM_VTKTrihedron.cxx \ GEOM_VTKTrihedron.cxx \
GEOM_VTKPropertyMaterial.cxx \
GEOM_AISVector.cxx \ GEOM_AISVector.cxx \
GEOM_PainterPolyDataMapper.cxx \ GEOM_PainterPolyDataMapper.cxx \
GEOM_DeviceActor.cxx GEOM_DeviceActor.cxx