VTK  9.5.20250902
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#include "vtkWrappingHints.h"
34
35#include <functional> // for std::function
36
37VTK_ABI_NAMESPACE_BEGIN
38class vtkAxis;
39class vtkContextScene;
40class vtkDoubleArray;
41class vtkProperty;
42class vtkTextProperty;
43
44class VTKRENDERINGGRIDAXES_EXPORT VTK_MARSHALAUTO vtkGridAxesActor2D : public vtkProp3D
45{
46public:
49 void PrintSelf(ostream& os, vtkIndent indent) override;
50
52
57 vtkSetVector6Macro(GridBounds, double);
58 vtkGetVector6Macro(GridBounds, double);
60
62
68 vtkGetMacro(Face, int);
70
72
80 vtkSetMacro(LabelMask, unsigned int);
81 vtkGetMacro(LabelMask, unsigned int);
83
93
98 void UpdateGeometry(vtkViewport* viewport, bool doRegularUpdate);
99
101
108
110
117
119
126
128
133 void SetTitle(int axis, const std::string& title);
134 const std::string& GetTitle(int axis);
136
138
144 void SetNotation(int axis, int notation);
145 int GetNotation(int axis);
147
149
152 void SetPrecision(int axis, int val);
153 int GetPrecision(int axis);
155
157
163 void SetTickLabelFunction(int axis, std::function<double(double)> func);
164 std::function<double(double)> GetTickLabelFunction(int axis);
166
174 void SetCustomTickPositions(int axis, vtkDoubleArray* positions);
175
176 //---------------------------------------------------------------------------
177 // *** Properties to control grid rendering ***
178 //---------------------------------------------------------------------------
179
181
186 void SetGenerateGrid(bool val) { this->PlaneActor->SetGenerateGrid(val); }
187 bool GetGenerateGrid() { return this->PlaneActor->GetGenerateGrid(); }
188 vtkBooleanMacro(GenerateGrid, bool);
190
192
197 void SetGenerateEdges(bool val) { this->PlaneActor->SetGenerateEdges(val); }
198 bool GetGenerateEdges() { return this->PlaneActor->GetGenerateEdges(); }
199 vtkBooleanMacro(GenerateEdges, bool);
201
203
209 void SetGenerateTicks(bool val) { this->PlaneActor->SetGenerateTicks(val); }
210 bool GetGenerateTicks() { return this->PlaneActor->GetGenerateTicks(); }
211 vtkBooleanMacro(GenerateTicks, bool);
213
214 //--------------------------------------------------------------------------
215 // Methods for vtkProp3D API.
216 //--------------------------------------------------------------------------
217
219
222 double* GetBounds() override
223 {
224 this->GetGridBounds(this->Bounds);
225 return this->Bounds;
226 }
228
230
235 vtkSetMacro(ForceOpaque, bool);
236 vtkGetMacro(ForceOpaque, bool);
237 vtkBooleanMacro(ForceOpaque, bool);
239
241
246 int RenderOverlay(vtkViewport* viewport) override;
249
256
261
263
273 vtkSetVector2Macro(LabelDisplayOffset, int);
274 vtkGetVector2Macro(LabelDisplayOffset, int);
276
277protected:
280
281 bool Update(vtkViewport* viewport);
285 friend class vtkGridAxesActor3D;
286
287private:
288 vtkGridAxesActor2D(const vtkGridAxesActor2D&) = delete;
289 void operator=(const vtkGridAxesActor2D&) = delete;
290
291 class vtkLabels;
292 vtkLabels* Labels;
293 friend class vtkLabels;
294
295 bool DoRender;
296
297 double GridBounds[6];
298 int Face = vtkGridAxesHelper::MIN_YZ;
299 unsigned int LabelMask = 0xff;
300
301 vtkTuple<vtkSmartPointer<vtkTextProperty>, 3> TitleTextProperty;
302 vtkTuple<vtkSmartPointer<vtkTextProperty>, 3> LabelTextProperty;
304
307 vtkNew<vtkAxis> AxisHelpers[3];
308 vtkNew<vtkContextScene> AxisHelperScene;
309 vtkTimeStamp UpdateLabelTextPropertiesMTime;
310 int LabelDisplayOffset[2] = { 0, 0 };
311
312 bool ForceOpaque = false;
313 std::function<double(double)> TickLabelFunction[3] = { nullptr, nullptr, nullptr };
314};
315
316VTK_ABI_NAMESPACE_END
317#endif
takes care of drawing 2D axes
Definition vtkAxis.h:172
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
#define VTK_MARSHALAUTO