vtkPolarAxesActor.h 11 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
/*=========================================================================

  Program:   Visualization Toolkit
  Module:    vtkCubeAxesActor.h
  Language:  C++
  Date:      $Date$
  Version:   $Revision$
  Thanks:    Kathleen Bonnell, B Division, Lawrence Livermore Nat'l Laboratory

Copyright (c) 1993-2001 Ken Martin, Will Schroeder, Bill Lorensen
All rights reserve
  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.

     This software is distributed WITHOUT ANY WARRANTY; without even
     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
     PURPOSE.  See the above copyright notice for more information.
=========================================================================*/
// .NAME vtkPolarAxesActor - create an actor of a polar axes -
// 
// .SECTION Description
// vtkPolarAxesActor is a composite actor that draws polar axes in a 
// specified plane for a give pole. 
// Currently the plane has to be the xy plane.
//
// .SECTION Thanks
// This class was written by:
// Philippe Pbay, Kitware SAS 2011.
//
// .section See Also
// vtkActor vtkAxisActor vtkPolarAxesActor

#ifndef __vtkPolarAxesActor_h
#define __vtkPolarAxesActor_h

35
36
#define VTK_MAXIMUM_NUMBER_OF_RADIAL_AXES 50
#define VTK_DEFAULT_NUMBER_OF_RADIAL_AXES 5
37
#define VTK_MAXIMUM_NUMBER_OF_POLAR_AXIS_TICKS 200
38
#define VTK_DEFAULT_MAXIMUM_POLAR_ANGLE 90.0
39
#define VTK_POLAR_ARC_RESOLUTION_PER_DEG 0.2
40
41
42
43
44

#include "vtkActor.h"

class vtkAxisActor;
class vtkCamera;
45
46
class vtkPolyData;
class vtkPolyDataMapper;
47
class vtkTextProperty;
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68

class VTK_HYBRID_EXPORT vtkPolarAxesActor : public vtkActor
{
public:
  vtkTypeMacro(vtkPolarAxesActor,vtkActor);
  void PrintSelf(ostream& os, vtkIndent indent);

  // Description:
  // Instantiate object with label format "6.3g" and the number of labels
  // per axis set to 3.
  static vtkPolarAxesActor *New();

  // Description:
  // Draw the polar axes
  virtual int RenderOpaqueGeometry(vtkViewport*);
  virtual int RenderTranslucentPolygonalGeometry(vtkViewport*) {return 0;};

  // Description:
  // Explicitly specify the coordinate of the pole.
  // The default coordinates are (0,0,0).
  vtkSetVector3Macro( Pole, double );
69
  vtkGetVector3Macro( Pole, double );
70
71
72
73

  // Description:
  // Gets/Sets the number of radial axes
  // Default: VTK_DEFAULT_NUMBER_OF_RADIAL_AXES
74
  vtkSetClampMacro( NumberOfRadialAxes, vtkIdType, 2, VTK_MAXIMUM_NUMBER_OF_RADIAL_AXES );
75
76
  vtkGetMacro( NumberOfRadialAxes, vtkIdType );

77
78
  // Description:
  // Gets/Sets the number of ticks and labels along polar axis
79
  // NB: will be overriden if AutoSubdividePolarAxis is true
80
81
82
83
84
  vtkSetClampMacro( NumberOfPolarAxisTicks, vtkIdType, 0, VTK_MAXIMUM_NUMBER_OF_POLAR_AXIS_TICKS );
  vtkGetMacro( NumberOfPolarAxisTicks, vtkIdType );

  // Description:
  // Set/Get whether the number of polar axis ticks and arcs should be automatically calculated
85
  // Default: true
86
87
88
  vtkSetMacro( AutoSubdividePolarAxis, bool );
  vtkGetMacro( AutoSubdividePolarAxis, bool );

89
  // Description:
90
  //  Set/Get the maximum radius of the polar coordinates.
91
  // Default: VTK_DOUBLE_MAX
92
  vtkSetClampMacro( MaximumRadius, double, 0., VTK_DOUBLE_MAX );
93
94
  vtkGetMacro( MaximumRadius, double );

95
96
  // Description:
  // Turn on and off the auto-scaling of the maximum radius.
97
98
99
  // Default: false
  vtkSetMacro( AutoScaleRadius,bool );
  vtkGetMacro( AutoScaleRadius,bool );
100

101
102
103
104
105
106
  // Description:
  //  Set/Get the minimum radius of the polar coordinates (in degrees).
  // Default: 0.
  vtkSetClampMacro( MinimumAngle, double, 0., 360. );
  vtkGetMacro( MinimumAngle, double );

107
  // Description:
108
  //  Set/Get the maximum radius of the polar coordinates (in degrees).
109
  // Default: VTK_DEFAULT_MAXIMUM_POLAR_ANGLE
110
  vtkSetClampMacro( MaximumAngle, double, 0., 360. );
111
  vtkGetMacro( MaximumAngle, double );
112

113
  // Description: Set/Get whether angle units (degrees) are used to label radial axes 
114
  // Default: true
115
116
117
  vtkSetMacro( RadialUnits, bool ); 
  vtkGetMacro( RadialUnits, bool );

118
119
120
121
  // Description:
  // Explicitly specify the screen size of title and label text.
  // ScreenSize detemines the size of the text in terms of screen
  // pixels. 
122
  // Default: 10.0.
123
124
125
126
127
128
129
130
131
  void SetScreenSize( double screenSize );
  vtkGetMacro( ScreenSize, double );

