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 
167  vtkSetMacro(VerticalLabels, bool);
168  vtkGetMacro(VerticalLabels, bool);
169  vtkBooleanMacro(VerticalLabels, bool);
171 
173 
177  vtkSetMacro(AddRangeLabels, int);
178  vtkGetMacro(AddRangeLabels, int);
180 
182 
186  vtkSetMacro(AutomaticAnnotations, int);
187  vtkGetMacro(AutomaticAnnotations, int);
188  vtkBooleanMacro(AutomaticAnnotations, int);
190 
192 
196  vtkGetMacro(AddRangeAnnotations, int);
197  vtkSetMacro(AddRangeAnnotations, int);
198  vtkBooleanMacro(AddRangeAnnotations, int);
200 
202 
205  vtkSetMacro(DrawTickMarks, bool);
206  vtkGetMacro(DrawTickMarks, bool);
208 
210 
213  vtkSetMacro(AllowOverlappingLabels, bool);
214  vtkGetMacro(AllowOverlappingLabels, bool);
215  vtkBooleanMacro(AllowOverlappingLabels, int);
217 
219 
222  virtual void SetRangeLabelFormat(const char* format);
223  vtkGetStringMacro(RangeLabelFormat);
225 
227 
230  virtual void SetDataRangeLabelFormat(const char* format);
231  vtkGetStringMacro(DataRangeLabelFormat);
233 
235 
238  void SetNumberOfCustomLabels(vtkIdType numLabels);
239  vtkIdType GetNumberOfCustomLabels();
241 
245  void SetCustomLabel(vtkIdType index, double value);
246 
250  int RenderOverlay(vtkViewport* viewport) override;
251 
255  int RenderOpaqueGeometry(vtkViewport* viewport) override;
256 
262  void ReleaseGraphicsResources(vtkWindow* window) override;
263 
267  virtual bool Paint(vtkContext2D* painter);
268 
273  vtkRectf GetBoundingRect();
274 
281  int GetEstimatedNumberOfAnnotations();
282 
284 
288  vtkSetMacro(DrawDataRange, bool);
289  vtkGetMacro(DrawDataRange, bool);
290  vtkBooleanMacro(DrawDataRange, bool);
292 
294 
299  vtkSetMacro(DataRangeMin, double);
300  vtkGetMacro(DataRangeMin, double);
302 
304 
309  vtkSetMacro(DataRangeMax, double);
310  vtkGetMacro(DataRangeMax, double);
312 
313 protected:
315  ~vtkContext2DScalarBarActor() override;
316 
321 
323 
326  double DataRangeMin = 0;
327  double DataRangeMax = 0;
329 
333  int VerticalOffset = 0;
334 
335 private:
337  void operator=(const vtkContext2DScalarBarActor&) = delete;
338 
339  vtkContextActor* ActorDelegate;
340 
341  int TitleJustification;
342 
347  bool ForceHorizontalTitle;
348 
352  double ScalarBarOutlineColor[3];
353 
357  int ScalarBarThickness;
358 
362  double BackgroundColor[4];
363 
367  double BackgroundPadding;
368 
372  double ScalarBarLength;
373 
374  int AutomaticLabelFormat;
375 
376  bool VerticalLabels;
377 
378  int AddRangeLabels;
379  int AutomaticAnnotations;
380  int AddRangeAnnotations;
381  char* RangeLabelFormat;
382  char* DataRangeLabelFormat;
383 
387  bool AllowOverlappingLabels;
388 
392  bool DrawScalarBarOutline;
393 
397  int ScalarBarOutlineThickness;
398 
403  double Spacer;
404 
408  bool DrawTickMarks;
409 
413  bool ReverseLegend;
414 
419  class vtkScalarBarItem;
420  vtkScalarBarItem* ScalarBarItem;
421 
425  vtkViewport* CurrentViewport;
426 
430  vtkAxis* Axis;
431 
435  bool InGetBoundingRect;
436 
444  vtkRectf CurrentBoundingRect;
445 
450  void UpdateScalarBarTexture(vtkImageData* image);
451 
457  void GetSize(double size[2], vtkContext2D* painter);
458 
464  vtkRectf GetColorBarRect(double size[2], bool includeSwatch = true);
465 
470  vtkRectf GetFullColorBarRect(double size[2]);
471 
475  vtkRectf GetAboveRangeColorRect(double size[2]);
476 
480  vtkRectf GetBelowRangeColorRect(double size[2]);
481 
482  vtkRectf GetOutOfRangeColorRectInternal(
483  vtkContext2DScalarBarActor::OutOfRangeType type, double size[2]);
484 
488  vtkRectf GetNaNColorRect(double size[2]);
489 
493  void UpdateTextProperties();
494 
498  void PaintColorBar(vtkContext2D* painter, double size[2]);
499 
503  void PaintAxis(vtkContext2D* painter, double size[2]);
504 
508  void PaintTitle(vtkContext2D* painter, double size[2]);
509 
513  void PaintRange(vtkContext2D* painter, double size[2]);
514 
515  class vtkAnnotationMap;
516 
522  void PaintAnnotations(vtkContext2D* painter, double size[2], const vtkAnnotationMap& map);
523 
527  void PaintAnnotationsVertically(
528  vtkContext2D* painter, double size[2], const vtkAnnotationMap& map);
529 
533  void PaintAnnotationsHorizontally(
534  vtkContext2D* painter, double size[2], const vtkAnnotationMap& map);
535 
539  float HorizontalAnnotationHeight;
540 
544  float VerticalRangeDataHeight;
545 };
546 
547 #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 *)