]> SALOME platform Git repositories - modules/hydro.git/blob - src/HYDROGUI/HYDROGUI_Module.cxx
Salome HOME
Compilation by CMake.
[modules/hydro.git] / src / HYDROGUI / HYDROGUI_Module.cxx
1
2 #include <HYDROGUI_Module.h>
3 #include <LightApp_Application.h>
4 #include <LightApp_SelectionMgr.h>
5 #include <GraphicsView_PrsImage.h>
6 #include <GraphicsView_Viewer.h>
7 #include <GraphicsView_ViewFrame.h>
8 #include <GraphicsView_ViewPort.h>
9 #include <LightApp_GVSelector.h>
10 #include <SUIT_ViewManager.h>
11 #include <SUIT_Desktop.h>
12 #include <QApplication>
13 #include <HYDROGUI_InputPanel.h>
14 #include <HYDROGUI_ObjSelector.h>
15
16 extern "C" HYDRO_EXPORT CAM_Module* createModule()
17 {
18   return new HYDROGUI_Module();
19 }
20
21 HYDROGUI_Module::HYDROGUI_Module()
22 : LightApp_Module( "HYDRO GUI" )
23 {
24 }
25
26 HYDROGUI_Module::~HYDROGUI_Module()
27 {
28 }
29
30 void HYDROGUI_Module::initialize( CAM_Application* theApp )
31 {
32   LightApp_Module::initialize( theApp );
33
34   CreateActions();
35   CreateMenus();
36   CreatePopups();
37   CreateToolbars();
38
39   setMenuShown( false );
40
41   HYDROGUI_InputPanel* aDlg = new HYDROGUI_InputPanel( this, "Fuse Images" );
42   HYDROGUI_ObjSelector* aSel1 = new HYDROGUI_ObjSelector( this, aDlg );
43   HYDROGUI_ObjSelector* aSel2 = new HYDROGUI_ObjSelector( this, aDlg );
44   aDlg->addWidget( "Image 1", aSel1 );
45   aDlg->addWidget( "Image 2", aSel2 );
46   application()->desktop()->addDockWidget( Qt::RightDockWidgetArea, aDlg );
47
48   qApp->processEvents();
49 }
50
51 bool HYDROGUI_Module::activateModule( SUIT_Study* theStudy )
52 {
53   setMenuShown( true );
54   return LightApp_Module::activateModule( theStudy );
55 }
56
57 void HYDROGUI_Module::windows( QMap<int, int>& theMap ) const
58 {
59   theMap.clear();
60   theMap.insert( LightApp_Application::WT_LogWindow,     Qt::BottomDockWidgetArea );
61   theMap.insert( LightApp_Application::WT_ObjectBrowser, Qt::LeftDockWidgetArea   );
62 }
63
64 void HYDROGUI_Module::viewManagers( QStringList& theTypesList ) const
65 {
66   theTypesList << GraphicsView_Viewer::Type();
67 }
68
69 void HYDROGUI_Module::onViewManagerAdded( SUIT_ViewManager* theMgr )
70 {
71   LightApp_Module::onViewManagerAdded( theMgr );
72   connect( theMgr, SIGNAL( viewCreated( SUIT_ViewWindow* ) ),
73            this, SLOT( onViewWindowAdded( SUIT_ViewWindow* ) ) );
74 }
75
76 void HYDROGUI_Module::onViewWindowAdded( SUIT_ViewWindow* theWnd )
77 {
78   GraphicsView_ViewFrame* aViewFrame = dynamic_cast<GraphicsView_ViewFrame*>( theWnd );
79
80   LightApp_SelectionMgr* aSelMgr = getApp()->selectionMgr();
81   LightApp_GVSelector* aSelector = new LightApp_GVSelector( aViewFrame->getViewer(), aSelMgr );
82
83   GraphicsView_ViewPort* aViewPort = aViewFrame->getViewPort();
84
85   GraphicsView_PrsImage* aPrs1 = new GraphicsView_PrsImage();
86   QImage anImage1( "W:/Work/HYDRO/data/samples/1.bmp" );
87   aPrs1->setImage( anImage1 );
88   aPrs1->setName( "example_1" );
89   aPrs1->compute();
90   aViewPort->addItem( aPrs1 );
91
92   GraphicsView_PrsImage* aPrs2 = new GraphicsView_PrsImage();
93   QImage anImage2( "W:/Work/HYDRO/data/samples/2.bmp" );
94   aPrs2->setImage( anImage2 );
95   aPrs2->setName( "example_2" );
96   aPrs2->setRotationAngle( 30 );
97   aPrs2->setPosition( 200, 50 );
98   aPrs2->compute();
99   aViewPort->addItem( aPrs2 );
100   
101   //qApp->processEvents();
102   aViewPort->fitAll();
103 }