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 vtkContextItem;
42 class vtkContextScene;
43 class vtkDoubleArray;
44 class vtkImageData;
45 class vtkPoints2D;
46 class vtkScalarsToColors;
47 class vtkScalarBarItem;
48 class vtkTextProperty;
49 class vtkViewport;
50 
52 {
53 public:
55  void PrintSelf(ostream& os, vtkIndent indent) override;
57 
59 
63  vtkGetMacro(TitleJustification, int);
64  vtkSetClampMacro(TitleJustification, int, VTK_TEXT_LEFT, VTK_TEXT_RIGHT);
66 
68 
72  vtkSetMacro(ForceHorizontalTitle, bool);
73  vtkGetMacro(ForceHorizontalTitle, bool);
74  vtkBooleanMacro(ForceHorizontalTitle, bool);
76 
77  enum
78  {
79  PrecedeScalarBar = 0,
80  SucceedScalarBar
81  };
82 
84  {
85  BELOW_RANGE = 0,
86  ABOVE_RANGE = 1,
87  };
88 
90 
96  vtkSetClampMacro(ScalarBarThickness, int, 0, VTK_INT_MAX);
97  vtkGetMacro(ScalarBarThickness, int);
99 
101 
109  vtkSetClampMacro(ScalarBarLength, double, 0, 1);
110  vtkGetMacro(ScalarBarLength, double);
112 
114 
118  vtkSetMacro(ReverseLegend, bool);
119  vtkGetMacro(ReverseLegend, bool);
120  vtkBooleanMacro(ReverseLegend, bool);
122 
124 
129  vtkGetMacro(AutomaticLabelFormat, int);
130  vtkSetMacro(AutomaticLabelFormat, int);
131  vtkBooleanMacro(AutomaticLabelFormat, int);
133 
135 
139  vtkSetMacro(AddRangeLabels, int);
140  vtkGetMacro(AddRangeLabels, int);
142 
144 
148  vtkSetMacro(AutomaticAnnotations, int);
149  vtkGetMacro(AutomaticAnnotations, int);
150  vtkBooleanMacro(AutomaticAnnotations, int);
152 
154 
158  vtkGetMacro(AddRangeAnnotations, int);
159  vtkSetMacro(AddRangeAnnotations, int);
160  vtkBooleanMacro(AddRangeAnnotations, int);
162 
164 
167  vtkSetMacro(DrawTickMarks, bool);
168  vtkGetMacro(DrawTickMarks, bool);
170 
172 
175  vtkSetStringMacro(RangeLabelFormat);
176  vtkGetStringMacro(RangeLabelFormat);
178 
180 
183  void SetUseCustomLabels(bool useLabels);
184  vtkGetMacro(UseCustomLabels, bool);
186 
188 
191  void SetNumberOfCustomLabels(vtkIdType numLabels);
192  vtkIdType GetNumberOfCustomLabels();
194 
198  void SetCustomLabel(vtkIdType index, double value);
199 
203  int RenderOverlay(vtkViewport* viewport) override;
204 
208  int RenderOpaqueGeometry(vtkViewport* viewport) override;
209 
215  void ReleaseGraphicsResources(vtkWindow* window) override;
216 
220  virtual bool Paint(vtkContext2D* painter);
221 
226  vtkRectf GetBoundingRect();
227 
234  int GetEstimatedNumberOfAnnotations();
235 
236 protected:
238  ~vtkContext2DScalarBarActor() override;
239 
240 private:
242  void operator=(const vtkContext2DScalarBarActor&) = delete;
243 
244  vtkContextActor* ActorDelegate;
245 
246  int TitleJustification;
247 
252  bool ForceHorizontalTitle;
253 
257  int ScalarBarThickness;
258 
262  double ScalarBarLength;
263 
264  int AutomaticLabelFormat;
265 
266  int AddRangeLabels;
267  int AutomaticAnnotations;
268  int AddRangeAnnotations;
269  char* RangeLabelFormat;
270 
274  int OutlineScalarBar;
275 
280  double Spacer;
281 
285  bool DrawTickMarks;
286 
287  bool UseCustomLabels;
288 
292  bool ReverseLegend;
293 
297  vtkSmartPointer<vtkDoubleArray> CustomLabels;
298 
303  class vtkScalarBarItem;
304  vtkScalarBarItem* ScalarBarItem;
305 
309  vtkViewport* CurrentViewport;
310 
314  vtkAxis* Axis;
315 
320  void UpdateScalarBarTexture(vtkImageData* image);
321 
327  void GetSize(double size[2], vtkContext2D* painter);
328 
334  vtkRectf GetColorBarRect(double size[2]);
335 
340  vtkRectf GetFullColorBarRect(double size[2]);
341 
345  vtkRectf GetAboveRangeColorRect(double size[2]);
346 
350  vtkRectf GetBelowRangeColorRect(double size[2]);
351 
352  vtkRectf GetOutOfRangeColorRectInternal(
353  vtkContext2DScalarBarActor::OutOfRangeType type, double size[2]);
354 
358  vtkRectf GetNaNColorRect(double size[2]);
359 
363  void UpdateTextProperties();
364 
368  void PaintColorBar(vtkContext2D* painter, double size[2]);
369 
373  void PaintAxis(vtkContext2D* painter, double size[2]);
374 
378  void PaintTitle(vtkContext2D* painter, double size[2]);
379 
380  class vtkAnnotationMap;
381 
387  void PaintAnnotations(vtkContext2D* painter, double size[2], const vtkAnnotationMap& map);
388 
392  void PaintAnnotationsVertically(
393  vtkContext2D* painter, double size[2], const vtkAnnotationMap& map);
394 
398  void PaintAnnotationsHorizontally(
399  vtkContext2D* painter, double size[2], const vtkAnnotationMap& map);
400 };
401 
402 #endif // vtkContext2DScalarBarActor_h
#define VTKREMOTINGVIEWS_EXPORT
int RenderOverlay(vtkViewport *viewport)
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 *)