Salome HOME
Activation objects redesign.
[modules/shaper.git] / src / SHAPERGUI / SHAPERGUI.cpp
index b07144617027e1c5b78fc4f4ce83c775a6e145ee..20524c9030f8fa31d56b65aa199c8ec559f6b905 100644 (file)
@@ -1,5 +1,22 @@
-// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
-
+// Copyright (C) 2014-2017  CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or
+// email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
+//
 
 #include "SHAPERGUI.h"
 #include "SHAPERGUI_DataModel.h"
@@ -13,6 +30,8 @@
 #include <XGUI_OperationMgr.h>
 #include <XGUI_Displayer.h>
 #include <XGUI_MenuMgr.h>
+#include <XGUI_FacesPanel.h>
+#include <XGUI_SelectionActivate.h>
 
 #include <ModuleBase_Operation.h>
 #include <ModuleBase_Preferences.h>
@@ -47,7 +66,7 @@
 #include <QTimer>
 #include <QMenu>
 
-//#define SALOME_PATCH_FOR_CTRL_WHEEL
+#define SALOME_PATCH_FOR_CTRL_WHEEL
 
 extern "C" {
 SHAPERGUI_EXPORT CAM_Module* createModule()
@@ -256,6 +275,17 @@ bool SHAPERGUI::activateModule(SUIT_Study* theStudy)
   // Postrrocessing for LoadScriptId to remove created(if it was created) SALOME Object Browser
   connect(getApp()->action(LightApp_Application::UserID+1), SIGNAL(triggered(bool)),
           this, SLOT(onScriptLoaded()));
+
+  disconnect(getApp()->action(LightApp_Application::FileSaveId), SIGNAL(triggered(bool)),
+             getApp(), SLOT(onSaveDoc()));
+  disconnect(getApp()->action(LightApp_Application::FileSaveAsId), SIGNAL(triggered(bool)),
+             getApp(), SLOT(onSaveAsDoc()));
+
+  connect(getApp()->action(LightApp_Application::FileSaveId), SIGNAL(triggered(bool)),
+          this, SLOT(onSaveDocByShaper()));
+  connect(getApp()->action(LightApp_Application::FileSaveAsId), SIGNAL(triggered(bool)),
+          this, SLOT(onSaveAsDocByShaper()));
+
   return isDone;
 }
 
@@ -294,6 +324,7 @@ bool SHAPERGUI::deactivateModule(SUIT_Study* theStudy)
     mySelector = 0;
   }
 
+  myWorkshop->hidePanel(myWorkshop->facesPanel());
   //myWorkshop->contextMenuMgr()->disconnectViewer();
 
   SUIT_ResourceMgr* aResMgr = application()->resourceMgr();
@@ -304,6 +335,17 @@ bool SHAPERGUI::deactivateModule(SUIT_Study* theStudy)
   disconnect(getApp()->action(LightApp_Application::UserID+1), SIGNAL(triggered(bool)),
              this, SLOT(onScriptLoaded()));
 
+  disconnect(getApp()->action(LightApp_Application::FileSaveId), SIGNAL(triggered(bool)),
+             this, SLOT(onSaveDocByShaper()));
+  disconnect(getApp()->action(LightApp_Application::FileSaveAsId), SIGNAL(triggered(bool)),
+             this, SLOT(onSaveAsDocByShaper()));
+
+  connect(getApp()->action(LightApp_Application::FileSaveId), SIGNAL(triggered(bool)),
+          getApp(), SLOT(onSaveDoc()));
+  connect(getApp()->action(LightApp_Application::FileSaveAsId), SIGNAL(triggered(bool)),
+          getApp(), SLOT(onSaveAsDoc()));
+
+
   return LightApp_Module::deactivateModule(theStudy);
 }
 
@@ -312,7 +354,8 @@ void SHAPERGUI::onViewManagerAdded(SUIT_ViewManager* theMgr)
 {
   if (!mySelector) {
     mySelector = createSelector(theMgr);
-    myWorkshop->module()->activateSelectionFilters();
+    myWorkshop->selectionActivate()->updateSelectionFilters();
+    myWorkshop->selectionActivate()->updateSelectionModes();
     myWorkshop->synchronizeViewer();
   }
 }
@@ -371,6 +414,24 @@ void SHAPERGUI::onScriptLoaded()
     delete aBrowser;
 }
 
+//******************************************************
+void SHAPERGUI::onSaveDocByShaper()
+{
+  if(!workshop()->operationMgr()->abortAllOperations(XGUI_OperationMgr::XGUI_InformationMessage))
+    return;
+
+  getApp()->onSaveDoc();
+}
+
+//******************************************************
+void SHAPERGUI::onSaveAsDocByShaper()
+{
+  if(!workshop()->operationMgr()->abortAllOperations(XGUI_OperationMgr::XGUI_InformationMessage))
+    return;
+
+  getApp()->onSaveAsDoc();
+}
+
 //******************************************************
 void SHAPERGUI::onUpdateCommandStatus()
 {