VTK  9.7.1
vtkGridAxesActor3D.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
17 #ifndef vtkGridAxesActor3D_h
18 #define vtkGridAxesActor3D_h
19 
20 #include "vtkProp3D.h"
21 #include "vtkRenderingGridAxesModule.h" //needed for exports
22 
23 #include "vtkGridAxesHelper.h" // needed for vtkGridAxesHelper.
24 #include "vtkNew.h" // needed for vtkNew.
25 #include "vtkWrappingHints.h"
26 
27 #include <functional> // for std::function
28 
29 VTK_ABI_NAMESPACE_BEGIN
30 class vtkDoubleArray;
31 class vtkGridAxesActor2D;
32 class vtkProperty;
33 class vtkTextProperty;
34 
35 class VTKRENDERINGGRIDAXES_EXPORT VTK_MARSHALAUTO vtkGridAxesActor3D : public vtkProp3D
36 {
37 public:
38  static vtkGridAxesActor3D* New();
39  vtkTypeMacro(vtkGridAxesActor3D, vtkProp3D);
40  void PrintSelf(ostream& os, vtkIndent indent) override;
41 
45  void ShallowCopy(vtkProp* prop) override;
46 
48 
53  vtkSetVector6Macro(GridBounds, double);
54  vtkGetVector6Macro(GridBounds, double);
56 
58 
65  virtual void SetFaceMask(unsigned int mask);
66  vtkGetMacro(FaceMask, unsigned int);
68 
70 
75  virtual void SetLabelMask(unsigned int mask);
76  unsigned int GetLabelMask();
78 
87  void GetActors(vtkPropCollection*) override;
88 
93  void UpdateGeometry(vtkViewport* vp);
94 
96 
102  vtkSetMacro(LabelUniqueEdgesOnly, bool);
103  vtkGetMacro(LabelUniqueEdgesOnly, bool);
105 
107 
112  void SetGenerateGrid(bool val);
113  bool GetGenerateGrid();
114  vtkBooleanMacro(GenerateGrid, bool);
116 
118 
124  void SetGenerateEdges(bool val);
125  bool GetGenerateEdges();
126  vtkBooleanMacro(GenerateEdges, bool);
128 
130 
136  void SetGenerateTicks(bool val);
137  bool GetGenerateTicks();
138  vtkBooleanMacro(GenerateTicks, bool);
140 
142 
145  void SetProperty(vtkProperty*);
146  vtkProperty* GetProperty();
148 
149  //---------------------------------------------------------------------------
150  // *** Properties to control the axis titles ***
151 
153 
157  void SetTitleTextProperty(int axis, vtkTextProperty*);
158  void SetXTitleTextProperty(vtkTextProperty* prop) { this->SetTitleTextProperty(0, prop); }
159  void SetYTitleTextProperty(vtkTextProperty* prop) { this->SetTitleTextProperty(1, prop); }
160  void SetZTitleTextProperty(vtkTextProperty* prop) { this->SetTitleTextProperty(2, prop); }
161  vtkTextProperty* GetTitleTextProperty(int axis);
162  vtkTextProperty* GetXTitleTextProperty() { return this->GetTitleTextProperty(0); }
163  vtkTextProperty* GetYTitleTextProperty() { return this->GetTitleTextProperty(1); }
164  vtkTextProperty* GetZTitleTextProperty() { return this->GetTitleTextProperty(2); }
166 
168 
174  void SetTitle(int axis, const std::string& title);
175  void SetXTitle(const std::string& title) { this->SetTitle(0, title); }
176  void SetYTitle(const std::string& title) { this->SetTitle(1, title); }
177  void SetZTitle(const std::string& title) { this->SetTitle(2, title); }
178  const std::string& GetTitle(int axis);
179  const std::string& GetXTitle() { return this->GetTitle(0); }
180  const std::string& GetYTitle() { return this->GetTitle(1); }
181  const std::string& GetZTitle() { return this->GetTitle(2); }
183 
185 
191  void SetUseCustomLabels(int axis, bool val);
192  void SetXUseCustomLabels(bool val) { this->SetUseCustomLabels(0, val); }
193  void SetYUseCustomLabels(bool val) { this->SetUseCustomLabels(1, val); }
194  void SetZUseCustomLabels(bool val) { this->SetUseCustomLabels(2, val); }
195  bool GetUseCustomLabels(int axis);
196  bool GetXUseCustomLabels() { return this->GetUseCustomLabels(0); }
197  bool GetYUseCustomLabels() { return this->GetUseCustomLabels(1); }
198  bool GetZUseCustomLabels() { return this->GetUseCustomLabels(2); }
199 
200  void SetNumberOfLabels(int axis, vtkIdType val);
201  void SetNumberOfXLabels(vtkIdType val) { this->SetNumberOfLabels(0, val); }
202  void SetNumberOfYLabels(vtkIdType val) { this->SetNumberOfLabels(1, val); }
203  void SetNumberOfZLabels(vtkIdType val) { this->SetNumberOfLabels(2, val); }
204  vtkIdType GetNumberOfLabels(int axis);
205  vtkIdType GetNumberOfXLabels() { return this->GetNumberOfLabels(0); }
206  vtkIdType GetNumberOfYLabels() { return this->GetNumberOfLabels(1); }
207  vtkIdType GetNumberOfZLabels() { return this->GetNumberOfLabels(2); }
208 
209  void SetLabel(int axis, vtkIdType index, double value);
210  void SetXLabel(vtkIdType index, double value) { this->SetLabel(0, index, value); }
211  void SetYLabel(vtkIdType index, double value) { this->SetLabel(1, index, value); }
212  void SetZLabel(vtkIdType index, double value) { this->SetLabel(2, index, value); }
213  double GetLabel(int axis, vtkIdType index);
214  double GetXLabel(vtkIdType index) { return this->GetLabel(0, index); }
215  double GetYLabel(vtkIdType index) { return this->GetLabel(1, index); }
216  double GetZLabel(vtkIdType index) { return this->GetLabel(2, index); }
218 
219  //---------------------------------------------------------------------------
220  // *** Properties to control the axis data labels ***
221 
223 
227  void SetLabelTextProperty(int axis, vtkTextProperty*);
228  void SetXLabelTextProperty(vtkTextProperty* prop) { this->SetLabelTextProperty(0, prop); }
229  void SetYLabelTextProperty(vtkTextProperty* prop) { this->SetLabelTextProperty(1, prop); }
230  void SetZLabelTextProperty(vtkTextProperty* prop) { this->SetLabelTextProperty(2, prop); }
231  vtkTextProperty* GetLabelTextProperty(int axis);
232  vtkTextProperty* GetXLabelTextProperty() { return this->GetLabelTextProperty(0); }
233  vtkTextProperty* GetYLabelTextProperty() { return this->GetLabelTextProperty(1); }
234  vtkTextProperty* GetZLabelTextProperty() { return this->GetLabelTextProperty(2); }
236 
238 
244  void SetNotation(int axis, int notation);
245  void SetXNotation(int notation) { this->SetNotation(0, notation); }
246  void SetYNotation(int notation) { this->SetNotation(1, notation); }
247  void SetZNotation(int notation) { this->SetNotation(2, notation); }
248  int GetNotation(int axis);
249  int GetXNotation() { return this->GetNotation(0); }
250  int GetYNotation() { return this->GetNotation(1); }
251  int GetZNotation() { return this->GetNotation(2); }
253 
255 
258  void SetPrecision(int axis, int val);
259  void SetXPrecision(int val) { this->SetPrecision(0, val); }
260  void SetYPrecision(int val) { this->SetPrecision(1, val); }
261  void SetZPrecision(int val) { this->SetPrecision(2, val); }
262  int GetPrecision(int axis);
263  int GetXPrecision() { return this->GetPrecision(0); }
264  int GetYPrecision() { return this->GetPrecision(1); }
265  int GetZPrecision() { return this->GetPrecision(2); }
267 
269 
275  void SetTickLabelFunction(int axis, std::function<double(double)> func);
276  std::function<double(double)> GetTickLabelFunction(int axis);
278 
279  //--------------------------------------------------------------------------
280  // Methods for vtkProp3D API.
281  //--------------------------------------------------------------------------
282 
284 
287  double* GetBounds() override;
288  using Superclass::GetBounds;
290 
295  virtual void GetRenderedBounds(double bounds[6]);
296 
298 
303  vtkSetMacro(ForceOpaque, bool);
304  vtkGetMacro(ForceOpaque, bool);
305  vtkBooleanMacro(ForceOpaque, bool);
307 
309 
312  int RenderOpaqueGeometry(vtkViewport*) override;
313  int RenderTranslucentPolygonalGeometry(vtkViewport* viewport) override;
314  int RenderOverlay(vtkViewport* viewport) override;
317 
323  void ReleaseGraphicsResources(vtkWindow*) override;
324 
326 
333  virtual void SetLabelDisplayOffset(int xoffset, int yoffset);
334  virtual void SetLabelDisplayOffset(const int offset[2]);
335  virtual int* GetLabelDisplayOffset() VTK_SIZEHINT(2);
336  VTK_WRAPEXCLUDE virtual void GetLabelDisplayOffset(int& xoffset, int& yoffset);
337  VTK_WRAPEXCLUDE virtual void GetLabelDisplayOffset(int offset[2]);
339 
340 protected:
342  ~vtkGridAxesActor3D() override;
343 
344  virtual void Update(vtkViewport* viewport);
345 
346 private:
347  vtkGridAxesActor3D(const vtkGridAxesActor3D&) = delete;
348  void operator=(const vtkGridAxesActor3D&) = delete;
349 
350  vtkMTimeType GetBoundsMTime = 0;
351  double GridBounds[6] = { -1.0, 1.0, -1.0, 1.0, -1.0, 1.0 };
352  unsigned int FaceMask = 0;
353  bool LabelUniqueEdgesOnly = true;
354  vtkTuple<bool, 3> UseCustomLabels;
355  vtkTuple<vtkNew<vtkDoubleArray>, 3> CustomLabels;
356  vtkMTimeType CustomLabelsMTime = 0;
357 
358  vtkTuple<vtkNew<vtkGridAxesActor2D>, 6> GridAxes2DActors;
359 
360  bool ForceOpaque = false;
361 };
362 
363 VTK_ABI_NAMESPACE_END
364 #endif
void SetYPrecision(int val)
Get/set the numerical precision to use, default is 2.
vtkIdType GetNumberOfXLabels()
Set whether the specified axis should use custom labels instead of automatically determined ones...
void SetXLabelTextProperty(vtkTextProperty *prop)
Get/Set the vtkTextProperty that governs how the axis labels are displayed.
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:49
vtkIdType GetNumberOfZLabels()
Set whether the specified axis should use custom labels instead of automatically determined ones...
vtkIdType GetNumberOfYLabels()
Set whether the specified axis should use custom labels instead of automatically determined ones...
vtkTextProperty * GetYTitleTextProperty()
Get/Set the vtkTextProperty for the title for each the axes.
const std::string & GetXTitle()
Get/Set the text to use for titles for the axis.
vtkTextProperty * GetZTitleTextProperty()
Get/Set the vtkTextProperty for the title for each the axes.
int GetXPrecision()
Get/set the numerical precision to use, default is 2.
void SetXNotation(int notation)
Get/set the numerical notation, standard, scientific or mixed (0, 1, 2).
double * GetBounds() override=0
Return a reference to the Prop3D's composite transform.
vtkTypeUInt32 vtkMTimeType
Definition: vtkType.h:318
abstract specification for Viewports
Definition: vtkViewport.h:46
represent surface properties of a geometric object
Definition: vtkProperty.h:59
void SetZTitle(const std::string &title)
Get/Set the text to use for titles for the axis.
virtual int RenderOpaqueGeometry(vtkViewport *)
WARNING: INTERNAL METHOD - NOT INTENDED FOR GENERAL USE DO NOT USE THESE METHODS OUTSIDE OF THE RENDE...
Definition: vtkProp.h:236
virtual vtkTypeBool HasTranslucentPolygonalGeometry()
WARNING: INTERNAL METHOD - NOT INTENDED FOR GENERAL USE DO NOT USE THESE METHODS OUTSIDE OF THE RENDE...
Definition: vtkProp.h:300
virtual int RenderOverlay(vtkViewport *)
Definition: vtkProp.h:239
int GetZNotation()
Get/set the numerical notation, standard, scientific or mixed (0, 1, 2).
void SetZTitleTextProperty(vtkTextProperty *prop)
Get/Set the vtkTextProperty for the title for each the axes.
represents an 3D object for placement in a rendered scene
Definition: vtkProp3D.h:39
int vtkIdType
Definition: vtkType.h:363
bool GetXUseCustomLabels()
Set whether the specified axis should use custom labels instead of automatically determined ones...
int GetXNotation()
Get/set the numerical notation, standard, scientific or mixed (0, 1, 2).
bool GetYUseCustomLabels()
Set whether the specified axis should use custom labels instead of automatically determined ones...
void SetNumberOfYLabels(vtkIdType val)
Set whether the specified axis should use custom labels instead of automatically determined ones...
dynamic, self-adjusting array of double
void SetXLabel(vtkIdType index, double value)
Set whether the specified axis should use custom labels instead of automatically determined ones...
an ordered list of Props
int vtkTypeBool
Definition: vtkABI.h:64
virtual void ReleaseGraphicsResources(vtkWindow *)
WARNING: INTERNAL METHOD - NOT INTENDED FOR GENERAL USE Release any graphics resources that are being...
Definition: vtkProp.h:321
virtual double * GetBounds()
Get the bounds for this Prop as (Xmin,Xmax,Ymin,Ymax,Zmin,Zmax).
Definition: vtkProp.h:128
window superclass for vtkRenderWindow
Definition: vtkWindow.h:41
double GetYLabel(vtkIdType index)
Set whether the specified axis should use custom labels instead of automatically determined ones...
int GetYPrecision()
Get/set the numerical precision to use, default is 2.
actor for a cube-axes like prop in the 3D view.
void SetZNotation(int notation)
Get/set the numerical notation, standard, scientific or mixed (0, 1, 2).
vtkTextProperty * GetYLabelTextProperty()
Get/Set the vtkTextProperty that governs how the axis labels are displayed.
a simple class to control print indentation
Definition: vtkIndent.h:28
int GetYNotation()
Get/set the numerical notation, standard, scientific or mixed (0, 1, 2).
vtkTextProperty * GetXLabelTextProperty()
Get/Set the vtkTextProperty that governs how the axis labels are displayed.
void SetNumberOfXLabels(vtkIdType val)
Set whether the specified axis should use custom labels instead of automatically determined ones...
void SetYLabel(vtkIdType index, double value)
Set whether the specified axis should use custom labels instead of automatically determined ones...
void ShallowCopy(vtkProp *prop) override
Shallow copy of this vtkProp3D.
void SetZPrecision(int val)
Get/set the numerical precision to use, default is 2.
void SetXTitle(const std::string &title)
Get/Set the text to use for titles for the axis.
vtkTextProperty * GetXTitleTextProperty()
Get/Set the vtkTextProperty for the title for each the axes.
double GetXLabel(vtkIdType index)
Set whether the specified axis should use custom labels instead of automatically determined ones...
const std::string & GetYTitle()
Get/Set the text to use for titles for the axis.
const std::string & GetZTitle()
Get/Set the text to use for titles for the axis.
void SetZLabelTextProperty(vtkTextProperty *prop)
Get/Set the vtkTextProperty that governs how the axis labels are displayed.
#define VTK_SIZEHINT(...)
represent text properties.
void SetYTitle(const std::string &title)
Get/Set the text to use for titles for the axis.
void SetYUseCustomLabels(bool val)
Set whether the specified axis should use custom labels instead of automatically determined ones...
void SetNumberOfZLabels(vtkIdType val)
Set whether the specified axis should use custom labels instead of automatically determined ones...
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
virtual int RenderTranslucentPolygonalGeometry(vtkViewport *)
Definition: vtkProp.h:237
void SetXTitleTextProperty(vtkTextProperty *prop)
Get/Set the vtkTextProperty for the title for each the axes.
vtkTextProperty * GetZLabelTextProperty()
Get/Set the vtkTextProperty that governs how the axis labels are displayed.
#define VTK_MARSHALAUTO
void SetYNotation(int notation)
Get/set the numerical notation, standard, scientific or mixed (0, 1, 2).
void SetZUseCustomLabels(bool val)
Set whether the specified axis should use custom labels instead of automatically determined ones...
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on...
int GetZPrecision()
Get/set the numerical precision to use, default is 2.
void SetXUseCustomLabels(bool val)
Set whether the specified axis should use custom labels instead of automatically determined ones...
void SetYLabelTextProperty(vtkTextProperty *prop)
Get/Set the vtkTextProperty that governs how the axis labels are displayed.
void SetYTitleTextProperty(vtkTextProperty *prop)
Get/Set the vtkTextProperty for the title for each the axes.
#define VTK_WRAPEXCLUDE
virtual void GetActors(vtkPropCollection *)
For some exporters and other other operations we must be able to collect all the actors or volumes...
Definition: vtkProp.h:60
void SetXPrecision(int val)
Get/set the numerical precision to use, default is 2.
bool GetZUseCustomLabels()
Set whether the specified axis should use custom labels instead of automatically determined ones...
void SetZLabel(vtkIdType index, double value)
Set whether the specified axis should use custom labels instead of automatically determined ones...
double GetZLabel(vtkIdType index)
Set whether the specified axis should use custom labels instead of automatically determined ones...
actor for an axes plane in a 3D view.