]> SALOME platform Git repositories - modules/gui.git/blob - src/SVTK/SALOME_Actor.h
Salome HOME
d377ff633a148f0a96680711ef0f00c8d08f5f0e
[modules/gui.git] / src / SVTK / SALOME_Actor.h
1 //  SALOME OBJECT : implementation of interactive object visualization for OCC and VTK viewers
2 //
3 //  Copyright (C) 2003  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. 
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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
21 //
22 //
23 //
24 //  File   : SALOME_Actor.h
25 //  Author : Nicolas REJNERI
26 //  Module : SALOME
27 //  $Header$
28
29 #ifndef SALOME_ACTOR_H
30 #define SALOME_ACTOR_H
31
32 #include "SVTK_SelectionEvent.h"
33 #include "SVTK_Selector.h"
34 #include "SVTK.h"
35
36 #include "SALOME_InteractiveObject.hxx"
37
38 // undefining min and max because CASCADE's defines them and
39 // it clashes with std::min(), std::max()
40 #undef min
41 #undef max
42
43 #include "VTKViewer_Actor.h"
44
45 #include <vtkSmartPointer.h>
46
47 class vtkPointPicker;
48 class vtkCellPicker;
49 class vtkOutlineSource;
50 class vtkInteractorStyle;
51 class vtkRenderWindowInteractor;
52
53 class SVTK_Actor;
54 class SVTK_RectPicker;
55 class SVTK_InteractorStyle;
56
57 extern int SALOME_POINT_SIZE;
58 extern int SALOME_LINE_WIDTH;
59
60 //! The class is a basic one for all SALOME VTK presentation.
61 /*!
62   It provide highlight and prehighlight capabilites,
63   common way to publish and remove VTK presentation, 
64   mapping of VTK and object IDs and so on.
65  */
66 class SVTK_EXPORT SALOME_Actor : public VTKViewer_Actor 
67 {
68  public:
69   static SALOME_Actor* New();
70   
71   vtkTypeMacro(SALOME_Actor,VTKViewer_Actor);
72
73   //----------------------------------------------------------------------------
74   //! To check, if the #SALOME_Actor has a reference to #SALOME_InteractiveObject
75   virtual
76   Standard_Boolean 
77   hasIO();
78
79   //! Get correspoinding reference to #SALOME_InteractiveObject
80   virtual 
81   const Handle(SALOME_InteractiveObject)& 
82   getIO(); 
83
84   //! Set reference to #SALOME_InteractiveObject
85   virtual
86   void
87   setIO(const Handle(SALOME_InteractiveObject)& theIO);
88
89   //! Name the #SALOME_Actor
90   virtual
91   void
92   setName(const char* theName);
93
94   //----------------------------------------------------------------------------
95   //! Apply view transformation
96   virtual
97   void
98   SetTransform(VTKViewer_Transform* theTransform); 
99
100   //! Apply additional position
101   virtual
102   void
103   SetPosition(float _arg1, float _arg2, float _arg3);
104
105   //! Apply additional position
106   virtual
107   void
108   SetPosition(float _arg[3]);
109
110   //----------------------------------------------------------------------------
111   //! Visibility management
112   virtual
113   void
114   SetVisibility( int );
115
116   //----------------------------------------------------------------------------
117   //! To publish the actor an all its internal devices
118   virtual
119   void
120   AddToRender(vtkRenderer* theRendere); 
121
122   //! To remove the actor an all its internal devices
123   virtual
124   void
125   RemoveFromRender(vtkRenderer* theRendere);
126
127   //! Get reference on renderer where it is published
128   vtkRenderer*
129   GetRenderer();
130
131   //----------------------------------------------------------------------------
132   //! To set interactor in order to use #vtkInteractorObserver devices
133   virtual
134   void
135   SetInteractor(vtkRenderWindowInteractor* theInteractor);
136
137   //! Put a request to redraw the view 
138   virtual
139   void
140   Update();
141
142   //----------------------------------------------------------------------------
143   //! Set selector in order to the actor at any time can restore current selection
144   virtual
145   void
146   SetSelector(SVTK_Selector* theSelector);
147
148   //! Just to update visibility of the highlight devices
149   virtual
150   void
151   highlight(bool theHighlight);  
152
153   //! To map current selection to VTK representation
154   virtual
155   void
156   Highlight(bool theHighlight);  
157
158   //----------------------------------------------------------------------------
159   //! To process prehighlight (called from #SVTK_InteractorStyle)
160   virtual
161   bool
162   PreHighlight(vtkInteractorStyle* theInteractorStyle, 
163                SVTK_SelectionEvent* theSelectionEvent,
164                bool theIsHighlight);
165
166   //! To process highlight (called from #SVTK_InteractorStyle)
167   virtual 
168   bool
169   Highlight(vtkInteractorStyle* theInteractorStyle, 
170             SVTK_SelectionEvent* theSelectionEvent,
171             bool theIsHighlight);
172
173   //----------------------------------------------------------------------------
174   //! To set up a picker for nodal selection (initialized by #SVTK_Renderer::AddActor)
175   void
176   SetPointPicker(vtkPointPicker* thePointPicker); 
177
178   //! To set up a picker for cell selection (initialized by #SVTK_Renderer::AddActor)
179   void
180   SetCellPicker(vtkCellPicker* theCellPicker); 
181
182   //! To set up a picker for point rectangle selection (initialized by #SVTK_Renderer::AddActor)
183   void
184   SetPointRectPicker(SVTK_RectPicker* theRectPicker);
185
186   //! To set up a picker for cell rectangle selection (initialized by #SVTK_Renderer::AddActor)
187   void
188   SetCellRectPicker(SVTK_RectPicker* theRectPicker);
189
190   //----------------------------------------------------------------------------
191   //! To set up a prehighlight property (initialized by #SVTK_Renderer::AddActor)
192   void
193   SetPreHighlightProperty(vtkProperty* theProperty);
194
195   //! To set up a highlight property (initialized by #SVTK_Renderer::AddActor)
196   void
197   SetHighlightProperty(vtkProperty* theProperty);
198
199  protected:
200   //----------------------------------------------------------------------------
201   vtkRenderWindowInteractor* myInteractor;
202   vtkRenderer* myRenderer;
203
204   Handle(SALOME_InteractiveObject) myIO;
205
206   SALOME_Actor();
207   ~SALOME_Actor();
208
209  protected:
210   Selection_Mode mySelectionMode;
211   vtkSmartPointer<SVTK_Selector> mySelector;
212
213   //----------------------------------------------------------------------------
214   // Highlight/ Prehighlight devices
215   vtkSmartPointer<vtkPointPicker> myPointPicker;
216   vtkSmartPointer<vtkCellPicker> myCellPicker;
217
218   vtkSmartPointer<SVTK_RectPicker> myPointRectPicker;
219   vtkSmartPointer<SVTK_RectPicker> myCellRectPicker;
220
221   vtkSmartPointer<SVTK_Actor> myPreHighlightActor;
222   vtkSmartPointer<SVTK_Actor> myHighlightActor;
223
224   vtkSmartPointer<VTKViewer_Actor> myOutlineActor;
225   vtkSmartPointer<vtkOutlineSource> myOutline;
226 };
227
228 #endif // SALOME_ACTOR_H