1 /*=========================================================================
3 Program: Visualization Toolkit
4 Module: $RCSfile: vtkProp.h,v $
6 Date: $Date: 2002/12/26 18:24:21 $
7 Version: $Revision: 1.39 $
9 Copyright (c) 1993-2002 Ken Martin, Will Schroeder, Bill Lorensen
11 See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
13 This software is distributed WITHOUT ANY WARRANTY; without even
14 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 PURPOSE. See the above copyright notice for more information.
17 =========================================================================*/
18 // .NAME vtkProp - abstract superclass for all actors, volumes and annotations
19 // .SECTION Description
20 // vtkProp is an abstract superclass for any objects that can exist in a
21 // rendered scene (either 2D or 3D). Instances of vtkProp may respond to
22 // various render methods (e.g., RenderOpaqueGeometry()). vtkProp also
23 // defines the API for picking, LOD manipulation, and common instance
24 // variables that control visibility, picking, and dragging.
26 // vtkActor2D vtkActor vtkVolume vtkProp3D
31 #include "vtkObject.h"
33 class vtkAssemblyPath;
34 class vtkAssemblyPaths;
36 class vtkPropCollection;
40 class VTK_COMMON_EXPORT vtkProp : public vtkObject
43 vtkTypeRevisionMacro(vtkProp,vtkObject);
44 void PrintSelf(ostream& os, vtkIndent indent);
47 // For some exporters and other other operations we must be
48 // able to collect all the actors or volumes. These methods
49 // are used in that process.
50 virtual void GetActors(vtkPropCollection *) {}
51 virtual void GetActors2D(vtkPropCollection *) {}
52 virtual void GetVolumes(vtkPropCollection *) {}
55 // Set/Get visibility of this vtkProp.
56 vtkSetMacro(Visibility, int);
57 vtkGetMacro(Visibility, int);
58 vtkBooleanMacro(Visibility, int);
61 // Set/Get the pickable instance variable. This determines if the vtkProp
62 // can be picked (typically using the mouse). Also see dragable.
63 vtkSetMacro(Pickable,int);
64 vtkGetMacro(Pickable,int);
65 vtkBooleanMacro(Pickable,int);
68 // This method is invoked when an instance of vtkProp (or subclass,
69 // e.g., vtkActor) is picked by vtkPicker.
70 void SetPickMethod(void (*f)(void *), void *arg);
71 void SetPickMethodArgDelete(void (*f)(void *));
74 // Method invokes PickMethod() if one defined and the prop is picked.
78 // Set/Get the value of the dragable instance variable. This determines if
79 // an Prop, once picked, can be dragged (translated) through space.
80 // This is typically done through an interactive mouse interface.
81 // This does not affect methods such as SetPosition, which will continue
82 // to work. It is just intended to prevent some vtkProp'ss from being
83 // dragged from within a user interface.
84 vtkSetMacro(Dragable,int);
85 vtkGetMacro(Dragable,int);
86 vtkBooleanMacro(Dragable,int);
89 // Return the mtime of anything that would cause the rendered image to
90 // appear differently. Usually this involves checking the mtime of the
91 // prop plus anything else it depends on such as properties, textures
93 virtual unsigned long GetRedrawMTime() {return this->GetMTime();}
96 // Get the bounds for this Prop as (Xmin,Xmax,Ymin,Ymax,Zmin,Zmax).
97 // in world coordinates. NULL means that the bounds are not defined.
98 virtual float *GetBounds() {return NULL;}
101 // Shallow copy of this vtkProp.
102 virtual void ShallowCopy(vtkProp *prop);
105 // vtkProp and its subclasses can be picked by subclasses of
106 // vtkAbstractPicker (e.g., vtkPropPicker). The following methods interface
107 // with the picking classes and return "pick paths". A pick path is a
108 // hierarchical, ordered list of props that form an assembly. Most often,
109 // when a vtkProp is picked, its path consists of a single node (i.e., the
110 // prop). However, classes like vtkAssembly and vtkPropAssembly can return
111 // more than one path, each path being several layers deep. (See
112 // vtkAssemblyPath for more information.) To use these methods - first
113 // invoke InitPathTraversal() followed by repeated calls to GetNextPath().
114 // GetNextPath() returns a NULL pointer when the list is exhausted.
115 virtual void InitPathTraversal();
116 virtual vtkAssemblyPath *GetNextPath();
117 virtual int GetNumberOfPaths() {return 1;}
120 // These methods are used by subclasses to place a matrix (if any) in the
121 // prop prior to rendering. Generally used only for picking. See vtkProp3D
122 // for more information.
123 virtual void PokeMatrix(vtkMatrix4x4 *vtkNotUsed(matrix)) {}
124 virtual vtkMatrix4x4 *GetMatrix() {return NULL;}
128 // WARNING: INTERNAL METHOD - NOT INTENDED FOR GENERAL USE
129 // DO NOT USE THESE METHODS OUTSIDE OF THE RENDERING PROCESS
130 // All concrete subclasses must be able to render themselves.
131 // There are three key render methods in vtk and they correspond
132 // to three different points in the rendering cycle. Any given
133 // prop may implement one or more of these methods.
134 // The first method is intended for rendering all opaque geometry. The
135 // second method is intended for rendering all translucent geometry. Most
136 // volume rendering mappers draw their results during this second method.
137 // The last method is to render any 2D annotation or overlays.
138 // Each of these methods return an integer value indicating
139 // whether or not this render method was applied to this data.
140 virtual int RenderOpaqueGeometry( vtkViewport *) { return 0; }
141 virtual int RenderTranslucentGeometry( vtkViewport *) { return 0; }
142 virtual int RenderOverlay( vtkViewport *) { return 0; }
145 // WARNING: INTERNAL METHOD - NOT INTENDED FOR GENERAL USE
146 // Release any graphics resources that are being consumed by this actor.
147 // The parameter window could be used to determine which graphic
148 // resources to release.
149 virtual void ReleaseGraphicsResources(vtkWindow *) {}
152 // WARNING: INTERNAL METHOD - NOT INTENDED FOR GENERAL USE
153 // DO NOT USE THESE METHODS OUTSIDE OF THE RENDERING PROCESS
154 // The EstimatedRenderTime may be used to select between different props,
155 // for example in LODProp it is used to select the level-of-detail.
156 // The value is returned in seconds. For simple geometry the accuracy may
157 // not be great due to buffering. For ray casting, which is already
158 // multi-resolution, the current resolution of the image is factored into
159 // the time. We need the viewport for viewing parameters that affect timing.
160 // The no-arguments version simply returns the value of the variable with
162 virtual float GetEstimatedRenderTime( vtkViewport * )
163 { return this->EstimatedRenderTime; }
164 virtual float GetEstimatedRenderTime(){ return this->EstimatedRenderTime; }
167 // WARNING: INTERNAL METHOD - NOT INTENDED FOR GENERAL USE
168 // DO NOT USE THESE METHODS OUTSIDE OF THE RENDERING PROCESS
169 // This method is used by, for example, the vtkLODProp3D in order to
170 // initialize the estimated render time at start-up to some user defined
172 virtual void SetEstimatedRenderTime(float t)
173 {this->EstimatedRenderTime = t; this->SavedEstimatedRenderTime = t;}
176 // WARNING: INTERNAL METHOD - NOT INTENDED FOR GENERAL USE
177 // DO NOT USE THESE METHODS OUTSIDE OF THE RENDERING PROCESS
178 // When the EstimatedRenderTime is first set to 0.0 (in the
179 // SetAllocatedRenderTime method) the old value is saved. This
180 // method is used to restore that old value should the render be
182 virtual void RestoreEstimatedRenderTime()
183 { this->EstimatedRenderTime = this->SavedEstimatedRenderTime; }
187 // WARNING: INTERNAL METHOD - NOT INTENDED FOR GENERAL USE
188 // DO NOT USE THIS METHOD OUTSIDE OF THE RENDERING PROCESS
189 // This method is intended to allow the renderer to add to the
190 // EstimatedRenderTime in props that require information that
191 // the renderer has in order to do this. For example, props
192 // that are rendered with a ray casting method do not know
193 // themselves how long it took for them to render. We don't want to
194 // cause a this->Modified() when we set this value since it is not
195 // really a modification to the object. (For example, we don't want
196 // to rebuild matrices at every render because the estimated render time
198 virtual void AddEstimatedRenderTime(float t, vtkViewport *vtkNotUsed(vp))
199 {this->EstimatedRenderTime+=t;}
202 // WARNING: INTERNAL METHOD - NOT INTENDED FOR GENERAL USE
203 // DO NOT USE THIS METHOD OUTSIDE OF THE RENDERING PROCESS
204 // The renderer may use the allocated rendering time to determine
205 // how to render this actor. Therefore it might need the information
206 // provided in the viewport.
207 // A side effect of this method is to reset the EstimatedRenderTime to
208 // 0.0. This way, each of the ways that this prop may be rendered can
209 // be timed and added together into this value.
210 virtual void SetAllocatedRenderTime(float t, vtkViewport *vtkNotUsed(v))
212 this->AllocatedRenderTime = t;
213 this->SavedEstimatedRenderTime = this->EstimatedRenderTime;
214 this->EstimatedRenderTime = 0.0;
218 // WARNING: INTERNAL METHOD - NOT INTENDED FOR GENERAL USE
219 // DO NOT USE THIS METHOD OUTSIDE OF THE RENDERING PROCESS
220 vtkGetMacro(AllocatedRenderTime, float);
223 // WARNING: INTERNAL METHOD - NOT INTENDED FOR GENERAL USE
224 // DO NOT USE THIS METHOD OUTSIDE OF THE RENDERING PROCESS
225 // Get/Set the multiplier for the render time. This is used
226 // for culling and is a number between 0 and 1. It is used
227 // to create the allocated render time value.
228 void SetRenderTimeMultiplier( float t ) { this->RenderTimeMultiplier = t; }
229 vtkGetMacro(RenderTimeMultiplier, float);
232 // WARNING: INTERNAL METHOD - NOT INTENDED FOR GENERAL USE
233 // DO NOT USE THIS METHOD OUTSIDE OF THE RENDERING PROCESS
234 // Used to construct assembly paths and perform part traversal.
235 virtual void BuildPaths(vtkAssemblyPaths *paths, vtkAssemblyPath *path);
238 // Get the number of consumers
239 vtkGetMacro(NumberOfConsumers,int);
242 // Add or remove or get or check a consumer,
243 void AddConsumer(vtkObject *c);
244 void RemoveConsumer(vtkObject *c);
245 vtkObject *GetConsumer(int i);
246 int IsConsumer(vtkObject *c);
256 unsigned long PickTag;
259 float AllocatedRenderTime;
260 float EstimatedRenderTime;
261 float SavedEstimatedRenderTime;
262 float RenderTimeMultiplier;
264 // how many consumers does this object have
265 int NumberOfConsumers;
266 vtkObject **Consumers;
268 // support multi-part props and access to paths of prop
269 // stuff that follows is used to build the assembly hierarchy
270 vtkAssemblyPaths *Paths;
273 vtkProp(const vtkProp&); // Not implemented.
274 void operator=(const vtkProp&); // Not implemented.