Salome HOME
Imp: allow customization of nodes / cells numbering text properties via preferences
authorvsr <vsr@opencascade.com>
Mon, 17 Dec 2012 15:48:01 +0000 (15:48 +0000)
committervsr <vsr@opencascade.com>
Mon, 17 Dec 2012 15:48:01 +0000 (15:48 +0000)
13 files changed:
resources/SalomeApp.xml.in
src/OBJECT/SMESH_Actor.cxx
src/OBJECT/SMESH_Actor.h
src/OBJECT/SMESH_ActorDef.h
src/OBJECT/SMESH_ActorUtils.h
src/OBJECT/SMESH_CellLabelActor.cxx
src/OBJECT/SMESH_CellLabelActor.h
src/OBJECT/SMESH_NodeLabelActor.cxx
src/OBJECT/SMESH_NodeLabelActor.h
src/SMESHGUI/SMESHGUI.cxx
src/SMESHGUI/SMESHGUI_VTKUtils.cxx
src/SMESHGUI/SMESHGUI_VTKUtils.h
src/SMESHGUI/SMESH_msg_en.ts

index 20be2291777f1f731c46d505c9288e9a44a232f0..d72d424806b80846e5d4bf571f6bca1654bcd87a 100644 (file)
     <parameter name="documentation"                value="smesh_help"/>
     <parameter name="preview_actor_chunk_size"     value="100" />
     <parameter name="historical_python_dump"       value="true" />
+    <parameter name="numbering_node_color"         value="255, 255, 255" />
+    <parameter name="numbering_node_size"          value="10" />
+    <parameter name="numbering_node_font"          value="Times" />
+    <parameter name="numbering_node_bold"          value="true" />
+    <parameter name="numbering_node_italic"        value="false" />
+    <parameter name="numbering_node_shadow"        value="false" />
+    <parameter name="numbering_elem_color"         value="0, 255, 0" />
+    <parameter name="numbering_elem_size"          value="12" />
+    <parameter name="numbering_elem_font"          value="Times" />
+    <parameter name="numbering_elem_bold"          value="true" />
+    <parameter name="numbering_elem_italic"        value="false" />
+    <parameter name="numbering_elem_shadow"        value="false" />
     <!-- Input field precisions -->
     <parameter name="def_precision"                value="3"  />
     <parameter name="length_precision"             value="-6"  />
index 94d90d1b2427fba24d83a4352bc1bee0fed4733c..4a64b0de0b7e7f689058b9b30cbacccd9ac4a52b 100644 (file)
@@ -152,6 +152,22 @@ SMESH_ActorDef::SMESH_ActorDef()
   vtkFloatingPointType aLineWidth    = SMESH::GetFloat("SMESH:element_width",1);
   vtkFloatingPointType aOutlineWidth = SMESH::GetFloat("SMESH:outline_width",1);
 
+  int aSizeNd = mgr->integerValue( "SMESH", "numbering_node_size", 10 );
+  SMESH::LabelFont aFamilyNd = (SMESH::LabelFont)( mgr->integerValue( "SMESH", "numbering_node_font", 2 ) );
+  bool aBoldNd    = mgr->booleanValue( "SMESH", "numbering_node_bold",  true );
+  bool anItalicNd = mgr->booleanValue( "SMESH", "numbering_node_italic", false );
+  bool aShadowNd  = mgr->booleanValue( "SMESH", "numbering_node_shadow", false );
+  vtkFloatingPointType anRGBNd[3] = {1,1,1};
+  SMESH::GetColor( "SMESH", "numbering_node_color", anRGBNd[0], anRGBNd[1], anRGBNd[2], QColor( 255, 255, 255 ) );
+
+  int aSizeEl = mgr->integerValue( "SMESH", "numbering_elem_size", 12 );
+  SMESH::LabelFont aFamilyEl = (SMESH::LabelFont)( mgr->integerValue( "SMESH", "numbering_elem_font", 2 ) );
+  bool aBoldEl    = mgr->booleanValue( "SMESH", "numbering_elem_bold", true );
+  bool anItalicEl = mgr->booleanValue( "SMESH", "numbering_elem_italic", false );
+  bool aShadowEl  = mgr->booleanValue( "SMESH", "numbering_elem_shadow", false );
+  vtkFloatingPointType anRGBEl[3] = {0,1,0};
+  SMESH::GetColor( "SMESH", "numbering_elem_color", anRGBEl[0], anRGBEl[1], anRGBEl[2], QColor( 0, 255, 0 ) );
+
   vtkMatrix4x4 *aMatrix = vtkMatrix4x4::New();
   VTKViewer_ExtractUnstructuredGrid* aFilter = NULL;
 