  // Description:
  // Set/Get the camera to perform scaling and translation of the
  // vtkPolarAxesActor.
  virtual void SetCamera(vtkCamera*);
  vtkGetObjectMacro( Camera,vtkCamera );

132
133
134
135
136
137
  // Description:
  // Set/Get the labels for the polar axis.
  // Default: "Radial Distance".
  vtkSetStringMacro( PolarAxisTitle );
  vtkGetStringMacro( PolarAxisTitle );

138
  // Description:
139
140
141
  // Set/Get the format with which to print the polar axis labels
  vtkSetStringMacro( PolarLabelFormat );
  vtkGetStringMacro( PolarLabelFormat );
142
143
144
145
146

  // Description:
  // Release any graphics resources that are being consumed by this actor.
  // The parameter window could be used to determine which graphic
  // resources to release.
147
  void ReleaseGraphicsResources( vtkWindow* );
148
149

  // Description:
150
151
152
153
  // Turn on and off the visibility of the polar axis.
  vtkSetMacro( PolarAxisVisibility,int );
  vtkGetMacro( PolarAxisVisibility,int );
  vtkBooleanMacro( PolarAxisVisibility,int );
154

155
  // Description:
156
157
158
159
  // Turn on and off the visibility of titles for polar axis.
  vtkSetMacro( PolarTitleVisibility,int );
  vtkGetMacro( PolarTitleVisibility,int );
  vtkBooleanMacro( PolarTitleVisibility,int );
160

161
  // Description:
162
  // Turn on and off the visibility of labels for polar axis.
163
164
165
166
167
168
169
170
171
  vtkSetMacro( PolarLabelVisibility,int );
  vtkGetMacro( PolarLabelVisibility,int );
  vtkBooleanMacro( PolarLabelVisibility,int );

  // Description:
  // Turn on and off the visibility of ticks for polar axis.
  vtkSetMacro( PolarTickVisibility, int );
  vtkGetMacro( PolarTickVisibility, int );
  vtkBooleanMacro( PolarTickVisibility, int );
172

173
174
175
176
177
178
179
180
181
182
183
184
  // Description:
  // Turn on and off the visibility of non-polar radial axes.
  vtkSetMacro( RadialAxesVisibility,int );
  vtkGetMacro( RadialAxesVisibility,int );
  vtkBooleanMacro( RadialAxesVisibility,int );

  // Description:
  // Turn on and off the visibility of titles for non-polar radial axes.
  vtkSetMacro( RadialTitleVisibility,int );
  vtkGetMacro( RadialTitleVisibility,int );
  vtkBooleanMacro( RadialTitleVisibility,int );

185
186
187
188
189
190
  // Description:
  // Turn on and off the visibility of arcs for polar axis.
  vtkSetMacro( PolarArcsVisibility, int );
  vtkGetMacro( PolarArcsVisibility, int );
  vtkBooleanMacro( PolarArcsVisibility, int );

191
192
193
194
195
196
197
198
199
200
  // Description:
  // Set/Get the polar axis title text property. 
  virtual void SetPolarAxisTitleTextProperty(vtkTextProperty *p);
  vtkGetObjectMacro(PolarAxisTitleTextProperty,vtkTextProperty);

