Salome HOME
IPAL52528: TC7.5.0: Dump study - transparency is lost
[modules/gui.git] / src / SVTK / SVTK_ViewModel.h
1 // Copyright (C) 2007-2014  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   typedef SVTK_ViewWindow TViewWindow;
64   
65   //! Define string representation of the viewer type
66   static QString           Type() { return "VTKViewer"; }
67   static QString           backgroundData( QStringList&, QIntList&, QIntList& );
68
69   SVTK_Viewer();
70   virtual ~SVTK_Viewer();
71
72   //! See #SUIT_ViewModel::createView
73   virtual SUIT_ViewWindow* createView(SUIT_Desktop*);
74
75   //! See #SUIT_ViewModel::createView
76   virtual void setViewManager(SUIT_ViewManager* theViewManager);
77
78   //! See #SUIT_ViewModel::contextMenuPopup
79   virtual void contextMenuPopup( QMenu* );
80
81   //! See #SUIT_ViewModel::getType
82   virtual QString getType() const { return Type(); }
83
84   //! Get background color of the viewer [obsolete]
85   QColor backgroundColor() const;
86
87   //! Set background color to the viewer [obsolete]
88   void setBackgroundColor( const QColor& );
89
90   //! Get background color of the viewer
91   Qtx::BackgroundData background() const;
92
93   //! Set background color to the viewer
94   void setBackground( const Qtx::BackgroundData& );
95
96   //! Get size of trihedron of the viewer (see #SVTK_Renderer::SetTrihedronSize)
97   double trihedronSize() const;
98
99   //! Shows if the size of trihedron relative (see #SVTK_Renderer::SetTrihedronSize)
100   bool trihedronRelative() const;
101
102   //! Set size of trihedron of the viewer (see #SVTK_Renderer::SetTrihedronSize)
103   void setTrihedronSize( const double, const bool = true );
104
105   //! Get visibility status of the static trihedron
106   bool isStaticTrihedronVisible() const;
107
108   //! Set visibility status of the static trihedron
109   void setStaticTrihedronVisible( const bool );
110
111   //! Gets projection mode
112   int projectionMode() const;
113
114   //! Sets projection mode
115   void setProjectionMode( const int );
116
117   //! Gets interaction style
118   int interactionStyle() const;
119
120   //! Sets interaction style
121   void setInteractionStyle( const int );
122
123   //! Gets zooming style
124   int zoomingStyle() const;
125
126   //! Sets zooming style
127   void setZoomingStyle( const int );
128
129   //! Gets current preselection mode (standard, dynamic or disabled)
130   Preselection_Mode preSelectionMode() const;
131
132   //! Sets new preselection mode
133   void setPreSelectionMode( Preselection_Mode );
134  
135   //! Get incremental speed (see #SVTK_InteractorStyle::ControllerIncrement)
136   int incrementalSpeed() const;
137
138   //! Returns modification mode of incremental speed (see #SVTK_InteractorStyle::ControllerIncrement)
139   int incrementalSpeedMode() const;
140
141   //! Set the incremental speed for view operation (see #SVTK_InteractorStyle::ControllerIncrement)
142   void setIncrementalSpeed( const int, const int = 0 );
143
144   //! Gets spacemouse button for specified function
145   int spacemouseBtn( const int ) const;
146
147   //! Sets spacemouse buttons
148   void setSpacemouseButtons( const int, const int, const int );
149
150 public:
151   void enableSelection(bool isEnabled);
152   bool isSelectionEnabled() const { return mySelectionEnabled; }
153
154   void enableMultiselection(bool isEnable);
155   bool isMultiSelectionEnabled() const { return myMultiSelectionEnabled; }
156
157   int  getSelectionCount() const;
158
159   /* Reimplemented from SALOME_View */
160
161   //! See #SALOME_View::Display( const SALOME_Prs* )
162   void Display( const SALOME_VTKPrs* ); 
163
164   //! See #SALOME_View::Erase( const SALOME_VTKPrs*, const bool = false )
165   void Erase( const SALOME_VTKPrs*, const bool = false );
166
167   //! See #SALOME_View::EraseAll( SALOME_Displayer*, const bool = false )
168   void EraseAll( SALOME_Displayer*, const bool = false );
169
170   //! See #SALOME_View::getVisible( SALOME_ListIO& )
171   virtual void GetVisible( SALOME_ListIO& );
172
173   //! See #SALOME_View::CreatePrs( const char* entry = 0 )
174   SALOME_Prs* CreatePrs( const char* entry = 0 );
175
176   //! See #SALOME_View::isVisible( const Handle(SALOME_InteractiveObject)& )
177   virtual bool isVisible( const Handle(SALOME_InteractiveObject)& );
178
179   //! See #SALOME_View::Repaint()
180   virtual void Repaint();
181
182  signals:
183   void actorAdded(SVTK_ViewWindow*, VTKViewer_Actor*);
184   void actorRemoved(SVTK_ViewWindow*, VTKViewer_Actor*);
185
186 protected slots:
187   void onMousePress(SUIT_ViewWindow*, QMouseEvent*);
188   void onMouseMove(SUIT_ViewWindow*, QMouseEvent*);
189   void onMouseRelease(SUIT_ViewWindow*, QMouseEvent*);
190
191   void onDumpView();
192   void onChangeBackground();
193
194   void onActorAdded(VTKViewer_Actor*);
195   void onActorRemoved(VTKViewer_Actor*);
196
197 private:
198   void updateToolBars();
199
200   Qtx::BackgroundData  myDefaultBackground;
201   double myTrihedronSize;
202   bool                 myTrihedronRelative;
203   bool                 myIsStaticTrihedronVisible;
204   bool                 mySelectionEnabled;
205   bool                 myMultiSelectionEnabled;
206   int                  myIncrementSpeed;
207   int                  myIncrementMode;
208   int                  myProjMode;
209   int                  myStyle;
210   int                  myZoomingStyle;
211   Preselection_Mode    myPreSelectionMode;
212   int                  mySpaceBtn[3];
213 };
214
215 #endif