X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2FNewGeom%2FNewGeom_Module.cpp;h=8d1b9624646b31d0c800b0b3a199c4ed6b607518;hb=20a291604881eb90b02e85cc3d97562c513b9471;hp=affe26d7962d8eb0318ac414c85de81e029dd274;hpb=3950546b72ab1ff2c303c4314e0d2d7574a1629c;p=modules%2Fshaper.git diff --git a/src/NewGeom/NewGeom_Module.cpp b/src/NewGeom/NewGeom_Module.cpp index affe26d79..8d1b96246 100644 --- a/src/NewGeom/NewGeom_Module.cpp +++ b/src/NewGeom/NewGeom_Module.cpp @@ -2,20 +2,26 @@ #include "NewGeom_Module.h" #include "NewGeom_DataModel.h" +#include "NewGeom_OCCSelector.h" #include #include +#include +#include #include +#include + #include -#include +#include +#include extern "C" { NewGeom_EXPORT CAM_Module* createModule() { return new NewGeom_Module(); } - + NewGeom_EXPORT char* getModuleVersion() { return "0.0"; } @@ -24,7 +30,7 @@ extern "C" { //****************************************************** NewGeom_Module::NewGeom_Module() -: LightApp_Module( "NewGeom" ) +: LightApp_Module( "NewGeom" ), mySelector(0) { myWorkshop = new XGUI_Workshop(this); } @@ -61,10 +67,44 @@ bool NewGeom_Module::activateModule(SUIT_Study* theStudy) if (isDone) { setMenuShown( true ); setToolShown( true ); + + if (!mySelector) { + ViewManagerList OCCViewManagers; + application()->viewManagers(OCCViewer_Viewer::Type(), OCCViewManagers); + if (OCCViewManagers.size() > 0) { + mySelector = createSelector(OCCViewManagers.first()); + } + } } return isDone; } +//****************************************************** +void NewGeom_Module::onViewManagerAdded( SUIT_ViewManager* theMgr ) +{ + if ((!mySelector)) { + mySelector = createSelector(theMgr); + } +} + +//****************************************************** +NewGeom_OCCSelector* NewGeom_Module::createSelector(SUIT_ViewManager* theMgr) +{ + if (theMgr->getType() == OCCViewer_Viewer::Type()) { + OCCViewer_Viewer* aViewer = static_cast(theMgr->getViewModel()); + NewGeom_OCCSelector* aSelector = new NewGeom_OCCSelector(aViewer, + getApp()->selectionMgr()); + LightApp_SelectionMgr* aMgr = getApp()->selectionMgr(); + QList aList; + aMgr->selectors(aList); + foreach(SUIT_Selector* aSel, aList) { + aSel->setEnabled(aSel == aSelector); + } + return aSelector; + } + return 0; +} + //****************************************************** bool NewGeom_Module::deactivateModule(SUIT_Study* theStudy) { @@ -158,4 +198,36 @@ QAction* NewGeom_Module::command(const QString& theId) const return action(aId); } return 0; -} \ No newline at end of file +} + +//****************************************************** +void NewGeom_Module::setNestedActions(const QString& theId, const QStringList& theActions) +{ + myNestedActions[theId] = theActions; +} + +//****************************************************** +QStringList NewGeom_Module::nestedActions(const QString& theId) const +{ + if (myNestedActions.contains(theId)) + return myNestedActions[theId]; + return QStringList(); +} + +//****************************************************** +Handle(AIS_InteractiveContext) NewGeom_Module::AISContext() const +{ + Handle(AIS_InteractiveContext) aContext; + OCCViewer_Viewer* aViewer = mySelector->viewer(); + if (aViewer) { + aContext = aViewer->getAISContext(); + } + return aContext; +} + +//****************************************************** +void NewGeom_Module::selectionChanged() +{ + LightApp_Module::selectionChanged(); + myWorkshop->salomeViewerSelectionChanged(); +}