3 #include "NewGeom_Module.h"
4 #include "NewGeom_DataModel.h"
5 #include "NewGeom_OCCSelector.h"
7 #include <XGUI_Workshop.h>
8 #include <XGUI_PropertyPanel.h>
10 #include <LightApp_Application.h>
11 #include <LightApp_SelectionMgr.h>
12 #include <LightApp_OCCSelector.h>
13 #include <OCCViewer_ViewModel.h>
15 #include <SUIT_Selector.h>
16 #include <SUIT_Desktop.h>
17 #include <SUIT_ViewManager.h>
19 #include <QtxActionMenuMgr.h>
21 #include <QDockWidget>
25 NewGeom_EXPORT CAM_Module* createModule() {
26 return new NewGeom_Module();
29 NewGeom_EXPORT char* getModuleVersion() {
35 //******************************************************
36 NewGeom_Module::NewGeom_Module()
37 : LightApp_Module( "NewGeom" ), mySelector(0)
39 myWorkshop = new XGUI_Workshop(this);
40 myProxyViewer = new NewGeom_SalomeViewer(this);
43 //******************************************************
44 NewGeom_Module::~NewGeom_Module()
48 //******************************************************
49 void NewGeom_Module::initialize(CAM_Application* theApp)
51 LightApp_Module::initialize(theApp);
53 myWorkshop->startApplication();
56 //******************************************************
57 void NewGeom_Module::windows(QMap<int, int>& theWndMap) const
59 theWndMap.insert( LightApp_Application::WT_PyConsole, Qt::BottomDockWidgetArea );
62 //******************************************************
63 void NewGeom_Module::viewManagers(QStringList& theList) const
65 theList.append( OCCViewer_Viewer::Type() );
68 //******************************************************
69 bool NewGeom_Module::activateModule(SUIT_Study* theStudy)
71 bool isDone = LightApp_Module::activateModule(theStudy);
75 myWorkshop->propertyPanel()->hide();
78 ViewManagerList OCCViewManagers;
79 application()->viewManagers(OCCViewer_Viewer::Type(), OCCViewManagers);
80 if (OCCViewManagers.size() > 0) {
81 mySelector = createSelector(OCCViewManagers.first());
88 //******************************************************
89 void NewGeom_Module::onViewManagerAdded( SUIT_ViewManager* theMgr )
92 mySelector = createSelector(theMgr);
96 //******************************************************
97 NewGeom_OCCSelector* NewGeom_Module::createSelector(SUIT_ViewManager* theMgr)
99 if (theMgr->getType() == OCCViewer_Viewer::Type()) {
100 OCCViewer_Viewer* aViewer = static_cast<OCCViewer_Viewer*>(theMgr->getViewModel());
101 NewGeom_OCCSelector* aSelector = new NewGeom_OCCSelector(aViewer,
102 getApp()->selectionMgr());
103 LightApp_SelectionMgr* aMgr = getApp()->selectionMgr();
104 QList<SUIT_Selector*> aList;
105 aMgr->selectors(aList);
106 foreach(SUIT_Selector* aSel, aList) {
107 aSel->setEnabled(aSel == aSelector);
109 myProxyViewer->setSelector(aSelector);
115 //******************************************************
116 bool NewGeom_Module::deactivateModule(SUIT_Study* theStudy)
118 setMenuShown( false );
119 setToolShown( false );
120 return LightApp_Module::deactivateModule(theStudy);
123 //******************************************************
124 CAM_DataModel* NewGeom_Module::createDataModel()
126 return new NewGeom_DataModel( this );
129 //******************************************************
130 QAction* NewGeom_Module::addFeature(const QString& theWBName,
131 const QString& theId,
132 const QString& theTitle,
133 const QString& theTip,
134 const QIcon& theIcon,
135 const QKeySequence& theKeys,
138 int aMenu = createMenu(theWBName, -1, -1, 50);
139 int aTool = createTool(theWBName);
141 int aId = myActionsList.size();
142 myActionsList.append(theId);
143 SUIT_Desktop* aDesk = application()->desktop();
145 for (int i = 0; i < theKeys.count(); i++)
147 QAction* aAction = createAction(aId, theTip, theIcon, theTitle, theTip, aKeys, aDesk,
149 aAction->setData(theId);
150 int aItemId = createMenu( aId, aMenu, -1, 10 );
151 int aToolId = createTool( aId, aTool );
155 //******************************************************
156 QAction* NewGeom_Module::addEditCommand(const QString& theId,
157 const QString& theTitle,
158 const QString& theTip,
159 const QIcon& theIcon,
160 const QKeySequence& theKeys,
163 int aMenu = createMenu(tr( "MEN_DESK_EDIT" ), -1, -1);
165 int aId = myActionsList.size();
166 myActionsList.append(theId);
167 SUIT_Desktop* aDesk = application()->desktop();
169 for (int i = 0; i < theKeys.count(); i++)
171 QAction* aAction = createAction(aId, theTip, theIcon, theTitle, theTip, aKeys, aDesk,
173 aAction->setData(theId);
174 createMenu( aId, aMenu, 10 );
178 //******************************************************
179 void NewGeom_Module::addEditMenuSeparator()
181 int aMenu = createMenu(tr( "MEN_DESK_EDIT" ), -1, -1);
182 createMenu( separator(), aMenu, -1, 10 );
185 //******************************************************
186 QList<QAction*> NewGeom_Module::commandList() const
188 QList<QAction*> aActions;
189 for (int i = 0; i < myActionsList.size(); i++)
190 aActions.append(action(i));
194 //******************************************************
195 QStringList NewGeom_Module::commandIdList() const
197 return myActionsList;
200 //******************************************************
201 QMainWindow* NewGeom_Module::desktop() const
203 return application()->desktop();
206 //******************************************************
207 QString NewGeom_Module::commandId(const QAction* theCmd) const
209 int aId = actionId(theCmd);
210 if (aId < myActionsList.size())
211 return myActionsList[aId];
215 //******************************************************
216 QAction* NewGeom_Module::command(const QString& theId) const
218 int aId = myActionsList.indexOf(theId);
219 if ((aId != -1) && (aId < myActionsList.size())) {
225 //******************************************************
226 void NewGeom_Module::setNestedActions(const QString& theId, const QStringList& theActions)
228 myNestedActions[theId] = theActions;
231 //******************************************************
232 QStringList NewGeom_Module::nestedActions(const QString& theId) const
234 if (myNestedActions.contains(theId))
235 return myNestedActions[theId];
236 return QStringList();
239 //******************************************************
240 void NewGeom_Module::selectionChanged()
242 LightApp_Module::selectionChanged();
243 myWorkshop->salomeViewerSelectionChanged();