From e6495a16c0493c3c63fcfb422aa0fed74a1c610a Mon Sep 17 00:00:00 2001 From: vsv Date: Tue, 31 May 2022 15:01:35 +0300 Subject: [PATCH 1/1] bos #29098: Help panel for SHAPER module --- src/SHAPERGUI/SHAPERGUI.cpp | 96 ++++++++++++++++++++++++- src/SHAPERGUI/SHAPERGUI.h | 14 ++++ src/SHAPERGUI/SHAPERGUI_msg_fr.ts | 54 +++++++++++++- src/SHAPERGUI/resources/LightApp.xml.in | 4 +- 4 files changed, 164 insertions(+), 4 deletions(-) diff --git a/src/SHAPERGUI/SHAPERGUI.cpp b/src/SHAPERGUI/SHAPERGUI.cpp index f8416f993..e8850f627 100644 --- a/src/SHAPERGUI/SHAPERGUI.cpp +++ b/src/SHAPERGUI/SHAPERGUI.cpp @@ -61,6 +61,7 @@ #include #include #include +#include #include #include @@ -243,6 +244,7 @@ void SHAPERGUI::initialize(CAM_Application* theApp) void SHAPERGUI::windows(QMap& theWndMap) const { theWndMap.insert(LightApp_Application::WT_PyConsole, Qt::BottomDockWidgetArea); + theWndMap.insert(LightApp_Application::WT_InfoPanel, Qt::RightDockWidgetArea); } //****************************************************** @@ -390,7 +392,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; } @@ -591,6 +593,11 @@ void SHAPERGUI::onSaveAsDocByShaper() void SHAPERGUI::onUpdateCommandStatus() { getApp()->updateActions(); + + LightApp_Application* aApp = dynamic_cast(application()); + QtxInfoPanel* aInfoPanel = aApp->infoPanel(); + if (aInfoPanel->isVisible()) + updateInfoPanel(); } //****************************************************** @@ -1312,3 +1319,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& 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(application()); + QtxInfoPanel* aInfoPanel = aApp->infoPanel(); + aInfoPanel->clear(); + aInfoPanel->setTitle(tr("Welcome to SHAPER")); + + SessionPtr aMgr = ModelAPI_Session::get(); + QList 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); +} diff --git a/src/SHAPERGUI/SHAPERGUI.h b/src/SHAPERGUI/SHAPERGUI.h index c0dfcc411..1135d894e 100644 --- a/src/SHAPERGUI/SHAPERGUI.h +++ b/src/SHAPERGUI/SHAPERGUI.h @@ -35,6 +35,7 @@ class XGUI_Workshop; class SHAPERGUI_OCCSelector; class OCCViewer_Viewer; class CAM_Study; +class QtxInfoPanel; /** * \ingroup Salome @@ -173,6 +174,8 @@ Q_OBJECT void publishToStudy(); + virtual void updateInfoPanel(); + public slots: /// \brief The method is redefined to connect to the study viewer before the data /// model is filled by opened file. This file open will flush redisplay signals for, @@ -241,6 +244,17 @@ private slots: void saveToolbarsConfig(); void loadToolbarsConfig(); + //! Fill Info Panel in Part set mode + void fillPartSetInfoPanel(QtxInfoPanel* theInfoPanel); + + //! Fill Info Panel in Part mode + void fillPartInfoPanel(QtxInfoPanel* theInfoPanel); + + //! Fill Info Panel in Sketcher mode + void fillSketcherInfoPanel(QtxInfoPanel* theInfoPanel); + + //! Fill Info Panel in Sketcher mode + void addActionsToInfoGroup(QtxInfoPanel* theInfoPanel, const QString& theGroup, const QSet& theActions); void hideInternalWindows(); diff --git a/src/SHAPERGUI/SHAPERGUI_msg_fr.ts b/src/SHAPERGUI/SHAPERGUI_msg_fr.ts index efbcf21d7..42362b6bf 100644 --- a/src/SHAPERGUI/SHAPERGUI_msg_fr.ts +++ b/src/SHAPERGUI/SHAPERGUI_msg_fr.ts @@ -9,7 +9,7 @@ Information - Information + Information Show inspection window @@ -107,6 +107,58 @@ MEN_DESK_EDIT MEN_DESK_EDIT + + Parts management + Gestion des pièces + + + Import operations + Opérations d'importation + + + Export operations + Opérations d'exportation + + + Arrangement of parts + Disposition des pièces + + + Primitives + Primitives + + + Geometry + Géométrie + + + Features + Fonctionnalités + + + Dimensions + Dimensions + + + Constraints + Contraintes + + + Welcome to SHAPER + Bienvenue à SHAPER + + + Current mode: Part set mode + Mode actuel : Mode de réglage des pièces + + + Current mode: Part mode + Mode actuel : Mode partiel + + + Current mode: Sketcher mode + Mode actuel : Mode esquisseur + Group names display Affichage des noms de groupe diff --git a/src/SHAPERGUI/resources/LightApp.xml.in b/src/SHAPERGUI/resources/LightApp.xml.in index 35347b0a7..7081ad8bb 100644 --- a/src/SHAPERGUI/resources/LightApp.xml.in +++ b/src/SHAPERGUI/resources/LightApp.xml.in @@ -58,9 +58,9 @@
- +
- +
-- 2.39.2