1 // Copyright (C) 2006-2008 CEA/DEN, EDF R&D
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.
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.
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
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 * only one declaration in src/genericgui,
21 * implementations in salomewrap and standalonegui
24 #include "SuitWrapper.hxx"
25 #include "WrapGraphicsView.hxx"
27 #include "SalomeWrap_Module.hxx"
28 #include "SalomeWrap_DataModel.hxx"
30 #include <SalomeApp_Module.h>
31 #include <QxScene_ViewManager.h>
32 #include <QxScene_ViewModel.h>
33 #include <QxScene_ViewWindow.h>
34 #include <QtxActionToolMgr.h>
39 #include "YacsTrace.hxx"
42 using namespace YACS::HMI;
44 SuitWrapper::SuitWrapper(QObject* wrapped) : _wrapped(wrapped)
48 SuitWrapper::~SuitWrapper()
52 QWidget* SuitWrapper::getNewWindow(QGraphicsScene *scene)
54 SalomeWrap_Module* module = static_cast<SalomeWrap_Module*>(_wrapped);
55 return module->getNewWindow(scene);
59 * return studyId used in context delete when study is closed.
61 int SuitWrapper::AssociateViewToWindow(QGraphicsView* gView, QWidget* viewWindow)
63 SalomeWrap_Module* module = static_cast<SalomeWrap_Module*>(_wrapped);
64 QxScene_ViewWindow *svw = dynamic_cast<QxScene_ViewWindow*>(viewWindow);
66 int studyId = module->AssociateViewToWindow(gView, svw);
67 WrapGraphicsView* wgv = dynamic_cast<WrapGraphicsView*>(gView);
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()));
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()));
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()));
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()));
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()));
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()));
113 int SuitWrapper::activeStudyId()
115 SalomeWrap_Module* module = static_cast<SalomeWrap_Module*>(_wrapped);
116 return module->activeStudyId();
119 QAction* SuitWrapper::createAction(const int id,
120 const QString& toolTip,
123 const QString& status,
130 SalomeWrap_Module* module = static_cast<SalomeWrap_Module*>(_wrapped);
131 return module->wCreateAction(id, toolTip, icon, menu, status, shortCut,
132 parent, checkable, receiver, member);
135 int SuitWrapper::createMenu(const QString& subMenu,
136 const int parentMenuId,
141 SalomeWrap_Module* module = static_cast<SalomeWrap_Module*>(_wrapped);
142 return module->wCreateMenu(subMenu, parentMenuId, menuId, groupId, index);
145 int SuitWrapper::createMenu(const QString& subMenu,
146 const QString& parentMenu,
151 SalomeWrap_Module* module = static_cast<SalomeWrap_Module*>(_wrapped);
152 return module->wCreateMenu(subMenu, parentMenu, menuId, groupId, index);
155 int SuitWrapper::createMenu(const int actionId,
160 SalomeWrap_Module* module = static_cast<SalomeWrap_Module*>(_wrapped);
161 return module->wCreateMenu(actionId, menuId, groupId, index);
164 int SuitWrapper:: createMenu(const int actionId,
169 SalomeWrap_Module* module = static_cast<SalomeWrap_Module*>(_wrapped);
170 return module->wCreateMenu(actionId, menu, groupId, index);
173 int SuitWrapper::createMenu(QAction* action,
179 SalomeWrap_Module* module = static_cast<SalomeWrap_Module*>(_wrapped);
180 return module->wCreateMenu(action, menuId, actionId, groupId, index);
183 int SuitWrapper::createMenu(QAction* action,
189 SalomeWrap_Module* module = static_cast<SalomeWrap_Module*>(_wrapped);
190 return module->wCreateMenu(action, menu, actionId, groupId, index);
193 int SuitWrapper::createTool(const QString& name)
195 SalomeWrap_Module* module = static_cast<SalomeWrap_Module*>(_wrapped);
196 return module->wCreateTool(name);
199 int SuitWrapper::createTool(const int actionId,
203 SalomeWrap_Module* module = static_cast<SalomeWrap_Module*>(_wrapped);
204 return module->wCreateTool(actionId, toolbarId, index);
207 int SuitWrapper::createTool(const int actionId,
208 const QString& toolbar,
211 SalomeWrap_Module* module = static_cast<SalomeWrap_Module*>(_wrapped);
212 return module->wCreateTool(actionId, toolbar, index);
215 int SuitWrapper::createTool(QAction* action,
220 SalomeWrap_Module* module = static_cast<SalomeWrap_Module*>(_wrapped);
221 return module->wCreateTool(action, toolbarId, actionId, index);
224 int SuitWrapper::createTool(QAction* action,
225 const QString& toolbar,
229 SalomeWrap_Module* module = static_cast<SalomeWrap_Module*>(_wrapped);
230 return module->wCreateTool(action, toolbar, actionId, index);
233 QAction* SuitWrapper::separator()
235 return SalomeWrap_Module::wSeparator();
238 void SuitWrapper::setMenuShown(QAction* act, bool show)
240 SalomeWrap_Module* module = static_cast<SalomeWrap_Module*>(_wrapped);
241 module->setMenuShown(act, show);
244 void SuitWrapper::setToolShown(QAction* act, bool show)
246 SalomeWrap_Module* module = static_cast<SalomeWrap_Module*>(_wrapped);
247 module->setToolShown(act, show);
250 void SuitWrapper::createNewSchema(const QString& schemaName,
253 SalomeWrap_Module* module = static_cast<SalomeWrap_Module*>(_wrapped);
254 module->getDataModel()->createNewSchema(schemaName, viewWindow);
257 bool SuitWrapper::renameSchema(const QString& oldName,
258 const QString& newName,
261 SalomeWrap_Module* module = static_cast<SalomeWrap_Module*>(_wrapped);
262 module->getDataModel()->renameSchema(oldName, newName, viewWindow);
265 void SuitWrapper::createNewRun(const QString& schemaName,
266 const QString& runName,
270 SalomeWrap_Module* module = static_cast<SalomeWrap_Module*>(_wrapped);
271 module->getDataModel()->createNewRun(schemaName, runName, refWindow, viewWindow);