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 =========================================================================*/
56 #ifndef vtkScalarBarActor_h
57 #define vtkScalarBarActor_h
58 
59 #include "vtkRenderingAnnotationModule.h" // For export macro
60 #include "vtkActor2D.h"
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) VTK_OVERRIDE;
82 
88  static vtkScalarBarActor* New();
89 
91 
94  int RenderOpaqueGeometry(vtkViewport* viewport) VTK_OVERRIDE;
95  int RenderTranslucentPolygonalGeometry(vtkViewport*) VTK_OVERRIDE { return 0; };
96  int RenderOverlay(vtkViewport* viewport) VTK_OVERRIDE;
98 
102  int HasTranslucentPolygonalGeometry() VTK_OVERRIDE;
103 
109  void ReleaseGraphicsResources(vtkWindow*) VTK_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, int);
138  vtkGetMacro(UseOpacity, int);
139  vtkBooleanMacro(UseOpacity, int);
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);
167  {this->SetOrientation(VTK_ORIENT_HORIZONTAL);}
168  void SetOrientationToVertical() {this->SetOrientation(VTK_ORIENT_VERTICAL);}
170 
172 
175  virtual void SetTitleTextProperty(vtkTextProperty* p);
176  vtkGetObjectMacro(TitleTextProperty, vtkTextProperty);
178 
180 
183  virtual void SetLabelTextProperty(vtkTextProperty* p);
184  vtkGetObjectMacro(LabelTextProperty, vtkTextProperty);
186 
188 
191  virtual void SetAnnotationTextProperty(vtkTextProperty* p);
192  vtkGetObjectMacro(AnnotationTextProperty, vtkTextProperty);
194 
196 
200  vtkSetStringMacro(LabelFormat);
201  vtkGetStringMacro(LabelFormat);
203 
205 
208  vtkSetStringMacro(Title);
209  vtkGetStringMacro(Title);
211 
213 
216  vtkSetStringMacro(ComponentTitle);
217  vtkGetStringMacro(ComponentTitle);
219 
223  void ShallowCopy(vtkProp* prop) VTK_OVERRIDE;
224 
226 
229  vtkSetMacro(TextureGridWidth, double);
230  vtkGetMacro(TextureGridWidth, double);
232 
234 
237  vtkGetObjectMacro(TextureActor, vtkTexturedActor2D);
239 
240  enum { PrecedeScalarBar = 0, SucceedScalarBar };
241 
243 
251  vtkSetClampMacro(TextPosition, int, PrecedeScalarBar, SucceedScalarBar);
252  vtkGetMacro(TextPosition, int);
254  { this->SetTextPosition(vtkScalarBarActor::PrecedeScalarBar); }
256  { this->SetTextPosition(vtkScalarBarActor::SucceedScalarBar); }
258 
260 
267  vtkSetMacro(MaximumWidthInPixels, int);
268  vtkGetMacro(MaximumWidthInPixels, int);
269  vtkSetMacro(MaximumHeightInPixels, int);
270  vtkGetMacro(MaximumHeightInPixels, int);
272 
274 
279  vtkSetMacro(AnnotationLeaderPadding, double);
280  vtkGetMacro(AnnotationLeaderPadding, double);
282 
284 
289  vtkSetMacro(DrawAnnotations, int);
290  vtkGetMacro(DrawAnnotations, int);
291  vtkBooleanMacro(DrawAnnotations, int);
293 
295 
300  vtkSetMacro(DrawNanAnnotation, int);
301  vtkGetMacro(DrawNanAnnotation, int);
302  vtkBooleanMacro(DrawNanAnnotation, int);
304 
306 
311  vtkSetMacro(DrawBelowRangeSwatch, bool);
312  vtkGetMacro(DrawBelowRangeSwatch, bool);
313  vtkBooleanMacro(DrawBelowRangeSwatch, bool);
315 
317 
320  vtkSetStringMacro(BelowRangeAnnotation);
321  vtkGetStringMacro(BelowRangeAnnotation);
323 
325 
330  vtkSetMacro(DrawAboveRangeSwatch, bool);
331  vtkGetMacro(DrawAboveRangeSwatch, bool);
332  vtkBooleanMacro(DrawAboveRangeSwatch, bool);
334 
336 
339  vtkSetStringMacro(AboveRangeAnnotation);
340  vtkGetStringMacro(AboveRangeAnnotation);
342 
343 
351  vtkSetMacro(FixedAnnotationLeaderLineColor, int);
352  vtkGetMacro(FixedAnnotationLeaderLineColor, int);
353  vtkBooleanMacro(FixedAnnotationLeaderLineColor, int);
355 
357 
360  vtkSetStringMacro(NanAnnotation);
361  vtkGetStringMacro(NanAnnotation);
363 
365 
373  vtkSetMacro(AnnotationTextScaling, int);
374  vtkGetMacro(AnnotationTextScaling, int);
375  vtkBooleanMacro(AnnotationTextScaling, int);
377 
379 
383  vtkSetMacro(DrawBackground, int);
384  vtkGetMacro(DrawBackground, int);
385  vtkBooleanMacro(DrawBackground, int);
387 
389 
393  vtkSetMacro(DrawFrame, int);
394  vtkGetMacro(DrawFrame, int);
395  vtkBooleanMacro(DrawFrame, int);
397 
399 
403  vtkSetMacro(DrawColorBar, int);
404  vtkGetMacro(DrawColorBar, int);
405  vtkBooleanMacro(DrawColorBar, int);
407 
409 
412  vtkSetMacro(DrawTickLabels, int);
413  vtkGetMacro(DrawTickLabels, int);
414  vtkBooleanMacro(DrawTickLabels, int);
416 
418 
421  virtual void SetBackgroundProperty(vtkProperty2D* p);
422  vtkGetObjectMacro(BackgroundProperty, vtkProperty2D);
424 
426 
429  virtual void SetFrameProperty(vtkProperty2D* p);
430  vtkGetObjectMacro(FrameProperty, vtkProperty2D);
432 
434 
438  vtkGetMacro(TextPad, int);
439  vtkSetMacro(TextPad, int);
441 
443 
448  vtkGetMacro(VerticalTitleSeparation, int);
449  vtkSetMacro(VerticalTitleSeparation, int);
451 
453 
457  vtkGetMacro(BarRatio, double);
458  vtkSetClampMacro(BarRatio, double, 0., 1.);
460 
462 
468  vtkGetMacro(TitleRatio, double);
469  vtkSetClampMacro(TitleRatio, double, 0., 1.);
471 
473 
478  vtkSetMacro(UnconstrainedFontSize, bool);
479  vtkGetMacro(UnconstrainedFontSize, bool);
480  vtkBooleanMacro(UnconstrainedFontSize, bool);
482 
483 protected:
485  ~vtkScalarBarActor() VTK_OVERRIDE;
486 
511  virtual void RebuildLayout(vtkViewport* viewport);
512 
518  virtual int RebuildLayoutIfNeeded(vtkViewport* viewport);
519 
520 
524  virtual void FreeLayoutStorage();
525 
534  virtual void ComputeFrame();
535 
545  virtual void ComputeScalarBarThickness();
546 
550  virtual void ComputeSwatchPad();
551 
552  // This method must set this->P->NanSwatchSize and this->P->NanBox.
553  // It may depend on layout performed by ComputeScalarBarThickness.
554  virtual void LayoutNanSwatch();
555 
562  virtual void LayoutBelowRangeSwatch();
563 
570  virtual void LayoutAboveRangeSwatch();
571 
578  virtual void LayoutAboveRangeSwatchPosn();
579 
583  virtual void PrepareTitleText();
584 
595  virtual void LayoutTitle();
596 
601  virtual void LayoutForUnconstrainedFont();
602 
611  virtual void ComputeScalarBarLength();
612 
622  virtual void LayoutTicks();
623 
631  virtual void LayoutAnnotations();
632 
636  virtual void ConfigureAnnotations();
637 
641  virtual void ConfigureFrame();
642 
646  virtual void DrawBoxes();
647 
651  virtual void ConfigureScalarBar();
652 
656  virtual void ConfigureTitle();
657 
661  virtual void ConfigureTicks();
662 
669  virtual void ConfigureNanSwatch();
670 
675  virtual void ConfigureAboveBelowRangeSwatch(bool above);
676 
685  virtual void EditAnnotations() { }
686 
692  virtual void SizeTitle(double* titleSize, int* size, vtkViewport* viewport);
693 
697  int MapAnnotationLabels(
698  vtkScalarsToColors* lkup, double start, double delta, const double* range);
699 
703  int PlaceAnnotationsVertically(
704  double barX, double barY, double barWidth, double barHeight,
705  double delta, double pad);
709  int PlaceAnnotationsHorizontally(
710  double barX, double barY, double barWidth, double barHeight,
711  double delta, double pad);
712 
714 
719  int DrawBackground; // off by default
720  int DrawFrame; // off by default
721  int DrawColorBar; // on by default
722  int DrawTickLabels; // on by default
725  int AnnotationTextScaling; // off by default
729  char* Title;
731  char* LabelFormat;
732  int UseOpacity; // off by default
741  int TextPad;
743  double BarRatio;
744  double TitleRatio;
745  bool UnconstrainedFontSize; // off by default
746 
750 
752 
754  int LastSize[2];
755  int LastOrigin[2];
756 
758 
760 
765 
772 
776 
780 
781 
782 private:
783  vtkScalarBarActor(const vtkScalarBarActor&) VTK_DELETE_FUNCTION;
784  void operator=(const vtkScalarBarActor&) VTK_DELETE_FUNCTION;
785 };
786 
787 #endif
788 
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:44
int TextPad
User-changeable settings.
int DrawNanAnnotation
User-changeable settings.
int MaximumWidthInPixels
User-changeable settings.
int DrawTickLabels
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.
actor that draws 2D data with texture support
vtkPolyDataMapper2D * ScalarBarMapper
Mapper for ScalarBar.
int DrawFrame
User-changeable settings.
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:157
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 UseOpacity
User-changeable settings.
int VerticalTitleSeparation
User-changeable settings.
int DrawColorBar
User-changeable settings.
char * AboveRangeAnnotation
User-changeable settings.
int AnnotationTextScaling
User-changeable settings.
concrete dataset represents vertices, lines, polygons, and triangle strips
Definition: vtkPolyData.h:79
double TextureGridWidth
User-changeable settings.
void ShallowCopy(vtkProp *prop) override
Shallow copy of this vtkActor2D.
vtkTexture * Texture
Color data for TexturePolyData.
int FixedAnnotationLeaderLineColor
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.
char * Title
User-changeable settings.
Superclass for mapping scalar values to colors.
window superclass for vtkRenderWindow
Definition: vtkWindow.h:34
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.
int HasTranslucentPolygonalGeometry() override
Does this prop have some translucent polygonal geometry?
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:64
vtkGetStringMacro(ExtensionsString)
Returns a string listing all available extensions.
int Orientation
User-changeable settings.
int TextPosition
User-changeable settings.
vtkPolyData * ScalarBar
Polygon(s) colored by LookupTable.
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.
vtkSetMacro(IgnoreDriverBugs, bool)
When set known driver bugs are ignored during driver feature detection.
vtkTextProperty * TitleTextProperty
Font for the legend title.
int MaximumNumberOfColors
User-changeable settings.
char * NanAnnotation
User-changeable settings.
double BarRatio
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.
int DrawBackground
User-changeable settings.
bool DrawAboveRangeSwatch
User-changeable settings.
vtkBooleanMacro(IgnoreDriverBugs, bool)
When set known driver bugs are ignored during driver feature detection.
void SetOrientationToHorizontal()
Control the orientation of the scalar bar.
vtkProperty2D * FrameProperty
User-changeable settings.
bool UnconstrainedFontSize
User-changeable settings.
int DrawAnnotations
User-changeable settings.
vtkPolyData * Frame
Polyline used to highlight frame.
draw vtkPolyData onto the image plane
vtkPolyData * TexturePolyData
Polygon colored when UseOpacity is true.
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkTexturedActor2D * TextureActor
Actor for TexturePolyData.