VTK  9.2.6
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=========================================================================*/
168#ifndef vtkScalarBarActor_h
169#define vtkScalarBarActor_h
170
171#include "vtkActor2D.h"
172#include "vtkDoubleArray.h" // for ivars
173#include "vtkRenderingAnnotationModule.h" // For export macro
174
175class vtkColor3ub;
176class vtkPolyData;
178class vtkProperty2D;
181class vtkTextActor;
182class vtkTextMapper;
183class vtkTextProperty;
184class vtkTexture;
186
187#define VTK_ORIENT_HORIZONTAL 0
188#define VTK_ORIENT_VERTICAL 1
189
190class VTKRENDERINGANNOTATION_EXPORT vtkScalarBarActor : public vtkActor2D
191{
192public:
194 void PrintSelf(ostream& os, vtkIndent indent) override;
195
202
204
207 int RenderOpaqueGeometry(vtkViewport* viewport) override;
209 int RenderOverlay(vtkViewport* viewport) override;
211
216
223
229 virtual void GetScalarBarRect(int rect[4], vtkViewport* viewport);
230
232
239 vtkGetObjectMacro(LookupTable, vtkScalarsToColors);
241
243
250 vtkSetMacro(UseOpacity, vtkTypeBool);
251 vtkGetMacro(UseOpacity, vtkTypeBool);
252 vtkBooleanMacro(UseOpacity, vtkTypeBool);
254
256
261 vtkSetClampMacro(MaximumNumberOfColors, int, 2, VTK_INT_MAX);
262 vtkGetMacro(MaximumNumberOfColors, int);
264
266
269 vtkSetClampMacro(NumberOfLabels, int, 0, 64);
270 vtkGetMacro(NumberOfLabels, int);
272
274
277 virtual void SetCustomLabels(vtkDoubleArray* labels);
278 vtkGetObjectMacro(CustomLabels, vtkDoubleArray);
280
282
286 vtkGetMacro(UseCustomLabels, bool);
287 vtkSetMacro(UseCustomLabels, bool);
288 vtkBooleanMacro(UseCustomLabels, bool);
290
292
295 vtkSetClampMacro(Orientation, int, VTK_ORIENT_HORIZONTAL, VTK_ORIENT_VERTICAL);
296 vtkGetMacro(Orientation, int);
297 void SetOrientationToHorizontal() { this->SetOrientation(VTK_ORIENT_HORIZONTAL); }
298 void SetOrientationToVertical() { this->SetOrientation(VTK_ORIENT_VERTICAL); }
300
302
306 vtkGetObjectMacro(TitleTextProperty, vtkTextProperty);
308
310
314 vtkGetObjectMacro(LabelTextProperty, vtkTextProperty);
316
318
322 vtkGetObjectMacro(AnnotationTextProperty, vtkTextProperty);
324
326
330 vtkSetStringMacro(LabelFormat);
331 vtkGetStringMacro(LabelFormat);
333
335
338 vtkSetStringMacro(Title);
339 vtkGetStringMacro(Title);
341
343
346 vtkSetStringMacro(ComponentTitle);
347 vtkGetStringMacro(ComponentTitle);
349
353 void ShallowCopy(vtkProp* prop) override;
354
356
359 vtkSetMacro(TextureGridWidth, double);
360 vtkGetMacro(TextureGridWidth, double);
362
364
367 vtkGetObjectMacro(TextureActor, vtkTexturedActor2D);
369
370 enum
371 {
372 PrecedeScalarBar = 0,
373 SucceedScalarBar
374 };
375
377
385 vtkSetClampMacro(TextPosition, int, PrecedeScalarBar, SucceedScalarBar);
386 vtkGetMacro(TextPosition, int);
388 {
389 this->SetTextPosition(vtkScalarBarActor::PrecedeScalarBar);
390 }
392 {
393 this->SetTextPosition(vtkScalarBarActor::SucceedScalarBar);
394 }
396
398
405 vtkSetMacro(MaximumWidthInPixels, int);
406 vtkGetMacro(MaximumWidthInPixels, int);
407 vtkSetMacro(MaximumHeightInPixels, int);
408 vtkGetMacro(MaximumHeightInPixels, int);
410
412
417 vtkSetMacro(AnnotationLeaderPadding, double);
418 vtkGetMacro(AnnotationLeaderPadding, double);
420
422
427 vtkSetMacro(DrawAnnotations, vtkTypeBool);
428 vtkGetMacro(DrawAnnotations, vtkTypeBool);
429 vtkBooleanMacro(DrawAnnotations, vtkTypeBool);
431
433
438 vtkSetMacro(DrawNanAnnotation, vtkTypeBool);
439 vtkGetMacro(DrawNanAnnotation, vtkTypeBool);
440 vtkBooleanMacro(DrawNanAnnotation, vtkTypeBool);
442
444
449 vtkSetMacro(DrawBelowRangeSwatch, bool);
450 vtkGetMacro(DrawBelowRangeSwatch, bool);
451 vtkBooleanMacro(DrawBelowRangeSwatch, bool);
453
455
458 vtkSetStringMacro(BelowRangeAnnotation);
459 vtkGetStringMacro(BelowRangeAnnotation);
461
463
468 vtkSetMacro(DrawAboveRangeSwatch, bool);
469 vtkGetMacro(DrawAboveRangeSwatch, bool);
470 vtkBooleanMacro(DrawAboveRangeSwatch, bool);
472
474
477 vtkSetStringMacro(AboveRangeAnnotation);
478 vtkGetStringMacro(AboveRangeAnnotation);
481
489 vtkSetMacro(FixedAnnotationLeaderLineColor, vtkTypeBool);
490 vtkGetMacro(FixedAnnotationLeaderLineColor, vtkTypeBool);
491 vtkBooleanMacro(FixedAnnotationLeaderLineColor, vtkTypeBool);
493
495
498 vtkSetStringMacro(NanAnnotation);
499 vtkGetStringMacro(NanAnnotation);
501
503
511 vtkSetMacro(AnnotationTextScaling, vtkTypeBool);
512 vtkGetMacro(AnnotationTextScaling, vtkTypeBool);
513 vtkBooleanMacro(AnnotationTextScaling, vtkTypeBool);
515
517
521 vtkSetMacro(DrawBackground, vtkTypeBool);
522 vtkGetMacro(DrawBackground, vtkTypeBool);
523 vtkBooleanMacro(DrawBackground, vtkTypeBool);
525
527
531 vtkSetMacro(DrawFrame, vtkTypeBool);
532 vtkGetMacro(DrawFrame, vtkTypeBool);
533 vtkBooleanMacro(DrawFrame, vtkTypeBool);
535
537
541 vtkSetMacro(DrawColorBar, vtkTypeBool);
542 vtkGetMacro(DrawColorBar, vtkTypeBool);
543 vtkBooleanMacro(DrawColorBar, vtkTypeBool);
545
547
550 vtkSetMacro(DrawTickLabels, vtkTypeBool);
551 vtkGetMacro(DrawTickLabels, vtkTypeBool);
552 vtkBooleanMacro(DrawTickLabels, vtkTypeBool);
554
556
560 vtkGetObjectMacro(BackgroundProperty, vtkProperty2D);
562
564
568 vtkGetObjectMacro(FrameProperty, vtkProperty2D);
570
572
576 vtkGetMacro(TextPad, int);
577 vtkSetMacro(TextPad, int);
579
581
586 vtkGetMacro(VerticalTitleSeparation, int);
587 vtkSetMacro(VerticalTitleSeparation, int);
589
591
595 vtkGetMacro(BarRatio, double);
596 vtkSetClampMacro(BarRatio, double, 0., 1.);
598
600
606 vtkGetMacro(TitleRatio, double);
607 vtkSetClampMacro(TitleRatio, double, 0., 1.);
609
611
617 vtkSetMacro(UnconstrainedFontSize, bool);
618 vtkGetMacro(UnconstrainedFontSize, bool);
619 vtkBooleanMacro(UnconstrainedFontSize, bool);
621
622protected:
625
650 virtual void RebuildLayout(vtkViewport* viewport);
651
657 virtual int RebuildLayoutIfNeeded(vtkViewport* viewport);
658
662 virtual void FreeLayoutStorage();
663
672 virtual void ComputeFrame();
673
684
688 virtual void ComputeSwatchPad();
689
690 // This method must set this->P->NanSwatchSize and this->P->NanBox.
691 // It may depend on layout performed by ComputeScalarBarThickness.
692 virtual void LayoutNanSwatch();
693
701
709
717
721 virtual void PrepareTitleText();
722
733 virtual void LayoutTitle();
734
740
750
762 virtual void LayoutTicks();
763
771 virtual void LayoutAnnotations();
772
776 virtual void ConfigureAnnotations();
777
781 virtual void ConfigureFrame();
782
786 virtual void DrawBoxes();
787
791 virtual void ConfigureScalarBar();
792
796 virtual void ConfigureTitle();
797
801 virtual void ConfigureTicks();
802
809 virtual void ConfigureNanSwatch();
810
815 virtual void ConfigureAboveBelowRangeSwatch(bool above);
816
825 virtual void EditAnnotations() {}
826
832 virtual void SizeTitle(double* titleSize, int* size, vtkViewport* viewport);
833
838 vtkScalarsToColors* lkup, double start, double delta, const double* range);
839
844 double barX, double barY, double barWidth, double barHeight, double delta, double pad);
850 double barX, double barY, double barWidth, double barHeight, double delta, double pad);
851
858 vtkDoubleArray* CustomLabels = nullptr;
859 bool UseCustomLabels = false;
860 vtkTypeBool DrawBackground; // off by default
861 vtkTypeBool DrawFrame; // off by default
862 vtkTypeBool DrawColorBar; // on by default
863 vtkTypeBool DrawTickLabels; // on by default
870 char* Title;
873 vtkTypeBool UseOpacity; // off by default
884 double BarRatio;
886 bool UnconstrainedFontSize; // off by default
887
891
895 int LastSize[2];
896 int LastOrigin[2];
897
899
901
906
913
917
922
923private:
924 vtkScalarBarActor(const vtkScalarBarActor&) = delete;
925 void operator=(const vtkScalarBarActor&) = delete;
926};
927
928#endif
a actor that draws 2D data
Definition: vtkActor2D.h:155
Some derived classes for the different colors commonly used.
Definition: vtkColor.h:304
dynamic, self-adjusting array of double
a simple class to control print indentation
Definition: vtkIndent.h:119
draw vtkPolyData onto the image plane
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:200
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:73
represent surface properties of a 2D image
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.
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.
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? This is measured along the view...
virtual void SetTextPositionToSucceedScalarBar()
Should the title and tick marks precede the scalar bar or succeed it? This is measured along the view...
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.
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.
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.
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.
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.
Definition: vtkTextActor.h:166
2D text annotation
represent text properties.
handles properties associated with a texture map
Definition: vtkTexture.h:178
actor that draws 2D data with texture support
record modification and/or execution time
Definition: vtkTimeStamp.h:55
abstract specification for Viewports
Definition: vtkViewport.h:56
window superclass for vtkRenderWindow
Definition: vtkWindow.h:36
@ 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