1 | /*========================================================================= |
---|
2 | |
---|
3 | Program: Visualization Toolkit |
---|
4 | Module: vtkRpCubeAxesActor2D.h |
---|
5 | |
---|
6 | Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen |
---|
7 | All rights reserved. |
---|
8 | See Copyright.txt or http://www.kitware.com/Copyright.htm for details. |
---|
9 | |
---|
10 | This software is distributed WITHOUT ANY WARRANTY; without even |
---|
11 | the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
---|
12 | PURPOSE. See the above copyright notice for more information. |
---|
13 | |
---|
14 | =========================================================================*/ |
---|
15 | // .NAME vtkRpCubeAxesActor2D - create a 2D plot of a bounding box edges - used for navigation |
---|
16 | // .SECTION Description |
---|
17 | // vtkCubeAxesActor2D is a composite actor that draws three axes of the |
---|
18 | // bounding box of an input dataset. The axes include labels and titles |
---|
19 | // for the x-y-z axes. The algorithm selects the axes that are on the |
---|
20 | // "exterior" of the bounding box, exterior as determined from examining |
---|
21 | // outer edges of the bounding box in projection (display) space. Alternatively, |
---|
22 | // the edges closest to the viewer (i.e., camera position) can be drawn. |
---|
23 | // |
---|
24 | // To use this object you must define a bounding box and the camera used |
---|
25 | // to render the vtkCubeAxesActor2D. The camera is used to control the |
---|
26 | // scaling and position of the vtkCubeAxesActor2D so that it fits in the |
---|
27 | // viewport and always remains visible.) |
---|
28 | // |
---|
29 | // The font property of the axes titles and labels can be modified through the |
---|
30 | // AxisTitleTextProperty and AxisLabelTextProperty attributes. You may also |
---|
31 | // use the GetXAxisActor2D, GetYAxisActor2D or GetZAxisActor2D methods |
---|
32 | // to access each individual axis actor to modify their font properties. |
---|
33 | // |
---|
34 | // The bounding box to use is defined in one of three ways. First, if the Input |
---|
35 | // ivar is defined, then the input dataset's bounds is used. If the Input is |
---|
36 | // not defined, and the Prop (superclass of all actors) is defined, then the |
---|
37 | // Prop's bounds is used. If neither the Input or Prop is defined, then the |
---|
38 | // Bounds instance variable (an array of six doubles) is used. |
---|
39 | // |
---|
40 | // .SECTION See Also |
---|
41 | // vtkActor2D vtkAxisActor2D vtkXYPlotActor vtkTextProperty |
---|
42 | |
---|
43 | #ifndef __vtkRpCubeAxesActor2D_h |
---|
44 | #define __vtkRpCubeAxesActor2D_h |
---|
45 | |
---|
46 | #include "vtkActor2D.h" |
---|
47 | |
---|
48 | #define VTK_FLY_OUTER_EDGES 0 |
---|
49 | #define VTK_FLY_CLOSEST_TRIAD 1 |
---|
50 | #define VTK_FLY_NONE 2 |
---|
51 | |
---|
52 | class vtkAxisActor2D; |
---|
53 | class vtkCamera; |
---|
54 | class vtkDataSet; |
---|
55 | class vtkTextProperty; |
---|
56 | |
---|
57 | class VTK_HYBRID_EXPORT vtkRpCubeAxesActor2D : public vtkActor2D |
---|
58 | { |
---|
59 | public: |
---|
60 | vtkTypeMacro(vtkRpCubeAxesActor2D,vtkActor2D); |
---|
61 | void PrintSelf(ostream& os, vtkIndent indent); |
---|
62 | |
---|
63 | // Description: |
---|
64 | // Instantiate object with bold, italic, and shadow enabled; font family |
---|
65 | // set to Arial; and label format "6.3g". The number of labels per axis |
---|
66 | // is set to 3. |
---|
67 | static vtkRpCubeAxesActor2D *New(); |
---|
68 | |
---|
69 | // Description: |
---|
70 | // Draw the axes as per the vtkProp superclass' API. |
---|
71 | int RenderOverlay(vtkViewport*); |
---|
72 | int RenderOpaqueGeometry(vtkViewport*); |
---|
73 | virtual int RenderTranslucentPolygonalGeometry(vtkViewport *) {return 0;} |
---|
74 | |
---|
75 | // Description: |
---|
76 | // Does this prop have some translucent polygonal geometry? |
---|
77 | virtual int HasTranslucentPolygonalGeometry(); |
---|
78 | |
---|
79 | // Description: |
---|
80 | // Use the bounding box of this input dataset to draw the cube axes. If this |
---|
81 | // is not specified, then the class will attempt to determine the bounds from |
---|
82 | // the defined Prop or Bounds. |
---|
83 | virtual void SetInput(vtkDataSet*); |
---|
84 | vtkGetObjectMacro(Input, vtkDataSet); |
---|
85 | |
---|
86 | // Description: |
---|
87 | // Use the bounding box of this prop to draw the cube axes. The |
---|
88 | // ViewProp is used to determine the bounds only if the Input is not |
---|
89 | // defined. |
---|
90 | void SetViewProp(vtkProp* prop); |
---|
91 | vtkGetObjectMacro(ViewProp, vtkProp); |
---|
92 | |
---|
93 | // Description: |
---|
94 | // Explicitly specify the region in space around which to draw the bounds. |
---|
95 | // The bounds is used only when no Input or Prop is specified. The bounds |
---|
96 | // are specified according to (xmin,xmax, ymin,ymax, zmin,zmax), making |
---|
97 | // sure that the min's are less than the max's. |
---|
98 | vtkSetVector6Macro(Bounds,double); |
---|
99 | double *GetBounds(); |
---|
100 | void GetBounds(double& xmin, double& xmax, double& ymin, double& ymax, |
---|
101 | double& zmin, double& zmax); |
---|
102 | void GetBounds(double bounds[6]); |
---|
103 | |
---|
104 | // Description: |
---|
105 | // Explicitly specify the range of values used on the bounds. |
---|
106 | // The ranges are specified according to (xmin,xmax, ymin,ymax, zmin,zmax), |
---|
107 | // making sure that the min's are less than the max's. |
---|
108 | vtkSetVector6Macro(Ranges,double); |
---|
109 | double *GetRanges(); |
---|
110 | void GetRanges(double& xmin, double& xmax, double& ymin, double& ymax, |
---|
111 | double& zmin, double& zmax); |
---|
112 | void GetRanges(double ranges[6]); |
---|
113 | |
---|
114 | // Description: |
---|
115 | // Explicitly specify an origin for the axes. These usually intersect at one of the |
---|
116 | // corners of the bounding box, however users have the option to override this if |
---|
117 | // necessary |
---|
118 | vtkSetMacro( XOrigin, double ); |
---|
119 | vtkSetMacro( YOrigin, double ); |
---|
120 | vtkSetMacro( ZOrigin, double ); |
---|
121 | |
---|
122 | // Description: |
---|
123 | // Set/Get a flag that controls whether the axes use the data ranges |
---|
124 | // or the ranges set by SetRanges. By default the axes use the data |
---|
125 | // ranges. |
---|
126 | vtkSetMacro(UseRanges,int); |
---|
127 | vtkGetMacro(UseRanges,int); |
---|
128 | vtkBooleanMacro(UseRanges,int); |
---|
129 | |
---|
130 | // Description: |
---|
131 | // Set/Get the camera to perform scaling and translation of the |
---|
132 | // vtkRpCubeAxesActor2D. |
---|
133 | virtual void SetCamera(vtkCamera*); |
---|
134 | vtkGetObjectMacro(Camera,vtkCamera); |
---|
135 | |
---|
136 | // Description: |
---|
137 | // Specify a mode to control how the axes are drawn: either outer edges |
---|
138 | // or closest triad to the camera position, or you may also disable flying |
---|
139 | // of the axes. |
---|
140 | vtkSetClampMacro(FlyMode, int, VTK_FLY_OUTER_EDGES, VTK_FLY_NONE); |
---|
141 | vtkGetMacro(FlyMode, int); |
---|
142 | void SetFlyModeToOuterEdges() |
---|
143 | {this->SetFlyMode(VTK_FLY_OUTER_EDGES);}; |
---|
144 | void SetFlyModeToClosestTriad() |
---|
145 | {this->SetFlyMode(VTK_FLY_CLOSEST_TRIAD);}; |
---|
146 | void SetFlyModeToNone() |
---|
147 | {this->SetFlyMode(VTK_FLY_NONE);}; |
---|
148 | |
---|
149 | // Description: |
---|
150 | // Set/Get a flag that controls whether the axes are scaled to fit in |
---|
151 | // the viewport. If off, the axes size remains constant (i.e., stay the |
---|
152 | // size of the bounding box). By default scaling is on so the axes are |
---|
153 | // scaled to fit inside the viewport. |
---|
154 | vtkSetMacro(Scaling,int); |
---|
155 | vtkGetMacro(Scaling,int); |
---|
156 | vtkBooleanMacro(Scaling,int); |
---|
157 | |
---|
158 | // Description: |
---|
159 | // Set/Get the number of annotation labels to show along the x, y, and |
---|
160 | // z axes. This values is a suggestion: the number of labels may vary |
---|
161 | // depending on the particulars of the data. |
---|
162 | vtkSetClampMacro(NumberOfLabels, int, 0, 50); |
---|
163 | vtkGetMacro(NumberOfLabels, int); |
---|
164 | |
---|
165 | // Description: |
---|
166 | // Set/Get the labels for the x, y, and z axes. By default, |
---|
167 | // use "X", "Y" and "Z". |
---|
168 | vtkSetStringMacro(XLabel); |
---|
169 | vtkGetStringMacro(XLabel); |
---|
170 | vtkSetStringMacro(YLabel); |
---|
171 | vtkGetStringMacro(YLabel); |
---|
172 | vtkSetStringMacro(ZLabel); |
---|
173 | vtkGetStringMacro(ZLabel); |
---|
174 | |
---|
175 | // Description: |
---|
176 | // Retrieve handles to the X, Y and Z axis (so that you can set their text |
---|
177 | // properties for example) |
---|
178 | vtkAxisActor2D *GetXAxisActor2D() |
---|
179 | {return this->XAxis;} |
---|
180 | vtkAxisActor2D *GetYAxisActor2D() |
---|
181 | {return this->YAxis;} |
---|
182 | vtkAxisActor2D *GetZAxisActor2D() |
---|
183 | {return this->ZAxis;} |
---|
184 | |
---|
185 | // Description: |
---|
186 | // Set/Get the title text property of all axes. Note that each axis can |
---|
187 | // be controlled individually through the GetX/Y/ZAxisActor2D() methods. |
---|
188 | virtual void SetAxisTitleTextProperty(vtkTextProperty *p); |
---|
189 | vtkGetObjectMacro(AxisTitleTextProperty,vtkTextProperty); |
---|
190 | |
---|
191 | // Description: |
---|
192 | // Set/Get the labels text property of all axes. Note that each axis can |
---|
193 | // be controlled individually through the GetX/Y/ZAxisActor2D() methods. |
---|
194 | virtual void SetAxisLabelTextProperty(vtkTextProperty *p); |
---|
195 | vtkGetObjectMacro(AxisLabelTextProperty,vtkTextProperty); |
---|
196 | |
---|
197 | // Description: |
---|
198 | // Set/Get the format with which to print the labels on each of the |
---|
199 | // x-y-z axes. |
---|
200 | vtkSetStringMacro(LabelFormat); |
---|
201 | vtkGetStringMacro(LabelFormat); |
---|
202 | |
---|
203 | // Description: |
---|
204 | // Set/Get the factor that controls the overall size of the fonts used |
---|
205 | // to label and title the axes. |
---|
206 | vtkSetClampMacro(FontFactor, double, 0.1, 2.0); |
---|
207 | vtkGetMacro(FontFactor, double); |
---|
208 | |
---|
209 | // Description: |
---|
210 | // Set/Get the inertial factor that controls how often (i.e, how |
---|
211 | // many renders) the axes can switch position (jump from one axes |
---|
212 | // to another). |
---|
213 | vtkSetClampMacro(Inertia, int, 1, VTK_LARGE_INTEGER); |
---|
214 | vtkGetMacro(Inertia, int); |
---|
215 | |
---|
216 | // Description: |
---|
217 | // Set/Get the variable that controls whether the actual |
---|
218 | // bounds of the dataset are always shown. Setting this variable |
---|
219 | // to 1 means that clipping is disabled and that the actual |
---|
220 | // value of the bounds is displayed even with corner offsets |
---|
221 | // Setting this variable to 0 means these axis will clip |
---|
222 | // themselves and show variable bounds (legacy mode) |
---|
223 | vtkSetClampMacro(ShowActualBounds, int, 0, 1); |
---|
224 | vtkGetMacro(ShowActualBounds, int); |
---|
225 | |
---|
226 | // Description: |
---|
227 | // Specify an offset value to "pull back" the axes from the corner at |
---|
228 | // which they are joined to avoid overlap of axes labels. The |
---|
229 | // "CornerOffset" is the fraction of the axis length to pull back. |
---|
230 | vtkSetMacro(CornerOffset, double); |
---|
231 | vtkGetMacro(CornerOffset, double); |
---|
232 | |
---|
233 | // Description: |
---|
234 | // Release any graphics resources that are being consumed by this actor. |
---|
235 | // The parameter window could be used to determine which graphic |
---|
236 | // resources to release. |
---|
237 | void ReleaseGraphicsResources(vtkWindow *); |
---|
238 | |
---|
239 | // Description: |
---|
240 | // Turn on and off the visibility of each axis. |
---|
241 | vtkSetMacro(XAxisVisibility,int); |
---|
242 | vtkGetMacro(XAxisVisibility,int); |
---|
243 | vtkBooleanMacro(XAxisVisibility,int); |
---|
244 | vtkSetMacro(YAxisVisibility,int); |
---|
245 | vtkGetMacro(YAxisVisibility,int); |
---|
246 | vtkBooleanMacro(YAxisVisibility,int); |
---|
247 | vtkSetMacro(ZAxisVisibility,int); |
---|
248 | vtkGetMacro(ZAxisVisibility,int); |
---|
249 | vtkBooleanMacro(ZAxisVisibility,int); |
---|
250 | |
---|
251 | // Description: |
---|
252 | // Shallow copy of a CubeAxesActor2D. |
---|
253 | void ShallowCopy(vtkRpCubeAxesActor2D *actor); |
---|
254 | |
---|
255 | protected: |
---|
256 | vtkRpCubeAxesActor2D(); |
---|
257 | ~vtkRpCubeAxesActor2D(); |
---|
258 | |
---|
259 | vtkDataSet *Input; //Define bounds from input data, or |
---|
260 | vtkProp *ViewProp; //Define bounds from actor/assembly, or |
---|
261 | double Bounds[6]; //Define bounds explicitly |
---|
262 | double Ranges[6]; //Define ranges explicitly |
---|
263 | int UseRanges; //Flag to use ranges or not |
---|
264 | |
---|
265 | vtkCamera *Camera; |
---|
266 | int FlyMode; |
---|
267 | int Scaling; |
---|
268 | |
---|
269 | vtkAxisActor2D *XAxis; |
---|
270 | vtkAxisActor2D *YAxis; |
---|
271 | vtkAxisActor2D *ZAxis; |
---|
272 | |
---|
273 | vtkTextProperty *AxisTitleTextProperty; |
---|
274 | vtkTextProperty *AxisLabelTextProperty; |
---|
275 | |
---|
276 | vtkTimeStamp BuildTime; |
---|
277 | |
---|
278 | int NumberOfLabels; |
---|
279 | char *XLabel; |
---|
280 | char *YLabel; |
---|
281 | char *ZLabel; |
---|
282 | char *Labels[3]; |
---|
283 | |
---|
284 | int XAxisVisibility; |
---|
285 | int YAxisVisibility; |
---|
286 | int ZAxisVisibility; |
---|
287 | |
---|
288 | char *LabelFormat; |
---|
289 | double FontFactor; |
---|
290 | double CornerOffset; |
---|
291 | int Inertia; |
---|
292 | int RenderCount; |
---|
293 | int InertiaAxes[8]; |
---|
294 | |
---|
295 | int RenderSomething; |
---|
296 | |
---|
297 | // Always show the actual bounds of the object |
---|
298 | int ShowActualBounds; |
---|
299 | |
---|
300 | double XOrigin; |
---|
301 | double YOrigin; |
---|
302 | double ZOrigin; |
---|
303 | |
---|
304 | // various helper methods |
---|
305 | void TransformBounds(vtkViewport *viewport, double bounds[6], |
---|
306 | double pts[8][3]); |
---|
307 | int ClipBounds(vtkViewport *viewport, double pts[8][3], double bounds[6]); |
---|
308 | double EvaluatePoint(double planes[24], double x[3]); |
---|
309 | double EvaluateBounds(double planes[24], double bounds[6]); |
---|
310 | void AdjustAxes(double pts[8][3], double bounds[6], |
---|
311 | int idx, int xIdx, int yIdx, int zIdx, int zIdx2, |
---|
312 | int xAxes, int yAxes, int zAxes, |
---|
313 | double xCoords[4], double yCoords[4], double zCoords[4], |
---|
314 | double xRange[2], double yRange[2], double zRange[2]); |
---|
315 | |
---|
316 | private: |
---|
317 | // hide the superclass' ShallowCopy() from the user and the compiler. |
---|
318 | void ShallowCopy(vtkProp *prop) { this->vtkProp::ShallowCopy( prop ); }; |
---|
319 | private: |
---|
320 | vtkRpCubeAxesActor2D(const vtkRpCubeAxesActor2D&); // Not implemented. |
---|
321 | void operator=(const vtkRpCubeAxesActor2D&); // Not implemented. |
---|
322 | }; |
---|
323 | |
---|
324 | |
---|
325 | #endif |
---|