vtkActor.hh 8.68 KB
Newer Older
Ken Martin's avatar
Ken Martin committed
1
2
/*=========================================================================

Ken Martin's avatar
Ken Martin committed
3
  Program:   Visualization Toolkit
Ken Martin's avatar
Ken Martin committed
4
  Module:    vtkActor.hh
Ken Martin's avatar
Ken Martin committed
5
6
7
8
9
  Language:  C++
  Date:      $Date$
  Version:   $Revision$


10
Copyright (c) 1993-1996 Ken Martin, Will Schroeder, Bill Lorensen.
Ken Martin's avatar
Ken Martin committed
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38

This software is copyrighted by Ken Martin, Will Schroeder and Bill Lorensen.
The following terms apply to all files associated with the software unless
explicitly disclaimed in individual files. This copyright specifically does
not apply to the related textbook "The Visualization Toolkit" ISBN
013199837-4 published by Prentice Hall which is covered by its own copyright.

The authors hereby grant permission to use, copy, and distribute this
software and its documentation for any purpose, provided that existing
copyright notices are retained in all copies and that this notice is included
verbatim in any distributions. Additionally, the authors grant permission to
modify this software and its documentation for any purpose, provided that
such modifications are not distributed without the explicit consent of the
authors and that existing copyright notices are retained in all copies. Some
of the algorithms implemented by this software are patented, observe all
applicable patent law.

IN NO EVENT SHALL THE AUTHORS OR DISTRIBUTORS BE LIABLE TO ANY PARTY FOR
DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
OF THE USE OF THIS SOFTWARE, ITS DOCUMENTATION, OR ANY DERIVATIVES THEREOF,
EVEN IF THE AUTHORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

THE AUTHORS AND DISTRIBUTORS SPECIFICALLY DISCLAIM ANY WARRANTIES, INCLUDING,
BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
PARTICULAR PURPOSE, AND NON-INFRINGEMENT.  THIS SOFTWARE IS PROVIDED ON AN
"AS IS" BASIS, AND THE AUTHORS AND DISTRIBUTORS HAVE NO OBLIGATION TO PROVIDE
MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.

Ken Martin's avatar
Ken Martin committed
39
40

=========================================================================*/
Will Schroeder's avatar
Will Schroeder committed
41
// .NAME vtkActor - represents an object (geometry & properties) in a rendered scene 
Ken Martin's avatar
Ken Martin committed
42
// .SECTION Description
Ken Martin's avatar
Ken Martin committed
43
44
// vtkActor is used to represent an entity in a rendering scene.  It
// handles functions related to the actors position, orientation and
45
// scaling. It combines these instance variables into one 4x4
Ken Martin's avatar
Ken Martin committed
46
47
48
// transformation matrix as follows: [x y z 1] = [x y z 1]
// Translate(-origin) Scale(scale) Rot(y) Rot(x) Rot (z) Trans(origin)
// Trans(position). The actor also maintains a reference to the
49
// defining geometry (i.e., the mapper), rendering properties, and
Ken Martin's avatar
Ken Martin committed
50
51
52
// possibly a texture map.

// .SECTION See Also
53
54
// vtkProperty vtkTexture vtkMapper vtkActorDevice
// vtkAssembly vtkFollower vtkLODActor
Ken Martin's avatar
Ken Martin committed
55

Ken Martin's avatar
Ken Martin committed
56
57
#ifndef __vtkActor_hh
#define __vtkActor_hh
Ken Martin's avatar
Ken Martin committed
58

Ken Martin's avatar
Ken Martin committed
59
60
61
62
63
#include "vtkObject.hh"
#include "vtkProperty.hh"
#include "vtkTexture.hh"
#include "vtkMapper.hh"
#include "vtkTransform.hh"
64
#include "vtkAssemblyPaths.hh"
Ken Martin's avatar
Ken Martin committed
65

Ken Martin's avatar
Ken Martin committed
66
class vtkRenderer;
Will Schroeder's avatar
Will Schroeder committed
67
class vtkActorDevice;
Bill Lorensen's avatar
ENH:    
Bill Lorensen committed
68
69
class vtkProperty;
class vtkMapper;
Ken Martin's avatar
Ken Martin committed
70

