1 // Copyright (C) 2006-2021 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);
63 void SuitWrapper::AssociateViewToWindow(QGraphicsView* gView, QWidget* viewWindow)
65 SalomeWrap_Module* module = dynamic_cast<SalomeWrap_Module*>(_wrapped);
66 QxScene_ViewWindow *svw = dynamic_cast<QxScene_ViewWindow*>(viewWindow);
68 module->AssociateViewToWindow(gView, svw);
69 WrapGraphicsView* wgv = dynamic_cast<WrapGraphicsView*>(gView);
71 QObject::disconnect(svw->toolMgr()->action(QxScene_ViewWindow::FitAllId),
72 SIGNAL(triggered(bool)),
73 svw, SLOT(onViewFitAll()));
74 QObject::connect(svw->toolMgr()->action(QxScene_ViewWindow::FitAllId),
75 SIGNAL(triggered(bool)),
76 wgv, SLOT(onViewFitAll()));
78 QObject::disconnect(svw->toolMgr()->action(QxScene_ViewWindow::FitRectId),
79 SIGNAL(triggered(bool)),
80 svw, SLOT(onViewFitArea()));
81 QObject::connect(svw->toolMgr()->action(QxScene_ViewWindow::FitRectId),
82 SIGNAL(triggered(bool)),
83 wgv, SLOT(onViewFitArea()));
85 QObject::disconnect(svw->toolMgr()->action(QxScene_ViewWindow::ZoomId),
86 SIGNAL(triggered(bool)),
87 svw, SLOT(onViewZoom()));
88 QObject::connect(svw->toolMgr()->action(QxScene_ViewWindow::ZoomId),
89 SIGNAL(triggered(bool)),
90 wgv, SLOT(onViewZoom()));
92 QObject::disconnect(svw->toolMgr()->action(QxScene_ViewWindow::PanId),
93 SIGNAL(triggered(bool)),
94 svw, SLOT(onViewPan()));
95 QObject::connect(svw->toolMgr()->action(QxScene_ViewWindow::PanId),
96 SIGNAL(triggered(bool)),
97 wgv, SLOT(onViewPan()));
99 QObject::disconnect(svw->toolMgr()->action(QxScene_ViewWindow::GlobalPanId),
100 SIGNAL(triggered(bool)),
101 svw, SLOT(onViewGlobalPan()));
102 QObject::connect(svw->toolMgr()->action(QxScene_ViewWindow::GlobalPanId),
103 SIGNAL(triggered(bool)),
104 wgv, SLOT(onViewGlobalPan()));
106 QObject::disconnect(svw->toolMgr()->action(QxScene_ViewWindow::ResetId),
107 SIGNAL(triggered(bool)),
108 svw, SLOT(onViewReset()));
109 QObject::connect(svw->toolMgr()->action(QxScene_ViewWindow::ResetId),
110 SIGNAL(triggered(bool)),
111 wgv, SLOT(onViewReset()));
114 QDockWidget* SuitWrapper::objectBrowser()
116 SalomeWrap_Module* module = dynamic_cast<SalomeWrap_Module*>(_wrapped);
117 return module->objectBrowser();
120 QAction* SuitWrapper::createAction(const int id,
121 const QString& toolTip,
124 const QString& status,
131 SalomeWrap_Module* module = dynamic_cast<SalomeWrap_Module*>(_wrapped);
132 return module->wCreateAction(id, toolTip, icon, menu, status, shortCut,
133 parent, checkable, receiver, member);
136 int SuitWrapper::createMenu(const QString& subMenu,
137 const int parentMenuId,
142 SalomeWrap_Module* module = dynamic_cast<SalomeWrap_Module*>(_wrapped);
143 return module->wCreateMenu(subMenu, parentMenuId, menuId, groupId, index);
146 int SuitWrapper::createMenu(const QString& subMenu,
147 const QString& parentMenu,
152 SalomeWrap_Module* module = dynamic_cast<SalomeWrap_Module*>(_wrapped);
153 return module->wCreateMenu(subMenu, parentMenu, menuId, groupId, index);
156 int SuitWrapper::createMenu(const int actionId,
161 SalomeWrap_Module* module = dynamic_cast<SalomeWrap_Module*>(_wrapped);
162 return module->wCreateMenu(actionId, menuId, groupId, index);
165 int SuitWrapper:: createMenu(const int actionId,
170 SalomeWrap_Module* module = dynamic_cast<SalomeWrap_Module*>(_wrapped);
171 return module->wCreateMenu(actionId, menu, groupId, index);
174 int SuitWrapper::createMenu(QAction* action,
180 SalomeWrap_Module* module = dynamic_cast<SalomeWrap_Module*>(_wrapped);
181 return module->wCreateMenu(action, menuId, actionId, groupId, index);
184 int SuitWrapper::createMenu(QAction* action,
190 SalomeWrap_Module* module = dynamic_cast<SalomeWrap_Module*>(_wrapped);
191 return module->wCreateMenu(action, menu, actionId, groupId, index);
194 int SuitWrapper::createTool(const QString& title, const QString& name)
196 SalomeWrap_Module* module = dynamic_cast<SalomeWrap_Module*>(_wrapped);
197 return module->wCreateTool(title, name);
200 int SuitWrapper::createTool(const int actionId,
204 SalomeWrap_Module* module = dynamic_cast<SalomeWrap_Module*>(_wrapped);
205 return module->wCreateTool(actionId, toolbarId, index);
208 int SuitWrapper::createTool(const int actionId,
209 const QString& toolbar,
212 SalomeWrap_Module* module = dynamic_cast<SalomeWrap_Module*>(_wrapped);
213 return module->wCreateTool(actionId, toolbar, index);
216 int SuitWrapper::createTool(QAction* action,
221 SalomeWrap_Module* module = dynamic_cast<SalomeWrap_Module*>(_wrapped);
222 return module->wCreateTool(action, toolbarId, actionId, index);
225 int SuitWrapper::createTool(QAction* action,
226 const QString& toolbar,
230 SalomeWrap_Module* module = dynamic_cast<SalomeWrap_Module*>(_wrapped);
231 return module->wCreateTool(action, toolbar, actionId, index);
234 QAction* SuitWrapper::separator()
236 return SalomeWrap_Module::wSeparator();
239 void SuitWrapper::setMenuShown(QAction* act, bool show)
241 SalomeWrap_Module* module = dynamic_cast<SalomeWrap_Module*>(_wrapped);
242 module->setMenuShown(act, show);
245 void SuitWrapper::setToolShown(QAction* act, bool show)
247 SalomeWrap_Module* module = dynamic_cast<SalomeWrap_Module*>(_wrapped);
248 module->setToolShown(act, show);
251 void SuitWrapper::createNewSchema(const QString& schemaName,
254 SalomeWrap_Module* module = dynamic_cast<SalomeWrap_Module*>(_wrapped);
255 module->getDataModel()->createNewSchema(schemaName, viewWindow);
258 bool SuitWrapper::renameSchema(const QString& oldName,
259 const QString& newName,
262 SalomeWrap_Module* module = dynamic_cast<SalomeWrap_Module*>(_wrapped);
263 return module->getDataModel()->renameSchema(oldName, newName, viewWindow);
266 bool SuitWrapper::deleteSchema(QWidget* viewWindow)
268 SalomeWrap_Module* module = dynamic_cast<SalomeWrap_Module*>(_wrapped);
269 return module->getDataModel()->deleteSchema(viewWindow);
272 void SuitWrapper::createNewRun(const QString& schemaName,
273 const QString& runName,
277 SalomeWrap_Module* module = dynamic_cast<SalomeWrap_Module*>(_wrapped);
278 module->getDataModel()->createNewRun(schemaName, runName, refWindow, viewWindow);
281 QStringList SuitWrapper::getQuickDirList()
284 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
286 dirList = resMgr->stringValue( "FileDlg", "QuickDirList" ).split( ';', QString::SkipEmptyParts );
290 void SuitWrapper::onHelpContextModule( const QString& theComponentName, const QString& theFileName, const QString& theContext )
292 LightApp_Application* app = (LightApp_Application*)( SUIT_Session::session()->activeApplication() );
294 app->onHelpContextModule( theComponentName, theFileName, theContext );