Salome HOME
Join modifications from branch OCC_development_for_3_2_0a2
[modules/visu.git] / src / OBJECT / VISU_Actor.h
1 //  VISU OBJECT : interactive object for VISU entities implementation
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   : 
25 //  Author : 
26 //  Module : VISU
27 //  $Header$
28
29 #ifndef VISU_ACTOR_H
30 #define VISU_ACTOR_H
31
32 #include "SALOME_Actor.h"
33 #include "VISU_ActorFactory.h"
34 #include "VISU_BoostSignals.h"
35
36 #include <string>
37 #include <vtkSmartPointer.h>
38
39 class vtkProp;
40 class vtkProperty;
41 class vtkDataSetMapper;
42 class vtkTextMapper;
43 class vtkTextActor;
44 class vtkInteractorStyle;
45 class VTKViewer_ShrinkFilter;
46 class VISU_PipeLine;
47
48 #ifdef _WIN_32
49 #define VTKOCC_EXPORT __declspec (dllexport)
50 #else
51 #define VTKOCC_EXPORT VTK_EXPORT
52 #endif
53
54 namespace VISU 
55 {
56   class Prs3d_i;
57 }
58
59 //----------------------------------------------------------------------------
60 class VTKOCC_EXPORT VISU_Actor : 
61   public SALOME_Actor,
62   public boost::signalslib::trackable
63 {
64  public:
65   vtkTypeMacro(VISU_Actor,SALOME_Actor);
66
67   static 
68   VISU_Actor* 
69   New();
70
71   void
72   ShallowCopy(vtkProp *prop);
73
74   virtual
75   void
76   ShallowCopyPL(VISU_PipeLine* thePipeLine);
77
78   //----------------------------------------------------------------------------
79   virtual
80   void
81   setIO(const Handle(SALOME_InteractiveObject)& theIO);
82
83   //----------------------------------------------------------------------------
84   VISU::Prs3d_i* 
85   GetPrs3d();
86
87   virtual
88   void
89   SetPrs3d(VISU::Prs3d_i* thePrs3d);
90
91   //----------------------------------------------------------------------------
92   VISU::TActorFactory* 
93   GetFactory();
94
95   virtual
96   void
97   SetFactory(VISU::TActorFactory* theActorFactory);
98
99   //----------------------------------------------------------------------------
100   virtual
101   void
102   UpdateFromFactory();
103
104   virtual
105   void
106   RemoveFromRender();
107
108   //----------------------------------------------------------------------------
109   virtual
110   VISU_PipeLine* 
111   GetPipeLine();
112
113   virtual 
114   void
115   SetPipeLine(VISU_PipeLine* thePipeLine);
116
117   //----------------------------------------------------------------------------
118   virtual
119   void
120   SetRepresentation(int theMode);
121
122   //----------------------------------------------------------------------------
123   virtual
124   bool
125   IsShrunkable();
126
127   virtual
128   bool
129   IsShrunk();
130
131   virtual
132   void
133   SetShrink();
134
135   virtual
136   void
137   UnShrink(); 
138
139   virtual
140   void
141   SetShrinkable(bool theIsShrinkable);
142
143   virtual
144   void
145   SetShrinkFactor(float theFactor = 0.8); 
146
147   virtual
148   float
149   GetShrinkFactor();
150
151   //----------------------------------------------------------------------------
152   virtual
153   void
154   SetOpacity(float theValue);
155
156   virtual
157   float
158   GetOpacity();
159
160   virtual
161   void
162   SetLineWidth(float theLineWidth);
163
164   virtual
165   float
166   GetLineWidth();
167  
168   //----------------------------------------------------------------------------
169   virtual
170   void
171   AddToRender( vtkRenderer* ); 
172
173   virtual
174   void
175   RemoveFromRender( vtkRenderer* );
176
177   //----------------------------------------------------------------------------
178   virtual
179   bool
180   PreHighlight(vtkInteractorStyle* theInteractorStyle, 
181                SVTK_SelectionEvent* theSelectionEvent,
182                bool theIsHighlight);
183
184   virtual
185   void 
186   SetVTKMapping(bool theIsVTKMapping); 
187
188   virtual
189   bool 
190   IsVTKMapping() const;
191
192   virtual
193   vtkDataSet* 
194   GetInput(); 
195
196   //----------------------------------------------------------------------------
197   virtual
198   vtkIdType
199   GetNodeObjId(vtkIdType theID);
200
201   virtual
202   vtkIdType
203   GetNodeVTKID(vtkIdType theID);
204
205   virtual
206   float* 
207   GetNodeCoord(vtkIdType theObjID);
208
209   virtual
210   vtkIdType
211   GetElemObjId(vtkIdType theID);
212
213   virtual
214   vtkIdType
215   GetElemVTKID(vtkIdType theID);
216
217   virtual
218   vtkCell* 
219   GetElemCell(vtkIdType theObjID);
220
221   //----------------------------------------------------------------------------
222  protected:
223   VISU_Actor();
224
225   virtual
226   ~VISU_Actor();
227  
228   virtual 
229   void
230   SetMapperInput(vtkDataSet* theDataSet);
231
232   virtual
233   VISU_PipeLine* 
234   GetCurrentPL();
235
236   //----------------------------------------------------------------------------
237   bool myIsVTKMapping;
238   VISU::Prs3d_i* myPrs3d;
239   vtkSmartPointer<VISU_PipeLine> myPipeLine;
240   vtkSmartPointer<vtkDataSetMapper> myMapper;
241
242   VISU::TActorFactory* myActorFactory;
243   boost::signal1<void,VISU_Actor*> myDestroySignal;
244
245   vtkSmartPointer<VTKViewer_ShrinkFilter> myShrinkFilter;
246   bool myIsShrinkable;
247   bool myIsShrunk;
248
249   vtkSmartPointer<vtkTextMapper> myAnnotationMapper;
250   vtkSmartPointer<vtkTextActor>  myAnnotationActor;
251 };
252
253 #endif //VISU_ACTOR_H