]> SALOME platform Git repositories - modules/gui.git/blob - src/SVTK/SVTK_MainWindow.h
Salome HOME
45f525f288a80383d17d685f385a7f606576b555
[modules/gui.git] / src / SVTK / SVTK_MainWindow.h
1 #ifndef SVTK_MAINWINDOW_H
2 #define SVTK_MAINWINDOW_H
3
4 #ifdef WIN32
5 #pragma warning( disable:4251 )
6 #endif
7
8 #include "SVTK.h"
9 #include "SVTK_Selection.h"
10
11 #include <vtkSmartPointer.h>
12
13 #include <qmainwindow.h>
14
15 class QtxAction;
16
17 class vtkObject;
18 class vtkRenderer;
19 class vtkRenderWindow;
20 class vtkInteractorStyle;
21 class vtkRenderWindowInteractor;
22
23 class SUIT_ResourceMgr;
24 class SUIT_ViewWindow;
25
26 class SVTK_RenderWindowInteractor;
27 class SVTK_NonIsometricDlg;
28 class SVTK_CubeAxesActor2D;
29 class SVTK_CubeAxesDlg;
30
31 class VTKViewer_Trihedron;
32 class VTKViewer_Transform;
33 class VTKViewer_Actor;
34
35 class SVTK_Renderer;
36 class SVTK_Selector;
37
38
39 //----------------------------------------------------------------------------
40 //! The class is a container for #SVTK_RenderWindowInteractor.
41 /*!
42   The class contains #SVTK_RenderWindowInteractor instance and
43   adds predefined viewer actions and toolbar for user interaction.
44 */
45 class SVTK_EXPORT SVTK_MainWindow: public QMainWindow
46 {
47   Q_OBJECT;
48
49 public:
50   SVTK_MainWindow(QWidget* theParent, 
51                   const char* theName,
52                   SUIT_ResourceMgr* theResourceMgr,
53                   SUIT_ViewWindow* theViewWindow);
54   
55   //! To initialize the class
56   virtual
57   void
58   Initialize(SVTK_RenderWindowInteractor* theInteractor);
59
60   virtual
61   ~SVTK_MainWindow();
62
63   //----------------------------------------------------------------------------
64   //! Get used #SVTK_RenderWindowInteractor
65   SVTK_RenderWindowInteractor*
66   GetInteractor();
67
68   //! Get used #vtkRenderWindowInteractor (obsolete)
69   vtkRenderWindowInteractor*
70   getInteractor();
71
72   //! Get used #vtkRenderWindow (obsolete)
73   vtkRenderWindow*
74   getRenderWindow();
75
76   //! To repaint the view
77   void
78   Repaint(bool theUpdateTrihedron = true);
79
80   //! To invoke a VTK event on #SVTK_RenderWindowInteractor instance
81   void
82   InvokeEvent(unsigned long theEvent, void* theCallData);
83
84   //----------------------------------------------------------------------------
85   //! Redirect the request to #SVTK_RenderWindowInteractor::GetInteractorStyle
86   vtkInteractorStyle* 
87   GetInteractorStyle();
88
89   //! Redirect the request to #SVTK_RenderWindowInteractor::PushInteractorStyle
90   void
91   PushInteractorStyle(vtkInteractorStyle* theStyle);
92
93   //! Redirect the request to #SVTK_RenderWindowInteractor::PopInteractorStyle
94   void
95   PopInteractorStyle();
96
97   //----------------------------------------------------------------------------
98   //! Redirect the request to #SVTK_RenderWindowInteractor::GetSelector
99   SVTK_Selector* 
100   GetSelector();
101
102   //! Redirect the request to #SVTK_RenderWindowInteractor::SelectionMode
103   Selection_Mode
104   SelectionMode();
105
106   //! Redirect the request to #SVTK_RenderWindowInteractor::SetSelectionMode
107   void 
108   SetSelectionMode(Selection_Mode theMode);
109
110   //----------------------------------------------------------------------------
111   //! Redirect the request to #SVTK_RenderWindowInteractor::GetRenderer
112   SVTK_Renderer* 
113   GetRenderer();
114
115   //! Redirect the request to #SVTK_RenderWindowInteractor::getRenderer
116   vtkRenderer* 
117   getRenderer();
118
119   //! Set background color to the view
120   void
121   SetBackgroundColor(const QColor& theColor);
122
123   //! Get background color of the view
124   QColor 
125   BackgroundColor();
126
127   //! Redirect the request to #SVTK_Renderer::SetScale
128   void
129   SetScale(double theScale[3]);
130
131   //! Redirect the request to #SVTK_Renderer::GetScale
132   void
133   GetScale(double theScale[3]);
134
135   //! Redirect the request to #SVTK_Renderer::AddActor
136   virtual
137   void 
138   AddActor(VTKViewer_Actor* theActor, 
139            bool theIsUpdate = false);
140
141   //! Redirect the request to #SVTK_Renderer::RemoveActor
142   virtual
143   void 
144   RemoveActor(VTKViewer_Actor* theActor, 
145               bool theIsUpdate = false);
146
147   //! Redirect the request to #SVTK_Renderer::GetTrihedronSize
148   int  
149   GetTrihedronSize();
150
151   //! Redirect the request to #SVTK_Renderer::SetTrihedronSize
152   void
153   SetTrihedronSize(const int theSize, const bool theRelative = true);
154
155   //! Redirect the request to #SVTK_Renderer::AdjustActors
156   void 
157   AdjustActors();
158
159   //! Redirect the request to #SVTK_Renderer::IsTrihedronDisplayed
160   bool
161   IsTrihedronDisplayed();
162  
163   //! Redirect the request to #SVTK_Renderer::IsCubeAxesDisplayed
164   bool
165   IsCubeAxesDisplayed();
166
167   //! Redirect the request to #SVTK_Renderer::GetTrihedron
168   VTKViewer_Trihedron* 
169   GetTrihedron();
170
171   //! Redirect the request to #SVTK_Renderer::GetCubeAxes
172   SVTK_CubeAxesActor2D*
173   GetCubeAxes();
174
175   //----------------------------------------------------------------------------
176   QToolBar* getToolBar();
177
178  public slots:
179   void activateZoom();
180   void activateWindowFit();
181   void activateRotation();
182   void activatePanning(); 
183   void activateGlobalPanning(); 
184
185   void onFrontView(); 
186   void onBackView(); 
187   void onTopView();
188   void onBottomView();
189   void onRightView(); 
190   void onLeftView();     
191
192   void onResetView();     
193   void onFitAll();
194
195   void onViewTrihedron(); 
196   void onViewCubeAxes();
197
198   void onNonIsometric(bool theIsActivate);
199   void onGraduatedAxes(bool theIsActivate);
200
201   void onAdjustTrihedron();
202   void onAdjustCubeAxes();
203
204  public:
205   QImage dumpView();
206
207  protected:  
208   void
209   createActions(SUIT_ResourceMgr* theResourceMgr);
210
211   void
212   createToolBar();
213
214   void
215   SetEventDispatcher(vtkObject* theDispatcher);
216
217   enum { DumpId, FitAllId, FitRectId, ZoomId, PanId, GlobalPanId, RotationId,
218          FrontId, BackId, TopId, BottomId, LeftId, RightId, ResetId, 
219          ViewTrihedronId, NonIsometric, GraduatedAxes};
220   typedef QMap<int, QtxAction*> TActionsMap;
221
222   SUIT_ViewWindow* myViewWindow;
223
224   SVTK_NonIsometricDlg* myNonIsometricDlg;
225   SVTK_CubeAxesDlg* myCubeAxesDlg;
226
227   vtkSmartPointer<vtkObject> myEventDispatcher;
228   TActionsMap myActionsMap;  
229   QToolBar* myToolBar;
230
231   SVTK_RenderWindowInteractor* myInteractor;
232 };
233
234 #ifdef WIN32
235 #pragma warning( default:4251 )
236 #endif
237
238 #endif