]> SALOME platform Git repositories - modules/geom.git/commitdiff
Salome HOME
INT PAL 0052625: GEOM module: customize labels color
authormpa <mpa@opencascade.com>
Mon, 23 Mar 2015 12:33:25 +0000 (15:33 +0300)
committermpa <mpa@opencascade.com>
Mon, 23 Mar 2015 12:33:25 +0000 (15:33 +0300)
13 files changed:
doc/salome/gui/GEOM/images/name_mode.png [new file with mode: 0644]
doc/salome/gui/GEOM/images/pref15.png
doc/salome/gui/GEOM/input/geometry_preferences.doc
resources/SalomeApp.xml.in
src/GEOMGUI/GEOM_Displayer.cxx
src/GEOMGUI/GEOM_msg_en.ts
src/GEOMGUI/GEOM_msg_fr.ts
src/GEOMGUI/GEOM_msg_ja.ts
src/GEOMGUI/GeometryGUI.cxx
src/OBJECT/GEOM_AISShape.cxx
src/OBJECT/GEOM_AISShape.hxx
src/OBJECT/GEOM_Actor.cxx
src/OBJECT/GEOM_Actor.h

diff --git a/doc/salome/gui/GEOM/images/name_mode.png b/doc/salome/gui/GEOM/images/name_mode.png
new file mode 100644 (file)
index 0000000..cdac11e
Binary files /dev/null and b/doc/salome/gui/GEOM/images/name_mode.png differ
index 64aa25d740097337489f7ab885f4193ca2662496..d2b5966a61a4acdbe61e2e3bdb23afb3e20e570b 100644 (file)
Binary files a/doc/salome/gui/GEOM/images/pref15.png and b/doc/salome/gui/GEOM/images/pref15.png differ
index ea011b8bfefd350b78a4a157b59865741fd0b7bb..87bb9fc56959ff3016e2f82a685274c8071be673 100644 (file)
@@ -32,6 +32,8 @@ default color for edges, vectors and wires (isolated lines).</li>
 vertices.</li>
 <li><b>Color of isolines</b> - allows to select default color for
 isolines.</li>
+<li><b>Color of labels</b> - allows to select default color for
+labels (textual fields, shape name).</li>
 <li><b>Top level color</b> - allows to select default color for objects which 
 were brought to the viewer foreground.</li>
 <li><b>Top level display mode</b> - allows to select default top level display mode between:</li>
index 142a2ec38434fbe4e6bbe066c0d73ecdd6cb0901..84f53783c7e224fbc70819938ccc5890a03848b2 100644 (file)
@@ -58,6 +58,7 @@
     <parameter name="line_color"          value="255, 0, 0" />
     <parameter name="point_color"         value="#ff7700" />
     <parameter name="isos_color"          value="200, 200, 200" />
+    <parameter name="label_color"         value="255, 255, 255" />
     <parameter name="toplevel_color"      value="170, 85, 0" />
     <parameter name="toplevel_dm"         value="0" />
     <parameter name="editgroup_color"     value="170, 85, 0" />
