Salome HOME
Fix for the issue #2753 : error when dump/load script
[modules/shaper.git] / src / SHAPERGUI / SHAPERGUI.cpp
index d764e275396b0d26d473e15d812fed3d7d85c6dd..e7189ffd8e38023950240ac34bb8d7198691c283 100644 (file)
@@ -32,6 +32,7 @@
 #include <XGUI_MenuMgr.h>
 #include <XGUI_FacesPanel.h>
 #include <XGUI_SelectionActivate.h>
+#include <XGUI_InspectionPanel.h>
 
 #include <ModuleBase_Operation.h>
 #include <ModuleBase_Preferences.h>
@@ -120,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()),
@@ -135,6 +137,8 @@ SHAPERGUI::SHAPERGUI()
 //******************************************************
 SHAPERGUI::~SHAPERGUI()
 {
+  delete myWorkshop;
+  delete myProxyViewer;
 }
 
 //******************************************************
@@ -148,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);
 }
 
 //******************************************************
@@ -207,6 +227,13 @@ bool SHAPERGUI::activateModule(SUIT_Study* theStudy)
       desktop()->tabifyDockWidget(aObjDoc, myWorkshop->propertyPanel());
     }
 
+    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;
       application()->viewManagers(OCCViewer_Viewer::Type(), OCCViewManagers);
@@ -307,6 +334,11 @@ bool SHAPERGUI::deactivateModule(SUIT_Study* theStudy)
     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.
   // Abort operation should be performed before the selection's remove
@@ -471,6 +503,7 @@ QAction* SHAPERGUI::addFeature(const QString& theWBName, const ActionInfo& theIn
                                const bool isAddSeparator)
 {
   return addFeature(theWBName,
+                    theInfo.toolBar,
                     theInfo.id,
                     theInfo.text,
                     //Issue #650: in the SALOME mode the tooltip should be same as text
@@ -483,8 +516,8 @@ QAction* SHAPERGUI::addFeature(const QString& theWBName, const ActionInfo& theIn
 }
 
 //******************************************************
-QAction* SHAPERGUI::addFeature(const QString& theWBName, const QString& theId,
-                               const QString& theTitle, const QString& theTip,
+QAction* SHAPERGUI::addFeature(const QString& theWBName, const QString& theTBName,
+                               const QString& theId, const QString& theTitle, const QString& theTip,
                                const QIcon& theIcon, const QKeySequence& theKeys,
                                bool isCheckable, const bool isAddSeparator,
                                const QString& theStatusTip)
@@ -519,7 +552,7 @@ QAction* SHAPERGUI::addFeature(const QString& theWBName, const QString& theId,
   if (isAddSeparator)
     createMenu(separator(), aWBMenu);
 
-  int aWBTool = createTool(theWBName, theWBName);
+  int aWBTool = createTool(theTBName, theTBName);
   int aToolId = createTool(aId, aWBTool);
   if (isAddSeparator)
     createTool(separator(), aWBTool);
@@ -736,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);
+}