vtkContext2DScalarBarActor.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: ParaView
4  Module: vtkContext2DScalarBarActor.h
5 
6  Copyright (c) Kitware, Inc.
7  All rights reserved.
8  See Copyright.txt or http://www.paraview.org/HTML/Copyright.html for details.
9 
10  This software is distributed WITHOUT ANY WARRANTY; without even
11  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12  PURPOSE. See the above copyright notice for more information.
13 
14 =========================================================================*/
26 #ifndef vtkContext2DScalarBarActor_h
27 #define vtkContext2DScalarBarActor_h
28 
29 #include "vtkRemotingViewsModule.h" // needed for export macro
30 #include "vtkScalarBarActor.h"
31 
32 #include "vtkCoordinate.h" // for Position and Position 2
33 #include "vtkRect.h" // for functions that return vtkRects
34 #include "vtkSmartPointer.h" // for smart pointers
35 
36 class vtkAxis;
37 class vtkColorLegend;
39 class vtkContextActor;
40 class vtkContext2D;
41 class vtkContextScene;
42 class vtkDoubleArray;
43 class vtkImageData;
44 class vtkPoints2D;
45 class vtkScalarsToColors;
46 class vtkTextProperty;
47 class vtkViewport;
48 
50 {
51 public:
53  void PrintSelf(ostream& os, vtkIndent indent) override;
55 
57 
61  vtkGetMacro(TitleJustification, int);
62  vtkSetClampMacro(TitleJustification, int, VTK_TEXT_LEFT, VTK_TEXT_RIGHT);
64 
66 
70  vtkSetMacro(ForceHorizontalTitle, bool);
71  vtkGetMacro(ForceHorizontalTitle, bool);
72  vtkBooleanMacro(ForceHorizontalTitle, bool);
74 
75  enum
76  {
77  PrecedeScalarBar = 0,
78  SucceedScalarBar
79  };
80 
82  {
83  BELOW_RANGE = 0,
84  ABOVE_RANGE = 1,
85  };
86 
88 
94  vtkSetClampMacro(ScalarBarThickness, int, 0, VTK_INT_MAX);
95  vtkGetMacro(ScalarBarThickness, int);
97 
99 
107  vtkSetClampMacro(ScalarBarLength, double, 0, 1);
108  vtkGetMacro(ScalarBarLength, double);
110 
112 
115  vtkSetMacro(DrawScalarBarOutline, bool);
116  vtkGetMacro(DrawScalarBarOutline, bool);
117  vtkBooleanMacro(DrawScalarBarOutline, bool);
119 
121 
124  vtkSetVector3Macro(ScalarBarOutlineColor, double);
125  vtkGetVector3Macro(ScalarBarOutlineColor, double);
127 
129 
132  vtkSetClampMacro(ScalarBarOutlineThickness, int, 0, VTK_INT_MAX);
133  vtkGetMacro(ScalarBarOutlineThickness, int);
135 
137 
141  vtkSetVector4Macro(BackgroundColor, double);
143  vtkGetVector4Macro(BackgroundColor, double);
144 
146 
150  vtkSetMacro(BackgroundPadding, double);
152  vtkGetMacro(BackgroundPadding, double);
153 
155 
159  vtkSetMacro(ReverseLegend, bool);
160  vtkGetMacro(ReverseLegend, bool);
161  vtkBooleanMacro(ReverseLegend, bool);
163 
165 
170  vtkGetMacro(AutomaticLabelFormat, int);
171  vtkSetMacro(AutomaticLabelFormat, int);
172  vtkBooleanMacro(AutomaticLabelFormat, int);
174 
176 
180  vtkSetMacro(AddRangeLabels, int);
181  vtkGetMacro(AddRangeLabels, int);
183 
185 
189  vtkSetMacro(AutomaticAnnotations, int);
190  vtkGetMacro(AutomaticAnnotations, int);
191  vtkBooleanMacro(AutomaticAnnotations, int);
193 
195 
199  vtkGetMacro(AddRangeAnnotations, int);
200  vtkSetMacro(AddRangeAnnotations, int);
201  vtkBooleanMacro(AddRangeAnnotations, int);
203 
205 
208  vtkSetMacro(DrawTickMarks, bool);
209  vtkGetMacro(DrawTickMarks, bool);
211 
213 
216  vtkSetStringMacro(RangeLabelFormat);
217  vtkGetStringMacro(RangeLabelFormat);
219 
221 
224  vtkSetStringMacro(DataRangeLabelFormat);
225  vtkGetStringMacro(DataRangeLabelFormat);
227 
229 
232  void SetNumberOfCustomLabels(vtkIdType numLabels);
233  vtkIdType GetNumberOfCustomLabels();
235 
239  void SetCustomLabel(vtkIdType index, double value);
240 
244  int RenderOverlay(vtkViewport* viewport) override;
245 
249  int RenderOpaqueGeometry(vtkViewport* viewport) override;
250 
256  void ReleaseGraphicsResources(vtkWindow* window) override;
257 
261  virtual bool Paint(vtkContext2D* painter);
262 
267  vtkRectf GetBoundingRect();
268 
275  int GetEstimatedNumberOfAnnotations();
276 
278 
282  vtkSetMacro(DrawDataRange, bool);
283  vtkGetMacro(DrawDataRange, bool);
284  vtkBooleanMacro(DrawDataRange, bool);
286 
288 
293  vtkSetMacro(DataRangeMin, double);
294  vtkGetMacro(DataRangeMin, double);
296 
298 
303  vtkSetMacro(DataRangeMax, double);
304  vtkGetMacro(DataRangeMax, double);
306 
307 protected:
309  ~vtkContext2DScalarBarActor() override;
310 
315 
317 
320  double DataRangeMin = 0;
321  double DataRangeMax = 0;
323 
327  int VerticalOffset = 0;
328 
329 private:
331  void operator=(const vtkContext2DScalarBarActor&) = delete;
332 
333  vtkContextActor* ActorDelegate;
334 
335  int TitleJustification;
336 
341  bool ForceHorizontalTitle;
342 
346  double ScalarBarOutlineColor[3];
347 
351  int ScalarBarThickness;
352 
356  double BackgroundColor[4];
357 
361  double BackgroundPadding;
362 
366  double ScalarBarLength;
367 
368  int AutomaticLabelFormat;
369 
370  int AddRangeLabels;
371  int AutomaticAnnotations;
372  int AddRangeAnnotations;
373  char* RangeLabelFormat;
374  char* DataRangeLabelFormat;
375 
379  bool DrawScalarBarOutline;
380 
384  int ScalarBarOutlineThickness;
385 
390  double Spacer;
391 
395  bool DrawTickMarks;
396 
400  bool ReverseLegend;
401 
406  class vtkScalarBarItem;
407  vtkScalarBarItem* ScalarBarItem;
408 
412  vtkViewport* CurrentViewport;
413 
417  vtkAxis* Axis;
418 
422  bool InGetBoundingRect;
423 
431  vtkRectf CurrentBoundingRect;
432 
437  void UpdateScalarBarTexture(vtkImageData* image);
438 
444  void GetSize(double size[2], vtkContext2D* painter);
445 
451  vtkRectf GetColorBarRect(double size[2], bool includeSwatch = true);
452 
457  vtkRectf GetFullColorBarRect(double size[2]);
458 
462  vtkRectf GetAboveRangeColorRect(double size[2]);
463 
467  vtkRectf GetBelowRangeColorRect(double size[2]);
468 
469  vtkRectf GetOutOfRangeColorRectInternal(
470  vtkContext2DScalarBarActor::OutOfRangeType type, double size[2]);
471 
475  vtkRectf GetNaNColorRect(double size[2]);
476 
480  void UpdateTextProperties();
481 
485  void PaintColorBar(vtkContext2D* painter, double size[2]);
486 
490  void PaintAxis(vtkContext2D* painter, double size[2]);
491 
495  void PaintTitle(vtkContext2D* painter, double size[2]);
496 
500  void PaintRange(vtkContext2D* painter, double size[2]);
501 
502  class vtkAnnotationMap;
503 
509  void PaintAnnotations(vtkContext2D* painter, double size[2], const vtkAnnotationMap& map);
510 
514  void PaintAnnotationsVertically(
515  vtkContext2D* painter, double size[2], const vtkAnnotationMap& map);
516 
520  void PaintAnnotationsHorizontally(
521  vtkContext2D* painter, double size[2], const vtkAnnotationMap& map);
522 
526  float HorizontalAnnotationHeight;
527 
531  float VerticalRangeDataHeight;
532 };
533 
534 #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 *)