]> SALOME platform Git repositories - modules/visu.git/commitdiff
Salome HOME
Issue 0020306: EDF 981 VISU : Color of edges of a surface frame representation V5_1_main_20090812 V5_1_main_20090813
authorouv <ouv@opencascade.com>
Fri, 7 Aug 2009 10:12:39 +0000 (10:12 +0000)
committerouv <ouv@opencascade.com>
Fri, 7 Aug 2009 10:12:39 +0000 (10:12 +0000)
idl/VISU_Gen.idl
resources/SalomeApp.xml
src/OBJECT/VISU_ScalarMapAct.cxx
src/OBJECT/VISU_ScalarMapAct.h
src/VISUGUI/VISU_msg_en.ts
src/VISUGUI/VisuGUI.cxx
src/VISU_I/VISU_DumpPython.cc
src/VISU_I/VISU_Mesh_i.cc
src/VISU_I/VISU_ScalarMap_i.cc
src/VISU_I/VISU_ScalarMap_i.hh

index 1d7e764013221a4b7cca159a0043005b60b98c45..12efbee1693381753871389c61dfebf681d8dd34 100644 (file)
@@ -781,6 +781,16 @@ module VISU {
      */
     GaussMetric GetGaussMetric();
 
+    /*!
+     * Sets the color of mesh links.
+     * \param theColor The color of the links. This parameter is taken from <VAR>Color</VAR> enumeration.
+     */
+    void SetLinkColor(in SALOMEDS::Color theColor);
+
+    /*!
+     * Gets the color of mesh links.
+     */
+    SALOMEDS::Color GetLinkColor();
   };
 
   //-------------------------------------------------------
index d168f5b79ba332f451bdc3ff086298a9c5bea825..3aee730bb4fc9f6bd35729ea3533ba0a31afd8e9 100644 (file)
@@ -60,6 +60,7 @@
     <parameter name="show_manifold_edges"      value="false"/>
     <parameter name="show_non_manifold_edges"  value="false"/>
     <parameter name="feature_edges_coloring"   value="false"/>
+    <parameter name="edge_color"               value="255, 255, 255"/>
     <parameter name="scalar_bar_horizontal_height" value="0.08"/>
     <parameter name="scalar_bar_horizontal_width"  value="0.8" />
     <parameter name="scalar_bar_horizontal_x" value="0.1"/>
index 51e3ed8064ed6ef2c7c6bb9a7604319fced2cc67..028eaf8c8b5098cc848be4a591a87fb2ce9c9b00 100644 (file)
@@ -317,6 +317,14 @@ VISU_ScalarMapAct
   myEdgeActor->SetTransform(theTransform);
 }
 
+//----------------------------------------------------------------------------
+vtkProperty* 
+VISU_ScalarMapAct
+::GetEdgeProperty()
+{
+  return myEdgeActor->GetProperty();
+}
+
 //----------------------------------------------------------------------------
 void
 VISU_ScalarMapAct
@@ -456,6 +464,7 @@ VISU_ScalarMapAct
     SetBarVisibility(anActor->GetBarVisibility());
     myPointsActor->DeepCopy( anActor->myPointsActor );
     SetShading(anActor->IsShading());
+    GetEdgeProperty()->DeepCopy(anActor->GetEdgeProperty());
   }
 }
 
index b399f21d6effc96d82d9fea996fe2f7bc8674a9e..e98af5fed98b159170eaa25da189fe8e5581be3b 100644 (file)
@@ -61,6 +61,10 @@ class VISU_OBJECT_EXPORT VISU_ScalarMapAct : public VISU_DataSetActor
   void
   SetTransform(VTKViewer_Transform* theTransform); 
 
+  virtual
+  vtkProperty* 
+  GetEdgeProperty(); 
+
   virtual
   void
   SetShrinkable(bool theIsShrinkable);
index 16a5edf9bcfaa535aa0ae3604d17b43c84aeedd6..1d07e3b42568081055a117dc7aa9c6fa515c77eb 100644 (file)
@@ -161,6 +161,10 @@ number of time stamps or number of components is not the same!</translation>
             <source>VISU_DISP_ONLY</source>
             <translation>Display only on creation</translation>
         </message>
+        <message>
+            <source>VISU_EDGE_COLOR</source>
+            <translation>Edge Color</translation>
+        </message>
         <message>
             <source>VISU_FEATURE_EDGES</source>
             <translation>Feature edges</translation>
index bbaaa4e75e2b0f427709b30cbed908f1bf9098a2..8c724922f37d4328e283c6600e48bedab8440dac 100644 (file)
@@ -1305,10 +1305,17 @@ VisuGUI
     return;
 
   VISU::Mesh_i* aMesh = dynamic_cast<VISU::Mesh_i*>(aPrs3d);
-  if(!aMesh)
+  VISU::ScalarMap_i* aScalarMap = dynamic_cast<VISU::ScalarMap_i*>(aPrs3d);
+  if(!aMesh && !aScalarMap)
     return;
 
