Salome HOME
updated copyright message
[modules/shaper.git] / src / SHAPERGUI / SHAPERGUI.cpp
index f8416f993c329078ba4a6aa134680061a9e9919d..475b4933d71e1b9e4831a01199ad435ef3ce7780 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2014-2022  CEA/DEN, EDF R&D
+// Copyright (C) 2014-2023  CEA, EDF
 //
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
@@ -61,6 +61,7 @@
 #include <QtxActionMenuMgr.h>
 #include <QtxActionToolMgr.h>
 #include <QtxResourceMgr.h>
+#include <QtxInfoPanel.h>
 
 #include <Config_PropManager.h>
 #include <Config_ModuleReader.h>
@@ -243,6 +244,7 @@ void SHAPERGUI::initialize(CAM_Application* theApp)
 void SHAPERGUI::windows(QMap<int, int>& theWndMap) const
 {
   theWndMap.insert(LightApp_Application::WT_PyConsole, Qt::BottomDockWidgetArea);
+  theWndMap.insert(LightApp_Application::WT_InfoPanel, Qt::RightDockWidgetArea);
 }
 
 //******************************************************
@@ -328,19 +330,9 @@ bool SHAPERGUI::activateModule(SUIT_Study* theStudy)
     else
       myWorkshop->updateCommandStatus();
   }
-  SUIT_ResourceMgr* aResMgr = application()->resourceMgr();
-  myIsStorePositions = aResMgr->booleanValue("Study", "store_positions", true);
   myIsEditEnabled = getApp()->isEditEnabled();
   getApp()->setEditEnabled(false);
 
-  // this following row is caused by #187 bug.
-  // SALOME saves the dock widget positions before deactivateModule() and
-  // load it after the module activation. So, if the panel is visible before
-  // deactivate, it becomes visible after activate.
-  // In order to avoid the visible property panel, the widget position save is
-  // switch off in this module
-  aResMgr->setValue("Study", "store_positions", false);
-
   // Synchronize displayed objects
   Handle(AIS_InteractiveContext) aContext;
   if (mySelector && mySelector->viewer())
@@ -390,7 +382,7 @@ bool SHAPERGUI::activateModule(SUIT_Study* theStudy)
           this, SLOT(onSaveDocByShaper()));
   connect(getApp()->action(LightApp_Application::FileSaveAsId), SIGNAL(triggered(bool)),
           this, SLOT(onSaveAsDocByShaper()));
-
+  updateInfoPanel();
   return isDone;
 }
 
@@ -469,8 +461,6 @@ bool SHAPERGUI::deactivateModule(SUIT_Study* theStudy)
 
   //myWorkshop->contextMenuMgr()->disconnectViewer();
 
-  SUIT_ResourceMgr* aResMgr = application()->resourceMgr();
-  aResMgr->setValue("Study", "store_positions", myIsStorePositions);
   getApp()->setEditEnabled(myIsEditEnabled);
 
   myOldSelectionColor.clear();
@@ -591,6 +581,11 @@ void SHAPERGUI::onSaveAsDocByShaper()
 void SHAPERGUI::onUpdateCommandStatus()
 {
   getApp()->updateActions();
+
+  LightApp_Application* aApp = dynamic_cast<LightApp_Application*>(application());
+  QtxInfoPanel* aInfoPanel = aApp->infoPanel();
+  if (aInfoPanel->isVisible())
+    updateInfoPanel();
 }
 
 //******************************************************
@@ -1051,6 +1046,16 @@ void SHAPERGUI::updateModuleVisibilityState()
 {
   LightApp_Module::updateModuleVisibilityState();
   onWhatIs(myIsInspectionVisible);
+
+  // the following code is caused by #187 bug.
+  // SALOME saves the dock widget positions before deactivateModule() and
+  // load it after the module activation. So, if the panel is visible before
+  // deactivate, it becomes visible after activate.
+  // In order to avoid the visible property panel, we hide it here
+  ModuleBase_Operation* anOperation = myWorkshop->module()->currentOperation();
+  if (!anOperation) {
+    myWorkshop->hidePanel(myWorkshop->propertyPanel());
+  }
 }
 
 void SHAPERGUI::onEditToolbars()
@@ -1312,3 +1317,90 @@ void SHAPERGUI::publishToStudy()
     getApp()->updatePresentations("SHAPERSTUDY", aVMList);
   }
 }
