Salome HOME
Fix for the issue #2753 : error when dump/load script
[modules/shaper.git] / src / SHAPERGUI / SHAPERGUI.cpp
index ec47761726ebb96e786d63092b8dee34dd8f5030..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;
 }
 
 //******************************************************
@@ -149,6 +152,22 @@ void SHAPERGUI::initialize(CAM_Application* theApp)
   {
     connect(anApp, SIGNAL(preferenceResetToDefaults()), this, SLOT(onDefaultPreferences()));
   }
+
+  int aMenu = createMenu(tr("Inspection"), -1, -1, 30);
+  int aSubMenu = createMenu(tr("Information"), aMenu);
+
+  int aId = myActionsList.size();
+  myActionsList.append("INSPECTION_CMD");
+  SUIT_Desktop* aDesk = application()->desktop();
+  QString aTip = tr("Show inspection window");
+  myWhatIsAction = createAction(aId, aTip, QIcon(":pictures/whatis.png"), tr("What Is"),
+    aTip, QKeySequence(), aDesk, true, this, SLOT(onWhatIs(bool)));
+  myWhatIsAction->setStatusTip(aTip);
+  myWhatIsAction->setData("INSPECTION_CMD");
+  createMenu(aId, aSubMenu, 0);
+
+  int aTool = createTool(tr("Inspection tool"));
+  int aToolId = createTool(myWhatIsAction, aTool);
 }
 
 //******************************************************
@@ -208,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);
-      aInspection->setVisible(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;
@@ -314,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.
@@ -751,3 +769,26 @@ void SHAPERGUI::createFeatureActions()
 {
   myWorkshop->menuMgr()->createFeatureActions();
 }
+
+void SHAPERGUI::onWhatIs(bool isToggled)
+{
+  if (sender() == myWhatIsAction) {
+    QAction* aViewAct = myInspectionPanel->toggleViewAction();
+    aViewAct->blockSignals(true);
+    aViewAct->setChecked(isToggled);
+    aViewAct->blockSignals(false);
+    myInspectionPanel->setVisible(isToggled);
+  }
+  else {
+    myWhatIsAction->blockSignals(true);
+    myWhatIsAction->setChecked(isToggled);
+    myWhatIsAction->blockSignals(false);
+    myInspectionPanel->setVisible(isToggled);
+  }
+}
+
+void SHAPERGUI::updateModuleVisibilityState()
+{
+  LightApp_Module::updateModuleVisibilityState();
+  onWhatIs(myIsInspectionVisible);
+}