]> SALOME platform Git repositories - modules/yacs.git/blob - src/salomewrap/SuitWrapper.cxx
Salome HOME
mergefrom branch BR_V511_PR tag mergeto_trunk_03feb09
[modules/yacs.git] / src / salomewrap / SuitWrapper.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 /*!
20  *  only one declaration in src/genericgui,
21  *  implementations in salomewrap and standalonegui
22  */
23     
24 #include "SuitWrapper.hxx"
25 #include "WrapGraphicsView.hxx"
26
27 #include "SalomeWrap_Module.hxx"
28 #include "SalomeWrap_DataModel.hxx"
29
30 #include <SalomeApp_Module.h>
31 #include <QxScene_ViewManager.h>
32 #include <QxScene_ViewModel.h>
33 #include <QxScene_ViewWindow.h>
34 #include <QtxActionToolMgr.h>
35
36 #include <cassert>
37
38 //#define _DEVDEBUG_
39 #include "YacsTrace.hxx"
40
41 using namespace std;
42 using namespace YACS::HMI;
43
44 SuitWrapper::SuitWrapper(QObject* wrapped) : _wrapped(wrapped)
45 {
46 }
47
48 SuitWrapper::~SuitWrapper()
49 {
50 }
51
52 QWidget* SuitWrapper::getNewWindow(QGraphicsScene *scene)
53 {
54   SalomeWrap_Module* module = static_cast<SalomeWrap_Module*>(_wrapped);
55   return module->getNewWindow(scene);
56 }
57
58 /*!
59  * return studyId used in context delete when study is closed.
60  */
61 int SuitWrapper::AssociateViewToWindow(QGraphicsView* gView, QWidget* viewWindow)
62 {
63   SalomeWrap_Module* module = static_cast<SalomeWrap_Module*>(_wrapped);
64   QxScene_ViewWindow *svw = dynamic_cast<QxScene_ViewWindow*>(viewWindow);
65   assert(svw);
66   int studyId = module->AssociateViewToWindow(gView, svw);
67   WrapGraphicsView* wgv = dynamic_cast<WrapGraphicsView*>(gView);
68   assert(wgv);
69   QObject::disconnect(svw->toolMgr()->action(QxScene_ViewWindow::FitAllId),
70                       SIGNAL(triggered(bool)),
71                       svw, SLOT(onViewFitAll()));
72   QObject::connect(svw->toolMgr()->action(QxScene_ViewWindow::FitAllId),
73                    SIGNAL(triggered(bool)),
74                    wgv, SLOT(onViewFitAll()));
75
76   QObject::disconnect(svw->toolMgr()->action(QxScene_ViewWindow::FitRectId),
77                       SIGNAL(triggered(bool)),
78                       svw, SLOT(onViewFitArea()));
79   QObject::connect(svw->toolMgr()->action(QxScene_ViewWindow::FitRectId),
80                    SIGNAL(triggered(bool)),
81                    wgv, SLOT(onViewFitArea()));
82
83   QObject::disconnect(svw->toolMgr()->action(QxScene_ViewWindow::ZoomId),
84                       SIGNAL(triggered(bool)),
85                       svw, SLOT(onViewZoom()));
86   QObject::connect(svw->toolMgr()->action(QxScene_ViewWindow::ZoomId),
87                    SIGNAL(triggered(bool)),
88                    wgv, SLOT(onViewZoom()));
89
90   QObject::disconnect(svw->toolMgr()->action(QxScene_ViewWindow::PanId),
91                       SIGNAL(triggered(bool)),
92                       svw, SLOT(onViewPan()));
93   QObject::connect(svw->toolMgr()->action(QxScene_ViewWindow::PanId),
94                    SIGNAL(triggered(bool)),
95                    wgv, SLOT(onViewPan()));
96
97   QObject::disconnect(svw->toolMgr()->action(QxScene_ViewWindow::GlobalPanId),
98                       SIGNAL(triggered(bool)),
99                       svw, SLOT(onViewGlobalPan()));
100   QObject::connect(svw->toolMgr()->action(QxScene_ViewWindow::GlobalPanId),
101                    SIGNAL(triggered(bool)),
102                    wgv, SLOT(onViewGlobalPan()));
103
104   QObject::disconnect(svw->toolMgr()->action(QxScene_ViewWindow::ResetId),
105                       SIGNAL(triggered(bool)),
106                       svw, SLOT(onViewReset()));
107   QObject::connect(svw->toolMgr()->action(QxScene_ViewWindow::ResetId),
108                    SIGNAL(triggered(bool)),
109                    wgv, SLOT(onViewReset()));
110   return studyId;
111 }
112
113 int SuitWrapper::activeStudyId()
114 {
115   SalomeWrap_Module* module = static_cast<SalomeWrap_Module*>(_wrapped);
116   return module->activeStudyId();
117 }
118
119 QAction* SuitWrapper::createAction(const int id,
120                                     const QString& toolTip,
121                                     const QIcon& icon,
122                                     const QString& menu,
123                                     const QString& status,
124                                     const int shortCut,
125                                     QObject* parent,
126                                     bool checkable,
127                                     QObject* receiver,
128                                     const char* member)
129 {
130   SalomeWrap_Module* module = static_cast<SalomeWrap_Module*>(_wrapped);
131   return module->wCreateAction(id, toolTip, icon, menu, status, shortCut,
132                                parent, checkable, receiver, member);
133 }
134       
135 int SuitWrapper::createMenu(const QString& subMenu,
136                              const int parentMenuId,
137                              const int menuId,
138                              const int groupId,
139                              const int index)
140 {
141   SalomeWrap_Module* module = static_cast<SalomeWrap_Module*>(_wrapped);
142   return module->wCreateMenu(subMenu, parentMenuId, menuId, groupId, index);
143 }
144
145 int SuitWrapper::createMenu(const QString& subMenu,
146                              const QString& parentMenu,
147                              const int menuId,
148                              const int groupId,
149                              const int index)
150 {
151   SalomeWrap_Module* module = static_cast<SalomeWrap_Module*>(_wrapped);
152   return module->wCreateMenu(subMenu, parentMenu, menuId, groupId, index);
153 }
154
155 int SuitWrapper::createMenu(const int actionId,
156                              const int menuId,
157                              const int groupId,
158                              const int index)
159 {
160   SalomeWrap_Module* module = static_cast<SalomeWrap_Module*>(_wrapped);
161   return module->wCreateMenu(actionId, menuId, groupId, index);
162 }
163
164 int SuitWrapper:: createMenu(const int actionId,
165                              const QString& menu,
166                              const int groupId,
167                              const int index)
168 {
169   SalomeWrap_Module* module = static_cast<SalomeWrap_Module*>(_wrapped);
170   return module->wCreateMenu(actionId, menu, groupId, index);
171 }
172
173 int SuitWrapper::createMenu(QAction* action,
174                              const int menuId,
175                              const int actionId,
176                              const int groupId,
177                              const int index)
178 {
179   SalomeWrap_Module* module = static_cast<SalomeWrap_Module*>(_wrapped);
180   return module->wCreateMenu(action, menuId, actionId, groupId, index);
181 }
182
183 int SuitWrapper::createMenu(QAction* action,
184                              const QString& menu,
185                              const int actionId,
186                              const int groupId,
187                              const int index)
188 {
189   SalomeWrap_Module* module = static_cast<SalomeWrap_Module*>(_wrapped);
190   return module->wCreateMenu(action, menu, actionId, groupId, index);
191 }
192
193 int SuitWrapper::createTool(const QString& name)
194 {
195   SalomeWrap_Module* module = static_cast<SalomeWrap_Module*>(_wrapped);
196   return module->wCreateTool(name);
197 }
198
199 int SuitWrapper::createTool(const int actionId,
200                              const int toolbarId, 
201                              const int index)
202 {
203   SalomeWrap_Module* module = static_cast<SalomeWrap_Module*>(_wrapped);
204   return module->wCreateTool(actionId, toolbarId, index);
205 }
206
207 int SuitWrapper::createTool(const int actionId,
208                              const QString& toolbar,
209                              const int index)
210 {
211   SalomeWrap_Module* module = static_cast<SalomeWrap_Module*>(_wrapped);
212   return module->wCreateTool(actionId, toolbar, index);
213 }
214
215 int SuitWrapper::createTool(QAction* action, 
216                              const int toolbarId,
217                              const int actionId,
218                              const int index)
219 {
220   SalomeWrap_Module* module = static_cast<SalomeWrap_Module*>(_wrapped);
221   return module->wCreateTool(action, toolbarId, actionId, index);
222 }
223
224 int SuitWrapper::createTool(QAction* action,
225                              const QString& toolbar,
226                              const int actionId,
227                              const int index)
228 {
229   SalomeWrap_Module* module = static_cast<SalomeWrap_Module*>(_wrapped);
230   return module->wCreateTool(action, toolbar, actionId, index);
231 }
232
233 QAction* SuitWrapper::separator()
234 {
235   return SalomeWrap_Module::wSeparator();
236 }
237
238 void SuitWrapper::setMenuShown(QAction* act, bool show)
239 {
240   SalomeWrap_Module* module = static_cast<SalomeWrap_Module*>(_wrapped);
241   module->setMenuShown(act, show);
242 }
243
244 void SuitWrapper::setToolShown(QAction* act, bool show)
245 {
246   SalomeWrap_Module* module = static_cast<SalomeWrap_Module*>(_wrapped);
247   module->setToolShown(act, show);
248 }
249
250 void SuitWrapper::createNewSchema(const QString& schemaName,
251                                   QWidget* viewWindow)
252 {
253   SalomeWrap_Module* module = static_cast<SalomeWrap_Module*>(_wrapped);
254   module->getDataModel()->createNewSchema(schemaName, viewWindow);
255 }
256
257 bool SuitWrapper::renameSchema(const QString& oldName,
258                                const QString& newName,
259                                QWidget* viewWindow)
260 {
261   SalomeWrap_Module* module = static_cast<SalomeWrap_Module*>(_wrapped);
262   module->getDataModel()->renameSchema(oldName, newName, viewWindow);
263 }
264
265 void SuitWrapper::createNewRun(const QString& schemaName,
266                                const QString& runName,
267                                QWidget* refWindow,
268                                QWidget* viewWindow)
269 {
270   SalomeWrap_Module* module = static_cast<SalomeWrap_Module*>(_wrapped);
271   module->getDataModel()->createNewRun(schemaName, runName, refWindow, viewWindow);
272 }