1 // Copyright (C) 2007-2024 CEA, EDF, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License, or (at your option) any later version.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 #ifndef SVTK_VIEWMODEL_H
24 #define SVTK_VIEWMODEL_H
27 #include "SVTK_ViewModelBase.h"
28 #include "SVTK_Selection.h"
32 #include <SALOME_Prs.h>
33 #include <SALOME_InteractiveObject.hxx>
34 #include <SALOME_ListIO.hxx>
41 class SVTK_ViewWindow;
42 class VTKViewer_Actor;
44 //! Extends two interfaces #SVTK_ViewModelBase and #SALOME_View
45 class SVTK_EXPORT SVTK_Viewer : public SVTK_ViewModelBase, public SALOME_View
50 /*! supported gradient types */
54 FirstDiagonalGradient,
55 SecondDiagonalGradient,
60 LastGradient = FourthCornerGradient,
64 CrystalEyesType, RedBlueType,
65 InterlacedType, LeftType,
66 RightType, DresdenType,
67 AnaglyphType, CheckerboardType,
68 SplitViewPortHorizontalType
70 typedef SVTK_ViewWindow TViewWindow;
72 //! Define string representation of the viewer type
73 static QString Type() { return "VTKViewer"; }
74 static QString backgroundData( QStringList&, QIntList&, QIntList& );
75 static void stereoData( QStringList&, QIntList&);
78 virtual ~SVTK_Viewer();
80 //! See #SUIT_ViewModel::createView
81 virtual SUIT_ViewWindow* createView(SUIT_Desktop*);
83 //! See #SUIT_ViewModel::createView
84 virtual void setViewManager(SUIT_ViewManager* theViewManager);
86 //! See #SUIT_ViewModel::contextMenuPopup
87 virtual void contextMenuPopup( QMenu* );
89 //! See #SUIT_ViewModel::getType
90 virtual QString getType() const { return Type(); }
92 //! Get background color of the viewer [obsolete]
93 QColor backgroundColor() const;
95 //! Set background color to the viewer [obsolete]
96 void setBackgroundColor( const QColor& );
98 //! Get background color of the viewer
99 Qtx::BackgroundData background() const;
101 //! Set background color to the viewer
102 void setBackground( const Qtx::BackgroundData& );
104 //! Get size of trihedron of the viewer (see #SVTK_Renderer::SetTrihedronSize)
105 double trihedronSize() const;
107 //! Shows if the size of trihedron relative (see #SVTK_Renderer::SetTrihedronSize)
108 bool trihedronRelative() const;
110 //! Set size of trihedron of the viewer (see #SVTK_Renderer::SetTrihedronSize)
111 void setTrihedronSize( const double, const bool = true );
113 //! Get visibility status of the static trihedron
114 bool isStaticTrihedronVisible() const;
116 //! Set visibility status of the static trihedron
117 void setStaticTrihedronVisible( const bool );
119 //! Gets projection mode
120 int projectionMode() const;
122 //! Sets projection mode
123 void setProjectionMode( const int );
126 int stereoType() const;
129 void setStereoType( const int );
131 //! Gets anaglyph filter
132 int anaglyphFilter() const;
134 //! Sets anaglyph filter
135 void setAnaglyphFilter( const int );
137 //! Get support quad-buffered stereo
138 bool isQuadBufferSupport() const;
140 //! Set support quad-buffered stereo
141 void setQuadBufferSupport( const bool );
143 //! Gets interaction style
144 int interactionStyle() const;
146 //! Sets interaction style
147 void setInteractionStyle( const int );
149 //! Gets zooming style
150 int zoomingStyle() const;
152 //! Sets zooming style
153 void setZoomingStyle( const int );
155 //! Gets current preselection mode (standard, dynamic or disabled)
156 Preselection_Mode preSelectionMode() const;
158 //! Sets new preselection mode
159 void setPreSelectionMode( Preselection_Mode );
161 //! Get incremental speed (see #SVTK_InteractorStyle::ControllerIncrement)
162 int incrementalSpeed() const;
164 //! Returns modification mode of incremental speed (see #SVTK_InteractorStyle::ControllerIncrement)
165 int incrementalSpeedMode() const;
167 //! Set the incremental speed for view operation (see #SVTK_InteractorStyle::ControllerIncrement)
168 void setIncrementalSpeed( const int, const int = 0 );
170 //! Gets spacemouse button for specified function
171 int spacemouseBtn( const int ) const;
173 //! Sets spacemouse buttons
174 void setSpacemouseButtons( const int, const int, const int );
177 void enableSelection(bool isEnabled);
178 bool isSelectionEnabled() const { return mySelectionEnabled; }
180 void enableMultiselection(bool isEnable);
181 bool isMultiSelectionEnabled() const { return myMultiSelectionEnabled; }
183 int getSelectionCount() const;
185 /* Reimplemented from SALOME_View */
187 //! See #SALOME_View::Display( const SALOME_Prs* )
188 void Display( const SALOME_VTKPrs* );
190 //! See #SALOME_View::Erase( const SALOME_VTKPrs*, const bool = false )
191 void Erase( const SALOME_VTKPrs*, const bool = false );
193 //! See #SALOME_View::EraseAll( SALOME_Displayer*, const bool = false )
194 void EraseAll( SALOME_Displayer*, const bool = false );
196 //! See #SALOME_View::getVisible( SALOME_ListIO& )
197 virtual void GetVisible( SALOME_ListIO& );
199 //! See #SALOME_View::CreatePrs( const char* entry = 0 )
200 SALOME_Prs* CreatePrs( const char* entry = 0 );
202 //! See #SALOME_View::isVisible( const Handle(SALOME_InteractiveObject)& )
203 virtual bool isVisible( const Handle(SALOME_InteractiveObject)& );
205 //! See #SALOME_View::Repaint()
206 virtual void Repaint();
209 void actorAdded(SVTK_ViewWindow*, VTKViewer_Actor*);
210 void actorRemoved(SVTK_ViewWindow*, VTKViewer_Actor*);
213 void onMousePress(SUIT_ViewWindow*, QMouseEvent*);
214 void onMouseMove(SUIT_ViewWindow*, QMouseEvent*);
215 void onMouseRelease(SUIT_ViewWindow*, QMouseEvent*);
218 void onChangeBackground();
220 void onActorAdded(VTKViewer_Actor*);
221 void onActorRemoved(VTKViewer_Actor*);
223 void onViewCreated( SUIT_ViewWindow* );
226 void updateToolBars();
228 Qtx::BackgroundData myDefaultBackground;
229 double myTrihedronSize;
230 bool myTrihedronRelative;
231 bool myIsStaticTrihedronVisible;
232 bool mySelectionEnabled;
233 bool myMultiSelectionEnabled;
234 int myIncrementSpeed;
238 int myAnaglyphFilter;
239 bool myQuadBufferSupport;
242 Preselection_Mode myPreSelectionMode;