Salome HOME
Fix for the issue #2753 : error when dump/load script
[modules/shaper.git] / src / SHAPERGUI / SHAPERGUI.cpp
index 25ec9a918059bbbd78e4182e28c1d67242abb119..e7189ffd8e38023950240ac34bb8d7198691c283 100644 (file)
@@ -121,7 +121,8 @@ private:
 //******************************************************
 SHAPERGUI::SHAPERGUI()
     : LightApp_Module("SHAPER"),
-      mySelector(0), myIsOpened(0), myPopupMgr(0)
+      mySelector(0), myIsOpened(0), myPopupMgr(0), myIsInspectionVisible(false),
+  myInspectionPanel(0)
 {
   myWorkshop = new XGUI_Workshop(this);
   connect(myWorkshop, SIGNAL(commandStatusUpdated()),
@@ -136,6 +137,8 @@ SHAPERGUI::SHAPERGUI()
 //******************************************************
 SHAPERGUI::~SHAPERGUI()
 {
+  delete myWorkshop;
+  delete myProxyViewer;
 }
 
 //******************************************************
@@ -163,7 +166,7 @@ void SHAPERGUI::initialize(CAM_Application* theApp)
   myWhatIsAction->setData("INSPECTION_CMD");
   createMenu(aId, aSubMenu, 0);
 
-  int aTool = createTool("INSPWCTION_TOOL", "INSPWCTION_TOOL");
+  int aTool = createTool(tr("Inspection tool"));
   int aToolId = createTool(myWhatIsAction, aTool);
 }
 
@@ -224,12 +227,12 @@ bool SHAPERGUI::activateModule(SUIT_Study* theStudy)
       desktop()->tabifyDockWidget(aObjDoc, myWorkshop->propertyPanel());
     }
 
-    QDockWidget* aInspection = myWorkshop->inspectionPanel();
-    if (aInspection) {
-      QAction* aViewAct = aInspection->toggleViewAction();
-      aViewAct->setEnabled(true);
+    if (!myInspectionPanel) {
+      myInspectionPanel = myWorkshop->inspectionPanel();
+      QAction* aViewAct = myInspectionPanel->toggleViewAction();
       connect(aViewAct, SIGNAL(toggled(bool)), this, SLOT(onWhatIs(bool)));
     }
+    myInspectionPanel->toggleViewAction()->setEnabled(true);
 
     if (!mySelector) {
       ViewManagerList OCCViewManagers;
@@ -330,12 +333,11 @@ bool SHAPERGUI::deactivateModule(SUIT_Study* theStudy)
     QAction* aViewAct = aObjDoc->toggleViewAction();
     aViewAct->setEnabled(false);
   }
-  QDockWidget* aInspection = myWorkshop->inspectionPanel();
-  if (aInspection) {
-    aInspection->setVisible(false);
-    QAction* aViewAct = aInspection->toggleViewAction();
-    aViewAct->setEnabled(false);
-  }
+
+  myIsInspectionVisible = myInspectionPanel->isVisible();
+  myInspectionPanel->hide();
+  QAction* aViewAct = myInspectionPanel->toggleViewAction();
+  aViewAct->setEnabled(false);
 
   // the active operation should be stopped for the next activation.
   // There should not be active operation and visualized preview.
@@ -770,17 +772,23 @@ void SHAPERGUI::createFeatureActions()
 
 void SHAPERGUI::onWhatIs(bool isToggled)
 {
-  QDockWidget* aInspection = myWorkshop->inspectionPanel();
   if (sender() == myWhatIsAction) {
-    QAction* aViewAct = aInspection->toggleViewAction();
+    QAction* aViewAct = myInspectionPanel->toggleViewAction();
     aViewAct->blockSignals(true);
     aViewAct->setChecked(isToggled);
     aViewAct->blockSignals(false);
-    aInspection->setVisible(isToggled);
+    myInspectionPanel->setVisible(isToggled);
   }
   else {
     myWhatIsAction->blockSignals(true);
     myWhatIsAction->setChecked(isToggled);
     myWhatIsAction->blockSignals(false);
+    myInspectionPanel->setVisible(isToggled);
   }
-}
\ No newline at end of file
+}
+
+void SHAPERGUI::updateModuleVisibilityState()
+{
+  LightApp_Module::updateModuleVisibilityState();
+  onWhatIs(myIsInspectionVisible);
+}