Version: 9.16.0
SuitWrapper.cxx
Go to the documentation of this file.
1// Copyright (C) 2006-2026 CEA, EDF
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, or (at your option) any later version.
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
25#include "SuitWrapper.hxx"
26#include "WrapGraphicsView.hxx"
27
28#include "SalomeWrap_Module.hxx"
30
31#include <SalomeApp_Module.h>
32#include <SalomeApp_Application.h>
33#include "SUIT_Session.h"
34#include "SUIT_ResourceMgr.h"
35
36#include <QxScene_ViewManager.h>
37#include <QxScene_ViewModel.h>
38#include <QxScene_ViewWindow.h>
39#include <QtxActionToolMgr.h>
40
41#include <cassert>
42
43//#define _DEVDEBUG_
44#include "YacsTrace.hxx"
45
46using namespace std;
47using namespace YACS::HMI;
48
49SuitWrapper::SuitWrapper(QObject* wrapped) : _wrapped(wrapped)
50{
51}
52
54{
55}
56
58{
59 SalomeWrap_Module* module = dynamic_cast<SalomeWrap_Module*>(_wrapped);
60 return module->getNewWindow(scene);
61}
62
64{
65 SalomeWrap_Module* module = dynamic_cast<SalomeWrap_Module*>(_wrapped);
66 QxScene_ViewWindow *svw = dynamic_cast<QxScene_ViewWindow*>(viewWindow);
67 YASSERT(svw);
68 module->AssociateViewToWindow(gView, svw);
69 WrapGraphicsView* wgv = dynamic_cast<WrapGraphicsView*>(gView);
70 YASSERT(wgv);
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()));
77
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()));
84
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()));
91
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()));
98
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()));
105
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()));
112}
113
115{
116 SalomeWrap_Module* module = dynamic_cast<SalomeWrap_Module*>(_wrapped);
117 return module->objectBrowser();
118}
119
120QAction* SuitWrapper::createAction(const int id,
121 const QString& toolTip,
122 const QIcon& icon,
123 const QString& menu,
124 const QString& status,
125 const int shortCut,
126 QObject* parent,
127 bool checkable,
128 QObject* receiver,
129 const char* member)
130{
131 SalomeWrap_Module* module = dynamic_cast<SalomeWrap_Module*>(_wrapped);
132 return module->wCreateAction(id, toolTip, icon, menu, status, shortCut,
133 parent, checkable, receiver, member);
134}
135
136int SuitWrapper::createMenu(const QString& subMenu,
137 const int parentMenuId,
138 const int menuId,
139 const int groupId,
140 const int index)
141{
142 SalomeWrap_Module* module = dynamic_cast<SalomeWrap_Module*>(_wrapped);
143 return module->wCreateMenu(subMenu, parentMenuId, menuId, groupId, index);
144}
145
146int SuitWrapper::createMenu(const QString& subMenu,
147 const QString& parentMenu,
148 const int menuId,
149 const int groupId,
150 const int index)
151{
152 SalomeWrap_Module* module = dynamic_cast<SalomeWrap_Module*>(_wrapped);
153 return module->wCreateMenu(subMenu, parentMenu, menuId, groupId, index);
154}
155
156int SuitWrapper::createMenu(const int actionId,
157 const int menuId,
158 const int groupId,
159 const int index)
160{
161 SalomeWrap_Module* module = dynamic_cast<SalomeWrap_Module*>(_wrapped);
162 return module->wCreateMenu(actionId, menuId, groupId, index);
163}
164
165int SuitWrapper:: createMenu(const int actionId,
166 const QString& menu,
167 const int groupId,
168 const int index)
169{
170 SalomeWrap_Module* module = dynamic_cast<SalomeWrap_Module*>(_wrapped);
171 return module->wCreateMenu(actionId, menu, groupId, index);
172}
173
174int SuitWrapper::createMenu(QAction* action,
175 const int menuId,
176 const int actionId,
177 const int groupId,
178 const int index)
179{
180 SalomeWrap_Module* module = dynamic_cast<SalomeWrap_Module*>(_wrapped);
181 return module->wCreateMenu(action, menuId, actionId, groupId, index);
182}
183
184int SuitWrapper::createMenu(QAction* action,
185 const QString& menu,
186 const int actionId,
187 const int groupId,
188 const int index)
189{
190 SalomeWrap_Module* module = dynamic_cast<SalomeWrap_Module*>(_wrapped);
191 return module->wCreateMenu(action, menu, actionId, groupId, index);
192}
193
194int SuitWrapper::createTool(const QString& title, const QString& name)
195{
196 SalomeWrap_Module* module = dynamic_cast<SalomeWrap_Module*>(_wrapped);
197 return module->wCreateTool(title, name);
198}
199
200int SuitWrapper::createTool(const int actionId,
201 const int toolbarId,
202 const int index)
203{
204 SalomeWrap_Module* module = dynamic_cast<SalomeWrap_Module*>(_wrapped);
205 return module->wCreateTool(actionId, toolbarId, index);
206}
207
208int SuitWrapper::createTool(const int actionId,
209 const QString& toolbar,
210 const int index)
211{
212 SalomeWrap_Module* module = dynamic_cast<SalomeWrap_Module*>(_wrapped);
213 return module->wCreateTool(actionId, toolbar, index);
214}
215
216int SuitWrapper::createTool(QAction* action,
217 const int toolbarId,
218 const int actionId,
219 const int index)
220{
221 SalomeWrap_Module* module = dynamic_cast<SalomeWrap_Module*>(_wrapped);
222 return module->wCreateTool(action, toolbarId, actionId, index);
223}
224
225int SuitWrapper::createTool(QAction* action,
226 const QString& toolbar,
227 const int actionId,
228 const int index)
229{
230 SalomeWrap_Module* module = dynamic_cast<SalomeWrap_Module*>(_wrapped);
231 return module->wCreateTool(action, toolbar, actionId, index);
232}
233
235{
237}
238
239void SuitWrapper::setMenuShown(QAction* act, bool show)
240{
241 SalomeWrap_Module* module = dynamic_cast<SalomeWrap_Module*>(_wrapped);
242 module->setMenuShown(act, show);
243}
244
245void SuitWrapper::setToolShown(QAction* act, bool show)
246{
247 SalomeWrap_Module* module = dynamic_cast<SalomeWrap_Module*>(_wrapped);
248 module->setToolShown(act, show);
249}
250
251void SuitWrapper::createNewSchema(const QString& schemaName,
252 QWidget* viewWindow)
253{
254 SalomeWrap_Module* module = dynamic_cast<SalomeWrap_Module*>(_wrapped);
255 module->getDataModel()->createNewSchema(schemaName, viewWindow);
256}
257
258bool SuitWrapper::renameSchema(const QString& oldName,
259 const QString& newName,
260 QWidget* viewWindow)
261{
262 SalomeWrap_Module* module = dynamic_cast<SalomeWrap_Module*>(_wrapped);
263 return module->getDataModel()->renameSchema(oldName, newName, viewWindow);
264}
265
267{
268 SalomeWrap_Module* module = dynamic_cast<SalomeWrap_Module*>(_wrapped);
269 return module->getDataModel()->deleteSchema(viewWindow);
270}
271
272void SuitWrapper::createNewRun(const QString& schemaName,
273 const QString& runName,
274 QWidget* refWindow,
275 QWidget* viewWindow)
276{
277 SalomeWrap_Module* module = dynamic_cast<SalomeWrap_Module*>(_wrapped);
278 module->getDataModel()->createNewRun(schemaName, runName, refWindow, viewWindow);
279}
280
282{
283 QStringList dirList;
284 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
285 if ( resMgr )
286 dirList = resMgr->stringValue( "FileDlg", "QuickDirList" ).split( ';', QString::SkipEmptyParts );
287 return dirList;
288}
289
290void SuitWrapper::onHelpContextModule( const QString& theComponentName, const QString& theFileName, const QString& theContext )
291{
292 LightApp_Application* app = (LightApp_Application*)( SUIT_Session::session()->activeApplication() );
293 if(app)
294 app->onHelpContextModule( theComponentName, theFileName, theContext );
295}
296
#define YASSERT(val)
YASSERT macro is always defined, used like assert, but throw a YACS::Exception instead of abort.
Definition: YacsTrace.hxx:59
virtual void createNewSchema(const QString &schemaName, QWidget *viewWindow)
virtual bool renameSchema(const QString &oldName, const QString &newName, QWidget *viewWindow)
virtual void createNewRun(const QString &schemaName, const QString &runName, QWidget *refWindow, QWidget *viewWindow)
virtual bool deleteSchema(QWidget *viewWindow)
SalomeWrap_DataModel * getDataModel()
int wCreateMenu(const QString &subMenu, const int parentMenuId, const int menuId=-1, const int groupId=-1, const int index=-1)
QxScene_ViewWindow * getNewWindow(QGraphicsScene *scene)
static QAction * wSeparator()
QAction * wCreateAction(const int id, const QString &toolTip, const QIcon &icon, const QString &menu, const QString &status, const int shortCut, QObject *parent=0, bool checkable=false, QObject *receiver=0, const char *member=0)
QDockWidget * objectBrowser()
int wCreateTool(const QString &title, const QString &name=QString())
void AssociateViewToWindow(QGraphicsView *gView, QxScene_ViewWindow *viewWindow)
void AssociateViewToWindow(QGraphicsView *gView, QWidget *viewWindow)
Definition: SuitWrapper.cxx:63
void createNewRun(const QString &schemaName, const QString &runName, QWidget *refWindow, QWidget *viewWindow)
bool deleteSchema(QWidget *viewWindow)
QAction * createAction(const int id, const QString &toolTip, const QIcon &icon, const QString &menu, const QString &status, const int shortCut, QObject *parent=0, bool checkable=false, QObject *receiver=0, const char *member=0)
int createMenu(const QString &subMenu, const int parentMenuId, const int menuId=-1, const int groupId=-1, const int index=-1)
virtual void onHelpContextModule(const QString &, const QString &, const QString &=QString())
void setMenuShown(QAction *act, bool show)
QDockWidget * objectBrowser()
QWidget * getNewWindow(QGraphicsScene *scene)
Definition: SuitWrapper.cxx:57
static QAction * separator()
void createNewSchema(const QString &schemaName, QWidget *viewWindow)
int createTool(const QString &title, const QString &name=QString())
bool renameSchema(const QString &oldName, const QString &newName, QWidget *viewWindow)
QStringList getQuickDirList()
void setToolShown(QAction *act, bool show)