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