-// 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>
-#define SALOME_PATCH_FOR_CTRL_WHEEL
+#include <ModelAPI_Session.h>
+
+#if OCC_VERSION_HEX < 0x070400
+ #define SALOME_PATCH_FOR_CTRL_WHEEL
+#endif
extern "C" {
SHAPERGUI_EXPORT CAM_Module* createModule()
SHAPERGUI::SHAPERGUI()
: LightApp_Module("SHAPER"),
mySelector(0), myIsOpened(0), myPopupMgr(0), myIsInspectionVisible(false),
- myInspectionPanel(0), myIsToolbarsModified(false)
+ myInspectionPanel(0), myIsFacesPanelVisible(false), myIsToolbarsModified(false),
+ myAxisArrowRate(-1)
{
myWorkshop = new XGUI_Workshop(this);
connect(myWorkshop, SIGNAL(commandStatusUpdated()),
}
int aMenu = createMenu(tr("Inspection"), -1, -1, 30);
- int aSubMenu = createMenu(tr("Information"), aMenu);
+ int aSubMenu = createMenu(tr("Information"), aMenu, -1, -1, 0);
int aId = getNextCommandId();
myActionsList.append(aId);
myWhatIsAction->setData("INSPECTION_CMD");
createMenu(aId, aSubMenu, 0);
- QString aToolName = tr("Inspection tool");
+ 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);
QObject* aObj = myWorkshop->objectBrowser()->parent();
QDockWidget* aObjDoc = dynamic_cast<QDockWidget*>(aObj);
if (aObjDoc) {
- QAction* aViewAct = aObjDoc->toggleViewAction();
- aViewAct->setEnabled(true);
myWorkshop->objectBrowser()->setVisible(true);
aObjDoc->setVisible(true);
desktop()->tabifyDockWidget(aObjDoc, myWorkshop->propertyPanel());
+ aObjDoc->toggleViewAction()->setVisible(true);
}
- if (!myInspectionPanel) {
- myInspectionPanel = myWorkshop->inspectionPanel();
- QAction* aViewAct = myInspectionPanel->toggleViewAction();
- connect(aViewAct, SIGNAL(toggled(bool)), this, SLOT(onWhatIs(bool)));
- }
- myInspectionPanel->toggleViewAction()->setEnabled(true);
+ myInspectionPanel->toggleViewAction()->setVisible(true);
+
+ myWorkshop->facesPanel()->toggleViewAction()->setVisible(true);
+ if (myIsFacesPanelVisible)
+ myWorkshop->facesPanel()->show();
+ myWorkshop->propertyPanel()->toggleViewAction()->setVisible(true);
if (!mySelector) {
ViewManagerList OCCViewManagers;
XGUI_Displayer* aDisp = myWorkshop->displayer();
QObjectPtrList aObjList = aDisp->displayedObjects();
+ if (myOldSelectionColor.size() == 0)
+ myOldSelectionColor = aDisp->selectionColor();
+
AIS_ListOfInteractive aList;
aContext->DisplayedObjects(aList);
AIS_ListIteratorOfListOfInteractive aLIt;
}
//******************************************************
-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->setVisible(false);
myWorkshop->objectBrowser()->setVisible(false);
- QAction* aViewAct = aObjDoc->toggleViewAction();
- aViewAct->setEnabled(false);
+ aObjDoc->toggleViewAction()->setVisible(false);
}
- myIsInspectionVisible = myInspectionPanel->isVisible();
myInspectionPanel->hide();
- QAction* aViewAct = myInspectionPanel->toggleViewAction();
- aViewAct->setEnabled(false);
+ myInspectionPanel->toggleViewAction()->setVisible(false);
+
+ 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.
}
// Delete selector because it has to be redefined on next activation
if (mySelector) {
+ // Restore size of arrows of trihedron
+ if (myAxisArrowRate > 0) {
+ Handle(AIS_Trihedron) aTrihedron = mySelector->viewer()->getTrihedron();
+ Handle(Prs3d_DatumAspect) aDatumAspect = aTrihedron->Attributes()->DatumAspect();
+ aDatumAspect->SetAttribute(Prs3d_DP_ShadingConeLengthPercent, myAxisArrowRate);
+ Handle(AIS_InteractiveContext) aContext = mySelector->viewer()->getAISContext();
+ aContext->Redisplay(aTrihedron, false);
+ }
+ myWorkshop->displayer()->setSelectionColor(myOldSelectionColor);
myProxyViewer->setSelector(0);
+
+ LightApp_SelectionMgr* aMgr = getApp()->selectionMgr();
+ QList<SUIT_Selector*> aList;
+ aMgr->selectors(aList);
+ foreach(SUIT_Selector* aSel, aList) {
+ aSel->setEnabled(aSel != mySelector);
+ }
+
delete mySelector;
mySelector = 0;
}
- myWorkshop->hidePanel(myWorkshop->facesPanel());
//myWorkshop->contextMenuMgr()->disconnectViewer();
SUIT_ResourceMgr* aResMgr = application()->resourceMgr();
aResMgr->setValue("Study", "store_positions", myIsStorePositions);
getApp()->setEditEnabled(myIsEditEnabled);
+ myOldSelectionColor.clear();
+
// Post-processing for LoadScriptId to remove created(if it was created) SALOME Object Browser
disconnect(getApp()->action(LightApp_Application::UserID+1), SIGNAL(triggered(bool)),
this, SLOT(onScriptLoaded()));
connect(getApp()->action(LightApp_Application::FileSaveAsId), SIGNAL(triggered(bool)),
getApp(), SLOT(onSaveAsDoc()));
+ publishToStudy();
+
return LightApp_Module::deactivateModule(theStudy);
}
SUIT_DataBrowser* aBrowser = getApp()->objectBrowser();
if (aBrowser)
delete aBrowser;
+ myWorkshop->displayer()->updateViewer();
+ myWorkshop->updateCommandStatus();
}
//******************************************************
{
if (theMgr->getType() == OCCViewer_Viewer::Type()) {
OCCViewer_Viewer* aViewer = static_cast<OCCViewer_Viewer*>(theMgr->getViewModel());
+
+ // Remember current length of arrow of axis
+ Handle(AIS_Trihedron) aTrihedron = aViewer->getTrihedron();
+ Handle(Prs3d_DatumAspect) aDatumAspect = aTrihedron->Attributes()->DatumAspect();
+ myAxisArrowRate = aDatumAspect->Attribute(Prs3d_DP_ShadingConeLengthPercent);
+
SHAPERGUI_OCCSelector* aSelector = new SHAPERGUI_OCCSelector(aViewer,
getApp()->selectionMgr());
#ifdef SALOME_PATCH_FOR_CTRL_WHEEL
aSel->setEnabled(aSel == aSelector);
}
myProxyViewer->setSelector(aSelector);
+
+ if (myOldSelectionColor.size() == 0)
+ myOldSelectionColor = myWorkshop->displayer()->selectionColor();
+
+ std::vector<int> aColor = Config_PropManager::color("Visualization", "selection_color");
+ myWorkshop->displayer()->setSelectionColor(aColor);
+
+ // Cause scaling of arrows of axis and dimensions
+ myWorkshop->module()->onViewTransformed();
+
return aSelector;
}
return 0;
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);
QAction* SHAPERGUI::addDesktopCommand(const QString& theId, const QString& theTitle,
const QString& theTip, const QIcon& theIcon,
const QKeySequence& theKeys, bool isCheckable,
- const char* theMenuSourceText, const int theMenuPosition)
+ const char* theMenuSourceText,
+ const QString& theSubMenu,
+ const int theMenuPosition,
+ const int theSuibMenuPosition)
{
int aMenu = createMenu(tr(theMenuSourceText), -1, -1);
+ if (!theSubMenu.isNull())
+ aMenu = createMenu(theSubMenu, aMenu, -1, theSuibMenuPosition);
int aId = getNextCommandId();
myActionsList.append(aId);
}
aProp->setValue(aValue);
+ 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) {
SUIT_ResourceMgr* aResMgr = application()->resourceMgr();
aResMgr->remove(ToolbarsSection);
}
+
+void SHAPERGUI::publishToStudy()
+{
+ if (isActiveModule() && ModelAPI_Session::get()->hasModuleDocument())
+ myWorkshop->module()->launchOperation("PublishToStudy", false);
+}