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>
24 NewGeom_EXPORT CAM_Module* createModule() {
25 return new NewGeom_Module();
28 NewGeom_EXPORT char* getModuleVersion() {
34 //******************************************************
35 NewGeom_Module::NewGeom_Module()
36 : LightApp_Module( "NewGeom" ), mySelector(0)
38 myWorkshop = new XGUI_Workshop(this);
39 myProxyViewer = new NewGeom_SalomeViewer(this);
42 //******************************************************
43 NewGeom_Module::~NewGeom_Module()
47 //******************************************************
48 void NewGeom_Module::initialize(CAM_Application* theApp)
50 LightApp_Module::initialize(theApp);
52 myWorkshop->startApplication();
55 //******************************************************
56 void NewGeom_Module::windows(QMap<int, int>& theWndMap) const
58 theWndMap.insert( LightApp_Application::WT_PyConsole, Qt::BottomDockWidgetArea );
61 //******************************************************
62 void NewGeom_Module::viewManagers(QStringList& theList) const
64 theList.append( OCCViewer_Viewer::Type() );
67 //******************************************************
68 bool NewGeom_Module::activateModule(SUIT_Study* theStudy)
70 bool isDone = LightApp_Module::activateModule(theStudy);
74 myWorkshop->propertyPanel()->hide();
77 ViewManagerList OCCViewManagers;
78 application()->viewManagers(OCCViewer_Viewer::Type(), OCCViewManagers);
79 if (OCCViewManagers.size() > 0) {
80 mySelector = createSelector(OCCViewManagers.first());
87 //******************************************************
88 void NewGeom_Module::onViewManagerAdded( SUIT_ViewManager* theMgr )
91 mySelector = createSelector(theMgr);
95 //******************************************************
96 NewGeom_OCCSelector* NewGeom_Module::createSelector(SUIT_ViewManager* theMgr)
98 if (theMgr->getType() == OCCViewer_Viewer::Type()) {
99 OCCViewer_Viewer* aViewer = static_cast<OCCViewer_Viewer*>(theMgr->getViewModel());
100 NewGeom_OCCSelector* aSelector = new NewGeom_OCCSelector(aViewer,
101 getApp()->selectionMgr());
102 LightApp_SelectionMgr* aMgr = getApp()->selectionMgr();
103 QList<SUIT_Selector*> aList;
104 aMgr->selectors(aList);
105 foreach(SUIT_Selector* aSel, aList) {
106 aSel->setEnabled(aSel == aSelector);
108 myProxyViewer->setSelector(aSelector);
114 //******************************************************
115 bool NewGeom_Module::deactivateModule(SUIT_Study* theStudy)
117 setMenuShown( false );
118 setToolShown( false );
119 return LightApp_Module::deactivateModule(theStudy);
122 //******************************************************
123 CAM_DataModel* NewGeom_Module::createDataModel()
125 return new NewGeom_DataModel( this );
128 //******************************************************
129 void NewGeom_Module::addFeature(const QString& theWBName,
130 const QString& theId,
131 const QString& theTitle,
132 const QString& theTip,
133 const QIcon& theIcon,
135 QObject* theReciever,
136 const char* theMember,
137 const QKeySequence& theKeys)
139 int aMenu = createMenu(theWBName, -1, -1, 50);
140 int aTool = createTool(theWBName);
142 int aId = myActionsList.size();
143 myActionsList.append(theId);
144 SUIT_Desktop* aDesk = application()->desktop();
146 for (int i = 0; i < theKeys.count(); i++)
148 createAction(aId, theTip, theIcon, theTitle, theTip, aKeys, aDesk,
149 isCheckable, theReciever, theMember);
150 int aItemId = createMenu( aId, aMenu, -1, 10 );
151 int aToolId = createTool( aId, aTool );
154 //******************************************************
155 void NewGeom_Module::addEditCommand(const QString& theId,
156 const QString& theTitle,
157 const QString& theTip,
158 const QIcon& theIcon,
160 QObject* theReciever,
161 const char* theMember,
162 const QKeySequence& theKeys)
164 int aMenu = createMenu(tr( "MEN_DESK_EDIT" ), -1, -1);
166 int aId = myActionsList.size();
167 myActionsList.append(theId);
168 SUIT_Desktop* aDesk = application()->desktop();
170 for (int i = 0; i < theKeys.count(); i++)
172 createAction(aId, theTip, theIcon, theTitle, theTip, aKeys, aDesk,
173 isCheckable, theReciever, theMember);
174 createMenu( aId, aMenu, 10 );
177 //******************************************************
178 void NewGeom_Module::addEditMenuSeparator()
180 int aMenu = createMenu(tr( "MEN_DESK_EDIT" ), -1, -1);
181 createMenu( separator(), aMenu, -1, 10 );
184 //******************************************************
185 QMainWindow* NewGeom_Module::desktop() const
187 return application()->desktop();
190 //******************************************************
191 QString NewGeom_Module::commandId(const QAction* theCmd) const
193 int aId = actionId(theCmd);
194 if (aId < myActionsList.size())
195 return myActionsList[aId];
199 //******************************************************
200 QAction* NewGeom_Module::command(const QString& theId) const
202 int aId = myActionsList.indexOf(theId);
203 if ((aId != -1) && (aId < myActionsList.size())) {
209 //******************************************************
210 void NewGeom_Module::setNestedActions(const QString& theId, const QStringList& theActions)
212 myNestedActions[theId] = theActions;
215 //******************************************************
216 QStringList NewGeom_Module::nestedActions(const QString& theId) const
218 if (myNestedActions.contains(theId))
219 return myNestedActions[theId];
220 return QStringList();
223 //******************************************************
224 void NewGeom_Module::selectionChanged()
226 LightApp_Module::selectionChanged();
227 myWorkshop->salomeViewerSelectionChanged();