Salome HOME
INT PAL 0052685: Add possibility to show/hide Scalar Bar of Actor
authorimn <imn@opencascade.com>
Tue, 21 Apr 2015 07:37:02 +0000 (10:37 +0300)
committerimn <imn@opencascade.com>
Tue, 21 Apr 2015 07:37:02 +0000 (10:37 +0300)
src/SMESHGUI/SMESHGUI.cxx
src/SMESHGUI/SMESHGUI_Operations.h
src/SMESHGUI/SMESHGUI_Selection.cxx
src/SMESHGUI/SMESHGUI_Selection.h
src/SMESHGUI/SMESH_msg_en.ts
src/SMESHGUI/SMESH_msg_fr.ts
src/SMESHGUI/SMESH_msg_ja.ts

index de3f26559900713a3cfa74842478cd418f9ef699..0b30830c43c2c024bfafb2205f9899e917616301 100644 (file)
@@ -1187,7 +1187,7 @@ namespace
     }
   }
 
-  void ShowDistribution() {
+  void ShowElement(int theCommandID ) {
     LightApp_SelectionMgr* aSel = SMESHGUI::selectionMgr();
     SALOME_ListIO selected;
     if ( aSel )
@@ -1199,7 +1199,12 @@ namespace
         SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() );
         if ( anActor && anActor->GetScalarBarActor() && anActor->GetControlMode() != SMESH_Actor::eNone ) {
           SMESH_ScalarBarActor *aScalarBarActor = anActor->GetScalarBarActor();
-          aScalarBarActor->SetDistributionVisibility(!aScalarBarActor->GetDistributionVisibility());
+          if ( theCommandID == SMESHOp::OpShowDistribution ) {
+            aScalarBarActor->SetDistributionVisibility(!aScalarBarActor->GetDistributionVisibility());
+          }
+          else if ( theCommandID == SMESHOp::OpShowScalarBar ) {
+            aScalarBarActor->SetVisibility( !aScalarBarActor->GetVisibility());
+          }
         }
       }
     }
@@ -1323,7 +1328,7 @@ namespace
         QColor orientationColor, outlineColor, volumeColor;
         int deltaF = 0, deltaV = 0;
         int elem0dSize   = 1;
-        int ballSize     = 1;
+        //int ballSize     = 1;
         double ballScale = 1.0;
         int edgeWidth    = 1;
         int outlineWidth = 1;
@@ -1368,7 +1373,7 @@ namespace
             // balls: color, size
             anActor->GetBallColor( color[0], color[1], color[2] );
             ballColor.setRgbF( color[0], color[1], color[2] );
-            ballSize = qMax( (int)anActor->GetBallSize(), 1 ); // minimum allowed size is 1
+            //ballSize = qMax( (int)anActor->GetBallSize(), 1 ); // minimum allowed size is 1
             ballScale = qMax( (double)anActor->GetBallScale(), 1e-2 ); // minimum allowed scale is 1e-2
             // outlines: color
             anActor->GetOutlineColor( color[0], color[1], color[2] );
@@ -1425,7 +1430,7 @@ namespace
         dlg.setElem0dSize( elem0dSize );
         // balls: color, size
         dlg.setBallColor( ballColor );
-        dlg.setBallSize( ballSize );
+        //dlg.setBallSize( ballSize );
         dlg.setBallScale( ballScale );
         // orientation: color, scale, 3d flag
         dlg.setOrientationColor( orientationColor );
@@ -1452,7 +1457,7 @@ namespace
           elem0dColor      = dlg.elem0dColor();
           elem0dSize       = dlg.elem0dSize();
           ballColor        = dlg.ballColor();
-          ballSize         = dlg.ballSize();
+         // ballSize         = dlg.ballSize();
           ballScale        = dlg.ballScale();
           orientationColor = dlg.orientationColor();
           orientationScale = dlg.orientationSize() / 100.;
