1 // Copyright (C) 2007-2014 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, 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,
63 typedef SVTK_ViewWindow TViewWindow;
65 //! Define string representation of the viewer type
66 static QString Type() { return "VTKViewer"; }
67 static QString backgroundData( QStringList&, QIntList&, QIntList& );
70 virtual ~SVTK_Viewer();
72 //! See #SUIT_ViewModel::createView
73 virtual SUIT_ViewWindow* createView(SUIT_Desktop*);
75 //! See #SUIT_ViewModel::createView
76 virtual void setViewManager(SUIT_ViewManager* theViewManager);
78 //! See #SUIT_ViewModel::contextMenuPopup
79 virtual void contextMenuPopup( QMenu* );
81 //! See #SUIT_ViewModel::getType
82 virtual QString getType() const { return Type(); }
84 //! Get background color of the viewer [obsolete]
85 QColor backgroundColor() const;
87 //! Set background color to the viewer [obsolete]
88 void setBackgroundColor( const QColor& );
90 //! Get background color of the viewer
91 Qtx::BackgroundData background() const;
93 //! Set background color to the viewer
94 void setBackground( const Qtx::BackgroundData& );
96 //! Get size of trihedron of the viewer (see #SVTK_Renderer::SetTrihedronSize)
97 double trihedronSize() const;
99 //! Shows if the size of trihedron relative (see #SVTK_Renderer::SetTrihedronSize)
100 bool trihedronRelative() const;
102 //! Set size of trihedron of the viewer (see #SVTK_Renderer::SetTrihedronSize)
103 void setTrihedronSize( const double, const bool = true );
105 //! Get visibility status of the static trihedron
106 bool isStaticTrihedronVisible() const;
108 //! Set visibility status of the static trihedron
109 void setStaticTrihedronVisible( const bool );
111 //! Gets projection mode
112 int projectionMode() const;
114 //! Sets projection mode
115 void setProjectionMode( const int );
117 //! Gets interaction style
118 int interactionStyle() const;
120 //! Sets interaction style
121 void setInteractionStyle( const int );
123 //! Gets zooming style
124 int zoomingStyle() const;
126 //! Sets zooming style
127 void setZoomingStyle( const int );
129 //! Gets current preselection mode (standard, dynamic or disabled)
130 Preselection_Mode preSelectionMode() const;
132 //! Sets new preselection mode
133 void setPreSelectionMode( Preselection_Mode );
135 //! Get incremental speed (see #SVTK_InteractorStyle::ControllerIncrement)
136 int incrementalSpeed() const;
138 //! Returns modification mode of incremental speed (see #SVTK_InteractorStyle::ControllerIncrement)
139 int incrementalSpeedMode() const;
141 //! Set the incremental speed for view operation (see #SVTK_InteractorStyle::ControllerIncrement)
142 void setIncrementalSpeed( const int, const int = 0 );
144 //! Gets spacemouse button for specified function
145 int spacemouseBtn( const int ) const;
147 //! Sets spacemouse buttons
148 void setSpacemouseButtons( const int, const int, const int );
151 void enableSelection(bool isEnabled);
152 bool isSelectionEnabled() const { return mySelectionEnabled; }
154 void enableMultiselection(bool isEnable);
155 bool isMultiSelectionEnabled() const { return myMultiSelectionEnabled; }
157 int getSelectionCount() const;
159 /* Reimplemented from SALOME_View */
161 //! See #SALOME_View::Display( const SALOME_Prs* )
162 void Display( const SALOME_VTKPrs* );
164 //! See #SALOME_View::Erase( const SALOME_VTKPrs*, const bool = false )
165 void Erase( const SALOME_VTKPrs*, const bool = false );
167 //! See #SALOME_View::EraseAll( const bool = false )
168 void EraseAll( const bool = false );
170 //! See #SALOME_View::getVisible( SALOME_ListIO& )
171 virtual void GetVisible( SALOME_ListIO& );
173 //! See #SALOME_View::CreatePrs( const char* entry = 0 )
174 SALOME_Prs* CreatePrs( const char* entry = 0 );
176 //! See #SALOME_View::isVisible( const Handle(SALOME_InteractiveObject)& )
177 virtual bool isVisible( const Handle(SALOME_InteractiveObject)& );
179 //! See #SALOME_View::Repaint()
180 virtual void Repaint();
183 void actorAdded(SVTK_ViewWindow*, VTKViewer_Actor*);
184 void actorRemoved(SVTK_ViewWindow*, VTKViewer_Actor*);
187 void onMousePress(SUIT_ViewWindow*, QMouseEvent*);
188 void onMouseMove(SUIT_ViewWindow*, QMouseEvent*);
189 void onMouseRelease(SUIT_ViewWindow*, QMouseEvent*);
192 void onChangeBackground();
194 void onActorAdded(VTKViewer_Actor*);
195 void onActorRemoved(VTKViewer_Actor*);
198 void updateToolBars();
200 Qtx::BackgroundData myDefaultBackground;
201 double myTrihedronSize;
202 bool myTrihedronRelative;
203 bool myIsStaticTrihedronVisible;
204 bool mySelectionEnabled;
205 bool myMultiSelectionEnabled;
206 int myIncrementSpeed;
211 Preselection_Mode myPreSelectionMode;