1 | /*========================================================================= |
---|
2 | |
---|
3 | Program: Visualization Toolkit |
---|
4 | Module: vtkRpCubeAxesActor.h |
---|
5 | Language: C++ |
---|
6 | Date: $Date$ |
---|
7 | Version: $Revision$ |
---|
8 | Thanks: Kathleen Bonnell, B Division, Lawrence Livermore Nat'l Laboratory |
---|
9 | |
---|
10 | Copyright (c) 1993-2001 Ken Martin, Will Schroeder, Bill Lorensen |
---|
11 | All rights reserve |
---|
12 | See Copyright.txt or http://www.kitware.com/Copyright.htm for details. |
---|
13 | |
---|
14 | This software is distributed WITHOUT ANY WARRANTY; without even |
---|
15 | the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
---|
16 | PURPOSE. See the above copyright notice for more information. |
---|
17 | =========================================================================*/ |
---|
18 | // .NAME vtkRpCubeAxesActor - create a plot of a bounding box edges - |
---|
19 | // used for navigation |
---|
20 | // .SECTION Description |
---|
21 | // vtkRpCubeAxesActor is a composite actor that draws axes of the |
---|
22 | // bounding box of an input dataset. The axes include labels and titles |
---|
23 | // for the x-y-z axes. The algorithm selects which axes to draw based |
---|
24 | // on the user-defined 'fly' mode. (STATIC is default). |
---|
25 | // 'STATIC' constructs axes from all edges of the bounding box. |
---|
26 | // 'CLOSEST_TRIAD' consists of the three axes x-y-z forming a triad that |
---|
27 | // lies closest to the specified camera. |
---|
28 | // 'FURTHEST_TRIAD' consists of the three axes x-y-z forming a triad that |
---|
29 | // lies furthest from the specified camera. |
---|
30 | // 'OUTER_EDGES' is constructed from edges that are on the "exterior" of the |
---|
31 | // bounding box, exterior as determined from examining outer edges of the |
---|
32 | // bounding box in projection (display) space. |
---|
33 | // |
---|
34 | // To use this object you must define a bounding box and the camera used |
---|
35 | // to render the vtkRpCubeAxesActor. You can optionally turn on/off labels, |
---|
36 | // ticks, gridlines, and set tick location, number of labels, and text to |
---|
37 | // use for axis-titles. A 'corner offset' can also be set. This allows |
---|
38 | // the axes to be set partially away from the actual bounding box to perhaps |
---|
39 | // prevent overlap of labels between the various axes. |
---|
40 | // |
---|
41 | // The Bounds instance variable (an array of six doubles) is used to determine |
---|
42 | // the bounding box. |
---|
43 | // |
---|
44 | // .SECTION See Also |
---|
45 | // vtkActor vtkRpAxisActor vtkRpCubeAxesActor2D |
---|
46 | |
---|
47 | #ifndef __vtkRpCubeAxesActor_h |
---|
48 | #define __vtkRpCubeAxesActor_h |
---|
49 | |
---|
50 | #define VTK_FLY_OUTER_EDGES 0 |
---|
51 | #define VTK_FLY_CLOSEST_TRIAD 1 |
---|
52 | #define VTK_FLY_FURTHEST_TRIAD 2 |
---|
53 | #define VTK_FLY_STATIC_TRIAD 3 |
---|
54 | #define VTK_FLY_STATIC_EDGES 4 |
---|
55 | |
---|
56 | #define VTK_TICKS_INSIDE 0 |
---|
57 | #define VTK_TICKS_OUTSIDE 1 |
---|
58 | #define VTK_TICKS_BOTH 2 |
---|
59 | |
---|
60 | #include "vtkActor.h" |
---|
61 | |
---|
62 | class vtkRpAxisActor; |
---|
63 | class vtkCamera; |
---|
64 | |
---|
65 | class VTK_HYBRID_EXPORT vtkRpCubeAxesActor : public vtkActor |
---|
66 | { |
---|
67 | public: |
---|
68 | vtkTypeMacro(vtkRpCubeAxesActor,vtkActor); |
---|
69 | void PrintSelf(ostream& os, vtkIndent indent); |
---|
70 | |
---|
71 | // Description: |
---|
72 | // Instantiate object with label format "6.3g" and the number of labels |
---|
73 | // per axis set to 3. |
---|
74 | static vtkRpCubeAxesActor *New(); |
---|
75 | |
---|
76 | // Description: |
---|
77 | // Draw the axes as per the vtkProp superclass' API. |
---|
78 | virtual int RenderOpaqueGeometry(vtkViewport*); |
---|
79 | virtual int RenderTranslucentGeometry(vtkViewport *) {return 0;} |
---|
80 | |
---|
81 | // Description: |
---|
82 | // Explicitly specify the region in space around which to draw the bounds. |
---|
83 | // The bounds is used only when no Input or Prop is specified. The bounds |
---|
84 | // are specified according to (xmin,xmax, ymin,ymax, zmin,zmax), making |
---|
85 | // sure that the min's are less than the max's. |
---|
86 | vtkSetVector6Macro(Bounds,double); |
---|
87 | double *GetBounds(); |
---|
88 | void GetBounds(double& xmin, double& xmax, double& ymin, double& ymax, |
---|
89 | double& zmin, double& zmax); |
---|
90 | void GetBounds(double bounds[6]); |
---|
91 | |
---|
92 | // Description: |
---|
93 | // Explicitly specify the range of each axes that's used to define the prop. |
---|
94 | // The default, (if you do not use these methods) is to use the bounds |
---|
95 | // specified, or use the bounds of the Input Prop if one is specified. This |
---|
96 | // method allows you to separate the notion of extent of the axes in physical |
---|
97 | // space (bounds) and the extent of the values it represents. In other words, |
---|
98 | // you can have the ticks and labels show a different range. |
---|
99 | vtkSetVector2Macro( XAxisRange, double ); |
---|
100 | vtkSetVector2Macro( YAxisRange, double ); |
---|
101 | vtkSetVector2Macro( ZAxisRange, double ); |
---|
102 | vtkGetVector2Macro( XAxisRange, double ); |
---|
103 | vtkGetVector2Macro( YAxisRange, double ); |
---|
104 | vtkGetVector2Macro( ZAxisRange, double ); |
---|
105 | |
---|
106 | // Description: |
---|
107 | // Set/Get the camera to perform scaling and translation of the |
---|
108 | // vtkRpCubeAxesActor. |
---|
109 | virtual void SetCamera(vtkCamera*); |
---|
110 | vtkGetObjectMacro(Camera,vtkCamera); |
---|
111 | |
---|
112 | // Description: |
---|
113 | // Specify a mode to control how the axes are drawn: either static, |
---|
114 | // closest triad, furthest triad or outer edges in relation to the |
---|
115 | // camera position. |
---|
116 | vtkSetClampMacro(FlyMode, int, VTK_FLY_OUTER_EDGES, VTK_FLY_STATIC_EDGES); |
---|
117 | vtkGetMacro(FlyMode, int); |
---|
118 | void SetFlyModeToOuterEdges() |
---|
119 | {this->SetFlyMode(VTK_FLY_OUTER_EDGES);}; |
---|
120 | void SetFlyModeToClosestTriad() |
---|
121 | {this->SetFlyMode(VTK_FLY_CLOSEST_TRIAD);}; |
---|
122 | void SetFlyModeToFurthestTriad() |
---|
123 | {this->SetFlyMode(VTK_FLY_FURTHEST_TRIAD);}; |
---|
124 | void SetFlyModeToStaticTriad() |
---|
125 | {this->SetFlyMode(VTK_FLY_STATIC_TRIAD);}; |
---|
126 | void SetFlyModeToStaticEdges() |
---|
127 | {this->SetFlyMode(VTK_FLY_STATIC_EDGES);}; |
---|
128 | |
---|
129 | // Description: |
---|
130 | // Set/Get the labels for the x, y, and z axes. By default, |
---|
131 | // use "X-Axis", "Y-Axis" and "Z-Axis". |
---|
132 | vtkSetStringMacro(XTitle); |
---|
133 | vtkGetStringMacro(XTitle); |
---|
134 | vtkSetStringMacro(XUnits); |
---|
135 | vtkGetStringMacro(XUnits); |
---|
136 | vtkSetStringMacro(YTitle); |
---|
137 | vtkGetStringMacro(YTitle); |
---|
138 | vtkSetStringMacro(YUnits); |
---|
139 | vtkGetStringMacro(YUnits); |
---|
140 | vtkSetStringMacro(ZTitle); |
---|
141 | vtkGetStringMacro(ZTitle); |
---|
142 | vtkSetStringMacro(ZUnits); |
---|
143 | vtkGetStringMacro(ZUnits); |
---|
144 | |
---|
145 | // Description: |
---|
146 | // Set/Get the format with which to print the labels on each of the |
---|
147 | // x-y-z axes. |
---|
148 | vtkSetStringMacro(XLabelFormat); |
---|
149 | vtkGetStringMacro(XLabelFormat); |
---|
150 | vtkSetStringMacro(YLabelFormat); |
---|
151 | vtkGetStringMacro(YLabelFormat); |
---|
152 | vtkSetStringMacro(ZLabelFormat); |
---|
153 | vtkGetStringMacro(ZLabelFormat); |
---|
154 | |
---|
155 | // Description: |
---|
156 | // Set/Get the inertial factor that controls how often (i.e, how |
---|
157 | // many renders) the axes can switch position (jump from one axes |
---|
158 | // to another). |
---|
159 | vtkSetClampMacro(Inertia, int, 1, VTK_LARGE_INTEGER); |
---|
160 | vtkGetMacro(Inertia, int); |
---|
161 | |
---|
162 | // Description: |
---|
163 | // Specify an offset value to "pull back" the axes from the corner at |
---|
164 | // which they are joined to avoid overlap of axes labels. The |
---|
165 | // "CornerOffset" is the fraction of the axis length to pull back. |
---|
166 | vtkSetMacro(CornerOffset, double); |
---|
167 | vtkGetMacro(CornerOffset, double); |
---|
168 | |
---|
169 | // Description: |
---|
170 | // Release any graphics resources that are being consumed by this actor. |
---|
171 | // The parameter window could be used to determine which graphic |
---|
172 | // resources to release. |
---|
173 | void ReleaseGraphicsResources(vtkWindow *); |
---|
174 | |
---|
175 | // Description: |
---|
176 | // Turn on and off the visibility of each axis. |
---|
177 | vtkSetMacro(XAxisVisibility,int); |
---|
178 | vtkGetMacro(XAxisVisibility,int); |
---|
179 | vtkBooleanMacro(XAxisVisibility,int); |
---|
180 | vtkSetMacro(YAxisVisibility,int); |
---|
181 | vtkGetMacro(YAxisVisibility,int); |
---|
182 | vtkBooleanMacro(YAxisVisibility,int); |
---|
183 | vtkSetMacro(ZAxisVisibility,int); |
---|
184 | vtkGetMacro(ZAxisVisibility,int); |
---|
185 | vtkBooleanMacro(ZAxisVisibility,int); |
---|
186 | |
---|
187 | // Description: |
---|
188 | // Turn on and off the visibility of labels for each axis. |
---|
189 | vtkSetMacro(XAxisLabelVisibility,int); |
---|
190 | vtkGetMacro(XAxisLabelVisibility,int); |
---|
191 | vtkBooleanMacro(XAxisLabelVisibility,int); |
---|
192 | |
---|
193 | vtkSetMacro(YAxisLabelVisibility,int); |
---|
194 | vtkGetMacro(YAxisLabelVisibility,int); |
---|
195 | vtkBooleanMacro(YAxisLabelVisibility,int); |
---|
196 | |
---|
197 | vtkSetMacro(ZAxisLabelVisibility,int); |
---|
198 | vtkGetMacro(ZAxisLabelVisibility,int); |
---|
199 | vtkBooleanMacro(ZAxisLabelVisibility,int); |
---|
200 | |
---|
201 | // Description: |
---|
202 | // Turn on and off the visibility of ticks for each axis. |
---|
203 | vtkSetMacro(XAxisTickVisibility,int); |
---|
204 | vtkGetMacro(XAxisTickVisibility,int); |
---|
205 | vtkBooleanMacro(XAxisTickVisibility,int); |
---|
206 | |
---|
207 | vtkSetMacro(YAxisTickVisibility,int); |
---|
208 | vtkGetMacro(YAxisTickVisibility,int); |
---|
209 | vtkBooleanMacro(YAxisTickVisibility,int); |
---|
210 | |
---|
211 | vtkSetMacro(ZAxisTickVisibility,int); |
---|
212 | vtkGetMacro(ZAxisTickVisibility,int); |
---|
213 | vtkBooleanMacro(ZAxisTickVisibility,int); |
---|
214 | |
---|
215 | // Description: |
---|
216 | // Turn on and off the visibility of minor ticks for each axis. |
---|
217 | vtkSetMacro(XAxisMinorTickVisibility,int); |
---|
218 | vtkGetMacro(XAxisMinorTickVisibility,int); |
---|
219 | vtkBooleanMacro(XAxisMinorTickVisibility,int); |
---|
220 | |
---|
221 | vtkSetMacro(YAxisMinorTickVisibility,int); |
---|
222 | vtkGetMacro(YAxisMinorTickVisibility,int); |
---|
223 | vtkBooleanMacro(YAxisMinorTickVisibility,int); |
---|
224 | |
---|
225 | vtkSetMacro(ZAxisMinorTickVisibility,int); |
---|
226 | vtkGetMacro(ZAxisMinorTickVisibility,int); |
---|
227 | vtkBooleanMacro(ZAxisMinorTickVisibility,int); |
---|
228 | |
---|
229 | vtkSetMacro(DrawXGridlines,int); |
---|
230 | vtkGetMacro(DrawXGridlines,int); |
---|
231 | vtkBooleanMacro(DrawXGridlines,int); |
---|
232 | |
---|
233 | vtkSetMacro(DrawYGridlines,int); |
---|
234 | vtkGetMacro(DrawYGridlines,int); |
---|
235 | vtkBooleanMacro(DrawYGridlines,int); |
---|
236 | |
---|
237 | vtkSetMacro(DrawZGridlines,int); |
---|
238 | vtkGetMacro(DrawZGridlines,int); |
---|
239 | vtkBooleanMacro(DrawZGridlines,int); |
---|
240 | |
---|
241 | // Description: |
---|
242 | // Set/Get the location of ticks marks. |
---|
243 | vtkSetClampMacro(TickLocation, int, VTK_TICKS_INSIDE, VTK_TICKS_BOTH); |
---|
244 | vtkGetMacro(TickLocation, int); |
---|
245 | |
---|
246 | void SetTickLocationToInside(void) |
---|
247 | { this->SetTickLocation(VTK_TICKS_INSIDE); }; |
---|
248 | void SetTickLocationToOutside(void) |
---|
249 | { this->SetTickLocation(VTK_TICKS_OUTSIDE); }; |
---|
250 | void SetTickLocationToBoth(void) |
---|
251 | { this->SetTickLocation(VTK_TICKS_BOTH); }; |
---|
252 | |
---|
253 | void SetLabelScaling(bool, int, int, int); |
---|
254 | // Description: |
---|
255 | // Shallow copy of a KatCubeAxesActor. |
---|
256 | void ShallowCopy(vtkRpCubeAxesActor *actor); |
---|
257 | |
---|
258 | protected: |
---|
259 | vtkRpCubeAxesActor(); |
---|
260 | ~vtkRpCubeAxesActor(); |
---|
261 | |
---|
262 | int LabelExponent(double min, double max); |
---|
263 | int Digits(double min, double max); |
---|
264 | double MaxOf(double, double); |
---|
265 | double MaxOf(double, double, double, double); |
---|
266 | double FFix(double); |
---|
267 | double FSign(double, double); |
---|
268 | |
---|
269 | double Bounds[6]; //Define bounds explicitly |
---|
270 | |
---|
271 | vtkCamera *Camera; |
---|
272 | int FlyMode; |
---|
273 | |
---|
274 | // to control all axes |
---|
275 | // [0] always for 'Major' axis during non-static fly modes. |
---|
276 | vtkRpAxisActor *XAxes[4]; |
---|
277 | vtkRpAxisActor *YAxes[4]; |
---|
278 | vtkRpAxisActor *ZAxes[4]; |
---|
279 | |
---|
280 | char *XTitle; |
---|
281 | char *XUnits; |
---|
282 | char *YTitle; |
---|
283 | char *YUnits; |
---|
284 | char *ZTitle; |
---|
285 | char *ZUnits; |
---|
286 | |
---|
287 | char *ActualXLabel; |
---|
288 | char *ActualYLabel; |
---|
289 | char *ActualZLabel; |
---|
290 | |
---|
291 | int TickLocation; |
---|
292 | |
---|
293 | int XAxisVisibility; |
---|
294 | int YAxisVisibility; |
---|
295 | int ZAxisVisibility; |
---|
296 | |
---|
297 | int XAxisTickVisibility; |
---|
298 | int YAxisTickVisibility; |
---|
299 | int ZAxisTickVisibility; |
---|
300 | |
---|
301 | int XAxisMinorTickVisibility; |
---|
302 | int YAxisMinorTickVisibility; |
---|
303 | int ZAxisMinorTickVisibility; |
---|
304 | |
---|
305 | int XAxisLabelVisibility; |
---|
306 | int YAxisLabelVisibility; |
---|
307 | int ZAxisLabelVisibility; |
---|
308 | |
---|
309 | int DrawXGridlines; |
---|
310 | int DrawYGridlines; |
---|
311 | int DrawZGridlines; |
---|
312 | |
---|
313 | char *XLabelFormat; |
---|
314 | char *YLabelFormat; |
---|
315 | char *ZLabelFormat; |
---|
316 | double CornerOffset; |
---|
317 | int Inertia; |
---|
318 | int RenderCount; |
---|
319 | int InertiaLocs[3]; |
---|
320 | |
---|
321 | int RenderSomething; |
---|
322 | |
---|
323 | private: |
---|
324 | vtkRpCubeAxesActor(const vtkRpCubeAxesActor&); // Not implemented |
---|
325 | void operator=(const vtkRpCubeAxesActor&); // Not implemented |
---|
326 | |
---|
327 | vtkSetStringMacro(ActualXLabel); |
---|
328 | vtkSetStringMacro(ActualYLabel); |
---|
329 | vtkSetStringMacro(ActualZLabel); |
---|
330 | |
---|
331 | vtkTimeStamp BuildTime; |
---|
332 | int LastXPow; |
---|
333 | int LastYPow; |
---|
334 | int LastZPow; |
---|
335 | int UserXPow; |
---|
336 | int UserYPow; |
---|
337 | int UserZPow; |
---|
338 | bool AutoLabelScaling; |
---|
339 | int LastXAxisDigits; |
---|
340 | int LastYAxisDigits; |
---|
341 | int LastZAxisDigits; |
---|
342 | double LastXRange[2]; |
---|
343 | double LastYRange[2]; |
---|
344 | double LastZRange[2]; |
---|
345 | int LastFlyMode; |
---|
346 | |
---|
347 | int RenderAxesX[4]; |
---|
348 | int RenderAxesY[4]; |
---|
349 | int RenderAxesZ[4]; |
---|
350 | int NumberOfAxesX; |
---|
351 | int NumberOfAxesY; |
---|
352 | int NumberOfAxesZ; |
---|
353 | |
---|
354 | bool MustAdjustXValue; |
---|
355 | bool MustAdjustYValue; |
---|
356 | bool MustAdjustZValue; |
---|
357 | bool ForceXLabelReset; |
---|
358 | bool ForceYLabelReset; |
---|
359 | bool ForceZLabelReset; |
---|
360 | |
---|
361 | double XAxisRange[2]; |
---|
362 | double YAxisRange[2]; |
---|
363 | double ZAxisRange[2]; |
---|
364 | |
---|
365 | // various helper methods |
---|
366 | void TransformBounds(vtkViewport *viewport, const double bounds[6], |
---|
367 | double pts[8][3]); |
---|
368 | void AdjustAxes(double bounds[6], |
---|
369 | double xCoords[4][6], double yCoords[4][6], |
---|
370 | double zCoords[4][6], |
---|
371 | double xRange[2], double yRange[2], double zRange[2]); |
---|
372 | |
---|
373 | bool ComputeTickSize(double bounds[6]); |
---|
374 | void AdjustValues(const double xRange[2], |
---|
375 | const double yRange[2], |
---|
376 | const double zRange[2]); |
---|
377 | void AdjustRange(const double bounds[6]); |
---|
378 | void BuildAxes(vtkViewport *); |
---|
379 | void DetermineRenderAxes(vtkViewport *); |
---|
380 | void SetNonDependentAttributes(void); |
---|
381 | void BuildLabels(vtkRpAxisActor *axes[4]); |
---|
382 | void AdjustTicksComputeRange(vtkRpAxisActor *axes[4], |
---|
383 | double rangeMin, double rangeMax); |
---|
384 | |
---|
385 | // hide the superclass' ShallowCopy() from the user and the compiler. |
---|
386 | void ShallowCopy(vtkProp *prop) { this->vtkProp::ShallowCopy( prop ); }; |
---|
387 | }; |
---|
388 | |
---|
389 | |
---|
390 | #endif |
---|