ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
vtkContext2DScalarBarActor.h
Go to the documentation of this file.
1 // ----------------------------------------------------------------------------
2 // - CloudViewer: www.cloudViewer.org -
3 // ----------------------------------------------------------------------------
4 // Copyright (c) 2018-2024 www.cloudViewer.org
5 // SPDX-License-Identifier: MIT
6 // ----------------------------------------------------------------------------
7 
8 #pragma once
9 
10 #include "qPCL.h"
11 #include "vtkCoordinate.h" // for Position and Position 2
12 #include "vtkRect.h" // for functions that return vtkRects
13 #include "vtkScalarBarActor.h"
14 #include "vtkSmartPointer.h" // for smart pointers
15 
16 class vtkAxis;
17 class vtkColorLegend;
18 class vtkColorTransferFunctionItem;
19 class vtkContextActor;
20 class vtkContext2D;
21 class vtkContextItem;
22 class vtkContextScene;
23 class vtkDoubleArray;
24 class vtkImageData;
25 class vtkPoints2D;
26 class vtkScalarsToColors;
27 class vtkScalarBarItem;
28 class vtkTextProperty;
29 class vtkViewport;
30 
32  : public vtkScalarBarActor {
33 public:
35  void PrintSelf(ostream& os, vtkIndent indent) override;
37 
39 
43  vtkGetMacro(TitleJustification, int);
44  vtkSetClampMacro(TitleJustification, int, VTK_TEXT_LEFT, VTK_TEXT_RIGHT);
46 
48 
52  vtkSetMacro(ForceHorizontalTitle, bool);
53  vtkGetMacro(ForceHorizontalTitle, bool);
54  vtkBooleanMacro(ForceHorizontalTitle, bool);
56 
57  enum { PrecedeScalarBar = 0, SucceedScalarBar };
58 
60  BELOW_RANGE = 0,
61  ABOVE_RANGE = 1,
62  };
63 
65 
71  vtkSetClampMacro(ScalarBarThickness, int, 0, VTK_INT_MAX);
72  vtkGetMacro(ScalarBarThickness, int);
74 
76 
84  vtkSetClampMacro(ScalarBarLength, double, 0, 1);
85  vtkGetMacro(ScalarBarLength, double);
87 
89 
93  vtkSetMacro(ReverseLegend, bool);
94  vtkGetMacro(ReverseLegend, bool);
95  vtkBooleanMacro(ReverseLegend, bool);
97 
99 
104  vtkGetMacro(AutomaticLabelFormat, int);
105  vtkSetMacro(AutomaticLabelFormat, int);
106  vtkBooleanMacro(AutomaticLabelFormat, int);
108 
110 
114  vtkSetMacro(AddRangeLabels, int);
115  vtkGetMacro(AddRangeLabels, int);
117 
119 
123  vtkSetMacro(AutomaticAnnotations, int);
124  vtkGetMacro(AutomaticAnnotations, int);
125  vtkBooleanMacro(AutomaticAnnotations, int);
127 
129 
133  vtkGetMacro(AddRangeAnnotations, int);
134  vtkSetMacro(AddRangeAnnotations, int);
135  vtkBooleanMacro(AddRangeAnnotations, int);
137 
139 
142  vtkGetMacro(OutlineScalarBar, int);
143  vtkSetMacro(OutlineScalarBar, int);
144  vtkBooleanMacro(OutlineScalarBar, int);
146 
148 
151  vtkSetMacro(DrawTickMarks, bool);
152  vtkGetMacro(DrawTickMarks, bool);
154 
156 
159  vtkSetStringMacro(RangeLabelFormat);
160  vtkGetStringMacro(RangeLabelFormat);
162 
164 
167  void SetUseCustomLabels(bool useLabels);
168  vtkGetMacro(UseCustomLabels, bool);
170 
172 
176  vtkSetMacro(NumberOfTicks, int);
177  vtkGetMacro(NumberOfTicks, int);
178 
180 
183  void SetNumberOfCustomLabels(vtkIdType numLabels);
184  vtkIdType GetNumberOfCustomLabels();
186 
190  void SetCustomLabel(vtkIdType index, double value);
191 
195  int RenderOverlay(vtkViewport* viewport) override;
196 
200  int RenderOpaqueGeometry(vtkViewport* viewport) override;
201 
207  void ReleaseGraphicsResources(vtkWindow* window) override;
208 
212  virtual bool Paint(vtkContext2D* painter);
213 
218  vtkRectf GetBoundingRect();
219 
226  int GetEstimatedNumberOfAnnotations();
227 
228 protected:
230  ~vtkContext2DScalarBarActor() override;
231 
232 private:
234  void operator=(const vtkContext2DScalarBarActor&) = delete;
235 
236  vtkContextActor* ActorDelegate;
237 
238  int TitleJustification;
239 
244  bool ForceHorizontalTitle;
245 
249  int ScalarBarThickness;
250 
254  double ScalarBarLength;
255 
256  int NumberOfTicks;
257 
258  int AutomaticLabelFormat;
259 
260  int AddRangeLabels;
261  int AutomaticAnnotations;
262  int AddRangeAnnotations;
263  char* RangeLabelFormat;
264 
268  int OutlineScalarBar;
269 
274  double Spacer;
275 
279  bool DrawTickMarks;
280 
281  bool UseCustomLabels;
282 
286  bool ReverseLegend;
287 
291  vtkSmartPointer<vtkDoubleArray> CustomLabels;
292 
297  class vtkScalarBarItem;
298  vtkScalarBarItem* ScalarBarItem;
299 
303  vtkViewport* CurrentViewport;
304 
308  vtkAxis* Axis;
309 
314  void UpdateScalarBarTexture(vtkImageData* image);
315 
321  void GetSize(double size[2], vtkContext2D* painter);
322 
328  vtkRectf GetColorBarRect(double size[2]);
329 
334  vtkRectf GetFullColorBarRect(double size[2]);
335 
339  vtkRectf GetAboveRangeColorRect(double size[2]);
340 
344  vtkRectf GetBelowRangeColorRect(double size[2]);
345 
346  vtkRectf GetOutOfRangeColorRectInternal(
348 
352  vtkRectf GetNaNColorRect(double size[2]);
353 
357  void UpdateTextProperties();
358 
362  void PaintColorBar(vtkContext2D* painter, double size[2]);
363 
367  void PaintAxis(vtkContext2D* painter, double size[2]);
368 
372  void PaintTitle(vtkContext2D* painter, double size[2]);
373 
374  class vtkAnnotationMap;
375 
381  void PaintAnnotations(vtkContext2D* painter,
382  double size[2],
383  const vtkAnnotationMap& map);
384 
388  void PaintAnnotationsVertically(vtkContext2D* painter,
389  double size[2],
390  const vtkAnnotationMap& map);
391 
395  void PaintAnnotationsHorizontally(vtkContext2D* painter,
396  double size[2],
397  const vtkAnnotationMap& map);
398 };
std::shared_ptr< core::Tensor > image
int size
char type
vtkSetMacro(OutlineScalarBar, int)
vtkSetMacro(AutomaticLabelFormat, int)
vtkSetClampMacro(ScalarBarThickness, int, 0, VTK_INT_MAX)
static vtkContext2DScalarBarActor * New()
vtkBooleanMacro(AddRangeAnnotations, int)
vtkBooleanMacro(ReverseLegend, bool)
vtkSetClampMacro(TitleJustification, int, VTK_TEXT_LEFT, VTK_TEXT_RIGHT)
vtkGetMacro(TitleJustification, int)
vtkGetStringMacro(RangeLabelFormat)
vtkGetMacro(UseCustomLabels, bool)
vtkGetMacro(OutlineScalarBar, int)
vtkGetMacro(ReverseLegend, bool)
vtkGetMacro(AutomaticLabelFormat, int)
vtkGetMacro(ForceHorizontalTitle, bool)
vtkGetMacro(DrawTickMarks, bool)
vtkSetMacro(AddRangeAnnotations, int)
vtkSetMacro(AddRangeLabels, int)
vtkSetMacro(ForceHorizontalTitle, bool)
vtkGetMacro(ScalarBarThickness, int)
vtkGetMacro(ScalarBarLength, double)
vtkSetClampMacro(ScalarBarLength, double, 0, 1)
vtkGetMacro(AddRangeLabels, int)
vtkBooleanMacro(AutomaticAnnotations, int)
vtkSetStringMacro(RangeLabelFormat)
vtkGetMacro(AddRangeAnnotations, int)
vtkSetMacro(DrawTickMarks, bool)
vtkGetMacro(AutomaticAnnotations, int)
vtkGetMacro(NumberOfTicks, int)
vtkSetMacro(NumberOfTicks, int)
vtkBooleanMacro(OutlineScalarBar, int)
vtkSetMacro(AutomaticAnnotations, int)
vtkTypeMacro(vtkContext2DScalarBarActor, vtkScalarBarActor)
vtkBooleanMacro(ForceHorizontalTitle, bool)
vtkBooleanMacro(AutomaticLabelFormat, int)
vtkSetMacro(ReverseLegend, bool)
#define QPCL_ENGINE_LIB_API
Definition: qPCL.h:15