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>
14 #include <SUIT_Selector.h>
15 #include <SUIT_Desktop.h>
16 #include <SUIT_ViewManager.h>
18 #include <QtxActionMenuMgr.h>
20 #include <QDockWidget>
23 NewGeom_EXPORT CAM_Module* createModule() {
24 return new NewGeom_Module();
27 NewGeom_EXPORT char* getModuleVersion() {
33 //******************************************************
34 NewGeom_Module::NewGeom_Module()
35 : LightApp_Module( "NewGeom" ), mySelector(0)
37 myWorkshop = new XGUI_Workshop(this);
38 myProxyViewer = new NewGeom_SalomeViewer(this);
41 //******************************************************
42 NewGeom_Module::~NewGeom_Module()
46 //******************************************************
47 void NewGeom_Module::initialize(CAM_Application* theApp)
49 LightApp_Module::initialize(theApp);
51 myWorkshop->startApplication();
54 //******************************************************
55 void NewGeom_Module::windows(QMap<int, int>& theWndMap) const
57 theWndMap.insert( LightApp_Application::WT_PyConsole, Qt::BottomDockWidgetArea );
60 //******************************************************
61 void NewGeom_Module::viewManagers(QStringList& theList) const
63 theList.append( OCCViewer_Viewer::Type() );
66 //******************************************************
67 bool NewGeom_Module::activateModule(SUIT_Study* theStudy)
69 bool isDone = LightApp_Module::activateModule(theStudy);
73 myWorkshop->propertyPanel()->hide();
76 ViewManagerList OCCViewManagers;
77 application()->viewManagers(OCCViewer_Viewer::Type(), OCCViewManagers);
78 if (OCCViewManagers.size() > 0) {
79 mySelector = createSelector(OCCViewManagers.first());
86 //******************************************************
87 void NewGeom_Module::onViewManagerAdded( SUIT_ViewManager* theMgr )
90 mySelector = createSelector(theMgr);
94 //******************************************************
95 NewGeom_OCCSelector* NewGeom_Module::createSelector(SUIT_ViewManager* theMgr)
97 if (theMgr->getType() == OCCViewer_Viewer::Type()) {
98 OCCViewer_Viewer* aViewer = static_cast<OCCViewer_Viewer*>(theMgr->getViewModel());
99 NewGeom_OCCSelector* aSelector = new NewGeom_OCCSelector(aViewer,
100 getApp()->selectionMgr());
101 LightApp_SelectionMgr* aMgr = getApp()->selectionMgr();
102 QList<SUIT_Selector*> aList;
103 aMgr->selectors(aList);
104 foreach(SUIT_Selector* aSel, aList) {
105 aSel->setEnabled(aSel == aSelector);
107 myProxyViewer->setSelector(aSelector);
113 //******************************************************
114 bool NewGeom_Module::deactivateModule(SUIT_Study* theStudy)
116 setMenuShown( false );
117 setToolShown( false );
118 return LightApp_Module::deactivateModule(theStudy);
121 //******************************************************
122 CAM_DataModel* NewGeom_Module::createDataModel()
124 return new NewGeom_DataModel( this );
127 //******************************************************
128 void NewGeom_Module::addFeature(const QString& theWBName,
129 const QString& theId,
130 const QString& theTitle,
131 const QString& theTip,
132 const QIcon& theIcon,
134 QObject* theReciever,
135 const char* theMember,
136 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 createAction(aId, theTip, theIcon, theTitle, theTip, aKeys, aDesk,
148 isCheckable, theReciever, theMember);
149 int aItemId = createMenu( aId, aMenu, -1, 10 );
150 int aToolId = createTool( aId, aTool );
153 //******************************************************
154 void NewGeom_Module::addEditCommand(const QString& theId,
155 const QString& theTitle,
156 const QString& theTip,
157 const QIcon& theIcon,
159 QObject* theReciever,
160 const char* theMember,
161 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 createAction(aId, theTip, theIcon, theTitle, theTip, aKeys, aDesk,
172 isCheckable, theReciever, theMember);
173 createMenu( aId, aMenu, 10 );
176 //******************************************************
177 void NewGeom_Module::addEditMenuSeparator()
179 int aMenu = createMenu(tr( "MEN_DESK_EDIT" ), -1, -1);
180 createMenu( separator(), aMenu, -1, 10 );
183 //******************************************************
184 QMainWindow* NewGeom_Module::desktop() const
186 return application()->desktop();
189 //******************************************************
190 QString NewGeom_Module::commandId(const QAction* theCmd) const
192 int aId = actionId(theCmd);
193 if (aId < myActionsList.size())
194 return myActionsList[aId];
198 //******************************************************
199 QAction* NewGeom_Module::command(const QString& theId) const
201 int aId = myActionsList.indexOf(theId);
202 if ((aId != -1) && (aId < myActionsList.size())) {
208 //******************************************************
209 void NewGeom_Module::setNestedActions(const QString& theId, const QStringList& theActions)
211 myNestedActions[theId] = theActions;
214 //******************************************************
215 QStringList NewGeom_Module::nestedActions(const QString& theId) const
217 if (myNestedActions.contains(theId))
218 return myNestedActions[theId];
219 return QStringList();
222 //******************************************************
223 void NewGeom_Module::selectionChanged()
225 LightApp_Module::selectionChanged();
226 myWorkshop->salomeViewerSelectionChanged();