Salome HOME
Update copyrights
[modules/gui.git] / src / SVTK / SVTK_ViewModel.h
1 // Copyright (C) 2007-2019  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
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.
10 //
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.
15 //
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
19 //
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22
23 #ifndef SVTK_VIEWMODEL_H
24 #define SVTK_VIEWMODEL_H
25
26 #include "SVTK.h"
27 #include "SVTK_ViewModelBase.h"
28 #include "SVTK_Selection.h"
29
30 #include "Qtx.h"
31
32 #include <SALOME_Prs.h>
33 #include <SALOME_InteractiveObject.hxx>
34 #include <SALOME_ListIO.hxx>
35
36 #include <QColor>
37 #include <QMap>
38
39 class QMouseEvent;
40
41 class SVTK_ViewWindow;
42 class VTKViewer_Actor;
43
44 //! Extends two interfaces #SVTK_ViewModelBase and #SALOME_View 
45 class SVTK_EXPORT SVTK_Viewer : public SVTK_ViewModelBase, public SALOME_View 
46 {
47   Q_OBJECT;
48
49 public:
50   /*! supported gradient types */
51   enum { 
52     HorizontalGradient,
53     VerticalGradient,
54     FirstDiagonalGradient,
55     SecondDiagonalGradient,
56     FirstCornerGradient,
57     SecondCornerGradient,
58     ThirdCornerGradient,
59     FourthCornerGradient,
60     LastGradient = FourthCornerGradient,
61   };
62
63   enum {
64     CrystalEyesType, RedBlueType,
65     InterlacedType,  LeftType,
66     RightType,       DresdenType,
67     AnaglyphType,    CheckerboardType,
68     SplitViewPortHorizontalType
69   };
70   typedef SVTK_ViewWindow TViewWindow;
71   
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&);
76
77   SVTK_Viewer();
78   virtual ~SVTK_Viewer();
79
80   //! See #SUIT_ViewModel::createView
81   virtual SUIT_ViewWindow* createView(SUIT_Desktop*);
82
83   //! See #SUIT_ViewModel::createView
84   virtual void setViewManager(SUIT_ViewManager* theViewManager);
85
86   //! See #SUIT_ViewModel::contextMenuPopup
87   virtual void contextMenuPopup( QMenu* );
88
89   //! See #SUIT_ViewModel::getType
90   virtual QString getType() const { return Type(); }
91
92   //! Get background color of the viewer [obsolete]
93   QColor backgroundColor() const;
94
95   //! Set background color to the viewer [obsolete]
96   void setBackgroundColor( const QColor& );
97
98   //! Get background color of the viewer
99   Qtx::BackgroundData background() const;
100
101   //! Set background color to the viewer
102   void setBackground( const Qtx::BackgroundData& );
103
104   //! Get size of trihedron of the viewer (see #SVTK_Renderer::SetTrihedronSize)
105   double trihedronSize() const;
106
107   //! Shows if the size of trihedron relative (see #SVTK_Renderer::SetTrihedronSize)
108   bool trihedronRelative() const;
109
110   //! Set size of trihedron of the viewer (see #SVTK_Renderer::SetTrihedronSize)
111   void setTrihedronSize( const double, const bool = true );
112
113   //! Get visibility status of the static trihedron
114   bool isStaticTrihedronVisible() const;
115
116   //! Set visibility status of the static trihedron
117   void setStaticTrihedronVisible( const bool );
118
119   //! Gets projection mode
120   int projectionMode() const;
121
122   //! Sets projection mode
123   void setProjectionMode( const int );
124
125   //! Gets stereo type
126   int stereoType() const;
127
128   //! Sets stereo type
129   void setStereoType( const int );
130
131   //! Gets anaglyph filter
132   int anaglyphFilter() const;
133
134   //! Sets anaglyph filter
135   void setAnaglyphFilter( const int );
136
137   //! Get support quad-buffered stereo
138   bool isQuadBufferSupport() const;
139
140   //! Set support quad-buffered stereo
141   void setQuadBufferSupport( const bool );
142
143   //! Gets interaction style
144   int interactionStyle() const;
145
146   //! Sets interaction style
147   void setInteractionStyle( const int );
148
149   //! Gets zooming style
150   int zoomingStyle() const;
151
152   //! Sets zooming style
153   void setZoomingStyle( const int );
154
155   //! Gets current preselection mode (standard, dynamic or disabled)
156   Preselection_Mode preSelectionMode() const;
157
158   //! Sets new preselection mode
159   void setPreSelectionMode( Preselection_Mode );
160  
161   //! Get incremental speed (see #SVTK_InteractorStyle::ControllerIncrement)
162   int incrementalSpeed() const;
163
164   //! Returns modification mode of incremental speed (see #SVTK_InteractorStyle::ControllerIncrement)
165   int incrementalSpeedMode() const;
166
167   //! Set the incremental speed for view operation (see #SVTK_InteractorStyle::ControllerIncrement)
168   void setIncrementalSpeed( const int, const int = 0 );
169
170   //! Gets spacemouse button for specified function
171   int spacemouseBtn( const int ) const;
172
173   //! Sets spacemouse buttons
174   void setSpacemouseButtons( const int, const int, const int );
175
176 public:
177   void enableSelection(bool isEnabled);
178   bool isSelectionEnabled() const { return mySelectionEnabled; }
179
180   void enableMultiselection(bool isEnable);
181   bool isMultiSelectionEnabled() const { return myMultiSelectionEnabled; }
182
183   int  getSelectionCount() const;
184
185   /* Reimplemented from SALOME_View */
186
187   //! See #SALOME_View::Display( const SALOME_Prs* )
188   void Display( const SALOME_VTKPrs* ); 
189
190   //! See #SALOME_View::Erase( const SALOME_VTKPrs*, const bool = false )
191   void Erase( const SALOME_VTKPrs*, const bool = false );
192
193   //! See #SALOME_View::EraseAll( SALOME_Displayer*, const bool = false )
194   void EraseAll( SALOME_Displayer*, const bool = false );
195
196   //! See #SALOME_View::getVisible( SALOME_ListIO& )
197   virtual void GetVisible( SALOME_ListIO& );
198
199   //! See #SALOME_View::CreatePrs( const char* entry = 0 )
200   SALOME_Prs* CreatePrs( const char* entry = 0 );
201
202   //! See #SALOME_View::isVisible( const Handle(SALOME_InteractiveObject)& )
203   virtual bool isVisible( const Handle(SALOME_InteractiveObject)& );
204
205   //! See #SALOME_View::Repaint()
206   virtual void Repaint();
207
208  signals:
209   void actorAdded(SVTK_ViewWindow*, VTKViewer_Actor*);
210   void actorRemoved(SVTK_ViewWindow*, VTKViewer_Actor*);
211
212 protected slots:
213   void onMousePress(SUIT_ViewWindow*, QMouseEvent*);
214   void onMouseMove(SUIT_ViewWindow*, QMouseEvent*);
215   void onMouseRelease(SUIT_ViewWindow*, QMouseEvent*);
216
217   void onDumpView();
218   void onChangeBackground();
219
220   void onActorAdded(VTKViewer_Actor*);
221   void onActorRemoved(VTKViewer_Actor*);
222
223 private:
224   void updateToolBars();
225
226   Qtx::BackgroundData  myDefaultBackground;
227   double myTrihedronSize;
228   bool                 myTrihedronRelative;
229   bool                 myIsStaticTrihedronVisible;
230   bool                 mySelectionEnabled;
231   bool                 myMultiSelectionEnabled;
232   int                  myIncrementSpeed;
233   int                  myIncrementMode;
234   int                  myProjMode;
235   int                  myStereoType;
236   int                  myAnaglyphFilter;
237   bool                 myQuadBufferSupport;
238   int                  myStyle;
239   int                  myZoomingStyle;
240   Preselection_Mode    myPreSelectionMode;
241   int                  mySpaceBtn[3];
242 };
243
244 #endif