-// Copyright (C) 2014-2021 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
#include <QtxActionMenuMgr.h>
#include <QtxActionToolMgr.h>
#include <QtxResourceMgr.h>
+#include <QtxInfoPanel.h>
#include <Config_PropManager.h>
#include <Config_ModuleReader.h>
#include <QToolBar>
#include <ModelAPI_Session.h>
+#include <Events_MessageBool.h>
#if OCC_VERSION_HEX < 0x070400
#define SALOME_PATCH_FOR_CTRL_WHEEL
static const QString FreeCommandsParam("OutOFToolbars");
-/**
+/**
* Class for preferences management
*/
class SHAPERGUI_PrefMgr: public ModuleBase_IPrefMgr
void SHAPERGUI::windows(QMap<int, int>& theWndMap) const
{
theWndMap.insert(LightApp_Application::WT_PyConsole, Qt::BottomDockWidgetArea);
+ theWndMap.insert(LightApp_Application::WT_InfoPanel, Qt::RightDockWidgetArea);
}
//******************************************************
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())
this, SLOT(onSaveDocByShaper()));
connect(getApp()->action(LightApp_Application::FileSaveAsId), SIGNAL(triggered(bool)),
this, SLOT(onSaveAsDocByShaper()));
+ updateInfoPanel();
+
+ //connect(myWorkshop->operationMgr(), SIGNAL(operationResumed(ModuleBase_Operation*)),
+ // this, SLOT(onOperationResumed(ModuleBase_Operation*)));
+ //connect(myWorkshop->operationMgr(), SIGNAL(operationStopped(ModuleBase_Operation*)),
+ // this, SLOT(onOperationStopped(ModuleBase_Operation*)));
+ connect(myWorkshop->operationMgr(), SIGNAL(operationCommitted(ModuleBase_Operation*)),
+ this, SLOT(onOperationCommitted(ModuleBase_Operation*)));
+ connect(myWorkshop->operationMgr(), SIGNAL(operationAborted(ModuleBase_Operation*)),
+ this, SLOT(onOperationAborted(ModuleBase_Operation*)));
return isDone;
}
//myWorkshop->contextMenuMgr()->disconnectViewer();
- SUIT_ResourceMgr* aResMgr = application()->resourceMgr();
- aResMgr->setValue("Study", "store_positions", myIsStorePositions);
getApp()->setEditEnabled(myIsEditEnabled);
myOldSelectionColor.clear();
return LightApp_Module::deactivateModule(theStudy);
}
+//******************************************************
+void SHAPERGUI::logShaperGUIEvent()
+{
+ QAction* anAction = static_cast<QAction*>(sender());
+ if ( !anAction )
+ return;
+ const QString anId = anAction->data().toString();
+ const QString section = anId.contains("Sketch") ? "sketcher" : "";
+
+ CAM_Application::logStructuredUserEvent( moduleName(),
+ section,
+ anAction->text(),
+ "activated" );
+}
+
+//******************************************************
+static void onOperationGeneric( ModuleBase_Operation* theOperation,
+ const QString moduleName,
+ const QString &event )
+{
+ QString anId = theOperation->id();
+ QString section = "";
+
+ if (anId.contains("Sketch"))
+ {
+ section = "sketcher";
+ anId.remove("Sketch");
+ }
+
+ CAM_Application::logStructuredUserEvent( moduleName,
+ section,
+ anId,
+ event );
+}
+
+//******************************************************
+void SHAPERGUI::onOperationCommitted(ModuleBase_Operation* theOperation)
+{
+ onOperationGeneric(theOperation, moduleName(), "committed");
+}
+
+//******************************************************
+void SHAPERGUI::onOperationAborted(ModuleBase_Operation* theOperation)
+{
+ onOperationGeneric(theOperation, moduleName(), "aborted");
+}
+
//******************************************************
void SHAPERGUI::onViewManagerAdded(SUIT_ViewManager* theMgr)
{
void SHAPERGUI::onUpdateCommandStatus()
{
getApp()->updateActions();
+
+ LightApp_Application* aApp = dynamic_cast<LightApp_Application*>(application());
+ QtxInfoPanel* aInfoPanel = aApp->infoPanel();
+ if (aInfoPanel->isVisible())
+ updateInfoPanel();
}
//******************************************************
aAction->setData(theId);
int aWBMenu = createMenu(theWBName, -1, -1, 30/*10-Window, 1000 - Help*/);
-#ifdef _DEBUG
- int aItemId =
-#endif
if( theId == "PointCoordinates" )
createMenu(separator(), aWBMenu);
- createMenu(aId, aWBMenu);
+#ifdef _DEBUG
+ int aItemId =
+#endif
+ createMenu(aId, aWBMenu);
if (isAddSeparator)
createMenu(separator(), aWBMenu);
createTool(separator(), aWBTool);
registerCommandToolbar(theTBName, -1);
}
+ connect(aAction, SIGNAL(triggered(bool)), this, SLOT(logShaperGUIEvent()));
return aAction;
}
createTool(separator(), aWBTool); /// nested action is always separated of others
registerCommandToolbar(theWBName, -1);
+ connect(anAction, SIGNAL(triggered(bool)), this, SLOT(logShaperGUIEvent()));
+
return anAction;
}
aAction->setStatusTip(theTip);
aAction->setData(theId);
createMenu(aId, aMenu, theMenuPosition);
+
+ connect(aAction, SIGNAL(triggered(bool)), this, SLOT(logShaperGUIEvent()));
+
return aAction;
}
//******************************************************
void SHAPERGUI::createPreferences()
{
- LightApp_Preferences* pref = preferences();
- if (!pref)
+ LightApp_Preferences* aPref = preferences();
+ if (!aPref)
return;
ModuleBase_Preferences::updateConfigByResources();
QString aModName = moduleName();
- QtxPreferenceItem* item = pref->findItem(aModName, true );
+ QtxPreferenceItem* item = aPref->findItem(aModName, true );
if ( item && (!item->isEmpty() )) {
item->parentItem()->removeItem(item);
delete item;
}
- int catId = pref->addPreference(aModName, -1 );
+ int catId = aPref->addPreference(aModName, -1 );
if ( catId == -1 )
return;
- SHAPERGUI_PrefMgr aMgr(pref, aModName);
+ SHAPERGUI_PrefMgr aMgr(aPref, aModName);
ModuleBase_Preferences::createEditContent(&aMgr, catId);
- int viewTab = pref->addItem(tr("Viewer"), catId);
+ int viewTab = aPref->addItem(tr("Viewer"), catId);
// Create other parameters group in viewer tab
- int otherGroup = pref->addItem(tr("Default selection"), viewTab);
- pref->setItemProperty("columns", 3, otherGroup);
- pref->addItem(tr("Faces"), otherGroup,
+ int otherGroup = aPref->addItem(tr("Default selection"), viewTab);
+ aPref->setItemProperty("columns", 3, otherGroup);
+ aPref->addItem(tr("Faces"), otherGroup,
SUIT_PreferenceMgr::Bool,
ModuleBase_Preferences::VIEWER_SECTION, "face-selection");
- pref->addItem(tr("Edges"), otherGroup,
+ aPref->addItem(tr("Edges"), otherGroup,
SUIT_PreferenceMgr::Bool,
ModuleBase_Preferences::VIEWER_SECTION, "edge-selection");
- pref->addItem(tr("Vertices"), otherGroup,
+ aPref->addItem(tr("Vertices"), otherGroup,
SUIT_PreferenceMgr::Bool,
ModuleBase_Preferences::VIEWER_SECTION, "vertex-selection");
- int sensitivityGroup = pref->addItem(tr("Selection sensitivity"), viewTab);
- pref->setItemProperty("columns", 2, sensitivityGroup);
- pref->addItem(tr("Vertex"), sensitivityGroup, SUIT_PreferenceMgr::DblSpin,
+ int sensitivityGroup = aPref->addItem(tr("Selection sensitivity"), viewTab);
+ aPref->setItemProperty("columns", 2, sensitivityGroup);
+ aPref->addItem(tr("Vertex"), sensitivityGroup, SUIT_PreferenceMgr::DblSpin,
ModuleBase_Preferences::VIEWER_SECTION, "point-selection-sensitivity");
- pref->addItem(tr("Edge"), sensitivityGroup, SUIT_PreferenceMgr::DblSpin,
+ aPref->addItem(tr("Edge"), sensitivityGroup, SUIT_PreferenceMgr::DblSpin,
ModuleBase_Preferences::VIEWER_SECTION, "edge-selection-sensitivity");
- int highlightGroup = pref->addItem(tr("Additional highlighting"), viewTab);
- pref->setItemProperty("columns", 2, highlightGroup);
- pref->addItem(tr("In 3d mode"), highlightGroup,
+ int highlightGroup = aPref->addItem(tr("Additional highlighting"), viewTab);
+ aPref->setItemProperty("columns", 2, highlightGroup);
+ aPref->addItem(tr("In 3d mode"), highlightGroup,
SUIT_PreferenceMgr::Bool, ModuleBase_Preferences::VIEWER_SECTION, "highlighting-3d");
- pref->addItem(tr("In 2d mode"), highlightGroup,
+ aPref->addItem(tr("In 2d mode"), highlightGroup,
SUIT_PreferenceMgr::Bool, ModuleBase_Preferences::VIEWER_SECTION, "highlighting-2d");
- int colorScaleGroup = pref->addItem(tr("Color scale"), viewTab);
- pref->setItemProperty("columns", 4, colorScaleGroup);
+ int colorScaleGroup = aPref->addItem(tr("Color scale"), viewTab);
+ aPref->setItemProperty("columns", 4, colorScaleGroup);
int aItem = aMgr.addPreference(tr("X position"), colorScaleGroup,
SUIT_PreferenceMgr::Double, ModuleBase_Preferences::VIEWER_SECTION, "scalar_bar_x_position");
- pref->setItemProperty("min", 0, aItem);
- pref->setItemProperty("max", 1, aItem);
-
+ aPref->setItemProperty("min", 0, aItem);
+ aPref->setItemProperty("max", 1, aItem);
aItem = aMgr.addPreference(tr("Y position"), colorScaleGroup,
SUIT_PreferenceMgr::Double, ModuleBase_Preferences::VIEWER_SECTION, "scalar_bar_y_position");
- pref->setItemProperty("min", 0, aItem);
- pref->setItemProperty("max", 1, aItem);
-
+ aPref->setItemProperty("min", 0, aItem);
+ aPref->setItemProperty("max", 1, aItem);
aItem = aMgr.addPreference(tr("Width"), colorScaleGroup,
SUIT_PreferenceMgr::Double, ModuleBase_Preferences::VIEWER_SECTION, "scalar_bar_width");
- pref->setItemProperty("min", 0, aItem);
- pref->setItemProperty("max", 1, aItem);
-
+ aPref->setItemProperty("min", 0, aItem);
+ aPref->setItemProperty("max", 1, aItem);
aItem = aMgr.addPreference(tr("Height"), colorScaleGroup,
SUIT_PreferenceMgr::Double, ModuleBase_Preferences::VIEWER_SECTION, "scalar_bar_height");
- pref->setItemProperty("min", 0, aItem);
- pref->setItemProperty("max", 1, aItem);
-
+ aPref->setItemProperty("min", 0, aItem);
+ aPref->setItemProperty("max", 1, aItem);
aItem = aMgr.addPreference(tr("Intervals number"), colorScaleGroup,
SUIT_PreferenceMgr::Integer, ModuleBase_Preferences::VIEWER_SECTION, "scalar_bar_nb_intervals");
- pref->setItemProperty("min", 0, aItem);
- pref->setItemProperty("max", 100, aItem);
-
+ aPref->setItemProperty("min", 0, aItem);
+ aPref->setItemProperty("max", 100, aItem);
aItem = aMgr.addPreference(tr("Text height"), colorScaleGroup,
SUIT_PreferenceMgr::Integer, ModuleBase_Preferences::VIEWER_SECTION, "scalar_bar_text_height");
- pref->setItemProperty("min", 0, aItem);
- pref->setItemProperty("max", 100, aItem);
-
+ aPref->setItemProperty("min", 0, aItem);
+ aPref->setItemProperty("max", 100, aItem);
aItem = aMgr.addPreference(tr("Text color"), colorScaleGroup,
SUIT_PreferenceMgr::Color, ModuleBase_Preferences::VIEWER_SECTION, "scalar_bar_text_color");
- pref->retrieve();
+ int aGroupNamesGroup = aMgr.addPreference(tr("Group names display"), viewTab,
+ SUIT_PreferenceMgr::GroupBox , ModuleBase_Preferences::VIEWER_SECTION, "group_names_display");
+ aPref->setItemProperty("columns", 3, aGroupNamesGroup);
+ aMgr.addPreference(tr("Text font"), aGroupNamesGroup,
+ SUIT_PreferenceMgr::String, ModuleBase_Preferences::VIEWER_SECTION, "group_names_font");
+ aItem = aMgr.addPreference(tr("Text size"), aGroupNamesGroup,
+ SUIT_PreferenceMgr::Integer, ModuleBase_Preferences::VIEWER_SECTION, "group_names_size");
+ aPref->setItemProperty("min", 8, aItem);
+ aPref->setItemProperty("max", 100, aItem);
+ aItem = aMgr.addPreference(tr("Text color"), aGroupNamesGroup,
+ SUIT_PreferenceMgr::Color, ModuleBase_Preferences::VIEWER_SECTION, "group_names_color");
+
+ aPref->retrieve();
}
//******************************************************
QString aVal = aResMgr->stringValue(theSection, theParam);
Config_Prop* aProp = Config_PropManager::findProp(theSection.toStdString(),
theParam.toStdString());
+ if (!aProp)
+ return; // invalid case, the property default value must be registered in XML file
std::string aValue = aVal.toStdString();
if (aValue.empty()) {
aValue = aProp->defaultValue();
aResMgr->setValue(theSection, theParam, QString(aValue.c_str()));
- LightApp_Preferences* pref = preferences();
- if (pref)
- pref->retrieve();
+ LightApp_Preferences* aPref = preferences();
+ if (aPref)
+ aPref->retrieve();
}
aProp->setValue(aValue);
}
}
}
+ else if (theSection == ModuleBase_Preferences::GENERAL_SECTION && theParam == "create_init_part") {
+ bool aCreate = ModuleBase_Preferences::resourceMgr()->booleanValue(
+ ModuleBase_Preferences::GENERAL_SECTION, "create_init_part", true);
+ Events_MessageBool aCreateMsg(Events_Loop::eventByName(EVENT_CREATE_PART_ON_START), aCreate);
+ aCreateMsg.send();
+ }
+ else if (theSection == ModuleBase_Preferences::VIEWER_SECTION &&
+ theParam.startsWith("group_names_"))
+ { // one of the group names parameter changed, so, update the groups names vizualization
+ myWorkshop->updateGroupsText();
+ myWorkshop->displayer()->updateViewer();
+ }
myWorkshop->displayer()->redisplayObjects();
}
{
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()
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);
+}