index 24f2c017c844a72a0a8e06bd032914684c8f4f52..f2dd8bdb07e62099a4d64b38b4a0cf30a1eac571 100644 (file)
@@ -832,6 +832,9 @@ void GEOM_Displayer::updateShapeProperties( const Handle(GEOM_AISShape)& AISShap
   // - color for edges in shading+edges mode
   AISShape->SetEdgesInShadingColor( SalomeApp_Tools::color( propMap.value( GEOM::propertyName( GEOM::OutlineColor ) ).value<QColor>() ) );
 
+  // - color of labels (textual fields and shape name)
+  AISShape->SetLabelColor( qColorFromResources( "label_color", QColor( 255, 255, 255 ) ) );
+
   // set display mode
   AISShape->SetDisplayMode( HasDisplayMode() ? 
                             // predefined display mode, manually set to displayer via GEOM_Displayer::SetDisplayMode() function 
@@ -1126,6 +1129,10 @@ void GEOM_Displayer::updateActorProperties( GEOM_Actor* actor, bool create )
   c = propMap.value( GEOM::propertyName( GEOM::OutlineColor ) ).value<QColor>();
   actor->SetEdgesInShadingColor( c.redF(), c.greenF(), c.blueF() );
 
+  // - color of labels (shape name)
+  c = colorFromResources( "label_color", QColor( 255, 255, 255 ) );
+  actor->SetLabelColor( c.redF(), c.greenF(), c.blueF() );
+
   // set opacity
   if( HasTransparency() ) {
     actor->SetOpacity( 1.0 - GetTransparency() );
index 3d0ebd610cef00c81cb53772cf420b2c0a2bd317..4da50d2e7b1262380ae7e7bafc62ca9d028ce949 100644 (file)
@@ -3304,6 +3304,10 @@ Please, select face, shell or solid and try again</translation>
         <source>PREF_ISOS_COLOR</source>
         <translation>Color of isolines</translation>
     </message>
+    <message>
+        <source>PREF_LABEL_COLOR</source>
+        <translation>Color of labels</translation>
+    </message>
     <message>
         <source>PREF_TOPLEVEL_COLOR</source>
         <translation>Top level color</translation>
index 0dda5406f6670fc8a8e82da5241696a9cce6abab..69786b158fc606e8df4b23ca0712f413462566a1 100644 (file)
@@ -3288,6 +3288,10 @@ Choisissez une face, une coque ou un solide et essayez de nouveau</translation>
         <source>PREF_ISOS_COLOR</source>
         <translation>Couleur des isolignes</translation>
     </message>
+    <message>
+        <source>PREF_LABEL_COLOR</source>
+        <translation type="unfinished">Color of labels</translation>
+    </message>
     <message>
         <source>PREF_TOPLEVEL_COLOR</source>
         <translation>Couleur des objets mis au premier plan</translation>
index a73d31a00e070f7515814fdb76ec539e61a9c3de..6b5668ec800ad0d5dc670430ddb3184da6e6228b 100644 (file)
       <source>PREF_ISOS_COLOR</source>
       <translation>輪郭の色</translation>
     </message>
+    <message>
+        <source>PREF_LABEL_COLOR</source>
+        <translation type="unfinished">Color of labels</translation>
+    </message>
     <message>
       <source>PREF_TOPLEVEL_COLOR</source>
       <translation>前景オブジェクトの色</translation>
index 526eeaac507160c8cbf8f8e78c7a8e1c3ff023dd..143f63b05d3176494c9a0fd9d12b58a530b6d756 100644 (file)
@@ -2260,6 +2260,11 @@ void GeometryGUI::createPreferences()
   addPreference( tr( "PREF_ISOS_COLOR" ), genGroup,
                  LightApp_Preferences::Color, "Geometry", "isos_color" );
 
+  addPreference( tr( "PREF_LABEL_COLOR" ), genGroup,
+                 LightApp_Preferences::Color, "Geometry", "label_color" );
+
+  addPreference( "", genGroup, LightApp_Preferences::Space );
+
   addPreference( tr( "PREF_TOPLEVEL_COLOR" ), genGroup,
                  LightApp_Preferences::Color, "Geometry", "toplevel_color" );
 
@@ -2637,7 +2642,8 @@ void GeometryGUI::preferencesChanged( const QString& section, const QString& par
               param == QString("dimensions_arrow_length") ||
               param == QString("dimensions_show_units")   ||
               param == QString("dimensions_length_units") ||
-              param == QString("dimensions_angle_units") )
+              param == QString("dimensions_angle_units")  ||
+              param == QString("label_color") )
     {
       SalomeApp_Application* anApp = getApp();
       if ( !anApp )
@@ -2668,7 +2674,22 @@ void GeometryGUI::preferencesChanged( const QString& section, const QString& par
         aViewer->GetVisible( aVisible );
         aDisplayer.Redisplay( aVisible, false, aViewer );
       }
-
+      if ( param == QString( "label_color" ) ) {
+        ViewManagerList aVMsVTK;
+        anApp->viewManagers( SVTK_Viewer::Type(), aVMsVTK );
+        ViewManagerList::Iterator anIt = aVMsVTK.begin();
+        for ( ; anIt != aVMsVTK.end(); ++anIt )
+        {
+            SVTK_Viewer* aViewer = dynamic_cast<SVTK_Viewer*>( (*anIt)->getViewModel() );
+            if ( !aViewer )
+            {
+              continue;
+            }
+            SALOME_ListIO aVisible;
+            aViewer->GetVisible( aVisible );
+            aDisplayer.Redisplay( aVisible, false, aViewer );
+          }
+      }
       aDisplayer.UpdateViewer();
     }
     else if ( param.startsWith( "dependency_tree") )
index 87838da18ed8b310f3cdbcf8126a46f3561c4a22..b1f7ade349d6fa61e13871b6d6a5bc46318dbfa2 100644 (file)
@@ -344,6 +344,10 @@ void GEOM_AISShape::SetEdgesInShadingColor(const Quantity_Color &aCol)
   myEdgesInShadingColor = aCol;
 }
 
+void GEOM_AISShape::SetLabelColor(const Quantity_Color &aCol) {
+  myLabelColor = aCol;
+}
+
 void GEOM_AISShape::highlightSubShapes(const TColStd_IndexedMapOfInteger& aIndexMap, 
                                        const Standard_Boolean aHighlight )
 {
@@ -569,6 +573,7 @@ void GEOM_AISShape::drawField( const Handle(Prs3d_Presentation)& thePrs,
 
           Handle(Graphic3d_AspectText3d) anAspectText3d = new Graphic3d_AspectText3d();
           anAspectText3d->SetStyle( Aspect_TOST_ANNOTATION );
+          anAspectText3d->SetColor( myLabelColor );
           aGroup->SetPrimitivesAspect( anAspectText3d );
 
           aGroup->Text( aString.toLatin1().constData(), aVertex, 14 );
@@ -628,6 +633,7 @@ void GEOM_AISShape::drawName( const Handle(Prs3d_Presentation)& thePrs )
 
   Handle(Graphic3d_AspectText3d) anAspectText3d = new Graphic3d_AspectText3d();
   anAspectText3d->SetStyle( Aspect_TOST_ANNOTATION );
+  anAspectText3d->SetColor( myLabelColor );
   aGroup->SetPrimitivesAspect( anAspectText3d );
 
   const char* aName = getIO()->getName();
index babd2a0b70e776f8759c20bb5024aff89da01a59..f666361265248298247f685965fa671af3ac03df 100644 (file)
@@ -79,6 +79,7 @@ public:
   
   Standard_EXPORT void SetShadingColor(const Quantity_Color &aCol);
   Standard_EXPORT void SetEdgesInShadingColor(const Quantity_Color &aCol);
+  Standard_EXPORT void SetLabelColor(const Quantity_Color &aCol);
   Standard_EXPORT void SetDisplayVectors(bool isShow);
   Standard_EXPORT void SetDisplayVertices(bool isShow);
   Standard_EXPORT void SetDisplayName(bool isShow);
@@ -137,6 +138,7 @@ protected:
 private: 
   Quantity_Color           myShadingColor;
   Quantity_Color           myEdgesInShadingColor;
+  Quantity_Color           myLabelColor;
 
   TCollection_AsciiString  myName;
   bool                     myDisplayVectors;
index 09eb877546f29c4a5456863d6986e58479745f0c..306d146e04c7070319a4aac85816c4a6ae37b99b 100644 (file)
@@ -444,12 +444,12 @@ GEOM_Actor
 
 void
 GEOM_Actor
-::SetShapeName(const TopoDS_Shape& theShape)
+::SetShapeName()
 {
-  if( !getIO() )
+  if( !getIO() || myShape.IsNull() )
     return;
 
-  gp_Ax3 anAx3 = GEOMUtils::GetPosition(theShape);
+  gp_Ax3 anAx3 = GEOMUtils::GetPosition(myShape);
   double center[3] = { anAx3.Location().X(),
                        anAx3.Location().Y(),
                        anAx3.Location().Z() };
@@ -538,7 +538,7 @@ void GEOM_Actor::SetShape (const TopoDS_Shape& theShape,
     myHighlightActor->GetDeviceActor()->SetInfinitive(true);
   }
 
-  SetShapeName( theShape );
+  SetShapeName();
 
   // 0051777: TC7.2.0: Element could not be selected in Hypothesis Construction
   myAppendFilter->Update();
@@ -856,6 +856,15 @@ void GEOM_Actor::SetIsosColor(double r, double g, double b)
   myWireframeFaceActor->GetProperty()->SetColor(r, g, b);
 }
 
+/*!
+  \brief Set color of labels
+  This actor is shown only if 'Show name' is switched-on, see SetVisibility()
+*/
+void GEOM_Actor::SetLabelColor(double r, double g, double b)
+{
+  myTextActor->GetTextProperty()->SetColor(r, g, b);
+}
+
 void GEOM_Actor::SetMaterial(std::vector<vtkProperty*> theProps)
 {
   // we set material properties as back and front material
index f2884817d3f706deb6bfdea3034f5a87ccde649a..f0f3621881eb9b22f5dd485b6c8d3a42157797a4 100644 (file)
@@ -139,6 +139,8 @@ public:
   void SetEdgesInShadingColor(double r, double g, double b);
   // Color of iso-lines
   void SetIsosColor(double r, double g, double b);
+  // Color of labels
+  void SetLabelColor(double r, double g, double b);
 
 
   // Material
@@ -224,7 +226,7 @@ protected:
   void SetModified();
 
   void GetMatrix(vtkCamera* theCam, vtkMatrix4x4 *result);
-  void SetShapeName(const TopoDS_Shape& theShape);
+  void SetShapeName();
 
   GEOM_Actor();
   ~GEOM_Actor();