1 // Copyright (C) 2005 CEA/DEN, EDF R&D, OPEN CASCADE, 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/
19 #ifndef SVTK_MAINWINDOW_H
20 #define SVTK_MAINWINDOW_H
23 #pragma warning( disable:4251 )
27 #include "SVTK_Selection.h"
29 #include <vtkSmartPointer.h>
31 #include <qmainwindow.h>
37 class vtkRenderWindow;
38 class vtkInteractorStyle;
39 class vtkRenderWindowInteractor;
41 class SUIT_ResourceMgr;
42 class SUIT_ViewWindow;
44 class SVTK_RenderWindowInteractor;
45 class SVTK_NonIsometricDlg;
46 class SVTK_UpdateRateDlg;
47 class SVTK_CubeAxesActor2D;
48 class SVTK_CubeAxesDlg;
50 class VTKViewer_Trihedron;
51 class VTKViewer_Transform;
52 class VTKViewer_Actor;
58 //! The class is a container for #SVTK_RenderWindowInteractor.
60 The class contains #SVTK_RenderWindowInteractor instance and
61 adds predefined viewer actions and toolbar for user interaction.
63 class SVTK_EXPORT SVTK_MainWindow: public QMainWindow
68 SVTK_MainWindow(QWidget* theParent,
70 SUIT_ResourceMgr* theResourceMgr,
71 SUIT_ViewWindow* theViewWindow);
73 //! To initialize the class
76 Initialize(SVTK_RenderWindowInteractor* theInteractor);
81 //----------------------------------------------------------------------------
82 //! Get used #SVTK_RenderWindowInteractor
83 SVTK_RenderWindowInteractor*
86 //! Get used #vtkRenderWindowInteractor (obsolete)
87 vtkRenderWindowInteractor*
90 //! Get used #vtkRenderWindow (obsolete)
94 //! To repaint the view
96 Repaint(bool theUpdateTrihedron = true);
98 //! To invoke a VTK event on #SVTK_RenderWindowInteractor instance
100 InvokeEvent(unsigned long theEvent, void* theCallData);
102 //----------------------------------------------------------------------------
103 //! Redirect the request to #SVTK_RenderWindowInteractor::GetInteractorStyle
105 GetInteractorStyle();
107 //! Redirect the request to #SVTK_RenderWindowInteractor::PushInteractorStyle
109 PushInteractorStyle(vtkInteractorStyle* theStyle);
111 //! Redirect the request to #SVTK_RenderWindowInteractor::PopInteractorStyle
113 PopInteractorStyle();
115 //----------------------------------------------------------------------------
116 //! Redirect the request to #SVTK_RenderWindowInteractor::GetSelector
120 //! Redirect the request to #SVTK_RenderWindowInteractor::SelectionMode
124 //! Redirect the request to #SVTK_RenderWindowInteractor::SetSelectionMode
126 SetSelectionMode(Selection_Mode theMode);
128 //----------------------------------------------------------------------------
129 //! Redirect the request to #SVTK_RenderWindowInteractor::GetRenderer
133 //! Redirect the request to #SVTK_RenderWindowInteractor::getRenderer
137 //! Set background color to the view
139 SetBackgroundColor(const QColor& theColor);
141 //! Get background color of the view
145 //! Redirect the request to #SVTK_Renderer::SetScale
147 SetScale(double theScale[3]);
149 //! Redirect the request to #SVTK_Renderer::GetScale
151 GetScale(double theScale[3]);
153 //! Redirect the request to #SVTK_Renderer::AddActor
156 AddActor(VTKViewer_Actor* theActor,
157 bool theIsUpdate = false);
159 //! Redirect the request to #SVTK_Renderer::RemoveActor
162 RemoveActor(VTKViewer_Actor* theActor,
163 bool theIsUpdate = false);
165 //! Redirect the request to #SVTK_Renderer::GetTrihedronSize
169 //! Redirect the request to #SVTK_Renderer::SetTrihedronSize
171 SetTrihedronSize(const int theSize, const bool theRelative = true);
173 //! Redirect the request to #SVTK_Renderer::AdjustActors
177 //! Redirect the request to #SVTK_Renderer::IsTrihedronDisplayed
179 IsTrihedronDisplayed();
181 //! Redirect the request to #SVTK_Renderer::IsCubeAxesDisplayed
183 IsCubeAxesDisplayed();
185 //! Redirect the request to #SVTK_Renderer::GetTrihedron
189 //! Redirect the request to #SVTK_Renderer::GetCubeAxes
190 SVTK_CubeAxesActor2D*
193 //----------------------------------------------------------------------------
194 QToolBar* getToolBar();
197 void Show( QShowEvent * );
198 void Hide( QHideEvent * );
201 virtual void showEvent( QShowEvent * );
202 virtual void hideEvent( QHideEvent * );
205 void activateWindowFit();
206 void activateRotation();
207 void activatePanning();
208 void activateGlobalPanning();
220 void onViewTrihedron();
221 void onViewCubeAxes();
223 void onUpdateRate(bool theIsActivate);
224 void onNonIsometric(bool theIsActivate);
225 void onGraduatedAxes(bool theIsActivate);
227 void onAdjustTrihedron();
228 void onAdjustCubeAxes();
235 createActions(SUIT_ResourceMgr* theResourceMgr);
241 SetEventDispatcher(vtkObject* theDispatcher);
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;
248 SUIT_ViewWindow* myViewWindow;
250 SVTK_NonIsometricDlg* myNonIsometricDlg;
251 SVTK_UpdateRateDlg* myUpdateRateDlg;
252 SVTK_CubeAxesDlg* myCubeAxesDlg;
254 vtkSmartPointer<vtkObject> myEventDispatcher;
255 TActionsMap myActionsMap;
258 SVTK_RenderWindowInteractor* myInteractor;
262 #pragma warning( default:4251 )