@@ -182,6 +198,7 @@ SMESH_ActorDef::SMESH_ActorDef()
   my2DActor->SetStoreGemetryMapping(true);
   my2DActor->SetUserMatrix(aMatrix);
   my2DActor->PickableOff();
+  my2DActor->SetFontProperties( aFamilyEl, aSizeEl, aBoldEl, anItalicEl, aShadowEl, anRGBEl[0], anRGBEl[1], anRGBEl[2] ); 
   my2DActor->SetProperty(mySurfaceProp);
   my2DActor->SetBackfaceProperty(myBackSurfaceProp);
   my2DActor->SetRepresentation(SMESH_DeviceActor::eSurface);
@@ -220,6 +237,7 @@ SMESH_ActorDef::SMESH_ActorDef()
   my3DActor->SetStoreGemetryMapping(true);
   my3DActor->SetUserMatrix(aMatrix);
   my3DActor->PickableOff();
+  my3DActor->SetFontProperties( aFamilyEl, aSizeEl, aBoldEl, anItalicEl, aShadowEl, anRGBEl[0], anRGBEl[1], anRGBEl[2] ); 
   my3DActor->SetProperty(myNormalVProp);
   my3DActor->SetBackfaceProperty(myReversedVProp);
   my3DActor->SetRepresentation(SMESH_DeviceActor::eSurface);
@@ -289,6 +307,7 @@ SMESH_ActorDef::SMESH_ActorDef()
   my1DActor->SetUserMatrix(aMatrix);
   my1DActor->PickableOff();
   my1DActor->SetHighlited(true);
+  my1DActor->SetFontProperties( aFamilyEl, aSizeEl, aBoldEl, anItalicEl, aShadowEl, anRGBEl[0], anRGBEl[1], anRGBEl[2] );
   my1DActor->SetProperty(myEdgeProp);
   my1DActor->SetRepresentation(SMESH_DeviceActor::eSurface);
   aFilter = my1DActor->GetExtractUnstructuredGrid();
@@ -334,6 +353,7 @@ SMESH_ActorDef::SMESH_ActorDef()
   my0DActor->SetUserMatrix(aMatrix);
   my0DActor->SetStoreGemetryMapping(true);
   my0DActor->PickableOff();
+  my0DActor->SetFontProperties( aFamilyEl, aSizeEl, aBoldEl, anItalicEl, aShadowEl, anRGBEl[0], anRGBEl[1], anRGBEl[2] );
   my0DActor->SetVisibility(false);
   my0DActor->SetProperty(my0DProp);
   my0DActor->SetRepresentation(SMESH_DeviceActor::eSurface);
@@ -353,6 +373,7 @@ SMESH_ActorDef::SMESH_ActorDef()
   myBallActor->SetUserMatrix(aMatrix);
   myBallActor->SetStoreGemetryMapping(true);
   myBallActor->PickableOff();
+  myBallActor->SetFontProperties( aFamilyEl, aSizeEl, aBoldEl, anItalicEl, aShadowEl, anRGBEl[0], anRGBEl[1], anRGBEl[2] );  
   myBallActor->SetVisibility(false);
   myBallActor->SetProperty(myBallProp);
   myBallActor->SetRepresentation(SMESH_DeviceActor::eSurface);
@@ -393,6 +414,7 @@ SMESH_ActorDef::SMESH_ActorDef()
   myNodeActor->SetStoreClippingMapping(true);
   myNodeActor->PickableOff();
   myNodeActor->SetVisibility(false);
+  myNodeActor->SetFontProperties( aFamilyNd, aSizeNd, aBoldNd, anItalicNd, aShadowNd, anRGBNd[0], anRGBNd[1], anRGBNd[2] );  
   myNodeActor->SetProperty(myNodeProp);
   myNodeActor->SetRepresentation(SMESH_DeviceActor::ePoint);
   aFilter = myNodeActor->GetExtractUnstructuredGrid();
@@ -622,6 +644,48 @@ void SMESH_ActorDef::SetPointsLabeled( bool theIsPointsLabeled )
   }
 }
 
