]> SALOME platform Git repositories - modules/hydro.git/blob - src/HYDROGUI/HYDROGUI_Module.cxx
Salome HOME
1) Data model draft.
[modules/hydro.git] / src / HYDROGUI / HYDROGUI_Module.cxx
1 // Copyright (C) 2007-2013  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
10 //
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 // Lesser General Public License for more details.
15 //
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 //
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22
23 #include "HYDROGUI_Module.h"
24
25 #include "HYDROGUI_DataModel.h"
26 #include "HYDROGUI_InputPanel.h"
27 #include "HYDROGUI_ObjSelector.h"
28 #include "HYDROGUI_Operations.h"
29
30 #include <GraphicsView_PrsImage.h>
31 #include <GraphicsView_ViewFrame.h>
32 #include <GraphicsView_ViewPort.h>
33 #include <GraphicsView_Viewer.h>
34
35 #include <LightApp_Application.h>
36 #include <LightApp_GVSelector.h>
37 #include <LightApp_SelectionMgr.h>
38
39 #include <SUIT_Desktop.h>
40 #include <SUIT_Study.h>
41 #include <SUIT_ViewManager.h>
42
43 #include <QApplication>
44
45 extern "C" HYDRO_EXPORT CAM_Module* createModule()
46 {
47   return new HYDROGUI_Module();
48 }
49
50 HYDROGUI_Module::HYDROGUI_Module()
51 : LightApp_Module( "HYDRO GUI" )
52 {
53 }
54
55 HYDROGUI_Module::~HYDROGUI_Module()
56 {
57 }
58
59 int HYDROGUI_Module::getStudyId() const
60 {
61   LightApp_Application* anApp = getApp();
62   return anApp ? anApp->activeStudy()->id() : 0;
63 }
64
65 void HYDROGUI_Module::initialize( CAM_Application* theApp )
66 {
67   printf( "Initialization of the HYDROGUI module\n" );
68   LightApp_Module::initialize( theApp );
69
70   CreateActions();
71   CreateMenus();
72   CreatePopups();
73   CreateToolbars();
74
75   setMenuShown( false );
76
77   //startOperation( ImportImageId );
78   startOperation( FuseId );
79 }
80
81 bool HYDROGUI_Module::activateModule( SUIT_Study* theStudy )
82 {
83   setMenuShown( true );
84   return LightApp_Module::activateModule( theStudy );
85 }
86
87 void HYDROGUI_Module::windows( QMap<int, int>& theMap ) const
88 {
89   theMap.clear();
90   theMap.insert( LightApp_Application::WT_LogWindow,     Qt::BottomDockWidgetArea );
91   theMap.insert( LightApp_Application::WT_ObjectBrowser, Qt::LeftDockWidgetArea   );
92 }
93
94 void HYDROGUI_Module::viewManagers( QStringList& theTypesList ) const
95 {
96   theTypesList << GraphicsView_Viewer::Type();
97 }
98
99 HYDROGUI_DataModel* HYDROGUI_Module::getModel() const
100 {
101   return (HYDROGUI_DataModel*)dataModel();
102 }
103
104 CAM_DataModel* HYDROGUI_Module::createDataModel()
105 {
106   return new HYDROGUI_DataModel( this );
107 }
108
109 void HYDROGUI_Module::onViewManagerAdded( SUIT_ViewManager* theMgr )
110 {
111   LightApp_Module::onViewManagerAdded( theMgr );
112   connect( theMgr, SIGNAL( viewCreated( SUIT_ViewWindow* ) ),
113            this, SLOT( onViewWindowAdded( SUIT_ViewWindow* ) ) );
114 }
115
116 void HYDROGUI_Module::onViewWindowAdded( SUIT_ViewWindow* theWnd )
117 {
118   GraphicsView_ViewFrame* aViewFrame = dynamic_cast<GraphicsView_ViewFrame*>( theWnd );
119
120   LightApp_SelectionMgr* aSelMgr = getApp()->selectionMgr();
121   LightApp_GVSelector* aSelector = new LightApp_GVSelector( aViewFrame->getViewer(), aSelMgr );
122
123   GraphicsView_ViewPort* aViewPort = aViewFrame->getViewPort();
124
125   GraphicsView_PrsImage* aPrs1 = new GraphicsView_PrsImage();
126   QImage anImage1( "W:/Work/HYDRO/data/samples/1.bmp" );
127   aPrs1->setImage( anImage1 );
128   aPrs1->setName( "example_1" );
129   aPrs1->compute();
130   aViewPort->addItem( aPrs1 );
131
132   GraphicsView_PrsImage* aPrs2 = new GraphicsView_PrsImage();
133   QImage anImage2( "W:/Work/HYDRO/data/samples/2.bmp" );
134   aPrs2->setImage( anImage2 );
135   aPrs2->setName( "example_2" );
136   aPrs2->setRotationAngle( 30 );
137   aPrs2->setPosition( 200, 50 );
138   aPrs2->compute();
139   aViewPort->addItem( aPrs2 );
140   
141   //qApp->processEvents();
142   aViewPort->fitAll();
143 }