Salome HOME
Join modifications from branch OCC_debug_for_3_2_0b1
[modules/gui.git] / src / SVTK / SVTK_View.h
1 // Copyright (C) 2005  CEA/DEN, EDF R&D, OPEN CASCADE, PRINCIPIA R&D
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License.
7 //
8 // This library is distributed in the hope that it will be useful
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 // See http://www.salome-platform.org/
18 //
19 #ifndef SVTK_VIEW_H
20 #define SVTK_VIEW_H
21
22 #ifdef WIN32
23 #pragma warning( disable:4251 )
24 #endif
25
26 #include "SVTK.h"
27 #include "SALOME_InteractiveObject.hxx"
28
29 #include <qobject.h>
30
31 class vtkActorCollection;
32 class vtkRenderer;
33
34 class SVTK_MainWindow;
35 class SVTK_Renderer;
36
37 class SALOME_Actor;
38
39 //! Main purpose of the class is to provide a way to customize #SVTK_MainWindow.
40 /*!
41   This class is initialized by #SVTK_MainWindow and just pass Qt signals from 
42   corresponding #SVTK_RenderWindowInteractor of the #SVTK_MainWindow.
43   Its main purpose is to provide a simple and flexible way to customize the #SVTK_MainWindow.
44   So, in your own viewer it is possible to derive new #SVTK_MainWindow and 
45   use existing functionality without any modifications.
46  */
47 class SVTK_EXPORT SVTK_SignalHandler : public QObject
48 {
49   Q_OBJECT;
50
51 public:
52   SVTK_SignalHandler(SVTK_MainWindow* theMainWindow);
53
54   virtual
55   ~SVTK_SignalHandler();
56
57   //! Get reference to its #SVTK_MainWindow
58   SVTK_MainWindow*
59   GetMainWindow();
60
61   //----------------------------------------------------------------------------
62   //! Redirect the request to #SVTK_MainWindow::Repaint (just for flexibility)
63   void
64   Repaint(bool theUpdateTrihedron = true);
65
66   //----------------------------------------------------------------------------
67   //! Redirect the request to #SVTK_MainWindow::GetRenderer (just for flexibility)
68   SVTK_Renderer* 
69   GetRenderer();
70
71   //! Redirect the request to #SVTK_MainWindow::getRenderer (just for flexibility)
72   vtkRenderer* 
73   getRenderer();
74
75   //----------------------------------------------------------------------------
76  public slots:
77   void onSelectionChanged();
78
79  public:
80  signals:
81   void MouseMove( QMouseEvent* );
82   void MouseButtonPressed( QMouseEvent* );
83   void MouseButtonReleased( QMouseEvent* );
84   void MouseDoubleClicked( QMouseEvent* );
85   void ButtonPressed(const QMouseEvent *event);
86   void ButtonReleased(const QMouseEvent *event);
87   void WheelMoved( QWheelEvent* );
88   void KeyPressed( QKeyEvent* );
89   void KeyReleased( QKeyEvent* );
90   void contextMenuRequested( QContextMenuEvent *e );
91   void selectionChanged();
92
93  protected:
94   SVTK_MainWindow* myMainWindow;
95 };
96
97
98 //! This class is introduced just for compatibility with old code.
99 /*!
100   This class contains frequantly used functionality in old code.
101   Now, you are supposed to extend existing functionality through
102   writing corresponding functors (see SVTK_Functor.h for example).
103  */
104 class SVTK_EXPORT SVTK_View : public SVTK_SignalHandler
105 {
106   Q_OBJECT;
107
108 public:
109   SVTK_View(SVTK_MainWindow* theMainWindow);
110
111   virtual
112   ~SVTK_View();
113   
114   /*  interactive object management */
115   //! To highlight a VTK presentation with the same #SALOME_InteractiveObject
116   void
117   highlight(const Handle(SALOME_InteractiveObject)& IObject, 
118             bool highlight, 
119             bool immediatly = true);
120
121   //! To unhighlight all VTK presentations
122   void
123   unHighlightAll();
124
125   //! Try to find a SALOME_InteractiveObject in the view that corresponds to the entry
126   Handle(SALOME_InteractiveObject) 
127   FindIObject(const char* Entry);
128
129   //! Check, if the viewer contains a presentatin with defined #SALOME_InteractiveObject
130   bool
131   isInViewer(const Handle(SALOME_InteractiveObject)& IObject);
132
133   //! Check, if a presentatin with defined #SALOME_InteractiveObject is visible
134   bool
135   isVisible(const Handle(SALOME_InteractiveObject)& IObject);
136
137   void
138   rename(const Handle(SALOME_InteractiveObject)& IObject, 
139          const QString& newName);
140   
141   //----------------------------------------------------------------------------
142   // Displaymode management
143   //! Get current display mode (obsolete)
144   int 
145   GetDisplayMode();
146
147   //! Set current display mode
148   void
149   SetDisplayMode(int);
150
151   //! Switch representation wireframe/shading
152   void
153   SetDisplayMode(const Handle(SALOME_InteractiveObject)& IObject, 
154                  int theMode);
155
156   //! Change all actors to wireframe
157   void 
158   ChangeRepresentationToWireframe();
159
160   //! Change all actors to surface
161   void
162   ChangeRepresentationToSurface();
163
164   //! Change to wireframe a list of vtkactor
165   void
166   ChangeRepresentationToWireframe(vtkActorCollection* theListofActors);
167
168   //! Change to surface a list of vtkactor
169   void
170   ChangeRepresentationToSurface(vtkActorCollection* theListofActors);
171
172   //! Change transparency
173   void
174   SetTransparency(const Handle(SALOME_InteractiveObject)& theIObject,
175                   float trans);
176
177   //! Get current transparency
178   float 
179   GetTransparency(const Handle(SALOME_InteractiveObject)& theIObject);
180
181   //! Change color
182   void
183   SetColor(const Handle(SALOME_InteractiveObject)& theIObject,
184            const QColor& theColor);
185
186   //! Get current color
187   QColor
188   GetColor(const Handle(SALOME_InteractiveObject)& theIObject);
189
190   //----------------------------------------------------------------------------
191   // Erase Display functions
192   //! To erase all existing VTK presentations
193   void
194   EraseAll();
195
196   //! To display all existing VTK presentations
197   void
198   DisplayAll();
199
200   //! To remove from the view all existing VTK presentations
201   void
202   RemoveAll( const bool immediatly );
203
204   //! To erase VTK presentation with defined #SALOME_InteractiveObject
205   void
206   Erase(const Handle(SALOME_InteractiveObject)& IObject, 
207         bool immediatly = true);
208   void
209   Remove(const Handle(SALOME_InteractiveObject)& IObject, 
210          bool immediatly = true);
211
212   //! To display VTK presentation with defined #SALOME_InteractiveObject
213   void
214   Display(const Handle(SALOME_InteractiveObject)& IObject, 
215           bool immediatly = true);
216
217   //! To display VTK presentation with defined #SALOME_InteractiveObject and erase all anothers
218   void
219   DisplayOnly(const Handle(SALOME_InteractiveObject)& IObject);
220
221   //! To display the VTK presentation
222   void
223   Display(SALOME_Actor* SActor, 
224           bool immediatly = true);
225
226   //! To erase the VTK presentation
227   void
228   Erase(SALOME_Actor* SActor, 
229         bool immediatly = true);
230
231   //! To remove the VTK presentation
232   void
233   Remove(SALOME_Actor* SActor, 
234          bool updateViewer = true);
235
236   //----------------------------------------------------------------------------
237   //! Redirect the request to #SVTK_Renderer::SetPreselectionProp
238   void
239   SetSelectionProp(const double& theRed = 1, 
240                    const double& theGreen = 1,
241                    const double& theBlue = 0, 
242                    const int& theWidth = 5);
243
244   //! Redirect the request to #SVTK_Renderer::SetPreselectionProp
245   void
246   SetPreselectionProp(const double& theRed = 0, 
247                       const double& theGreen = 1,
248                       const double& theBlue = 1, 
249                       const int& theWidth = 5);
250
251   //! Redirect the request to #SVTK_Renderer::SetPreselectionProp
252   void
253   SetSelectionTolerance(const double& theTolNodes = 0.025, 
254                         const double& theTolCell = 0.001);
255
256  protected:  
257   int myDisplayMode;
258 };
259
260 #ifdef WIN32
261 #pragma warning( default:4251 )
262 #endif
263
264 #endif