]> SALOME platform Git repositories - modules/yacs.git/blob - src/salomewrap/SalomeWrap_Module.cxx
Salome HOME
mergefrom branch BR_V511_PR tag mergeto_trunk_03feb09
[modules/yacs.git] / src / salomewrap / SalomeWrap_Module.cxx
1 //  Copyright (C) 2006-2008  CEA/DEN, EDF R&D
2 //
3 //  This library is free software; you can redistribute it and/or
4 //  modify it under the terms of the GNU Lesser General Public
5 //  License as published by the Free Software Foundation; either
6 //  version 2.1 of the License.
7 //
8 //  This library is distributed in the hope that it will be useful,
9 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
10 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 //  Lesser General Public License for more details.
12 //
13 //  You should have received a copy of the GNU Lesser General Public
14 //  License along with this library; if not, write to the Free Software
15 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 //  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19 #include "SalomeWrap_Module.hxx"
20 #include "SalomeWrap_DataModel.hxx"
21
22 #include <SalomeApp_Application.h>
23 #include <QxScene_ViewManager.h>
24 #include <QxScene_ViewModel.h>
25 #include <QxScene_ViewWindow.h>
26 #include <CAM_DataModel.h>
27 #include <SUIT_Study.h>
28
29 #include <cassert>
30
31 //#define _DEVDEBUG_
32 #include "YacsTrace.hxx"
33
34 using namespace std;
35
36 SalomeWrap_Module::SalomeWrap_Module(const char* name) :
37   SalomeApp_Module( name )
38 {
39   _mapOfViewWindow.clear();
40 }
41
42 /*! create a new QxScene_ViewWindow unless the active view is an empty
43  *  QxScene_ViewWindow automatically created when SALOME module is loaded.
44  */
45 QxScene_ViewWindow* SalomeWrap_Module::getNewWindow(QGraphicsScene *scene)
46 {
47   SUIT_ViewManager *svm = 0;
48   if (_mapOfViewWindow.empty()) // --- reuse already created view manager 
49     svm = getApp()->getViewManager(QxScene_Viewer::Type(), true);
50   else
51     svm = getApp()->createViewManager(QxScene_Viewer::Type());
52   SUIT_ViewWindow* svw = svm->getActiveView();
53   QxScene_ViewWindow *aView = 0;
54   QGraphicsScene* existingScene = 0;
55   if (!svw) svw = svm->createViewWindow();
56   if (svw) aView = dynamic_cast<QxScene_ViewWindow*>(svw);
57   if (aView) existingScene = aView->getScene();
58   if (existingScene)
59     {
60       svw = svm->createViewWindow();
61       if (svw) aView = dynamic_cast<QxScene_ViewWindow*>(svw);
62     }
63   assert(aView);
64   aView->setScene(scene);
65   _mapOfViewWindow[scene] = aView;
66   return aView;
67 }
68
69 int SalomeWrap_Module::AssociateViewToWindow(QGraphicsView* gView,
70                                              QxScene_ViewWindow* viewWindow)
71 {
72   viewWindow->setSceneView(gView);
73   viewWindow->setCentralWidget(gView);
74   return viewWindow->getViewManager()->study()->id();
75 }
76
77 int SalomeWrap_Module::activeStudyId()
78 {
79   return getApp()->activeStudy()->id();
80 }
81
82 QAction* SalomeWrap_Module::wCreateAction(const int id,
83                                           const QString& toolTip,
84                                           const QIcon& icon,
85                                           const QString& menu,
86                                           const QString& status,
87                                           const int shortCut,
88                                           QObject* parent,
89                                           bool checkable,
90                                           QObject* receiver,
91                                           const char* member)
92 {
93   return createAction(id, toolTip, icon, menu, status, shortCut,
94                       parent, checkable, receiver, member);
95 }
96       
97 int SalomeWrap_Module::wCreateMenu(const QString& subMenu,
98                                    const int parentMenuId,
99                                    const int menuId,
100                                    const int groupId,
101                                    const int index)
102 {
103   return createMenu(subMenu, parentMenuId, menuId, groupId, index);
104 }
105
106 int SalomeWrap_Module::wCreateMenu(const QString& subMenu,
107                                    const QString& parentMenu,
108                                    const int menuId,
109                                    const int groupId,
110                                    const int index)
111 {
112   return createMenu(subMenu, parentMenu, menuId, groupId, index);
113 }
114
115 int SalomeWrap_Module::wCreateMenu(const int actionId,
116                                    const int menuId,
117                                    const int groupId,
118                                    const int index)
119 {
120   return createMenu(actionId, menuId, groupId, index);
121 }
122
123 int SalomeWrap_Module:: wCreateMenu(const int actionId,
124                                     const QString& menu,
125                                     const int groupId,
126                                     const int index)
127 {
128   return createMenu(actionId, menu, groupId, index);
129 }
130
131 int SalomeWrap_Module::wCreateMenu(QAction* action,
132                                    const int menuId,
133                                    const int actionId,
134                                    const int groupId,
135                                    const int index)
136 {
137   return createMenu(action, menuId, actionId, groupId, index);
138 }
139
140 int SalomeWrap_Module::wCreateMenu(QAction* action,
141                                    const QString& menu,
142                                    const int actionId,
143                                    const int groupId,
144                                    const int index)
145 {
146   return createMenu(action, menu, actionId, groupId, index);
147 }
148
149 int SalomeWrap_Module::wCreateTool(const QString& name)
150 {
151   return createTool(name);
152 }
153
154 int SalomeWrap_Module::wCreateTool(const int actionId,
155                                    const int toolbarId, 
156                                    const int index)
157 {
158   return createTool(actionId, toolbarId, index);
159 }
160
161 int SalomeWrap_Module::wCreateTool(const int actionId,
162                                    const QString& toolbar,
163                                    const int index)
164 {
165   return createTool(actionId, toolbar, index);
166 }
167
168 int SalomeWrap_Module::wCreateTool(QAction* action, 
169                                    const int toolbarId,
170                                    const int actionId,
171                                    const int index)
172 {
173   return createTool(action, toolbarId, actionId, index);
174 }
175
176 int SalomeWrap_Module::wCreateTool(QAction* action,
177                                    const QString& toolbar,
178                                    const int actionId,
179                                    const int index)
180 {
181   return createTool(action, toolbar, actionId, index);
182 }
183
184 QAction* SalomeWrap_Module::wSeparator()
185 {
186   return separator();
187 }
188
189 SalomeWrap_DataModel* SalomeWrap_Module::getDataModel()
190 {
191   return dynamic_cast<SalomeWrap_DataModel*>(dataModel());
192 }
193
194 CAM_DataModel* SalomeWrap_Module::createDataModel()
195 {
196   return new SalomeWrap_DataModel(this);
197 }