1 // Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
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.
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.
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
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 #ifndef SVTK_VIEWWINDOW_H
20 #define SVTK_VIEWWINDOW_H
23 #pragma warning( disable:4251 )
27 #include "SVTK_Selection.h"
28 #include "SUIT_ViewWindow.h"
29 #include "SALOME_InteractiveObject.hxx"
35 class VTKViewer_Actor;
36 class VTKViewer_Trihedron;
38 class SVTK_ViewModelBase;
39 class SVTK_MainWindow;
43 class SVTK_InteractorStyle;
44 class SVTK_CubeAxesActor2D;
46 class SVTK_RenderWindow;
47 class SVTK_RenderWindowInteractor;
50 class vtkRenderWindow;
51 class vtkRenderWindowInteractor;
56 int convertAction( const int );
59 //! Define a container for SALOME VTK view window
60 class SVTK_EXPORT SVTK_ViewWindow : public SUIT_ViewWindow
65 //! To construct #SVTK_ViewWindow instance
66 SVTK_ViewWindow(SUIT_Desktop* theDesktop);
71 virtual QImage dumpView();
73 //! To initialize #SVTK_ViewWindow instance
76 Initialize(SVTK_ViewModelBase* theModel);
82 //! Get #SVTK_MainWindow
86 //! Redirect the request to #SVTK_MainWindow::getRenderWindow
90 //! Redirect the request to #SVTK_MainWindow::getInteractor
91 vtkRenderWindowInteractor*
94 //! Redirect the request to #SVTK_MainWindow::getRenderer
98 //! Redirect the request to #SVTK_MainWindow::GetSelector
102 //! Redirect the request to #SVTK_Selector::SelectionMode
104 SelectionMode() const;
106 //! Change selection mode
109 SetSelectionMode(Selection_Mode theMode);
111 //! Redirect the request to #SVTK_MainWindow::SetBackgroundColor
114 setBackgroundColor( const QColor& );
116 //! Redirect the request to #SVTK_MainWindow::SetBackgroundColor
118 backgroundColor() const;
120 //! Redirect the request to #SVTK_Renderer::IsTrihedronDisplayed
122 isTrihedronDisplayed();
124 //! Redirect the request to #SVTK_Renderer::IsCubeAxesDisplayed
126 isCubeAxesDisplayed();
128 /* interactive object management */
129 //! Redirect the request to #SVTK_View::highlight (to support old code)
132 highlight(const Handle(SALOME_InteractiveObject)& theIO,
133 bool theIsHighlight = true,
134 bool theIsUpdate = true);
136 //! Redirect the request to #SVTK_View::unHighlightAll (to support old code)
141 //! Redirect the request to #SVTK_View::isInViewer (to support old code)
143 isInViewer(const Handle(SALOME_InteractiveObject)& theIObject);
145 //! Redirect the request to #SVTK_View::isVisible (to support old code)
147 isVisible(const Handle(SALOME_InteractiveObject)& theIObject);
149 //! Redirect the request to #SVTK_View::FindIObject (to support old code)
150 //----------------------------------------------------------------------------
151 Handle(SALOME_InteractiveObject)
152 FindIObject(const char* theEntry);
155 //----------------------------------------------------------------------------
156 //! Redirect the request to #SVTK_View::Display (to support old code)
159 Display(const Handle(SALOME_InteractiveObject)& theIObject,
160 bool theImmediatly = true);
162 //! Redirect the request to #SVTK_View::DisplayOnly (to support old code)
165 DisplayOnly(const Handle(SALOME_InteractiveObject)& theIObject);
167 //! Redirect the request to #SVTK_View::Erase (to support old code)
170 Erase(const Handle(SALOME_InteractiveObject)& theIObject,
171 bool theImmediatly = true);
173 //! Redirect the request to #SVTK_View::DisplayAll (to support old code)
178 //! Redirect the request to #SVTK_View::EraseAll (to support old code)
183 //! To repaint the viewer
186 Repaint(bool theUpdateTrihedron = true);
188 //----------------------------------------------------------------------------
189 //! Redirect the request to #SVTK_Renderer::SetScale
192 SetScale( double theScale[3] );
194 //! Redirect the request to #SVTK_Renderer::GetScale
197 GetScale( double theScale[3] );
199 //! Redirect the request to #SVTK_Renderer::AddActor
202 AddActor(VTKViewer_Actor* theActor,
203 bool theIsUpdate = false);
205 //! Redirect the request to #SVTK_Renderer::RemoveActor
208 RemoveActor(VTKViewer_Actor* theActor,
209 bool theIsUpdate = false);
211 //----------------------------------------------------------------------------
212 //! Redirect the request to #SVTK_Renderer::AdjustActors
215 AdjustTrihedrons(const bool theIsForced);
217 //! Redirect the request to #SVTK_Renderer::GetTrihedron
221 //! Redirect the request to #SVTK_Renderer::GetCubeAxes
222 SVTK_CubeAxesActor2D*
225 //! Redirect the request to #SVTK_Renderer::GetTrihedronSize
227 GetTrihedronSize() const;
229 //! Redirect the request to #SVTK_Renderer::SetTrihedronSize
232 SetTrihedronSize( const vtkFloatingPointType, const bool = true );
234 //! Redirect the request to #SVTK_Renderer::SetSelectionProp
237 SetSelectionProp(const double& theRed = 1,
238 const double& theGreen = 1,
239 const double& theBlue = 0,
240 const int& theWidth = 5);
242 //! Redirect the request to #SVTK_Renderer::SetPreselectionProp
245 SetPreselectionProp(const double& theRed = 0,
246 const double& theGreen = 1,
247 const double& theBlue = 1,
248 const int& theWidth = 5);
250 //! Redirect the request to #SVTK_Renderer::SetSelectionTolerance
253 SetSelectionTolerance(const double& theTolNodes = 0.025,
254 const double& theTolCell = 0.001,
255 const double& theTolObjects = 0.025);
257 //! Methods to save/restore visual parameters of a view (pan, zoom, etc.)
260 getVisualParameters();
264 setVisualParameters( const QString& parameters );
268 eventFilter( QObject*, QEvent* );
271 void RefreshDumpImage();
276 onSelectionChanged();
279 void selectionChanged();
282 //! Redirect the request to #SVTK_Renderer::OnFrontView
287 //! Redirect the request to #SVTK_Renderer::OnBackView
292 //! Redirect the request to #SVTK_Renderer::OnTopView
297 //! Redirect the request to #SVTK_Renderer::OnBottomView
302 //! Redirect the request to #SVTK_Renderer::OnRightView
307 //! Redirect the request to #SVTK_Renderer::OnLeftView
312 //! Redirect the request to #SVTK_Renderer::OnResetView
317 //! Redirect the request to #SVTK_Renderer::OnFitAll
322 //! Redirect the request to #SVTK_Renderer::OnViewTrihedron
327 //! Redirect the request to #SVTK_Renderer::OnViewCubeAxes
332 //! Redirect the request to #SVTK_Renderer::OnAdjustTrihedron
337 //! Redirect the request to #SVTK_Renderer::OnAdjustCubeAxes
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);
353 Initialize(SVTK_View* theView,
354 SVTK_ViewModelBase* theModel);
357 doSetVisualParameters( const QString& );
359 virtual QString filter() const;
360 virtual bool dumpViewToFormat( const QImage& img, const QString& fileName, const QString& format );
362 virtual bool action( const int );
365 SVTK_MainWindow* myMainWindow;
366 SVTK_ViewModelBase* myModel;
368 QString myVisualParams; // used for delayed setting of view parameters
375 #pragma warning( default:4251 )