Salome HOME
1fc559c78145aea29e4d99de0a916e077ac778eb
[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   /* selection */
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 );
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 public slots:
247   virtual
248   void
249   onSelectionChanged();
250
251 signals:
252  void selectionChanged();
253
254 public slots:
255   //! Redirect the request to #SVTK_Renderer::OnFrontView
256   virtual
257   void
258   onFrontView(); 
259
260   //! Redirect the request to #SVTK_Renderer::OnBackView
261   virtual
262   void
263   onBackView(); 
264
265   //! Redirect the request to #SVTK_Renderer::OnTopView
266   virtual
267   void
268   onTopView();
269
270   //! Redirect the request to #SVTK_Renderer::OnBottomView
271   virtual
272   void
273   onBottomView();
274
275   //! Redirect the request to #SVTK_Renderer::OnRightView
276   virtual
277   void 
278   onRightView(); 
279
280   //! Redirect the request to #SVTK_Renderer::OnLeftView
281   virtual
282   void 
283   onLeftView();     
284
285   //! Redirect the request to #SVTK_Renderer::OnResetView
286   virtual
287   void
288   onResetView();     
289
290   //! Redirect the request to #SVTK_Renderer::OnFitAll
291   virtual
292   void 
293   onFitAll();
294
295   //! Redirect the request to #SVTK_Renderer::OnViewTrihedron
296   virtual
297   void
298   onViewTrihedron(); 
299
300   //! Redirect the request to #SVTK_Renderer::OnViewCubeAxes
301   virtual
302   void
303   onViewCubeAxes();
304
305   //! Redirect the request to #SVTK_Renderer::OnAdjustTrihedron
306   virtual
307   void
308   onAdjustTrihedron();
309
310   //! Redirect the request to #SVTK_Renderer::OnAdjustCubeAxes
311   virtual
312   void 
313   onAdjustCubeAxes();
314
315 protected slots:
316   void onKeyPressed(QKeyEvent* event);
317   void onKeyReleased(QKeyEvent* event);
318   void onMousePressed(QMouseEvent* event);
319   void onMouseDoubleClicked(QMouseEvent* event);
320   void onMouseReleased(QMouseEvent* event);
321   void onMouseMoving(QMouseEvent* event);
322
323 protected:
324   virtual
325   void
326   Initialize(SVTK_View* theView,
327              SVTK_ViewModelBase* theModel);
328
329   QImage dumpView();
330   virtual void action( const int );
331
332   SVTK_View* myView;
333   SVTK_MainWindow* myMainWindow;
334   SVTK_ViewModelBase* myModel;
335 };
336
337 #ifdef WIN32
338 #pragma warning( default:4251 )
339 #endif
340
341 #endif