Version: 8.3.0
SalomeWrap_Module.cxx
Go to the documentation of this file.
1 // Copyright (C) 2006-2016 CEA/DEN, EDF R&D
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"
21 #include "SalomeWrap_DataModel.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 
39 using 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  return viewWindow->getViewManager()->study()->id();
80 }
81 
83 {
84  return getApp()->activeStudy()->id();
85 }
86 
88  if ( !getApp()->objectBrowser() )
89  return 0;
90 
91  QWidget* wid = getApp()->objectBrowser()->treeView();
92 
93  if ( !wid ) {
94  return 0;
95  };
96 
97  QDockWidget* dock = 0;
98  QWidget* w = wid->parentWidget();
99  while ( w && !dock ) {
100  dock = ::qobject_cast<QDockWidget*>( w );
101  w = w->parentWidget();
102  };
103 
104  return dock;
105 }
106 
107 
108 QAction* SalomeWrap_Module::wCreateAction(const int id,
109  const QString& toolTip,
110  const QIcon& icon,
111  const QString& menu,
112  const QString& status,
113  const int shortCut,
114  QObject* parent,
115  bool checkable,
116  QObject* receiver,
117  const char* member)
118 {
119  return createAction(id, toolTip, icon, menu, status, shortCut,
120  parent, checkable, receiver, member);
121 }
122 
123 int SalomeWrap_Module::wCreateMenu(const QString& subMenu,
124  const int parentMenuId,
125  const int menuId,
126  const int groupId,
127  const int index)
128 {
129  return createMenu(subMenu, parentMenuId, menuId, groupId, index);
130 }
131 
132 int SalomeWrap_Module::wCreateMenu(const QString& subMenu,
133  const QString& parentMenu,
134  const int menuId,
135  const int groupId,
136  const int index)
137 {
138  return createMenu(subMenu, parentMenu, menuId, groupId, index);
139 }
140 
141 int SalomeWrap_Module::wCreateMenu(const int actionId,
142  const int menuId,
143  const int groupId,
144  const int index)
145 {
146  return createMenu(actionId, menuId, groupId, index);
147 }
148 
149 int SalomeWrap_Module:: wCreateMenu(const int actionId,
150  const QString& menu,
151  const int groupId,
152  const int index)
153 {
154  return createMenu(actionId, menu, groupId, index);
155 }
156 
157 int SalomeWrap_Module::wCreateMenu(QAction* action,
158  const int menuId,
159  const int actionId,
160  const int groupId,
161  const int index)
162 {
163  return createMenu(action, menuId, actionId, groupId, index);
164 }
165 
166 int SalomeWrap_Module::wCreateMenu(QAction* action,
167  const QString& menu,
168  const int actionId,
169  const int groupId,
170  const int index)
171 {
172  return createMenu(action, menu, actionId, groupId, index);
173 }
174 
175 int SalomeWrap_Module::wCreateTool(const QString& title, const QString& name)
176 {
177  return createTool(title, name);
178 }
179 
180 int SalomeWrap_Module::wCreateTool(const int actionId,
181  const int toolbarId,
182  const int index)
183 {
184  return createTool(actionId, toolbarId, index);
185 }
186 
187 int SalomeWrap_Module::wCreateTool(const int actionId,
188  const QString& toolbar,
189  const int index)
190 {
191  return createTool(actionId, toolbar, index);
192 }
193 
194 int SalomeWrap_Module::wCreateTool(QAction* action,
195  const int toolbarId,
196  const int actionId,
197  const int index)
198 {
199  return createTool(action, toolbarId, actionId, index);
200 }
201 
202 int SalomeWrap_Module::wCreateTool(QAction* action,
203  const QString& toolbar,
204  const int actionId,
205  const int index)
206 {
207  return createTool(action, toolbar, actionId, index);
208 }
209 
211 {
212  return separator();
213 }
214 
216 {
217  return dynamic_cast<SalomeWrap_DataModel*>(dataModel());
218 }
219 
221 {
222  return new SalomeWrap_DataModel(this);
223 }