<parameter name="base_vectors_length" value="1" />
<parameter name="marker_scale" value="1" />
<parameter name="geom_preview" value="false" />
- <parameter name="front_material" value="Gold" />
- <parameter name="back_material" value="Gold" />
+ <parameter name="material" value="Plastic" />
<parameter name="edge_width" value="1" />
<parameter name="isolines_width" value="1" />
<parameter name="preview_edge_width" value="1" />
#include "GeometryGUI.h"
#include "GEOM_Displayer.h"
+#include "Material_Model.h"
+
#include <GEOM_Constants.h>
#include <SalomeApp_Application.h>
#include <GEOMImpl_Types.hxx>
#include <GEOM_AISShape.hxx>
+#include <GEOM_VTKPropertyMaterial.hxx>
// OCCT Includes
#include <AIS.hxx>
#include <AIS_InteractiveObject.hxx>
#include <AIS_ListOfInteractive.hxx>
+#include <AIS_GraphicTool.hxx>
+#include <AIS_Drawer.hxx>
+#include <Prs3d_ShadingAspect.hxx>
+#include<Graphic3d_MaterialAspect.hxx>
// VTK Includes
#include <vtkActorCollection.h>
v = compoundOfVertices( idx );
else if ( p == "imported" )
v = isImported( idx );
+ else if ( p == "isPhysicalMaterial" )
+ v = isPhysicalMaterial(idx);
else
v = LightApp_Selection::parameter( idx, p );
}
}
}
- else if ( viewType == SVTK_Viewer::Type() ) { // assuming VTK
+ else if ( viewType == SVTK_Viewer::Type() ) { // assuming VTK
SVTK_Prs* vtkPrs = dynamic_cast<SVTK_Prs*>( prs );
vtkActorCollection* lst = vtkPrs ? vtkPrs->GetObjects() : 0;
if ( lst ) {
bool GEOMGUI_Selection::topLevel( const int index ) const {
bool res = false;
-
+
#ifdef USE_VISUAL_PROP_MAP
bool found = false;
QVariant v = visibleProperty( entry( index ), TOP_LEVEL_PROP );
}
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;
+}
bool hasShownChildren( const int ) const;
bool compoundOfVertices( const int ) const;
bool topLevel( const int ) const;
+ bool isPhysicalMaterial( const int ) const;
bool isComponent( const int ) const;
GEOM::GEOM_Object_ptr getObject( const int ) const;
#include <GEOM_AISVector.hxx>
#include <GEOM_AISTrihedron.hxx>
#include <GEOM_VTKTrihedron.hxx>
+#include <GEOM_VTKPropertyMaterial.hxx>
#include <Material_Model.h>
anAspect = AISShape->Attributes()->UnFreeBoundaryAspect();
anAspect->SetColor( aColor );
AISShape->Attributes()->SetUnFreeBoundaryAspect( anAspect );
- AISShape->storeBoundaryColors();
+ AISShape->storeBoundaryColors();
// Set free boundaries aspect
col = aResMgr->colorValue( "Geometry", "free_bound_color", QColor( 0, 255, 0 ) );
anAspect->SetColor( aColor );
AISShape->Attributes()->SetWireAspect( anAspect );
- // Set color for edges in shading
- col = aResMgr->colorValue( "Geometry", "edges_in_shading_color", QColor( 255, 255, 0 ) );
- aColor = SalomeApp_Tools::color( col );
- AISShape->SetEdgesInShadingColor( aColor );
+ // Set color for edges in shading
+ col = aResMgr->colorValue( "Geometry", "edges_in_shading_color", QColor( 255, 255, 0 ) );
+ aColor = SalomeApp_Tools::color( col );
+ AISShape->SetEdgesInShadingColor( aColor );
// bug [SALOME platform 0019868]
// Set deviation angle. Default one is 12 degrees (Prs3d_Drawer.cxx:18)
double aDC = 0;
if(useStudy) {
aDC = aPropMap.value(DEFLECTION_COEFF_PROP).toDouble();
- SetWidth(aPropMap.value(EDGE_WIDTH_PROP).toInt());
- SetIsosWidth(aPropMap.value(ISOS_WIDTH_PROP).toInt());
+ SetWidth(aPropMap.value(EDGE_WIDTH_PROP).toInt());
+ SetIsosWidth(aPropMap.value(ISOS_WIDTH_PROP).toInt());
}
else {
aDC = aResMgr->doubleValue("Geometry", "deflection_coeff", 0.001);
// get material properties, set material
Material_Model* aModelF = 0;
- Material_Model* aModelB = 0;
if ( useStudy ) {
- // Get front material property from study and construct front material model
- QString aMaterialF = aPropMap.value(FRONT_MATERIAL_PROP).toString();
+ // Get material property from study and construct material model
+ QString aMaterialF = aPropMap.value(MATERIAL_PROP).toString();
QStringList aProps = aMaterialF.split(DIGIT_SEPARATOR);
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 {
- // 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->fromResources( aResMgr, "Geometry", true );
-
- // Get back material property from study and construct back material model
- aModelB = new Material_Model();
- aModelB->fromResources( aResMgr, "Geometry", false );
+ aModelF->fromResources( aResMgr, "Geometry" );
}
- // Set front material property
+ // Set material property
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
- QString aMaterialPropB = aModelB->getMaterialProperty();
- aStudy->setObjectProperty( aMgrId, anIO->getEntry(), BACK_MATERIAL_PROP, aMaterialPropB );
-
- // Get front material properties from the model
+ // Get material properties from the model
Graphic3d_MaterialAspect aMatF = aModelF->getMaterialOCCAspect();
- // Get back material properties from the model
- Graphic3d_MaterialAspect aMatB = aModelB->getMaterialOCCAspect();
-
- // 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);
+ // Set material for the selected shape
+ AISShape->SetMaterial(aMatF);
// Release memory
if ( aModelF )
delete aModelF;
- if ( aModelB )
- delete aModelB;
if(HasWidth())
aStudy->setObjectProperty( aMgrId, anIO->getEntry(), EDGE_WIDTH_PROP, GetWidth() );
aGeomGActor->setDisplayMode(aDispModeId);
aGeomGActor->SetDeflection(aPropMap.value(DEFLECTION_COEFF_PROP).toDouble());
- // Get front material property of the object stored in the study
- QString aMaterialF = aPropMap.value(FRONT_MATERIAL_PROP).toString();
+ // Get material property of the object stored in the study
+ QString aMaterialF = aPropMap.value(MATERIAL_PROP).toString();
QStringList aPropsF = aMaterialF.split(DIGIT_SEPARATOR);
- // Create front material model
+ // Create material model
Material_Model* aModelF = Material_Model::getMaterialModel( aPropsF );
- // Set front material properties for the object
+ // Set material properties for the object
QString aMaterialPropF = aModelF->getMaterialProperty();
- aStudy->setObjectProperty( aMgrId, anEntry, FRONT_MATERIAL_PROP, aMaterialPropF );
- // Get material properties from the front model
- vtkProperty* aMatPropF = aModelF->getMaterialVTKProperty();
+ aStudy->setObjectProperty( aMgrId, anEntry, MATERIAL_PROP, aMaterialPropF );
+ // Get material properties from the model
+ 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
delete aModelF;
}
}
}
- aGeomGActor->SetColor(aColor[0],aColor[1],aColor[2]);
+ if ( !aMatPropF->GetPhysical() )
+ aGeomGActor->SetColor(aColor[0],aColor[1],aColor[2]);
}
else {
SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
if ( aResMgr ) {
- // Create front material model
+ // Create material model
Material_Model aModelF;
- // Get front material name from resources
- aModelF.fromResources( aResMgr, "Geometry", true );
- // Set front material properties for the object
+ // Get material name from resources
+ aModelF.fromResources( aResMgr, "Geometry" );
+ // Set material properties for the object
QString aMaterialPropF = aModelF.getMaterialProperty();
- aStudy->setObjectProperty( aMgrId, anEntry, FRONT_MATERIAL_PROP, aMaterialPropF );
- // Get material properties from the front model
- vtkProperty* 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();
+ aStudy->setObjectProperty( aMgrId, anEntry, MATERIAL_PROP, aMaterialPropF );
+ // Get material properties from the model
+ GEOM_VTKPropertyMaterial* aMatPropF = aModelF.getMaterialVTKProperty();
// Set material for the selected shape
- std::vector<vtkProperty*> aProps;
- aProps.push_back(aMatPropF);
- aProps.push_back(aMatPropB);
- aGeomGActor->SetMaterial(aProps);
- }
+ std::vector<vtkProperty*> aProps;
+ aProps.push_back( (vtkProperty*) aMatPropF );
+ aGeomGActor->SetMaterial(aProps); }
}
}
aDefaultMap.insert( DEFLECTION_COEFF_PROP , aDC);
//8. Material
- // Front material
Material_Model aModelF;
- aModelF.fromResources( aResMgr, "Geometry", true );
+ aModelF.fromResources( aResMgr, "Geometry" );
QString aMaterialF = aModelF.getMaterialProperty();
- aDefaultMap.insert( FRONT_MATERIAL_PROP , aMaterialF );
+ aDefaultMap.insert( MATERIAL_PROP , aMaterialF );
- //9. Back material
- Material_Model aModelB;
- aModelB.fromResources( aResMgr, "Geometry", false );
- QString aMaterialB = aModelB.getMaterialProperty();
- aDefaultMap.insert( BACK_MATERIAL_PROP , aMaterialB );
-
- //10. Width of the edges
+ //9. Width of the edges
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));
if(viewer_type == SOCC_Viewer::Type()) {
theOrigin.insert(DEFLECTION_COEFF_PROP, theDefault.value(DEFLECTION_COEFF_PROP));
nbInserted++;
}
- if(!theOrigin.contains(FRONT_MATERIAL_PROP)) {
- theOrigin.insert(FRONT_MATERIAL_PROP, theDefault.value(FRONT_MATERIAL_PROP));
- nbInserted++;
- }
- if(!theOrigin.contains(BACK_MATERIAL_PROP)) {
- theOrigin.insert(BACK_MATERIAL_PROP, theDefault.value(BACK_MATERIAL_PROP));
+ if(!theOrigin.contains(MATERIAL_PROP)) {
+ theOrigin.insert(MATERIAL_PROP, theDefault.value(MATERIAL_PROP));
nbInserted++;
}
nbInserted++;
}
+ if(!theOrigin.contains(COLOR_PROP)) {
+ theOrigin.insert(COLOR_PROP, theDefault.value(COLOR_PROP));
+ nbInserted++;
+ }
+
return (nbInserted > 0);
}
<translation>Default wireframe color</translation>
</message>
<message>
- <source>PREF_FRONT_MATERIAL</source>
- <translation>Default front material</translation>
- </message>
- <message>
- <source>PREF_BACK_MATERIAL</source>
- <translation>Default back material</translation>
+ <source>PREF_MATERIAL</source>
+ <translation>Default material</translation>
</message>
<message>
<source>PREF_EDGE_WIDTH</source>
<source>SHININESS</source>
<translation>Shininess:</translation>
</message>
+ <message>
+ <source>PHYSICAL</source>
+ <translation>Physical:</translation>
+ </message>
<message>
<source>CUSTOM_MATERIAL</source>
<translation>Custom material</translation>
<source>SHININESS</source>
<translation>Shininess:</translation>
</message>
+ <message>
+ <source>PHYSICAL</source>
+ <translation>Physical:</translation>
+ </message>
<message>
<source>CUSTOM_MATERIAL</source>
<translation>Matériau personnalisé</translation>
if ( pref ) {
Material_ResourceMgr aMatResMgr;
QStringList aPerfMatNames = aMatResMgr.getPreferenceMaterialsNames();
- setPreferenceProperty( pref->rootItem()->findItem( tr( "PREF_FRONT_MATERIAL" ), true )->id(),
- "strings",
- aPerfMatNames );
- setPreferenceProperty( pref->rootItem()->findItem( tr( "PREF_BACK_MATERIAL" ), true )->id(),
+ setPreferenceProperty( pref->rootItem()->findItem( tr( "PREF_MATERIAL" ), true )->id(),
"strings",
aPerfMatNames );
}
mgr->setRule( action( GEOMOp::OpVectors ), clientOCCorVTK + " and isVectorsMode", QtxPopupMgr::ToggleRule );
mgr->insert( separator(), -1, -1 ); // -----------
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->setRule( action( GEOMOp::OpTransparency ), clientOCCorVTK_AndSomeVisible, QtxPopupMgr::VisibleRule );
mgr->insert( action( GEOMOp::OpIsos ), -1, -1 ); // isos
int defl = addPreference( tr( "PREF_DEFLECTION" ), genGroup,
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,
- "Geometry", "front_material" );
+ "Geometry", "material" );
- int back_material = addPreference( tr( "PREF_BACK_MATERIAL" ), genGroup,
- LightApp_Preferences::Selector,
- "Geometry", "back_material" );
-
const int nb = 4;
int wd[nb];
int iter=0;
// Set property for default material
Material_ResourceMgr aMatResMgr;
QStringList aPrefMatNames = aMatResMgr.getPreferenceMaterialsNames();
- setPreferenceProperty( front_material, "strings", aPrefMatNames );
- setPreferenceProperty( back_material, "strings", aPrefMatNames );
+ setPreferenceProperty( material, "strings", aPrefMatNames );
// Set property vertex marker type
QList<QVariant> aMarkerTypeIndicesList;
ip->setParameter(entry, param, aProps.value(MARKER_TYPE_PROP).toString().toLatin1().data());
}
- if(aProps.contains(FRONT_MATERIAL_PROP)) {
- param = occParam + FRONT_MATERIAL_PROP;
- ip->setParameter(entry, param, aProps.value(FRONT_MATERIAL_PROP).toString().toLatin1().data());
+ if(aProps.contains(MATERIAL_PROP)) {
+ param = occParam + MATERIAL_PROP;
+ 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 )) {
param = occParam + EDGE_WIDTH_PROP;
ip->setParameter(entry, param, aProps.value(EDGE_WIDTH_PROP).toString().toLatin1().data());
aListOfMap[viewIndex].insert( DEFLECTION_COEFF_PROP, val.toDouble());
} else if(paramNameStr == MARKER_TYPE_PROP) {
aListOfMap[viewIndex].insert( MARKER_TYPE_PROP, val);
- } else if(paramNameStr == FRONT_MATERIAL_PROP) {
- aListOfMap[viewIndex].insert( FRONT_MATERIAL_PROP, val);
- } else if(paramNameStr == BACK_MATERIAL_PROP) {
- aListOfMap[viewIndex].insert( BACK_MATERIAL_PROP, val);
+ } else if(paramNameStr == MATERIAL_PROP) {
+ aListOfMap[viewIndex].insert( MATERIAL_PROP, val);
} else if(paramNameStr == EDGE_WIDTH_PROP) {
aListOfMap[viewIndex].insert( EDGE_WIDTH_PROP , val);
} else if(paramNameStr == ISOS_WIDTH_PROP) {
#include "GEOMToolsGUI_PublishDlg.h"
#include "GEOMToolsGUI_MaterialPropertiesDlg.h"
#include "GEOMToolsGUI_LineWidthDlg.h"
+#include "Material_Model.h"
#include <GeometryGUI.h>
#include <GeometryGUI_Operations.h>
if ( c.isValid() ) {
SUIT_OverrideCursor();
for ( SALOME_ListIteratorOfListIO It( selected ); It.More(); It.Next() ) {
- aView->SetColor( It.Value(), c );
- appStudy->setObjectProperty(mgrId,It.Value()->getEntry(),COLOR_PROP, c);
+ 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;
+ }
+ if ( !aPhys ) {
+ aView->SetColor( It.Value(), c );
+ appStudy->setObjectProperty(mgrId,It.Value()->getEntry(),COLOR_PROP, c);
+ }
}
GeometryGUI::Modified();
}
} // if ( isVTK )
else if ( isOCC ) {
- Handle(AIS_InteractiveObject) io = GEOMBase::GetAIS( selected.First() );
+ Handle(AIS_InteractiveObject) io = GEOMBase::GetAIS( selected.First() );
if ( !io.IsNull() ) {
Quantity_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.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 c = QColorDialog::getColor( initcolor, app->desktop() );
OCCViewer_Viewer* vm = dynamic_cast<OCCViewer_Viewer*> ( window->getViewManager()->getViewModel() );
Handle (AIS_InteractiveContext) ic = vm->getAISContext();
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 );
- 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) ) ) {
TopoDS_Shape theShape = Handle(AIS_Shape)::DownCast( io )->Shape();
ic->SetLocalAttributes(io, aCurDrawer, Standard_False);
}
}
-
+
io->SetColor( aColor );
if ( io->IsKind( STANDARD_TYPE(GEOM_AISShape) ) ) {
Handle(GEOM_AISShape) aGAISShape = Handle(GEOM_AISShape)::DownCast( io );
- aGAISShape->SetShadingColor( aColor );
- aGAISShape->storeBoundaryColors();
- }
-
+ aGAISShape->SetShadingColor( aColor );
+ aGAISShape->storeBoundaryColors();
+ }
+
appStudy->setObjectProperty(mgrId,It.Value()->getEntry(), COLOR_PROP, c);
io->Redisplay( Standard_True );
aSColor.G = (double)c.green() / 255.0;
aSColor.B = (double)c.blue() / 255.0;
anObject->SetColor( aSColor );
- anObject->SetAutoColor( false );
+ anObject->SetAutoColor( false );
}
} // for
ic->UpdateCurrentViewer();
main->setMargin( 0 ); main->setSpacing( SPACING );
// Create main widgets
- myBackMaterialCheck = new QCheckBox( tr( "MATERIAL_BACK_CHK" ), this );
QFrame* fr = new QFrame( this );
fr->setFrameStyle( QFrame::Box | QFrame::Sunken );
- main->addWidget( myBackMaterialCheck );
main->addWidget( fr );
// Create editor widgets
frLayout->setStretchFactor( myMaterialList, 1 );
frLayout->setStretchFactor( myMaterialTab, 2 );
- // ======================= Create a tab for front material =======================
+ // ======================= Create a tab for material =======================
QWidget* w1 = new QWidget( myMaterialTab );
QVBoxLayout* vLayout1 = new QVBoxLayout( w1 );
gLayout1->addWidget( mySpecularGroupF, 1, 0 );
gLayout1->addWidget( myEmissionGroupF, 1, 1 );
- // Shininess
+ // Shininess and type
QLabel* shininessLab1 = new QLabel( tr( "SHININESS" ), w1 );
myShininessF = new QtxDoubleSpinBox( w1 );
myShininessF->setMaximum(1);
myShininessF->setSingleStep(0.05);
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
- QHBoxLayout* shLayout1 = new QHBoxLayout( w1 );
+ // Shininess and type layout
+ QGridLayout* shLayout1 = new QGridLayout( w1 );
shLayout1->setMargin( MARGIN ); shLayout1->setSpacing( SPACING );
- shLayout1->addWidget( shininessLab1 );
- shLayout1->addWidget( myShininessF );
+ shLayout1->addWidget( shininessLab1, 0, 0 );
+ 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
vLayout1->addLayout( gLayout1 );
vLayout1->addLayout( shLayout1 );
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
- myMaterialTab->addTab( w1, tr( "Front material" ) );
- myMaterialTab->addTab( myMaterialBWidget, tr( "Back material" ) );
+ myMaterialTab->addTab( w1, tr( "Material" ) );
// Initialize dialog box
setFocusProxy( fr );
}
// Connect signals
- connect( myMaterialTab, SIGNAL( currentChanged( int ) ),
- this, SLOT( onCurrentTabChanged( int ) ) );
- connect( myBackMaterialCheck, SIGNAL( toggled( bool ) ),
- this, SLOT( onBackMaterialChecked( bool ) ) );
-
connect( myMaterialList, SIGNAL( itemSelectionChanged() ),
this, SLOT( onMaterialChanged() ) );
connect( myMaterialList, SIGNAL( itemChanged( QListWidgetItem* ) ),
connect( this, SIGNAL( dlgApply() ), this, SLOT( onApply() ) );
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 ) {
LightApp_SelectionMgr* aSelMgr = app->selectionMgr();
if ( aSelMgr ) {
int aMgrId = window->getViewManager()->getGlobalId();
QString aMaterialF;
- QString aMaterialB;
for ( SALOME_ListIteratorOfListIO It( selected ); It.More(); It.Next() ) {
PropMap aPropMap = aStudy->getObjectPropMap( aMgrId, It.Value()->getEntry() );
- aMaterialF = aPropMap.value(FRONT_MATERIAL_PROP).toString();
- aMaterialB = aPropMap.value(BACK_MATERIAL_PROP).toString();
+ aMaterialF = aPropMap.value(MATERIAL_PROP).toString();
if ( !aMaterialF.isEmpty() ) {
QStringList aPropsF = aMaterialF.split(DIGIT_SEPARATOR);
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;
}
}
if ( aMaterialF.isEmpty() ) {
myCurrentModelF = new Material_Model();
myCurrentModelF->fromResources( SUIT_Session::session()->resourceMgr(), "Geometry" );
-
- myCurrentModelB = new Material_Model();
- myCurrentModelB->fromResources( SUIT_Session::session()->resourceMgr(), "Geometry", false );
- }
- }
+ }
+ }
}
}
}
myMaterialList->setCurrentRow( 0 );
myMaterialListFId = 0;
- myMaterialListBId = 0;
-
- myIsBTabWasActivated = false;
myHelpFileName = "material_page.html";
}
{
if ( myCurrentModelF )
delete myCurrentModelF;
-
- if ( myCurrentModelB )
- delete myCurrentModelB;
}
/*!
void GEOMToolsGUI_MaterialPropertiesDlg::fromModel( Material_Model* model)
{
if ( !model ) return;
-
- bool isReflectionTypeActive;
-
- if ( isFrontTabActive() ) { // Fill in front material tab
-
- // Ambient reflection type
- isReflectionTypeActive = model->hasAmbientReflection();
- myAmbientGroupF->setChecked( isReflectionTypeActive );
- if ( isReflectionTypeActive ) {
- // 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() );
-
+ bool isReflectionTypeActive;
+ // Ambient reflection type
+ isReflectionTypeActive = model->hasAmbientReflection();
+ myAmbientGroupF->setChecked( isReflectionTypeActive );
+ if ( isReflectionTypeActive ) {
+ // Load ambient color
+ myAmbientColorF->setColor( model->color(Material_Model::Ambient) );
+ // Load ambient coefficient
+ myAmbientCoefntF->setValue( model->coefficient(Material_Model::Ambient) );
}
- else { // Fill in back material tab
-
- // Ambient reflection type
- isReflectionTypeActive = model->hasAmbientReflection();
- myAmbientGroupB->setChecked( isReflectionTypeActive );
- if ( isReflectionTypeActive ) {
- // Load ambient color
- myAmbientColorB->setColor( model->color(Material_Model::Ambient) );
- // Load ambient coefficient
- 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() );
-
+
+ // 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() );
+
+ //Physical
+ myMaterialPhysicalCheck->setChecked( model->isPhysical() );
+
}
/*!
- \brief Save values from dialog box fields to material model
- \param model material model
+ \brief Save values from dialog box fields material model
+ \param model material model to be filled
*/
void GEOMToolsGUI_MaterialPropertiesDlg::toModel( Material_Model* model ) const
{
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
if ( myAmbientGroupF->isChecked() ) {
model->setColor( Material_Model::Ambient, myAmbientColorF->color() );
// Shininess
model->setShininess( myShininessF->value() );
-}
-
-/*!
- \brief Save values from dialog box fields to back material model
- \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() );
+ //Type
+ model->setPhysical( myMaterialPhysicalCheck->isChecked()? true : false );
}
/*!
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
*/
// save user materials
resourceMgr()->save();
- toFrontModel( myCurrentModelF );
- if ( myBackMaterialCheck->isChecked() && myIsBTabWasActivated )
- toBackModel( myCurrentModelB );
+ toModel( myCurrentModelF );
SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
if ( !app )
// Parse material properties and form a string for persistent purpose
QString aMaterialF = myCurrentModelF->getMaterialProperty();
- QString aMaterialB;
- if ( myBackMaterialCheck->isChecked() )
- aMaterialB = myCurrentModelB->getMaterialProperty();
-
+
if ( myViewerType == VTK ) {
// Get material properties from the current model
/*
if ( !unsetMaterial )
aPropertyF = myCurrentModelF->getMaterialVTKProperty();
*/
- vtkProperty* aPropertyF = myCurrentModelF->getMaterialVTKProperty();
- vtkProperty* aPropertyB = aPropertyF;
- if ( myBackMaterialCheck->isChecked() )
- aPropertyB = myCurrentModelB->getMaterialVTKProperty();
+ GEOM_VTKPropertyMaterial* aPropertyF = myCurrentModelF->getMaterialVTKProperty();
SVTK_ViewWindow* vtkVW = dynamic_cast<SVTK_ViewWindow*>( window );
if ( !vtkVW )
else
// 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
- aStudy->setObjectProperty( aMgrId, It.Value()->getEntry(), FRONT_MATERIAL_PROP, aMaterialF );
- aStudy->setObjectProperty( aMgrId, It.Value()->getEntry(), BACK_MATERIAL_PROP, aMaterialB );
+ aStudy->setObjectProperty( aMgrId, It.Value()->getEntry(), MATERIAL_PROP, aMaterialF );
} // for...
aView->Repaint();
GeometryGUI::Modified();
aMatF = myCurrentModelF->getMaterialOCCAspect();
*/
Graphic3d_MaterialAspect aMatF = myCurrentModelF->getMaterialOCCAspect();
- Graphic3d_MaterialAspect aMatB = aMatF;
- if ( myBackMaterialCheck->isChecked() )
- aMatB = myCurrentModelB->getMaterialOCCAspect();
Handle(GEOM_AISShape) aisShape;
aisShape->UnsetMaterial();
else
*/
- if ( myBackMaterialCheck->isChecked() ) {
- // 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);
- }
+ aisShape->SetMaterial(aMatF);
if (aisShape->DisplayMode() != AIS_Shaded/*aisShape->DisplayMode() == GEOM_AISShape::ShadingWithEdges*/)
ic->RecomputePrsOnly( aisShape, Standard_False );
// Persistent
- aStudy->setObjectProperty( aMgrId, It.Value()->getEntry(), FRONT_MATERIAL_PROP, aMaterialF );
- aStudy->setObjectProperty( aMgrId, It.Value()->getEntry(), BACK_MATERIAL_PROP, aMaterialB );
+ aStudy->setObjectProperty( aMgrId, It.Value()->getEntry(), MATERIAL_PROP, aMaterialF );
}
} // for...
ic->UpdateCurrentViewer();
}
}
-/*!
- \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
*/
Material_Model* model = 0;
- bool isFrontTab = isFrontTabActive();
-
- if ( isFrontTab )
- myMaterialListFId = myMaterialList->currentRow();
- else
- myMaterialListBId = myMaterialList->currentRow();
+ myMaterialListFId = myMaterialList->currentRow();
switch ( type ) {
case Current:
// current material
- model = ( isFrontTab ? myCurrentModelF : myCurrentModelB );
+ model = myCurrentModelF;
break;
case Default:
// default material
model = new Material_Model();
- model->fromResources( SUIT_Session::session()->resourceMgr(), "Geometry", ( isFrontTab ? true : false ) );
+ model->fromResources( SUIT_Session::session()->resourceMgr(), "Geometry" );
break;
case Global:
case User:
QListWidgetItem* item = myMaterialList->currentItem();
int type = item->data( TypeRole ).toInt();
- bool isFrontTab = isFrontTabActive();
-
// for the current and user schemas do not perform any actions
if ( type == Current ) {
- Material_Model model = ( isFrontTab ? *( myCurrentModelF ) : *( myCurrentModelB ) );
+ Material_Model model = *(myCurrentModelF);
toModel( &model );
- model.save( 0, QString(), isFrontTab );
+ model.save( 0, QString() );
blockSignals( true );
fromModel( &model );
blockSignals( false );
toModel( &model );
QString oldName = item->data( NameRole ).toString(), newName = item->text();
if ( oldName == newName ) {
- model.save( resourceMgr(), oldName, isFrontTab );
+ model.save( resourceMgr(), oldName );
}
else {
resourceMgr()->remove( oldName );
- model.save( resourceMgr(), newName, isFrontTab );
+ model.save( resourceMgr(), newName );
item->setData( NameRole, newName );
}
blockSignals( true );
Material_Model model;
toModel( &model );
- model.save( resourceMgr(), newName, isFrontTab );
+ model.save( resourceMgr(), newName );
myMaterialList->setCurrentItem( item );
- if ( isFrontTab )
- myMaterialListFId = myMaterialList->currentRow();
- else
- myMaterialListBId = myMaterialList->currentRow();
-
+ myMaterialListFId = myMaterialList->currentRow();
}
}
QColor c;
- // Make changes on front material tab
+ // Make changes on material tab
if ( anObj == myAmbientGroupF ) {
myAmbientColorF->setColor( c );
myAmbientCoefntF->setValue( 0.0 );
myEmissionColorF->setColor( c );
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() );
}
void fromModel( Material_Model* );
void toModel( Material_Model* ) const;
- void toFrontModel( Material_Model* ) const;
- void toBackModel( Material_Model* ) const;
QString findUniqueName( const QString&,
QListWidgetItem* = 0,
bool = false );
- bool isFrontTabActive() const;
-
signals:
void materialChanged();
void changed();
void onApply();
void onHelp();
- void onBackMaterialChecked( bool );
- void onCurrentTabChanged( int );
void onMaterialChanged();
void onChanged();
void onItemChanged( QListWidgetItem* );
Material_ResourceMgr* myResMgr;
- QCheckBox* myBackMaterialCheck;
+ QCheckBox* myMaterialPhysicalCheck;
- //! Current material model for front material
+ //! Current material model for material
Material_Model* myCurrentModelF;
- //! Current material model for back material
- Material_Model* myCurrentModelB;
-
QListWidget* myMaterialList;
int myMaterialListFId;
- int myMaterialListBId;
QTabWidget* myMaterialTab;
- QWidget* myMaterialBWidget;
- bool myIsBTabWasActivated;
- //! Controls defining front material properties
+ //! Controls defining material properties
QGroupBox* myAmbientGroupF;
QtxColorButton* myAmbientColorF;
QtxDoubleSpinBox* myAmbientCoefntF;
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;
ViewerType myViewerType;
-I$(srcdir)/../OBJECT
libMaterial_la_LDFLAGS = -lVTKViewer -lOCCViewer -lsuit -lSalomeApp \
+ ../OBJECT/libGEOMObject.la \
$(GUI_LDFLAGS) -lqtx \
$(QT_MT_LIBS) \
$(CAS_LDFLAGS) -lTKV3d -lTKGeomBase \
#include "Material_Model.h"
#include "Material_ResourceMgr.h"
+#include "GEOM_VTKPropertyMaterial.hxx"
#include <GEOM_Constants.h>
#include <QtxResourceMgr.h>
// OCCT Includes
#include <Graphic3d_AspectFillArea3d.hxx>
-// VTK includes
-#include <vtkProperty.h>
-
/*!
\brief Constructor
: myResourceMgr( 0 )
{
myShininess = 0.0;
+ myIsPhysical = false;
}
/*!
bool ok;
double aCoef = aProp.right( aProp.length() - (anId+aPropName.length()) ).toDouble(&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;
aMaterial += "%1Shininess=%2";
aMaterial = aMaterial.arg( DIGIT_SEPARATOR );
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;
}
// Shininess
aMat.SetShininess( shininess() );
+ aMat.SetMaterialType(isPhysical() ? Graphic3d_MATERIAL_PHYSIC : Graphic3d_MATERIAL_ASPECT);
return aMat;
}
\return VTK property with correspondent material properties
*/
-vtkProperty* Material_Model::getMaterialVTKProperty()
+GEOM_VTKPropertyMaterial* Material_Model::getMaterialVTKProperty()
{
// Get material properties from the current model
- vtkProperty* aProperty = vtkProperty::New();
+ GEOM_VTKPropertyMaterial* aProperty = GEOM_VTKPropertyMaterial::New();
bool isReflectionTypeActive;
QColor c;
}
// Shininess
aProperty->SetSpecularPower( shininess()*100.0 );
+ //Type
+ aProperty->SetPhysical( isPhysical() );
return aProperty;
}
// Set default shininess
setShininess( 0.039 );
+
+ // Set default type - artificial
+ setPhysical( false );
}
/*!
myColors.clear();
myCoefficients.clear();
myShininess = 0.0;
+ myIsPhysical = false;
}
/*!
\param theResMgr resources manager
\param theResSection resources section name
- \param theIsFront if True, it is front material, else it is back material
\sa save()
*/
void Material_Model::fromResources( QtxResourceMgr* theResMgr,
- const QString& theResSection,
- bool theIsFront )
+ const QString& theResSection/*, bool theIsFront*/ )
{
// Clear current content of the model
// before setting properties from resources
return;
if ( theResSection.compare( "Geometry" ) == 0 ) {
- if ( theIsFront ) {
- myResourceSection = theResMgr->stringValue("Geometry", "front_material", "Gold");
- }
- else {
- myResourceSection = theResMgr->stringValue("Geometry", "back_material", "");
- if ( myResourceSection.isEmpty() )
- myResourceSection = theResMgr->stringValue("Geometry", "front_material", "Gold");
- }
-
+ myResourceSection = theResMgr->stringValue("Geometry", "material", "Gold");
myResourceMgr = new Material_ResourceMgr();
}
- QString section = resourceSection( theIsFront );
+ QString section = resourceSection();
// If there is no material preference in XML files,
// use the default material hardcoded in material model
if ( resourceMgr()->hasValue( section, "shininess" ) ) {
setShininess( resourceMgr()->doubleValue( section, "shininess" ) );
}
+
+ // Set type: physical or artificial
+ if ( resourceMgr()->hasValue( section, "physical" ) ) {
+ setPhysical( resourceMgr()->booleanValue( section, "physical" ) );
+ }
}
/*!
\param theResMgr resources manager
\param theResSection resources section name
- \param theIsFront if True, it is front material, else it is back material
\sa fromResources()
*/
void Material_Model::save( QtxResourceMgr* theResMgr,
- const QString& theResSection,
- bool theIsFront )
+ const QString& theResSection)
{
if ( !theResMgr )
theResMgr = resourceMgr();
if ( !theResMgr )
return;
- QString section = theResSection.isEmpty() ? resourceSection( theIsFront ) : theResSection;
+ QString section = theResSection.isEmpty() ? resourceSection() : theResSection;
myResourceSection = section;
if ( hasAmbientReflection() ) {
// Save shininess
theResMgr->setValue( section, "shininess", shininess() );
+
+ // Save type: physical or artificial
+ theResMgr->setValue( section, "physical", isPhysical() );
}
/*!
\brief Get resources section name
If section name is empty, default material name from "Geometry" section
- is returned ("front_material" or "back_material" is used depending on
- the parameter value)
+ is returned.
- \param theIsFront the flag indicating that section of front or back material
- is required
\return resource section name passed previously to the fromResources() method
\sa fromResources(), resourceMgr()
*/
-QString Material_Model::resourceSection( bool theIsFront ) const
+QString Material_Model::resourceSection() const
{
return !myResourceSection.isEmpty() ? myResourceSection :
- SUIT_Session::session()->resourceMgr()->stringValue("Geometry",
- ( theIsFront ? "front_material" : "back_material" ),
- "Gold");
+ SUIT_Session::session()->resourceMgr()->stringValue("Geometry", "material", "Gold");
}
/*!
{
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;
+}
+
\ No newline at end of file
class Graphic3d_MaterialAspect;
-class vtkProperty;
+class GEOM_VTKPropertyMaterial;
class QtxResourceMgr;
QString getMaterialProperty();
Graphic3d_MaterialAspect getMaterialOCCAspect();
- vtkProperty* getMaterialVTKProperty();
+ GEOM_VTKPropertyMaterial* getMaterialVTKProperty();
void initDefaults();
- void fromResources( QtxResourceMgr*, const QString& = QString(), bool theIsFront = true );
- void save( QtxResourceMgr* = 0, const QString& = QString(), bool theIsFront = true );
+ void fromResources( QtxResourceMgr*, const QString& = QString());
+ void save( QtxResourceMgr* = 0, const QString& = QString() );
QtxResourceMgr* resourceMgr() const;
- QString resourceSection( bool theIsFront ) const;
+ QString resourceSection() const;
bool hasAmbientReflection();
bool hasDiffuseReflection();
QColor color( ReflectionType ) const;
void setColor( ReflectionType, const QColor& );
void setColor( QString,
- QString,
- ReflectionType );
+ QString,
+ ReflectionType );
void removeColor( ReflectionType );
double coefficient( ReflectionType ) const;
void setCoefficient( ReflectionType, double );
void setCoefficient( QString,
- QString,
- ReflectionType );
+ QString,
+ ReflectionType );
void removeCoefficient( ReflectionType );
double shininess() const;
void setShininess( double );
+ bool isPhysical() const;
+ void setPhysical( bool );
+
private:
void clearModel();
double myShininess;
+ bool myIsPhysical;
+
};
#endif // MATERIAL_MODEL_H
<parameter name="specular-color" value="#ffffff" />
<parameter name="specular-coefficient" value="0.06" />
<parameter name="shininess" value="0.0078125" />
+ <parameter name="physical" value="false" />
</section>
<section name="Shiny plastic" >
<parameter name="ambient-color" value="#333333" />
<parameter name="specular-color" value="#ffffff" />
<parameter name="specular-coefficient" value="1.0" />
<parameter name="shininess" value="1.0" />
+ <parameter name="physical" value="false" />
</section>
<section name="Satin" >
<parameter name="ambient-color" value="#333333" />
<parameter name="specular-color" value="#ffffff" />
<parameter name="specular-coefficient" value="0.44" />
<parameter name="shininess" value="0.09375" />
+ <parameter name="physical" value="false" />
</section>
<section name="Metal" >
<parameter name="diffuse-color" value="#000000" />
<parameter name="specular-color" value="#ffffff" />
<parameter name="specular-coefficient" value="0.45" />
<parameter name="shininess" value="0.13" />
+ <parameter name="physical" value="false" />
</section>
<section name="Brass">
<parameter name="ambient-color" value="#543907" />
<parameter name="specular-color" value="#fdf0ce" />
<parameter name="specular-coefficient" value="1.0" />
<parameter name="shininess" value="0.21794844" />
+ <parameter name="physical" value="true" />
</section>
<section name="Bronze">
<parameter name="ambient-color" value="#36200d" />
<parameter name="specular-color" value="#64452a" />
<parameter name="specular-coefficient" value="1.0" />
<parameter name="shininess" value="0.2" />
+ <parameter name="physical" value="true" />
</section>
<section name="Copper" >
<parameter name="ambient-color" value="#54423a" />
<parameter name="specular-color" value="#f3ba00" />
<parameter name="specular-coefficient" value="1.0" />
<parameter name="shininess" value="0.93" />
+ <parameter name="physical" value="true" />
</section>
<section name="Gold" >
<parameter name="ambient-color" value="#ffc451" />
<parameter name="specular-color" value="#fffac7" />
<parameter name="specular-coefficient" value="0.9" />
<parameter name="shininess" value="0.0625" />
+ <parameter name="physical" value="true" />
</section>
<section name="Pewter" >
<parameter name="ambient-color" value="#1b0f1d" />
<parameter name="specular-color" value="#555585" />
<parameter name="specular-coefficient" value="1.0" />
<parameter name="shininess" value="0.076923047" />
+ <parameter name="physical" value="true" />
</section>
<section name="Plaster" >
<parameter name="ambient-color" value="#313131" />
<parameter name="specular-color" value="#828282" />
<parameter name="specular-coefficient" value="0.06" />
<parameter name="shininess" value="0.0078125" />
+ <parameter name="physical" value="true" />
</section>
<section name="Silver" >
<parameter name="ambient-color" value="#313131" />
<parameter name="specular-color" value="#828282" />
<parameter name="specular-coefficient" value="1.0" />
<parameter name="shininess" value="0.2" />
+ <parameter name="physical" value="true" />
</section>
<section name="Steel" >
<parameter name="ambient-color" value="#333333" />
<parameter name="specular-color" value="#ffffff" />
<parameter name="specular-coefficient" value="0.98" />
<parameter name="shininess" value="0.06" />
+ <parameter name="physical" value="true" />
</section>
<section name="Stone" >
<parameter name="ambient-color" value="#ffcc9e" />
<parameter name="specular-color" value="#faff99" />
<parameter name="specular-coefficient" value="0.08" />
<parameter name="shininess" value="0.17" />
+ <parameter name="physical" value="true" />
</section>
<section name="Chrome" >
<parameter name="ambient-color" value="#595959" />
<parameter name="specular-color" value="#f9f9f9" />
<parameter name="specular-coefficient" value="1.0" />
<parameter name="shininess" value="0.1" />
+ <parameter name="physical" value="true" />
</section>
<section name="Neon" >
<parameter name="ambient-color" value="#ffffff" />
<parameter name="emission-color" value="#00ff75" />
<parameter name="emission-coefficient" value="0.9" />
<parameter name="shininess" value="0.05" />
+ <parameter name="physical" value="true" />
</section>
<section name="Aluminium" >
<parameter name="ambient-color" value="#4c4c4c" />
<parameter name="specular-color" value="#b3b3cc" />
<parameter name="specular-coefficient" value="1.0" />
<parameter name="shininess" value="0.09" />
+ <parameter name="physical" value="true" />
</section>
<section name="Obsidian" >
<parameter name="ambient-color" value="#0d0c10" />
<parameter name="specular-color" value="#555458" />
<parameter name="specular-coefficient" value="1.0" />
<parameter name="shininess" value="0.3" />
+ <parameter name="physical" value="true" />
</section>
<section name="Jade" >
<parameter name="ambient-color" value="#223828" />
<parameter name="specular-color" value="#505050" />
<parameter name="specular-coefficient" value="1.0" />
<parameter name="shininess" value="0.1" />
+ <parameter name="physical" value="true" />
</section>
</document>
myHighlightProp(vtkProperty::New()),
myPreHighlightProp(vtkProperty::New()),
- myShadingFaceProp(vtkProperty::New()),
- myShadingBackFaceProp(vtkProperty::New())
+ myShadingFaceProp(vtkProperty::New())
{
#ifdef MYDEBUG
MESSAGE (this<< " GEOM_Actor::GEOM_Actor");
myHighlightProp->Delete();
myPreHighlightProp->Delete();
myShadingFaceProp->Delete();
- myShadingBackFaceProp->Delete();
}
GEOM_Actor*
case eShadingWithEdges://shading with edges
myPreHighlightProp->SetRepresentationToSurface();
myHighlightProp->SetRepresentationToSurface();
+ myShadingFaceProp->SetRepresentationToSurface();
break;
}
if(myIsPreselected){
this->myHighlightActor->SetProperty(myPreHighlightProp.GetPointer());
myShadingFaceActor->SetProperty(myPreHighlightProp.GetPointer());
- myShadingFaceActor->SetBackfaceProperty(myPreHighlightProp.GetPointer());
} else {
this->myHighlightActor->SetProperty(myShadingFaceProp.GetPointer());
myShadingFaceActor->SetProperty(myShadingFaceProp.GetPointer());
- myShadingFaceActor->SetBackfaceProperty(myShadingBackFaceProp.GetPointer());
}
}
else{
this->myHighlightActor->SetProperty(myHighlightProp.GetPointer());
myShadingFaceActor->SetProperty(myHighlightProp.GetPointer());
- myShadingFaceActor->SetBackfaceProperty(myHighlightProp.GetPointer());
}
this->Property->Render(this, ren);
{
// enk:tested OK
myShadingFaceProp->SetOpacity(opa);
- myShadingBackFaceProp->SetOpacity(opa);
myHighlightProp->SetOpacity(opa);
myPreHighlightProp->SetOpacity(opa);
myVertexActor->GetProperty()->SetOpacity(opa);
{
// enk:tested OK
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)
if ( myDisplayMode != (int)eShadingWithEdges ) {
myIsolatedEdgeActor->GetProperty()->SetColor(r,g,b); // standalone edge color (Wireframe)
void GEOM_Actor::SetMaterial(std::vector<vtkProperty*> theProps)
{
- int aSize = theProps.size();
-
- 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
-
+ // we set material properties as back and front material
double aCoefnt;
// Set reflection coefficients
aCoefnt = theProps[0]->GetAmbient();
myShadingFaceProp->SetAmbient(aCoefnt);
myVertexActor->GetProperty()->SetAmbient(aCoefnt);
- if ( aSize == 2 )
- aCoefnt = theProps[1]->GetAmbient();
- myShadingBackFaceProp->SetAmbient(aCoefnt);
// Set diffuse coefficients
aCoefnt = theProps[0]->GetDiffuse();
myShadingFaceProp->SetDiffuse(aCoefnt);
myVertexActor->GetProperty()->SetDiffuse(aCoefnt);
- if ( aSize == 2 )
- aCoefnt = theProps[1]->GetDiffuse();
- myShadingBackFaceProp->SetDiffuse(aCoefnt);
// Set specular coefficients
aCoefnt = theProps[0]->GetSpecular();
myShadingFaceProp->SetSpecular(aCoefnt);
myVertexActor->GetProperty()->SetSpecular(aCoefnt);
- if ( aSize == 2 )
- aCoefnt = theProps[1]->GetSpecular();
- myShadingBackFaceProp->SetSpecular(aCoefnt);
-
double* aColor;
aColor = theProps[0]->GetAmbientColor();
myShadingFaceProp->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
aColor = theProps[0]->GetDiffuseColor();
myShadingFaceProp->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
aColor = theProps[0]->GetSpecularColor();
myShadingFaceProp->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
aCoefnt = theProps[0]->GetSpecularPower();
myShadingFaceProp->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;
}
-vtkProperty* GEOM_Actor::GetBackMaterial()
-{
- return myShadingBackFaceProp;
-}
-
bool GEOM_Actor::IsInfinitive()
{
return ((bool)myShape.Infinite() || isOnlyVertex);
// Material
void SetMaterial(std::vector<vtkProperty*> theProps);
- vtkProperty* GetFrontMaterial();
- vtkProperty* GetBackMaterial();
+ vtkProperty* GetMaterial();
virtual bool IsInfinitive();
vtkSmartPointer<vtkProperty> myHighlightProp;
vtkSmartPointer<vtkProperty> myPreHighlightProp;
vtkSmartPointer<vtkProperty> myShadingFaceProp;
- vtkSmartPointer<vtkProperty> myShadingBackFaceProp;
PAppendFilter myAppendFilter;
PPolyGeomPainterDataMapper myPolyDataMapper;
#define VECTOR_MODE_PROP "VectorMode" //Vector mode property
#define DEFLECTION_COEFF_PROP "DeflectionCoeff" //Deflection coeff property
#define MARKER_TYPE_PROP "MarkerType" //Marker type property
-#define FRONT_MATERIAL_PROP "FrontMaterial" //Object front material property
-#define BACK_MATERIAL_PROP "BackMaterial" //Object back material property
+#define MATERIAL_PROP "Material" //Object material property
#define EDGE_WIDTH_PROP "EdgeWidth" //Width of the edge
#define ISOS_WIDTH_PROP "IsosWidth" //Width of the iso-lines
#define TOP_LEVEL_PROP "TopLevelFlag" //Top level flag
return myActor->GetProperty();
}
-void
-GEOM_DeviceActor::
-SetBackfaceProperty(vtkProperty* theProperty)
-{
- myActor->SetBackfaceProperty(theProperty);
-}
-
-vtkProperty*
-GEOM_DeviceActor::
-GetBackfaceProperty()
-{
- return myActor->GetBackfaceProperty();
-}
-
void
GEOM_DeviceActor::
SetVisibility(int theVisibility)
void SetProperty(vtkProperty* theProperty);
vtkProperty* GetProperty();
-
- void SetBackfaceProperty(vtkProperty* theProperty);
- vtkProperty* GetBackfaceProperty();
void SetVisibility(int theVisibility);
int GetVisibility();
--- /dev/null
+// 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()
+{
+}
--- /dev/null
+// 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
Handle_GEOM_InteractiveObject.hxx \
GEOM_AISTrihedron.hxx \
GEOM_VTKTrihedron.hxx \
+ GEOM_VTKPropertyMaterial.hxx \
GEOM_AISVector.hxx \
GEOM_OBJECT_defs.hxx \
GEOM_OCCReader.h \
GEOM_InteractiveObject.cxx \
GEOM_AISTrihedron.cxx \
GEOM_VTKTrihedron.cxx \
+ GEOM_VTKPropertyMaterial.cxx \
GEOM_AISVector.cxx \
GEOM_PainterPolyDataMapper.cxx \
GEOM_DeviceActor.cxx