Salome HOME
Copyright update 2020
[modules/shaper.git] / src / SHAPERGUI / SHAPERGUI.cpp
index 2bd9679175c2f647abcccb8b69b6fb114edae79c..0cd96374cdeb1a27184df9232c583c408c1a5c22 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2014-2019  CEA/DEN, EDF R&D
+// Copyright (C) 2014-2020  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
@@ -74,7 +74,9 @@
 #include <QMenu>
 #include <QToolBar>
 
-#define SALOME_PATCH_FOR_CTRL_WHEEL
+#if OCC_VERSION_HEX < 0x070400
+  #define SALOME_PATCH_FOR_CTRL_WHEEL
+#endif
 
 extern "C" {
 SHAPERGUI_EXPORT CAM_Module* createModule()
@@ -134,7 +136,7 @@ private:
 SHAPERGUI::SHAPERGUI()
     : LightApp_Module("SHAPER"),
       mySelector(0), myIsOpened(0), myPopupMgr(0), myIsInspectionVisible(false),
-  myInspectionPanel(0), myIsToolbarsModified(false)
+  myInspectionPanel(0), myIsFacesPanelVisible(false), myIsToolbarsModified(false)
 {
   myWorkshop = new XGUI_Workshop(this);
   connect(myWorkshop, SIGNAL(commandStatusUpdated()),
@@ -168,7 +170,7 @@ void SHAPERGUI::initialize(CAM_Application* theApp)
   }
 
   int aMenu = createMenu(tr("Inspection"), -1, -1, 30);
-  int aSubMenu = createMenu(tr("Information"), aMenu);
+  int aSubMenu = createMenu(tr("Information"), aMenu, -1, -1, 0);
 
   int aId = getNextCommandId();
   myActionsList.append(aId);
@@ -180,7 +182,7 @@ void SHAPERGUI::initialize(CAM_Application* theApp)
   myWhatIsAction->setData("INSPECTION_CMD");
   createMenu(aId, aSubMenu, 0);
 
-  QString aToolName = tr("Inspection tool");
+  QString aToolName = tr("Inspection");
   int aTool = createTool(aToolName);
   int aToolId = createTool(myWhatIsAction, aTool);
   registerCommandToolbar(aToolName, aId);
@@ -267,19 +269,23 @@ bool SHAPERGUI::activateModule(SUIT_Study* theStudy)
     QObject* aObj = myWorkshop->objectBrowser()->parent();
     QDockWidget* aObjDoc = dynamic_cast<QDockWidget*>(aObj);
     if (aObjDoc) {
-      QAction* aViewAct = aObjDoc->toggleViewAction();
-      aViewAct->setEnabled(true);
       myWorkshop->objectBrowser()->setVisible(true);
       aObjDoc->setVisible(true);
       desktop()->tabifyDockWidget(aObjDoc, myWorkshop->propertyPanel());
+      aObjDoc->toggleViewAction()->setVisible(true);
     }
 
     if (!myInspectionPanel) {
       myInspectionPanel = myWorkshop->inspectionPanel();
-      QAction* aViewAct = myInspectionPanel->toggleViewAction();
-      connect(aViewAct, SIGNAL(toggled(bool)), this, SLOT(onWhatIs(bool)));
+      connect(myInspectionPanel->toggleViewAction(), SIGNAL(toggled(bool)),
+              this, SLOT(onWhatIs(bool)));
     }
-    myInspectionPanel->toggleViewAction()->setEnabled(true);
+    myInspectionPanel->toggleViewAction()->setVisible(true);
+
+    myWorkshop->facesPanel()->toggleViewAction()->setVisible(true);
+    if (myIsFacesPanelVisible)
+      myWorkshop->facesPanel()->show();
+    myWorkshop->propertyPanel()->toggleViewAction()->setVisible(true);
 
     if (!mySelector) {
       ViewManagerList OCCViewManagers;
@@ -387,14 +393,19 @@ bool SHAPERGUI::deactivateModule(SUIT_Study* theStudy)
   if (aObjDoc) {
     aObjDoc->setVisible(false);
     myWorkshop->objectBrowser()->setVisible(false);
-    QAction* aViewAct = aObjDoc->toggleViewAction();
-    aViewAct->setEnabled(false);
+    aObjDoc->toggleViewAction()->setVisible(false);
   }
 
   myIsInspectionVisible = myInspectionPanel->isVisible();
   myInspectionPanel->hide();
-  QAction* aViewAct = myInspectionPanel->toggleViewAction();
-  aViewAct->setEnabled(false);
+  myInspectionPanel->toggleViewAction()->setVisible(false);
+
+  myIsFacesPanelVisible = myWorkshop->facesPanel()->isVisible();
+  myWorkshop->facesPanel()->hide();
+  myWorkshop->facesPanel()->toggleViewAction()->setVisible(false);
+
+  myWorkshop->propertyPanel()->hide();
+  myWorkshop->propertyPanel()->toggleViewAction()->setVisible(false);
 
   // the active operation should be stopped for the next activation.
   // There should not be active operation and visualized preview.
@@ -415,6 +426,14 @@ bool SHAPERGUI::deactivateModule(SUIT_Study* theStudy)
     //}
     myWorkshop->displayer()->setSelectionColor(myOldSelectionColor);
     myProxyViewer->setSelector(0);
+
+    LightApp_SelectionMgr* aMgr = getApp()->selectionMgr();
+    QList<SUIT_Selector*> aList;
+    aMgr->selectors(aList);
+    foreach(SUIT_Selector* aSel, aList) {
+      aSel->setEnabled(aSel != mySelector);
+    }
+
     delete mySelector;
     mySelector = 0;
   }
@@ -442,6 +461,8 @@ bool SHAPERGUI::deactivateModule(SUIT_Study* theStudy)
   connect(getApp()->action(LightApp_Application::FileSaveAsId), SIGNAL(triggered(bool)),
           getApp(), SLOT(onSaveAsDoc()));
 
+  publishToStudy();
+
   return LightApp_Module::deactivateModule(theStudy);
 }
 
@@ -516,6 +537,8 @@ void SHAPERGUI::onScriptLoaded()
   SUIT_DataBrowser* aBrowser = getApp()->objectBrowser();
   if (aBrowser)
     delete aBrowser;
+  myWorkshop->displayer()->updateViewer();
+  myWorkshop->updateCommandStatus();
 }
 
 //******************************************************
@@ -687,9 +710,14 @@ QAction* SHAPERGUI::addFeatureOfNested(const QString& theWBName,
 QAction* SHAPERGUI::addDesktopCommand(const QString& theId, const QString& theTitle,
                                            const QString& theTip, const QIcon& theIcon,
                                            const QKeySequence& theKeys, bool isCheckable,
-                                           const char* theMenuSourceText, const int theMenuPosition)
+                                           const char* theMenuSourceText,
+                                           const QString& theSubMenu,
+                                           const int theMenuPosition,
+                                           const int theSuibMenuPosition)
 {
   int aMenu = createMenu(tr(theMenuSourceText), -1, -1);
+  if (!theSubMenu.isNull())
+    aMenu = createMenu(theSubMenu, aMenu, -1, theSuibMenuPosition);
 
   int aId = getNextCommandId();
   myActionsList.append(aId);
@@ -1174,3 +1202,9 @@ void SHAPERGUI::resetToolbars()
   SUIT_ResourceMgr* aResMgr = application()->resourceMgr();
   aResMgr->remove(ToolbarsSection);
 }
+
+void SHAPERGUI::publishToStudy()
+{
+  if (isActiveModule())
+    myWorkshop->module()->launchOperation("PublishToStudy", false);
+}