Salome HOME
basic implementation of images operations support
[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 #include <HYDROGUI_Operations.h>
16
17 extern "C" HYDRO_EXPORT CAM_Module* createModule()
18 {
19   return new HYDROGUI_Module();
20 }
21
22 HYDROGUI_Module::HYDROGUI_Module()
23 : LightApp_Module( "HYDRO GUI" )
24 {
25 }
26
27 HYDROGUI_Module::~HYDROGUI_Module()
28 {
29 }
30
31 void HYDROGUI_Module::initialize( CAM_Application* theApp )
32 {
33   printf( "Initialization of the HYDROGUI module\n" );
34   LightApp_Module::initialize( theApp );
35
36   CreateActions();
37   CreateMenus();
38   CreatePopups();
39   CreateToolbars();
40
41   setMenuShown( false );
42
43   //startOperation( ImportImageId );
44   startOperation( FuseId );
45 }
46
47 bool HYDROGUI_Module::activateModule( SUIT_Study* theStudy )
48 {
49   setMenuShown( true );
50   return LightApp_Module::activateModule( theStudy );
51 }
52
53 void HYDROGUI_Module::windows( QMap<int, int>& theMap ) const
54 {
55   theMap.clear();
56   theMap.insert( LightApp_Application::WT_LogWindow,     Qt::BottomDockWidgetArea );
57   theMap.insert( LightApp_Application::WT_ObjectBrowser, Qt::LeftDockWidgetArea   );
58 }
59
60 void HYDROGUI_Module::viewManagers( QStringList& theTypesList ) const
61 {
62   theTypesList << GraphicsView_Viewer::Type();
63 }
64
65 void HYDROGUI_Module::onViewManagerAdded( SUIT_ViewManager* theMgr )
66 {
67   LightApp_Module::onViewManagerAdded( theMgr );
68   connect( theMgr, SIGNAL( viewCreated( SUIT_ViewWindow* ) ),
69            this, SLOT( onViewWindowAdded( SUIT_ViewWindow* ) ) );
70 }
71
72 void HYDROGUI_Module::onViewWindowAdded( SUIT_ViewWindow* theWnd )
73 {
74   GraphicsView_ViewFrame* aViewFrame = dynamic_cast<GraphicsView_ViewFrame*>( theWnd );
75
76   LightApp_SelectionMgr* aSelMgr = getApp()->selectionMgr();
77   LightApp_GVSelector* aSelector = new LightApp_GVSelector( aViewFrame->getViewer(), aSelMgr );
78
79   GraphicsView_ViewPort* aViewPort = aViewFrame->getViewPort();
80
81   GraphicsView_PrsImage* aPrs1 = new GraphicsView_PrsImage();
82   QImage anImage1( "W:/Work/HYDRO/data/samples/1.bmp" );
83   aPrs1->setImage( anImage1 );
84   aPrs1->setName( "example_1" );
85   aPrs1->compute();
86   aViewPort->addItem( aPrs1 );
87
88   GraphicsView_PrsImage* aPrs2 = new GraphicsView_PrsImage();
89   QImage anImage2( "W:/Work/HYDRO/data/samples/2.bmp" );
90   aPrs2->setImage( anImage2 );
91   aPrs2->setName( "example_2" );
92   aPrs2->setRotationAngle( 30 );
93   aPrs2->setPosition( 200, 50 );
94   aPrs2->compute();
95   aViewPort->addItem( aPrs2 );
96   
97   //qApp->processEvents();
98   aViewPort->fitAll();
99 }