1 // Copyright (C) 2007-2012 CEA/DEN, EDF R&D, 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.
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"
31 #include <SALOME_Prs.h>
32 #include <SALOME_InteractiveObject.hxx>
33 #include <SALOME_ListIO.hxx>
40 class SVTK_ViewWindow;
41 class VTKViewer_Actor;
43 //! Extends two interfaces #SVTK_ViewModelBase and #SALOME_View
44 class SVTK_EXPORT SVTK_Viewer : public SVTK_ViewModelBase, public SALOME_View
49 /*! supported gradient types */
53 FirstDiagonalGradient,
54 SecondDiagonalGradient,
59 LastGradient = FourthCornerGradient,
62 typedef SVTK_ViewWindow TViewWindow;
64 //! Define string representation of the viewer type
65 static QString Type() { return "VTKViewer"; }
66 static QString backgroundData( QStringList&, QIntList&, QIntList& );
69 virtual ~SVTK_Viewer();
71 //! See #SUIT_ViewModel::createView
72 virtual SUIT_ViewWindow* createView(SUIT_Desktop*);
74 //! See #SUIT_ViewModel::createView
75 virtual void setViewManager(SUIT_ViewManager* theViewManager);
77 //! See #SUIT_ViewModel::contextMenuPopup
78 virtual void contextMenuPopup( QMenu* );
80 //! See #SUIT_ViewModel::getType
81 virtual QString getType() const { return Type(); }
83 //! Get background color of the viewer [obsolete]
84 QColor backgroundColor() const;
86 //! Set background color to the viewer [obsolete]
87 void setBackgroundColor( const QColor& );
89 //! Get background color of the viewer
90 Qtx::BackgroundData background() const;
92 //! Set background color to the viewer
93 void setBackground( const Qtx::BackgroundData& );
95 //! Get size of trihedron of the viewer (see #SVTK_Renderer::SetTrihedronSize)
96 vtkFloatingPointType trihedronSize() const;
98 //! Shows if the size of trihedron relative (see #SVTK_Renderer::SetTrihedronSize)
99 bool trihedronRelative() const;
101 //! Set size of trihedron of the viewer (see #SVTK_Renderer::SetTrihedronSize)
102 void setTrihedronSize( const vtkFloatingPointType, const bool = true );
104 //! Get visibility status of the static trihedron
105 bool isStaticTrihedronVisible() const;
107 //! Set visibility status of the static trihedron
108 void setStaticTrihedronVisible( const bool );
110 //! Gets projection mode
111 int projectionMode() const;
113 //! Sets projection mode
114 void setProjectionMode( const int );
116 //! Gets interaction style
117 int interactionStyle() const;
119 //! Sets interaction style
120 void setInteractionStyle( const int );
122 //! Gets zooming style
123 int zoomingStyle() const;
125 //! Sets zooming style
126 void setZoomingStyle( const int );
128 //! Gets dynamic preselection
129 bool dynamicPreSelection() const;
131 //! Sets dynamic preselection
132 void setDynamicPreSelection( const bool );
134 //! Get incremental speed (see #SVTK_InteractorStyle::ControllerIncrement)
135 int incrementalSpeed() const;
137 //! Returns modification mode of incremental speed (see #SVTK_InteractorStyle::ControllerIncrement)
138 int incrementalSpeedMode() const;
140 //! Set the incremental speed for view operation (see #SVTK_InteractorStyle::ControllerIncrement)
141 void setIncrementalSpeed( const int, const int = 0 );
143 //! Gets spacemouse button for specified function
144 int spacemouseBtn( const int ) const;
146 //! Sets spacemouse buttons
147 void setSpacemouseButtons( const int, const int, const int );
150 void enableSelection(bool isEnabled);
151 bool isSelectionEnabled() const { return mySelectionEnabled; }
153 void enableMultiselection(bool isEnable);
154 bool isMultiSelectionEnabled() const { return myMultiSelectionEnabled; }
156 int getSelectionCount() const;
158 /* Reimplemented from SALOME_View */
160 //! See #SALOME_View::Display( const SALOME_Prs* )
161 void Display( const SALOME_VTKPrs* );
163 //! See #SALOME_View::Erase( const SALOME_VTKPrs*, const bool = false )
164 void Erase( const SALOME_VTKPrs*, const bool = false );
166 //! See #SALOME_View::EraseAll( const bool = false )
167 void EraseAll( const bool = false );
169 //! See #SALOME_View::getVisible( SALOME_ListIO& )
170 virtual void GetVisible( SALOME_ListIO& );
172 //! See #SALOME_View::CreatePrs( const char* entry = 0 )
173 SALOME_Prs* CreatePrs( const char* entry = 0 );
175 //! See #SALOME_View::isVisible( const Handle(SALOME_InteractiveObject)& )
176 virtual bool isVisible( const Handle(SALOME_InteractiveObject)& );
178 //! See #SALOME_View::Repaint()
179 virtual void Repaint();
182 void actorAdded(SVTK_ViewWindow*, VTKViewer_Actor*);
183 void actorRemoved(SVTK_ViewWindow*, VTKViewer_Actor*);
186 void onMousePress(SUIT_ViewWindow*, QMouseEvent*);
187 void onMouseMove(SUIT_ViewWindow*, QMouseEvent*);
188 void onMouseRelease(SUIT_ViewWindow*, QMouseEvent*);
191 void onChangeBackground();
193 void onActorAdded(VTKViewer_Actor*);
194 void onActorRemoved(VTKViewer_Actor*);
197 void updateToolBars();
199 Qtx::BackgroundData myDefaultBackground;
200 vtkFloatingPointType myTrihedronSize;
201 bool myTrihedronRelative;
202 bool myIsStaticTrihedronVisible;
203 bool mySelectionEnabled;
204 bool myMultiSelectionEnabled;
205 int myIncrementSpeed;
210 bool myDynamicPreSelection;