+void SMESH_ActorDef::SetPointsFontProperties( SMESH::LabelFont theFamily, int theSize,
+                                             bool theBold, bool theItalic, bool theShadow,
+                                             vtkFloatingPointType r, vtkFloatingPointType g, vtkFloatingPointType b )
+{    
+  if(myNodeActor) {
+    myNodeActor->SetFontProperties( theFamily, theSize, theBold, theItalic, theShadow, r, g, b );
+    SetRepresentation( GetRepresentation() );
+    myTimeStamp->Modified();
+  }
+}
+
+void SMESH_ActorDef::SetCellsFontProperties( SMESH::LabelFont theFamily, int theSize,
+                                            bool theBold, bool theItalic, bool theShadow,
+                                            vtkFloatingPointType r, vtkFloatingPointType g, vtkFloatingPointType b )
+{    
+  if(my3DActor) {
+    my3DActor->SetFontProperties( theFamily, theSize, theBold, theItalic, theShadow, r, g, b );
+    SetRepresentation( GetRepresentation() );
+    myTimeStamp->Modified();
+  }
+  if(my2DActor) {
+    my2DActor->SetFontProperties( theFamily, theSize, theBold, theItalic, theShadow, r, g, b );
+    SetRepresentation( GetRepresentation() );
+    myTimeStamp->Modified();
+  }
+  if(my1DActor) {
+    my1DActor->SetFontProperties( theFamily, theSize, theBold, theItalic, theShadow, r, g, b );
+    SetRepresentation( GetRepresentation() );
+    myTimeStamp->Modified();
+  }
+  if(my0DActor) {
+    my0DActor->SetFontProperties( theFamily, theSize, theBold, theItalic, theShadow, r, g, b );
+    SetRepresentation( GetRepresentation() );
+    myTimeStamp->Modified();
+  }
+  if(myBallActor) {
+    myBallActor->SetFontProperties( theFamily, theSize, theBold, theItalic, theShadow, r, g, b );
+    SetRepresentation( GetRepresentation() );
+    myTimeStamp->Modified();
+  }
+}
+
 bool SMESH_ActorDef::GetPointsLabeled() {
   return myNodeActor && myNodeActor->GetPointsLabeled();
 }
index fc954253d052994d1848ef53fa1602e750fb52bd..2952818a7c5afe2e9271b8cf8f56e59616cf4f1d 100644 (file)
@@ -31,6 +31,7 @@
 #include <SALOMEconfig.h> // To fix some redefinition
 #include <SALOME_Actor.h>
 #include "SMESH_Object.h"
+#include "SMESH_ActorUtils.h"
 
 #include <vtkCommand.h>
 
@@ -162,6 +163,13 @@ class SMESHOBJECT_EXPORT SMESH_Actor: public SALOME_Actor
   virtual void UpdateScalarBar() = 0;
   virtual void UpdateDistribution() = 0;
 
+  virtual void SetPointsFontProperties( SMESH::LabelFont family, int size, 
+                                       bool bold, bool italic, bool shadow,
+                                       vtkFloatingPointType r, vtkFloatingPointType g, vtkFloatingPointType b ) = 0;
+  virtual void SetCellsFontProperties( SMESH::LabelFont family, int size, 
+                                      bool bold, bool italic, bool shadow,
+                                      vtkFloatingPointType r, vtkFloatingPointType g, vtkFloatingPointType b ) = 0;
+
 #ifndef DISABLE_PLOT2DVIEWER
   virtual SPlot2d_Histogram* GetPlot2Histogram() = 0;
   virtual SPlot2d_Histogram* UpdatePlot2Histogram() = 0;
index 11d7fe41ac030f0ae2fa35d61108dc60a9a49b73..2238faa5ebe08dc2adf558b4b933a8d4dcc16161 100644 (file)
@@ -180,6 +180,13 @@ class SMESH_ActorDef : public SMESH_Actor
   virtual void SetPointsLabeled(bool theIsPointsLabeled);
   virtual bool GetPointsLabeled();
 
+  virtual void SetPointsFontProperties( SMESH::LabelFont family, int size, 
+                                       bool bold, bool italic, bool shadow,
+                                       vtkFloatingPointType r, vtkFloatingPointType g, vtkFloatingPointType b );
+  virtual void SetCellsFontProperties( SMESH::LabelFont family, int size, 
+                                      bool bold, bool italic, bool shadow,
+                                      vtkFloatingPointType r, vtkFloatingPointType g, vtkFloatingPointType b );
+  
   virtual void SetCellsLabeled(bool theIsCellsLabeled);
   virtual bool GetCellsLabeled();
 
