1 // Copyright (C) 2006-2016 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 void 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 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()));
117 QDockWidget* SuitWrapper::objectBrowser()
119 SalomeWrap_Module* module = dynamic_cast<SalomeWrap_Module*>(_wrapped);
120 return module->objectBrowser();
123 QAction* SuitWrapper::createAction(const int id,
124 const QString& toolTip,
127 const QString& status,
134 SalomeWrap_Module* module = dynamic_cast<SalomeWrap_Module*>(_wrapped);
135 return module->wCreateAction(id, toolTip, icon, menu, status, shortCut,
136 parent, checkable, receiver, member);
139 int SuitWrapper::createMenu(const QString& subMenu,
140 const int parentMenuId,
145 SalomeWrap_Module* module = dynamic_cast<SalomeWrap_Module*>(_wrapped);
146 return module->wCreateMenu(subMenu, parentMenuId, menuId, groupId, index);
149 int SuitWrapper::createMenu(const QString& subMenu,
150 const QString& parentMenu,
155 SalomeWrap_Module* module = dynamic_cast<SalomeWrap_Module*>(_wrapped);
156 return module->wCreateMenu(subMenu, parentMenu, menuId, groupId, index);
159 int SuitWrapper::createMenu(const int actionId,
164 SalomeWrap_Module* module = dynamic_cast<SalomeWrap_Module*>(_wrapped);
165 return module->wCreateMenu(actionId, menuId, groupId, index);
168 int SuitWrapper:: createMenu(const int actionId,
173 SalomeWrap_Module* module = dynamic_cast<SalomeWrap_Module*>(_wrapped);
174 return module->wCreateMenu(actionId, menu, groupId, index);
177 int SuitWrapper::createMenu(QAction* action,
183 SalomeWrap_Module* module = dynamic_cast<SalomeWrap_Module*>(_wrapped);
184 return module->wCreateMenu(action, menuId, actionId, groupId, index);
187 int SuitWrapper::createMenu(QAction* action,
193 SalomeWrap_Module* module = dynamic_cast<SalomeWrap_Module*>(_wrapped);
194 return module->wCreateMenu(action, menu, actionId, groupId, index);
197 int SuitWrapper::createTool(const QString& title, const QString& name)
199 SalomeWrap_Module* module = dynamic_cast<SalomeWrap_Module*>(_wrapped);
200 return module->wCreateTool(title, name);
203 int SuitWrapper::createTool(const int actionId,
207 SalomeWrap_Module* module = dynamic_cast<SalomeWrap_Module*>(_wrapped);
208 return module->wCreateTool(actionId, toolbarId, index);
211 int SuitWrapper::createTool(const int actionId,
212 const QString& toolbar,
215 SalomeWrap_Module* module = dynamic_cast<SalomeWrap_Module*>(_wrapped);
216 return module->wCreateTool(actionId, toolbar, index);
219 int SuitWrapper::createTool(QAction* action,
224 SalomeWrap_Module* module = dynamic_cast<SalomeWrap_Module*>(_wrapped);
225 return module->wCreateTool(action, toolbarId, actionId, index);
228 int SuitWrapper::createTool(QAction* action,
229 const QString& toolbar,
233 SalomeWrap_Module* module = dynamic_cast<SalomeWrap_Module*>(_wrapped);
234 return module->wCreateTool(action, toolbar, actionId, index);
237 QAction* SuitWrapper::separator()
239 return SalomeWrap_Module::wSeparator();
242 void SuitWrapper::setMenuShown(QAction* act, bool show)
244 SalomeWrap_Module* module = dynamic_cast<SalomeWrap_Module*>(_wrapped);
245 module->setMenuShown(act, show);
248 void SuitWrapper::setToolShown(QAction* act, bool show)
250 SalomeWrap_Module* module = dynamic_cast<SalomeWrap_Module*>(_wrapped);
251 module->setToolShown(act, show);
254 void SuitWrapper::createNewSchema(const QString& schemaName,
257 SalomeWrap_Module* module = dynamic_cast<SalomeWrap_Module*>(_wrapped);
258 module->getDataModel()->createNewSchema(schemaName, viewWindow);
261 bool SuitWrapper::renameSchema(const QString& oldName,
262 const QString& newName,
265 SalomeWrap_Module* module = dynamic_cast<SalomeWrap_Module*>(_wrapped);
266 return module->getDataModel()->renameSchema(oldName, newName, viewWindow);
269 bool SuitWrapper::deleteSchema(QWidget* viewWindow)
271 SalomeWrap_Module* module = dynamic_cast<SalomeWrap_Module*>(_wrapped);
272 return module->getDataModel()->deleteSchema(viewWindow);
275 void SuitWrapper::createNewRun(const QString& schemaName,
276 const QString& runName,
280 SalomeWrap_Module* module = dynamic_cast<SalomeWrap_Module*>(_wrapped);
281 module->getDataModel()->createNewRun(schemaName, runName, refWindow, viewWindow);
284 QStringList SuitWrapper::getQuickDirList()
287 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
289 dirList = resMgr->stringValue( "FileDlg", "QuickDirList" ).split( ';', QString::SkipEmptyParts );
293 void SuitWrapper::onHelpContextModule( const QString& theComponentName, const QString& theFileName, const QString& theContext )
295 LightApp_Application* app = (LightApp_Application*)( SUIT_Session::session()->activeApplication() );
297 app->onHelpContextModule( theComponentName, theFileName, theContext );