X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FSHAPERGUI%2FSHAPERGUI.cpp;h=5b69d3593ffb8e02830a296173cbdf0abf0185bb;hb=97c06c5cd9fc736f9b5a1dacde369a9d7b5be703;hp=48b1ed4253e0d83bd804ce779f4da82b9fd035f0;hpb=437800222d180c99595cf3d01ad36de3d781e765;p=modules%2Fshaper.git diff --git a/src/SHAPERGUI/SHAPERGUI.cpp b/src/SHAPERGUI/SHAPERGUI.cpp index 48b1ed425..5b69d3593 100644 --- a/src/SHAPERGUI/SHAPERGUI.cpp +++ b/src/SHAPERGUI/SHAPERGUI.cpp @@ -1,4 +1,4 @@ -// Copyright (C) 2014-2017 CEA/DEN, EDF R&D +// Copyright (C) 2014-2019 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 @@ -12,10 +12,9 @@ // // You should have received a copy of the GNU Lesser General Public // License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or -// email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // #include "SHAPERGUI.h" @@ -34,21 +33,27 @@ #include #include #include +#include #include #include #include #include +#include + #include #include #include #include + #include +#include #include #include #include +#include #include #include @@ -138,7 +143,9 @@ SHAPERGUI::SHAPERGUI() myProxyViewer = new SHAPERGUI_SalomeViewer(this); ModuleBase_Preferences::setResourceMgr(application()->resourceMgr()); - ModuleBase_Preferences::loadCustomProps(); + + // It will be called in XGUI_Workshop::startApplication + // ModuleBase_Preferences::loadCustomProps(); } //****************************************************** @@ -186,6 +193,26 @@ void SHAPERGUI::initialize(CAM_Application* theApp) 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); + + // Initialize viewer proxy if OCC viewer is already exist + ViewManagerList aOCCViewManagers; + application()->viewManagers(OCCViewer_Viewer::Type(), aOCCViewManagers); + if (aOCCViewManagers.size() > 0) { + SUIT_ViewManager* aMgr = aOCCViewManagers.first(); + SUIT_ViewWindow* aWnd = aMgr->getActiveView(); + if (aWnd) { + OCCViewer_ViewWindow* aOccWnd = static_cast(aWnd); + OCCViewer_ViewPort3d* aViewPort = aOccWnd->getViewPort(); + if (aViewPort) { + XGUI_ViewerProxy* aViewer = myWorkshop->viewer(); + aViewPort->installEventFilter(aViewer); + Handle(V3d_View) aView = aViewPort->getView(); + aViewer->SetScale(aView, aView->Camera()->Scale()); + // We can not create selector here because other modules will be deactivated later + //onViewManagerAdded(aMgr); + } + } + } } //****************************************************** @@ -207,7 +234,7 @@ void SHAPERGUI::viewManagers(QStringList& theList) const //void SHAPERGUI::connectToStudy(CAM_Study* theStudy) //{ // // if there are created viewer managers, we should try to create viewer -// // selector and initialize viewer with it. It sets interactive contect to the +// // selector and initialize viewer with it. It sets interactive context to the // // proxy viewer. If study is opened, CAM application calls this method before the open() // // of data model // // the SHAPER data model is specific and during open(load) redisplay signals are flushed, so @@ -258,10 +285,10 @@ bool SHAPERGUI::activateModule(SUIT_Study* theStudy) ViewManagerList OCCViewManagers; application()->viewManagers(OCCViewer_Viewer::Type(), OCCViewManagers); if (OCCViewManagers.size() > 0) { - mySelector = createSelector(OCCViewManagers.first()); + onViewManagerAdded(OCCViewManagers.first()); } } - // it should be pefromed after the selector creation in order to have AISContext + // it should be performed after the selector creation in order to have AISContext myWorkshop->activateModule(); //action(myEraseAll)->setEnabled(false); @@ -319,7 +346,7 @@ bool SHAPERGUI::activateModule(SUIT_Study* theStudy) } myProxyViewer->activateViewer(true); - // Postrrocessing for LoadScriptId to remove created(if it was created) SALOME Object Browser + // Post-processing for LoadScriptId to remove created(if it was created) SALOME Object Browser connect(getApp()->action(LightApp_Application::UserID+1), SIGNAL(triggered(bool)), this, SLOT(onScriptLoaded())); @@ -385,7 +412,7 @@ bool SHAPERGUI::deactivateModule(SUIT_Study* theStudy) aResMgr->setValue("Study", "store_positions", myIsStorePositions); getApp()->setEditEnabled(myIsEditEnabled); - // Postrrocessing for LoadScriptId to remove created(if it was created) SALOME Object Browser + // 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())); @@ -422,8 +449,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; @@ -757,6 +792,49 @@ void SHAPERGUI::createPreferences() ModuleBase_Preferences::VIEWER_SECTION, "point-selection-sensitivity"); pref->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, + SUIT_PreferenceMgr::Bool, ModuleBase_Preferences::VIEWER_SECTION, "highlighting-3d"); + pref->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 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); + + 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); + + 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); + + 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); + + 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); + + 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); + + aItem = aMgr.addPreference(tr("Text color"), colorScaleGroup, + SUIT_PreferenceMgr::Color, ModuleBase_Preferences::VIEWER_SECTION, "scalar_bar_text_color"); + pref->retrieve(); } @@ -914,7 +992,7 @@ void SHAPERGUI::saveToolbarsConfig() { if (!myIsToolbarsModified) return; - // Save toolbars config into map + // Save toolbars configuration into map QMap aToolbarsConfig; QtxActionToolMgr* aMgr = toolMgr(); QStringList aToolbars = myToolbars.keys(); @@ -930,7 +1008,7 @@ void SHAPERGUI::saveToolbarsConfig() } aToolbarsConfig[aName] = aContent; } - // Store the config into resources + // Store the configuration into resources SUIT_ResourceMgr* aResMgr = application()->resourceMgr(); QStringList aNames = aToolbarsConfig.keys(); QStringList aValues;