1 // Copyright (C) 2006-2008 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.
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
19 #include "SalomeWrap_Module.hxx"
20 #include "SalomeWrap_DataModel.hxx"
22 #include <SalomeApp_Application.h>
23 #include <QxScene_ViewManager.h>
24 #include <QxScene_ViewModel.h>
25 #include <QxScene_ViewWindow.h>
26 #include <CAM_DataModel.h>
27 #include <SUIT_Study.h>
32 #include "YacsTrace.hxx"
36 SalomeWrap_Module::SalomeWrap_Module(const char* name) :
37 SalomeApp_Module( name )
39 _mapOfViewWindow.clear();
42 /*! create a new QxScene_ViewWindow unless the active view is an empty
43 * QxScene_ViewWindow automatically created when SALOME module is loaded.
45 QxScene_ViewWindow* SalomeWrap_Module::getNewWindow(QGraphicsScene *scene)
47 SUIT_ViewManager *svm = 0;
48 if (_mapOfViewWindow.empty()) // --- reuse already created view manager
49 svm = getApp()->getViewManager(QxScene_Viewer::Type(), true);
51 svm = getApp()->createViewManager(QxScene_Viewer::Type());
52 SUIT_ViewWindow* svw = svm->getActiveView();
53 QxScene_ViewWindow *aView = 0;
54 QGraphicsScene* existingScene = 0;
55 if (!svw) svw = svm->createViewWindow();
56 if (svw) aView = dynamic_cast<QxScene_ViewWindow*>(svw);
57 if (aView) existingScene = aView->getScene();
60 svw = svm->createViewWindow();
61 if (svw) aView = dynamic_cast<QxScene_ViewWindow*>(svw);
64 aView->setScene(scene);
65 _mapOfViewWindow[scene] = aView;
69 int SalomeWrap_Module::AssociateViewToWindow(QGraphicsView* gView,
70 QxScene_ViewWindow* viewWindow)
72 viewWindow->setSceneView(gView);
73 viewWindow->setCentralWidget(gView);
74 return viewWindow->getViewManager()->study()->id();
77 int SalomeWrap_Module::activeStudyId()
79 return getApp()->activeStudy()->id();
82 QAction* SalomeWrap_Module::wCreateAction(const int id,
83 const QString& toolTip,
86 const QString& status,
93 return createAction(id, toolTip, icon, menu, status, shortCut,
94 parent, checkable, receiver, member);
97 int SalomeWrap_Module::wCreateMenu(const QString& subMenu,
98 const int parentMenuId,
103 return createMenu(subMenu, parentMenuId, menuId, groupId, index);
106 int SalomeWrap_Module::wCreateMenu(const QString& subMenu,
107 const QString& parentMenu,
112 return createMenu(subMenu, parentMenu, menuId, groupId, index);
115 int SalomeWrap_Module::wCreateMenu(const int actionId,
120 return createMenu(actionId, menuId, groupId, index);
123 int SalomeWrap_Module:: wCreateMenu(const int actionId,
128 return createMenu(actionId, menu, groupId, index);
131 int SalomeWrap_Module::wCreateMenu(QAction* action,
137 return createMenu(action, menuId, actionId, groupId, index);
140 int SalomeWrap_Module::wCreateMenu(QAction* action,
146 return createMenu(action, menu, actionId, groupId, index);
149 int SalomeWrap_Module::wCreateTool(const QString& name)
151 return createTool(name);
154 int SalomeWrap_Module::wCreateTool(const int actionId,
158 return createTool(actionId, toolbarId, index);
161 int SalomeWrap_Module::wCreateTool(const int actionId,
162 const QString& toolbar,
165 return createTool(actionId, toolbar, index);
168 int SalomeWrap_Module::wCreateTool(QAction* action,
173 return createTool(action, toolbarId, actionId, index);
176 int SalomeWrap_Module::wCreateTool(QAction* action,
177 const QString& toolbar,
181 return createTool(action, toolbar, actionId, index);
184 QAction* SalomeWrap_Module::wSeparator()
189 SalomeWrap_DataModel* SalomeWrap_Module::getDataModel()
191 return dynamic_cast<SalomeWrap_DataModel*>(dataModel());
194 CAM_DataModel* SalomeWrap_Module::createDataModel()
196 return new SalomeWrap_DataModel(this);