source: trunk/packages/vizservers/vtkvis/vtkRpCubeAxesActor2D.h @ 2217

Last change on this file since 2217 was 2100, checked in by ldelgass, 13 years ago

VTKVis server for 2D contour plots. Required modifications to vizservers build
to follow.

  • Property svn:eol-style set to native
File size: 12.8 KB
Line 
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 __vtkCubeAxesActor2D_h
44#define __vtkCubeAxesActor2D_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
52class vtkAxisActor2D;
53class vtkCamera;
54class vtkDataSet;
55class vtkTextProperty;
56
57class VTK_HYBRID_EXPORT vtkRpCubeAxesActor2D : public vtkActor2D
58{
59public:
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// Disable warnings about qualifiers on return types.
256#if defined(_COMPILER_VERSION)
257# pragma set woff 3303
258#endif
259#if defined(__INTEL_COMPILER)
260# pragma warning (push)
261# pragma warning (disable:858)
262#endif
263
264#ifdef VTK_WORKAROUND_WINDOWS_MANGLE
265# define SetPropA SetProp
266# define SetPropW SetProp
267# define GetPropA GetProp
268# define GetPropW GetProp
269#endif
270
271  // Description:
272  // @deprecated Replaced by vtkRpCubeAxesActor2D::SetViewProp() as of VTK 5.0.
273  VTK_LEGACY(virtual void SetProp(vtkProp* prop));
274
275  // Description:
276  // @deprecated Replaced by vtkRpCubeAxesActor2D::GetViewProp() as of VTK 5.0.
277  VTK_LEGACY(virtual vtkProp* GetProp());
278
279#ifdef VTK_WORKAROUND_WINDOWS_MANGLE
280# undef SetPropW
281# undef SetPropA
282# undef GetPropW
283# undef GetPropA
284  //BTX
285  VTK_LEGACY(virtual void SetPropA(vtkProp* prop));
286  VTK_LEGACY(virtual void SetPropW(vtkProp* prop));
287  VTK_LEGACY(virtual vtkProp* GetPropA());
288  VTK_LEGACY(virtual vtkProp* GetPropW());
289  //ETX
290#endif
291
292// Reset disabled warning about qualifiers on return types.
293#if defined(__INTEL_COMPILER)
294# pragma warning (pop)
295#endif
296#if defined(_COMPILER_VERSION)
297# pragma reset woff 3303
298#endif
299
300protected:
301  vtkRpCubeAxesActor2D();
302  ~vtkRpCubeAxesActor2D();
303
304  vtkDataSet *Input;    //Define bounds from input data, or
305  vtkProp    *ViewProp;     //Define bounds from actor/assembly, or
306  double      Bounds[6]; //Define bounds explicitly
307  double      Ranges[6]; //Define ranges explicitly
308  int        UseRanges; //Flag to use ranges or not
309
310  vtkCamera *Camera;
311  int FlyMode;
312  int Scaling;
313 
314  vtkAxisActor2D *XAxis;
315  vtkAxisActor2D *YAxis;
316  vtkAxisActor2D *ZAxis;
317 
318  vtkTextProperty *AxisTitleTextProperty;
319  vtkTextProperty *AxisLabelTextProperty;
320
321  vtkTimeStamp  BuildTime;
322
323  int   NumberOfLabels;
324  char *XLabel;
325  char *YLabel;
326  char *ZLabel;
327  char *Labels[3];
328
329  int XAxisVisibility;
330  int YAxisVisibility;
331  int ZAxisVisibility;
332
333  char  *LabelFormat;
334  double FontFactor;
335  double CornerOffset;
336  int   Inertia;
337  int   RenderCount;
338  int   InertiaAxes[8];
339 
340  int RenderSomething;
341 
342  // Always show the actual bounds of the object
343  int ShowActualBounds;
344
345  double XOrigin;
346  double YOrigin;
347  double ZOrigin;
348 
349  // various helper methods
350  void TransformBounds(vtkViewport *viewport, double bounds[6],
351                       double pts[8][3]);
352  int ClipBounds(vtkViewport *viewport, double pts[8][3], double bounds[6]);
353  double EvaluatePoint(double planes[24], double x[3]);
354  double EvaluateBounds(double planes[24], double bounds[6]);
355  void AdjustAxes(double pts[8][3], double bounds[6],
356                  int idx, int xIdx, int yIdx, int zIdx, int zIdx2,
357                  int xAxes, int yAxes, int zAxes,
358                  double xCoords[4], double yCoords[4], double zCoords[4],
359                  double xRange[2], double yRange[2], double zRange[2]);
360
361private:
362  // hide the superclass' ShallowCopy() from the user and the compiler.
363  void ShallowCopy(vtkProp *prop) { this->vtkProp::ShallowCopy( prop ); };
364private:
365  vtkRpCubeAxesActor2D(const vtkRpCubeAxesActor2D&);  // Not implemented.
366  void operator=(const vtkRpCubeAxesActor2D&);  // Not implemented.
367};
368
369
370#endif
Note: See TracBrowser for help on using the repository browser.