VTK
vtkCubeAxesActor.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkCubeAxesActor.h
5  Language: C++
6 
7 Copyright (c) 1993-2001 Ken Martin, Will Schroeder, Bill Lorensen
8 All rights reserve
9  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
10 
11  This software is distributed WITHOUT ANY WARRANTY; without even
12  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
13  PURPOSE. See the above copyright notice for more information.
14 =========================================================================*/
59 #ifndef __vtkCubeAxesActor_h
60 #define __vtkCubeAxesActor_h
61 
62 #define VTK_FLY_OUTER_EDGES 0
63 #define VTK_FLY_CLOSEST_TRIAD 1
64 #define VTK_FLY_FURTHEST_TRIAD 2
65 #define VTK_FLY_STATIC_TRIAD 3
66 #define VTK_FLY_STATIC_EDGES 4
67 
68 #define VTK_TICKS_INSIDE 0
69 #define VTK_TICKS_OUTSIDE 1
70 #define VTK_TICKS_BOTH 2
71 
72 #define NUMBER_OF_ALIGNED_AXIS 4
73 
74 #include "vtkActor.h"
75 
76 class vtkAxisActor;
77 class vtkCamera;
78 class vtkTextProperty;
79 
81 {
82 public:
83  vtkTypeMacro(vtkCubeAxesActor,vtkActor);
84  void PrintSelf(ostream& os, vtkIndent indent);
85 
88  static vtkCubeAxesActor *New();
89 
91 
92  virtual int RenderOpaqueGeometry(vtkViewport*);
93  virtual int RenderTranslucentGeometry(vtkViewport*);
95  virtual int RenderOverlay(vtkViewport*);
98 
100 
101  vtkSetMacro( RebuildAxes, bool );
102  vtkGetMacro( RebuildAxes, bool );
104 
106 
110  vtkSetVector6Macro(Bounds,double);
111  double *GetBounds();
112  void GetBounds(double& xmin, double& xmax, double& ymin, double& ymax,
113  double& zmin, double& zmax);
114  void GetBounds(double bounds[6]);
116 
118 
125  vtkSetVector2Macro( XAxisRange, double );
126  vtkSetVector2Macro( YAxisRange, double );
127  vtkSetVector2Macro( ZAxisRange, double );
128  vtkGetVector2Macro( XAxisRange, double );
129  vtkGetVector2Macro( YAxisRange, double );
130  vtkGetVector2Macro( ZAxisRange, double );
132 
134 
137  void SetScreenSize(double screenSize);
138  vtkGetMacro(ScreenSize, double);
140 
142 
144  virtual void SetCamera(vtkCamera*);
145  vtkGetObjectMacro(Camera,vtkCamera);
147 
149 
152  vtkSetClampMacro(FlyMode, int, VTK_FLY_OUTER_EDGES, VTK_FLY_STATIC_EDGES);
153  vtkGetMacro(FlyMode, int);
154  void SetFlyModeToOuterEdges()
155  {this->SetFlyMode(VTK_FLY_OUTER_EDGES);};
156  void SetFlyModeToClosestTriad()
157  {this->SetFlyMode(VTK_FLY_CLOSEST_TRIAD);};
158  void SetFlyModeToFurthestTriad()
159  {this->SetFlyMode(VTK_FLY_FURTHEST_TRIAD);};
160  void SetFlyModeToStaticTriad()
161  {this->SetFlyMode(VTK_FLY_STATIC_TRIAD);};
162  void SetFlyModeToStaticEdges()
163  {this->SetFlyMode(VTK_FLY_STATIC_EDGES);};
165 
167 
169  vtkSetStringMacro(XTitle);
170  vtkGetStringMacro(XTitle);
171  vtkSetStringMacro(XUnits);
172  vtkGetStringMacro(XUnits);
173  vtkSetStringMacro(YTitle);
174  vtkGetStringMacro(YTitle);
175  vtkSetStringMacro(YUnits);
176  vtkGetStringMacro(YUnits);
177  vtkSetStringMacro(ZTitle);
178  vtkGetStringMacro(ZTitle);
179  vtkSetStringMacro(ZUnits);
180  vtkGetStringMacro(ZUnits);
182 
184 
186  vtkSetStringMacro(XLabelFormat);
187  vtkGetStringMacro(XLabelFormat);
188  vtkSetStringMacro(YLabelFormat);
189  vtkGetStringMacro(YLabelFormat);
190  vtkSetStringMacro(ZLabelFormat);
191  vtkGetStringMacro(ZLabelFormat);
193 
195 
198  vtkSetClampMacro(Inertia, int, 1, VTK_LARGE_INTEGER);
199  vtkGetMacro(Inertia, int);
201 
203 
206  vtkSetMacro(CornerOffset, double);
207  vtkGetMacro(CornerOffset, double);
209 
214 
216 
218  vtkSetMacro( EnableDistanceLOD, int );
219  vtkGetMacro( EnableDistanceLOD, int );
221 
223 
224  vtkSetClampMacro( DistanceLODThreshold, double, 0.0, 1.0 );
225  vtkGetMacro( DistanceLODThreshold, double);
227 
229 
231  vtkSetMacro( EnableViewAngleLOD, int );
232  vtkGetMacro( EnableViewAngleLOD, int );
234 
236 
237  vtkSetClampMacro( ViewAngleLODThreshold, double, 0., 1. );
238  vtkGetMacro( ViewAngleLODThreshold, double );
240 
242 
243  vtkSetMacro(XAxisVisibility,int);
244  vtkGetMacro(XAxisVisibility,int);
245  vtkBooleanMacro(XAxisVisibility,int);
246  vtkSetMacro(YAxisVisibility,int);
247  vtkGetMacro(YAxisVisibility,int);
248  vtkBooleanMacro(YAxisVisibility,int);
249  vtkSetMacro(ZAxisVisibility,int);
250  vtkGetMacro(ZAxisVisibility,int);
251  vtkBooleanMacro(ZAxisVisibility,int);
253 
255 
256  vtkSetMacro(XAxisLabelVisibility,int);
257  vtkGetMacro(XAxisLabelVisibility,int);
258  vtkBooleanMacro(XAxisLabelVisibility,int);
260 
261  vtkSetMacro(YAxisLabelVisibility,int);
262  vtkGetMacro(YAxisLabelVisibility,int);
263  vtkBooleanMacro(YAxisLabelVisibility,int);
264 
265  vtkSetMacro(ZAxisLabelVisibility,int);
266  vtkGetMacro(ZAxisLabelVisibility,int);
267  vtkBooleanMacro(ZAxisLabelVisibility,int);
268 
270 
271  vtkSetMacro(XAxisTickVisibility,int);
272  vtkGetMacro(XAxisTickVisibility,int);
273  vtkBooleanMacro(XAxisTickVisibility,int);
275 
276  vtkSetMacro(YAxisTickVisibility,int);
277  vtkGetMacro(YAxisTickVisibility,int);
278  vtkBooleanMacro(YAxisTickVisibility,int);
279 
280  vtkSetMacro(ZAxisTickVisibility,int);
281  vtkGetMacro(ZAxisTickVisibility,int);
282  vtkBooleanMacro(ZAxisTickVisibility,int);
283 
285 
286  vtkSetMacro(XAxisMinorTickVisibility,int);
287  vtkGetMacro(XAxisMinorTickVisibility,int);
288  vtkBooleanMacro(XAxisMinorTickVisibility,int);
290 
291  vtkSetMacro(YAxisMinorTickVisibility,int);
292  vtkGetMacro(YAxisMinorTickVisibility,int);
293  vtkBooleanMacro(YAxisMinorTickVisibility,int);
294 
295  vtkSetMacro(ZAxisMinorTickVisibility,int);
296  vtkGetMacro(ZAxisMinorTickVisibility,int);
297  vtkBooleanMacro(ZAxisMinorTickVisibility,int);
298 
299  vtkSetMacro(DrawXGridlines,int);
300  vtkGetMacro(DrawXGridlines,int);
301  vtkBooleanMacro(DrawXGridlines,int);
302 
303  vtkSetMacro(DrawYGridlines,int);
304  vtkGetMacro(DrawYGridlines,int);
305  vtkBooleanMacro(DrawYGridlines,int);
306 
307  vtkSetMacro(DrawZGridlines,int);
308  vtkGetMacro(DrawZGridlines,int);
309  vtkBooleanMacro(DrawZGridlines,int);
310 
311  vtkSetMacro(DrawXInnerGridlines,int);
312  vtkGetMacro(DrawXInnerGridlines,int);
313  vtkBooleanMacro(DrawXInnerGridlines,int);
314 
315  vtkSetMacro(DrawYInnerGridlines,int);
316  vtkGetMacro(DrawYInnerGridlines,int);
317  vtkBooleanMacro(DrawYInnerGridlines,int);
318 
319  vtkSetMacro(DrawZInnerGridlines,int);
320  vtkGetMacro(DrawZInnerGridlines,int);
321  vtkBooleanMacro(DrawZInnerGridlines,int);
322 
323  vtkSetMacro(DrawXGridpolys,int);
324  vtkGetMacro(DrawXGridpolys,int);
325  vtkBooleanMacro(DrawXGridpolys,int);
326 
327  vtkSetMacro(DrawYGridpolys,int);
328  vtkGetMacro(DrawYGridpolys,int);
329  vtkBooleanMacro(DrawYGridpolys,int);
330 
331  vtkSetMacro(DrawZGridpolys,int);
332  vtkGetMacro(DrawZGridpolys,int);
333  vtkBooleanMacro(DrawZGridpolys,int);
334 
336  vtkTextProperty *GetTitleTextProperty(int);
337 
339  vtkTextProperty *GetLabelTextProperty(int);
340 
342 
343  void SetXAxesLinesProperty(vtkProperty *);
344  vtkProperty* GetXAxesLinesProperty();
345  void SetYAxesLinesProperty(vtkProperty *);
346  vtkProperty* GetYAxesLinesProperty();
347  void SetZAxesLinesProperty(vtkProperty *);
348  vtkProperty* GetZAxesLinesProperty();
350 
352 
353  void SetXAxesGridlinesProperty(vtkProperty *);
354  vtkProperty* GetXAxesGridlinesProperty();
355  void SetYAxesGridlinesProperty(vtkProperty *);
356  vtkProperty* GetYAxesGridlinesProperty();
357  void SetZAxesGridlinesProperty(vtkProperty *);
358  vtkProperty* GetZAxesGridlinesProperty();
360 
362 
363  void SetXAxesInnerGridlinesProperty(vtkProperty *);
364  vtkProperty* GetXAxesInnerGridlinesProperty();
365  void SetYAxesInnerGridlinesProperty(vtkProperty *);
366  vtkProperty* GetYAxesInnerGridlinesProperty();
367  void SetZAxesInnerGridlinesProperty(vtkProperty *);
368  vtkProperty* GetZAxesInnerGridlinesProperty();
370 
372 
373  void SetXAxesGridpolysProperty(vtkProperty *);
374  vtkProperty* GetXAxesGridpolysProperty();
375  void SetYAxesGridpolysProperty(vtkProperty *);
376  vtkProperty* GetYAxesGridpolysProperty();
377  void SetZAxesGridpolysProperty(vtkProperty *);
378  vtkProperty* GetZAxesGridpolysProperty();
380 
382 
383  vtkSetClampMacro(TickLocation, int, VTK_TICKS_INSIDE, VTK_TICKS_BOTH);
384  vtkGetMacro(TickLocation, int);
386 
387  void SetTickLocationToInside(void)
388  { this->SetTickLocation(VTK_TICKS_INSIDE); };
389  void SetTickLocationToOutside(void)
390  { this->SetTickLocation(VTK_TICKS_OUTSIDE); };
391  void SetTickLocationToBoth(void)
392  { this->SetTickLocation(VTK_TICKS_BOTH); };
393 
394  void SetLabelScaling(bool, int, int, int);
395 
397 
399  void SetUse2DMode( int val );
400  int GetUse2DMode();
402 
404  void SetSaveTitlePosition( int val );
405 
406 protected:
408  ~vtkCubeAxesActor();
409 
410  int LabelExponent(double min, double max);
411 
412  int Digits(double min, double max);
413 
414  double MaxOf(double, double);
415  double MaxOf(double, double, double, double);
416 
417  double FFix(double);
418  double FSign(double, double);
419 
420  void UpdateLabels(vtkAxisActor **axis, int index);
421 
422  double Bounds[6]; //Define bounds explicitly
423 
425 
426  int FlyMode;
427 
431 
435 
439 
443 
445 
451 
453 
454  char *XTitle;
455  char *XUnits;
456  char *YTitle;
457  char *YUnits;
458  char *ZTitle;
459  char *ZUnits;
460 
464 
466 
470 
474 
478 
482 
486 
490 
494 
498 
499  double CornerOffset;
500 
501  int Inertia;
502 
504 
505  int InertiaLocs[3];
506 
508 
511 
512  vtkTextProperty* TitleTextProperty[3];
513  vtkTextProperty* LabelTextProperty[3];
514 
527 
528 private:
529  vtkCubeAxesActor(const vtkCubeAxesActor&); // Not implemented
530  void operator=(const vtkCubeAxesActor&); // Not implemented
531 
532  vtkSetStringMacro(ActualXLabel);
533  vtkSetStringMacro(ActualYLabel);
534  vtkSetStringMacro(ActualZLabel);
535 
536  vtkTimeStamp BuildTime;
537  int LastXPow;
538  int LastYPow;
539  int LastZPow;
540 
541  int UserXPow;
542  int UserYPow;
543  int UserZPow;
544 
545  bool AutoLabelScaling;
546 
547  int LastXAxisDigits;
548  int LastYAxisDigits;
549  int LastZAxisDigits;
550 
551  double LastXRange[2];
552  double LastYRange[2];
553  double LastZRange[2];
554 
555  int LastFlyMode;
556 
557  int RenderAxesX[NUMBER_OF_ALIGNED_AXIS];
558  int RenderAxesY[NUMBER_OF_ALIGNED_AXIS];
559  int RenderAxesZ[NUMBER_OF_ALIGNED_AXIS];
560 
561  int NumberOfAxesX;
562  int NumberOfAxesY;
563  int NumberOfAxesZ;
564 
565  bool MustAdjustXValue;
566  bool MustAdjustYValue;
567  bool MustAdjustZValue;
568 
569  bool ForceXLabelReset;
570  bool ForceYLabelReset;
571  bool ForceZLabelReset;
572 
573  double XAxisRange[2];
574  double YAxisRange[2];
575  double ZAxisRange[2];
576 
577  double LabelScale;
578  double TitleScale;
579 
580  double ScreenSize;
581 
583 
585  double MajorStart[3];
586  double DeltaMajor[3];
588 
589  void TransformBounds(vtkViewport *viewport, const double bounds[6],
590  double pts[8][3]);
591  void AdjustAxes(double bounds[6],
592  double xCoords[NUMBER_OF_ALIGNED_AXIS][6],
593  double yCoords[NUMBER_OF_ALIGNED_AXIS][6],
594  double zCoords[NUMBER_OF_ALIGNED_AXIS][6],
595  double xRange[2], double yRange[2], double zRange[2]);
596 
597  bool ComputeTickSize(double bounds[6]);
598  void AdjustValues(const double xRange[2],
599  const double yRange[2],
600  const double zRange[2]);
601  void AdjustRange(const double bounds[6]);
602  void BuildAxes(vtkViewport *);
603  void DetermineRenderAxes(vtkViewport *);
604  void SetNonDependentAttributes(void);
605  void BuildLabels(vtkAxisActor *axes[NUMBER_OF_ALIGNED_AXIS]);
606  void AdjustTicksComputeRange(vtkAxisActor *axes[NUMBER_OF_ALIGNED_AXIS],
607  double rangeMin, double rangeMax);
608 
609  void AutoScale(vtkViewport *viewport);
610  void AutoScale(vtkViewport *viewport, vtkAxisActor *axes[NUMBER_OF_ALIGNED_AXIS]);
611  double AutoScale(vtkViewport *viewport, double screenSize, double position[3]);
612 };
613 
614 
615 #endif