2 #include "NewGeom_Module.h"
3 #include "NewGeom_DataModel.h"
4 #include "NewGeom_OCCSelector.h"
6 #include <XGUI_Workshop.h>
7 #include <XGUI_PropertyPanel.h>
8 #include <XGUI_ContextMenuMgr.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 <QtxPopupMgr.h>
20 #include <QtxActionMenuMgr.h>
22 #include <QDockWidget>
26 NewGeom_EXPORT CAM_Module* createModule()
28 return new NewGeom_Module();
31 NewGeom_EXPORT char* getModuleVersion()
37 //******************************************************
38 NewGeom_Module::NewGeom_Module()
39 : LightApp_Module("NewGeom"),
42 myWorkshop = new XGUI_Workshop(this);
43 myProxyViewer = new NewGeom_SalomeViewer(this);
46 //******************************************************
47 NewGeom_Module::~NewGeom_Module()
51 //******************************************************
52 void NewGeom_Module::initialize(CAM_Application* theApp)
54 LightApp_Module::initialize(theApp);
56 myWorkshop->startApplication();
59 //******************************************************
60 void NewGeom_Module::windows(QMap<int, int>& theWndMap) const
62 theWndMap.insert(LightApp_Application::WT_PyConsole, Qt::BottomDockWidgetArea);
65 //******************************************************
66 void NewGeom_Module::viewManagers(QStringList& theList) const
68 theList.append(OCCViewer_Viewer::Type());
71 //******************************************************
72 bool NewGeom_Module::activateModule(SUIT_Study* theStudy)
74 bool isDone = LightApp_Module::activateModule(theStudy);
80 ViewManagerList OCCViewManagers;
81 application()->viewManagers(OCCViewer_Viewer::Type(), OCCViewManagers);
82 if (OCCViewManagers.size() > 0) {
83 mySelector = createSelector(OCCViewManagers.first());
86 myWorkshop->propertyPanel()->hide();
87 QtxPopupMgr* aMgr = popupMgr(); // Create popup manager
88 action(myEraseAll)->setEnabled(false);
93 //******************************************************
94 bool NewGeom_Module::deactivateModule(SUIT_Study* theStudy)
98 //myWorkshop->contextMenuMgr()->disconnectViewer();
99 return LightApp_Module::deactivateModule(theStudy);
102 //******************************************************
103 void NewGeom_Module::onViewManagerAdded(SUIT_ViewManager* theMgr)
106 mySelector = createSelector(theMgr);
110 //******************************************************
111 NewGeom_OCCSelector* NewGeom_Module::createSelector(SUIT_ViewManager* theMgr)
113 if (theMgr->getType() == OCCViewer_Viewer::Type()) {
114 OCCViewer_Viewer* aViewer = static_cast<OCCViewer_Viewer*>(theMgr->getViewModel());
115 NewGeom_OCCSelector* aSelector = new NewGeom_OCCSelector(aViewer, getApp()->selectionMgr());
116 LightApp_SelectionMgr* aMgr = getApp()->selectionMgr();
117 QList<SUIT_Selector*> aList;
118 aMgr->selectors(aList);
119 foreach(SUIT_Selector* aSel, aList)
121 aSel->setEnabled(aSel == aSelector);
123 myProxyViewer->setSelector(aSelector);
129 //******************************************************
130 CAM_DataModel* NewGeom_Module::createDataModel()
132 return new NewGeom_DataModel(this);
135 //******************************************************
136 QAction* NewGeom_Module::addFeature(const QString& theWBName, const QString& theId,
137 const QString& theTitle, const QString& theTip,
138 const QIcon& theIcon, const QKeySequence& theKeys,
141 int aMenu = createMenu(theWBName, -1, -1, 50);
142 int aTool = createTool(theWBName);
144 int aId = myActionsList.size();
145 myActionsList.append(theId);
146 SUIT_Desktop* aDesk = application()->desktop();
148 for (int i = 0; i < theKeys.count(); i++)
150 QAction* aAction = createAction(aId, theTip, theIcon, theTitle, theTip, aKeys, aDesk,
152 aAction->setData(theId);
153 int aItemId = createMenu(aId, aMenu, -1, 10);
154 int aToolId = createTool(aId, aTool);
158 //******************************************************
159 QAction* NewGeom_Module::addEditCommand(const QString& theId, const QString& theTitle,
160 const QString& theTip, const QIcon& theIcon,
161 const QKeySequence& theKeys, bool isCheckable)
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();
246 //******************************************************
247 void NewGeom_Module::contextMenuPopup(const QString& theClient, QMenu* theMenu, QString& theTitle)
249 myWorkshop->contextMenuMgr()->addViewerItems(theMenu);
250 LightApp_Module::contextMenuPopup(theClient, theMenu, theTitle);