VTK
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 =========================================================================*/
59 #ifndef vtkScalarBarActor_h
60 #define vtkScalarBarActor_h
61 
62 #include "vtkRenderingAnnotationModule.h" // For export macro
63 #include "vtkActor2D.h"
64 
65 class vtkColor3ub;
66 class vtkPolyData;
68 class vtkProperty2D;
69 class vtkScalarsToColors;
71 class vtkTextActor;
72 class vtkTextMapper;
73 class vtkTextProperty;
74 class vtkTexture;
75 class vtkTexturedActor2D;
76 
77 #define VTK_ORIENT_HORIZONTAL 0
78 #define VTK_ORIENT_VERTICAL 1
79 
80 class VTKRENDERINGANNOTATION_EXPORT vtkScalarBarActor : public vtkActor2D
81 {
82 public:
83  vtkTypeMacro(vtkScalarBarActor, vtkActor2D);
84  void PrintSelf(ostream& os, vtkIndent indent) VTK_OVERRIDE;
85 
92 
94 
97  int RenderOpaqueGeometry(vtkViewport* viewport) VTK_OVERRIDE;
98  virtual int RenderTranslucentPolygonalGeometry(vtkViewport*) VTK_OVERRIDE { return 0; };
99  int RenderOverlay(vtkViewport* viewport) VTK_OVERRIDE;
101 
105  virtual int HasTranslucentPolygonalGeometry() VTK_OVERRIDE;
106 
112  virtual void ReleaseGraphicsResources(vtkWindow*) VTK_OVERRIDE;
113 
119  virtual void GetScalarBarRect(int rect[4], vtkViewport* viewport);
120 
122 
128  virtual void SetLookupTable(vtkScalarsToColors*);
129  vtkGetObjectMacro(LookupTable, vtkScalarsToColors);
131 
133 
140  vtkSetMacro(UseOpacity, int);
141  vtkGetMacro(UseOpacity, int);
142  vtkBooleanMacro(UseOpacity, int);
144 
146 
151  vtkSetClampMacro(MaximumNumberOfColors, int, 2, VTK_INT_MAX);
152  vtkGetMacro(MaximumNumberOfColors, int);
154 
156 
159  vtkSetClampMacro(NumberOfLabels, int, 0, 64);
160  vtkGetMacro(NumberOfLabels, int);
162 
164 
167  vtkSetClampMacro(Orientation, int, VTK_ORIENT_HORIZONTAL, VTK_ORIENT_VERTICAL);
168  vtkGetMacro(Orientation, int);
169  void SetOrientationToHorizontal()
170  {this->SetOrientation(VTK_ORIENT_HORIZONTAL);}
171  void SetOrientationToVertical() {this->SetOrientation(VTK_ORIENT_VERTICAL);}
173 
175 
179  vtkGetObjectMacro(TitleTextProperty, vtkTextProperty);
181 
183 
187  vtkGetObjectMacro(LabelTextProperty, vtkTextProperty);
189 
191 
195  vtkGetObjectMacro(AnnotationTextProperty, vtkTextProperty);
197 
199 
203  vtkSetStringMacro(LabelFormat);
204  vtkGetStringMacro(LabelFormat);
206 
208 
211  vtkSetStringMacro(Title);
214 
216 
219  vtkSetStringMacro(ComponentTitle);
220  vtkGetStringMacro(ComponentTitle);
222 
226  void ShallowCopy(vtkProp* prop) VTK_OVERRIDE;
227 
229 
232  vtkSetMacro(TextureGridWidth, double);
233  vtkGetMacro(TextureGridWidth, double);
235 
237 
240  vtkGetObjectMacro(TextureActor, vtkTexturedActor2D);
242 
243  enum { PrecedeScalarBar = 0, SucceedScalarBar };
244 
246 
254  vtkSetClampMacro(TextPosition, int, PrecedeScalarBar, SucceedScalarBar);
255  vtkGetMacro(TextPosition, int);
257  { this->SetTextPosition(vtkScalarBarActor::PrecedeScalarBar); }
259  { this->SetTextPosition(vtkScalarBarActor::SucceedScalarBar); }
261 
263 
270  vtkSetMacro(MaximumWidthInPixels, int);
271  vtkGetMacro(MaximumWidthInPixels, int);
272  vtkSetMacro(MaximumHeightInPixels, int);
273  vtkGetMacro(MaximumHeightInPixels, int);
275 
277 
282  vtkSetMacro(AnnotationLeaderPadding, double);
283  vtkGetMacro(AnnotationLeaderPadding, double);
285 
287 
292  vtkSetMacro(DrawAnnotations, int);
293  vtkGetMacro(DrawAnnotations, int);
294  vtkBooleanMacro(DrawAnnotations, int);
296 
298 
303  vtkSetMacro(DrawNanAnnotation, int);
304  vtkGetMacro(DrawNanAnnotation, int);
305  vtkBooleanMacro(DrawNanAnnotation, int);
307 
309 
314  vtkSetMacro(DrawBelowRangeSwatch, bool);
315  vtkGetMacro(DrawBelowRangeSwatch, bool);
316  vtkBooleanMacro(DrawBelowRangeSwatch, bool);
318 
320 
323  vtkSetStringMacro(BelowRangeAnnotation);
324  vtkGetStringMacro(BelowRangeAnnotation);
326 
328 
333  vtkSetMacro(DrawAboveRangeSwatch, bool);
334  vtkGetMacro(DrawAboveRangeSwatch, bool);
335  vtkBooleanMacro(DrawAboveRangeSwatch, bool);
337 
339 
342  vtkSetStringMacro(AboveRangeAnnotation);
343  vtkGetStringMacro(AboveRangeAnnotation);
345 
346 
354  vtkSetMacro(FixedAnnotationLeaderLineColor, int);
355  vtkGetMacro(FixedAnnotationLeaderLineColor, int);
356  vtkBooleanMacro(FixedAnnotationLeaderLineColor, int);
358 
360 
363  vtkSetStringMacro(NanAnnotation);
364  vtkGetStringMacro(NanAnnotation);
366 
368 
376  vtkSetMacro(AnnotationTextScaling, int);
377  vtkGetMacro(AnnotationTextScaling, int);
378  vtkBooleanMacro(AnnotationTextScaling, int);
380 
382 
386  vtkSetMacro(DrawBackground, int);
387  vtkGetMacro(DrawBackground, int);
388  vtkBooleanMacro(DrawBackground, int);
390 
392 
396  vtkSetMacro(DrawFrame, int);
397  vtkGetMacro(DrawFrame, int);
398  vtkBooleanMacro(DrawFrame, int);
400 
402 
406  vtkSetMacro(DrawColorBar, int);
407  vtkGetMacro(DrawColorBar, int);
408  vtkBooleanMacro(DrawColorBar, int);
410 
412 
415  vtkSetMacro(DrawTickLabels, int);
416  vtkGetMacro(DrawTickLabels, int);
417  vtkBooleanMacro(DrawTickLabels, int);
419 
421 
425  vtkGetObjectMacro(BackgroundProperty, vtkProperty2D);
427 
429 
432  virtual void SetFrameProperty(vtkProperty2D* p);
433  vtkGetObjectMacro(FrameProperty, vtkProperty2D);
435 
437 
441  vtkGetMacro(TextPad, int);
442  vtkSetMacro(TextPad, int);
444 
446 
451  vtkGetMacro(VerticalTitleSeparation, int);
452  vtkSetMacro(VerticalTitleSeparation, int);
454 
456 
460  vtkGetMacro(BarRatio, double);
461  vtkSetClampMacro(BarRatio, double, 0., 1.);
463 
465 
471  vtkGetMacro(TitleRatio, double);
472  vtkSetClampMacro(TitleRatio, double, 0., 1.);
474 
476 
481  vtkSetMacro(UnconstrainedFontSize, bool);
482  vtkGetMacro(UnconstrainedFontSize, bool);
483  vtkBooleanMacro(UnconstrainedFontSize, bool);
485 
486 protected:
489 
514  virtual void RebuildLayout(vtkViewport* viewport);
515 
521  virtual int RebuildLayoutIfNeeded(vtkViewport* viewport);
522 
523 
527  virtual void FreeLayoutStorage();
528 
537  virtual void ComputeFrame();
538 
549 
553  virtual void ComputeSwatchPad();
554 
555  // This method must set this->P->NanSwatchSize and this->P->NanBox.
556  // It may depend on layout performed by ComputeScalarBarThickness.
557  virtual void LayoutNanSwatch();
558 
565  virtual void LayoutBelowRangeSwatch();
566 
573  virtual void LayoutAboveRangeSwatch();
574 
582 
586  virtual void PrepareTitleText();
587 
598  virtual void LayoutTitle();
599 
605 
614  virtual void ComputeScalarBarLength();
615 
625  virtual void LayoutTicks();
626 
634  virtual void LayoutAnnotations();
635 
639  virtual void ConfigureAnnotations();
640 
644  virtual void ConfigureFrame();
645 
649  virtual void DrawBoxes();
650 
654  virtual void ConfigureScalarBar();
655 
659  virtual void ConfigureTitle();
660 
664  virtual void ConfigureTicks();
665 
672  virtual void ConfigureNanSwatch();
673 
678  virtual void ConfigureAboveBelowRangeSwatch(bool above);
679 
688  virtual void EditAnnotations() { }
689 
695  virtual void SizeTitle(double* titleSize, int* size, vtkViewport* viewport);
696 
701  vtkScalarsToColors* lkup, double start, double delta, const double* range);
702 
707  double barX, double barY, double barWidth, double barHeight,
708  double delta, double pad);
713  double barX, double barY, double barWidth, double barHeight,
714  double delta, double pad);
715 
717 
722  int DrawBackground; // off by default
723  int DrawFrame; // off by default
724  int DrawColorBar; // on by default
725  int DrawTickLabels; // on by default
728  int AnnotationTextScaling; // off by default
732  char* Title;
734  char* LabelFormat;
735  int UseOpacity; // off by default
744  int TextPad;
746  double BarRatio;
747  double TitleRatio;
748  bool UnconstrainedFontSize; // off by default
749 
753 
755 
757  int LastSize[2];
758  int LastOrigin[2];
759 
761 
763 
768 
775 
779 
784 
785 private:
786  vtkScalarBarActor(const vtkScalarBarActor&) VTK_DELETE_FUNCTION;
787  void operator=(const vtkScalarBarActor&) VTK_DELETE_FUNCTION;
788 };
789 
790 #endif
791 
a actor that draws 2D data
Definition: vtkActor2D.h:46
Some derived classes for the different colors commonly used.
Definition: vtkColor.h:195
a simple class to control print indentation
Definition: vtkIndent.h:40
draw vtkPolyData onto the image plane
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:86
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:48
represent surface properties of a 2D image
Definition: vtkProperty2D.h:41
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
Support the standard render methods.
virtual void ComputeScalarBarThickness()
Determine how thick the scalar bar should be (on an axis perpendicular to the direction in which scal...
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,...
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.
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.
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.
virtual int HasTranslucentPolygonalGeometry() override
Does this prop have some translucent polygonal geometry?
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.
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.
vtkTextProperty * LabelTextProperty
Font for tick labels.
virtual void ConfigureFrame()
Generate/configure the representation of the frame from laid-out geometry.
vtkPolyDataMapper2D * BackgroundMapper
Mapper for Background.
virtual void SetTitleTextProperty(vtkTextProperty *p)
Set/Get the title text property.
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.
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.
virtual int RenderTranslucentPolygonalGeometry(vtkViewport *) override
void ShallowCopy(vtkProp *prop) override
Shallow copy of a scalar bar actor.
vtkPolyDataMapper2D * ScalarBarMapper
Mapper for ScalarBar.
vtkTexture * Texture
Color data for TexturePolyData.
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:57
2D text annotation
Definition: vtkTextMapper.h:54
represent text properties.
handles properties associated with a texture map
Definition: vtkTexture.h:71
actor that draws 2D data with texture support
record modification and/or execution time
Definition: vtkTimeStamp.h:36
abstract specification for Viewports
Definition: vtkViewport.h:48
window superclass for vtkRenderWindow
Definition: vtkWindow.h:35
@ range
Definition: vtkX3D.h:238
@ size
Definition: vtkX3D.h:253
vtkSetMacro(IgnoreDriverBugs, bool)
Updates the extensions string.
vtkBooleanMacro(IgnoreDriverBugs, bool)
Updates the extensions string.
vtkGetStringMacro(ExtensionsString)
Returns a string listing all available extensions.
#define VTK_ORIENT_VERTICAL
#define VTK_ORIENT_HORIZONTAL
#define VTK_INT_MAX
Definition: vtkType.h:153