1 // Copyright (C) 2006-2014 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, or (at your option) any later version.
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
21 * only one declaration in src/genericgui,
22 * implementations in salomewrap and standalonegui
25 #include "SuitWrapper.hxx"
26 #include "WrapGraphicsView.hxx"
28 #include "SalomeWrap_Module.hxx"
29 #include "SalomeWrap_DataModel.hxx"
31 #include <SalomeApp_Module.h>
32 #include <SalomeApp_Application.h>
33 #include "SUIT_Session.h"
34 #include "SUIT_ResourceMgr.h"
36 #include <QxScene_ViewManager.h>
37 #include <QxScene_ViewModel.h>
38 #include <QxScene_ViewWindow.h>
39 #include <QtxActionToolMgr.h>
44 #include "YacsTrace.hxx"
47 using namespace YACS::HMI;
49 SuitWrapper::SuitWrapper(QObject* wrapped) : _wrapped(wrapped)
53 SuitWrapper::~SuitWrapper()
57 QWidget* SuitWrapper::getNewWindow(QGraphicsScene *scene)
59 SalomeWrap_Module* module = dynamic_cast<SalomeWrap_Module*>(_wrapped);
60 return module->getNewWindow(scene);
64 * return studyId used in context delete when study is closed.
66 int SuitWrapper::AssociateViewToWindow(QGraphicsView* gView, QWidget* viewWindow)
68 SalomeWrap_Module* module = dynamic_cast<SalomeWrap_Module*>(_wrapped);
69 QxScene_ViewWindow *svw = dynamic_cast<QxScene_ViewWindow*>(viewWindow);
71 int studyId = module->AssociateViewToWindow(gView, svw);
72 WrapGraphicsView* wgv = dynamic_cast<WrapGraphicsView*>(gView);
74 QObject::disconnect(svw->toolMgr()->action(QxScene_ViewWindow::FitAllId),
75 SIGNAL(triggered(bool)),
76 svw, SLOT(onViewFitAll()));
77 QObject::connect(svw->toolMgr()->action(QxScene_ViewWindow::FitAllId),
78 SIGNAL(triggered(bool)),
79 wgv, SLOT(onViewFitAll()));
81 QObject::disconnect(svw->toolMgr()->action(QxScene_ViewWindow::FitRectId),
82 SIGNAL(triggered(bool)),
83 svw, SLOT(onViewFitArea()));
84 QObject::connect(svw->toolMgr()->action(QxScene_ViewWindow::FitRectId),
85 SIGNAL(triggered(bool)),
86 wgv, SLOT(onViewFitArea()));
88 QObject::disconnect(svw->toolMgr()->action(QxScene_ViewWindow::ZoomId),
89 SIGNAL(triggered(bool)),
90 svw, SLOT(onViewZoom()));
91 QObject::connect(svw->toolMgr()->action(QxScene_ViewWindow::ZoomId),
92 SIGNAL(triggered(bool)),
93 wgv, SLOT(onViewZoom()));
95 QObject::disconnect(svw->toolMgr()->action(QxScene_ViewWindow::PanId),
96 SIGNAL(triggered(bool)),
97 svw, SLOT(onViewPan()));
98 QObject::connect(svw->toolMgr()->action(QxScene_ViewWindow::PanId),
99 SIGNAL(triggered(bool)),
100 wgv, SLOT(onViewPan()));
102 QObject::disconnect(svw->toolMgr()->action(QxScene_ViewWindow::GlobalPanId),
103 SIGNAL(triggered(bool)),
104 svw, SLOT(onViewGlobalPan()));
105 QObject::connect(svw->toolMgr()->action(QxScene_ViewWindow::GlobalPanId),
106 SIGNAL(triggered(bool)),
107 wgv, SLOT(onViewGlobalPan()));
109 QObject::disconnect(svw->toolMgr()->action(QxScene_ViewWindow::ResetId),
110 SIGNAL(triggered(bool)),
111 svw, SLOT(onViewReset()));
112 QObject::connect(svw->toolMgr()->action(QxScene_ViewWindow::ResetId),
113 SIGNAL(triggered(bool)),
114 wgv, SLOT(onViewReset()));
118 int SuitWrapper::activeStudyId()
120 SalomeWrap_Module* module = dynamic_cast<SalomeWrap_Module*>(_wrapped);
121 return module->activeStudyId();
124 QDockWidget* SuitWrapper::objectBrowser()
126 SalomeWrap_Module* module = dynamic_cast<SalomeWrap_Module*>(_wrapped);
127 return module->objectBrowser();
130 QAction* SuitWrapper::createAction(const int id,
131 const QString& toolTip,
134 const QString& status,
141 SalomeWrap_Module* module = dynamic_cast<SalomeWrap_Module*>(_wrapped);
142 return module->wCreateAction(id, toolTip, icon, menu, status, shortCut,
143 parent, checkable, receiver, member);
146 int SuitWrapper::createMenu(const QString& subMenu,
147 const int parentMenuId,
152 SalomeWrap_Module* module = dynamic_cast<SalomeWrap_Module*>(_wrapped);
153 return module->wCreateMenu(subMenu, parentMenuId, menuId, groupId, index);
156 int SuitWrapper::createMenu(const QString& subMenu,
157 const QString& parentMenu,
162 SalomeWrap_Module* module = dynamic_cast<SalomeWrap_Module*>(_wrapped);
163 return module->wCreateMenu(subMenu, parentMenu, menuId, groupId, index);
166 int SuitWrapper::createMenu(const int actionId,
171 SalomeWrap_Module* module = dynamic_cast<SalomeWrap_Module*>(_wrapped);
172 return module->wCreateMenu(actionId, menuId, groupId, index);
175 int SuitWrapper:: createMenu(const int actionId,
180 SalomeWrap_Module* module = dynamic_cast<SalomeWrap_Module*>(_wrapped);
181 return module->wCreateMenu(actionId, menu, groupId, index);
184 int SuitWrapper::createMenu(QAction* action,
190 SalomeWrap_Module* module = dynamic_cast<SalomeWrap_Module*>(_wrapped);
191 return module->wCreateMenu(action, menuId, actionId, groupId, index);
194 int SuitWrapper::createMenu(QAction* action,
200 SalomeWrap_Module* module = dynamic_cast<SalomeWrap_Module*>(_wrapped);
201 return module->wCreateMenu(action, menu, actionId, groupId, index);
204 int SuitWrapper::createTool(const QString& name)
206 SalomeWrap_Module* module = dynamic_cast<SalomeWrap_Module*>(_wrapped);
207 return module->wCreateTool(name);
210 int SuitWrapper::createTool(const int actionId,
214 SalomeWrap_Module* module = dynamic_cast<SalomeWrap_Module*>(_wrapped);
215 return module->wCreateTool(actionId, toolbarId, index);
218 int SuitWrapper::createTool(const int actionId,
219 const QString& toolbar,
222 SalomeWrap_Module* module = dynamic_cast<SalomeWrap_Module*>(_wrapped);
223 return module->wCreateTool(actionId, toolbar, index);
226 int SuitWrapper::createTool(QAction* action,
231 SalomeWrap_Module* module = dynamic_cast<SalomeWrap_Module*>(_wrapped);
232 return module->wCreateTool(action, toolbarId, actionId, index);
235 int SuitWrapper::createTool(QAction* action,
236 const QString& toolbar,
240 SalomeWrap_Module* module = dynamic_cast<SalomeWrap_Module*>(_wrapped);
241 return module->wCreateTool(action, toolbar, actionId, index);
244 QAction* SuitWrapper::separator()
246 return SalomeWrap_Module::wSeparator();
249 void SuitWrapper::setMenuShown(QAction* act, bool show)
251 SalomeWrap_Module* module = dynamic_cast<SalomeWrap_Module*>(_wrapped);
252 module->setMenuShown(act, show);
255 void SuitWrapper::setToolShown(QAction* act, bool show)
257 SalomeWrap_Module* module = dynamic_cast<SalomeWrap_Module*>(_wrapped);
258 module->setToolShown(act, show);
261 void SuitWrapper::createNewSchema(const QString& schemaName,
264 SalomeWrap_Module* module = dynamic_cast<SalomeWrap_Module*>(_wrapped);
265 module->getDataModel()->createNewSchema(schemaName, viewWindow);
268 bool SuitWrapper::renameSchema(const QString& oldName,
269 const QString& newName,
272 SalomeWrap_Module* module = dynamic_cast<SalomeWrap_Module*>(_wrapped);
273 return module->getDataModel()->renameSchema(oldName, newName, viewWindow);
276 bool SuitWrapper::deleteSchema(QWidget* viewWindow)
278 SalomeWrap_Module* module = dynamic_cast<SalomeWrap_Module*>(_wrapped);
279 return module->getDataModel()->deleteSchema(viewWindow);
282 void SuitWrapper::createNewRun(const QString& schemaName,
283 const QString& runName,
287 SalomeWrap_Module* module = dynamic_cast<SalomeWrap_Module*>(_wrapped);
288 module->getDataModel()->createNewRun(schemaName, runName, refWindow, viewWindow);
291 QStringList SuitWrapper::getQuickDirList()
294 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
296 dirList = resMgr->stringValue( "FileDlg", "QuickDirList" ).split( ';', QString::SkipEmptyParts );
300 void SuitWrapper::onHelpContextModule( const QString& theComponentName, const QString& theFileName, const QString& theContext )
302 LightApp_Application* app = (LightApp_Application*)( SUIT_Session::session()->activeApplication() );
304 app->onHelpContextModule( theComponentName, theFileName, theContext );