X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FSHAPERGUI%2FSHAPERGUI.cpp;h=0cd96374cdeb1a27184df9232c583c408c1a5c22;hb=50a8df0c6a66da8067b16155e5ae39f8f26a7ebc;hp=2ff3a28874415bd6772648bd2e833123fcd47a71;hpb=315f1e7ebc1a5f3120774a5b926a126aa9293825;p=modules%2Fshaper.git diff --git a/src/SHAPERGUI/SHAPERGUI.cpp b/src/SHAPERGUI/SHAPERGUI.cpp index 2ff3a2887..0cd96374c 100644 --- a/src/SHAPERGUI/SHAPERGUI.cpp +++ b/src/SHAPERGUI/SHAPERGUI.cpp @@ -1,4 +1,4 @@ -// 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 @@ -40,6 +40,8 @@ #include #include +#include + #include #include #include @@ -72,7 +74,9 @@ #include #include -#define SALOME_PATCH_FOR_CTRL_WHEEL +#if OCC_VERSION_HEX < 0x070400 + #define SALOME_PATCH_FOR_CTRL_WHEEL +#endif extern "C" { SHAPERGUI_EXPORT CAM_Module* createModule() @@ -132,7 +136,7 @@ private: SHAPERGUI::SHAPERGUI() : LightApp_Module("SHAPER"), mySelector(0), myIsOpened(0), myPopupMgr(0), myIsInspectionVisible(false), - myInspectionPanel(0), myIsToolbarsModified(false) + myInspectionPanel(0), myIsFacesPanelVisible(false), myIsToolbarsModified(false) { myWorkshop = new XGUI_Workshop(this); connect(myWorkshop, SIGNAL(commandStatusUpdated()), @@ -166,7 +170,7 @@ void SHAPERGUI::initialize(CAM_Application* theApp) } 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); @@ -178,7 +182,7 @@ void SHAPERGUI::initialize(CAM_Application* theApp) 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); registerCommandToolbar(aToolName, aId); @@ -265,25 +269,29 @@ bool SHAPERGUI::activateModule(SUIT_Study* theStudy) QObject* aObj = myWorkshop->objectBrowser()->parent(); QDockWidget* aObjDoc = dynamic_cast(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))); + connect(myInspectionPanel->toggleViewAction(), 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; application()->viewManagers(OCCViewer_Viewer::Type(), OCCViewManagers); if (OCCViewManagers.size() > 0) { - mySelector = createSelector(OCCViewManagers.first()); + onViewManagerAdded(OCCViewManagers.first()); } } // it should be performed after the selector creation in order to have AISContext @@ -320,6 +328,14 @@ bool SHAPERGUI::activateModule(SUIT_Study* theStudy) XGUI_Displayer* aDisp = myWorkshop->displayer(); QObjectPtrList aObjList = aDisp->displayedObjects(); + //if (myHighlightPointAspect.IsNull()) { + // Handle(AIS_Trihedron) aTrihedron = mySelector->viewer()->getTrihedron(); + // myHighlightPointAspect = + // new Graphic3d_AspectMarker3d(aTrihedron->getHighlightPointAspect()->Aspect().operator*()); + //} + if (myOldSelectionColor.size() == 0) + myOldSelectionColor = aDisp->selectionColor(); + AIS_ListOfInteractive aList; aContext->DisplayedObjects(aList); AIS_ListIteratorOfListOfInteractive aLIt; @@ -377,14 +393,19 @@ bool SHAPERGUI::deactivateModule(SUIT_Study* theStudy) 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); + + myIsFacesPanelVisible = myWorkshop->facesPanel()->isVisible(); + myWorkshop->facesPanel()->hide(); + myWorkshop->facesPanel()->toggleViewAction()->setVisible(false); + + myWorkshop->propertyPanel()->hide(); + myWorkshop->propertyPanel()->toggleViewAction()->setVisible(false); // the active operation should be stopped for the next activation. // There should not be active operation and visualized preview. @@ -398,7 +419,21 @@ bool SHAPERGUI::deactivateModule(SUIT_Study* theStudy) } // Delete selector because it has to be redefined on next activation if (mySelector) { + //if (!myHighlightPointAspect.IsNull()) { + // Handle(AIS_Trihedron) aTrihedron = mySelector->viewer()->getTrihedron(); + // aTrihedron->getHighlightPointAspect()->SetAspect(myHighlightPointAspect); + // myHighlightPointAspect.Nullify(); + //} + myWorkshop->displayer()->setSelectionColor(myOldSelectionColor); myProxyViewer->setSelector(0); + + LightApp_SelectionMgr* aMgr = getApp()->selectionMgr(); + QList aList; + aMgr->selectors(aList); + foreach(SUIT_Selector* aSel, aList) { + aSel->setEnabled(aSel != mySelector); + } + delete mySelector; mySelector = 0; } @@ -410,6 +445,8 @@ bool SHAPERGUI::deactivateModule(SUIT_Study* theStudy) 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())); @@ -424,6 +461,8 @@ bool SHAPERGUI::deactivateModule(SUIT_Study* theStudy) connect(getApp()->action(LightApp_Application::FileSaveAsId), SIGNAL(triggered(bool)), getApp(), SLOT(onSaveAsDoc())); + publishToStudy(); + return LightApp_Module::deactivateModule(theStudy); } @@ -447,8 +486,16 @@ void SHAPERGUI::onViewManagerRemoved(SUIT_ViewManager* theMgr) if (mySelector->viewer() == aViewer) { XGUI_Displayer* aDisp = myWorkshop->displayer(); QObjectPtrList aObjects = aDisp->displayedObjects(); - foreach(ObjectPtr aObj, aObjects) + ResultPtr aRes; + foreach(ObjectPtr aObj, aObjects) { aObj->setDisplayed(false); + aRes = std::dynamic_pointer_cast(aObj); + if (aRes.get()) { + while (aRes = ModelAPI_Tools::bodyOwner(aRes)) { + aRes->setDisplayed(false); + } + } + } Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY)); myProxyViewer->setSelector(0); delete mySelector; @@ -490,6 +537,8 @@ void SHAPERGUI::onScriptLoaded() SUIT_DataBrowser* aBrowser = getApp()->objectBrowser(); if (aBrowser) delete aBrowser; + myWorkshop->displayer()->updateViewer(); + myWorkshop->updateCommandStatus(); } //****************************************************** @@ -521,6 +570,12 @@ SHAPERGUI_OCCSelector* SHAPERGUI::createSelector(SUIT_ViewManager* theMgr) { if (theMgr->getType() == OCCViewer_Viewer::Type()) { OCCViewer_Viewer* aViewer = static_cast(theMgr->getViewModel()); + + //if (myHighlightPointAspect.IsNull()) { + // Handle(AIS_Trihedron) aTrihedron = aViewer->getTrihedron(); + // myHighlightPointAspect = + // new Graphic3d_AspectMarker3d(aTrihedron->getHighlightPointAspect()->Aspect().operator*()); + //} SHAPERGUI_OCCSelector* aSelector = new SHAPERGUI_OCCSelector(aViewer, getApp()->selectionMgr()); #ifdef SALOME_PATCH_FOR_CTRL_WHEEL @@ -534,6 +589,12 @@ SHAPERGUI_OCCSelector* SHAPERGUI::createSelector(SUIT_ViewManager* theMgr) aSel->setEnabled(aSel == aSelector); } myProxyViewer->setSelector(aSelector); + + if (myOldSelectionColor.size() == 0) + myOldSelectionColor = myWorkshop->displayer()->selectionColor(); + + std::vector aColor = Config_PropManager::color("Visualization", "selection_color"); + myWorkshop->displayer()->setSelectionColor(aColor); return aSelector; } return 0; @@ -649,9 +710,14 @@ QAction* SHAPERGUI::addFeatureOfNested(const QString& theWBName, 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); @@ -846,6 +912,11 @@ void SHAPERGUI::preferencesChanged(const QString& theSection, const QString& the } aProp->setValue(aValue); + if ((theSection == "Visualization") && (theParam == "selection_color")) { + std::vector aColor = Config_PropManager::color("Visualization", "selection_color"); + myWorkshop->displayer()->setSelectionColor(aColor); + } + myWorkshop->displayer()->redisplayObjects(); } @@ -1131,3 +1202,9 @@ void SHAPERGUI::resetToolbars() SUIT_ResourceMgr* aResMgr = application()->resourceMgr(); aResMgr->remove(ToolbarsSection); } + +void SHAPERGUI::publishToStudy() +{ + if (isActiveModule()) + myWorkshop->module()->launchOperation("PublishToStudy", false); +}