VTK  9.5.2
vtkScalarBarActor.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2// SPDX-License-Identifier: BSD-3-Clause
46
47#ifndef vtkScalarBarActor_h
48#define vtkScalarBarActor_h
49
50#include "vtkActor2D.h"
51#include "vtkDoubleArray.h" // for ivars
52#include "vtkRenderingAnnotationModule.h" // For export macro
53#include "vtkWrappingHints.h" // For VTK_MARSHALAUTO
54
55VTK_ABI_NAMESPACE_BEGIN
56class vtkColor3ub;
58class vtkPolyData;
60class vtkProperty2D;
63class vtkTextActor;
64class vtkTextMapper;
65class vtkTextProperty;
66class vtkTexture;
68
69#define VTK_ORIENT_HORIZONTAL 0
70#define VTK_ORIENT_VERTICAL 1
71
72class VTKRENDERINGANNOTATION_EXPORT VTK_MARSHALAUTO vtkScalarBarActor : public vtkActor2D
73{
74public:
76 void PrintSelf(ostream& os, vtkIndent indent) override;
77
84
86
89 int RenderOpaqueGeometry(vtkViewport* viewport) override;
91 int RenderOverlay(vtkViewport* viewport) override;
93
98
105
111 virtual void GetScalarBarRect(int rect[4], vtkViewport* viewport);
112
114
121 vtkGetObjectMacro(LookupTable, vtkScalarsToColors);
123
125
135
137
149 vtkSetMacro(UseOpacity, vtkTypeBool);
150 vtkGetMacro(UseOpacity, vtkTypeBool);
151 vtkBooleanMacro(UseOpacity, vtkTypeBool);
153
155
160 vtkSetClampMacro(MaximumNumberOfColors, int, 2, VTK_INT_MAX);
161 vtkGetMacro(MaximumNumberOfColors, int);
163
165
168 vtkSetClampMacro(NumberOfLabels, int, 0, 64);
169 vtkGetMacro(NumberOfLabels, int);
171
173
176 virtual void SetCustomLabels(vtkDoubleArray* labels);
177 vtkGetObjectMacro(CustomLabels, vtkDoubleArray);
179
181
185 vtkGetMacro(UseCustomLabels, bool);
186 vtkSetMacro(UseCustomLabels, bool);
187 vtkBooleanMacro(UseCustomLabels, bool);
189
191
195 vtkGetMacro(Orientation, int);
199
201
204 vtkGetMacro(ForceVerticalTitle, bool);
205 vtkSetMacro(ForceVerticalTitle, bool);
207
209
215
217
223
225
231
233
237 vtkSetStringMacro(LabelFormat);
238 vtkGetStringMacro(LabelFormat);
240
242
245 vtkSetStringMacro(Title);
246 vtkGetStringMacro(Title);
248
250
253 vtkSetStringMacro(ComponentTitle);
254 vtkGetStringMacro(ComponentTitle);
256
260 void ShallowCopy(vtkProp* prop) override;
261
263
266 vtkSetMacro(TextureGridWidth, double);
267 vtkGetMacro(TextureGridWidth, double);
269
271
274 vtkGetObjectMacro(TextureActor, vtkTexturedActor2D);
276
277 enum
278 {
281 };
282
284
293 vtkGetMacro(TextPosition, int);
302
303
305
312 vtkSetMacro(MaximumWidthInPixels, int);
313 vtkGetMacro(MaximumWidthInPixels, int);
314 vtkSetMacro(MaximumHeightInPixels, int);
315 vtkGetMacro(MaximumHeightInPixels, int);
317
319
324 vtkSetMacro(AnnotationLeaderPadding, double);
325 vtkGetMacro(AnnotationLeaderPadding, double);
327
329
336 vtkBooleanMacro(DrawAnnotations, vtkTypeBool);
338
340
349
351
356 vtkSetMacro(DrawBelowRangeSwatch, bool);
357 vtkGetMacro(DrawBelowRangeSwatch, bool);
358 vtkBooleanMacro(DrawBelowRangeSwatch, bool);
360
362
365 vtkSetStringMacro(BelowRangeAnnotation);
366 vtkGetStringMacro(BelowRangeAnnotation);
368
370
375 vtkSetMacro(DrawAboveRangeSwatch, bool);
376 vtkGetMacro(DrawAboveRangeSwatch, bool);
377 vtkBooleanMacro(DrawAboveRangeSwatch, bool);
379
381
384 vtkSetStringMacro(AboveRangeAnnotation);
385 vtkGetStringMacro(AboveRangeAnnotation);
388
400
402
405 vtkSetStringMacro(NanAnnotation);
406 vtkGetStringMacro(NanAnnotation);
408
410
422
424
430 vtkBooleanMacro(DrawBackground, vtkTypeBool);
432
434
438 vtkSetMacro(DrawFrame, vtkTypeBool);
439 vtkGetMacro(DrawFrame, vtkTypeBool);
440 vtkBooleanMacro(DrawFrame, vtkTypeBool);
442
444
450 vtkBooleanMacro(DrawColorBar, vtkTypeBool);
452
454
459 vtkBooleanMacro(DrawTickLabels, vtkTypeBool);
461
463
469
471
475 vtkGetObjectMacro(FrameProperty, vtkProperty2D);
477
479
483 vtkGetMacro(TextPad, int);
484 vtkSetMacro(TextPad, int);
486
488
493 vtkGetMacro(VerticalTitleSeparation, int);
494 vtkSetMacro(VerticalTitleSeparation, int);
496
498
502 vtkGetMacro(BarRatio, double);
503 vtkSetClampMacro(BarRatio, double, 0., 1.);
505
507
513 vtkGetMacro(TitleRatio, double);
514 vtkSetClampMacro(TitleRatio, double, 0., 1.);
516
518
524 vtkSetMacro(UnconstrainedFontSize, bool);
525 vtkGetMacro(UnconstrainedFontSize, bool);
526 vtkBooleanMacro(UnconstrainedFontSize, bool);
528
529protected:
532
557 virtual void RebuildLayout(vtkViewport* viewport);
558
564 virtual int RebuildLayoutIfNeeded(vtkViewport* viewport);
565
569 virtual void FreeLayoutStorage();
570
579 virtual void ComputeFrame();
580
591
595 virtual void ComputeSwatchPad();
596
597 // This method must set this->P->NanSwatchSize and this->P->NanBox.
598 // It may depend on layout performed by ComputeScalarBarThickness.
599 virtual void LayoutNanSwatch();
600
608
616
624
628 virtual void PrepareTitleText();
629
640 virtual void LayoutTitle();
641
647
657
669 virtual void LayoutTicks();
670
678 virtual void LayoutAnnotations();
679
683 virtual void ConfigureAnnotations();
684
688 virtual void ConfigureFrame();
689
693 virtual void DrawBoxes();
694
698 virtual void ConfigureScalarBar();
699
703 virtual void ConfigureTitle();
704
708 virtual void ConfigureTicks();
709
716 virtual void ConfigureNanSwatch();
717
722 virtual void ConfigureAboveBelowRangeSwatch(bool above);
723
732 virtual void EditAnnotations() {}
733
739 virtual void SizeTitle(double* titleSize, int* size, vtkViewport* viewport);
740
745 vtkScalarsToColors* lkup, double start, double delta, const double* range);
746
751 double barX, double barY, double barWidth, double barHeight, double delta, double pad);
757 double barX, double barY, double barWidth, double barHeight, double delta, double pad);
758
766 bool UseCustomLabels = false;
767 vtkTypeBool DrawBackground; // off by default
768 vtkTypeBool DrawFrame; // off by default
769 vtkTypeBool DrawColorBar; // on by default
770 vtkTypeBool DrawTickLabels; // on by default
777 char* Title;
780 vtkTypeBool UseOpacity; // off by default
791 double BarRatio;
793 bool UnconstrainedFontSize; // off by default
794 bool ForceVerticalTitle; // off by default
795
799
803 int LastSize[2];
804 int LastOrigin[2];
805
807
810
815
822
826
831
832private:
833 vtkScalarBarActor(const vtkScalarBarActor&) = delete;
834 void operator=(const vtkScalarBarActor&) = delete;
835};
836
837VTK_ABI_NAMESPACE_END
838#endif
Some derived classes for the different colors commonly used.
Definition vtkColor.h:184
dynamic, self-adjusting array of double
a simple class to control print indentation
Definition vtkIndent.h:29
Defines a 1D piecewise function.
draw vtkPolyData onto the image plane
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition vtkPolyData.h:72
represent surface properties of a 2D image
Internal state for the scalar bar actor shared with subclasses.
virtual void LayoutNanSwatch()
vtkPolyData * Background
Polygon used to fill the background.
virtual void SetOpacityFunction(vtkPiecewiseFunction *)
Set/Get the piecewise function that denotes opacity function to map values through.
vtkTypeBool DrawFrame
User-changeable settings.
int RenderOverlay(vtkViewport *viewport) override
Draw the scalar bar and annotation text to the screen.
virtual void ComputeScalarBarThickness()
Determine how thick the scalar bar should be (on an axis perpendicular to the direction in which scal...
vtkTypeBool AnnotationTextScaling
User-changeable settings.
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.
char * LabelFormat
User-changeable settings.
virtual void ComputeFrame()
If the scalar bar should be inset into a frame or rendered with a solid background,...
vtkTypeBool DrawBackground
User-changeable settings.
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
int Orientation
User-changeable settings.
virtual void LayoutTitle()
Determine the position and size of the scalar bar title box.
char * BelowRangeAnnotation
User-changeable settings.
vtkProperty2D * BackgroundProperty
User-changeable settings.
virtual void ConfigureNanSwatch()
Generate/configure the NaN swatch using the laid-out geometry.
void SetOrientationToVertical()
Control the orientation of the scalar bar.
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.
int NumberOfLabels
User-changeable settings.
double BarRatio
User-changeable settings.
int LastSize[2]
Projected size in viewport coordinates of last build.
void SetOrientationToHorizontal()
Control the orientation of the scalar bar.
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.
int TextPosition
User-changeable settings.
int MaximumHeightInPixels
User-changeable settings.
int VerticalTitleSeparation
User-changeable settings.
double AnnotationLeaderPadding
User-changeable settings.
bool UnconstrainedFontSize
User-changeable settings.
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.
int TextPad
User-changeable settings.
vtkActor2D * FrameActor
Actor for Frame.
vtkProperty2D * FrameProperty
User-changeable settings.
vtkPolyData * TexturePolyData
Polygon colored when UseOpacity is true.
int RenderTranslucentPolygonalGeometry(vtkViewport *) override
Draw the scalar bar and annotation text to the screen.
void ReleaseGraphicsResources(vtkWindow *) override
Release any graphics resources that are being consumed by this actor.
virtual void SetTextPositionToPrecedeScalarBar()
Should the title and tick marks precede the scalar bar or succeed it?
virtual void SetTextPositionToSucceedScalarBar()
Should the title and tick marks precede the scalar bar or succeed it?
char * Title
User-changeable settings.
vtkTypeBool UseOpacity
User-changeable settings.
bool DrawBelowRangeSwatch
User-changeable settings.
virtual void LayoutAboveRangeSwatchPosn()
Determine the position of the Above Range if it is to be rendered.
int LastOrigin[2]
Projected origin (viewport coordinates) of last build.
bool ForceVerticalTitle
User-changeable settings.
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.
char * AboveRangeAnnotation
User-changeable settings.
vtkTextProperty * LabelTextProperty
Font for tick labels.
bool UseCustomLabels
User-changeable settings.
vtkDoubleArray * CustomLabels
User-changeable settings.
vtkTypeBool DrawTickLabels
User-changeable settings.
virtual void ConfigureFrame()
Generate/configure the representation of the frame from laid-out geometry.
virtual void SetCustomLabels(vtkDoubleArray *labels)
Set/Get the fixed locations to use.
vtkTypeBool FixedAnnotationLeaderLineColor
User-changeable settings.
vtkTypeBool DrawColorBar
User-changeable settings.
char * NanAnnotation
User-changeable settings.
vtkPiecewiseFunction * OpacityFunction
The opacity function if UseOpacity is true.
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
User-changeable settings.
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.
static vtkScalarBarActor * New()
Instantiate object with 64 maximum colors; 5 labels; %%-#6.3g label format, no title,...
void ShallowCopy(vtkProp *prop) override
Shallow copy of a scalar bar actor.
char * ComponentTitle
User-changeable settings.
vtkPolyDataMapper2D * ScalarBarMapper
Mapper for ScalarBar.
vtkTexture * Texture
Color data for TexturePolyData.
vtkTypeBool DrawAnnotations
User-changeable settings.
vtkScalarBarActorInternal * P
Containers shared with subclasses.
vtkActor2D * ScalarBarActor
Actor for ScalarBar.
virtual void SetBackgroundProperty(vtkProperty2D *p)
Set/Get the background property.
double TitleRatio
User-changeable settings.
virtual void PrepareTitleText()
Set the title actor's input to the latest title (and subtitle) text.
double TextureGridWidth
User-changeable settings.
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.
bool DrawAboveRangeSwatch
User-changeable settings.
virtual void SetOrientation(int)
Control the orientation of the scalar bar.
virtual void SetTextPosition(int)
Should the title and tick marks precede the scalar bar or succeed it?
int MaximumWidthInPixels
User-changeable settings.
int NumberOfLabelsBuilt
User-changeable settings.
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.
2D text annotation
represent text properties.
handles properties associated with a texture map
Definition vtkTexture.h:59
actor that draws 2D data with texture support
record modification and/or execution time
abstract specification for Viewports
Definition vtkViewport.h:47
window superclass for vtkRenderWindow
Definition vtkWindow.h:26
int vtkTypeBool
Definition vtkABI.h:64
#define VTK_ORIENT_VERTICAL
#define VTK_ORIENT_HORIZONTAL
#define VTK_INT_MAX
Definition vtkType.h:161
#define VTK_MARSHALAUTO