+
+void SHAPERGUI::fillPartSetInfoPanel(QtxInfoPanel* theInfoPanel)
+{
+  QIntList aShaperActions = shaperActions();
+  theInfoPanel->addLabel(tr("Current mode: Part set mode"));
+
+  addActionsToInfoGroup(theInfoPanel, tr("Parts management"),
+    { "Part", "Duplicate", "Remove" });
+  addActionsToInfoGroup(theInfoPanel, tr("Import operations"),
+    { "OPEN_CMD", "IMPORT_PART_CMD", "IMPORT_SHAPE_CMD" });
+  addActionsToInfoGroup(theInfoPanel, tr("Export operations"),
+    { "SAVEAS_CMD", "EXPORT_PART_CMD", "EXPORT_SHAPE_CMD" });
+  addActionsToInfoGroup(theInfoPanel, tr("Arrangement of parts"),
+    { "Placement", "Translation", "Rotation" });
+}
+
+void SHAPERGUI::fillPartInfoPanel(QtxInfoPanel* theInfoPanel)
+{
+  QIntList aShaperActions = shaperActions();
+  theInfoPanel->addLabel(tr("Current mode: Part mode"));
+
+  addActionsToInfoGroup(theInfoPanel, tr("Primitives"),
+    { "Box", "Cylinder", "Sphere" });
+  addActionsToInfoGroup(theInfoPanel, tr("Geometry"),
+    { "Vertex", "Edge", "Wire", "Face" });
+  addActionsToInfoGroup(theInfoPanel, tr("Features"),
+    { "Extrusion", "Revolution", "Cut", "Fuse", "Fillet" });
+}
+
+void SHAPERGUI::fillSketcherInfoPanel(QtxInfoPanel* theInfoPanel)
+{
+  QIntList aShaperActions = shaperActions();
+  theInfoPanel->addLabel(tr("Current mode: Sketcher mode"));
+
+  addActionsToInfoGroup(theInfoPanel, tr("Primitives"),
+    { "SketchPoint", "SketchLine", "SketchCircle", "SketchRectangle" });
+  addActionsToInfoGroup(theInfoPanel, tr("Dimensions"),
+    { "SketchConstraintLength", "SketchConstraintRadius", "SketchConstraintAngle" });
+  addActionsToInfoGroup(theInfoPanel, tr("Constraints"),
+    { "SketchConstraintParallel", "SketchConstraintPerpendicular",
+    "SketchConstraintEqual", "SketchConstraintCoincidence" });
+}
+
+void SHAPERGUI::addActionsToInfoGroup(QtxInfoPanel* theInfoPanel,
+  const QString& theGroup, const QSet<QString>& theActions)
+{
+  QIntList aShaperActions = shaperActions();
+
+  int aGroup = theInfoPanel->addGroup(theGroup);
+  int aCount = 0;
+  foreach(int aCmd, aShaperActions) {
+    QAction* aAction = action(aCmd);
+    if (theActions.contains(aAction->data().toString()))
+    {
+      theInfoPanel->addAction(aAction, aGroup);
+      aCount++;
+    }
+    if (aCount >= theActions.size())
+      break;
+  }
+}
+
+void SHAPERGUI::updateInfoPanel()
+{
+  LightApp_Application* aApp = dynamic_cast<LightApp_Application*>(application());
+  QtxInfoPanel* aInfoPanel = aApp->infoPanel();
+  aInfoPanel->clear();
+  aInfoPanel->setTitle(tr("Welcome to SHAPER"));
+
+  SessionPtr aMgr = ModelAPI_Session::get();
+  QList<DocumentPtr> aDocs;
+  DocumentPtr aActiveDoc = aMgr->activeDocument();
+  DocumentPtr aModuleDoc = aMgr->moduleDocument();
+
+  XGUI_OperationMgr* aOpMgr = myWorkshop->operationMgr();
+  QStringList aOpList = aOpMgr->operationList();
+  bool isSketcher = false;
+  if (aOpList.size() > 0)
+    isSketcher = (aOpList.first() == "Sketch");
+
+  if (isSketcher) // Sketcher mode
+    fillSketcherInfoPanel(aInfoPanel);
+  else if (aActiveDoc == aModuleDoc) // Part set mode
+    fillPartSetInfoPanel(aInfoPanel);
+  else
+    fillPartInfoPanel(aInfoPanel);
+}