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