VTK  9.0.1
vtkScalarBarActor.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkScalarBarActor.h
5 
6  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7  All rights reserved.
8  See Copyright.txt or http://www.kitware.com/Copyright.htm 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 =========================================================================*/
56 #ifndef vtkScalarBarActor_h
57 #define vtkScalarBarActor_h
58 
59 #include "vtkActor2D.h"
60 #include "vtkRenderingAnnotationModule.h" // For export macro
61 
62 class vtkColor3ub;
63 class vtkPolyData;
65 class vtkProperty2D;
66 class vtkScalarsToColors;
68 class vtkTextActor;
69 class vtkTextMapper;
70 class vtkTextProperty;
71 class vtkTexture;
72 class vtkTexturedActor2D;
73 
74 #define VTK_ORIENT_HORIZONTAL 0
75 #define VTK_ORIENT_VERTICAL 1
76 
77 class VTKRENDERINGANNOTATION_EXPORT vtkScalarBarActor : public vtkActor2D
78 {
79 public:
80  vtkTypeMacro(vtkScalarBarActor, vtkActor2D);
81  void PrintSelf(ostream& os, vtkIndent indent) override;
82 
88  static vtkScalarBarActor* New();
89 
91 
94  int RenderOpaqueGeometry(vtkViewport* viewport) override;
95  int RenderTranslucentPolygonalGeometry(vtkViewport*) override { return 0; }
96  int RenderOverlay(vtkViewport* viewport) override;
98 
103 
109  void ReleaseGraphicsResources(vtkWindow*) override;
110 
116  virtual void GetScalarBarRect(int rect[4], vtkViewport* viewport);
117 
119 
125  virtual void SetLookupTable(vtkScalarsToColors*);
126  vtkGetObjectMacro(LookupTable, vtkScalarsToColors);
128 
130 
137  vtkSetMacro(UseOpacity, vtkTypeBool);
138  vtkGetMacro(UseOpacity, vtkTypeBool);
139  vtkBooleanMacro(UseOpacity, vtkTypeBool);
141 
143 
148  vtkSetClampMacro(MaximumNumberOfColors, int, 2, VTK_INT_MAX);
149  vtkGetMacro(MaximumNumberOfColors, int);
151 
153 
156  vtkSetClampMacro(NumberOfLabels, int, 0, 64);
157  vtkGetMacro(NumberOfLabels, int);
159 
161 
164  vtkSetClampMacro(Orientation, int, VTK_ORIENT_HORIZONTAL, VTK_ORIENT_VERTICAL);
165  vtkGetMacro(Orientation, int);
166  void SetOrientationToHorizontal() { this->SetOrientation(VTK_ORIENT_HORIZONTAL); }
167  void SetOrientationToVertical() { this->SetOrientation(VTK_ORIENT_VERTICAL); }
169 
171 
174  virtual void SetTitleTextProperty(vtkTextProperty* p);
175  vtkGetObjectMacro(TitleTextProperty, vtkTextProperty);
177 
179 
182  virtual void SetLabelTextProperty(vtkTextProperty* p);
183  vtkGetObjectMacro(LabelTextProperty, vtkTextProperty);
185 
187 
190  virtual void SetAnnotationTextProperty(vtkTextProperty* p);
191  vtkGetObjectMacro(AnnotationTextProperty, vtkTextProperty);
193 
195 
199  vtkSetStringMacro(LabelFormat);
200  vtkGetStringMacro(LabelFormat);
202 
204 
207  vtkSetStringMacro(Title);
208  vtkGetStringMacro(Title);
210 
212 
215  vtkSetStringMacro(ComponentTitle);
216  vtkGetStringMacro(ComponentTitle);
218 
222  void ShallowCopy(vtkProp* prop) override;
223 
225 
228  vtkSetMacro(TextureGridWidth, double);
229  vtkGetMacro(TextureGridWidth, double);
231 
233 
236  vtkGetObjectMacro(TextureActor, vtkTexturedActor2D);
238 
239  enum
240  {
241  PrecedeScalarBar = 0,
242  SucceedScalarBar
243  };
244 
246 
254  vtkSetClampMacro(TextPosition, int, PrecedeScalarBar, SucceedScalarBar);
255  vtkGetMacro(TextPosition, int);
257  {
258  this->SetTextPosition(vtkScalarBarActor::PrecedeScalarBar);
259  }
261  {
262  this->SetTextPosition(vtkScalarBarActor::SucceedScalarBar);
263  }
265 
267 
274  vtkSetMacro(MaximumWidthInPixels, int);
275  vtkGetMacro(MaximumWidthInPixels, int);
276  vtkSetMacro(MaximumHeightInPixels, int);
277  vtkGetMacro(MaximumHeightInPixels, int);
279 
281 
286  vtkSetMacro(AnnotationLeaderPadding, double);
287  vtkGetMacro(AnnotationLeaderPadding, double);
289 
291 
296  vtkSetMacro(DrawAnnotations, vtkTypeBool);
297  vtkGetMacro(DrawAnnotations, vtkTypeBool);
298  vtkBooleanMacro(DrawAnnotations, vtkTypeBool);
300 
302 
307  vtkSetMacro(DrawNanAnnotation, vtkTypeBool);
308  vtkGetMacro(DrawNanAnnotation, vtkTypeBool);
309  vtkBooleanMacro(DrawNanAnnotation, vtkTypeBool);
311 
313 
318  vtkSetMacro(DrawBelowRangeSwatch, bool);
319  vtkGetMacro(DrawBelowRangeSwatch, bool);
320  vtkBooleanMacro(DrawBelowRangeSwatch, bool);
322 
324 
327  vtkSetStringMacro(BelowRangeAnnotation);
328  vtkGetStringMacro(BelowRangeAnnotation);
330 
332 
337  vtkSetMacro(DrawAboveRangeSwatch, bool);
338  vtkGetMacro(DrawAboveRangeSwatch, bool);
339  vtkBooleanMacro(DrawAboveRangeSwatch, bool);
341 
343 
346  vtkSetStringMacro(AboveRangeAnnotation);
347  vtkGetStringMacro(AboveRangeAnnotation);
349 
350 
358  vtkSetMacro(FixedAnnotationLeaderLineColor, vtkTypeBool);
359  vtkGetMacro(FixedAnnotationLeaderLineColor, vtkTypeBool);
360  vtkBooleanMacro(FixedAnnotationLeaderLineColor, vtkTypeBool);
362 
364 
367  vtkSetStringMacro(NanAnnotation);
368  vtkGetStringMacro(NanAnnotation);
370 
372 
380  vtkSetMacro(AnnotationTextScaling, vtkTypeBool);
381  vtkGetMacro(AnnotationTextScaling, vtkTypeBool);
382  vtkBooleanMacro(AnnotationTextScaling, vtkTypeBool);
384 
386 
390  vtkSetMacro(DrawBackground, vtkTypeBool);
391  vtkGetMacro(DrawBackground, vtkTypeBool);
392  vtkBooleanMacro(DrawBackground, vtkTypeBool);
394 
396 
400  vtkSetMacro(DrawFrame, vtkTypeBool);
401  vtkGetMacro(DrawFrame, vtkTypeBool);
402  vtkBooleanMacro(DrawFrame, vtkTypeBool);
404 
406 
410  vtkSetMacro(DrawColorBar, vtkTypeBool);
411  vtkGetMacro(DrawColorBar, vtkTypeBool);
412  vtkBooleanMacro(DrawColorBar, vtkTypeBool);
414 
416 
419  vtkSetMacro(DrawTickLabels, vtkTypeBool);
420  vtkGetMacro(DrawTickLabels, vtkTypeBool);
421  vtkBooleanMacro(DrawTickLabels, vtkTypeBool);
423 
425 
428  virtual void SetBackgroundProperty(vtkProperty2D* p);
429  vtkGetObjectMacro(BackgroundProperty, vtkProperty2D);
431 
433 
436  virtual void SetFrameProperty(vtkProperty2D* p);
437  vtkGetObjectMacro(FrameProperty, vtkProperty2D);
439 
441 
445  vtkGetMacro(TextPad, int);
446  vtkSetMacro(TextPad, int);
448 
450 
455  vtkGetMacro(VerticalTitleSeparation, int);
456  vtkSetMacro(VerticalTitleSeparation, int);
458 
460 
464  vtkGetMacro(BarRatio, double);
465  vtkSetClampMacro(BarRatio, double, 0., 1.);
467 
469 
475  vtkGetMacro(TitleRatio, double);
476  vtkSetClampMacro(TitleRatio, double, 0., 1.);
478 
480 
485  vtkSetMacro(UnconstrainedFontSize, bool);
486  vtkGetMacro(UnconstrainedFontSize, bool);
487  vtkBooleanMacro(UnconstrainedFontSize, bool);
489 
490 protected:
492  ~vtkScalarBarActor() override;
493 
518  virtual void RebuildLayout(vtkViewport* viewport);
519 
525  virtual int RebuildLayoutIfNeeded(vtkViewport* viewport);
526 
530  virtual void FreeLayoutStorage();
531 
540  virtual void ComputeFrame();
541 
551  virtual void ComputeScalarBarThickness();
552 
556  virtual void ComputeSwatchPad();
557 
558  // This method must set this->P->NanSwatchSize and this->P->NanBox.
559  // It may depend on layout performed by ComputeScalarBarThickness.
560  virtual void LayoutNanSwatch();
561 
568  virtual void LayoutBelowRangeSwatch();
569 
576  virtual void LayoutAboveRangeSwatch();
577 
584  virtual void LayoutAboveRangeSwatchPosn();
585 
589  virtual void PrepareTitleText();
590 
601  virtual void LayoutTitle();
602 
607  virtual void LayoutForUnconstrainedFont();
608 
617  virtual void ComputeScalarBarLength();
618 
628  virtual void LayoutTicks();
629 
637  virtual void LayoutAnnotations();
638 
642  virtual void ConfigureAnnotations();
643 
647  virtual void ConfigureFrame();
648 
652  virtual void DrawBoxes();
653 
657  virtual void ConfigureScalarBar();
658 
662  virtual void ConfigureTitle();
663 
667  virtual void ConfigureTicks();
668 
675  virtual void ConfigureNanSwatch();
676 
681  virtual void ConfigureAboveBelowRangeSwatch(bool above);
682 
691  virtual void EditAnnotations() {}
692 
698  virtual void SizeTitle(double* titleSize, int* size, vtkViewport* viewport);
699 
703  int MapAnnotationLabels(
704  vtkScalarsToColors* lkup, double start, double delta, const double* range);
705 
709  int PlaceAnnotationsVertically(
710  double barX, double barY, double barWidth, double barHeight, double delta, double pad);
715  int PlaceAnnotationsHorizontally(
716  double barX, double barY, double barWidth, double barHeight, double delta, double pad);
717 
719 
724  vtkTypeBool DrawBackground; // off by default
725  vtkTypeBool DrawFrame; // off by default
726  vtkTypeBool DrawColorBar; // on by default
727  vtkTypeBool DrawTickLabels; // on by default
734  char* Title;
736  char* LabelFormat;
737  vtkTypeBool UseOpacity; // off by default
746  int TextPad;
748  double BarRatio;
749  double TitleRatio;
750  bool UnconstrainedFontSize; // off by default
751 
755 
757 
759  int LastSize[2];
760  int LastOrigin[2];
761 
763 
765 
770 
777 
781 
785 
786 
787 private:
788  vtkScalarBarActor(const vtkScalarBarActor&) = delete;
789  void operator=(const vtkScalarBarActor&) = delete;
790 };
791 
792 #endif
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:53
int TextPad
User-changeable settings.
int MaximumWidthInPixels
User-changeable settings.
virtual void EditAnnotations()
Subclasses may override this method to alter this->P->Labels, allowing the addition and removal of an...
double TitleRatio
User-changeable settings.
int RenderOverlay(vtkViewport *viewport) override
Support the standard render methods.
vtkTypeBool FixedAnnotationLeaderLineColor
User-changeable settings.
actor that draws 2D data with texture support
vtkPolyDataMapper2D * ScalarBarMapper
Mapper for ScalarBar.
abstract specification for Viewports
Definition: vtkViewport.h:44
virtual void SetTextPositionToPrecedeScalarBar()
Should the title and tick marks precede the scalar bar or succeed it? This is measured along the view...
vtkScalarsToColors * LookupTable
The object this actor illustrates.
#define VTK_INT_MAX
Definition: vtkType.h:155
vtkPolyDataMapper2D * BackgroundMapper
Mapper for Background.
a actor that draws 2D data
Definition: vtkActor2D.h:39
record modification and/or execution time
Definition: vtkTimeStamp.h:32
Internal state for the scalar bar actor shared with subclasses.
int NumberOfLabelsBuilt
User-changeable settings.
vtkActor2D * FrameActor
Actor for Frame.
Create a scalar bar with labels.
int VerticalTitleSeparation
User-changeable settings.
char * AboveRangeAnnotation
User-changeable settings.
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:84
double TextureGridWidth
User-changeable settings.
void ShallowCopy(vtkProp *prop) override
Shallow copy of this vtkActor2D.
vtkTexture * Texture
Color data for TexturePolyData.
vtkTypeBool AnnotationTextScaling
User-changeable settings.
vtkTypeBool DrawAnnotations
User-changeable settings.
2D text annotation
Definition: vtkTextMapper.h:47
char * BelowRangeAnnotation
User-changeable settings.
char * ComponentTitle
User-changeable settings.
#define VTK_ORIENT_VERTICAL
int MaximumHeightInPixels
User-changeable settings.
int RenderTranslucentPolygonalGeometry(vtkViewport *) override
Draw the scalar bar and annotation text to the screen.
int vtkTypeBool
Definition: vtkABI.h:69
char * Title
User-changeable settings.
Superclass for mapping scalar values to colors.
window superclass for vtkRenderWindow
Definition: vtkWindow.h:37
vtkActor2D * BackgroundActor
Actor for Background.
An actor that displays text.
Definition: vtkTextActor.h:50
#define VTK_ORIENT_HORIZONTAL
Some derived classes for the different colors commonly used.
Definition: vtkColor.h:194
void ReleaseGraphicsResources(vtkWindow *) override
Release any graphics resources that are being consumed by this actor.
a simple class to control print indentation
Definition: vtkIndent.h:33
char * LabelFormat
User-changeable settings.
vtkScalarBarActorInternal * P
Containers shared with subclasses.
int NumberOfLabels
User-changeable settings.
static vtkActor2D * New()
Creates an actor2D with the following defaults: position (0,0) (coordinate system is viewport); at la...
double AnnotationLeaderPadding
User-changeable settings.
handles properties associated with a texture map
Definition: vtkTexture.h:65
int Orientation
User-changeable settings.
int TextPosition
User-changeable settings.
vtkPolyData * ScalarBar
Polygon(s) colored by LookupTable.
vtkTypeBool UseOpacity
User-changeable settings.
bool DrawBelowRangeSwatch
User-changeable settings.
vtkProperty2D * BackgroundProperty
User-changeable settings.
vtkActor2D * ScalarBarActor
Actor for ScalarBar.
represent text properties.
vtkPolyData * Background
Polygon used to fill the background.
vtkTextProperty * LabelTextProperty
Font for tick labels.
vtkTimeStamp BuildTime
Internal state used for rendering.
vtkTextProperty * TitleTextProperty
Font for the legend title.
int MaximumNumberOfColors
User-changeable settings.
vtkTypeBool HasTranslucentPolygonalGeometry() override
Does this prop have some translucent polygonal geometry?
char * NanAnnotation
User-changeable settings.
vtkTypeBool DrawBackground
User-changeable settings.
vtkTypeBool DrawColorBar
User-changeable settings.
double BarRatio
User-changeable settings.
vtkTypeBool DrawFrame
User-changeable settings.
int RenderOpaqueGeometry(vtkViewport *viewport) override
Support the standard render methods.
vtkTextProperty * AnnotationTextProperty
Font for annotation labels.
vtkTextActor * TitleActor
The legend title text renderer.
vtkPolyDataMapper2D * FrameMapper
Mapper for Frame.
represent surface properties of a 2D image
Definition: vtkProperty2D.h:37
virtual void SetTextPositionToSucceedScalarBar()
Should the title and tick marks precede the scalar bar or succeed it? This is measured along the view...
void SetOrientationToVertical()
Control the orientation of the scalar bar.
bool DrawAboveRangeSwatch
User-changeable settings.
void SetOrientationToHorizontal()
Control the orientation of the scalar bar.
vtkProperty2D * FrameProperty
User-changeable settings.
bool UnconstrainedFontSize
User-changeable settings.
vtkPolyData * Frame
Polyline used to highlight frame.
vtkTypeBool DrawTickLabels
User-changeable settings.
draw vtkPolyData onto the image plane
vtkPolyData * TexturePolyData
Polygon colored when UseOpacity is true.
vtkTypeBool DrawNanAnnotation
User-changeable settings.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkTexturedActor2D * TextureActor
Actor for TexturePolyData.