VTK  9.2.6
vtkAxisActor.h
Go to the documentation of this file.
1/*=========================================================================
2Program: Visualization Toolkit
3Module: vtkAxisActor.h
4Language: C++
5
6Copyright (c) 1993-2000 Ken Martin, Will Schroeder, Bill Lorensen
7All rights reserved.
8This software is distributed WITHOUT ANY WARRANTY; without even
9the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
10PURPOSE. See the above copyright notice for more information.
11=========================================================================*/
52
53#ifndef vtkAxisActor_h
54#define vtkAxisActor_h
55
56#include "vtkActor.h"
57#include "vtkRenderingAnnotationModule.h" // For export macro
58
59class vtkAxisFollower;
60class vtkCamera;
61class vtkCoordinate;
62class vtkFollower;
63class vtkPoints;
64class vtkPolyData;
67class vtkProperty2D;
68class vtkStringArray;
69class vtkTextActor;
70class vtkTextActor3D;
71class vtkTextProperty;
72class vtkVectorText;
73
74class VTKRENDERINGANNOTATION_EXPORT vtkAxisActor : public vtkActor
75{
76public:
77 vtkTypeMacro(vtkAxisActor, vtkActor);
78 void PrintSelf(ostream& os, vtkIndent indent) override;
79
83 static vtkAxisActor* New();
84
86
90 virtual void SetPoint1(double x[3]) { this->SetPoint1(x[0], x[1], x[2]); }
91 virtual void SetPoint1(double x, double y, double z);
92 virtual double* GetPoint1();
94
96
100 virtual void SetPoint2(double x[3]) { this->SetPoint2(x[0], x[1], x[2]); }
101 virtual void SetPoint2(double x, double y, double z);
102 virtual double* GetPoint2();
104
106
110 vtkSetVector2Macro(Range, double);
111 vtkGetVectorMacro(Range, double, 2);
113
115
118 void SetBounds(const double bounds[6]);
119 void SetBounds(double xmin, double xmax, double ymin, double ymax, double zmin, double zmax);
120 double* GetBounds(void) VTK_SIZEHINT(6) override;
121 void GetBounds(double bounds[6]);
123
125
128 vtkSetStringMacro(LabelFormat);
129 vtkGetStringMacro(LabelFormat);
131
133
140 vtkSetMacro(UseTextActor3D, int);
141 vtkGetMacro(UseTextActor3D, int);
143
145
152
154
157 void SetTitle(const char* t);
158 vtkGetStringMacro(Title);
160
162
165 void SetExponent(const char* t);
166 vtkGetStringMacro(Exponent);
168
170
173 vtkSetMacro(MajorTickSize, double);
174 vtkGetMacro(MajorTickSize, double);
176
178
181 vtkSetMacro(MinorTickSize, double);
182 vtkGetMacro(MinorTickSize, double);
184
191
193
199 vtkGetMacro(TickLocation, int);
201
205
207
212 vtkBooleanMacro(AxisVisibility, vtkTypeBool);
214
216
221 vtkBooleanMacro(TickVisibility, vtkTypeBool);
223
225
230 vtkBooleanMacro(LabelVisibility, vtkTypeBool);
232
234
239 vtkBooleanMacro(TitleVisibility, vtkTypeBool);
241
243
246 vtkSetMacro(ExponentVisibility, bool);
247 vtkGetMacro(ExponentVisibility, bool);
248 vtkBooleanMacro(ExponentVisibility, bool);
250
252
257 vtkBooleanMacro(LastMajorTickPointCorrection, bool);
259
267
269
273 virtual void SetTitleAlignLocation(int location);
274 vtkGetMacro(TitleAlignLocation, int);
276
278
282 virtual void SetExponentLocation(int location);
283 vtkGetMacro(ExponentLocation, int);
285
287
291 vtkGetObjectMacro(TitleTextProperty, vtkTextProperty);
293
295
299 vtkGetObjectMacro(LabelTextProperty, vtkTextProperty);
301
303
309
311
317
319
325
327
333
335
341
343
349
351
357
359
364 vtkBooleanMacro(DrawGridlines, vtkTypeBool);
366
368
377
378 vtkSetMacro(DrawGridlinesLocation, int);
379 vtkGetMacro(DrawGridlinesLocation, int);
380
382
389
391
394 vtkSetMacro(GridlineXLength, double);
395 vtkGetMacro(GridlineXLength, double);
396 vtkSetMacro(GridlineYLength, double);
397 vtkGetMacro(GridlineYLength, double);
398 vtkSetMacro(GridlineZLength, double);
399 vtkGetMacro(GridlineZLength, double);
401
403
408 vtkBooleanMacro(DrawGridpolys, vtkTypeBool);
410
417
419
422 vtkSetClampMacro(AxisType, int, VTK_AXIS_TYPE_X, VTK_AXIS_TYPE_Z);
423 vtkGetMacro(AxisType, int);
428
436
438
441 vtkSetMacro(Log, bool);
442 vtkGetMacro(Log, bool);
443 vtkBooleanMacro(Log, bool);
445
447
455 vtkGetMacro(AxisPosition, int);
457
462
464
468 virtual void SetCamera(vtkCamera*);
469 vtkGetObjectMacro(Camera, vtkCamera);
471
473
476 int RenderOpaqueGeometry(vtkViewport* viewport) override;
479 int RenderOverlay(vtkViewport* viewport) override;
482
489
490 double ComputeMaxLabelLength(const double[3]);
491 double ComputeTitleLength(const double[3]);
492
493 void SetLabelScale(const double scale);
494 void SetLabelScale(int labelIndex, const double scale);
495 void SetTitleScale(const double scale);
496
498
502 vtkSetMacro(MinorStart, double);
503 vtkGetMacro(MinorStart, double);
504 double GetMajorStart(int axis);
505 void SetMajorStart(int axis, double value);
506 // vtkSetMacro(MajorStart, double);
507 // vtkGetMacro(MajorStart, double);
508 vtkSetMacro(DeltaMinor, double);
509 vtkGetMacro(DeltaMinor, double);
510 double GetDeltaMajor(int axis);
511 void SetDeltaMajor(int axis, double value);
512 // vtkSetMacro(DeltaMajor, double);
513 // vtkGetMacro(DeltaMajor, double);
515
517
523 vtkSetMacro(MinorRangeStart, double);
524 vtkGetMacro(MinorRangeStart, double);
525 vtkSetMacro(MajorRangeStart, double);
526 vtkGetMacro(MajorRangeStart, double);
527 vtkSetMacro(DeltaRangeMinor, double);
528 vtkGetMacro(DeltaRangeMinor, double);
529 vtkSetMacro(DeltaRangeMajor, double);
530 vtkGetMacro(DeltaRangeMajor, double);
532
534
535 void BuildAxis(vtkViewport* viewport, bool);
536
538
542 vtkGetObjectMacro(TitleActor, vtkAxisFollower);
544
546
549 vtkGetObjectMacro(ExponentActor, vtkAxisFollower);
551
555 inline vtkAxisFollower** GetLabelActors() { return this->LabelActors; }
556
558
562 vtkGetObjectMacro(TitleProp3D, vtkProp3DAxisFollower);
564
568 inline vtkProp3DAxisFollower** GetLabelProps3D() { return this->LabelProps3D; }
569
571
575 vtkGetObjectMacro(ExponentProp3D, vtkProp3DAxisFollower);
577
579
583 vtkGetMacro(NumberOfLabelsBuilt, int);
585
587
591 vtkSetMacro(CalculateTitleOffset, vtkTypeBool);
592 vtkGetMacro(CalculateTitleOffset, vtkTypeBool);
593 vtkBooleanMacro(CalculateTitleOffset, vtkTypeBool);
595
597
601 vtkSetMacro(CalculateLabelOffset, vtkTypeBool);
602 vtkGetMacro(CalculateLabelOffset, vtkTypeBool);
603 vtkBooleanMacro(CalculateLabelOffset, vtkTypeBool);
605
607
610 vtkSetMacro(Use2DMode, int);
611 vtkGetMacro(Use2DMode, int);
613
615
618 vtkSetMacro(VerticalOffsetXTitle2D, double);
619 vtkGetMacro(VerticalOffsetXTitle2D, double);
621
623
626 vtkSetMacro(HorizontalOffsetYTitle2D, double);
627 vtkGetMacro(HorizontalOffsetYTitle2D, double);
629
631
634 vtkSetMacro(SaveTitlePosition, int);
635 vtkGetMacro(SaveTitlePosition, int);
637
639
642 vtkSetVector3Macro(AxisBaseForX, double);
643 vtkGetVector3Macro(AxisBaseForX, double);
645
647
650 vtkSetVector3Macro(AxisBaseForY, double);
651 vtkGetVector3Macro(AxisBaseForY, double);
653
655
658 vtkSetVector3Macro(AxisBaseForZ, double);
659 vtkGetVector3Macro(AxisBaseForZ, double);
661
663
666 vtkSetMacro(AxisOnOrigin, int);
667 vtkGetMacro(AxisOnOrigin, int);
669
671
674 vtkSetMacro(LabelOffset, double);
675 vtkGetMacro(LabelOffset, double);
676 vtkSetMacro(TitleOffset, double);
677 vtkGetMacro(TitleOffset, double);
678 vtkSetMacro(ExponentOffset, double);
679 vtkGetMacro(ExponentOffset, double);
680 vtkSetMacro(ScreenSize, double);
681 vtkGetMacro(ScreenSize, double);
683
684protected:
686 ~vtkAxisActor() override;
687
688 char* Title;
689 char* Exponent;
690 double Range[2];
691 double LastRange[2];
697
704
710
716
720 int DrawGridlinesLocation; // 0: all | 1: closest | 2: farest
721 int LastDrawGridlinesLocation; // 0: all | 1: closest | 2: farest
725
728
731
739
740 bool Log;
743
744 // coordinate system for axisAxtor, relative to world coordinates
745 double AxisBaseForX[3];
746 double AxisBaseForY[3];
747 double AxisBaseForZ[3];
748
749private:
750 vtkAxisActor(const vtkAxisActor&) = delete;
751 void operator=(const vtkAxisActor&) = delete;
752
753 void TransformBounds(vtkViewport*, double bnds[6]);
754
755 void BuildLabels(vtkViewport*, bool);
756 void BuildLabels2D(vtkViewport*, bool);
757 void SetLabelPositions(vtkViewport*, bool);
758 void SetLabelPositions2D(vtkViewport*, bool);
759
764 void RotateActor2DFromAxisProjection(vtkTextActor* pActor2D);
765
769 void InitTitle();
770
774 void InitExponent();
775
782 void BuildTitle(bool);
783
788 void BuildExponent(bool force);
789
790 void BuildExponent2D(vtkViewport* viewport, bool force);
791
792 void BuildTitle2D(vtkViewport* viewport, bool);
793
794 void SetAxisPointsAndLines(void);
795
796 bool BuildTickPoints(double p1[3], double p2[3], bool force);
797
798 // Build major ticks for linear scale.
799 void BuildMajorTicks(double p1[3], double p2[3], double localCoordSys[3][3]);
800
801 // Build major ticks for logarithmic scale.
802 void BuildMajorTicksLog(double p1[3], double p2[3], double localCoordSys[3][3]);
803
804 // Build minor ticks for linear scale.
805 void BuildMinorTicks(double p1[3], double p2[3], double localCoordSys[3][3]);
806
807 // Build minor ticks for logarithmic scale enabled
808 void BuildMinorTicksLog(double p1[3], double p2[3], double localCoordSys[3][3]);
809
810 void BuildAxisGridLines(double p1[3], double p2[3], double localCoordSys[3][3]);
811
812 bool TickVisibilityChanged(void);
813 vtkProperty* NewTitleProperty();
814 vtkProperty2D* NewTitleProperty2D();
815 vtkProperty* NewLabelProperty();
816
817 bool BoundsDisplayCoordinateChanged(vtkViewport* viewport);
818
819 vtkCoordinate* Point1Coordinate;
820 vtkCoordinate* Point2Coordinate;
821
822 double MajorTickSize;
823 double MinorTickSize;
824
825 // For each axis (for the inner gridline generation)
826 double MajorStart[3];
827 double DeltaMajor[3];
828 double MinorStart;
829 double DeltaMinor;
830
831 // For the ticks, w.r.t to the set range
832 double MajorRangeStart;
833 double MinorRangeStart;
834
838 double DeltaRangeMinor;
839
843 double DeltaRangeMajor;
844
845 int LastAxisPosition;
846 int LastAxisType;
847 int LastTickLocation;
848 double LastLabelStart;
849
850 vtkPoints* MinorTickPts;
851 vtkPoints* MajorTickPts;
852 vtkPoints* GridlinePts;
853 vtkPoints* InnerGridlinePts;
854 vtkPoints* GridpolyPts;
855
856 vtkVectorText* TitleVector;
857 vtkPolyDataMapper* TitleMapper;
858 vtkAxisFollower* TitleActor;
859 vtkTextActor* TitleActor2D;
860 vtkProp3DAxisFollower* TitleProp3D;
861 vtkTextActor3D* TitleActor3D;
862 vtkTextProperty* TitleTextProperty;
863
865
868 vtkVectorText* ExponentVector;
869 vtkPolyDataMapper* ExponentMapper;
870 vtkAxisFollower* ExponentActor;
871 vtkTextActor* ExponentActor2D;
872 vtkProp3DAxisFollower* ExponentProp3D;
873 vtkTextActor3D* ExponentActor3D;
875
876 vtkVectorText** LabelVectors;
877 vtkPolyDataMapper** LabelMappers;
878 vtkAxisFollower** LabelActors;
879 vtkProp3DAxisFollower** LabelProps3D;
880 vtkTextActor** LabelActors2D;
881 vtkTextActor3D** LabelActors3D;
882 vtkTextProperty* LabelTextProperty;
883
884 // Main line axis
885 vtkPolyData* AxisLines;
886 vtkPolyDataMapper* AxisLinesMapper;
887 vtkActor* AxisLinesActor;
888
889 // Ticks of the axis
890 vtkPolyData *AxisMajorTicks, *AxisMinorTicks;
891 vtkPolyDataMapper *AxisMajorTicksMapper, *AxisMinorTicksMapper;
892 vtkActor *AxisMajorTicksActor, *AxisMinorTicksActor;
893
894 vtkPolyData* Gridlines;
895 vtkPolyDataMapper* GridlinesMapper;
896 vtkActor* GridlinesActor;
897 vtkPolyData* InnerGridlines;
898 vtkPolyDataMapper* InnerGridlinesMapper;
899 vtkActor* InnerGridlinesActor;
900 vtkPolyData* Gridpolys;
901 vtkPolyDataMapper* GridpolysMapper;
902 vtkActor* GridpolysActor;
903
904 vtkCamera* Camera;
905 vtkTimeStamp BuildTime;
906 vtkTimeStamp BuildTickPointsTime;
907 vtkTimeStamp BoundsTime;
908 vtkTimeStamp LabelBuildTime;
909 vtkTimeStamp TitleTextTime;
910 vtkTimeStamp ExponentTextTime;
911
912 int AxisOnOrigin;
913
914 int AxisHasZeroLength;
915
916 vtkTypeBool CalculateTitleOffset;
917 vtkTypeBool CalculateLabelOffset;
918
922 int Use2DMode;
923
928 double VerticalOffsetXTitle2D;
929
934 double HorizontalOffsetYTitle2D;
935
942 int SaveTitlePosition;
943
947 double TitleConstantPosition[2];
948
952 bool NeedBuild2D;
953
954 double LastMinDisplayCoordinate[3];
955 double LastMaxDisplayCoordinate[3];
956 double TickVector[3];
957
959
962 double ScreenSize;
963 double LabelOffset;
964 double TitleOffset;
965 double ExponentOffset;
967};
968
969#endif
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
int LastDrawGridlinesLocation
double GridlineZLength
int LastMinorTicksVisible
void SetAxisTypeToZ(void)
Set/Get the type of this axis.
virtual void SetPoint2(double x, double y, double z)
Specify the position of the second point defining the axis.
vtkTypeBool LabelVisibility
virtual void SetCamera(vtkCamera *)
Set/Get the camera for this axis.
void SetAxisPositionToMinMin(void)
virtual void SetPoint2(double x[3])
Specify the position of the second point defining the axis.
void SetDeltaMajor(int axis, double value)
Set/Get the starting position for minor and major tick points, and the delta values that determine th...
vtkTypeBool TitleVisibility
void SetAxisMainLineProperty(vtkProperty *)
Get/Set main line axis actor property.
virtual double * GetPoint1()
Specify the position of the first point defining the axis.
vtkProperty * GetGridlinesProperty()
Get/Set gridlines actor property (outer grid lines)
vtkTypeBool DrawGridpolys
void SetBounds(const double bounds[6])
Set or get the bounds for this Actor as (Xmin,Xmax,Ymin,Ymax,Zmin,Zmax).
int RenderOverlay(vtkViewport *viewport) override
Draw the axis.
vtkTypeBool HasTranslucentPolygonalGeometry() override
Draw the axis.
~vtkAxisActor() override
double ComputeMaxLabelLength(const double[3])
int NumberOfLabelsBuilt
void SetTickLocationToOutside(void)
double GetMajorStart(int axis)
Set/Get the starting position for minor and major tick points, and the delta values that determine th...
double GridlineYLength
vtkTypeBool DrawInnerGridlines
void SetGridlinesProperty(vtkProperty *)
Get/Set gridlines actor property (outer grid lines)
void SetLabelScale(int labelIndex, const double scale)
void SetTitle(const char *t)
Set/Get the title of the axis actor,.
double AxisBaseForY[3]
vtkProperty * GetGridpolysProperty()
Get/Set gridPolys actor property (grid quads)
virtual void SetLabelTextProperty(vtkTextProperty *p)
Set/Get the axis labels text property.
vtkAxisFollower ** GetLabelActors()
Get label actors responsigle for drawing label text.
double GridlineXLength
double Range[2]
virtual void SetExponentLocation(int location)
Get/Set the location of the Detached Exponent related to the axis.
virtual vtkCoordinate * GetPoint2Coordinate()
Specify the position of the second point defining the axis.
vtkProperty * GetInnerGridlinesProperty()
Get/Set inner gridlines actor property.
char * LabelFormat
double AxisBaseForZ[3]
bool LastMajorTickPointCorrection
double GetDeltaMajor(int axis)
Set/Get the starting position for minor and major tick points, and the delta values that determine th...
virtual void SetPoint1(double x[3])
Specify the position of the first point defining the axis.
double AxisBaseForX[3]
void SetAxisLinesProperty(vtkProperty *)
Get/Set axis actor property (axis and its ticks) (kept for compatibility)
vtkTypeBool DrawGridlines
void SetInnerGridlinesProperty(vtkProperty *)
Get/Set inner gridlines actor property.
vtkProperty * GetAxisMajorTicksProperty()
Get/Set axis actor property (axis and its ticks)
void SetAxisMajorTicksProperty(vtkProperty *)
Get/Set axis actor property (axis and its ticks)
void SetBounds(double xmin, double xmax, double ymin, double ymax, double zmin, double zmax)
Set or get the bounds for this Actor as (Xmin,Xmax,Ymin,Ymax,Zmin,Zmax).
int TitleAlignLocation
Hold the alignment property of the title related to the axis.
void BuildAxis(vtkViewport *viewport, bool)
void GetBounds(double bounds[6])
Set or get the bounds for this Actor as (Xmin,Xmax,Ymin,Ymax,Zmin,Zmax).
virtual double * GetPoint2()
Specify the position of the second point defining the axis.
void SetAxisTypeToX(void)
Set/Get the type of this axis.
vtkTypeBool DrawGridlinesOnly
vtkTypeBool TickVisibility
void ReleaseGraphicsResources(vtkWindow *) override
Release any graphics resources that are being consumed by this actor.
int RenderOpaqueGeometry(vtkViewport *viewport) override
Draw the axis.
vtkTypeBool AxisVisibility
virtual void SetAxisType(int)
Set/Get the type of this axis.
virtual void SetAxisPosition(int)
Set/Get the position of this axis (in relation to an an assumed bounding box).
int ExponentLocation
Hold the alignment property of the exponent coming from the label values.
int LastDrawInnerGridlines
virtual void SetTickLocation(int)
Set/Get the location of the ticks.
void SetAxisPositionToMaxMax(void)
bool ExponentVisibility
double * GetBounds(void) override
Set or get the bounds for this Actor as (Xmin,Xmax,Ymin,Ymax,Zmin,Zmax).
virtual void SetTitleAlignLocation(int location)
Get/Set the alignment of the title related to the axis.
vtkProperty * GetAxisMainLineProperty()
Get/Set main line axis actor property.
virtual void SetTitleTextProperty(vtkTextProperty *p)
Set/Get the axis title text property.
double ComputeTitleLength(const double[3])
void SetLabelScale(const double scale)
virtual vtkCoordinate * GetPoint1Coordinate()
Specify the position of the first point defining the axis.
virtual int RenderTranslucentGeometry(vtkViewport *viewport)
Draw the axis.
vtkProp3DAxisFollower ** GetLabelProps3D()
Get label actors responsigle for drawing label text.
void SetLabels(vtkStringArray *labels)
void SetTickLocationToInside(void)
vtkProperty * GetAxisMinorTicksProperty()
Get/Set axis actor property (axis and its ticks)
double LastRange[2]
void SetAxisPositionToMinMax(void)
virtual void SetPoint1(double x, double y, double z)
Specify the position of the first point defining the axis.
void SetAxisMinorTicksProperty(vtkProperty *)
Get/Set axis actor property (axis and its ticks)
void SetAxisTypeToY(void)
Set/Get the type of this axis.
vtkTypeBool MinorTicksVisible
static vtkAxisActor * New()
Instantiate object.
void SetMajorStart(int axis, double value)
Set/Get the starting position for minor and major tick points, and the delta values that determine th...
vtkProperty * GetAxisLinesProperty()
Get/Set axis actor property (axis and its ticks) (kept for compatibility)
void SetTickLocationToBoth(void)
void SetExponent(const char *t)
Set/Get the common exponent of the labels values.
void SetTitleScale(const double scale)
int RenderTranslucentPolygonalGeometry(vtkViewport *viewport) override
Draw the axis.
int DrawGridlinesLocation
void SetGridpolysProperty(vtkProperty *)
Get/Set gridPolys actor property (grid quads)
void SetAxisPositionToMaxMin(void)
a subclass of vtkFollower that ensures that data is always parallel to the axis defined by a vtkAxisA...
a virtual camera for 3D rendering
Definition vtkCamera.h:52
perform coordinate transformation, and represent position, in a variety of vtk coordinate systems
a subclass of actor that always faces the camera
Definition vtkFollower.h:44
a simple class to control print indentation
Definition vtkIndent.h:40
represent and manipulate 3D points
Definition vtkPoints.h:40
map vtkPolyData to graphics primitives
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition vtkPolyData.h:91
a subclass of vtkProp3DFollower that ensures that data is always parallel to the axis defined by a vt...
represent surface properties of a 2D image
represent surface properties of a geometric object
Definition vtkProperty.h:68
a vtkAbstractArray subclass for strings
An actor that displays text.
An actor that displays text.
represent text properties.
record modification and/or execution time
create polygonal text
abstract specification for Viewports
Definition vtkViewport.h:56
window superclass for vtkRenderWindow
Definition vtkWindow.h:39
int vtkTypeBool
Definition vtkABI.h:69
#define VTK_SIZEHINT(...)