]> SALOME platform Git repositories - modules/gui.git/blob - src/SVTK/SALOME_Actor.h
Salome HOME
Join modifications from branch OCC_debug_for_3_2_0b1
[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(vtkFloatingPointType _arg1, 
104               vtkFloatingPointType _arg2, 
105               vtkFloatingPointType _arg3);
106
107   //! Apply additional position
108   virtual
109   void
110   SetPosition(vtkFloatingPointType _arg[3]);
111
112   //----------------------------------------------------------------------------
113   //! Visibility management
114   virtual
115   void
116   SetVisibility( int );
117
118   //----------------------------------------------------------------------------
119   //! To publish the actor an all its internal devices
120   virtual
121   void
122   AddToRender(vtkRenderer* theRendere); 
123
124   //! To remove the actor an all its internal devices
125   virtual
126   void
127   RemoveFromRender(vtkRenderer* theRendere);
128
129   //! Get reference on renderer where it is published
130   vtkRenderer*
131   GetRenderer();
132
133   //----------------------------------------------------------------------------
134   //! To set interactor in order to use #vtkInteractorObserver devices
135   virtual
136   void
137   SetInteractor(vtkRenderWindowInteractor* theInteractor);
138
139   //! Put a request to redraw the view 
140   virtual
141   void
142   Update();
143
144   //----------------------------------------------------------------------------
145   //! Set selector in order to the actor at any time can restore current selection
146   virtual
147   void
148   SetSelector(SVTK_Selector* theSelector);
149
150   //! Just to update visibility of the highlight devices
151   virtual
152   void
153   highlight(bool theHighlight);  
154
155   //! To map current selection to VTK representation
156   virtual
157   void
158   Highlight(bool theHighlight);  
159
160   //----------------------------------------------------------------------------
161   //! To process prehighlight (called from #SVTK_InteractorStyle)
162   virtual
163   bool
164   PreHighlight(vtkInteractorStyle* theInteractorStyle, 
165                SVTK_SelectionEvent* theSelectionEvent,
166                bool theIsHighlight);
167
168   //! To process highlight (called from #SVTK_InteractorStyle)
169   virtual 
170   bool
171   Highlight(vtkInteractorStyle* theInteractorStyle, 
172             SVTK_SelectionEvent* theSelectionEvent,
173             bool theIsHighlight);
174
175   //----------------------------------------------------------------------------
176   //! To set up a picker for nodal selection (initialized by #SVTK_Renderer::AddActor)
177   void
178   SetPointPicker(vtkPointPicker* thePointPicker); 
179
180   //! To set up a picker for cell selection (initialized by #SVTK_Renderer::AddActor)
181   void
182   SetCellPicker(vtkCellPicker* theCellPicker); 
183
184   //! To set up a picker for point rectangle selection (initialized by #SVTK_Renderer::AddActor)
185   void
186   SetPointRectPicker(SVTK_RectPicker* theRectPicker);
187
188   //! To set up a picker for cell rectangle selection (initialized by #SVTK_Renderer::AddActor)
189   void
190   SetCellRectPicker(SVTK_RectPicker* theRectPicker);
191
192   //----------------------------------------------------------------------------
193   //! To set up a prehighlight property (initialized by #SVTK_Renderer::AddActor)
194   void
195   SetPreHighlightProperty(vtkProperty* theProperty);
196
197   //! To set up a highlight property (initialized by #SVTK_Renderer::AddActor)
198   void
199   SetHighlightProperty(vtkProperty* theProperty);
200
201  protected:
202   //----------------------------------------------------------------------------
203   vtkRenderWindowInteractor* myInteractor;
204   vtkRenderer* myRenderer;
205
206   Handle(SALOME_InteractiveObject) myIO;
207
208   SALOME_Actor();
209   ~SALOME_Actor();
210
211  protected:
212   Selection_Mode mySelectionMode;
213   vtkSmartPointer<SVTK_Selector> mySelector;
214
215   //----------------------------------------------------------------------------
216   // Highlight/ Prehighlight devices
217   vtkSmartPointer<vtkPointPicker> myPointPicker;
218   vtkSmartPointer<vtkCellPicker> myCellPicker;
219
220   vtkSmartPointer<SVTK_RectPicker> myPointRectPicker;
221   vtkSmartPointer<SVTK_RectPicker> myCellRectPicker;
222
223   vtkSmartPointer<SVTK_Actor> myPreHighlightActor;
224   vtkSmartPointer<SVTK_Actor> myHighlightActor;
225
226   vtkSmartPointer<VTKViewer_Actor> myOutlineActor;
227   vtkSmartPointer<vtkOutlineSource> myOutline;
228 };
229
230 #endif // SALOME_ACTOR_H