3 #include "NewGeom_Module.h"
4 #include "NewGeom_DataModel.h"
6 #include <XGUI_Workshop.h>
8 #include <LightApp_Application.h>
9 #include <OCCViewer_ViewModel.h>
11 #include <SUIT_Desktop.h>
12 #include <SUIT_ViewManager.h>
14 #include <QtxActionMenuMgr.h>
18 NewGeom_EXPORT CAM_Module* createModule() {
19 return new NewGeom_Module();
22 NewGeom_EXPORT char* getModuleVersion() {
28 //******************************************************
29 NewGeom_Module::NewGeom_Module()
30 : LightApp_Module( "NewGeom" )
32 myWorkshop = new XGUI_Workshop(this);
35 //******************************************************
36 NewGeom_Module::~NewGeom_Module()
40 //******************************************************
41 void NewGeom_Module::initialize(CAM_Application* theApp)
43 LightApp_Module::initialize(theApp);
45 myWorkshop->startApplication();
48 //******************************************************
49 void NewGeom_Module::windows(QMap<int, int>& theWndMap) const
51 theWndMap.insert( LightApp_Application::WT_PyConsole, Qt::BottomDockWidgetArea );
54 //******************************************************
55 void NewGeom_Module::viewManagers(QStringList& theList) const
57 theList.append( OCCViewer_Viewer::Type() );
60 //******************************************************
61 bool NewGeom_Module::activateModule(SUIT_Study* theStudy)
63 bool isDone = LightApp_Module::activateModule(theStudy);
71 //******************************************************
72 bool NewGeom_Module::deactivateModule(SUIT_Study* theStudy)
74 setMenuShown( false );
75 setToolShown( false );
76 return LightApp_Module::deactivateModule(theStudy);
79 //******************************************************
80 CAM_DataModel* NewGeom_Module::createDataModel()
82 return new NewGeom_DataModel( this );
85 //******************************************************
86 void NewGeom_Module::addFeature(const QString& theWBName,
88 const QString& theTitle,
89 const QString& theTip,
93 const char* theMember,
94 const QKeySequence& theKeys)
96 int aMenu = createMenu(theWBName, -1, -1, 50);
97 int aTool = createTool(theWBName);
99 int aId = myActionsList.size();
100 myActionsList.append(theId);
101 SUIT_Desktop* aDesk = application()->desktop();
103 for (int i = 0; i < theKeys.count(); i++)
105 createAction(aId, theTip, theIcon, theTitle, theTip, aKeys, aDesk,
106 isCheckable, theReciever, theMember);
107 int aItemId = createMenu( aId, aMenu, -1, 10 );
108 int aToolId = createTool( aId, aTool );
111 //******************************************************
112 void NewGeom_Module::addEditCommand(const QString& theId,
113 const QString& theTitle,
114 const QString& theTip,
115 const QIcon& theIcon,
117 QObject* theReciever,
118 const char* theMember,
119 const QKeySequence& theKeys)
121 int aMenu = createMenu(tr( "MEN_DESK_EDIT" ), -1, -1);
123 int aId = myActionsList.size();
124 myActionsList.append(theId);
125 SUIT_Desktop* aDesk = application()->desktop();
127 for (int i = 0; i < theKeys.count(); i++)
129 createAction(aId, theTip, theIcon, theTitle, theTip, aKeys, aDesk,
130 isCheckable, theReciever, theMember);
131 createMenu( aId, aMenu, 10 );
134 //******************************************************
135 void NewGeom_Module::addEditMenuSeparator()
137 int aMenu = createMenu(tr( "MEN_DESK_EDIT" ), -1, -1);
138 createMenu( separator(), aMenu, -1, 10 );
141 //******************************************************
142 QMainWindow* NewGeom_Module::desktop() const
144 return application()->desktop();
147 //******************************************************
148 QString NewGeom_Module::commandId(const QAction* theCmd) const
150 int aId = actionId(theCmd);
151 if (aId < myActionsList.size())
152 return myActionsList[aId];
156 //******************************************************
157 QAction* NewGeom_Module::command(const QString& theId) const
159 int aId = myActionsList.indexOf(theId);
160 if ((aId != -1) && (aId < myActionsList.size())) {
166 //******************************************************
167 Handle(AIS_InteractiveContext) NewGeom_Module::AISContext() const
169 Handle(AIS_InteractiveContext) aContext;
170 SUIT_ViewManager* aMgr = application()->viewManager(OCCViewer_Viewer::Type());
172 OCCViewer_Viewer* aViewer = static_cast<OCCViewer_Viewer*>(aMgr->getViewModel());
173 aContext = aViewer->getAISContext();