From af12d871fc1ca44e4e1330420b3ab15e8b4f8525 Mon Sep 17 00:00:00 2001 From: mzn Date: Fri, 25 Aug 2006 14:05:16 +0000 Subject: [PATCH] Fix for bug PAL12858(EDF210 GEOM Preferences menu of GEOM: color of the wireframe?) --- src/GEOMGUI/GEOM_Displayer.cxx | 48 +++++++++++++++++ src/GEOMGUI/GEOM_msg_en.po | 15 ++++++ src/GEOMGUI/GeometryGUI.cxx | 37 +++++++++---- src/OBJECT/GEOM_AssemblyBuilder.cxx | 82 ++++++++++++++++++++++------- 4 files changed, 153 insertions(+), 29 deletions(-) diff --git a/src/GEOMGUI/GEOM_Displayer.cxx b/src/GEOMGUI/GEOM_Displayer.cxx index 105d74879..7176ffeb7 100644 --- a/src/GEOMGUI/GEOM_Displayer.cxx +++ b/src/GEOMGUI/GEOM_Displayer.cxx @@ -69,6 +69,7 @@ // OCCT Includes #include #include +#include #include #include #include @@ -530,6 +531,53 @@ void GEOM_Displayer::Update( SALOME_OCCPrs* prs ) AISShape->Attributes()->SetPointAspect( anAspect ); } } + else + { + SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr(); + + // Set color for iso lines + QColor col = aResMgr->colorValue( "Geometry", "isos_color", QColor(int(0.5*255), int(0.5*255), int(0.5*255)) ); + Quantity_Color aColor = SalomeApp_Tools::color( col ); + + Handle(Prs3d_IsoAspect) anAspect = AISShape->Attributes()->UIsoAspect(); + anAspect->SetColor( aColor ); + AISShape->Attributes()->SetUIsoAspect( anAspect ); + + anAspect = AISShape->Attributes()->VIsoAspect(); + anAspect->SetColor( aColor ); + AISShape->Attributes()->SetVIsoAspect( anAspect ); + + if ( myShape.ShapeType() == TopAbs_FACE ) + { + col = aResMgr->colorValue( "Geometry", "face_color", QColor( 0, 255, 0 ) ); + aColor = SalomeApp_Tools::color( col ); + + AISShape->SetColor( aColor ); + } + else if ( myShape.ShapeType() == TopAbs_EDGE || myShape.ShapeType() == TopAbs_WIRE ) + { + col = aResMgr->colorValue( "Geometry", "edge_wire_color", QColor( 255, 0, 0 ) ); + aColor = SalomeApp_Tools::color( col ); + + AISShape->SetColor( aColor ); + } + else if ( myShape.ShapeType() == TopAbs_VERTEX ) + { + col = aResMgr->colorValue( "Geometry", "point_color", QColor( 255, 255, 0 ) ); + aColor = SalomeApp_Tools::color( col ); + + Handle(Prs3d_PointAspect) anAspect = AISShape->Attributes()->PointAspect(); + anAspect->SetColor( aColor ); + AISShape->Attributes()->SetPointAspect( anAspect ); + } + else + { + col = aResMgr->colorValue( "Geometry", "wireframe_color", QColor( 255, 255, 0 ) ); + aColor = SalomeApp_Tools::color( col ); + + AISShape->SetColor( aColor ); + } + } if ( HasWidth() ) AISShape->SetWidth( GetWidth() ); diff --git a/src/GEOMGUI/GEOM_msg_en.po b/src/GEOMGUI/GEOM_msg_en.po index f27c3eef5..92576204e 100644 --- a/src/GEOMGUI/GEOM_msg_en.po +++ b/src/GEOMGUI/GEOM_msg_en.po @@ -2935,6 +2935,21 @@ msgstr "General" msgid "PREF_SHADING_COLOR" msgstr "Default shading color" +msgid "PREF_WIREFRAME_COLOR" +msgstr "Default wireframe color" + +msgid "PREF_FACE_COLOR" +msgstr "Color of faces" + +msgid "PREF_EDGE_WIRE_COLOR" +msgstr "Color of edges and wires" + +msgid "PREF_POINT_COLOR" +msgstr "Color of points" + +msgid "PREF_ISOS_COLOR" +msgstr "Color of isolines" + msgid "PREF_STEP_VALUE" msgstr "Step value for spin boxes" diff --git a/src/GEOMGUI/GeometryGUI.cxx b/src/GEOMGUI/GeometryGUI.cxx index 8db643a17..f49100919 100644 --- a/src/GEOMGUI/GeometryGUI.cxx +++ b/src/GEOMGUI/GeometryGUI.cxx @@ -1647,18 +1647,31 @@ void GeometryGUI::createPreferences() int tabId = addPreference( tr( "PREF_TAB_SETTINGS" ) ); int genGroup = addPreference( tr( "PREF_GROUP_GENERAL" ), tabId ); - addPreference( tr( "PREF_SHADING_COLOR" ), genGroup, - LightApp_Preferences::Color, "Geometry", "shading_color" ); - int step = addPreference( tr( "PREF_STEP_VALUE" ), genGroup, - LightApp_Preferences::IntSpin, "Geometry", "SettingsGeomStep" ); + setPreferenceProperty( genGroup, "columns", 1 ); + int dispmode = addPreference( tr( "PREF_DISPLAY_MODE" ), genGroup, LightApp_Preferences::Selector, "Geometry", "display_mode" ); - setPreferenceProperty( genGroup, "columns", 1 ); - - setPreferenceProperty( step, "min", 0.001 ); - setPreferenceProperty( step, "max", 10000 ); - setPreferenceProperty( step, "precision", 3 ); + addPreference( tr( "PREF_SHADING_COLOR" ), genGroup, + LightApp_Preferences::Color, "Geometry", "shading_color" ); + + addPreference( tr( "PREF_WIREFRAME_COLOR" ), genGroup, + LightApp_Preferences::Color, "Geometry", "wireframe_color" ); + + addPreference( tr( "PREF_FACE_COLOR" ), genGroup, + LightApp_Preferences::Color, "Geometry", "face_color" ); + + addPreference( tr( "PREF_EDGE_WIRE_COLOR"), genGroup, + LightApp_Preferences::Color, "Geometry", "edge_wire_color" ); + + addPreference( tr( "PREF_POINT_COLOR"), genGroup, + LightApp_Preferences::Color, "Geometry", "point_color" ); + + addPreference( tr( "PREF_ISOS_COLOR" ), genGroup, + LightApp_Preferences::Color, "Geometry", "isos_color" ); + + int step = addPreference( tr( "PREF_STEP_VALUE" ), genGroup, + LightApp_Preferences::IntSpin, "Geometry", "SettingsGeomStep" ); // Set property for default display mode QStringList aModesList; @@ -1671,6 +1684,12 @@ void GeometryGUI::createPreferences() setPreferenceProperty( dispmode, "strings", aModesList ); setPreferenceProperty( dispmode, "indexes", anIndexesList ); + + // Set property for step value for spinboxes + setPreferenceProperty( step, "min", 0.001 ); + setPreferenceProperty( step, "max", 10000 ); + setPreferenceProperty( step, "precision", 3 ); + } void GeometryGUI::preferencesChanged( const QString& section, const QString& param ) diff --git a/src/OBJECT/GEOM_AssemblyBuilder.cxx b/src/OBJECT/GEOM_AssemblyBuilder.cxx index 603a071c9..b78e9f78a 100644 --- a/src/OBJECT/GEOM_AssemblyBuilder.cxx +++ b/src/OBJECT/GEOM_AssemblyBuilder.cxx @@ -34,6 +34,8 @@ #include "GEOM_AssemblyBuilder.h" #include "GEOM_Actor.h" +#include + #include // Open CASCADE Includes @@ -80,12 +82,19 @@ void GEOM_AssemblyBuilder::InitProperties(vtkProperty* IsoProp, FaceProp->SetDiffuseColor(0.780392, 0.568627, 0.113725); FaceProp->SetSpecularColor(0.992157, 0.941176, 0.807843); - // Wireframe for iso - IsoProp->SetRepresentationToWireframe(); - IsoProp->SetAmbientColor(0.5, 0.5, 0.5); - IsoProp->SetDiffuseColor(0.5, 0.5, 0.5); - IsoProp->SetSpecularColor(0.5, 0.5, 0.5); + SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr(); + QColor aColor; + // Wireframe for iso + aColor = aResMgr->colorValue( "Geometry", "isos_color", QColor( int(0.5*255), int(0.5*255), int(0.5*255) ) ); + float red = aColor.red()/255.0; + float green = aColor.green()/255.0; + float blue = aColor.blue()/255.0; + IsoProp->SetRepresentationToWireframe(); + IsoProp->SetAmbientColor(red, green, blue); + IsoProp->SetDiffuseColor(red, green, blue); + IsoProp->SetSpecularColor(red, green, blue); + // Wireframe for iso IsoPVProp->SetRepresentationToWireframe(); IsoPVProp->SetAmbientColor(0, 1, 1); @@ -93,23 +102,34 @@ void GEOM_AssemblyBuilder::InitProperties(vtkProperty* IsoProp, IsoPVProp->SetSpecularColor(0, 1, 1); // Wireframe for shared edge + aColor = aResMgr->colorValue( "Geometry", "wireframe_color", QColor( 255, 255, 0 ) ); + red = aColor.red()/255.0; + green = aColor.green()/255.0; + blue = aColor.blue()/255.0; EdgeSProp->SetRepresentationToWireframe(); - EdgeSProp->SetAmbientColor(1, 1, 0); - EdgeSProp->SetDiffuseColor(1, 1, 0); - EdgeSProp->SetSpecularColor(1, 1, 0); - + EdgeSProp->SetAmbientColor(red, green, blue); + EdgeSProp->SetDiffuseColor(red, green, blue); + EdgeSProp->SetSpecularColor(red, green, blue); + // Wireframe for free edge + aColor = aResMgr->colorValue( "Geometry", "face_color", QColor( 0, 255, 0 ) ); + red = aColor.red()/255.0; + green = aColor.green()/255.0; + blue = aColor.blue()/255.0; EdgeFProp->SetRepresentationToWireframe(); - EdgeFProp->SetAmbientColor(0, 1, 0); - EdgeFProp->SetDiffuseColor(0, 1, 0); - EdgeFProp->SetSpecularColor(0, 1, 0); + EdgeFProp->SetAmbientColor(red, green, blue); + EdgeFProp->SetDiffuseColor(red, green, blue); + EdgeFProp->SetSpecularColor(red, green, blue); // Wireframe for isolated edge + aColor = aResMgr->colorValue( "Geometry", "edge_wire_color", QColor( 255, 0, 0 ) ); + red = aColor.red()/255.0; + green = aColor.green()/255.0; + blue = aColor.blue()/255.0; EdgeIProp->SetRepresentationToWireframe(); - EdgeIProp->SetAmbientColor(1, 0, 0); - EdgeIProp->SetDiffuseColor(1, 0, 0); - EdgeIProp->SetSpecularColor(1, 0, 0); - + EdgeIProp->SetAmbientColor(red, green, blue); + EdgeIProp->SetDiffuseColor(red, green, blue); + // Wireframe for Preview edge EdgePVProp->SetRepresentationToWireframe(); EdgePVProp->SetAmbientColor(1, 1, 0); @@ -117,11 +137,15 @@ void GEOM_AssemblyBuilder::InitProperties(vtkProperty* IsoProp, EdgePVProp->SetSpecularColor(1, 1, 0); // Wireframe for vertex + aColor = aResMgr->colorValue( "Geometry", "point_color", QColor( 255, 255, 0 ) ); + red = aColor.red()/255.0; + green = aColor.green()/255.0; + blue = aColor.blue()/255.0; VertexProp->SetRepresentationToWireframe(); - VertexProp->SetAmbientColor(1, 1, 0); - VertexProp->SetDiffuseColor(1, 1, 0); - VertexProp->SetSpecularColor(1, 1, 0); - + VertexProp->SetAmbientColor(red, green, blue); + VertexProp->SetDiffuseColor(red, green, blue); + VertexProp->SetSpecularColor(red, green, blue); + // Wireframe for vertex VertexPVProp->SetRepresentationToWireframe(); VertexPVProp->SetAmbientColor(0, 1, 1); @@ -225,11 +249,13 @@ vtkActorCollection* GEOM_AssemblyBuilder::BuildActors(const TopoDS_Shape& myShap continue; } + /* PAL12858: we should to unify colors with OCC // compute the number of faces Standard_Integer nbf = edgemap.FindFromKey(ex2.Current()).Extent(); GEOM_Actor* EdgeActor = GEOM_Actor::New(); EdgeActor->SubShapeOn(); EdgeActor->setInputShape(ex2.Current(),deflection,mode); + switch (nbf) { case 0 : // isolated edge @@ -252,6 +278,22 @@ vtkActorCollection* GEOM_AssemblyBuilder::BuildActors(const TopoDS_Shape& myShap EdgeActor->SetWireframeProperty(EdgeSProp); } } + */ + GEOM_Actor* EdgeActor = GEOM_Actor::New(); + EdgeActor->SubShapeOn(); + EdgeActor->setInputShape(ex2.Current(),deflection,mode); + + if ( myShape.ShapeType() == 4 ) + { + EdgeActor->SetShadingProperty(EdgeFProp); + EdgeActor->SetWireframeProperty(EdgeFProp); + } + else + { + EdgeActor->SetShadingProperty(EdgeSProp); + EdgeActor->SetWireframeProperty(EdgeSProp); + } + EdgeActor->SetPreviewProperty(EdgePVProp); AISActors->AddItem(EdgeActor); }