VTK  9.5.2
vtkGridAxesActor2D.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (c) Kitware Inc.
2// SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
3// SPDX-License-Identifier: BSD-3-Clause
23#ifndef vtkGridAxesActor2D_h
24#define vtkGridAxesActor2D_h
25
26#include "vtkProp3D.h"
27#include "vtkRenderingGridAxesModule.h" //needed for exports
28
29#include "vtkGridAxesHelper.h" // needed of Helper
30#include "vtkGridAxesPlaneActor2D.h" // needed for inline methods
31#include "vtkNew.h" // needed for vtkNew.
32#include "vtkSmartPointer.h" // needed for vtkSmartPointer.
33
34#include <functional> // for std::function
35
36VTK_ABI_NAMESPACE_BEGIN
37class vtkAxis;
38class vtkContextScene;
39class vtkDoubleArray;
40class vtkProperty;
41class vtkTextProperty;
42
43class VTKRENDERINGGRIDAXES_EXPORT vtkGridAxesActor2D : public vtkProp3D
44{
45public:
48 void PrintSelf(ostream& os, vtkIndent indent) override;
49
51
56 vtkSetVector6Macro(GridBounds, double);
57 vtkGetVector6Macro(GridBounds, double);
59
61
67 vtkGetMacro(Face, int);
69
71
79 vtkSetMacro(LabelMask, unsigned int);
80 vtkGetMacro(LabelMask, unsigned int);
82
92
97 void UpdateGeometry(vtkViewport* viewport, bool doRegularUpdate);
98
100
107
109
116
118
125
127
132 void SetTitle(int axis, const std::string& title);
133 const std::string& GetTitle(int axis);
135
137
143 void SetNotation(int axis, int notation);
144 int GetNotation(int axis);
146
148
151 void SetPrecision(int axis, int val);
152 int GetPrecision(int axis);
154
156
162 void SetTickLabelFunction(int axis, std::function<double(double)> func);
163 std::function<double(double)> GetTickLabelFunction(int axis);
165
173 void SetCustomTickPositions(int axis, vtkDoubleArray* positions);
174
175 //---------------------------------------------------------------------------
176 // *** Properties to control grid rendering ***
177 //---------------------------------------------------------------------------
178
180
185 void SetGenerateGrid(bool val) { this->PlaneActor->SetGenerateGrid(val); }
186 bool GetGenerateGrid() { return this->PlaneActor->GetGenerateGrid(); }
187 vtkBooleanMacro(GenerateGrid, bool);
189
191
196 void SetGenerateEdges(bool val) { this->PlaneActor->SetGenerateEdges(val); }
197 bool GetGenerateEdges() { return this->PlaneActor->GetGenerateEdges(); }
198 vtkBooleanMacro(GenerateEdges, bool);
200
202
208 void SetGenerateTicks(bool val) { this->PlaneActor->SetGenerateTicks(val); }
209 bool GetGenerateTicks() { return this->PlaneActor->GetGenerateTicks(); }
210 vtkBooleanMacro(GenerateTicks, bool);
212
213 //--------------------------------------------------------------------------
214 // Methods for vtkProp3D API.
215 //--------------------------------------------------------------------------
216
218
221 double* GetBounds() override
222 {
223 this->GetGridBounds(this->Bounds);
224 return this->Bounds;
225 }
227
229
234 vtkSetMacro(ForceOpaque, bool);
235 vtkGetMacro(ForceOpaque, bool);
236 vtkBooleanMacro(ForceOpaque, bool);
238
240
245 int RenderOverlay(vtkViewport* viewport) override;
248
255
260
262
272 vtkSetVector2Macro(LabelDisplayOffset, int);
273 vtkGetVector2Macro(LabelDisplayOffset, int);
275
276protected:
279
280 bool Update(vtkViewport* viewport);
284 friend class vtkGridAxesActor3D;
285
286private:
287 vtkGridAxesActor2D(const vtkGridAxesActor2D&) = delete;
288 void operator=(const vtkGridAxesActor2D&) = delete;
289
290 class vtkLabels;
291 vtkLabels* Labels;
292 friend class vtkLabels;
293
294 bool DoRender;
295
296 double GridBounds[6];
297 int Face = vtkGridAxesHelper::MIN_YZ;
298 unsigned int LabelMask = 0xff;
299
300 vtkTuple<vtkSmartPointer<vtkTextProperty>, 3> TitleTextProperty;
301 vtkTuple<vtkSmartPointer<vtkTextProperty>, 3> LabelTextProperty;
303
306 vtkNew<vtkAxis> AxisHelpers[3];
307 vtkNew<vtkContextScene> AxisHelperScene;
308 vtkTimeStamp UpdateLabelTextPropertiesMTime;
309 int LabelDisplayOffset[2] = { 0, 0 };
310
311 bool ForceOpaque = false;
312 std::function<double(double)> TickLabelFunction[3] = { nullptr, nullptr, nullptr };
313};
314
315VTK_ABI_NAMESPACE_END
316#endif
takes care of drawing 2D axes
Definition vtkAxis.h:171
Provides a 2D scene for vtkContextItem objects.
dynamic, self-adjusting array of double
actor for an axes plane in a 3D view.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
bool GetGenerateTicks()
Turn off to not generate the markers for the tick positions.
vtkTextProperty * GetTitleTextProperty(int axis)
Get/Set the title text properties for each of the coordinate axes.
static vtkGridAxesActor2D * New()
vtkMTimeType GetMTime() override
Overridden to include the mtime for the text properties.
vtkTypeBool HasTranslucentPolygonalGeometry() override
Standard render methods for different types of geometry.
vtkTextProperty * GetLabelTextProperty(int axis)
Get/Set the label text properties for each of the coordinate axes.
void SetTickLabelFunction(int axis, std::function< double(double)> func)
Get/Set the function that will be applied to the tick label of each axis.
int RenderOpaqueGeometry(vtkViewport *) override
Standard render methods for different types of geometry.
void SetNotation(int axis, int notation)
Get/set the numerical notation, standard, scientific or mixed (0, 1, 2).
void SetLabelTextProperty(int axis, vtkTextProperty *)
Get/Set the label text properties for each of the coordinate axes.
void UpdateTextActors(vtkViewport *viewport)
void SetGenerateGrid(bool val)
Turn off to not generate polydata for the plane's grid.
void SetCustomTickPositions(int axis, vtkDoubleArray *positions)
Set custom tick positions for each of the axes.
void SetProperty(vtkProperty *)
Get/Set the property used to control the appearance of the rendered grid, including edges.
std::function< double(double)> GetTickLabelFunction(int axis)
Get/Set the function that will be applied to the tick label of each axis.
void UpdateLabelPositions(vtkViewport *viewport)
double * GetBounds() override
Returns the prop bounds.
void GetActors(vtkPropCollection *) override
For some exporters and other other operations we must be able to collect all the actors or volumes.
void ReleaseGraphicsResources(vtkWindow *) override
Release any graphics resources that are being consumed by this prop.
void SetPrecision(int axis, int val)
Get/set the numerical precision to use, default is 2.
bool GetGenerateEdges()
Turn off to not generate the polydata for the plane's edges.
bool GetGenerateGrid()
Turn off to not generate polydata for the plane's grid.
int GetNotation(int axis)
Get/set the numerical notation, standard, scientific or mixed (0, 1, 2).
void SetTitleTextProperty(int axis, vtkTextProperty *)
Get/Set the title text properties for each of the coordinate axes.
vtkProperty * GetProperty()
Get/Set the property used to control the appearance of the rendered grid, including edges.
int RenderOverlay(vtkViewport *viewport) override
Standard render methods for different types of geometry.
int RenderTranslucentPolygonalGeometry(vtkViewport *viewport) override
Standard render methods for different types of geometry.
const std::string & GetTitle(int axis)
Set titles for each of the axes.
void SetGenerateTicks(bool val)
Turn off to not generate the markers for the tick positions.
void SetTitle(int axis, const std::string &title)
Set titles for each of the axes.
void UpdateTextProperties(vtkViewport *viewport)
~vtkGridAxesActor2D() override
bool Update(vtkViewport *viewport)
int GetPrecision(int axis)
Get/set the numerical precision to use, default is 2.
void UpdateGeometry(vtkViewport *viewport, bool doRegularUpdate)
Updates the billboard geometry without performing any rendering, to assist GetActors().
void SetGenerateEdges(bool val)
Turn off to not generate the polydata for the plane's edges.
actor for a cube-axes like prop in the 3D view.
a simple class to control print indentation
Definition vtkIndent.h:108
Allocate and hold a VTK object.
Definition vtkNew.h:167
represents an 3D object for placement in a rendered scene
Definition vtkProp3D.h:89
double Bounds[6]
Definition vtkProp3D.h:449
an ordered list of Props
represent surface properties of a geometric object
Hold a reference to a vtkObjectBase instance.
represent text properties.
record modification and/or execution time
templated base type for containers of constant size.
Definition vtkTuple.h:30
abstract specification for Viewports
Definition vtkViewport.h:66
window superclass for vtkRenderWindow
Definition vtkWindow.h:48
int vtkTypeBool
Definition vtkABI.h:64
vtkTypeUInt32 vtkMTimeType
Definition vtkType.h:287