Ken Martin's avatar
Ken Martin committed
71
class vtkActor : public vtkObject
Ken Martin's avatar
Ken Martin committed
72
73
{
 public:
Ken Martin's avatar
Ken Martin committed
74
75
76
77
  vtkActor();
  ~vtkActor();
  char *GetClassName() {return "vtkActor";};
  void PrintSelf(ostream& os, vtkIndent indent);
Ken Martin's avatar
Ken Martin committed
78

Ken Martin's avatar
Ken Martin committed
79
  virtual void Render(vtkRenderer *ren);
Ken Martin's avatar
Ken Martin committed
80

81
82
  vtkActor &operator=(const vtkActor& actor);

Ken Martin's avatar
Ken Martin committed
83
84
  // Description: 
  // Set/Get the property object that controls this
85
  // actors surface properties.  This should be an instance of a
Will Schroeder's avatar
Will Schroeder committed
86
  // vtkProperty object.  Every actor must have a property associated
87
  // with it.  If one isn't specified, then one will be generated
Ken Martin's avatar
Ken Martin committed
88
  // automatically. Multiple actors can share one property object.
Ken Martin's avatar
Ken Martin committed
89
90
91
  void SetProperty(vtkProperty *lut);
  void SetProperty(vtkProperty& lut) {this->SetProperty(&lut);};
  vtkProperty *GetProperty();
92

Ken Martin's avatar
Ken Martin committed
93
  // Description: 
Will Schroeder's avatar
Will Schroeder committed
94
  // Set/Get the texture object to control rendering
Ken Martin's avatar
Ken Martin committed
95
  // texture maps.  This will be a vtkTexture object. An actor does
Bill Lorensen's avatar
Bill Lorensen committed
96
  // not need to have an associated texture map and multiple actors
Ken Martin's avatar
Ken Martin committed
97
  // can share one texture.
Ken Martin's avatar
Ken Martin committed
98
99
  vtkSetObjectMacro(Texture,vtkTexture);
  vtkGetObjectMacro(Texture,vtkTexture);
Ken Martin's avatar
Ken Martin committed
100

101
102
  // Description:
  // This is the method that is used to connect an actor to the end of a
Will Schroeder's avatar
Will Schroeder committed
103
  // visualization pipeline, i.e. the mapper. This should be a subclass
Ken Martin's avatar
Ken Martin committed
104
105
  // of vtkMapper. Typically vtkPolyMapper and vtkDataSetMapper will
  // be used.
Ken Martin's avatar
Ken Martin committed
106
  vtkSetObjectMacro(Mapper,vtkMapper);
Ken Martin's avatar
Ken Martin committed
107

108
  // Description:
109
  // Returns the Mapper that this actor is getting its data from.
Ken Martin's avatar
Ken Martin committed
110
  vtkGetObjectMacro(Mapper,vtkMapper);
Ken Martin's avatar
Ken Martin committed
111

Ken Martin's avatar
Ken Martin committed
112
  // Description:
Ken Martin's avatar
Ken Martin committed
113
  // In addition to the instance variables such as position and orientation,
114
115
  // you can specify your own 4x4 transformation matrix that will
  // get concatenated with the actor's 4x4 matrix as determined
Ken Martin's avatar
Ken Martin committed
116
117
118
119
  // by the other instance variables. If the other instance variables such
  // as position and orientation are left with  their default values then 
  // they will result in the identity matrix. And the resulting matrix
  // will be the user defined matrix.
Ken Martin's avatar
Ken Martin committed
120
121
  vtkSetObjectMacro(UserMatrix,vtkMatrix4x4);
  vtkGetObjectMacro(UserMatrix,vtkMatrix4x4);
Ken Martin's avatar
Ken Martin committed
122

Ken Martin's avatar
Ken Martin committed
123
  // Description:
Ken Martin's avatar
Ken Martin committed
124
  // Set/Get/Add the position of the actor in world coordinates.
Ken Martin's avatar
Ken Martin committed
125
  vtkSetVector3Macro(Position,float);
Ken Martin's avatar
Ken Martin committed
126
  vtkGetVectorMacro(Position,float,3);
127
  void AddPosition(float deltaPosition[3]);
Will Schroeder's avatar
Will Schroeder committed
128
  void AddPosition(float deltaX,float deltaY,float deltaZ);
Ken Martin's avatar
Ken Martin committed
129

Ken Martin's avatar
Ken Martin committed
130
  // Description:
Ken Martin's avatar
Ken Martin committed
131
  // Set/Get the origin of the actor. This is the point about which all 
Ken Martin's avatar
Ken Martin committed
132
  // rotations take place.
Ken Martin's avatar
Ken Martin committed
133
  vtkSetVector3Macro(Origin,float);
Ken Martin's avatar
Ken Martin committed
134
  vtkGetVectorMacro(Origin,float,3);
Ken Martin's avatar
Ken Martin committed
135

Ken Martin's avatar
Ken Martin committed
136
  // Description:
Ken Martin's avatar
Ken Martin committed
137
  // Set/Get the scale of the actor. Scaling in performed independently on the
138
  // X, Y and Z axis. A scale of zero is illegal and will be replaced with one.
Ken Martin's avatar
Ken Martin committed
139
  vtkSetVector3Macro(Scale,float);
Ken Martin's avatar
Ken Martin committed
140
  vtkGetVectorMacro(Scale,float,3);
Ken Martin's avatar
Ken Martin committed
141

Ken Martin's avatar
Ken Martin committed
142
  // Description:
Ken Martin's avatar
Ken Martin committed
143
  // Set/Get the visibility of the actor. Visibility is like a light switch
Ken Martin's avatar
Ken Martin committed
144
  // for actors. Use it to turn them on or off.
Ken Martin's avatar
Ken Martin committed
145
  vtkSetMacro(Visibility,int);
Ken Martin's avatar
Ken Martin committed
146
  vtkGetMacro(Visibility,int);
Ken Martin's avatar
Ken Martin committed
147
  vtkBooleanMacro(Visibility,int);
Ken Martin's avatar
Ken Martin committed
148

Ken Martin's avatar
Ken Martin committed
149
  // Description:
Ken Martin's avatar
Ken Martin committed
150
  // Set/Get the pickable instance variable.  This determines if the actor can 
Ken Martin's avatar
Ken Martin committed
151
  // be picked (typically using the mouse). Also see dragable.
Ken Martin's avatar
Ken Martin committed
152
  vtkSetMacro(Pickable,int);
Ken Martin's avatar
Ken Martin committed
153
  vtkGetMacro(Pickable,int);
Ken Martin's avatar
Ken Martin committed
154
  vtkBooleanMacro(Pickable,int);
Ken Martin's avatar
Ken Martin committed
155

Ken Martin's avatar
Ken Martin committed
156
  // Description:
Ken Martin's avatar
Ken Martin committed
157
  // Set/Get the value of the dragable instance variable. This determines if 
158
  // an actor, once picked, can be dragged (translated) through space.
Ken Martin's avatar
Ken Martin committed
159
  // This is typically done through an interactive mouse interface.
160
  // This does not affect methods such as SetPosition, which will continue
Ken Martin's avatar
Ken Martin committed
161
  // to work.  It is just intended to prevent some actors from being
Bill Lorensen's avatar
Bill Lorensen committed
162
  // dragged from within a user interface.
Ken Martin's avatar
Ken Martin committed
163
  vtkSetMacro(Dragable,int);
Ken Martin's avatar
Ken Martin committed
164
  vtkGetMacro(Dragable,int);
Ken Martin's avatar
Ken Martin committed
165
  vtkBooleanMacro(Dragable,int);
Ken Martin's avatar
Ken Martin committed
166

Ken Martin's avatar
Ken Martin committed
167
168
  vtkMatrix4x4& GetMatrix();
  virtual void GetMatrix(vtkMatrix4x4& m);
Ken Martin's avatar
Ken Martin committed
169

170
171
  virtual float *GetBounds();
  void GetBounds(float bounds[6]);
Ken Martin's avatar
Ken Martin committed
172
  float *GetCenter();
Ken Martin's avatar
Ken Martin committed
173
174
175
176
177
178
179
180
181
182
183
184
  float *GetXRange();
  float *GetYRange();
  float *GetZRange();

  void RotateX(float);
  void RotateY(float);
  void RotateZ(float);
  void RotateWXYZ(float,float,float,float);

  void SetOrientation(float,float,float);
  void SetOrientation(float a[3]);
  float *GetOrientation();
Ken Martin's avatar
Ken Martin committed
185
  float *GetOrientationWXYZ();
Ken Martin's avatar
Ken Martin committed
186
187
188
  void AddOrientation(float,float,float);
  void AddOrientation(float a[3]);

189
190
191
192
193
194
195
196
197
198
199
  // Description:
  // Subclasses of vtkActor can be composed of one or more parts. A part is an
  // actor or subclass of actor (e.g., vtkAssembly). The methods 
  // InitPartTraversal() and GetNextPart() allow you to get at the parts
  // that compose the actor. To use these methods - first invoke 
  // InitPartTraversal() followed by repeated calls to GetNextPart(). 
  // GetNextPart() returns a NULL pointer when the list is exhausted. (These
  // methods differ from the vtkAssembly::GetParts() method, which returns 
  // a list of the parts that are first level children of the assembly.)
  virtual void InitPartTraversal() {this->TraversalLocation = 0;};
  virtual vtkActor *GetNextPart();
200
  virtual int GetNumberOfParts() {return 1;};
201

202
203
204
205
  // Description:
  // Used to construct assembly paths and perform part traversal.
  virtual void BuildPaths(vtkAssemblyPaths *paths, vtkActorCollection *path);

206
207
208
209
210
211
212
  // Description:
  // Update visualization pipeline and any other parts of actor that are
  // necessary.
  virtual void Update();

  unsigned long int GetMTime();//overload superclasses' implementation

Ken Martin's avatar
Ken Martin committed
213
protected:
Ken Martin's avatar
Ken Martin committed
214
215
216
217
  vtkMatrix4x4 *UserMatrix;
  vtkProperty *Property; 
  vtkTexture *Texture; 
  vtkMapper *Mapper;
Ken Martin's avatar
Ken Martin committed
218
219
220
221
222
  float Origin[3];
  float Position[3];
  float Orientation[3];
  float Scale[3];
  int   Visibility;
Ken Martin's avatar
Ken Martin committed
223
224
  int   Pickable;
  int   Dragable;
Ken Martin's avatar
Ken Martin committed
225
  vtkTransform Transform;
Ken Martin's avatar
Ken Martin committed
226
  float Bounds[6];
Ken Martin's avatar
Ken Martin committed
227
  int SelfCreatedProperty;
Ken Martin's avatar
Ken Martin committed
228
  float Center[3];
Will Schroeder's avatar
Will Schroeder committed
229
  vtkActorDevice *Device;
230

231
232
233
  // this stuff supports multiple-part actors (e.g. assemblies)
  int TraversalLocation;

Ken Martin's avatar
Ken Martin committed
234
235
236
237
};

#endif