Salome HOME
Issue 0019818: EDF 703 SMESH VISU : Display Mesh Groups names in viewer (as a caption)
authorouv <ouv@opencascade.com>
Wed, 27 May 2009 12:05:48 +0000 (12:05 +0000)
committerouv <ouv@opencascade.com>
Wed, 27 May 2009 12:05:48 +0000 (12:05 +0000)
src/OBJECT/SMESH_Actor.cxx
src/OBJECT/SMESH_Object.cxx
src/OBJECT/SMESH_ObjectDef.h
src/SMESHGUI/SMESHGUI.cxx

index 9291df37ccd4e5d21f0cfd93bd3d72eaef36d7a5..875146e23fa4a44e81fa54381afa4296a04214ab 100644 (file)
@@ -1458,7 +1458,10 @@ vtkFloatingPointType SMESH_ActorDef::GetOpacity(){
 
 void SMESH_ActorDef::SetSufaceColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){
   mySurfaceProp->SetColor(r,g,b);
-  myNameActor->SetBackgroundColor(r,g,b);
+  if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
+    if( aGroupObj->GetElementType() == SMDSAbs_Face ||
+       aGroupObj->GetElementType() == SMDSAbs_Volume )
+      myNameActor->SetBackgroundColor(r,g,b);
   Modified();
 }
 
@@ -1480,6 +1483,9 @@ void SMESH_ActorDef::SetEdgeColor(vtkFloatingPointType r,vtkFloatingPointType g,
   myEdgeProp->SetColor(r,g,b);
   my1DProp->SetColor(r,g,b);
   my1DExtProp->SetColor(1.0-r,1.0-g,1.0-b);
+  if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
+    if( aGroupObj->GetElementType() == SMDSAbs_Edge )
+      myNameActor->SetBackgroundColor(r,g,b);
   Modified();
 }
 
@@ -1490,6 +1496,9 @@ void SMESH_ActorDef::GetEdgeColor(vtkFloatingPointType& r,vtkFloatingPointType&
 void SMESH_ActorDef::SetNodeColor(vtkFloatingPointType r,vtkFloatingPointType g,vtkFloatingPointType b){ 
   myNodeProp->SetColor(r,g,b);
   myNodeExtProp->SetColor(1.0-r,1.0-g,1.0-b);
+  if( SMESH_GroupObj* aGroupObj = dynamic_cast<SMESH_GroupObj*>( myVisualObj.get() ) )
+    if( aGroupObj->GetElementType() == SMDSAbs_Node )
+      myNameActor->SetBackgroundColor(r,g,b);
   Modified();
 }
 
index 30544754989fdeb7b411fab88f64a64c9c5edfbb..c286fcc7e355a6cd072640e7294cdc03c3d044c5 100644 (file)
@@ -748,6 +748,15 @@ bool SMESH_GroupObj::IsNodePrs() const
   return myGroupServer->GetType() == SMESH::NODE;
 }
 
+//=================================================================================
+// function : GetElementType
+// purpose  : Return type of elements of group
+//=================================================================================
+SMDSAbs_ElementType SMESH_GroupObj::GetElementType() const
+{
+  return SMDSAbs_ElementType(myGroupServer->GetType());
+}
+
 //=================================================================================
 // function : getNodesFromElems
 // purpose  : Retrieve nodes from elements
index e472a2121c2882208f7c0194d80ffbaf9a486f33..094504f33adae44e735ae4507141a1e47f2df5fc 100644 (file)
@@ -168,6 +168,8 @@ public:
   virtual int               GetEntities( const SMDSAbs_ElementType, TEntityList& ) const;
   virtual bool              IsNodePrs() const;
 
+  virtual SMDSAbs_ElementType GetElementType() const;
+
 private:
 
   SMESH::SMESH_GroupBase_var    myGroupServer;
index 04dd45a2ae39cd032f7d77a24a7b9767fc2e8113..dcbe51e7f59c77e0ec7df8aa8aaaa33420285c89 100644 (file)
                SMESH::SMESH_GroupBase_var aGroupObject = SMESH::IObjectToInterface<SMESH::SMESH_GroupBase>(IObject);
                if( !aGroupObject->_is_nil() )
                {
-                 SALOMEDS::Color aColor;
-                 aColor.R = (float)color.red() / 255.0;
-                 aColor.G = (float)color.green() / 255.0;
-                 aColor.B = (float)color.blue() / 255.0;
-                 aGroupObject->SetColor( aColor );
+                 SMESH::ElementType anElementType = aGroupObject->GetType();
+                 QColor aColor;
+                 switch( anElementType )
+                 {
+                   case SMESH::NODE: aColor = nodecolor; break;
+                   case SMESH::EDGE: aColor = edgecolor; break;
+                   default: aColor = color; break;
+                 }
+
+                 SALOMEDS::Color aGroupColor;
+                 aGroupColor.R = (float)aColor.red() / 255.0;
+                 aGroupColor.G = (float)aColor.green() / 255.0;
+                 aGroupColor.B = (float)aColor.blue() / 255.0;
+                 aGroupObject->SetColor( aGroupColor );
                }
 
                delete aDlg;