VTK
dox/Rendering/Annotation/vtkScalarBarActor.h
Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    vtkScalarBarActor.h
00005 
00006   Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
00007   All rights reserved.
00008   See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
00009 
00010      This software is distributed WITHOUT ANY WARRANTY; without even
00011      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
00012      PURPOSE.  See the above copyright notice for more information.
00013 
00014 =========================================================================*/
00058 #ifndef __vtkScalarBarActor_h
00059 #define __vtkScalarBarActor_h
00060 
00061 #include "vtkRenderingAnnotationModule.h" // For export macro
00062 #include "vtkActor2D.h"
00063 
00064 class vtkColor3ub;
00065 class vtkPolyData;
00066 class vtkPolyDataMapper2D;
00067 class vtkProperty2D;
00068 class vtkScalarsToColors;
00069 class vtkScalarBarActorInternal;
00070 class vtkTextActor;
00071 class vtkTextMapper;
00072 class vtkTextProperty;
00073 class vtkTexture;
00074 
00075 #define VTK_ORIENT_HORIZONTAL 0
00076 #define VTK_ORIENT_VERTICAL 1
00077 
00078 class VTKRENDERINGANNOTATION_EXPORT vtkScalarBarActor : public vtkActor2D
00079 {
00080 public:
00081   vtkTypeMacro(vtkScalarBarActor,vtkActor2D);
00082   void PrintSelf(ostream& os, vtkIndent indent);
00083 
00087   static vtkScalarBarActor* New();
00088 
00090 
00091   int RenderOpaqueGeometry(vtkViewport* viewport);
00092   virtual int RenderTranslucentPolygonalGeometry(vtkViewport*) { return 0; };
00093   int RenderOverlay(vtkViewport* viewport);
00095 
00097   virtual int HasTranslucentPolygonalGeometry();
00098 
00102   virtual void ReleaseGraphicsResources(vtkWindow*);
00103 
00105 
00109   virtual void SetLookupTable(vtkScalarsToColors*);
00110   vtkGetObjectMacro(LookupTable,vtkScalarsToColors);
00112 
00114 
00119   vtkSetMacro( UseOpacity, int );
00120   vtkGetMacro( UseOpacity, int );
00121   vtkBooleanMacro( UseOpacity, int );
00123 
00125 
00128   vtkSetClampMacro(MaximumNumberOfColors, int, 2, VTK_INT_MAX);
00129   vtkGetMacro(MaximumNumberOfColors, int);
00131 
00133 
00134   vtkSetClampMacro(NumberOfLabels, int, 0, 64);
00135   vtkGetMacro(NumberOfLabels, int);
00137 
00139 
00140   vtkSetClampMacro(Orientation,int,VTK_ORIENT_HORIZONTAL, VTK_ORIENT_VERTICAL);
00141   vtkGetMacro(Orientation, int);
00142   void SetOrientationToHorizontal()
00143        {this->SetOrientation(VTK_ORIENT_HORIZONTAL);}
00144   void SetOrientationToVertical() {this->SetOrientation(VTK_ORIENT_VERTICAL);}
00146 
00148 
00149   virtual void SetTitleTextProperty(vtkTextProperty* p);
00150   vtkGetObjectMacro(TitleTextProperty,vtkTextProperty);
00152 
00154 
00155   virtual void SetLabelTextProperty(vtkTextProperty* p);
00156   vtkGetObjectMacro(LabelTextProperty,vtkTextProperty);
00158 
00160 
00161   vtkSetStringMacro(LabelFormat);
00162   vtkGetStringMacro(LabelFormat);
00164 
00166 
00167   vtkSetStringMacro(Title);
00168   vtkGetStringMacro(Title);
00170 
00172 
00173   vtkSetStringMacro(ComponentTitle);
00174   vtkGetStringMacro(ComponentTitle);
00176 
00179   void ShallowCopy(vtkProp* prop);
00180 
00182 
00183   vtkSetMacro( TextureGridWidth, double );
00184   vtkGetMacro( TextureGridWidth, double );
00186 
00188 
00189   vtkGetObjectMacro( TextureActor, vtkActor2D );
00191 
00192 //BTX
00193   enum { PrecedeScalarBar = 0, SucceedScalarBar };
00194 //ETX
00195 
00197 
00203   vtkSetClampMacro( TextPosition, int, PrecedeScalarBar, SucceedScalarBar);
00204   vtkGetMacro( TextPosition, int );
00205   virtual void SetTextPositionToPrecedeScalarBar()
00206     { this->SetTextPosition( vtkScalarBarActor::PrecedeScalarBar ); }
00207   virtual void SetTextPositionToSucceedScalarBar()
00208     { this->SetTextPosition( vtkScalarBarActor::SucceedScalarBar ); }
00210 
00212 
00217   vtkSetMacro( MaximumWidthInPixels, int );
00218   vtkGetMacro( MaximumWidthInPixels, int );
00219   vtkSetMacro( MaximumHeightInPixels, int );
00220   vtkGetMacro( MaximumHeightInPixels, int );
00222 
00224 
00226   vtkSetMacro(AnnotationLeaderPadding, double);
00227   vtkGetMacro(AnnotationLeaderPadding, double);
00229 
00231 
00234   vtkSetMacro(DrawAnnotations, int);
00235   vtkGetMacro(DrawAnnotations, int);
00236   vtkBooleanMacro(DrawAnnotations, int);
00238 
00240 
00243   vtkSetMacro(DrawNanAnnotation, int);
00244   vtkGetMacro(DrawNanAnnotation, int);
00245   vtkBooleanMacro(DrawNanAnnotation, int);
00247 
00249 
00254   vtkSetMacro(FixedAnnotationLeaderLineColor, int);
00255   vtkGetMacro(FixedAnnotationLeaderLineColor, int);
00256   vtkBooleanMacro(FixedAnnotationLeaderLineColor, int);
00258 
00260 
00261   vtkSetStringMacro(NanAnnotation);
00262   vtkGetStringMacro(NanAnnotation);
00264 
00266 
00268   vtkSetMacro(DrawBackground, int);
00269   vtkGetMacro(DrawBackground, int);
00270   vtkBooleanMacro(DrawBackground, int);
00272 
00274 
00276   vtkSetMacro(DrawFrame, int);
00277   vtkGetMacro(DrawFrame, int);
00278   vtkBooleanMacro(DrawFrame, int);
00280 
00282 
00284   vtkSetMacro(DrawColorBar, int);
00285   vtkGetMacro(DrawColorBar, int);
00286   vtkBooleanMacro(DrawColorBar, int);
00288 
00290 
00291   virtual void SetBackgroundProperty(vtkProperty2D* p);
00292   vtkGetObjectMacro(BackgroundProperty,vtkProperty2D);
00294 
00296 
00297   virtual void SetFrameProperty(vtkProperty2D* p);
00298   vtkGetObjectMacro(FrameProperty,vtkProperty2D);
00300 
00302 
00304   vtkGetMacro(TextPad,int);
00305   vtkSetMacro(TextPad,int);
00307 
00309 
00311   vtkGetMacro(BarRatio,double);
00312   vtkSetClampMacro(BarRatio,double,0.,1.);
00314 
00316 
00320   vtkGetMacro(TitleRatio,double);
00321   vtkSetClampMacro(TitleRatio,double,0.,1.);
00323 
00324 protected:
00325   vtkScalarBarActor();
00326   ~vtkScalarBarActor();
00327 
00344   virtual void RebuildLayout(vtkViewport* viewport);
00345 
00347   virtual void FreeLayoutStorage();
00348 
00354   virtual void ComputeFrame();
00355 
00361   virtual void ComputeScalarBarThickness();
00362 
00366   virtual void LayoutNanSwatch();
00367 
00369   virtual void PrepareTitleText();
00370 
00377   virtual void LayoutTitle();
00378 
00384   virtual void ComputeScalarBarLength();
00385 
00391   virtual void LayoutTicks();
00392 
00396   virtual void LayoutAnnotations();
00397 
00399   virtual void ConfigureAnnotations();
00400 
00403   virtual void ConfigureFrame();
00404 
00406   virtual void DrawBoxes();
00407 
00410   virtual void ConfigureScalarBar();
00411 
00413   virtual void ConfigureTitle();
00414 
00416   virtual void ConfigureTicks();
00417 
00421   virtual void ConfigureNanSwatch();
00422 
00430   virtual void EditAnnotations() { }
00431 
00434   virtual void SizeTitle(double* titleSize, int* size, vtkViewport* viewport);
00435 
00437 
00439   int MapAnnotationLabels(
00440     vtkScalarsToColors* lkup, double start, double delta, double* range);
00442 
00444 
00446   int PlaceAnnotationsVertically(
00447     double barX, double barY, double barWidth, double barHeight,
00448     double delta, double pad);
00450 
00451 
00453   int PlaceAnnotationsHorizontally(
00454     double barX, double barY, double barWidth, double barHeight,
00455     double delta, double pad);
00457 
00459 
00460   int MaximumNumberOfColors;
00461   int NumberOfLabels;
00462   int NumberOfLabelsBuilt;
00463   int Orientation;
00464   int DrawBackground; // off by default
00465   int DrawFrame; // off by default
00466   int DrawColorBar; // on by default
00467   int DrawAnnotations;
00468   int DrawNanAnnotation;
00469   int FixedAnnotationLeaderLineColor;
00470   vtkProperty2D* BackgroundProperty;
00471   vtkProperty2D* FrameProperty;
00472   char* Title;
00473   char* ComponentTitle;
00474   char* LabelFormat;
00475   int UseOpacity; // off by default
00476   double TextureGridWidth;
00477   int TextPosition;
00478   char* NanAnnotation;
00479   double AnnotationLeaderPadding;
00480   int MaximumWidthInPixels;
00481   int MaximumHeightInPixels;
00482   int TextPad;
00483   double BarRatio;
00484   double TitleRatio;
00486 
00488 
00489   vtkTimeStamp BuildTime; 
00490   int LastSize[2]; 
00491   int LastOrigin[2]; 
00492 
00493   vtkScalarBarActorInternal* P; 
00494 
00495   vtkScalarsToColors* LookupTable; 
00496 
00497   vtkTextProperty* TitleTextProperty; 
00498   vtkTextProperty* LabelTextProperty; 
00499   vtkTextActor* TitleActor; 
00500 
00501   vtkPolyData* ScalarBar; 
00502   vtkPolyDataMapper2D* ScalarBarMapper; 
00503   vtkActor2D* ScalarBarActor; 
00504   vtkPolyData* TexturePolyData; 
00505   vtkTexture* Texture; 
00506   vtkActor2D* TextureActor; 
00507 
00508   vtkPolyData* Background; 
00509   vtkPolyDataMapper2D* BackgroundMapper; 
00510   vtkActor2D* BackgroundActor; 
00511 
00512   vtkPolyData* Frame; 
00513   vtkPolyDataMapper2D* FrameMapper; 
00514   vtkActor2D* FrameActor; 
00515 
00516 
00517 private:
00518   vtkScalarBarActor(const vtkScalarBarActor&);  // Not implemented.
00519   void operator=(const vtkScalarBarActor&);  // Not implemented.
00520 };
00521 
00522 
00523 #endif
00524