Salome HOME
Merge remote-tracking branch 'remotes/origin/BR_2017' into HEAD
[modules/hydro.git] / src / HYDROGUI / HYDROGUI_Operations.cxx
index f57063c236323fed679e8b36f387617fad04b199..a3631f1a46c2d133331979c07516c6d457b4694b 100644 (file)
@@ -72,8 +72,9 @@
 #include "HYDROGUI_ImportLandCoverMapOp.h"
 #include "HYDROGUI_BathymetrySelectionOp.h"
 #include "HYDROGUI_BathymetryOp.h"
+#include "HYDROGUI_RegenerateRegionColorsOp.h"
 #include "HYDROGUI_PolylineStyleOp.h"
-
+#include "HYDROGUI_ZoneSetColorOp.h"
 #include <HYDROData_Document.h>
 #include <HYDROData_Obstacle.h>
 #include <HYDROData_SplitToZonesTool.h>
 
 #include <LightApp_Application.h>
 
-#include <CAM_Application.h>
+#include <OCCViewer_ViewModel.h>
+#include <OCCViewer_ViewManager.h>
+#include <OCCViewer_ViewWindow.h>
+#include <OCCViewer_ViewFrame.h>
 
 #include <QtxListAction.h>
 #include <QtxActionToolMgr.h>
@@ -244,6 +248,8 @@ void HYDROGUI_Module::createActions()
   createAction( LandCoverScalarMapModeOnId, "LC_SCALARMAP_COLORING_ON" );
   createAction( LandCoverScalarMapModeOffId, "LC_SCALARMAP_COLORING_OFF" );
 
+  createAction( RegenerateRegionColorsId, "REGENERATE_REGION_COLORS" );
+  createAction( ZoneSetColorId, "ZONE_SET_COLOR" );
   createAction( ShowHideArrows, "SHOW_HIDE_ARROWS" );
 }
 
@@ -449,12 +455,42 @@ void HYDROGUI_Module::enableLCMActions()
   if ( anAction ) anAction->setEnabled( anEnableTools );
 }
 
+void HYDROGUI_Module::resetViewState()
+{
+  OCCViewer_ViewManager* mgr = dynamic_cast<OCCViewer_ViewManager*>(getApp()->viewManager( OCCViewer_Viewer::Type()));
+  if( mgr )
+  {
+    foreach( SUIT_ViewWindow* wnd, mgr->getViews() )
+    {
+      OCCViewer_ViewFrame* vf = dynamic_cast<OCCViewer_ViewFrame*>( wnd );
+      if( vf )
+      {
+        for( int i=OCCViewer_ViewFrame::MAIN_VIEW; i<=OCCViewer_ViewFrame::TOP_RIGHT; i++ )
+        {
+          OCCViewer_ViewWindow* iwnd = vf->getView(i);
+          if( iwnd )
+            iwnd->resetState();
+        }
+      }
+      else
+      {
+        OCCViewer_ViewWindow* ownd = dynamic_cast<OCCViewer_ViewWindow*>( wnd );
+        if( ownd )
+          ownd->resetState();
+      }
+    }
+  }
+}
+
 void HYDROGUI_Module::onOperation()
 {
   const QAction* anAction = dynamic_cast<const QAction*>( sender() );
   int anId = actionId( anAction );
   if( anId >= 0 )
+  {
+    resetViewState();
     startOperation( anId );
+  }
 
   if( anId==ShowHideArrows )
   {
@@ -765,6 +801,12 @@ LightApp_Operation* HYDROGUI_Module::createOperation( const int theId ) const
   case LandCoverScalarMapModeOffId:
     anOp = new HYDROGUI_LandCoverColoringOp( aModule, theId );
     break;
+  case RegenerateRegionColorsId:
+    anOp = new HYDROGUI_RegenerateRegionColorsOp( aModule );
+    break;
+  case ZoneSetColorId:
+    anOp = new HYDROGUI_ZoneSetColorOp( aModule );
+    break;
   }
 
   if( !anOp )
@@ -868,5 +910,9 @@ void HYDROGUI_Module::onBathymetryText()
   if( isChecked )
     startOperation( BathymetryTextId );
   else
-    operation( BathymetryTextId )->abort();
+  {
+    HYDROGUI_BathymetryOp* op = dynamic_cast<HYDROGUI_BathymetryOp*>( operation( BathymetryTextId ) );
+    if( op )
+      op->commit();
+  }
 }