-  SALOMEDS::Color anOldColor = aMesh->GetLinkColor(), aNewColor;
+  SALOMEDS::Color anOldColor, aNewColor;
+  if (aMesh)
+    anOldColor = aMesh->GetLinkColor();
+  else if (aScalarMap)
+    anOldColor = aScalarMap->GetLinkColor();
+
+
   QColor aColor (int(255*anOldColor.R),
                 int(255*anOldColor.G),
                 int(255*anOldColor.B));
@@ -1317,8 +1324,11 @@ VisuGUI
     aNewColor.R = aColorNew.red()/255.;
     aNewColor.G = aColorNew.green()/255.;
     aNewColor.B = aColorNew.blue()/255.;
-    aMesh->SetLinkColor(aNewColor);
-    RecreateActor(this, aMesh);
+    if (aMesh)
+      aMesh->SetLinkColor(aNewColor);
+    else
+      aScalarMap->SetLinkColor(aNewColor);
+    RecreateActor(this, aPrs3d);
   }
 }
 
@@ -3123,7 +3133,7 @@ VisuGUI
 
   // "Properties" submenu
   mgr->setRule( action( VISU_CELL_COLOR ), aRule + " and type='VISU::TMESH' and representation='VISU::SURFACEFRAME'" );
-  mgr->setRule( action( VISU_EDGE_COLOR ), aRule + " and type='VISU::TMESH' and representation='VISU::SURFACEFRAME'" );
+  mgr->setRule( action( VISU_EDGE_COLOR ), aRule + aSurfFrameType + " and representation='VISU::SURFACEFRAME'" );
   mgr->setRule( action( VISU_COLOR ), aRule + " and ((type='VISU::TMESH'"
                " and $representation in {'VISU::POINT' 'VISU::WIREFRAME' 'VISU::SHADED' 'VISU::INSIDEFRAME'}) "
                "or (type='VISU::TDEFORMEDSHAPE' and hasActor=1))" );
@@ -3968,6 +3978,9 @@ void VisuGUI::createPreferences()
   setPreferenceProperty( maxAngle, "max", 90 );
 
 
+  addPreference( tr( "VISU_EDGE_COLOR" ), representGr, LightApp_Preferences::Color, "VISU", "edge_color" );
+  addPreference( "", representGr, LightApp_Preferences::Space );
+
 
   addPreference( tr( "VISU_USE_SHADING" ), representGr, LightApp_Preferences::Bool, "VISU", "represent_shading" );
   sp = addPreference( "", representGr, LightApp_Preferences::Space );
index 4d008943e1fbcee74e69b0453358ee6343fbf14f..945739440bdb41f2c12d8f5faf97109e8e997975 100644 (file)
@@ -455,6 +455,10 @@ namespace VISU
     }
     theStr<<thePrefix<<theName<<".SetGaussMetric("<<aParam<<")"<<endl;
 
+    SALOMEDS::Color aColor = theServant->GetLinkColor();
+    theStr<<thePrefix<<theName<<".SetLinkColor(SALOMEDS.Color("<<
+      aColor.R<<", "<<aColor.G<<", "<<aColor.B<<"))"<<endl;
+
     if(theServant->IsRangeFixed())
       theStr<<thePrefix<<theName<<".SetRange("<<theServant->GetMin()<<", "<<theServant->GetMax()<<")"<<endl;
     else
index 368d9a6814d517ec7d47b3f1dc715c6d16a972cc..f703ca22a779dffc96c7423357420fedaa3ad688 100644 (file)
@@ -200,7 +200,13 @@ VISU::Mesh_i
       SetName((const char*)GenerateName().toLatin1(), false);
       myCellColor.R = 0.0;  myCellColor.G = myCellColor.B = 1.0;
       myNodeColor.R = myNodeColor.G = 1.0;  myNodeColor.B = 1.0;
-      myLinkColor.R = myLinkColor.G = myLinkColor.B = 83/255.;
+
+      QColor aColor = VISU::GetResourceMgr()->colorValue( "VISU", "edge_color", QColor( 255, 255, 255 ) );
+      SALOMEDS::Color aLinkColor;
+      aLinkColor.R = aColor.red()/255.;
+      aLinkColor.G = aColor.green()/255.;
+      aLinkColor.B = aColor.blue()/255.;
+      SetLinkColor(aLinkColor);
 
       my2DQuadPrsType = VISU::Quadratic2DPresentationType(VISU::GetResourceMgr()->integerValue( "VISU", "quadratic_mode", 0));
     }
index 450c8d99f7c36b3f9f50e6b956053a8d3bd83704..92a3e43c080c3b05e2f2f9efa0a2e14408deac1f 100644 (file)
@@ -33,6 +33,7 @@
 #include "VISU_ScalarMapAct.h"
 #include "VISU_ScalarMapPL.hxx"
 #include "VISU_LookupTable.hxx"
+#include "VISU_PipeLineUtils.hxx"
 #include "VISU_ScalarBarActor.hxx"
 #include "VISU_Convertor.hxx"
 
@@ -96,6 +97,20 @@ VISU::ScalarMap_i
   return aResult;
 }
 
