vtkContext2DScalarBarActor.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Kitware Inc.
2 // SPDX-License-Identifier: BSD-3-Clause
14 #ifndef vtkContext2DScalarBarActor_h
15 #define vtkContext2DScalarBarActor_h
16 
17 #include "vtkRemotingViewsModule.h" // needed for export macro
18 #include "vtkScalarBarActor.h"
19 
20 #include "vtkCoordinate.h" // for Position and Position 2
21 #include "vtkRect.h" // for functions that return vtkRects
22 #include "vtkSmartPointer.h" // for smart pointers
23 
24 class vtkAxis;
25 class vtkColorLegend;
27 class vtkContextActor;
28 class vtkContext2D;
29 class vtkContextScene;
30 class vtkDoubleArray;
31 class vtkImageData;
32 class vtkPoints2D;
33 class vtkScalarsToColors;
34 class vtkTextProperty;
35 class vtkViewport;
36 
38 {
39 public:
41  void PrintSelf(ostream& os, vtkIndent indent) override;
43 
45 
49  vtkGetMacro(TitleJustification, int);
50  vtkSetClampMacro(TitleJustification, int, VTK_TEXT_LEFT, VTK_TEXT_RIGHT);
52 
54 
58  vtkSetMacro(ForceHorizontalTitle, bool);
59  vtkGetMacro(ForceHorizontalTitle, bool);
60  vtkBooleanMacro(ForceHorizontalTitle, bool);
62 
63  enum
64  {
65  PrecedeScalarBar = 0,
66  SucceedScalarBar
67  };
68 
70  {
71  BELOW_RANGE = 0,
72  ABOVE_RANGE = 1,
73  };
74 
76 
82  vtkSetClampMacro(ScalarBarThickness, int, 0, VTK_INT_MAX);
83  vtkGetMacro(ScalarBarThickness, int);
85 
87 
95  vtkSetClampMacro(ScalarBarLength, double, 0, 1);
96  vtkGetMacro(ScalarBarLength, double);
98 
100 
103  vtkSetMacro(DrawScalarBarOutline, bool);
104  vtkGetMacro(DrawScalarBarOutline, bool);
105  vtkBooleanMacro(DrawScalarBarOutline, bool);
107 
109 
112  vtkSetVector3Macro(ScalarBarOutlineColor, double);
113  vtkGetVector3Macro(ScalarBarOutlineColor, double);
115 
117 
120  vtkSetClampMacro(ScalarBarOutlineThickness, int, 0, VTK_INT_MAX);
121  vtkGetMacro(ScalarBarOutlineThickness, int);
123 
125 
129  vtkSetVector4Macro(BackgroundColor, double);
131  vtkGetVector4Macro(BackgroundColor, double);
132 
134 
138  vtkSetMacro(BackgroundPadding, double);
140  vtkGetMacro(BackgroundPadding, double);
141 
143 
147  vtkSetMacro(ReverseLegend, bool);
148  vtkGetMacro(ReverseLegend, bool);
149  vtkBooleanMacro(ReverseLegend, bool);
151 
153 
158  vtkGetMacro(AutomaticLabelFormat, int);
159  vtkSetMacro(AutomaticLabelFormat, int);
160  vtkBooleanMacro(AutomaticLabelFormat, int);
162 
164 
168  vtkSetMacro(AddRangeLabels, int);
169  vtkGetMacro(AddRangeLabels, int);
171 
173 
177  vtkSetMacro(AutomaticAnnotations, int);
178  vtkGetMacro(AutomaticAnnotations, int);
179  vtkBooleanMacro(AutomaticAnnotations, int);
181 
183 
187  vtkGetMacro(AddRangeAnnotations, int);
188  vtkSetMacro(AddRangeAnnotations, int);
189  vtkBooleanMacro(AddRangeAnnotations, int);
191 
193 
196  vtkSetMacro(DrawTickMarks, bool);
197  vtkGetMacro(DrawTickMarks, bool);
199 
201 
204  vtkSetStringMacro(RangeLabelFormat);
205  vtkGetStringMacro(RangeLabelFormat);
207 
209 
212  vtkSetStringMacro(DataRangeLabelFormat);
213  vtkGetStringMacro(DataRangeLabelFormat);
215 
217 
220  void SetNumberOfCustomLabels(vtkIdType numLabels);
221  vtkIdType GetNumberOfCustomLabels();
223 
227  void SetCustomLabel(vtkIdType index, double value);
228 
232  int RenderOverlay(vtkViewport* viewport) override;
233 
237  int RenderOpaqueGeometry(vtkViewport* viewport) override;
238 
244  void ReleaseGraphicsResources(vtkWindow* window) override;
245 
249  virtual bool Paint(vtkContext2D* painter);
250 
255  vtkRectf GetBoundingRect();
256 
263  int GetEstimatedNumberOfAnnotations();
264 
266 
270  vtkSetMacro(DrawDataRange, bool);
271  vtkGetMacro(DrawDataRange, bool);
272  vtkBooleanMacro(DrawDataRange, bool);
274 
276 
281  vtkSetMacro(DataRangeMin, double);
282  vtkGetMacro(DataRangeMin, double);
284 
286 
291  vtkSetMacro(DataRangeMax, double);
292  vtkGetMacro(DataRangeMax, double);
294 
295 protected:
297  ~vtkContext2DScalarBarActor() override;
298 
303 
305 
308  double DataRangeMin = 0;
309  double DataRangeMax = 0;
311 
315  int VerticalOffset = 0;
316 
317 private:
319  void operator=(const vtkContext2DScalarBarActor&) = delete;
320 
321  vtkContextActor* ActorDelegate;
322 
323  int TitleJustification;
324 
329  bool ForceHorizontalTitle;
330 
334  double ScalarBarOutlineColor[3];
335 
339  int ScalarBarThickness;
340 
344  double BackgroundColor[4];
345 
349  double BackgroundPadding;
350 
354  double ScalarBarLength;
355 
356  int AutomaticLabelFormat;
357 
358  int AddRangeLabels;
359  int AutomaticAnnotations;
360  int AddRangeAnnotations;
361  char* RangeLabelFormat;
362  char* DataRangeLabelFormat;
363 
367  bool DrawScalarBarOutline;
368 
372  int ScalarBarOutlineThickness;
373 
378  double Spacer;
379 
383  bool DrawTickMarks;
384 
388  bool ReverseLegend;
389 
394  class vtkScalarBarItem;
395  vtkScalarBarItem* ScalarBarItem;
396 
400  vtkViewport* CurrentViewport;
401 
405  vtkAxis* Axis;
406 
410  bool InGetBoundingRect;
411 
419  vtkRectf CurrentBoundingRect;
420 
425  void UpdateScalarBarTexture(vtkImageData* image);
426 
432  void GetSize(double size[2], vtkContext2D* painter);
433 
439  vtkRectf GetColorBarRect(double size[2], bool includeSwatch = true);
440 
445  vtkRectf GetFullColorBarRect(double size[2]);
446 
450  vtkRectf GetAboveRangeColorRect(double size[2]);
451 
455  vtkRectf GetBelowRangeColorRect(double size[2]);
456 
457  vtkRectf GetOutOfRangeColorRectInternal(
458  vtkContext2DScalarBarActor::OutOfRangeType type, double size[2]);
459 
463  vtkRectf GetNaNColorRect(double size[2]);
464 
468  void UpdateTextProperties();
469 
473  void PaintColorBar(vtkContext2D* painter, double size[2]);
474 
478  void PaintAxis(vtkContext2D* painter, double size[2]);
479 
483  void PaintTitle(vtkContext2D* painter, double size[2]);
484 
488  void PaintRange(vtkContext2D* painter, double size[2]);
489 
490  class vtkAnnotationMap;
491 
497  void PaintAnnotations(vtkContext2D* painter, double size[2], const vtkAnnotationMap& map);
498 
502  void PaintAnnotationsVertically(
503  vtkContext2D* painter, double size[2], const vtkAnnotationMap& map);
504 
508  void PaintAnnotationsHorizontally(
509  vtkContext2D* painter, double size[2], const vtkAnnotationMap& map);
510 
514  float HorizontalAnnotationHeight;
515 
519  float VerticalRangeDataHeight;
520 };
521 
522 #endif // vtkContext2DScalarBarActor_h
#define VTKREMOTINGVIEWS_EXPORT
int RenderOverlay(vtkViewport *viewport)
bool DrawDataRange
Flag to show the range on the scalar bar.
int vtkIdType
void PrintSelf(ostream &os, vtkIndent indent)
int RenderOpaqueGeometry(vtkViewport *viewport)
static vtkScalarBarActor * New()
Custom scalar bar actor for ParaView that uses the Charts API.
void operator=(const vtkObjectBase &)
virtual void ReleaseGraphicsResources(vtkWindow *)