vtkGridAxes2DActor.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
20 #ifndef vtkGridAxes2DActor_h
21 #define vtkGridAxes2DActor_h
22 
23 #include "vtkProp3D.h"
24 #include "vtkRemotingViewsModule.h" //needed for exports
25 
26 #include "vtkGridAxesHelper.h" // needed of Helper
27 #include "vtkGridAxesPlane2DActor.h" // needed for inline methods
28 #include "vtkNew.h" // needed for vtkNew.
29 #include "vtkSmartPointer.h" // needed for vtkSmartPointer.
30 
31 #include <functional> // for std::function
32 
33 class vtkAxis;
34 class vtkContextScene;
35 class vtkDoubleArray;
36 class vtkProperty;
37 class vtkTextProperty;
38 
40 {
41 public:
42  static vtkGridAxes2DActor* New();
43  vtkTypeMacro(vtkGridAxes2DActor, vtkProp3D);
44  void PrintSelf(ostream& os, vtkIndent indent) override;
45 
47 
52  vtkSetVector6Macro(GridBounds, double);
53  vtkGetVector6Macro(GridBounds, double);
55 
56  // These are in the same order as the faces of a vtkVoxel.
57  enum Faces
58  {
65  };
66 
68 
71  vtkSetClampMacro(Face, int, MIN_YZ, MAX_XY);
72  vtkGetMacro(Face, int);
74 
79  {
86  };
87 
89 
95  vtkSetMacro(LabelMask, unsigned int);
96  vtkGetMacro(LabelMask, unsigned int);
98 
107  void GetActors(vtkPropCollection*) override;
108 
113  void UpdateGeometry(vtkViewport* viewport, bool doRegularUpdate);
114 
116 
120  void SetProperty(vtkProperty*);
121  vtkProperty* GetProperty();
123 
125 
129  void SetTitleTextProperty(int axis, vtkTextProperty*);
130  vtkTextProperty* GetTitleTextProperty(int axis);
132 
134 
138  void SetLabelTextProperty(int axis, vtkTextProperty*);
139  vtkTextProperty* GetLabelTextProperty(int axis);
141 
143 
146  void SetTitle(int axis, const std::string& title);
147  const std::string& GetTitle(int axis);
149 
151 
155  void SetNotation(int axis, int notation);
156  int GetNotation(int axis);
158 
160 
163  void SetPrecision(int axis, int val);
164  int GetPrecision(int axis);
166 
168 
174  void SetTickLabelFunction(int axis, std::function<double(double)> func);
175  std::function<double(double)> GetTickLabelFunction(int axis);
177 
183  void SetCustomTickPositions(int axis, vtkDoubleArray* positions);
184 
185  //---------------------------------------------------------------------------
186  // *** Properties to control grid rendering ***
187  //---------------------------------------------------------------------------
188 
190 
193  void SetGenerateGrid(bool val) { this->PlaneActor->SetGenerateGrid(val); }
194  bool GetGenerateGrid() { return this->PlaneActor->GetGenerateGrid(); }
195  vtkBooleanMacro(GenerateGrid, bool);
197 
199 
202  void SetGenerateEdges(bool val) { this->PlaneActor->SetGenerateEdges(val); }
203  bool GetGenerateEdges() { return this->PlaneActor->GetGenerateEdges(); }
204  vtkBooleanMacro(GenerateEdges, bool);
206 
208 
212  void SetGenerateTicks(bool val) { this->PlaneActor->SetGenerateTicks(val); }
213  bool GetGenerateTicks() { return this->PlaneActor->GetGenerateTicks(); }
214  vtkBooleanMacro(GenerateTicks, bool);
216 
217  //--------------------------------------------------------------------------
218  // Methods for vtkProp3D API.
219  //--------------------------------------------------------------------------
220 
222 
225  double* GetBounds() override
226  {
227  this->GetGridBounds(this->Bounds);
228  return this->Bounds;
229  }
231 
233 
236  vtkSetMacro(ForceOpaque, bool);
237  vtkGetMacro(ForceOpaque, bool);
238  vtkBooleanMacro(ForceOpaque, bool);
240 
241  int RenderOpaqueGeometry(vtkViewport*) override;
242  int RenderTranslucentPolygonalGeometry(vtkViewport* viewport) override;
243  int RenderOverlay(vtkViewport* viewport) override;
244  int HasTranslucentPolygonalGeometry() override;
245  void ReleaseGraphicsResources(vtkWindow*) override;
246 
250  vtkMTimeType GetMTime() override;
251 
252 protected:
254  ~vtkGridAxes2DActor() override;
255 
256  bool Update(vtkViewport* viewport);
257  void UpdateTextProperties(vtkViewport* viewport);
258  void UpdateLabelPositions(vtkViewport* viewport);
259  void UpdateTextActors(vtkViewport* viewport);
260  friend class vtkGridAxes3DActor;
261 
262  double GridBounds[6];
263  int Face;
264  unsigned int LabelMask;
265 
269 
272  vtkNew<vtkAxis> AxisHelpers[3];
275 
277  std::function<double(double)> TickLabelFunction[3] = { nullptr, nullptr, nullptr };
278 
279 private:
280  vtkGridAxes2DActor(const vtkGridAxes2DActor&) = delete;
281  void operator=(const vtkGridAxes2DActor&) = delete;
282 
283  class vtkLabels;
284  vtkLabels* Labels;
285  friend class vtkLabels;
286 
287  bool DoRender;
288 };
289 
290 #endif
bool GetGenerateTicks()
Turn off to not generate the markers for the tick positions.
vtkTimeStamp UpdateLabelTextPropertiesMTime
bool GetGenerateGrid()
Turn off to not generate polydata for the plane&#39;s grid.
vtkNew< vtkGridAxesHelper > Helper
vtkTuple< vtkSmartPointer< vtkTextProperty >, 3 > TitleTextProperty
#define VTKREMOTINGVIEWS_EXPORT
bool GetGenerateEdges()
Turn off to not generate the polydata for the plane&#39;s edges.
virtual int RenderOpaqueGeometry(vtkViewport *)
vtkTuple< std::string, 3 > Titles
virtual int HasTranslucentPolygonalGeometry()
virtual int RenderOverlay(vtkViewport *)
vtkSmartPointer< vtkGridAxesPlane2DActor > PlaneActor
virtual void Update()
vtkTuple< vtkSmartPointer< vtkTextProperty >, 3 > LabelTextProperty
vtkTypeUInt64 vtkMTimeType
void SetGenerateGrid(bool val)
Turn off to not generate polydata for the plane&#39;s grid.
virtual void ReleaseGraphicsResources(vtkWindow *)
void PrintSelf(ostream &os, vtkIndent indent)
double Bounds[6]
actor for a cube-axes like prop in the 3D view.
void SetGenerateTicks(bool val)
Turn off to not generate the markers for the tick positions.
LabelMasks
Valid values for LabelMask.
void SetGenerateEdges(bool val)
Turn off to not generate the polydata for the plane&#39;s edges.
vtkMTimeType GetMTime()
double * GetBounds() override
Returns the prop bounds.
virtual int RenderTranslucentPolygonalGeometry(vtkViewport *)
actor for an axes plane in a 3D view.
vtkNew< vtkContextScene > AxisHelperScene
static vtkObject * New()
void operator=(const vtkObjectBase &)
virtual void GetActors(vtkPropCollection *)