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 =========================================================================*/
15 /**
16  * @class   vtkScalarBarActor
17  * @brief   Create a scalar bar with labels
18  *
19  * vtkScalarBarActor creates a scalar bar with tick marks. A scalar
20  * bar is a legend that indicates to the viewer the correspondence between
21  * color value and data value. The legend consists of a rectangular bar
22  * made of rectangular pieces each colored a constant value. Since
23  * vtkScalarBarActor is a subclass of vtkActor2D, it is drawn in the image
24  * plane (i.e., in the renderer's viewport) on top of the 3D graphics window.
25  *
26  * To use vtkScalarBarActor you must associate a vtkScalarsToColors (or
27  * subclass) with it. The lookup table defines the colors and the
28  * range of scalar values used to map scalar data.  Typically, the
29  * number of colors shown in the scalar bar is not equal to the number
30  * of colors in the lookup table, in which case sampling of
31  * the lookup table is performed.
32  *
33  * Other optional capabilities include specifying the fraction of the
34  * viewport size (both x and y directions) which will control the size
35  * of the scalar bar and the number of tick labels. The actual position
36  * of the scalar bar on the screen is controlled by using the
37  * vtkActor2D::SetPosition() method (by default the scalar bar is
38  * centered in the viewport).  Other features include the ability to
39  * orient the scalar bar horizontally of vertically and controlling
40  * the format (printf style) with which to print the labels on the
41  * scalar bar. Also, the vtkScalarBarActor's property is applied to
42  * the scalar bar and annotations (including layer, and
43  * compositing operator).
44  *
45  * Set the text property/attributes of the title and the labels through the
46  * vtkTextProperty objects associated to this actor.
47  *
48  * @warning
49  * If a vtkLogLookupTable is specified as the lookup table to use, then the
50  * labels are created using a logarithmic scale.
51  *
52  * @sa
53  * vtkActor2D vtkTextProperty vtkTextMapper vtkPolyDataMapper2D
54  */
55 
56 #ifndef vtkScalarBarActor_h
57 #define vtkScalarBarActor_h
58 
59 #include "vtkActor2D.h"
60 #include "vtkDoubleArray.h"               // for ivars
61 #include "vtkRenderingAnnotationModule.h" // For export macro
62 
63 class vtkColor3ub;
64 class vtkPolyData;
65 class vtkPolyDataMapper2D;
66 class vtkProperty2D;
67 class vtkScalarsToColors;
68 class vtkScalarBarActorInternal;
69 class vtkTextActor;
70 class vtkTextMapper;
71 class vtkTextProperty;
72 class vtkTexture;
73 class vtkTexturedActor2D;
74 
75 #define VTK_ORIENT_HORIZONTAL 0
76 #define VTK_ORIENT_VERTICAL 1
77 
78 class VTKRENDERINGANNOTATION_EXPORT vtkScalarBarActor : public vtkActor2D
79 {
80 public:
81   vtkTypeMacro(vtkScalarBarActor, vtkActor2D);
82   void PrintSelf(ostream& os, vtkIndent indent) override;
83 
84   /**
85    * Instantiate object with 64 maximum colors; 5 labels; %%-#6.3g label
86    * format, no title, and vertical orientation. The initial scalar bar
87    * size is (0.05 x 0.8) of the viewport size.
88    */
89   static vtkScalarBarActor* New();
90 
91   ///@{
92   /**
93    * Draw the scalar bar and annotation text to the screen.
94    */
95   int RenderOpaqueGeometry(vtkViewport* viewport) override;
RenderTranslucentPolygonalGeometry(vtkViewport *)96   int RenderTranslucentPolygonalGeometry(vtkViewport*) override { return 0; }
97   int RenderOverlay(vtkViewport* viewport) override;
98   ///@}
99 
100   /**
101    * Does this prop have some translucent polygonal geometry?
102    */
103   vtkTypeBool HasTranslucentPolygonalGeometry() override;
104 
105   /**
106    * Release any graphics resources that are being consumed by this actor.
107    * The parameter window could be used to determine which graphic
108    * resources to release.
109    */
110   void ReleaseGraphicsResources(vtkWindow*) override;
111 
112   /**
113    * Fills rect with the dimensions of the scalar bar in viewport coordinates.
114    * Only the color bar is considered -- text labels are not considered.
115    * rect is {xmin, xmax, width, height}
116    */
117   virtual void GetScalarBarRect(int rect[4], vtkViewport* viewport);
118 
119   ///@{
120   /**
121    * Set/Get the lookup table to use. The lookup table specifies the number
122    * of colors to use in the table (if not overridden), the scalar range,
123    * and any annotated values.
124    * Annotated values are rendered using vtkTextActor.
125    */
126   virtual void SetLookupTable(vtkScalarsToColors*);
127   vtkGetObjectMacro(LookupTable, vtkScalarsToColors);
128   ///@}
129 
130   ///@{
131   /**
132    * Should be display the opacity as well. This is displayed by changing
133    * the opacity of the scalar bar in accordance with the opacity of the
134    * given color. For clarity, a texture grid is placed in the background
135    * if Opacity is ON. You might also want to play with SetTextureGridWith
136    * in that case. [Default: off]
137    */
138   vtkSetMacro(UseOpacity, vtkTypeBool);
139   vtkGetMacro(UseOpacity, vtkTypeBool);
140   vtkBooleanMacro(UseOpacity, vtkTypeBool);
141   ///@}
142 
143   ///@{
144   /**
145    * Set/Get the maximum number of scalar bar segments to show. This may
146    * differ from the number of colors in the lookup table, in which case
147    * the colors are samples from the lookup table.
148    */
149   vtkSetClampMacro(MaximumNumberOfColors, int, 2, VTK_INT_MAX);
150   vtkGetMacro(MaximumNumberOfColors, int);
151   ///@}
152 
153   ///@{
154   /**
155    * Set/Get the number of automatic tick labels to show.
156    */
157   vtkSetClampMacro(NumberOfLabels, int, 0, 64);
158   vtkGetMacro(NumberOfLabels, int);
159   ///@}
160 
161   ///@{
162   /**
163    * Set/Get the fixed locations to use.
164    */
165   virtual void SetCustomLabels(vtkDoubleArray* labels);
166   vtkGetObjectMacro(CustomLabels, vtkDoubleArray);
167   ///@}
168 
169   ///@{
170   /**
171    * Get/Set whether custom labels will be used.
172    * bonds. Default: Off.
173    */
174   vtkGetMacro(UseCustomLabels, bool);
175   vtkSetMacro(UseCustomLabels, bool);
176   vtkBooleanMacro(UseCustomLabels, bool);
177   ///@}
178 
179   ///@{
180   /**
181    * Control the orientation of the scalar bar.
182    */
183   vtkSetClampMacro(Orientation, int, VTK_ORIENT_HORIZONTAL, VTK_ORIENT_VERTICAL);
184   vtkGetMacro(Orientation, int);
SetOrientationToHorizontal()185   void SetOrientationToHorizontal() { this->SetOrientation(VTK_ORIENT_HORIZONTAL); }
SetOrientationToVertical()186   void SetOrientationToVertical() { this->SetOrientation(VTK_ORIENT_VERTICAL); }
187   ///@}
188 
189   ///@{
190   /**
191    * Set/Get the title text property.
192    */
193   virtual void SetTitleTextProperty(vtkTextProperty* p);
194   vtkGetObjectMacro(TitleTextProperty, vtkTextProperty);
195   ///@}
196 
197   ///@{
198   /**
199    * Set/Get the labels text property.
200    */
201   virtual void SetLabelTextProperty(vtkTextProperty* p);
202   vtkGetObjectMacro(LabelTextProperty, vtkTextProperty);
203   ///@}
204 
205   ///@{
206   /**
207    * Set/Get the annotation text property.
208    */
209   virtual void SetAnnotationTextProperty(vtkTextProperty* p);
210   vtkGetObjectMacro(AnnotationTextProperty, vtkTextProperty);
211   ///@}
212 
213   ///@{
214   /**
215    * Set/Get the format with which to print the labels on the scalar
216    * bar.
217    */
218   vtkSetStringMacro(LabelFormat);
219   vtkGetStringMacro(LabelFormat);
220   ///@}
221 
222   ///@{
223   /**
224    * Set/Get the title of the scalar bar actor,
225    */
226   vtkSetStringMacro(Title);
227   vtkGetStringMacro(Title);
228   ///@}
229 
230   ///@{
231   /**
232    * Set/Get the title for the component that is selected,
233    */
234   vtkSetStringMacro(ComponentTitle);
235   vtkGetStringMacro(ComponentTitle);
236   ///@}
237 
238   /**
239    * Shallow copy of a scalar bar actor. Overloads the virtual vtkProp method.
240    */
241   void ShallowCopy(vtkProp* prop) override;
242 
243   ///@{
244   /**
245    * Set the width of the texture grid. Used only if UseOpacity is ON.
246    */
247   vtkSetMacro(TextureGridWidth, double);
248   vtkGetMacro(TextureGridWidth, double);
249   ///@}
250 
251   ///@{
252   /**
253    * Get the texture actor.. you may want to change some properties on it
254    */
255   vtkGetObjectMacro(TextureActor, vtkTexturedActor2D);
256   ///@}
257 
258   enum
259   {
260     PrecedeScalarBar = 0,
261     SucceedScalarBar
262   };
263 
264   ///@{
265   /**
266    * Should the title and tick marks precede the scalar bar or succeed it?
267    * This is measured along the viewport coordinate direction perpendicular
268    * to the long axis of the scalar bar, not the reading direction.
269    * Thus, succeed implies the that the text is above scalar bar if
270    * the orientation is horizontal or right of scalar bar if the orientation
271    * is vertical. Precede is the opposite.
272    */
273   vtkSetClampMacro(TextPosition, int, PrecedeScalarBar, SucceedScalarBar);
274   vtkGetMacro(TextPosition, int);
SetTextPositionToPrecedeScalarBar()275   virtual void SetTextPositionToPrecedeScalarBar()
276   {
277     this->SetTextPosition(vtkScalarBarActor::PrecedeScalarBar);
278   }
SetTextPositionToSucceedScalarBar()279   virtual void SetTextPositionToSucceedScalarBar()
280   {
281     this->SetTextPosition(vtkScalarBarActor::SucceedScalarBar);
282   }
283   ///@}
284 
285   ///@{
286   /**
287    * Set/Get the maximum width and height in pixels. Specifying the size as
288    * a relative fraction of the viewport can sometimes undesirably stretch
289    * the size of the actor too much. These methods allow the user to set
290    * bounds on the maximum size of the scalar bar in pixels along any
291    * direction. Defaults to unbounded.
292    */
293   vtkSetMacro(MaximumWidthInPixels, int);
294   vtkGetMacro(MaximumWidthInPixels, int);
295   vtkSetMacro(MaximumHeightInPixels, int);
296   vtkGetMacro(MaximumHeightInPixels, int);
297   ///@}
298 
299   ///@{
300   /**
301    * Set/get the padding between the scalar bar and the text annotations.
302    * This space is used to draw leader lines.
303    * The default is 8 pixels.
304    */
305   vtkSetMacro(AnnotationLeaderPadding, double);
306   vtkGetMacro(AnnotationLeaderPadding, double);
307   ///@}
308 
309   ///@{
310   /**
311    * Set/get whether text annotations should be rendered or not.
312    * Currently, this only affects rendering when \a IndexedLookup is true.
313    * The default is true.
314    */
315   vtkSetMacro(DrawAnnotations, vtkTypeBool);
316   vtkGetMacro(DrawAnnotations, vtkTypeBool);
317   vtkBooleanMacro(DrawAnnotations, vtkTypeBool);
318   ///@}
319 
320   ///@{
321   /**
322    * Set/get whether the NaN annotation should be rendered or not.
323    * This only affects rendering when \a DrawAnnotations is true.
324    * The default is false.
325    */
326   vtkSetMacro(DrawNanAnnotation, vtkTypeBool);
327   vtkGetMacro(DrawNanAnnotation, vtkTypeBool);
328   vtkBooleanMacro(DrawNanAnnotation, vtkTypeBool);
329   ///@}
330 
331   ///@{
332   /**
333    * Set/get whether the Below range swatch should be rendered or not.
334    * This only affects rendering when \a DrawAnnotations is true.
335    * The default is false.
336    */
337   vtkSetMacro(DrawBelowRangeSwatch, bool);
338   vtkGetMacro(DrawBelowRangeSwatch, bool);
339   vtkBooleanMacro(DrawBelowRangeSwatch, bool);
340   ///@}
341 
342   ///@{
343   /**
344    * Set/get the annotation text for "Below Range" values.
345    */
346   vtkSetStringMacro(BelowRangeAnnotation);
347   vtkGetStringMacro(BelowRangeAnnotation);
348   ///@}
349 
350   ///@{
351   /**
352    * Set/get whether the Above range swatch should be rendered or not.
353    * This only affects rendering when \a DrawAnnotations is true.
354    * The default is false.
355    */
356   vtkSetMacro(DrawAboveRangeSwatch, bool);
357   vtkGetMacro(DrawAboveRangeSwatch, bool);
358   vtkBooleanMacro(DrawAboveRangeSwatch, bool);
359   ///@}
360 
361   ///@{
362   /**
363    * Set/get the annotation text for "Above Range Swatch" values.
364    */
365   vtkSetStringMacro(AboveRangeAnnotation);
366   vtkGetStringMacro(AboveRangeAnnotation);
367   ///@}
368   ///@{
369   /**
370    * Set/get how leader lines connecting annotations to values should be colored.
371 
372    * When true, leader lines are all the same color (and match the LabelTextProperty color).
373    * When false, leader lines take on the color of the value they correspond to.
374    * This only affects rendering when \a DrawAnnotations is true.
375    * The default is false.
376    */
377   vtkSetMacro(FixedAnnotationLeaderLineColor, vtkTypeBool);
378   vtkGetMacro(FixedAnnotationLeaderLineColor, vtkTypeBool);
379   vtkBooleanMacro(FixedAnnotationLeaderLineColor, vtkTypeBool);
380   ///@}
381 
382   ///@{
383   /**
384    * Set/get the annotation text for "NaN" values.
385    */
386   vtkSetStringMacro(NanAnnotation);
387   vtkGetStringMacro(NanAnnotation);
388   ///@}
389 
390   ///@{
391   /**
392    * Set/get whether annotation labels should be scaled with the viewport.
393 
394    * The default value is 0 (no scaling).
395    * If non-zero, the vtkTextActor instances used to render annotation
396    * labels will have their TextScaleMode set to viewport-based scaling,
397    * which nonlinearly scales font size with the viewport size.
398    */
399   vtkSetMacro(AnnotationTextScaling, vtkTypeBool);
400   vtkGetMacro(AnnotationTextScaling, vtkTypeBool);
401   vtkBooleanMacro(AnnotationTextScaling, vtkTypeBool);
402   ///@}
403 
404   ///@{
405   /**
406    * Set/Get whether a background should be drawn around the scalar bar.
407    * Default is off.
408    */
409   vtkSetMacro(DrawBackground, vtkTypeBool);
410   vtkGetMacro(DrawBackground, vtkTypeBool);
411   vtkBooleanMacro(DrawBackground, vtkTypeBool);
412   ///@}
413 
414   ///@{
415   /**
416    * Set/Get whether a frame should be drawn around the scalar bar.
417    * Default is off.
418    */
419   vtkSetMacro(DrawFrame, vtkTypeBool);
420   vtkGetMacro(DrawFrame, vtkTypeBool);
421   vtkBooleanMacro(DrawFrame, vtkTypeBool);
422   ///@}
423 
424   ///@{
425   /**
426    * Set/Get whether the color bar should be drawn. If off, only the tickmarks
427    * and text will be drawn. Default is on.
428    */
429   vtkSetMacro(DrawColorBar, vtkTypeBool);
430   vtkGetMacro(DrawColorBar, vtkTypeBool);
431   vtkBooleanMacro(DrawColorBar, vtkTypeBool);
432   ///@}
433 
434   ///@{
435   /**
436    * Set/Get whether the tick labels should be drawn. Default is on.
437    */
438   vtkSetMacro(DrawTickLabels, vtkTypeBool);
439   vtkGetMacro(DrawTickLabels, vtkTypeBool);
440   vtkBooleanMacro(DrawTickLabels, vtkTypeBool);
441   ///@}
442 
443   ///@{
444   /**
445    * Set/Get the background property.
446    */
447   virtual void SetBackgroundProperty(vtkProperty2D* p);
448   vtkGetObjectMacro(BackgroundProperty, vtkProperty2D);
449   ///@}
450 
451   ///@{
452   /**
453    * Set/Get the frame property.
454    */
455   virtual void SetFrameProperty(vtkProperty2D* p);
456   vtkGetObjectMacro(FrameProperty, vtkProperty2D);
457   ///@}
458 
459   ///@{
460   /**
461    * Set/get the amount of padding around text boxes.
462    * The default is 1 pixel.
463    */
464   vtkGetMacro(TextPad, int);
465   vtkSetMacro(TextPad, int);
466   ///@}
467 
468   ///@{
469   /**
470    * Set/get the margin in pixels, between the title and the bar,
471    * when the \a Orientation is vertical.
472    * The default is 0 pixels.
473    */
474   vtkGetMacro(VerticalTitleSeparation, int);
475   vtkSetMacro(VerticalTitleSeparation, int);
476   ///@}
477 
478   ///@{
479   /**
480    * Set/get the thickness of the color bar relative to the widget frame.
481    * The default is 0.375 and must always be in the range ]0, 1[.
482    */
483   vtkGetMacro(BarRatio, double);
484   vtkSetClampMacro(BarRatio, double, 0., 1.);
485   ///@}
486 
487   ///@{
488   /**
489    * Set/get the ratio of the title height to the tick label height
490    * (used only when the \a Orientation is horizontal).
491    * The default is 0.5, which attempts to make the labels and title
492    * the same size. This must be a number in the range ]0, 1[.
493    */
494   vtkGetMacro(TitleRatio, double);
495   vtkSetClampMacro(TitleRatio, double, 0., 1.);
496   ///@}
497 
498   ///@{
499   /**
500    * Set/Get whether the font size of title and labels is unconstrained. Default is off.
501    * When it is constrained, the size of the scalar bar will constrain the font size.
502    * When it is not, the size of the font will always be respected.
503    * Using custom labels will force this mode to be on.
504    */
505   vtkSetMacro(UnconstrainedFontSize, bool);
506   vtkGetMacro(UnconstrainedFontSize, bool);
507   vtkBooleanMacro(UnconstrainedFontSize, bool);
508   ///@}
509 
510 protected:
511   vtkScalarBarActor();
512   ~vtkScalarBarActor() override;
513 
514   /**
515    * Called from within \a RenderOpaqueGeometry when the internal state
516    * members need to be updated before rendering.
517 
518    * This method invokes many virtual methods that first lay out the
519    * scalar bar and then use the layout to position actors and create
520    * datasets used to represent the scalar bar.
521    * Specifically, it invokes: FreeLayoutStorage, ComputeFrame,
522    * ComputeScalarBarThickness, LayoutNanSwatch, PrepareTitleText,
523    * LayoutTitle, ComputeScalarBarLength, LayoutTicks, and LayoutAnnotations
524    * to perform the layout step.
525    * Then, it invokes ConfigureAnnotations, ConfigureFrame,
526    * ConfigureScalarBar, ConfigureTitle, ConfigureTicks, and
527    * ConfigureNanSwatch to create and position actors used to render
528    * portions of the scalar bar.
529 
530    * By overriding one or more of these virtual methods, subclasses
531    * may change the appearance of the scalar bar.
532 
533    * In the layout phase, text actors must have their text properties
534    * and input strings updated, but the position of the actors should
535    * not be set or relied upon as subsequent layout steps may alter
536    * their placement.
537    */
538   virtual void RebuildLayout(vtkViewport* viewport);
539 
540   /**
541    * Calls RebuildLayout if it is needed such as when
542    * positions etc have changed. Return 1 on success
543    * zero on error
544    */
545   virtual int RebuildLayoutIfNeeded(vtkViewport* viewport);
546 
547   /**
548    * Free internal storage used by the previous layout.
549    */
550   virtual void FreeLayoutStorage();
551 
552   /**
553    * If the scalar bar should be inset into a frame or rendered with a
554    * solid background, this method will inset the outermost scalar bar
555    * rectangle by a small amount to avoid having the scalar bar
556    * illustration overlap any edges.
557 
558    * This method must set the frame coordinates (this->P->Frame).
559    */
560   virtual void ComputeFrame();
561 
562   /**
563    * Determine how thick the scalar bar should be (on an axis perpendicular
564    * to the direction in which scalar values vary).
565 
566    * This method must set the scalar bar thickness
567    * (this->P->ScalarBarBox.Size[0]).
568    * It may depend on layout performed by ComputeFrame
569    * (i.e., the frame coordinates in this->P->Frame).
570    */
571   virtual void ComputeScalarBarThickness();
572 
573   /**
574    * Compute a correct SwatchPad
575    */
576   virtual void ComputeSwatchPad();
577 
578   // This method must set this->P->NanSwatchSize and this->P->NanBox.
579   // It may depend on layout performed by ComputeScalarBarThickness.
580   virtual void LayoutNanSwatch();
581 
582   /**
583    * Determine the size of the Below Range if it is to be rendered.
584 
585    * This method must set this->P->BelowSwatchSize and this->P->BelowBox.
586    * It may depend on layout performed by ComputeScalarBarThickness.
587    */
588   virtual void LayoutBelowRangeSwatch();
589 
590   /**
591    * Determine the size of the Above Range if it is to be rendered.
592 
593    * This method must set this->P->AboveBox.
594    * It may depend on layout performed by ComputeScalarBarThickness.
595    */
596   virtual void LayoutAboveRangeSwatch();
597 
598   /**
599    * Determine the position of the Above Range if it is to be rendered.
600 
601    * This method must set this->P->AboveRangeSize.
602    * It may depend on layout performed by ComputeScalarBarLength.
603    */
604   virtual void LayoutAboveRangeSwatchPosn();
605 
606   /**
607    * Set the title actor's input to the latest title (and subtitle) text.
608    */
609   virtual void PrepareTitleText();
610 
611   /**
612    * Determine the position and size of the scalar bar title box.
613 
614    * This method must set this->P->TitleBox
615    * It may depend on layout performed by LayoutNanSwatch.
616    * If useTickBox is true, it should increase the target area
617    * for the label to touch the tick box. It is called in this
618    * way when the tick labels are small due to constraints other
619    * than the title box.
620    */
621   virtual void LayoutTitle();
622 
623   /**
624    * This method sets the title and tick-box size and position
625    * for the UnconstrainedFontSize mode.
626    */
627   virtual void LayoutForUnconstrainedFont();
628 
629   /**
630    * Determine how long the scalar bar should be (on an axis parallel
631    * to the direction in which scalar values vary).
632 
633    * This method must set this->P->ScalarBarBox.Size[1] and should
634    * estimate this->P->ScalarBarBox.Posn.
635    * It may depend on layout performed by LayoutTitle.
636    */
637   virtual void ComputeScalarBarLength();
638 
639   /**
640    * Determine the size and placement of any tick marks to be rendered.
641 
642    * This method must set this->P->TickBox.
643    * It may depend on layout performed by ComputeScalarBarLength.
644 
645    * The default implementation creates exactly this->NumberOfLabels
646    * tick marks, uniformly spaced on a linear or logarithmic scale,
647    * or creates them based on the numbers and values this->CustomLabels
648    * when this->UseCustomLabels is true.
649    */
650   virtual void LayoutTicks();
651 
652   /**
653    * This method must lay out annotation text and leader lines so
654    * they do not overlap.
655 
656    * This method must set this->P->AnnotationAnchors.
657    * It may depend on layout performed by LayoutTicks.
658    */
659   virtual void LayoutAnnotations();
660 
661   /**
662    * Generate/configure the annotation labels using the laid-out geometry.
663    */
664   virtual void ConfigureAnnotations();
665 
666   /**
667    * Generate/configure the representation of the frame from laid-out geometry.
668    */
669   virtual void ConfigureFrame();
670 
671   /**
672    * For debugging, add placement boxes to the frame polydata.
673    */
674   virtual void DrawBoxes();
675 
676   /**
677    * Generate/configure the scalar bar representation from laid-out geometry.
678    */
679   virtual void ConfigureScalarBar();
680 
681   /**
682    * Generate/configure the title actor using the laid-out geometry.
683    */
684   virtual void ConfigureTitle();
685 
686   /**
687    * Generate/configure the tick-mark actors using the laid-out geometry.
688    */
689   virtual void ConfigureTicks();
690 
691   /**
692    * Generate/configure the NaN swatch using the laid-out geometry.
693 
694    * Currently the NaN swatch is rendered by the same actor as the scalar bar.
695    * This may change in the future.
696    */
697   virtual void ConfigureNanSwatch();
698 
699   /**
700    * Generate/configure the above/below range swatch using the laid-out
701    * geometry.
702    */
703   virtual void ConfigureAboveBelowRangeSwatch(bool above);
704 
705   /**
706    * Subclasses may override this method to alter this->P->Labels, allowing
707    * the addition and removal of annotations. The member maps viewport coordinates
708    * along the long axis of the scalar bar to text (which may include MathText;
709    * see vtkTextActor). It is a single-valued map, so you must perturb
710    * the coordinate if you wish multiple labels to annotate the same position.
711    * Each entry in this->P->Labels must have a matching entry in this->P->LabelColors.
712    */
EditAnnotations()713   virtual void EditAnnotations() {}
714 
715   /**
716    * Compute the best size for the legend title.
717 
718    * This guarantees that the title will fit within the frame defined by Position and Position2.
719    */
720   virtual void SizeTitle(double* titleSize, int* size, vtkViewport* viewport);
721 
722   /**
723    * Allocate actors for lookup table annotations and position them properly.
724    */
725   int MapAnnotationLabels(
726     vtkScalarsToColors* lkup, double start, double delta, const double* range);
727 
728   /**
729    * This method is called by \a ConfigureAnnotationLabels when Orientation is VTK_ORIENT_VERTICAL.
730    */
731   int PlaceAnnotationsVertically(
732     double barX, double barY, double barWidth, double barHeight, double delta, double pad);
733   /**
734    * This method is called by \a ConfigureAnnotationLabels when Orientation is
735    * VTK_ORIENT_HORIZONTAL.
736    */
737   int PlaceAnnotationsHorizontally(
738     double barX, double barY, double barWidth, double barHeight, double delta, double pad);
739 
740   /// User-changeable settings
741   ///@{
742   int MaximumNumberOfColors;
743   int NumberOfLabels;
744   int NumberOfLabelsBuilt;
745   int Orientation;
746   vtkDoubleArray* CustomLabels = nullptr;
747   bool UseCustomLabels = false;
748   vtkTypeBool DrawBackground; // off by default
749   vtkTypeBool DrawFrame;      // off by default
750   vtkTypeBool DrawColorBar;   // on by default
751   vtkTypeBool DrawTickLabels; // on by default
752   vtkTypeBool DrawAnnotations;
753   vtkTypeBool DrawNanAnnotation;
754   vtkTypeBool AnnotationTextScaling; // off by default
755   vtkTypeBool FixedAnnotationLeaderLineColor;
756   vtkProperty2D* BackgroundProperty;
757   vtkProperty2D* FrameProperty;
758   char* Title;
759   char* ComponentTitle;
760   char* LabelFormat;
761   vtkTypeBool UseOpacity; // off by default
762   double TextureGridWidth;
763   int TextPosition;
764   char* NanAnnotation;
765   char* BelowRangeAnnotation;
766   char* AboveRangeAnnotation;
767   double AnnotationLeaderPadding;
768   int MaximumWidthInPixels;
769   int MaximumHeightInPixels;
770   int TextPad;
771   int VerticalTitleSeparation;
772   double BarRatio;
773   double TitleRatio;
774   bool UnconstrainedFontSize; // off by default
775 
776   bool DrawBelowRangeSwatch;
777   bool DrawAboveRangeSwatch;
778   ///@}
779 
780   /// Internal state used for rendering
781   ///@{
782   vtkTimeStamp BuildTime; //!< Last time internal state changed.
783   int LastSize[2];        //!< Projected size in viewport coordinates of last build.
784   int LastOrigin[2];      //!< Projected origin (viewport coordinates) of last build.
785 
786   vtkScalarBarActorInternal* P; //!< Containers shared with subclasses
787 
788   vtkScalarsToColors* LookupTable; //!< The object this actor illustrates
789 
790   vtkTextProperty* TitleTextProperty;      //!< Font for the legend title.
791   vtkTextProperty* LabelTextProperty;      //!< Font for tick labels.
792   vtkTextProperty* AnnotationTextProperty; //!< Font for annotation labels.
793   vtkTextActor* TitleActor;                //!< The legend title text renderer.
794 
795   vtkPolyData* ScalarBar;               //!< Polygon(s) colored by \a LookupTable.
796   vtkPolyDataMapper2D* ScalarBarMapper; //!< Mapper for \a ScalarBar.
797   vtkActor2D* ScalarBarActor;           //!< Actor for \a ScalarBar.
798   vtkPolyData* TexturePolyData;         //!< Polygon colored when UseOpacity is true.
799   vtkTexture* Texture;                  //!< Color data for \a TexturePolyData.
800   vtkTexturedActor2D* TextureActor;     //!< Actor for \a TexturePolyData.
801 
802   vtkPolyData* Background;               //!< Polygon used to fill the background.
803   vtkPolyDataMapper2D* BackgroundMapper; //!< Mapper for \a Background.
804   vtkActor2D* BackgroundActor;           //!< Actor for \a Background.
805 
806   vtkPolyData* Frame;               //!< Polyline used to highlight frame.
807   vtkPolyDataMapper2D* FrameMapper; //!< Mapper for \a Frame.
808   vtkActor2D* FrameActor;           //!< Actor for \a Frame.
809   ///@}
810 
811 private:
812   vtkScalarBarActor(const vtkScalarBarActor&) = delete;
813   void operator=(const vtkScalarBarActor&) = delete;
814 };
815 
816 #endif
817