  // Description:
  // Set/Get the polar axis labels text property.
  virtual void SetPolarAxisLabelTextProperty(vtkTextProperty *p);
  vtkGetObjectMacro(PolarAxisLabelTextProperty,vtkTextProperty);
  
201
202
203
204
205
  // Description:
  // Get/Set polar axis actor properties.
  virtual void SetPolarAxisProperty(vtkProperty *);
  vtkProperty* GetPolarAxisProperty();

206
207
  // Description:
  // Get/Set radial axes actors properties.
208
  virtual void SetRadialAxesProperty(vtkProperty *);
209
210
  vtkProperty* GetRadialAxesProperty();

211
212
213
214
215
  // Description:
  // Get/Set polar arcs actors property
  virtual void SetPolarArcsProperty(vtkProperty *);
  vtkProperty* GetPolarArcsProperty();

216
217
218
219
220
221
222
223
224
225
226
  // Description:
  // Explicitly specify the region in space around which to draw the bounds.
  // The bounds are used only when no Input or Prop is specified. The bounds
  // are specified according to (xmin,xmax, ymin,ymax, zmin,zmax), making
  // sure that the min's are less than the max's.
  vtkSetVector6Macro(Bounds,double);
  double *GetBounds();
  void GetBounds(double& xmin, double& xmax, double& ymin, double& ymax,
                 double& zmin, double& zmax);
  void GetBounds(double bounds[6]);

227
228
229
230
protected:
  vtkPolarAxesActor();
  ~vtkPolarAxesActor();

Philippe Pébay's avatar
Philippe Pébay committed
231
  // Description:
232
233
  // Build the axes. 
  // Determine coordinates, position, etc.
234
  void  BuildAxes( vtkViewport * );
235

236
  // Description:
237
238
  // Send attributes which are common to all axes, both polar and radial
  void  SetCommonAxisAttributes( vtkAxisActor* );
239

240
  // Description:
241
  // Prepare ticks on polar axis with respect to coordinate offset
242
  void  BuildPolarAxisTicks( double );
243
244

  // Description:
245
246
  // Build polar axis labels and arcs with respect to specified pole.
  void  BuildPolarAxisLabelsArcs( double* );
247

248
249
  // Description:
  // Convenience methods
250
251
252
  double MaxOf(double, double );
  double FFix(double );
  double FSign(double, double );
253

254
255
256
257
  // Description:
  // Automatically rescale titles and labels 
  // NB: Current implementation only for perspective projections.
  void AutoScale( vtkViewport* viewport );
258
259
260
261
262
263
264
265
266

  // Description:
  // Coordinates of the pole
  double Pole[3]; 

  // Description:
  // Number of radial axes
  int NumberOfRadialAxes;

267
268
269
270
271
272
273
274
275
  // Description:
  // Number of polar arcs
  int NumberOfPolarAxisTicks;

  // Description:
  // Whether the number of polar axis ticks and arcs should be automatically calculated
  // Default: TRUE
  bool AutoSubdividePolarAxis;

276
277
278
  // Description:
  // Maximum polar radius (minimum is always 0)
  double MaximumRadius;
279

280
281
282
283
  // Description:
  // Auto-scale polar radius (with respect to average length scale of x-y bounding box)
  bool AutoScaleRadius;

284
  // Description:
285
286
287
288
289
  // Minimum polar angle
  double MinimumAngle;

  // Description:
  // Maximum polar angle
290
  double MaximumAngle;
291

292
293
294
295
  // Description:
  // Explicit actor bounds
  double Bounds[6];

296
297
298
299
300
301
302
303
  // Description:
  // Structures for polar arcs
  vtkPolyData        *PolarArcs;
  vtkPolyDataMapper  *PolarArcsMapper;
  vtkActor           *PolarArcsActor;

  // Description:
  // Camera attached to the polar axes system
304
305
306
  vtkCamera *Camera;

  // Description:
307
308
309
310
311
  // Control variables for polar axis
  vtkAxisActor* PolarAxis;

  // Description:
  // Control variables for non-polar radial axes
312
313
  vtkAxisActor** RadialAxes;

314
315
  // Description:
  // Title to be used for the polar axis
316
  // NB: Non-polar radial axes use the polar angle as title and have no labels
317
  char *PolarAxisTitle;
318
  char  *PolarLabelFormat;
319

320
321
322
  // Description:
  // Use angle units (degrees) to label radial axes
  bool RadialUnits;
323

324
325
326
327
328
329
  // Visibility of polar axis and its title, labels, ticks (major only)
  int PolarAxisVisibility;
  int PolarTitleVisibility;
  int PolarLabelVisibility;
  int PolarTickVisibility;

330
  // Visibility of radial axes and their titles
331
  int RadialAxesVisibility;
332
  int RadialTitleVisibility;
333

334
  // Visibility of polar arcs
335
  int PolarArcsVisibility;
336
337
338
339
340
341
342

  int   RenderCount;

  int RenderSomething;

  double LabelScreenOffset;

343
344
345
346
  // Text properties of polar axis title and labels
  vtkTextProperty   *PolarAxisTitleTextProperty;
  vtkTextProperty   *PolarAxisLabelTextProperty;

347
348
349
  // General properties of polar axis
  vtkProperty* PolarAxisProperty;

350
  // General properties of radial axes
351
352
353
354
355
  vtkProperty* RadialAxesProperty;

  vtkTimeStamp BuildTime;

  double LabelScale;
356
  double TitleScale;
357
358
359
360
361
362
363
364
365
366

  double ScreenSize;

private:
  vtkPolarAxesActor( const vtkPolarAxesActor& ); // Not implemented
  void operator=( const vtkPolarAxesActor& ); // Not implemented
};


#endif