Salome HOME
refs #1330: global option show/hide arrows
authorasl <asl@opencascade.com>
Thu, 2 Nov 2017 06:27:41 +0000 (09:27 +0300)
committerasl <asl@opencascade.com>
Thu, 2 Nov 2017 06:27:41 +0000 (09:27 +0300)
src/HYDROGUI/HYDROGUI_Module.cxx
src/HYDROGUI/HYDROGUI_Module.h
src/HYDROGUI/HYDROGUI_Operations.cxx
src/HYDROGUI/HYDROGUI_Operations.h
src/HYDROGUI/resources/HYDROGUI_msg_en.ts

index 42473a596984f35e421b4084467891210897fb11..57f0f934ccff1d5a7519176bcbf0e899d757ea38 100644 (file)
@@ -744,8 +744,6 @@ void HYDROGUI_Module::contextMenuPopup( const QString& theClient,
     bool isPoly = anIsPolyline || anIsPolyline3D;
     if (isPoly  && !anIsLandCoverMap)
       theMenu->addAction( action( ExportToShapeFileID ) );
-    if( isPoly )
-      theMenu->addAction( action( PolylineStyleId ) );
 
     // Add copy action
     QAction* aCopyAction = action( CopyId );
@@ -822,6 +820,15 @@ void HYDROGUI_Module::contextMenuPopup( const QString& theClient,
       }
     }
   }
+
+  bool isPoly = anIsPolyline || anIsPolyline3D;
+  if( isPoly )
+  {
+    theMenu->addSeparator();
+    QAction* a = action( ShowHideArrows );
+    a->setText( arrowsVisible() ? tr( "HIDE_ARROWS" ) : tr( "SHOW_ARROWS" ) );
+    theMenu->addAction( a );
+  }
 }
 
 void HYDROGUI_Module::createPreferences()
index edf520d70832c5158c97fd18649d59091ca77cc9..ba0f8ba5457a41d081dae1951d0127947e00a1f2 100644 (file)
@@ -258,6 +258,9 @@ public:
 
   void                            enableLCMActions();
 
+  bool arrowsVisible() const;
+  void setArrowsVisible( bool );
+
 protected:
   CAM_DataModel*                  createDataModel();
 
index e9cf65806506a9b7cf0cab48558480e61b1ea3ff..eaaebfbc9ec8e7ebe56ebc2ef4a76c0caaf9ce59 100644 (file)
@@ -243,7 +243,7 @@ void HYDROGUI_Module::createActions()
   createAction( LandCoverScalarMapModeOnId, "LC_SCALARMAP_COLORING_ON" );
   createAction( LandCoverScalarMapModeOffId, "LC_SCALARMAP_COLORING_OFF" );
 
-  createAction( PolylineStyleId, "POLYLINE_STYLE" );
+  createAction( ShowHideArrows, "SHOW_HIDE_ARROWS" );
 }
 
 void HYDROGUI_Module::createMenus()
@@ -454,6 +454,47 @@ void HYDROGUI_Module::onOperation()
   int anId = actionId( anAction );
   if( anId >= 0 )
     startOperation( anId );
+
+  if( anId==ShowHideArrows )
+  {
+    setArrowsVisible( !arrowsVisible() );
+  }
+}
+
+bool HYDROGUI_Module::arrowsVisible() const
+{
+  int aType;
+  SUIT_ResourceMgr* resMgr = application()->resourceMgr();
+  if( resMgr )
+  {
+    resMgr->value( "polyline", "arrow_type", aType );
+    return aType>0;
+  }
+  else
+    return false;
+}
+
+void HYDROGUI_Module::setArrowsVisible( bool isVisible )
+{
+  SUIT_ResourceMgr* resMgr = application()->resourceMgr();
+
+  int aType=-1;
+  if( !resMgr )
+    return;
+
+  if( isVisible )
+  {
+    if( resMgr->hasValue( "polyline", "prev_arrow_type" ) )
+      resMgr->value( "polyline", "prev_arrow_type", aType );
+    resMgr->setValue( "polyline", "arrow_type", aType );
+  }
+  else
+  {
+    resMgr->value( "polyline", "arrow_type", aType );
+    resMgr->setValue( "polyline", "prev_arrow_type", aType );
+    resMgr->setValue( "polyline", "arrow_type", 0 );
+  }
+  preferencesChanged( "polyline", "arrow_type" );
 }
 
 void HYDROGUI_Module::onDelete()
@@ -717,9 +758,6 @@ LightApp_Operation* HYDROGUI_Module::createOperation( const int theId ) const
   case LandCoverScalarMapModeOffId:
     anOp = new HYDROGUI_LandCoverColoringOp( aModule, theId );
     break;
-  case PolylineStyleId:
-    anOp = new HYDROGUI_PolylineStyleOp( aModule );
-    break;
   }
 
   if( !anOp )
index a2a18fe69e65c50ee980b17e6c3a9493d2f3cd51..fdd3048da307485937a438391a83bd97564c8288 100644 (file)
@@ -144,7 +144,7 @@ enum OperationId
   BathymetryRescaleUserId,
   BathymetryRescaleDefaultId,
 
-  PolylineStyleId,
+  ShowHideArrows,
 };
 
 #endif
index 812f119210af9aa8a428d223cb197e42e041d3ec..ed6904559e43bf22560a6b34f3e2ab8f86be2166 100644 (file)
@@ -996,8 +996,8 @@ Would you like to remove all references from the image?</translation>
       <translation>Default rescale bathymetry</translation>
     </message>
     <message>
-      <source>DSK_POLYLINE_STYLE</source>
-      <translation>Polyline style</translation>
+      <source>DSK_SHOW_HIDE_ARROWS</source>
+      <translation>Show/hide arrows</translation>
     </message>
     <message>
       <source>DSK_IMPORT_IMAGE</source>
@@ -1369,8 +1369,16 @@ Would you like to remove all references from the image?</translation>
       <translation>Default rescale bathymetry</translation>
     </message>
     <message>
-      <source>MEN_POLYLINE_STYLE</source>
-      <translation>Polyline style</translation>
+      <source>MEN_SHOW_HIDE_ARROWS</source>
+      <translation>Show/hide arrows</translation>
+    </message>
+    <message>
+      <source>HIDE_ARROWS</source>
+      <translation>Hide arrows</translation>
+    </message>
+    <message>
+      <source>SHOW_ARROWS</source>
+      <translation>Show arrows</translation>
     </message>
     <message>
       <source>MEN_IMPORT_IMAGE</source>