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