index 3a15c40adcb9c97ec7f4524c8b7a754478a8573a..5aafbbbf558ab19b042bef956f1acd1ce8d0af8b 100644 (file)
@@ -33,6 +33,13 @@ class SMESH_Actor;
 
 namespace SMESH
 {
+  //! Label font family
+  enum LabelFont { 
+    FntArial,    //!< arial font family
+    FntCourier,  //!< courier font family
+    FntTimes,    //!< times font family
+  };
+
 SMESHOBJECT_EXPORT  
   vtkFloatingPointType 
   GetFloat( const QString& theValue, 
index 81f2107f0964a136eb0e75e273bea664869f9a5d..0726cd65fe8eb59e1e4bad96fc2de96c817fb5f5 100644 (file)
@@ -69,21 +69,19 @@ SMESH_CellLabelActor::SMESH_CellLabelActor() {
   myClsLabeledDataMapper->SetLabelFormat("%d");
   myClsLabeledDataMapper->SetLabelModeToLabelScalars();
     
-  vtkTextProperty* aClsTextProp = vtkTextProperty::New();
-  aClsTextProp->SetFontFamilyToTimes();
-  static int aCellsFontSize = 12;
-  aClsTextProp->SetFontSize(aCellsFontSize);
-  aClsTextProp->SetBold(1);
-  aClsTextProp->SetItalic(0);
-  aClsTextProp->SetShadow(0);
-  myClsLabeledDataMapper->SetLabelTextProperty(aClsTextProp);
-  aClsTextProp->Delete();
+  myClsTextProp = vtkTextProperty::New();
+  myClsTextProp->SetFontFamilyToTimes();
+  myClsTextProp->SetFontSize(12);
+  myClsTextProp->SetBold(1);
+  myClsTextProp->SetItalic(0);
+  myClsTextProp->SetShadow(0);
+  myClsTextProp->SetColor( 0, 1, 0 );
+  myClsLabeledDataMapper->SetLabelTextProperty(myClsTextProp);
     
   myIsCellsLabeled = false;
 
   myCellsLabels = vtkActor2D::New();
   myCellsLabels->SetMapper(myClsLabeledDataMapper);
-  myCellsLabels->GetProperty()->SetColor(0,1,0);
   myCellsLabels->SetVisibility(myIsCellsLabeled);
 
   vtkCallbackCommand* callBackCommand = vtkCallbackCommand::New();
@@ -116,12 +114,30 @@ SMESH_CellLabelActor::~SMESH_CellLabelActor() {
   // commented: porting to vtk 5.0
   //  myClsSelectVisiblePoints->UnRegisterAllOutputs();
   myClsSelectVisiblePoints->Delete();
-  
-  
-  
+  myClsTextProp->Delete();
 }
 
 
+void SMESH_CellLabelActor::SetFontProperties( SMESH::LabelFont family, int size,
+                                             bool bold, bool italic, bool shadow,
+                                             vtkFloatingPointType r, vtkFloatingPointType g, vtkFloatingPointType b  )
+{
+  switch ( family ) {
+  case SMESH::FntArial:
+    myClsTextProp->SetFontFamilyToArial(); break;
+  case SMESH::FntCourier:
+    myClsTextProp->SetFontFamilyToCourier(); break;
+  case SMESH::FntTimes:
+  default:
+    myClsTextProp->SetFontFamilyToTimes(); break;
+  }    
+  myClsTextProp->SetFontSize( size );
+  myClsTextProp->SetBold( bold );
+  myClsTextProp->SetItalic( italic );
+  myClsTextProp->SetShadow( shadow );
+  myClsTextProp->SetColor( r, g, b ); 
+}
+
 void SMESH_CellLabelActor::SetCellsLabeled(bool theIsCellsLabeled) {
   myTransformFilter->Update();
   vtkUnstructuredGrid* aGrid = vtkUnstructuredGrid::SafeDownCast(myTransformFilter->GetOutput());
index a754d0b08ffbe5c9e3dfed82edaadd79ff2056c2..eff545d7c86d8e11ce2841b191b977e0f5cddfbd 100644 (file)
 #define SMESH_CELL_LABEL_ACTOR_H
 
 #include "SMESH_DeviceActor.h"
+#include "SMESH_ActorUtils.h"
 
 class vtkSelectVisiblePoints;
 class vtkLabeledDataMapper;
 class vtkActor2D;
 class vtkMaskPoints;
 class vtkUnstructuredGrid;
+class vtkTextProperty;
 
 class VTKViewer_CellCenters;
 
@@ -57,6 +59,10 @@ public:
 
   virtual void AddToRender(vtkRenderer* theRenderer);
   virtual void RemoveFromRender(vtkRenderer* theRenderer);
+  
+  virtual void SetFontProperties( SMESH::LabelFont family, int size,
+                                 bool bold, bool italic, bool shadow,
+                                 vtkFloatingPointType r, vtkFloatingPointType g, vtkFloatingPointType b );
 
   void UpdateLabels();
   
@@ -72,6 +78,7 @@ protected:
   vtkLabeledDataMapper* myClsLabeledDataMapper;
   vtkSelectVisiblePoints* myClsSelectVisiblePoints;  
   SMESH_DeviceActor* myBaseActor; //Pointer to the base actor
+  vtkTextProperty* myClsTextProp;
 
 protected:
   // Not implemented.
index aa2ba78a27104a9c13d8300580599923341fd03e..2e172d4ab586b69ddacc561524e70df6332b426e 100644 (file)
@@ -63,21 +63,19 @@ SMESH_NodeLabelActor::SMESH_NodeLabelActor() {
   myPtsLabeledDataMapper->SetLabelFormat("%d");
   myPtsLabeledDataMapper->SetLabelModeToLabelScalars();
     
-  vtkTextProperty* aPtsTextProp = vtkTextProperty::New();
-  aPtsTextProp->SetFontFamilyToTimes();
-  static int aPointsFontSize = 10;
-  aPtsTextProp->SetFontSize(aPointsFontSize);
-  aPtsTextProp->SetBold(1);
-  aPtsTextProp->SetItalic(0);
-  aPtsTextProp->SetShadow(0);
-  myPtsLabeledDataMapper->SetLabelTextProperty(aPtsTextProp);
-  aPtsTextProp->Delete();
+  myPtsTextProp = vtkTextProperty::New();
+  myPtsTextProp->SetFontFamilyToTimes();
+  myPtsTextProp->SetFontSize(10);
+  myPtsTextProp->SetBold(1);
+  myPtsTextProp->SetItalic(0);
+  myPtsTextProp->SetShadow(0);
+  myPtsTextProp->SetColor( 1, 1, 1 );
+  myPtsLabeledDataMapper->SetLabelTextProperty(myPtsTextProp);
 
   myIsPointsLabeled = false;
 
   myPointLabels = vtkActor2D::New();
   myPointLabels->SetMapper(myPtsLabeledDataMapper);
-  myPointLabels->GetProperty()->SetColor(1,1,1);
   myPointLabels->SetVisibility(myIsPointsLabeled);
 
   vtkCallbackCommand* callBackCommand = vtkCallbackCommand::New();
@@ -109,7 +107,27 @@ SMESH_NodeLabelActor::~SMESH_NodeLabelActor() {
   //  myPtsMaskPoints->UnRegisterAllOutputs();
   myPtsMaskPoints->Delete();
   myPointLabels->Delete();
+  myPtsTextProp->Delete();
+}
 
+void SMESH_NodeLabelActor::SetFontProperties( SMESH::LabelFont family, int size, 
+                                             bool bold, bool italic, bool shadow,
+                                             vtkFloatingPointType r, vtkFloatingPointType g, vtkFloatingPointType b )
+{
+  switch ( family ) {
+  case SMESH::FntArial:
+    myPtsTextProp->SetFontFamilyToArial(); break;
+  case SMESH::FntCourier:
+    myPtsTextProp->SetFontFamilyToCourier(); break;
+  case SMESH::FntTimes:
+  default:
+    myPtsTextProp->SetFontFamilyToTimes(); break;
+  }
+  myPtsTextProp->SetFontSize( size );
+  myPtsTextProp->SetBold( bold );
+  myPtsTextProp->SetItalic( italic );
+  myPtsTextProp->SetShadow( shadow ); 
+  myPtsTextProp->SetColor( r, g, b ); 
 }
 
 void SMESH_NodeLabelActor::SetPointsLabeled(bool theIsPointsLabeled) {
index a05b35467c27609a06e1a53b673ed366a1a7745a..df09248d3700c5a7675ab46adb538ff2560d2e57 100644 (file)
 #define SMESH_NODE_LABEL_ACTOR_H
 
 #include "SMESH_DeviceActor.h"
+#include "SMESH_ActorUtils.h"
 
 class vtkSelectVisiblePoints;
 class vtkLabeledDataMapper;
 class vtkActor2D;
 class vtkMaskPoints;
 class vtkUnstructuredGrid;
-
+class vtkTextProperty;
 
 class SMESHOBJECT_EXPORT SMESH_NodeLabelActor : public SMESH_DeviceActor {
 public:
@@ -55,6 +56,10 @@ public:
 
   virtual void AddToRender(vtkRenderer* theRenderer); 
   virtual void RemoveFromRender(vtkRenderer* theRenderer);
+  
+  virtual void SetFontProperties( SMESH::LabelFont family, int size,
+                                 bool bold, bool italic, bool shadow,
+                                 vtkFloatingPointType r, vtkFloatingPointType g, vtkFloatingPointType b );
 
   void UpdateLabels();
   
@@ -68,6 +73,7 @@ protected:
   vtkMaskPoints* myPtsMaskPoints;
   vtkLabeledDataMapper* myPtsLabeledDataMapper;
   vtkSelectVisiblePoints* myPtsSelectVisiblePoints;
+  vtkTextProperty* myPtsTextProp;
 
 protected:
   // Not implemented.
index d6831d7adf70d6d9b079ebff7ab4fc6078491584..60ab1696172c0cbc1ab56c38d50fd915e1593a94 100644 (file)
@@ -4880,6 +4880,34 @@ void SMESHGUI::createPreferences()
   setPreferenceProperty( shrink, "min", 0 );
   setPreferenceProperty( shrink, "max", 100 );
 
+  int numGroup = addPreference( tr( "PREF_GROUP_NUMBERING" ), meshTab );
+  setPreferenceProperty( numGroup, "columns", 6 );
+  QStringList fonts;
+  fonts << tr( "SMESH_ARIAL" ) << tr( "SMESH_COURIER" ) << tr( "SMESH_TIMES" );
+  indices.clear(); indices << 0 << 1 << 2;
+  // ...
+  addPreference( tr( "PREF_NUMBERING_NODE" ), numGroup, LightApp_Preferences::Color, "SMESH", "numbering_node_color" );
+  int NumNodeSize = addPreference( tr( "PREF_NUMBERING_SIZE" ), numGroup, LightApp_Preferences::IntSpin, "SMESH", "numbering_node_size" );
+  setPreferenceProperty( NumNodeSize, "min", 1 );
+  setPreferenceProperty( NumNodeSize, "max", 100 );
+  int NumFontNode = addPreference( tr( "PREF_NUMBERING_FONT" ), numGroup, LightApp_Preferences::Selector, "SMESH", "numbering_node_font" );
+  setPreferenceProperty( NumFontNode, "strings", fonts );
+  setPreferenceProperty( NumFontNode, "indexes", indices );
+  addPreference( tr( "PREF_NUMBERING_BOLD" ), numGroup, LightApp_Preferences::Bool, "SMESH", "numbering_node_bold" );
+  addPreference( tr( "PREF_NUMBERING_ITALIC" ), numGroup, LightApp_Preferences::Bool, "SMESH", "numbering_node_italic" );
+  addPreference( tr( "PREF_NUMBERING_SHADOW" ), numGroup, LightApp_Preferences::Bool, "SMESH", "numbering_node_shadow" );
+  // ...
+  addPreference( tr( "PREF_NUMBERING_ELEM" ), numGroup, LightApp_Preferences::Color, "SMESH", "numbering_elem_color" );
+  int NumElemSize = addPreference( tr( "PREF_NUMBERING_SIZE" ), numGroup, LightApp_Preferences::IntSpin, "SMESH", "numbering_elem_size" );
+  setPreferenceProperty( NumElemSize, "min", 1 );
+  setPreferenceProperty( NumElemSize, "max", 100 );
+  int NumFontElem = addPreference( tr( "PREF_NUMBERING_FONT" ), numGroup, LightApp_Preferences::Selector, "SMESH", "numbering_elem_font" );
+  setPreferenceProperty( NumFontElem, "strings", fonts );
+  setPreferenceProperty( NumFontElem, "indexes", indices ); 
+  addPreference( tr( "PREF_NUMBERING_BOLD" ), numGroup, LightApp_Preferences::Bool, "SMESH", "numbering_elem_bold" );
+  addPreference( tr( "PREF_NUMBERING_ITALIC" ), numGroup, LightApp_Preferences::Bool, "SMESH", "numbering_elem_italic" );
+  addPreference( tr( "PREF_NUMBERING_SHADOW" ), numGroup, LightApp_Preferences::Bool, "SMESH", "numbering_elem_shadow" );
+
   int orientGroup = addPreference( tr( "PREF_GROUP_FACES_ORIENTATION" ), meshTab );
   setPreferenceProperty( orientGroup, "columns", 1 );
 
@@ -5066,6 +5094,16 @@ void SMESHGUI::preferencesChanged( const QString& sect, const QString& name )
       QString val = aResourceMgr->stringValue( "SMESH", name );
       myComponentSMESH->SetOption( name.toLatin1().constData(), val.toLatin1().constData() );
     }
+    else if(name ==  QString("numbering_node_color")  || name ==  QString("numbering_node_size") ||
+           name ==  QString("numbering_node_font")   || name ==  QString("numbering_node_bold") ||
+           name ==  QString("numbering_node_italic") || name ==  QString("numbering_node_shadow") ) {
+      SMESH::UpdateFontProp( this );
+    }
+    else if(name ==  QString("numbering_elem_color")  || name ==  QString("numbering_elem_size") ||
+           name ==  QString("numbering_elem_font")   || name ==  QString("numbering_elem_bold") ||
+           name ==  QString("numbering_elem_italic") || name ==  QString("numbering_elem_shadow") ) {
+      SMESH::UpdateFontProp( this );
+    }
 
     if(aWarning.size() != 0){
       aWarning += "The default values are applied instead.";
index 7831412dbac727617863cc889f17ae9de56580ce..48ce5afc7d126f13cbd4563764f276554de05747 100644 (file)
@@ -34,6 +34,8 @@
 
 #include <SMESH_Actor.h>
 #include <SMESH_ActorUtils.h>
+#include "SMESH_NodeLabelActor.h"
+#include "SMESH_CellLabelActor.h"
 #include <SMESH_ObjectDef.h>
 #include <SMDS_Mesh.hxx>
 
@@ -949,6 +951,58 @@ namespace SMESH
   }
 
 
+  void UpdateFontProp( SMESHGUI* theModule )
+  {
+    if ( !theModule ) return;
+
+    SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( theModule->application() );
+    if ( !app ) return;
+
+    SUIT_ResourceMgr* mgr = SMESH::GetResourceMgr( theModule );
+    if ( !mgr ) return;
+    //
+    vtkFloatingPointType anRGBNd[3] = {1,1,1};
+    SMESH::GetColor( "SMESH", "numbering_node_color", anRGBNd[0], anRGBNd[1], anRGBNd[2], QColor( 255, 255, 255 ) );
+    int aSizeNd     = mgr->integerValue( "SMESH", "numbering_node_size",  10 );
+    SMESH::LabelFont aFamilyNd = (SMESH::LabelFont)( mgr->integerValue( "SMESH", "numbering_node_font",  2 ) );
+    bool aBoldNd    = mgr->booleanValue( "SMESH", "numbering_node_bold",   true );
+    bool anItalicNd = mgr->booleanValue( "SMESH", "numbering_node_italic", false );
+    bool aShadowNd  = mgr->booleanValue( "SMESH", "numbering_node_shadow", false );
+    //
+    vtkFloatingPointType anRGBEl[3] = {0,1,0};
+    SMESH::GetColor( "SMESH", "numbering_elem_color", anRGBEl[0], anRGBEl[1], anRGBEl[2], QColor( 0, 255, 0 ) );
+    int aSizeEl     = mgr->integerValue( "SMESH", "numbering_elem_size",  12 );
+    SMESH::LabelFont aFamilyEl = (SMESH::LabelFont)( mgr->integerValue( "SMESH", "numbering_elem_font",  2 ) );
+    bool aBoldEl    = mgr->booleanValue( "SMESH", "numbering_elem_bold",   true );
+    bool anItalicEl = mgr->booleanValue( "SMESH", "numbering_elem_italic", false );
+    bool aShadowEl  = mgr->booleanValue( "SMESH", "numbering_elem_shadow", false );
+    //
+    ViewManagerList vmList;
+    app->viewManagers( SVTK_Viewer::Type(), vmList );
+    foreach ( SUIT_ViewManager* vm, vmList ) {
+      QVector<SUIT_ViewWindow*> views = vm->getViews();
+      foreach ( SUIT_ViewWindow* vw, views ) {
+       // update VTK viewer properties
+       if ( SVTK_ViewWindow* aVtkView = GetVtkViewWindow( vw ) ) {
+         // update actors
+         vtkRenderer* aRenderer = aVtkView->getRenderer();
+         VTK::ActorCollectionCopy aCopy( aRenderer->GetActors() );
+         vtkActorCollection* aCollection = aCopy.GetActors();
+         aCollection->InitTraversal();
+         while ( vtkActor* anAct = aCollection->GetNextActor() ) {
+           if ( SMESH_NodeLabelActor* anActor = dynamic_cast< SMESH_NodeLabelActor* >( anAct ) ) {
+             anActor->SetFontProperties( aFamilyNd, aSizeNd, aBoldNd, anItalicNd, aShadowNd, anRGBNd[0], anRGBNd[1], anRGBNd[2] );
+           }
+           else if ( SMESH_CellLabelActor* anActor = dynamic_cast< SMESH_CellLabelActor* >( anAct ) ) {
+             anActor->SetFontProperties( aFamilyEl, aSizeEl, aBoldEl, anItalicEl, aShadowEl, anRGBEl[0], anRGBEl[1], anRGBEl[2] );
+           }
+         }
+         aVtkView->Repaint( false );     
+       }
+      }
+    }
+  }
+
   //----------------------------------------------------------------------------
   SVTK_Selector*
   GetSelector(SUIT_ViewWindow *theWindow)
index 94d69a9cd9d3b08d73add36bbf5f84b793b2149e..b226f7767263878de40db1ebad4ba33837ee60ad 100644 (file)
@@ -137,6 +137,9 @@ SMESHGUI_EXPORT
 SMESHGUI_EXPORT
   void UpdateSelectionProp( SMESHGUI* );
 
+SMESHGUI_EXPORT
+  void UpdateFontProp( SMESHGUI* );
+
   //----------------------------------------------------------------------------
 SMESHGUI_EXPORT
   SVTK_Selector* GetSelector( SUIT_ViewWindow* = GetActiveWindow() );
index 12109c0b94789b60268c8a3605db0132aff3e84d..2e7d4dd30de68e5edb3c718eeefe95408fcf0d19 100644 (file)
@@ -2232,6 +2232,50 @@ Check algorithm documentation for supported geometry</translation>
         <source>SMESH_PRECISION</source>
         <translation>Precision</translation>
     </message>
+    <message>
+        <source>PREF_GROUP_NUMBERING</source>
+        <translation>Numbering</translation>
+    </message>
+    <message>
+        <source>PREF_NUMBERING_NODE</source>
+        <translation>Nodes: Color</translation>
+    </message>
+     <message>
+        <source>PREF_NUMBERING_ELEM</source>
+        <translation>Edges: Color</translation>
+    </message>
+    <message>
+        <source>PREF_NUMBERING_SIZE</source>
+        <translation>Size</translation>
+    </message>
+    <message>
+        <source>PREF_NUMBERING_FONT</source>
+        <translation>Font</translation>
+    </message>
+    <message>
+        <source>SMESH_ARIAL</source>
+        <translation>Arial</translation>
+    </message>
+    <message>
+        <source>SMESH_COURIER</source>
+        <translation>Courier</translation>
+    </message>
+    <message>
+        <source>SMESH_TIMES</source>
+        <translation>Times</translation>
+    </message>
+    <message>
+       <source>PREF_NUMBERING_BOLD</source>
+        <translation>Bold</translation>
+    </message> 
+    <message>
+        <source>PREF_NUMBERING_ITALIC</source>
+        <translation>Italic</translation>
+    </message>
+    <message>
+        <source>PREF_NUMBERING_SHADOW</source>
+        <translation>Shadow</translation>
+    </message>
     <message>
         <source>SMESH_PREFERENCES_SCALARBAR</source>
         <translation>Scalar Bar Preferences</translation>