VTK  9.0.3
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 
89 
91 
94  int RenderOpaqueGeometry(vtkViewport* viewport) override;
95  int RenderTranslucentPolygonalGeometry(vtkViewport*) override { return 0; }
96  int RenderOverlay(vtkViewport* viewport) override;
98 
103 
110 
116  virtual void GetScalarBarRect(int rect[4], vtkViewport* viewport);
117 
119 
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 
175  vtkGetObjectMacro(TitleTextProperty, vtkTextProperty);
177 
179 
183  vtkGetObjectMacro(LabelTextProperty, vtkTextProperty);
185 
187 
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 
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 
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 
585 
589  virtual void PrepareTitleText();
590 
601  virtual void LayoutTitle();
602 
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 
704  vtkScalarsToColors* lkup, double start, double delta, const double* range);
705 
710  double barX, double barY, double barWidth, double barHeight, double delta, double pad);
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 
786 
787 private:
788  vtkScalarBarActor(const vtkScalarBarActor&) = delete;
789  void operator=(const vtkScalarBarActor&) = delete;
790 };
791 
792 #endif
a actor that draws 2D data
Definition: vtkActor2D.h:40
Some derived classes for the different colors commonly used.
Definition: vtkColor.h:195
a simple class to control print indentation
Definition: vtkIndent.h:34
draw vtkPolyData onto the image plane
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:85
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:48
represent surface properties of a 2D image
Definition: vtkProperty2D.h:38
Internal state for the scalar bar actor shared with subclasses.
Create a scalar bar with labels.
virtual void LayoutNanSwatch()
vtkPolyData * Background
Polygon used to fill the background.
int RenderOverlay(vtkViewport *viewport) override
virtual void ComputeScalarBarThickness()
Determine how thick the scalar bar should be (on an axis perpendicular to the direction in which scal...
vtkTypeBool AnnotationTextScaling
virtual void SetAnnotationTextProperty(vtkTextProperty *p)
Set/Get the annotation text property.
virtual void FreeLayoutStorage()
Free internal storage used by the previous layout.
virtual void ConfigureAnnotations()
Generate/configure the annotation labels using the laid-out geometry.
static vtkScalarBarActor * New()
Instantiate object with 64 maximum colors; 5 labels; %%-#6.3g label format, no title,...
virtual void ComputeFrame()
If the scalar bar should be inset into a frame or rendered with a solid background,...
vtkTypeBool DrawBackground
virtual void ComputeSwatchPad()
Compute a correct SwatchPad.
int RenderOpaqueGeometry(vtkViewport *viewport) override
Draw the scalar bar and annotation text to the screen.
vtkTextActor * TitleActor
The legend title text renderer.
~vtkScalarBarActor() override
virtual void LayoutTitle()
Determine the position and size of the scalar bar title box.
vtkProperty2D * BackgroundProperty
virtual void ConfigureNanSwatch()
Generate/configure the NaN swatch using the laid-out geometry.
vtkTypeBool HasTranslucentPolygonalGeometry() override
Does this prop have some translucent polygonal geometry?
int MaximumNumberOfColors
User-changeable settings.
vtkTextProperty * AnnotationTextProperty
Font for annotation labels.
vtkTexturedActor2D * TextureActor
Actor for TexturePolyData.
virtual void LayoutBelowRangeSwatch()
Determine the size of the Below Range if it is to be rendered.
vtkPolyData * Frame
Polyline used to highlight frame.
int PlaceAnnotationsVertically(double barX, double barY, double barWidth, double barHeight, double delta, double pad)
This method is called by ConfigureAnnotationLabels when Orientation is VTK_ORIENT_VERTICAL.
vtkPolyData * ScalarBar
Polygon(s) colored by LookupTable.
virtual void ConfigureTicks()
Generate/configure the tick-mark actors using the laid-out geometry.
vtkPolyDataMapper2D * FrameMapper
Mapper for Frame.
virtual void LayoutAnnotations()
This method must lay out annotation text and leader lines so they do not overlap.
virtual void RebuildLayout(vtkViewport *viewport)
Called from within RenderOpaqueGeometry when the internal state members need to be updated before ren...
int MapAnnotationLabels(vtkScalarsToColors *lkup, double start, double delta, const double *range)
Allocate actors for lookup table annotations and position them properly.
vtkTextProperty * TitleTextProperty
Font for the legend title.
virtual int RebuildLayoutIfNeeded(vtkViewport *viewport)
Calls RebuildLayout if it is needed such as when positions etc have changed.
vtkActor2D * FrameActor
Actor for Frame.
vtkProperty2D * FrameProperty
vtkPolyData * TexturePolyData
Polygon colored when UseOpacity is true.
int RenderTranslucentPolygonalGeometry(vtkViewport *) override
void ReleaseGraphicsResources(vtkWindow *) override
Release any graphics resources that are being consumed by this actor.
virtual void SetTextPositionToPrecedeScalarBar()
virtual void SetTextPositionToSucceedScalarBar()
virtual void LayoutAboveRangeSwatchPosn()
Determine the position of the Above Range if it is to be rendered.
virtual void EditAnnotations()
Subclasses may override this method to alter this->P->Labels, allowing the addition and removal of an...
vtkActor2D * BackgroundActor
Actor for Background.
virtual void DrawBoxes()
For debugging, add placement boxes to the frame polydata.
virtual void SetLookupTable(vtkScalarsToColors *)
Set/Get the lookup table to use.
vtkTextProperty * LabelTextProperty
Font for tick labels.
vtkTypeBool DrawTickLabels
virtual void ConfigureFrame()
Generate/configure the representation of the frame from laid-out geometry.
vtkTypeBool FixedAnnotationLeaderLineColor
vtkTypeBool DrawColorBar
vtkPolyDataMapper2D * BackgroundMapper
Mapper for Background.
virtual void SetTitleTextProperty(vtkTextProperty *p)
Set/Get the title text property.
virtual void GetScalarBarRect(int rect[4], vtkViewport *viewport)
Fills rect with the dimensions of the scalar bar in viewport coordinates.
virtual void SizeTitle(double *titleSize, int *size, vtkViewport *viewport)
Compute the best size for the legend title.
virtual void ConfigureAboveBelowRangeSwatch(bool above)
Generate/configure the above/below range swatch using the laid-out geometry.
int PlaceAnnotationsHorizontally(double barX, double barY, double barWidth, double barHeight, double delta, double pad)
This method is called by ConfigureAnnotationLabels when Orientation is VTK_ORIENT_HORIZONTAL.
vtkTypeBool DrawNanAnnotation
virtual void ConfigureScalarBar()
Generate/configure the scalar bar representation from laid-out geometry.
virtual void ComputeScalarBarLength()
Determine how long the scalar bar should be (on an axis parallel to the direction in which scalar val...
virtual void ConfigureTitle()
Generate/configure the title actor using the laid-out geometry.
void ShallowCopy(vtkProp *prop) override
Shallow copy of a scalar bar actor.
vtkPolyDataMapper2D * ScalarBarMapper
Mapper for ScalarBar.
vtkTexture * Texture
Color data for TexturePolyData.
vtkTypeBool DrawAnnotations
vtkScalarBarActorInternal * P
Containers shared with subclasses.
vtkActor2D * ScalarBarActor
Actor for ScalarBar.
virtual void SetBackgroundProperty(vtkProperty2D *p)
Set/Get the background property.
virtual void PrepareTitleText()
Set the title actor's input to the latest title (and subtitle) text.
vtkTimeStamp BuildTime
Internal state used for rendering.
virtual void LayoutAboveRangeSwatch()
Determine the size of the Above Range if it is to be rendered.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
virtual void SetFrameProperty(vtkProperty2D *p)
Set/Get the frame property.
virtual void LayoutForUnconstrainedFont()
This method sets the title and tick-box size and position for the UnconstrainedFontSize mode.
vtkScalarsToColors * LookupTable
The object this actor illustrates.
virtual void LayoutTicks()
Determine the size and placement of any tick marks to be rendered.
virtual void SetLabelTextProperty(vtkTextProperty *p)
Set/Get the labels text property.
Superclass for mapping scalar values to colors.
An actor that displays text.
Definition: vtkTextActor.h:51
2D text annotation
Definition: vtkTextMapper.h:48
represent text properties.
handles properties associated with a texture map
Definition: vtkTexture.h:66
actor that draws 2D data with texture support
record modification and/or execution time
Definition: vtkTimeStamp.h:33
abstract specification for Viewports
Definition: vtkViewport.h:45
window superclass for vtkRenderWindow
Definition: vtkWindow.h:35
@ range
Definition: vtkX3D.h:244
@ size
Definition: vtkX3D.h:259
int vtkTypeBool
Definition: vtkABI.h:69
#define VTK_ORIENT_VERTICAL
#define VTK_ORIENT_HORIZONTAL
#define VTK_INT_MAX
Definition: vtkType.h:155