3 #include "NewGeom_Module.h"
4 #include "NewGeom_DataModel.h"
5 #include "NewGeom_OCCSelector.h"
7 #include <XGUI_Workshop.h>
9 #include <LightApp_Application.h>
10 #include <LightApp_SelectionMgr.h>
11 #include <LightApp_OCCSelector.h>
12 #include <OCCViewer_ViewModel.h>
13 #include <SUIT_Selector.h>
15 #include <SUIT_Desktop.h>
16 #include <SUIT_ViewManager.h>
18 #include <QtxActionMenuMgr.h>
21 NewGeom_EXPORT CAM_Module* createModule() {
22 return new NewGeom_Module();
25 NewGeom_EXPORT char* getModuleVersion() {
31 //******************************************************
32 NewGeom_Module::NewGeom_Module()
33 : LightApp_Module( "NewGeom" ), mySelector(0)
35 myWorkshop = new XGUI_Workshop(this);
36 myProxyViewer = new NewGeom_SalomeViewer(this);
39 //******************************************************
40 NewGeom_Module::~NewGeom_Module()
44 //******************************************************
45 void NewGeom_Module::initialize(CAM_Application* theApp)
47 LightApp_Module::initialize(theApp);
49 myWorkshop->startApplication();
52 //******************************************************
53 void NewGeom_Module::windows(QMap<int, int>& theWndMap) const
55 theWndMap.insert( LightApp_Application::WT_PyConsole, Qt::BottomDockWidgetArea );
58 //******************************************************
59 void NewGeom_Module::viewManagers(QStringList& theList) const
61 theList.append( OCCViewer_Viewer::Type() );
64 //******************************************************
65 bool NewGeom_Module::activateModule(SUIT_Study* theStudy)
67 bool isDone = LightApp_Module::activateModule(theStudy);
73 ViewManagerList OCCViewManagers;
74 application()->viewManagers(OCCViewer_Viewer::Type(), OCCViewManagers);
75 if (OCCViewManagers.size() > 0) {
76 mySelector = createSelector(OCCViewManagers.first());
83 //******************************************************
84 void NewGeom_Module::onViewManagerAdded( SUIT_ViewManager* theMgr )
87 mySelector = createSelector(theMgr);
91 //******************************************************
92 NewGeom_OCCSelector* NewGeom_Module::createSelector(SUIT_ViewManager* theMgr)
94 if (theMgr->getType() == OCCViewer_Viewer::Type()) {
95 OCCViewer_Viewer* aViewer = static_cast<OCCViewer_Viewer*>(theMgr->getViewModel());
96 NewGeom_OCCSelector* aSelector = new NewGeom_OCCSelector(aViewer,
97 getApp()->selectionMgr());
98 LightApp_SelectionMgr* aMgr = getApp()->selectionMgr();
99 QList<SUIT_Selector*> aList;
100 aMgr->selectors(aList);
101 foreach(SUIT_Selector* aSel, aList) {
102 aSel->setEnabled(aSel == aSelector);
104 myProxyViewer->setSelector(aSelector);
110 //******************************************************
111 bool NewGeom_Module::deactivateModule(SUIT_Study* theStudy)
113 setMenuShown( false );
114 setToolShown( false );
115 return LightApp_Module::deactivateModule(theStudy);
118 //******************************************************
119 CAM_DataModel* NewGeom_Module::createDataModel()
121 return new NewGeom_DataModel( this );
124 //******************************************************
125 void NewGeom_Module::addFeature(const QString& theWBName,
126 const QString& theId,
127 const QString& theTitle,
128 const QString& theTip,
129 const QIcon& theIcon,
131 QObject* theReciever,
132 const char* theMember,
133 const QKeySequence& theKeys)
135 int aMenu = createMenu(theWBName, -1, -1, 50);
136 int aTool = createTool(theWBName);
138 int aId = myActionsList.size();
139 myActionsList.append(theId);
140 SUIT_Desktop* aDesk = application()->desktop();
142 for (int i = 0; i < theKeys.count(); i++)
144 createAction(aId, theTip, theIcon, theTitle, theTip, aKeys, aDesk,
145 isCheckable, theReciever, theMember);
146 int aItemId = createMenu( aId, aMenu, -1, 10 );
147 int aToolId = createTool( aId, aTool );
150 //******************************************************
151 void NewGeom_Module::addEditCommand(const QString& theId,
152 const QString& theTitle,
153 const QString& theTip,
154 const QIcon& theIcon,
156 QObject* theReciever,
157 const char* theMember,
158 const QKeySequence& theKeys)
160 int aMenu = createMenu(tr( "MEN_DESK_EDIT" ), -1, -1);
162 int aId = myActionsList.size();
163 myActionsList.append(theId);
164 SUIT_Desktop* aDesk = application()->desktop();
166 for (int i = 0; i < theKeys.count(); i++)
168 createAction(aId, theTip, theIcon, theTitle, theTip, aKeys, aDesk,
169 isCheckable, theReciever, theMember);
170 createMenu( aId, aMenu, 10 );
173 //******************************************************
174 void NewGeom_Module::addEditMenuSeparator()
176 int aMenu = createMenu(tr( "MEN_DESK_EDIT" ), -1, -1);
177 createMenu( separator(), aMenu, -1, 10 );
180 //******************************************************
181 QMainWindow* NewGeom_Module::desktop() const
183 return application()->desktop();
186 //******************************************************
187 QString NewGeom_Module::commandId(const QAction* theCmd) const
189 int aId = actionId(theCmd);
190 if (aId < myActionsList.size())
191 return myActionsList[aId];
195 //******************************************************
196 QAction* NewGeom_Module::command(const QString& theId) const
198 int aId = myActionsList.indexOf(theId);
199 if ((aId != -1) && (aId < myActionsList.size())) {
205 //******************************************************
206 void NewGeom_Module::setNestedActions(const QString& theId, const QStringList& theActions)
208 myNestedActions[theId] = theActions;
211 //******************************************************
212 QStringList NewGeom_Module::nestedActions(const QString& theId) const
214 if (myNestedActions.contains(theId))
215 return myNestedActions[theId];
216 return QStringList();
219 //******************************************************
220 void NewGeom_Module::selectionChanged()
222 LightApp_Module::selectionChanged();
223 myWorkshop->salomeViewerSelectionChanged();