Version: 9.16.0
SalomeWrap_Module.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
20#include "SalomeWrap_Module.hxx"
22
23#include <SalomeApp_Application.h>
24#include <QxScene_ViewManager.h>
25#include <QxScene_ViewModel.h>
26#include <QxScene_ViewWindow.h>
27#include <CAM_DataModel.h>
28#include <SUIT_Study.h>
29
30#include <SUIT_DataBrowser.h>
31#include <QtxTreeView.h>
32#include <SUIT_DataObject.h>
33
34#include <cassert>
35
36//#define _DEVDEBUG_
37#include "YacsTrace.hxx"
38
39using namespace std;
40
42 SalomeApp_Module( name )
43{
44 _mapOfViewWindow.clear();
45}
46
51{
52 SUIT_ViewManager *svm = 0;
53 if (_mapOfViewWindow.empty()) // --- reuse already created view manager
54 svm = getApp()->getViewManager(QxScene_Viewer::Type(), true);
55 else
56 svm = getApp()->createViewManager(QxScene_Viewer::Type());
57 SUIT_ViewWindow* svw = svm->getActiveView();
58 QxScene_ViewWindow *aView = 0;
59 QGraphicsScene* existingScene = 0;
60 if (!svw) svw = svm->createViewWindow();
61 if (svw) aView = dynamic_cast<QxScene_ViewWindow*>(svw);
62 if (aView) existingScene = aView->getScene();
63 if (existingScene)
64 {
65 svw = svm->createViewWindow();
66 if (svw) aView = dynamic_cast<QxScene_ViewWindow*>(svw);
67 }
68 YASSERT(aView);
69 aView->setScene(scene);
70 _mapOfViewWindow[scene] = aView;
71 return aView;
72}
73
75 QxScene_ViewWindow* viewWindow)
76{
77 viewWindow->setSceneView(gView);
78 viewWindow->setCentralWidget(gView);
79}
80
82 if ( !getApp()->objectBrowser() )
83 return 0;
84
85 QWidget* wid = getApp()->objectBrowser()->treeView();
86
87 if ( !wid ) {
88 return 0;
89 };
90
91 QDockWidget* dock = 0;
92 QWidget* w = wid->parentWidget();
93 while ( w && !dock ) {
94 dock = ::qobject_cast<QDockWidget*>( w );
95 w = w->parentWidget();
96 };
97
98 return dock;
99}
100
101
103 const QString& toolTip,
104 const QIcon& icon,
105 const QString& menu,
106 const QString& status,
107 const int shortCut,
108 QObject* parent,
109 bool checkable,
110 QObject* receiver,
111 const char* member)
112{
113 return createAction(id, toolTip, icon, menu, status, shortCut,
114 parent, checkable, receiver, member);
115}
116
117int SalomeWrap_Module::wCreateMenu(const QString& subMenu,
118 const int parentMenuId,
119 const int menuId,
120 const int groupId,
121 const int index)
122{
123 return createMenu(subMenu, parentMenuId, menuId, groupId, index);
124}
125
126int SalomeWrap_Module::wCreateMenu(const QString& subMenu,
127 const QString& parentMenu,
128 const int menuId,
129 const int groupId,
130 const int index)
131{
132 return createMenu(subMenu, parentMenu, menuId, groupId, index);
133}
134
135int SalomeWrap_Module::wCreateMenu(const int actionId,
136 const int menuId,
137 const int groupId,
138 const int index)
139{
140 return createMenu(actionId, menuId, groupId, index);
141}
142
143int SalomeWrap_Module:: wCreateMenu(const int actionId,
144 const QString& menu,
145 const int groupId,
146 const int index)
147{
148 return createMenu(actionId, menu, groupId, index);
149}
150
152 const int menuId,
153 const int actionId,
154 const int groupId,
155 const int index)
156{
157 return createMenu(action, menuId, actionId, groupId, index);
158}
159
161 const QString& menu,
162 const int actionId,
163 const int groupId,
164 const int index)
165{
166 return createMenu(action, menu, actionId, groupId, index);
167}
168
169int SalomeWrap_Module::wCreateTool(const QString& title, const QString& name)
170{
171 return createTool(title, name);
172}
173
174int SalomeWrap_Module::wCreateTool(const int actionId,
175 const int toolbarId,
176 const int index)
177{
178 return createTool(actionId, toolbarId, index);
179}
180
181int SalomeWrap_Module::wCreateTool(const int actionId,
182 const QString& toolbar,
183 const int index)
184{
185 return createTool(actionId, toolbar, index);
186}
187
189 const int toolbarId,
190 const int actionId,
191 const int index)
192{
193 return createTool(action, toolbarId, actionId, index);
194}
195
197 const QString& toolbar,
198 const int actionId,
199 const int index)
200{
201 return createTool(action, toolbar, actionId, index);
202}
203
205{
206 return separator();
207}
208
210{
211 return dynamic_cast<SalomeWrap_DataModel*>(dataModel());
212}
213
215{
216 return new SalomeWrap_DataModel(this);
217}
#define YASSERT(val)
YASSERT macro is always defined, used like assert, but throw a YACS::Exception instead of abort.
Definition: YacsTrace.hxx:59
std::map< QGraphicsScene *, QxScene_ViewWindow * > _mapOfViewWindow
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()
SalomeWrap_Module(const char *name)
virtual CAM_DataModel * createDataModel()
int wCreateTool(const QString &title, const QString &name=QString())
void AssociateViewToWindow(QGraphicsView *gView, QxScene_ViewWindow *viewWindow)