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);
38 //******************************************************
39 NewGeom_Module::~NewGeom_Module()
43 //******************************************************
44 void NewGeom_Module::initialize(CAM_Application* theApp)
46 LightApp_Module::initialize(theApp);
48 myWorkshop->startApplication();
51 //******************************************************
52 void NewGeom_Module::windows(QMap<int, int>& theWndMap) const
54 theWndMap.insert( LightApp_Application::WT_PyConsole, Qt::BottomDockWidgetArea );
57 //******************************************************
58 void NewGeom_Module::viewManagers(QStringList& theList) const
60 theList.append( OCCViewer_Viewer::Type() );
63 //******************************************************
64 bool NewGeom_Module::activateModule(SUIT_Study* theStudy)
66 bool isDone = LightApp_Module::activateModule(theStudy);
72 ViewManagerList OCCViewManagers;
73 application()->viewManagers(OCCViewer_Viewer::Type(), OCCViewManagers);
74 if (OCCViewManagers.size() > 0) {
75 mySelector = createSelector(OCCViewManagers.first());
82 //******************************************************
83 void NewGeom_Module::onViewManagerAdded( SUIT_ViewManager* theMgr )
86 mySelector = createSelector(theMgr);
90 //******************************************************
91 NewGeom_OCCSelector* NewGeom_Module::createSelector(SUIT_ViewManager* theMgr)
93 if (theMgr->getType() == OCCViewer_Viewer::Type()) {
94 OCCViewer_Viewer* aViewer = static_cast<OCCViewer_Viewer*>(theMgr->getViewModel());
95 NewGeom_OCCSelector* aSelector = new NewGeom_OCCSelector(aViewer,
96 getApp()->selectionMgr());
97 LightApp_SelectionMgr* aMgr = getApp()->selectionMgr();
98 QList<SUIT_Selector*> aList;
99 aMgr->selectors(aList);
100 foreach(SUIT_Selector* aSel, aList) {
101 aSel->setEnabled(aSel == aSelector);
108 //******************************************************
109 bool NewGeom_Module::deactivateModule(SUIT_Study* theStudy)
111 setMenuShown( false );
112 setToolShown( false );
113 return LightApp_Module::deactivateModule(theStudy);
116 //******************************************************
117 CAM_DataModel* NewGeom_Module::createDataModel()
119 return new NewGeom_DataModel( this );
122 //******************************************************
123 void NewGeom_Module::addFeature(const QString& theWBName,
124 const QString& theId,
125 const QString& theTitle,
126 const QString& theTip,
127 const QIcon& theIcon,
129 QObject* theReciever,
130 const char* theMember,
131 const QKeySequence& theKeys)
133 int aMenu = createMenu(theWBName, -1, -1, 50);
134 int aTool = createTool(theWBName);
136 int aId = myActionsList.size();
137 myActionsList.append(theId);
138 SUIT_Desktop* aDesk = application()->desktop();
140 for (int i = 0; i < theKeys.count(); i++)
142 createAction(aId, theTip, theIcon, theTitle, theTip, aKeys, aDesk,
143 isCheckable, theReciever, theMember);
144 int aItemId = createMenu( aId, aMenu, -1, 10 );
145 int aToolId = createTool( aId, aTool );
148 //******************************************************
149 void NewGeom_Module::addEditCommand(const QString& theId,
150 const QString& theTitle,
151 const QString& theTip,
152 const QIcon& theIcon,
154 QObject* theReciever,
155 const char* theMember,
156 const QKeySequence& theKeys)
158 int aMenu = createMenu(tr( "MEN_DESK_EDIT" ), -1, -1);
160 int aId = myActionsList.size();
161 myActionsList.append(theId);
162 SUIT_Desktop* aDesk = application()->desktop();
164 for (int i = 0; i < theKeys.count(); i++)
166 createAction(aId, theTip, theIcon, theTitle, theTip, aKeys, aDesk,
167 isCheckable, theReciever, theMember);
168 createMenu( aId, aMenu, 10 );
171 //******************************************************
172 void NewGeom_Module::addEditMenuSeparator()
174 int aMenu = createMenu(tr( "MEN_DESK_EDIT" ), -1, -1);
175 createMenu( separator(), aMenu, -1, 10 );
178 //******************************************************
179 QMainWindow* NewGeom_Module::desktop() const
181 return application()->desktop();
184 //******************************************************
185 QString NewGeom_Module::commandId(const QAction* theCmd) const
187 int aId = actionId(theCmd);
188 if (aId < myActionsList.size())
189 return myActionsList[aId];
193 //******************************************************
194 QAction* NewGeom_Module::command(const QString& theId) const
196 int aId = myActionsList.indexOf(theId);
197 if ((aId != -1) && (aId < myActionsList.size())) {
203 //******************************************************
204 void NewGeom_Module::setNestedActions(const QString& theId, const QStringList& theActions)
206 myNestedActions[theId] = theActions;
209 //******************************************************
210 QStringList NewGeom_Module::nestedActions(const QString& theId) const
212 if (myNestedActions.contains(theId))
213 return myNestedActions[theId];
214 return QStringList();
217 //******************************************************
218 Handle(AIS_InteractiveContext) NewGeom_Module::AISContext() const
220 Handle(AIS_InteractiveContext) aContext;
221 OCCViewer_Viewer* aViewer = mySelector->viewer();
223 aContext = aViewer->getAISContext();
228 //******************************************************
229 void NewGeom_Module::selectionChanged()
231 LightApp_Module::selectionChanged();
232 myWorkshop->salomeViewerSelectionChanged();