@@ -1496,7 +1501,7 @@ namespace
             anActor->Set0DSize( elem0dSize );
             // balls: color, size
             anActor->SetBallColor( ballColor.redF(), ballColor.greenF(), ballColor.blueF() );
-            anActor->SetBallSize( ballSize );
+            // anActor->SetBallSize( ballSize );
             anActor->SetBallScale( ballScale );
             // orientation: color, scale, 3d flag
             anActor->SetFacesOrientationColor( orientationColor.redF(), orientationColor.greenF(), orientationColor.blueF() );
@@ -2482,6 +2487,12 @@ bool SMESHGUI::OnGUIEvent( int theCommandID )
       SMESHGUI_Preferences_ScalarBarDlg::ScalarBarProperties( this );
       break;
     }
+  case SMESHOp::OpShowScalarBar:
+    {
+      // show/hide scalar bar
+      ::ShowElement(theCommandID);
+      break;
+    }
   case SMESHOp::OpSaveDistribution:
     {
       // dump control distribution data to the text file
@@ -2491,8 +2502,8 @@ bool SMESHGUI::OnGUIEvent( int theCommandID )
 
   case SMESHOp::OpShowDistribution:
     {
-      // show/ distribution
-      ::ShowDistribution();
+      // show/hide distribution
+      ::ShowElement(theCommandID);
       break;
     }
 
@@ -3921,6 +3932,7 @@ void SMESHGUI::initialize( CAM_Application* app )
 
   createSMESHAction( SMESHOp::OpReset,               "RESET" );
   createSMESHAction( SMESHOp::OpScalarBarProperties, "SCALAR_BAR_PROP" );
+  createSMESHAction( SMESHOp::OpShowScalarBar,       "SHOW_SCALAR_BAR","",0, true  );
   createSMESHAction( SMESHOp::OpSaveDistribution,    "SAVE_DISTRIBUTION" );
   createSMESHAction( SMESHOp::OpShowDistribution,    "SHOW_DISTRIBUTION","",0, true );
 #ifndef DISABLE_PLOT2DVIEWER
@@ -4639,6 +4651,9 @@ void SMESHGUI::initialize( CAM_Application* app )
 
   popupMgr()->insert( separator(), anId, -1 );
 
+  popupMgr()->insert( action( SMESHOp::OpShowScalarBar ), anId, -1 );
+  popupMgr()->setRule( action( SMESHOp::OpShowScalarBar ), aMeshInVTK + "&& controlMode <> 'eNone'", QtxPopupMgr::VisibleRule );
+  popupMgr()->setRule( action( SMESHOp::OpShowScalarBar ), aMeshInVTK + "&& controlMode <> 'eNone' && isScalarBarVisible", QtxPopupMgr::ToggleRule );
   popupMgr()->insert( action( SMESHOp::OpScalarBarProperties ), anId, -1 );
   popupMgr()->setRule( action( SMESHOp::OpScalarBarProperties ), aMeshInVTK + "&& controlMode <> 'eNone'", QtxPopupMgr::VisibleRule );
 
@@ -4651,7 +4666,7 @@ void SMESHGUI::initialize( CAM_Application* app )
 
   popupMgr()->insert( action( SMESHOp::OpShowDistribution ), aSubId, -1 );
   popupMgr()->setRule( action( SMESHOp::OpShowDistribution ), aMeshInVTK + "&& isNumFunctor", QtxPopupMgr::VisibleRule );
-  popupMgr()->setRule( action( SMESHOp::OpShowDistribution ), aMeshInVTK + "&& isNumFunctor && isDistributionVisible", QtxPopupMgr::ToggleRule);
+  popupMgr()->setRule( action( SMESHOp::OpShowDistribution ), aMeshInVTK + "&& isNumFunctor && isScalarBarVisible && isDistributionVisible", QtxPopupMgr::ToggleRule);
 
 #ifndef DISABLE_PLOT2DVIEWER
   popupMgr()->insert( action( SMESHOp::OpPlotDistribution ), aSubId, -1 );
@@ -5129,8 +5144,10 @@ void SMESHGUI::createPreferences()
 
   int size0d = addPreference(tr("PREF_SIZE_0D"), elemGroup,
                              LightApp_Preferences::IntSpin, "SMESH", "elem0d_size");
-  int ballSize = addPreference(tr("PREF_BALL_SIZE"), elemGroup,
-                             LightApp_Preferences::IntSpin, "SMESH", "ball_elem_size");
+  /* int ballSize = addPreference(tr("PREF_BALL_SIZE"), elemGroup,
+                             LightApp_Preferences::IntSpin, "SMESH", "ball_elem_size"); */
+  int ballDiameter = addPreference(tr("PREF_BALL_DIAMETER"), elemGroup,
+                             LightApp_Preferences::IntSpin, "SMESH", "ball_elem_diameter");
   double ballScale = addPreference(tr("PREF_BALL_SCALE"), elemGroup,
                              LightApp_Preferences::DblSpin, "SMESH", "ball_elem_scale");
   int elemW  = addPreference(tr("PREF_WIDTH"), elemGroup,
@@ -5143,8 +5160,12 @@ void SMESHGUI::createPreferences()
   setPreferenceProperty( size0d, "min", 1 );
   setPreferenceProperty( size0d, "max", 10 );
 
-  setPreferenceProperty( ballSize, "min", 1 );
-  setPreferenceProperty( ballSize, "max", 10 );
+ // setPreferenceProperty( ballSize, "min", 1 );
+ // setPreferenceProperty( ballSize, "max", 10 );
+
+  setPreferenceProperty( ballDiameter, "min", 1e-7 );
+  setPreferenceProperty( ballDiameter, "max", 1e9 );
+  setPreferenceProperty( ballDiameter, "step", 0.1 );
 
   setPreferenceProperty( ballScale, "min", 1e-2 );
   setPreferenceProperty( ballScale, "max", 1e7 );
@@ -5821,7 +5842,8 @@ void SMESHGUI::storeVisualParameters (int savePoint)
                   sizeStr << "elem0d";
                   sizeStr << QString::number((int)aSmeshActor->Get0DSize());
                   sizeStr << "ball";
-                  sizeStr << QString::number((int)aSmeshActor->GetBallSize());
+                  //sizeStr << QString::number((int)aSmeshActor->GetBallSize());
+                  sizeStr << QString::number((double)aSmeshActor->GetBallSize());
                   sizeStr << QString::number((double)aSmeshActor->GetBallScale());
                   sizeStr << "shrink";
                   sizeStr << QString::number(aSmeshActor->GetShrinkFactor());
@@ -6406,7 +6428,8 @@ void SMESHGUI::restoreVisualParameters (int savePoint)
               int lineWidth = -1;
               int outlineWidth = -1;
               int elem0dSize = -1;
-              int ballSize = -1;
+              //int ballSize = -1;
+              double ballDiameter = -1.0;
               double ballScale = -1.0;
               double shrinkSize = -1;
               double orientationSize = -1;
@@ -6439,10 +6462,12 @@ void SMESHGUI::restoreVisualParameters (int savePoint)
                   // - size - is a integer value specifying size
                   // - scale - is a double value specifying scale factor
                   if ( i+1 >= sizes.count() ) break;                       // format error
-                  int v1 = sizes[i+1].toInt( &bOk ); if ( !bOk ) break;    // format error
+                  //int v1 = sizes[i+1].toInt( &bOk ); if ( !bOk ) break;    // format error
+                  double v1 = sizes[i+1].toInt( &bOk ); if ( !bOk ) break;    // format error
                   if ( i+2 >= sizes.count() ) break;                       // format error
                   double v2 = sizes[i+2].toDouble( &bOk ); if ( !bOk ) break; // format error
-                  ballSize = v1;
+                  //ballSize = v1;
+                  ballDiameter = v1;
                   ballScale = v2;
                   i += 2;
                 }
@@ -6478,8 +6503,11 @@ void SMESHGUI::restoreVisualParameters (int savePoint)
               if ( elem0dSize > 0 )
                 aSmeshActor->Set0DSize( elem0dSize );
               // ball size
-              if ( ballSize > 0 )
-                aSmeshActor->SetBallSize( ballSize );
+              /*if ( ballSize > 0 )
+                aSmeshActor->SetBallSize( ballSize );*/
+              // ball diameter
+              if ( ballDiameter > 0 )
+                aSmeshActor->SetBallSize( ballDiameter );
               // ball scale
               if ( ballScale > 0.0 )
                 aSmeshActor->SetBallScale( ballScale );
index 576133bcf5f91c3de532d06deedb6de17cb90638..c9b3a2f58e38a8800f8f91673f052579c477819b 100644 (file)
@@ -29,6 +29,7 @@ namespace SMESHOp {
     OpSelectFiltersLibrary   = 1010,   // MENU TOOLS - SELECTION FILTERS LIBRARY
     OpReset                  = 1020,   // RESET
     OpScalarBarProperties    = 1021,   // SCALAR BAR PROPERTIES
+    OpShowScalarBar          = 1022,   // SHOW SCALAR BAR
     OpSaveDistribution       = 1030,   // SAVE DISTRIBUTION
     OpShowDistribution       = 1031,   // SHOW DISTRIBUTION
 #ifndef DISABLE_PLOT2DVIEWER
index b40dabd2079207db160448e0efac8f7f2d7c0bac..1c99de1d85176c7e9cd25d17ce726f604f3c6cf3 100644 (file)
@@ -134,6 +134,7 @@ QVariant SMESHGUI_Selection::parameter( const int ind, const QString& p ) const
   else if ( p=="groupType" )            val = QVariant( groupType( ind ) );
   else if ( p=="quadratic2DMode")       val = QVariant( quadratic2DMode( ind ) );
   else if ( p=="isDistributionVisible") val = QVariant( isDistributionVisible( ind ) );
+  else if ( p=="isScalarBarVisible")    val = QVariant( isScalarBarVisible( ind ) );
   else if ( p=="hasChildren")           val = QVariant( hasChildren( ind ) );
   else if ( p=="nbChildren")            val = QVariant( nbChildren( ind ) );
   else if ( p=="isContainer")           val = QVariant( isContainer( ind ) );
@@ -257,6 +258,16 @@ bool SMESHGUI_Selection::isDistributionVisible(int ind) const {
   return (actor && actor->GetScalarBarActor() && actor->GetScalarBarActor()->GetDistributionVisibility());
 } 
 
+//=======================================================================
+//function : isScalarBarVisible
+//purpose  : Visible/Invisible Scalar Bar
+//=======================================================================
+
+bool SMESHGUI_Selection::isScalarBarVisible(int ind) const {
+  SMESH_Actor* actor = getActor( ind );
+  return (actor && actor->GetScalarBarActor() && actor->GetScalarBarActor()->GetVisibility());
+}
+
 //=======================================================================
 //function : shrinkMode
 //purpose  : return either 'IsSrunk', 'IsNotShrunk' or 'IsNotShrinkable'
index d06d35e5211805ca91c20d4c5e08c635fba4b0bf..f26b9979ce4f9f0d23c395e6e545262bd0933743 100644 (file)
@@ -61,9 +61,10 @@ public:
   virtual QVariant        hasReference( int ) const;
   virtual QVariant        isVisible( int ) const;
 
-  virtual QString         quadratic2DMode(int ) const;
+  virtual QString         quadratic2DMode( int ) const;
 
-  virtual bool            isDistributionVisible(int ) const;
+  virtual bool            isDistributionVisible( int ) const;
+  virtual bool            isScalarBarVisible( int ) const;
   virtual bool            hasChildren( int ) const;
   virtual int             nbChildren( int ) const;
   virtual bool            isContainer( int ) const;
index 08bb2e205a1eca12ad27ce38db4fd5b3da31dc45..59e9c9be989c9fb64707e975b855499770848b05 100644 (file)
         <source>MEN_SHADE</source>
         <translation>Shading</translation>
     </message>
+    <message>
+        <source>MEN_SHOW_SCALAR_BAR</source>
+        <translation>Show Scalar Bar</translation>
+    </message>
     <message>
         <source>MEN_QUADRATIC_REPRESENT</source>
         <translation>2D Quadratic</translation>
@@ -2581,6 +2585,10 @@ Check algorithm documentation for supported geometry</translation>
         <source>SMESH_SEWING</source>
         <translation>Sewing</translation>
     </message>
+    <message>
+        <source>SMESH_SHOW_SCALAR_BAR</source>
+        <translation>Show Scalar Bar</translation>
+    </message>
     <message>
         <source>SMESH_SMOOTHING</source>
         <translation>Smoothing</translation>
@@ -3328,6 +3336,10 @@ Use Display Entity menu command to show them.
         <source>STB_SHOW</source>
         <translation>Show</translation>
     </message>
+    <message>
+        <source>STB_SHOW_SCALAR_BAR</source>
+        <translation>Show Scalar Bar</translation>
+    </message>
     <message>
         <source>STB_SHRINK</source>
         <translation>Shrink</translation>
index 47ef037d805f748b5b8b913f389aac80c8e5a578..96922a41ab1201738312adddcf6520db4ee9d862 100755 (executable)
         <source>MEN_SHADE</source>
         <translation>Ombrage</translation>
     </message>
+    <message>
+        <source>MEN_SHOW_SCALAR_BAR</source>
+        <translation type="unfinished">Show Scalar Bar</translation>
+    </message>
     <message>
         <source>MEN_QUADRATIC_REPRESENT</source>
         <translation>Quadratique 2D</translation>
@@ -2577,6 +2581,10 @@ Référez-vous à la documentation sur l&apos;algorithme et la géométrie suppo
         <source>SMESH_SEWING</source>
         <translation>Couture</translation>
     </message>
+    <message>
+        <source>SMESH_SHOW_SCALAR_BAR</source>
+        <translation type="unfinished">Show Scalar Bar</translation>
+    </message>
     <message>
         <source>SMESH_SMOOTHING</source>
         <translation>Lissage</translation>
@@ -3289,6 +3297,10 @@ Utilisez le menu &quot;Visualiser une entité&quot; pour les afficher.
         <source>STB_SHOW_DISTRIBUTION</source>
         <translation>Afficher la distribution</translation>
     </message>
+    <message>
+        <source>STB_SHOW_SCALAR_BAR</source>
+        <translation type="unfinished">Show Scalar Bar</translation>
+    </message>
     <message>
         <source>STB_REVOLUTION</source>
         <translation>Révolution</translation>
index f909eba822df409957ccf93b6444e0e9c40125f3..29698eb01cd8299f31044c66cb0e4c05ea2508d1 100644 (file)
       <source>MEN_SHADE</source>
       <translation>網かけ</translation>
     </message>
+    <message>
+      <source>MEN_SHOW_SCALAR_BAR</source>
+      <translation type="unfinished">Show Scalar Bar</translation>
+    </message>
     <message>
       <source>MEN_QUADRATIC_REPRESENT</source>
       <translation>二次 2D</translation>
       <source>SMESH_SHOW_DISTRIBUTION_SCALARBAR</source>
       <translation>分布を表示します。</translation>
     </message>
+    <message>
+      <source>SMESH_SHOW_SCALAR_BAR</source>
+      <translation type="unfinished">Show Scalar Bar</translation>
+    </message>
     <message>
       <source>SMESH_PRECISION</source>
       <translation>精度</translation>
       <source>STB_SHOW_DISTRIBUTION</source>
       <translation>分布を表示します。</translation>
     </message>
+    <message>
+      <source>STB_SHOW_SCALAR_BAR</source>
+      <translation type="unfinished">Show Scalar Bar</translation>
+    </message>
     <message>
       <source>STB_REVOLUTION</source>
       <translation>Revolution</translation>