+//----------------------------------------------------------------------------
+namespace
+{
+  bool
+  IsSameColor(const SALOMEDS::Color& theLeft,
+             const SALOMEDS::Color& theRight)
+  {
+    return 
+      VISU::CheckIsSameValue(theLeft.R, theRight.R) &&
+      VISU::CheckIsSameValue(theLeft.G, theRight.G) &&
+      VISU::CheckIsSameValue(theLeft.B, theRight.B);
+  }
+}
+
 //----------------------------------------------------------------------------
 int VISU::ScalarMap_i::myNbPresent = 0;
 
@@ -227,6 +242,13 @@ VISU::ScalarMap_i
   else
     SetScaling(VISU::LINEAR);
 
+  QColor aColor = aResourceMgr->colorValue( "VISU", "edge_color", QColor( 255, 255, 255 ) );
+  SALOMEDS::Color aLinkColor;
+  aLinkColor.R = aColor.red()/255.;
+  aLinkColor.G = aColor.green()/255.;
+  aLinkColor.B = aColor.blue()/255.;
+  SetLinkColor(aLinkColor);
+
   int aGaussMetric = aResourceMgr->integerValue("VISU", "scalar_gauss_metric", 0);
   SetGaussMetric((VISU::GaussMetric)aGaussMetric);
 
@@ -258,6 +280,12 @@ VISU::ScalarMap_i
 
   SetGaussMetric(VISU::GaussMetric(VISU::Storable::FindValue(theMap,"myGaussMetric").toInt()));
 
+  SALOMEDS::Color aLinkColor;
+  aLinkColor.R = VISU::Storable::FindValue(theMap,"myLinkColor.R").toDouble();
+  aLinkColor.G = VISU::Storable::FindValue(theMap,"myLinkColor.G").toDouble();
+  aLinkColor.B = VISU::Storable::FindValue(theMap,"myLinkColor.B").toDouble();
+  SetLinkColor(aLinkColor);
+
   // Check if the icon needs to be updated, update if necessary
   SALOMEDS::Study_var aStudy = theSObject->GetStudy();
   SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder();
@@ -282,6 +310,11 @@ VISU::ScalarMap_i
   Storable::DataToStream( theStr, "myScaling",        GetScaling() );
   Storable::DataToStream( theStr, "myShowBar",        (IsBarVisible()? 1:0) );
   Storable::DataToStream( theStr, "myGaussMetric",    int(GetGaussMetric()) );
+
+  SALOMEDS::Color aLinkColor = GetLinkColor();
+  Storable::DataToStream( theStr, "myLinkColor.R",    aLinkColor.R );
+  Storable::DataToStream( theStr, "myLinkColor.G",    aLinkColor.G );
+  Storable::DataToStream( theStr, "myLinkColor.B",    aLinkColor.B );
 }
 
 
@@ -304,6 +337,28 @@ VISU::ScalarMap_i
                   (GetSpecificPL(), &VISU_ColoredPL::SetScaling, theScaling));
 }
 
+//----------------------------------------------------------------------------
+void 
+VISU::ScalarMap_i
+::SetLinkColor(const SALOMEDS::Color& theColor) 
+{ 
+  if(IsSameColor(myLinkColor, theColor))
+    return;
+
+  VISU::TSetModified aModified(this);
+  
+  myLinkColor = theColor;
+  myParamsTime.Modified();
+}
+
+//----------------------------------------------------------------------------
+SALOMEDS::Color 
+VISU::ScalarMap_i
+::GetLinkColor() 
+{ 
+  return myLinkColor;
+}
+
 //----------------------------------------------------------------------------
 VISU::GaussMetric 
 VISU::ScalarMap_i
@@ -543,6 +598,10 @@ VISU::ScalarMap_i
       GetValLblFontColor( anRGB[ 0 ], anRGB[ 1 ], anRGB[ 2 ] );
       aProp->SetColor( anRGB[ 0 ], anRGB[ 1 ], anRGB[ 2 ] );
     }
+
+    // Update edge property
+    SALOMEDS::Color aLinkColor = GetLinkColor();
+    anActor->GetEdgeProperty()->SetColor(aLinkColor.R, aLinkColor.G, aLinkColor.B);
   }
   TSuperClass::UpdateActor(theActor);
 }
index aba260e0e3e164c7545909703f44a0f0c5bc423c..aa0b4644a62662e4946217a76babff6eaa647497 100644 (file)
@@ -76,6 +76,15 @@ namespace VISU
     void
     SetScaling(VISU::Scaling theScaling);
 
+    //----------------------------------------------------------------------------
+    virtual 
+    void 
+    SetLinkColor(const SALOMEDS::Color& theColor);
+
+    virtual 
+    SALOMEDS::Color 
+    GetLinkColor();
+
     //----------------------------------------------------------------------------
     virtual 
     VISU::GaussMetric 
@@ -202,6 +211,7 @@ namespace VISU
 
   private:
     VISU_ScalarMapPL* myScalarMapPL;
+    SALOMEDS::Color myLinkColor;
     bool myShowBar;
   };
 }