VTK  9.7.1
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 
37 VTK_ABI_NAMESPACE_BEGIN
38 class vtkAxis;
39 class vtkContextScene;
40 class vtkDoubleArray;
41 class vtkProperty;
42 class vtkTextProperty;
43 
44 class VTKRENDERINGGRIDAXES_EXPORT VTK_MARSHALAUTO vtkGridAxesActor2D : public vtkProp3D
45 {
46 public:
47  static vtkGridAxesActor2D* New();
48  vtkTypeMacro(vtkGridAxesActor2D, vtkProp3D);
49  void PrintSelf(ostream& os, vtkIndent indent) override;
50 
52 
57  vtkSetVector6Macro(GridBounds, double);
58  vtkGetVector6Macro(GridBounds, double);
60 
62 
67  vtkSetClampMacro(Face, int, vtkGridAxesHelper::MIN_YZ, vtkGridAxesHelper::MAX_XY);
68  vtkGetMacro(Face, int);
70 
72 
80  vtkSetMacro(LabelMask, unsigned int);
81  vtkGetMacro(LabelMask, unsigned int);
83 
92  void GetActors(vtkPropCollection*) override;
93 
98  void UpdateGeometry(vtkViewport* viewport, bool doRegularUpdate);
99 
101 
105  void SetProperty(vtkProperty*);
106  vtkProperty* GetProperty();
108 
110 
114  void SetTitleTextProperty(int axis, vtkTextProperty*);
115  vtkTextProperty* GetTitleTextProperty(int axis);
117 
119 
123  void SetLabelTextProperty(int axis, vtkTextProperty*);
124  vtkTextProperty* GetLabelTextProperty(int axis);
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 
244  int RenderOpaqueGeometry(vtkViewport*) override;
245  int RenderTranslucentPolygonalGeometry(vtkViewport* viewport) override;
246  int RenderOverlay(vtkViewport* viewport) override;
249 
255  void ReleaseGraphicsResources(vtkWindow*) override;
256 
260  vtkMTimeType GetMTime() override;
261 
263 
273  vtkSetVector2Macro(LabelDisplayOffset, int);
274  vtkGetVector2Macro(LabelDisplayOffset, int);
276 
277 protected:
279  ~vtkGridAxesActor2D() override;
280 
281  bool Update(vtkViewport* viewport);
282  void UpdateTextProperties(vtkViewport* viewport);
283  void UpdateLabelPositions(vtkViewport* viewport);
284  void UpdateTextActors(vtkViewport* viewport);
285  friend class vtkGridAxesActor3D;
286 
287 private:
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 
316 VTK_ABI_NAMESPACE_END
317 #endif
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
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
record modification and/or execution time
Definition: vtkTimeStamp.h:24
represents an 3D object for placement in a rendered scene
Definition: vtkProp3D.h:39
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.
dynamic, self-adjusting array of double
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
window superclass for vtkRenderWindow
Definition: vtkWindow.h:41
actor for a cube-axes like prop in the 3D view.
templated base type for containers of constant size.
Definition: vtkTuple.h:29
takes care of drawing 2D axes
Definition: vtkAxis.h:61
Provides a 2D scene for vtkContextItem objects.
a simple class to control print indentation
Definition: vtkIndent.h:28
void SetGenerateEdges(bool val)
Turn off to not generate the polydata for the plane's edges.
double Bounds[6]
Definition: vtkProp3D.h:400
bool GetGenerateTicks()
Turn off to not generate the markers for the tick positions.
void SetGenerateGrid(bool val)
Turn off to not generate polydata for the plane's grid.
void SetGenerateTicks(bool val)
Turn off to not generate the markers for the tick positions.
represent text properties.
double * GetBounds() override
Returns the prop bounds.
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
#define VTK_MARSHALAUTO
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on...
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
vtkMTimeType GetMTime() override
Get the vtkProp3D's mtime.
actor for an axes plane in a 3D view.