]> SALOME platform Git repositories - modules/shaper.git/blob - src/NewGeom/NewGeom_Module.cpp
Salome HOME
Connect operations to SALOME (Issue #31)
[modules/shaper.git] / src / NewGeom / NewGeom_Module.cpp
1
2
3 #include "NewGeom_Module.h"
4 #include "NewGeom_DataModel.h"
5
6 #include <XGUI_Workshop.h>
7
8 #include <LightApp_Application.h>
9 #include <OCCViewer_ViewModel.h>
10 #include <SUIT_Desktop.h>
11 #include <QtxActionMenuMgr.h>
12
13
14 extern "C" {
15   NewGeom_EXPORT CAM_Module* createModule() {
16     return new NewGeom_Module();
17   }
18   
19   NewGeom_EXPORT char* getModuleVersion() {
20     return "0.0";
21   }
22 }
23
24
25 //******************************************************
26 NewGeom_Module::NewGeom_Module()
27 : LightApp_Module( "NewGeom" )
28 {
29   myWorkshop = new XGUI_Workshop(this);
30 }
31
32 //******************************************************
33 NewGeom_Module::~NewGeom_Module()
34 {
35 }
36
37 //******************************************************
38 void NewGeom_Module::initialize(CAM_Application* theApp)
39 {
40   LightApp_Module::initialize(theApp);
41   
42   myWorkshop->startApplication();
43 }
44
45 //******************************************************
46 void NewGeom_Module::windows(QMap<int, int>& theWndMap) const
47 {
48   theWndMap.insert( LightApp_Application::WT_PyConsole, Qt::BottomDockWidgetArea );
49 }
50
51 //******************************************************
52 void NewGeom_Module::viewManagers(QStringList& theList) const
53 {
54   theList.append( OCCViewer_Viewer::Type() );
55 }
56
57 //******************************************************
58 bool NewGeom_Module::activateModule(SUIT_Study* theStudy)
59 {
60   bool isDone = LightApp_Module::activateModule(theStudy);
61   if (isDone) {
62     setMenuShown( true );
63     setToolShown( true );
64   }
65   return isDone;
66 }
67
68 //******************************************************
69 bool NewGeom_Module::deactivateModule(SUIT_Study* theStudy)
70 {
71   setMenuShown( false );
72   setToolShown( false );
73   return LightApp_Module::deactivateModule(theStudy);
74 }
75
76 //******************************************************
77 CAM_DataModel* NewGeom_Module::createDataModel()
78 {
79   return new NewGeom_DataModel( this );
80 }
81
82 //******************************************************
83 void NewGeom_Module::addFeature(const QString& theWBName,
84                                 const QString& theId, 
85                                 const QString& theTitle, 
86                                 const QString& theTip,
87                                 const QIcon& theIcon, 
88                                 bool isCheckable,
89                                 QObject* theReciever,
90                                 const char* theMember,
91                                 const QKeySequence& theKeys)
92 {
93   int aMenu = createMenu(theWBName, -1, -1, 50);
94   int aTool = createTool(theWBName);
95
96   int aId = myActionsList.size();
97   myActionsList.append(theId);
98   SUIT_Desktop* aDesk = application()->desktop();
99   int aKeys = 0;
100   for (int i = 0; i < theKeys.count(); i++) 
101     aKeys += theKeys[i];
102   createAction(aId, theTip, theIcon, theTitle, theTip, aKeys, aDesk, 
103                isCheckable, theReciever, theMember);
104   int aItemId = createMenu( aId,  aMenu, -1, 10 );
105   int aToolId = createTool( aId, aTool );
106 }
107
108 //******************************************************
109 void NewGeom_Module::addEditCommand(const QString& theId,
110                                     const QString& theTitle,
111                                     const QString& theTip,
112                                     const QIcon& theIcon, 
113                                     bool isCheckable,
114                                     QObject* theReciever,
115                                     const char* theMember,
116                                     const QKeySequence& theKeys)
117 {
118   int aMenu = createMenu(tr( "MEN_DESK_EDIT" ), -1, -1);
119
120   int aId = myActionsList.size();
121   myActionsList.append(theId);
122   SUIT_Desktop* aDesk = application()->desktop();
123   int aKeys = 0;
124   for (int i = 0; i < theKeys.count(); i++) 
125     aKeys += theKeys[i];
126   createAction(aId, theTip, theIcon, theTitle, theTip, aKeys, aDesk, 
127                isCheckable, theReciever, theMember);
128   createMenu( aId, aMenu, 10 );
129 }
130
131 //******************************************************
132 void NewGeom_Module::addEditMenuSeparator()
133 {
134   int aMenu = createMenu(tr( "MEN_DESK_EDIT" ), -1, -1);
135   createMenu( separator(), aMenu, -1, 10 );
136 }
137
138 //******************************************************
139 QMainWindow* NewGeom_Module::desktop() const
140 {
141   return application()->desktop();
142 }
143
144 //******************************************************
145 QString NewGeom_Module::commandId(const QAction* theCmd) const
146 {
147   int aId = actionId(theCmd);
148   if (aId < myActionsList.size())
149     return myActionsList[aId];
150   return QString();
151 }
152
153 //******************************************************
154 QAction* NewGeom_Module::command(const QString& theId) const
155 {
156   int aId = myActionsList.indexOf(theId);
157   if ((aId != -1) && (aId < myActionsList.size())) {
158     return action(aId);
159   }
160   return 0;
161 }