-// Copyright (C) 2014-2019 CEA/DEN, EDF R&D
+// Copyright (C) 2014-2020 CEA/DEN, EDF R&D
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
#include <QMenu>
#include <QToolBar>
+#include <ModelAPI_Session.h>
+
#if OCC_VERSION_HEX < 0x070400
#define SALOME_PATCH_FOR_CTRL_WHEEL
#endif
QString aToolName = tr("Inspection");
int aTool = createTool(aToolName);
- int aToolId = createTool(myWhatIsAction, aTool);
+#ifdef _DEBUG
+ int aToolId =
+#endif
+ createTool(myWhatIsAction, aTool);
registerCommandToolbar(aToolName, aId);
// Define Edit toolbars command
aId = getNextCommandId();
//myActionsList.append(aId); Do not use it for editing of toolbars
aTip = tr("Edit toolbars of the module");
- QAction* aAction = createAction(aId, aTip, QIcon(":pictures/configure_toolbars.png"),
+#ifdef _DEBUG
+ QAction* aAction =
+#endif
+ createAction(aId, aTip, QIcon(":pictures/configure_toolbars.png"),
tr("Edit toolbars..."), aTip, QKeySequence(), aDesk, false, this, SLOT(onEditToolbars()));
int aEditMenu = createMenu(tr("MEN_DESK_EDIT"), -1, -1, 30);
- int aEditItem = createMenu(aId, aEditMenu);
+#ifdef _DEBUG
+ int aEditItem =
+#endif
+ createMenu(aId, aEditMenu);
+
+ if (!myInspectionPanel) {
+ myInspectionPanel = myWorkshop->inspectionPanel();
+ connect(myInspectionPanel->toggleViewAction(), SIGNAL(toggled(bool)),
+ this, SLOT(onWhatIs(bool)));
+ }
+ hideInternalWindows();
// Initialize viewer proxy if OCC viewer is already exist
ViewManagerList aOCCViewManagers;
}
}
}
+ SHAPERGUI_DataModel* aDataModel = dynamic_cast<SHAPERGUI_DataModel*>(dataModel());
+ aDataModel->initRootObject();
}
//******************************************************
//******************************************************
bool SHAPERGUI::activateModule(SUIT_Study* theStudy)
{
- bool isDone = LightApp_Module::activateModule(theStudy);
- loadToolbarsConfig();
+ ModelAPI_Session::get()->moduleDocument(); // initialize a root document if not done yet
+ // this must be done in the initialization and in activation (on the second activation
+ // initialization in not called, so SComponent must be added anyway
SHAPERGUI_DataModel* aDataModel = dynamic_cast<SHAPERGUI_DataModel*>(dataModel());
aDataModel->initRootObject();
+
+ bool isDone = LightApp_Module::activateModule(theStudy);
+ loadToolbarsConfig();
+
if (isDone) {
setMenuShown(true);
setToolShown(true);
aObjDoc->toggleViewAction()->setVisible(true);
}
- if (!myInspectionPanel) {
- myInspectionPanel = myWorkshop->inspectionPanel();
- connect(myInspectionPanel->toggleViewAction(), SIGNAL(toggled(bool)),
- this, SLOT(onWhatIs(bool)));
- }
myInspectionPanel->toggleViewAction()->setVisible(true);
myWorkshop->facesPanel()->toggleViewAction()->setVisible(true);
}
//******************************************************
-bool SHAPERGUI::deactivateModule(SUIT_Study* theStudy)
+void SHAPERGUI::hideInternalWindows()
{
- saveToolbarsConfig();
-
myProxyViewer->activateViewer(false);
setMenuShown(false);
setToolShown(false);
- myWorkshop->deactivateModule();
-
QObject* aObj = myWorkshop->objectBrowser()->parent();
QDockWidget* aObjDoc = dynamic_cast<QDockWidget*>(aObj);
if (aObjDoc) {
aObjDoc->toggleViewAction()->setVisible(false);
}
- myIsInspectionVisible = myInspectionPanel->isVisible();
myInspectionPanel->hide();
myInspectionPanel->toggleViewAction()->setVisible(false);
- myIsFacesPanelVisible = myWorkshop->facesPanel()->isVisible();
myWorkshop->facesPanel()->hide();
myWorkshop->facesPanel()->toggleViewAction()->setVisible(false);
myWorkshop->propertyPanel()->hide();
myWorkshop->propertyPanel()->toggleViewAction()->setVisible(false);
+ myWorkshop->hidePanel(myWorkshop->facesPanel());
+}
+
+
+//******************************************************
+bool SHAPERGUI::deactivateModule(SUIT_Study* theStudy)
+{
+ saveToolbarsConfig();
+ myWorkshop->deactivateModule();
+
+ myIsInspectionVisible = myInspectionPanel->isVisible();
+ myIsFacesPanelVisible = myWorkshop->facesPanel()->isVisible();
+ hideInternalWindows();
+
+
// 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
mySelector = 0;
}
- myWorkshop->hidePanel(myWorkshop->facesPanel());
//myWorkshop->contextMenuMgr()->disconnectViewer();
SUIT_ResourceMgr* aResMgr = application()->resourceMgr();
aAction->setData(theId);
int aWBMenu = createMenu(theWBName, -1, -1, 30/*10-Window, 1000 - Help*/);
- int aItemId = createMenu(aId, aWBMenu);
+#ifdef _DEBUG
+ int aItemId =
+#endif
+ createMenu(aId, aWBMenu);
if (isAddSeparator)
createMenu(separator(), aWBMenu);
int aWBTool = createTool(theTBName, theTBName);
- int aToolId = createTool(aId, aWBTool);
+#ifdef _DEBUG
+ int aToolId =
+#endif
+ createTool(aId, aWBTool);
registerCommandToolbar(theTBName, aId);
if (isAddSeparator) {
createTool(separator(), aWBTool);
createMenu(separator(), aWBMenu); /// nested action is always separated of others
int aWBTool = createTool(theWBName, theWBName);
- int aToolId = createTool(anAction, aWBTool);
+#ifdef _DEBUG
+ int aToolId =
+#endif
+ createTool(anAction, aWBTool);
registerCommandToolbar(theWBName, aItemId);
createTool(separator(), aWBTool); /// nested action is always separated of others
registerCommandToolbar(theWBName, -1);
}
aProp->setValue(aValue);
- if ((theSection == "Visualization") && (theParam == "selection_color")) {
- std::vector<int> aColor = Config_PropManager::color("Visualization", "selection_color");
- myWorkshop->displayer()->setSelectionColor(aColor);
- }
+ if (theSection == "Visualization") {
+ if (theParam == "selection_color") {
+ std::vector<int> aColor = Config_PropManager::color("Visualization", "selection_color");
+ myWorkshop->displayer()->setSelectionColor(aColor);
+ }
+ if ((theParam == "zoom_trihedron_arrows") || (theParam == "axis_arrow_size")) {
+ if (mySelector) {
+ Handle(AIS_Trihedron) aTrihedron = mySelector->viewer()->getTrihedron();
+ if (!aTrihedron.IsNull()) {
+ bool aZoom = Config_PropManager::boolean("Visualization", "zoom_trihedron_arrows");
+ Handle(AIS_InteractiveContext) aContext = mySelector->viewer()->getAISContext();
+
+ ModuleBase_IViewer* aViewer = myWorkshop->viewer();
+ Handle(V3d_View) aView = aViewer->activeView();
+ if (aZoom) {
+ double aAxLen =
+ aView->Convert(Config_PropManager::integer("Visualization", "axis_arrow_size"));
+ Handle(Prs3d_DatumAspect) aDatumAspect = aTrihedron->Attributes()->DatumAspect();
+ double aAxisLen = aDatumAspect->AxisLength(Prs3d_DP_XAxis);
+ myAxisArrowRate = aDatumAspect->Attribute(Prs3d_DP_ShadingConeLengthPercent);
+ aDatumAspect->SetAttribute(Prs3d_DP_ShadingConeLengthPercent, aAxLen / aAxisLen);
+ aTrihedron->Attributes()->SetDatumAspect(aDatumAspect);
+ aContext->Redisplay(aTrihedron, true);
+ }
+ else if (myAxisArrowRate > 0) {
+ Handle(Prs3d_DatumAspect) aDatumAspect = aTrihedron->Attributes()->DatumAspect();
+ aDatumAspect->SetAttribute(Prs3d_DP_ShadingConeLengthPercent, myAxisArrowRate);
+ aContext->Redisplay(aTrihedron, true);
+ }
+ }
+ }
+ }
+ }
myWorkshop->displayer()->redisplayObjects();
}
return;
// Save toolbars configuration into map
QMap<QString, QStringList> aToolbarsConfig;
- QtxActionToolMgr* aMgr = toolMgr();
+#ifdef _DEBUG
+ QtxActionToolMgr* aMgr =
+#endif
+ toolMgr();
QStringList aToolbars = myToolbars.keys();
QIntList aActionsIds;
foreach(QString aName, aToolbars) {
void SHAPERGUI::publishToStudy()
{
- if (isActiveModule())
+ if (isActiveModule() && ModelAPI_Session::get()->hasModuleDocument())
myWorkshop->module()->launchOperation("PublishToStudy", false);
}