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