Salome HOME
Join modifications from branch OCC_debug_for_3_2_0b1
[modules/gui.git] / src / SVTK / SVTK_ViewWindow.h
1 // Copyright (C) 2005  OPEN CASCADE, CEA/DEN, EDF R&D, 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_VIEWWINDOW_H
20 #define SVTK_VIEWWINDOW_H
21
22 #ifdef WIN32
23 #pragma warning( disable:4251 )
24 #endif
25
26 #include "SVTK.h"
27 #include "SVTK_Selection.h"
28 #include "SUIT_ViewWindow.h"
29 #include "SALOME_InteractiveObject.hxx"
30
31 class SUIT_Desktop;
32
33 class VTKViewer_Actor;
34 class VTKViewer_Trihedron;
35
36 class SVTK_ViewModelBase;
37 class SVTK_MainWindow;
38 class SVTK_Selector;
39 class SVTK_View;
40
41 class SVTK_InteractorStyle;
42 class SVTK_CubeAxesActor2D;
43
44 class SVTK_RenderWindow;
45 class SVTK_RenderWindowInteractor;
46
47 class vtkRenderer;
48 class vtkRenderWindow;
49 class vtkRenderWindowInteractor;
50
51 //! Define a container for SALOME VTK view window
52 class SVTK_EXPORT SVTK_ViewWindow : public SUIT_ViewWindow
53 {
54   Q_OBJECT;
55
56  public:
57   //! To construct #SVTK_ViewWindow instance
58   SVTK_ViewWindow(SUIT_Desktop* theDesktop);
59
60   virtual
61   ~SVTK_ViewWindow();
62   
63   //! To initialize #SVTK_ViewWindow instance
64   virtual
65   void
66   Initialize(SVTK_ViewModelBase* theModel);
67
68   //! Get #SVTK_View
69   SVTK_View* 
70   getView();
71
72   //! Get #SVTK_MainWindow
73   SVTK_MainWindow* 
74   getMainWindow();
75
76   //! Redirect the request to #SVTK_MainWindow::getRenderWindow
77   vtkRenderWindow* 
78   getRenderWindow();
79
80   //! Redirect the request to #SVTK_MainWindow::getInteractor
81   vtkRenderWindowInteractor*
82   getInteractor();
83
84   //! Redirect the request to #SVTK_MainWindow::getRenderer 
85   vtkRenderer* 
86   getRenderer();
87
88   //! Redirect the request to #SVTK_MainWindow::GetSelector 
89   SVTK_Selector* 
90   GetSelector();
91   
92   //! Redirect the request to #SVTK_Selector::SelectionMode
93   Selection_Mode
94   SelectionMode() const;
95   
96   //! Change selection mode
97   virtual
98   void
99   SetSelectionMode(Selection_Mode theMode);
100
101   //! Redirect the request to #SVTK_MainWindow::SetBackgroundColor 
102   virtual
103   void
104   setBackgroundColor( const QColor& );
105
106   //! Redirect the request to #SVTK_MainWindow::SetBackgroundColor 
107   QColor
108   backgroundColor() const;
109
110   //! Redirect the request to #SVTK_Renderer::IsTrihedronDisplayed
111   bool
112   isTrihedronDisplayed();
113
114   //! Redirect the request to #SVTK_Renderer::IsCubeAxesDisplayed
115   bool
116   isCubeAxesDisplayed();
117  
118   /*  interactive object management */
119   //! Redirect the request to #SVTK_View::highlight (to support old code)
120   virtual
121   void
122   highlight(const Handle(SALOME_InteractiveObject)& theIO, 
123             bool theIsHighlight = true, 
124             bool theIsUpdate = true);
125
126   //! Redirect the request to #SVTK_View::unHighlightAll (to support old code)
127   virtual
128   void
129   unHighlightAll();
130
131   //! Redirect the request to #SVTK_View::isInViewer (to support old code)
132   bool
133   isInViewer(const Handle(SALOME_InteractiveObject)& theIObject);
134
135   //! Redirect the request to #SVTK_View::isVisible (to support old code)
136   bool
137   isVisible(const Handle(SALOME_InteractiveObject)& theIObject);
138
139   //! Redirect the request to #SVTK_View::FindIObject (to support old code)
140   //----------------------------------------------------------------------------
141   Handle(SALOME_InteractiveObject) 
142   FindIObject(const char* theEntry);
143   
144   /* display */         
145   //----------------------------------------------------------------------------
146   //! Redirect the request to #SVTK_View::Display (to support old code)
147   virtual
148   void
149   Display(const Handle(SALOME_InteractiveObject)& theIObject,
150           bool theImmediatly = true);
151
152   //! Redirect the request to #SVTK_View::DisplayOnly (to support old code)
153   virtual
154   void
155   DisplayOnly(const Handle(SALOME_InteractiveObject)& theIObject);
156
157   //! Redirect the request to #SVTK_View::Erase (to support old code)
158   virtual
159   void
160   Erase(const Handle(SALOME_InteractiveObject)& theIObject,
161         bool theImmediatly = true);
162
163   //! Redirect the request to #SVTK_View::DisplayAll (to support old code)
164   virtual
165   void 
166   DisplayAll();
167
168   //! Redirect the request to #SVTK_View::EraseAll (to support old code)
169   virtual
170   void 
171   EraseAll();
172
173   //! To repaint the viewer
174   virtual
175   void
176   Repaint(bool theUpdateTrihedron = true);
177
178   //----------------------------------------------------------------------------
179   //! Redirect the request to #SVTK_Renderer::SetScale
180   virtual
181   void 
182   SetScale( double theScale[3] );
183
184   //! Redirect the request to #SVTK_Renderer::GetScale
185   virtual
186   void
187   GetScale( double theScale[3] );
188
189   //! Redirect the request to #SVTK_Renderer::AddActor
190   virtual
191   void
192   AddActor(VTKViewer_Actor* theActor,
193            bool theIsUpdate = false);
194
195   //! Redirect the request to #SVTK_Renderer::RemoveActor
196   virtual
197   void
198   RemoveActor(VTKViewer_Actor* theActor,
199               bool theIsUpdate = false);
200
201   //----------------------------------------------------------------------------
202   //! Redirect the request to #SVTK_Renderer::AdjustActors
203   virtual
204   void
205   AdjustTrihedrons(const bool theIsForced);
206
207   //! Redirect the request to #SVTK_Renderer::GetTrihedron
208   VTKViewer_Trihedron*  
209   GetTrihedron();
210
211   //! Redirect the request to #SVTK_Renderer::GetCubeAxes
212   SVTK_CubeAxesActor2D* 
213   GetCubeAxes();
214
215   //! Redirect the request to #SVTK_Renderer::GetTrihedronSize
216   int  
217   GetTrihedronSize() const;
218
219   //! Redirect the request to #SVTK_Renderer::SetTrihedronSize
220   virtual
221   void 
222   SetTrihedronSize( const int, const bool = true );
223
224   //! Redirect the request to #SVTK_Renderer::SetSelectionProp
225   virtual
226   void
227   SetSelectionProp(const double& theRed = 1, 
228                    const double& theGreen = 1,
229                    const double& theBlue = 0, 
230                    const int& theWidth = 5);
231
232   //! Redirect the request to #SVTK_Renderer::SetPreselectionProp
233   virtual
234   void
235   SetPreselectionProp(const double& theRed = 0, 
236                       const double& theGreen = 1,
237                       const double& theBlue = 1, 
238                       const int& theWidth = 5);
239
240   //! Redirect the request to #SVTK_Renderer::SetSelectionTolerance
241   virtual
242   void
243   SetSelectionTolerance(const double& theTolNodes = 0.025, 
244                         const double& theTolCell = 0.001);
245
246   //! Methods to save/restore visual parameters of a view (pan, zoom, etc.)
247   virtual 
248   QString   
249   getVisualParameters();
250   
251   virtual
252   void
253   setVisualParameters( const QString& parameters );
254
255   virtual
256   bool
257   eventFilter( QObject*, QEvent* );
258   
259 public slots:
260   virtual
261   void
262   onSelectionChanged();
263
264 signals:
265  void selectionChanged();
266
267 public slots:
268   //! Redirect the request to #SVTK_Renderer::OnFrontView
269   virtual
270   void
271   onFrontView(); 
272
273   //! Redirect the request to #SVTK_Renderer::OnBackView
274   virtual
275   void
276   onBackView(); 
277
278   //! Redirect the request to #SVTK_Renderer::OnTopView
279   virtual
280   void
281   onTopView();
282
283   //! Redirect the request to #SVTK_Renderer::OnBottomView
284   virtual
285   void
286   onBottomView();
287
288   //! Redirect the request to #SVTK_Renderer::OnRightView
289   virtual
290   void 
291   onRightView(); 
292
293   //! Redirect the request to #SVTK_Renderer::OnLeftView
294   virtual
295   void 
296   onLeftView();     
297
298   //! Redirect the request to #SVTK_Renderer::OnResetView
299   virtual
300   void
301   onResetView();     
302
303   //! Redirect the request to #SVTK_Renderer::OnFitAll
304   virtual
305   void 
306   onFitAll();
307
308   //! Redirect the request to #SVTK_Renderer::OnViewTrihedron
309   virtual
310   void
311   onViewTrihedron(); 
312
313   //! Redirect the request to #SVTK_Renderer::OnViewCubeAxes
314   virtual
315   void
316   onViewCubeAxes();
317
318   //! Redirect the request to #SVTK_Renderer::OnAdjustTrihedron
319   virtual
320   void
321   onAdjustTrihedron();
322
323   //! Redirect the request to #SVTK_Renderer::OnAdjustCubeAxes
324   virtual
325   void 
326   onAdjustCubeAxes();
327
328 protected slots:
329   void onKeyPressed(QKeyEvent* event);
330   void onKeyReleased(QKeyEvent* event);
331   void onMousePressed(QMouseEvent* event);
332   void onMouseDoubleClicked(QMouseEvent* event);
333   void onMouseReleased(QMouseEvent* event);
334   void onMouseMoving(QMouseEvent* event);
335
336 protected:
337   virtual
338   void
339   Initialize(SVTK_View* theView,
340              SVTK_ViewModelBase* theModel);
341
342   void
343   doSetVisualParameters( const QString& );
344
345   QImage dumpView();
346   virtual bool action( const int );
347
348   SVTK_View* myView;
349   SVTK_MainWindow* myMainWindow;
350   SVTK_ViewModelBase* myModel;
351
352   QString myVisualParams; // used for delayed setting of view parameters 
353 };
354
355 #ifdef WIN32
356 #pragma warning( default:4251 )
357 #endif
358
359 #endif