X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FNewGeom%2FNewGeom_Module.cpp;h=023a1ffb10f3322e5e0a8fc2e2604c6b8c5f92dc;hb=7668e5c890fe62948ff1e50676fd87221c5af9bc;hp=7ef9d61f18c100692f12f54a3bec8d58f1196d1c;hpb=e9d86ad2a12c582582e33458bb95a35853fe405c;p=modules%2Fshaper.git diff --git a/src/NewGeom/NewGeom_Module.cpp b/src/NewGeom/NewGeom_Module.cpp index 7ef9d61f1..023a1ffb1 100644 --- a/src/NewGeom/NewGeom_Module.cpp +++ b/src/NewGeom/NewGeom_Module.cpp @@ -1,39 +1,79 @@ - #include "NewGeom_Module.h" #include "NewGeom_DataModel.h" #include "NewGeom_OCCSelector.h" #include +#include +#include +#include +#include #include #include #include #include -#include +#include #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"; - } +NewGeom_EXPORT CAM_Module* createModule() +{ + return new NewGeom_Module(); +} + +NewGeom_EXPORT char* getModuleVersion() +{ + return "0.0"; } +} + +class NewGeom_PrefMgr: public XGUI_IPrefMgr +{ +public: + NewGeom_PrefMgr(LightApp_Preferences* theMgr, const QString& theModName):myMgr(theMgr), myModName(theModName) {} + + virtual int addPreference(const QString& theLbl, int pId, + SUIT_PreferenceMgr::PrefItemType theType, + const QString& theSection, const QString& theName ) + { + return myMgr->addPreference(myModName, theLbl, pId, theType, theSection, theName); + } + + virtual SUIT_PreferenceMgr* prefMgr() const { return myMgr; } + +private: + LightApp_Preferences* myMgr; + QString myModName; +}; + + //****************************************************** NewGeom_Module::NewGeom_Module() -: LightApp_Module( "NewGeom" ), mySelector(0) + : LightApp_Module("NewGeom"), + mySelector(0), myIsOpened(0) { myWorkshop = new XGUI_Workshop(this); myProxyViewer = new NewGeom_SalomeViewer(this); + + XGUI_Preferences::setResourceMgr(application()->resourceMgr()); + XGUI_Preferences::loadCustomProps(); } //****************************************************** @@ -45,20 +85,20 @@ NewGeom_Module::~NewGeom_Module() void NewGeom_Module::initialize(CAM_Application* theApp) { LightApp_Module::initialize(theApp); - + myWorkshop->startApplication(); } //****************************************************** void NewGeom_Module::windows(QMap& theWndMap) const { - theWndMap.insert( LightApp_Application::WT_PyConsole, Qt::BottomDockWidgetArea ); + theWndMap.insert(LightApp_Application::WT_PyConsole, Qt::BottomDockWidgetArea); } //****************************************************** void NewGeom_Module::viewManagers(QStringList& theList) const { - theList.append( OCCViewer_Viewer::Type() ); + theList.append(OCCViewer_Viewer::Type()); } //****************************************************** @@ -66,8 +106,8 @@ bool NewGeom_Module::activateModule(SUIT_Study* theStudy) { bool isDone = LightApp_Module::activateModule(theStudy); if (isDone) { - setMenuShown( true ); - setToolShown( true ); + setMenuShown(true); + setToolShown(true); if (!mySelector) { ViewManagerList OCCViewManagers; @@ -76,12 +116,31 @@ bool NewGeom_Module::activateModule(SUIT_Study* theStudy) mySelector = createSelector(OCCViewManagers.first()); } } + myWorkshop->propertyPanel()->hide(); + QtxPopupMgr* aMgr = popupMgr(); // Create popup manager + action(myEraseAll)->setEnabled(false); + + if (myIsOpened) { + myWorkshop->objectBrowser()->rebuildDataTree(); + myWorkshop->updateCommandStatus(); + myIsOpened = false; + QTimer::singleShot(1000, myWorkshop, SLOT(displayAllResults())); + } } return isDone; } //****************************************************** -void NewGeom_Module::onViewManagerAdded( SUIT_ViewManager* theMgr ) +bool NewGeom_Module::deactivateModule(SUIT_Study* theStudy) +{ + setMenuShown(false); + setToolShown(false); + //myWorkshop->contextMenuMgr()->disconnectViewer(); + return LightApp_Module::deactivateModule(theStudy); +} + +//****************************************************** +void NewGeom_Module::onViewManagerAdded(SUIT_ViewManager* theMgr) { if ((!mySelector)) { mySelector = createSelector(theMgr); @@ -93,12 +152,12 @@ 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()); + NewGeom_OCCSelector* aSelector = new NewGeom_OCCSelector(aViewer, getApp()->selectionMgr()); LightApp_SelectionMgr* aMgr = getApp()->selectionMgr(); QList aList; aMgr->selectors(aList); - foreach(SUIT_Selector* aSel, aList) { + foreach(SUIT_Selector* aSel, aList) + { aSel->setEnabled(aSel == aSelector); } myProxyViewer->setSelector(aSelector); @@ -107,30 +166,17 @@ NewGeom_OCCSelector* NewGeom_Module::createSelector(SUIT_ViewManager* theMgr) return 0; } -//****************************************************** -bool NewGeom_Module::deactivateModule(SUIT_Study* theStudy) -{ - setMenuShown( false ); - setToolShown( false ); - return LightApp_Module::deactivateModule(theStudy); -} - //****************************************************** CAM_DataModel* NewGeom_Module::createDataModel() { - return new NewGeom_DataModel( this ); + return new NewGeom_DataModel(this); } //****************************************************** -void NewGeom_Module::addFeature(const QString& theWBName, - const QString& theId, - const QString& theTitle, - const QString& theTip, - const QIcon& theIcon, - bool isCheckable, - QObject* theReciever, - const char* theMember, - const QKeySequence& theKeys) +QAction* NewGeom_Module::addFeature(const QString& theWBName, const QString& theId, + const QString& theTitle, const QString& theTip, + const QIcon& theIcon, const QKeySequence& theKeys, + bool isCheckable) { int aMenu = createMenu(theWBName, -1, -1, 50); int aTool = createTool(theWBName); @@ -139,42 +185,56 @@ void NewGeom_Module::addFeature(const QString& theWBName, myActionsList.append(theId); SUIT_Desktop* aDesk = application()->desktop(); int aKeys = 0; - for (int i = 0; i < theKeys.count(); i++) + for (unsigned int i = 0; i < theKeys.count(); i++) aKeys += theKeys[i]; - createAction(aId, theTip, theIcon, theTitle, theTip, aKeys, aDesk, - isCheckable, theReciever, theMember); - int aItemId = createMenu( aId, aMenu, -1, 10 ); - int aToolId = createTool( aId, aTool ); + QAction* aAction = createAction(aId, theTip, theIcon, theTitle, theTip, aKeys, aDesk, + isCheckable); + aAction->setData(theId); + int aItemId = createMenu(aId, aMenu, -1, 10); + int aToolId = createTool(aId, aTool); + return aAction; } //****************************************************** -void NewGeom_Module::addEditCommand(const QString& theId, - const QString& theTitle, - const QString& theTip, - const QIcon& theIcon, - bool isCheckable, - QObject* theReciever, - const char* theMember, - const QKeySequence& theKeys) +QAction* NewGeom_Module::addEditCommand(const QString& theId, const QString& theTitle, + const QString& theTip, const QIcon& theIcon, + const QKeySequence& theKeys, bool isCheckable) { - int aMenu = createMenu(tr( "MEN_DESK_EDIT" ), -1, -1); + int aMenu = createMenu(tr("MEN_DESK_EDIT"), -1, -1); int aId = myActionsList.size(); myActionsList.append(theId); SUIT_Desktop* aDesk = application()->desktop(); int aKeys = 0; - for (int i = 0; i < theKeys.count(); i++) + for (unsigned int i = 0; i < theKeys.count(); i++) aKeys += theKeys[i]; - createAction(aId, theTip, theIcon, theTitle, theTip, aKeys, aDesk, - isCheckable, theReciever, theMember); - createMenu( aId, aMenu, 10 ); + QAction* aAction = createAction(aId, theTip, theIcon, theTitle, theTip, aKeys, aDesk, + isCheckable); + aAction->setData(theId); + createMenu(aId, aMenu, 10); + return aAction; } //****************************************************** void NewGeom_Module::addEditMenuSeparator() { - int aMenu = createMenu(tr( "MEN_DESK_EDIT" ), -1, -1); - createMenu( separator(), aMenu, -1, 10 ); + int aMenu = createMenu(tr("MEN_DESK_EDIT"), -1, -1); + createMenu(separator(), aMenu, -1, 10); +} + +//****************************************************** +QList NewGeom_Module::commandList() const +{ + QList aActions; + for (int i = 0; i < myActionsList.size(); i++) + aActions.append(action(i)); + return aActions; +} + +//****************************************************** +QStringList NewGeom_Module::commandIdList() const +{ + return myActionsList; } //****************************************************** @@ -222,3 +282,45 @@ void NewGeom_Module::selectionChanged() LightApp_Module::selectionChanged(); myWorkshop->salomeViewerSelectionChanged(); } + +//****************************************************** +void NewGeom_Module::contextMenuPopup(const QString& theClient, QMenu* theMenu, QString& theTitle) +{ + myWorkshop->contextMenuMgr()->addViewerItems(theMenu); + LightApp_Module::contextMenuPopup(theClient, theMenu, theTitle); +} + + +//****************************************************** +void NewGeom_Module::createPreferences() +{ + LightApp_Preferences* pref = preferences(); + if (!pref) + return; + XGUI_Preferences::updateCustomProps(); + QString aModName = moduleName(); + + QtxPreferenceItem* item = pref->findItem(aModName, true ); + if ( item && (!item->isEmpty() )) { + item->parentItem()->removeItem(item); + delete item; + } + + int catId = pref->addPreference(aModName, -1 ); + if ( catId == -1 ) + return; + NewGeom_PrefMgr aMgr(pref, aModName); + XGUI_Preferences::createEditContent(&aMgr, catId); + pref->retrieve(); +} + +//****************************************************** +void NewGeom_Module::preferencesChanged(const QString& theSection, const QString& theParam) +{ + SUIT_ResourceMgr* aResMgr = application()->resourceMgr(); + QString aVal = aResMgr->stringValue(theSection, theParam); + if (!aVal.isNull()) { + Config_Prop* aProp = Config_PropManager::findProp(theSection.toStdString(), theParam.toStdString()); + aProp->setValue(aVal.toStdString()); + } +}