#include "GeometryGUI.h"
+#include <GEOM_Constants.h>
#include <GEOM_TypeFilter.h>
#include <GEOM_EdgeFilter.h>
#include <GEOM_FaceFilter.h>
#include <GEOM_AISTrihedron.hxx>
#include <GEOM_VTKTrihedron.hxx>
+#include <Material_Model.h>
+
#include <SUIT_Desktop.h>
#include <SUIT_ViewWindow.h>
#include <SUIT_Session.h>
#include <Prs3d_PointAspect.hxx>
#include <StdSelect_TypeOfEdge.hxx>
#include <StdSelect_TypeOfFace.hxx>
+#include <StdSelect_DisplayMode.hxx>
#include <TopoDS_Face.hxx>
#include <BRep_Tool.hxx>
#include <Geom_Plane.hxx>
#include <Geom_Axis2Placement.hxx>
+#include <Graphic3d_AspectFillArea3d.hxx>
#include <gp_Pln.hxx>
#include <TColStd_MapOfInteger.hxx>
#include <TColStd_MapIteratorOfMapOfInteger.hxx>
#include <TopTools_ListIteratorOfListOfShape.hxx>
#include <TopoDS.hxx>
+#include <Prs3d_ShadingAspect.hxx>
+
+#include <BRepMesh_IncrementalMesh.hxx>
+
// VTK Includes
#include <vtkActorCollection.h>
#include <vtkProperty.h>
myShadingColor = SalomeApp_Tools::color( col );
myDisplayMode = resMgr->integerValue("Geometry", "display_mode", 0);
+
int aType = resMgr->integerValue("Geometry", "type_of_marker", (int)Aspect_TOM_PLUS);
+ myWidth = resMgr->integerValue("Geometry", "edge_width", -1);
+ myIsosWidth = resMgr->integerValue("Geometry", "isolines_width", -1);
+
myTypeOfMarker = (Aspect_TypeOfMarker)(std::min((int)Aspect_TOM_RING3, std::max((int)Aspect_TOM_POINT, aType)));
myScaleOfMarker = (resMgr->integerValue("Geometry", "marker_scale", 1)-(int)GEOM::MS_10)*0.5 + 1.0;
myScaleOfMarker = std::min(7.0, std::max(1., myScaleOfMarker));
myColor = -1;
// This color is used for shape displaying. If it is equal -1 then
// default color is used.
+ myTexture = "";
myWidth = -1;
myType = -1;
myToActivate = true;
// This parameter is used for activisation/deactivisation of objects to be displayed
+
+ #if OCC_VERSION_LARGE > 0x06050100 // Functionnality available only in OCCT 6.5.2
+ // Activate parallel vizualisation only for testing purpose
+ // and if the corresponding env variable is set to 1
+ char* parallel_visu = getenv("PARALLEL_VISU");
+ if (parallel_visu && atoi(parallel_visu))
+ {
+ MESSAGE("Parallel visualisation on");
+ BRepMesh_IncrementalMesh::SetParallelDefault(Standard_True);
+ }
+ #endif
myViewFrame = 0;
}
AISShape->SetDisplayMode( aPropMap.value(DISPLAY_MODE_PROP).toInt() );
AISShape->SetDisplayVectors(aPropMap.value(VECTOR_MODE_PROP).toInt());
- //Color property
- if(aPropMap.contains(COLOR_PROP)) {
+ if(aPropMap.contains(TOP_LEVEL_PROP)) {
+ AISShape->setTopLevel( aPropMap.value(TOP_LEVEL_PROP).value<Standard_Boolean>() );
+ }
+
+ if(aPropMap.contains(COLOR_PROP)) {
Quantity_Color quant_col = SalomeApp_Tools::color( aPropMap.value(COLOR_PROP).value<QColor>());
AISShape->SetShadingColor( quant_col );
} else
useObjColor = true;
}else {
- AISShape->SetDisplayMode( myDisplayMode );
+ MESSAGE("myDisplayMode = "<< myDisplayMode)
+ AISShape->SetDisplayMode( myDisplayMode );
AISShape->SetShadingColor( myShadingColor );
}
Handle(Prs3d_IsoAspect) anAspect = AISShape->Attributes()->UIsoAspect();
anAspect->SetNumber( anUIsoNumber );
anAspect->SetColor( aColor );
+ if(HasIsosWidth())
+ anAspect->SetWidth( GetIsosWidth() );
AISShape->Attributes()->SetUIsoAspect( anAspect );
+
anAspect = AISShape->Attributes()->VIsoAspect();
anAspect->SetNumber( aVIsoNumber );
+ if(HasIsosWidth())
+ anAspect->SetWidth( GetIsosWidth() );
anAspect->SetColor( aColor );
AISShape->Attributes()->SetVIsoAspect( anAspect );
}
}
}
+
else
{
if ( onlyVertex )
anAspect = AISShape->Attributes()->UnFreeBoundaryAspect();
anAspect->SetColor( aColor );
AISShape->Attributes()->SetUnFreeBoundaryAspect( anAspect );
+ 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 );
+
// bug [SALOME platform 0019868]
// Set deviation angle. Default one is 12 degrees (Prs3d_Drawer.cxx:18)
//AISShape->SetOwnDeviationAngle( 10*PI/180 );
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());
}
else {
aDC = aResMgr->doubleValue("Geometry", "deflection_coeff", 0.001);
AISShape->SetOwnDeviationCoefficient(aDC);
}
}
-
+
+ if ( HasTexture() )
+ {
+ AISShape->SetTextureFileName(TCollection_AsciiString(myTexture.c_str()));
+ AISShape->SetTextureMapOn();
+ AISShape->DisableTextureModulate();
+ AISShape->SetDisplayMode(3);
+ }
+
if ( HasWidth() )
AISShape->SetWidth( GetWidth() );
anAspect->SetTypeOfMarker( myTypeOfMarker );
AISShape->Attributes()->SetPointAspect( anAspect );
}
- } else if(!hasColor) {
+ } else if( !hasColor ) {
//In case if color wasn't defined in the property map of the object
//and GEOM_Object color also wasn't defined get default color from Resource Mgr.
QColor col = aResMgr->colorValue( "Geometry", "shading_color", QColor( 255, 0, 0 ) );
}
}
}
+
+ // 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();
+ 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
+ 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 );
+ }
+
+ // Set front material property
+ QString aMaterialPropF = aModelF->getMaterialProperty();
+ aStudy->setObjectProperty( aMgrId, anIO->getEntry(), FRONT_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
+ 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);
+
+ // Release memory
+ if ( aModelF )
+ delete aModelF;
+ if ( aModelB )
+ delete aModelB;
+
+ if(HasWidth())
+ aStudy->setObjectProperty( aMgrId, anIO->getEntry(), EDGE_WIDTH_PROP, GetWidth() );
+
+ if(HasIsosWidth())
+ aStudy->setObjectProperty( aMgrId, anIO->getEntry(), ISOS_WIDTH_PROP, GetIsosWidth() );
+
+
}
+
// AISShape->SetName(???); ??? necessary to set name ???
occPrs->AddObject( AISShape );
vtkActorCollection* theActors = 0;
+ QString anEntry;
+ if(!myIO.IsNull()) {
+ anEntry = myIO->getEntry();
+ }
+
if ( myType == GEOM_MARKER && myShape.ShapeType() == TopAbs_FACE ) {
//myToActivate = false; // ouv: commented to make the trihedron pickable (see IPAL18657)
GEOM_VTKTrihedron* aTrh = GEOM_VTKTrihedron::New();
else {
PropMap aDefPropMap = getDefaultPropertyMap(SVTK_Viewer::Type());
- QString anEntry;
if(!myIO.IsNull()) {
aMgrId = getViewManagerId(myViewFrame);
- anEntry = myIO->getEntry();
}
useStudy = !anEntry.isEmpty() && aMgrId != -1;
aProp->SetColor( aColor.Red(), aColor.Green(), aColor.Blue() );
}
- if ( HasWidth() )
- {
- aProp->SetLineWidth( GetWidth() );
- }
-
while ( anActor != NULL )
{
SALOME_Actor* GActor = SALOME_Actor::SafeDownCast( anActor );
aGeomGActor->SetShadingProperty( aProp );
aGeomGActor->SetWireframeProperty( aProp );
}
+
+ // Set color for edges in shading
+ SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
+ if(aResMgr) {
+ QColor c = aResMgr->colorValue( "Geometry", "edges_in_shading_color", QColor( 255, 255, 0 ) );
+ aGeomGActor->SetEdgesInShadingColor( c.red()/255., c.green()/255., c.blue()/255. );
+ }
+
int aIsos[2]= { 1, 1 };
if(useStudy) {
QString anIsos = aPropMap.value(ISOS_PROP).toString();
aIsos[0] = uv[0].toInt(); aIsos[1] = uv[1].toInt();
aGeomGActor->SetNbIsos(aIsos);
aGeomGActor->SetOpacity(1.0 - aPropMap.value(TRANSPARENCY_PROP).toDouble());
+ SetWidth(aPropMap.value(EDGE_WIDTH_PROP).toInt());
+ SetIsosWidth(aPropMap.value(ISOS_WIDTH_PROP).toInt());
aGeomGActor->SetVectorMode(aPropMap.value(VECTOR_MODE_PROP).toInt());
- aGeomGActor->setDisplayMode(aPropMap.value(DISPLAY_MODE_PROP).toInt());
+ int aDispModeId = aPropMap.value(DISPLAY_MODE_PROP).toInt();
+ // Specially processing of 'Shading with edges' mode from preferences,
+ // because there is the following enum in VTK viewer:
+ // Points - 0, Wireframe - 1, Surface - 2, Insideframe - 3, SurfaceWithEdges - 4
+ // (see VTKViewer::Representation enum) and the following enum in GEOM_Actor:
+ // eWireframe - 0, eShading - 1, eShadingWithEdges - 3
+ if ( aDispModeId == 2 )
+ // this is 'Shading with edges' mode => do the correct mapping to EDisplayMode
+ // enum in GEOM_Actor (and further to VTKViewer::Representation enum)
+ aDispModeId++;
+ 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();
+ QStringList aPropsF = aMaterialF.split(DIGIT_SEPARATOR);
+ // Create front material model
+ Material_Model* aModelF = Material_Model::getMaterialModel( aPropsF );
+ // Set front 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();
+
+ // 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;
+
vtkFloatingPointType aColor[3] = {1.,0.,0.};
if(aPropMap.contains(COLOR_PROP)) {
QColor c = aPropMap.value(COLOR_PROP).value<QColor>();
}
aGeomGActor->SetColor(aColor[0],aColor[1],aColor[2]);
}
+ else {
+ SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
+ if ( aResMgr ) {
+ // Create front material model
+ Material_Model aModelF;
+ // Get front material name from resources
+ aModelF.fromResources( aResMgr, "Geometry", true );
+ // Set front 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();
+
+ // Set material for the selected shape
+ std::vector<vtkProperty*> aProps;
+ aProps.push_back(aMatPropF);
+ aProps.push_back(aMatPropB);
+ aGeomGActor->SetMaterial(aProps);
+ }
+ }
}
+ if ( HasWidth() )
+ {
+ aGeomGActor->SetWidth( GetWidth() );
+ }
+
+
+ if ( HasIsosWidth() )
+ {
+ aGeomGActor->SetIsosWidth( GetIsosWidth() );
+ }
+
if ( myToActivate )
GActor->PickableOn();
else
myShadingColor = SalomeApp_Tools::color( col );
}
+//=================================================================
+/*!
+ * GEOM_Displayer::SetTexture
+ * Set color for shape displaying. If it is equal -1 then default color is used.
+ * Available values are from Quantity_NameOfColor enumeration
+ */
+//=================================================================
+void GEOM_Displayer::SetTexture( const std::string& texureFileName )
+{
+ if(texureFileName!="")
+ {
+ myTexture = texureFileName;
+ }
+}
+
+bool GEOM_Displayer::HasTexture() const
+{
+ return myTexture != "";
+}
+
+std::string GEOM_Displayer::GetTexture() const
+{
+ return myTexture;
+}
+
//=================================================================
/*!
* GEOM_Displayer::SetWidth
myWidth = -1;
}
+
+int GEOM_Displayer::GetIsosWidth() const
+{
+ return myIsosWidth;
+}
+
+void GEOM_Displayer::SetIsosWidth(const int width)
+{
+ myIsosWidth = width;
+}
+
+bool GEOM_Displayer::HasIsosWidth() const
+{
+ return myIsosWidth != -1;
+}
+
+
//=================================================================
/*!
* GEOM_Displayer::SetToActivate
aDefaultMap.insert( DEFLECTION_COEFF_PROP , aDC);
+ //8. Material
+ // Front material
+ Material_Model aModelF;
+ aModelF.fromResources( aResMgr, "Geometry", true );
+ QString aMaterialF = aModelF.getMaterialProperty();
+ aDefaultMap.insert( FRONT_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
+ aDefaultMap.insert( EDGE_WIDTH_PROP , aResMgr->integerValue("Geometry", "edge_width", 1));
+
+
+ //11. Width of iso-lines
+ aDefaultMap.insert( ISOS_WIDTH_PROP , aResMgr->integerValue("Geometry", "isolines_width", 1));
+
+ if(viewer_type == SOCC_Viewer::Type()) {
+
+ aDefaultMap.insert(TOP_LEVEL_PROP, Standard_False);
+ }
+
return aDefaultMap;
}
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));
+ nbInserted++;
+ }
+
+ if(!theOrigin.contains(EDGE_WIDTH_PROP)) {
+ theOrigin.insert(EDGE_WIDTH_PROP, theDefault.value(EDGE_WIDTH_PROP));
+ nbInserted++;
+ }
+
+ if(!theOrigin.contains(ISOS_WIDTH_PROP)) {
+ theOrigin.insert(ISOS_WIDTH_PROP, theDefault.value(ISOS_WIDTH_PROP));
+ nbInserted++;
+ }
+
return (nbInserted > 0);
}