VTK
dox/Widgets/vtkBalloonRepresentation.h
Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    vtkBalloonRepresentation.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 =========================================================================*/
00059 #ifndef __vtkBalloonRepresentation_h
00060 #define __vtkBalloonRepresentation_h
00061 
00062 #include "vtkWidgetRepresentation.h"
00063 
00064 class vtkTextMapper;
00065 class vtkTextActor;
00066 class vtkTextProperty;
00067 class vtkPoints;
00068 class vtkCellArray;
00069 class vtkPolyData;
00070 class vtkPolyDataMapper2D;
00071 class vtkActor2D;
00072 class vtkProperty2D;
00073 class vtkImageData;
00074 class vtkTexture;
00075 class vtkPoints;
00076 class vtkPolyData;
00077 class vtkPolyDataMapper2D;
00078 class vtkActor2D;
00079 
00080 class VTK_WIDGETS_EXPORT vtkBalloonRepresentation : public vtkWidgetRepresentation
00081 {
00082 public:
00084   static vtkBalloonRepresentation *New();
00085 
00087 
00088   vtkTypeMacro(vtkBalloonRepresentation,vtkWidgetRepresentation);
00089   void PrintSelf(ostream& os, vtkIndent indent);
00091 
00093 
00094   virtual void SetBalloonImage(vtkImageData *img);
00095   vtkGetObjectMacro(BalloonImage,vtkImageData);
00097 
00099 
00100   vtkGetStringMacro(BalloonText);
00101   vtkSetStringMacro(BalloonText);
00103 
00105 
00109   vtkSetVector2Macro(ImageSize,int);
00110   vtkGetVector2Macro(ImageSize,int);
00112 
00114 
00115   virtual void SetTextProperty(vtkTextProperty *p);
00116   vtkGetObjectMacro(TextProperty,vtkTextProperty);
00118     
00120 
00122   virtual void SetFrameProperty(vtkProperty2D *p);
00123   vtkGetObjectMacro(FrameProperty,vtkProperty2D);
00125     
00127 
00128   virtual void SetImageProperty(vtkProperty2D *p);
00129   vtkGetObjectMacro(ImageProperty,vtkProperty2D);
00131     
00132 //BTX
00133   enum {ImageLeft=0,ImageRight,ImageBottom,ImageTop};
00134 //ETX
00136 
00142   vtkSetMacro(BalloonLayout,int);
00143   vtkGetMacro(BalloonLayout,int);
00144   void SetBalloonLayoutToImageLeft() {this->SetBalloonLayout(ImageLeft);}
00145   void SetBalloonLayoutToImageRight() {this->SetBalloonLayout(ImageRight);}
00146   void SetBalloonLayoutToImageBottom() {this->SetBalloonLayout(ImageBottom);}
00147   void SetBalloonLayoutToImageTop() {this->SetBalloonLayout(ImageTop);}
00148   void SetBalloonLayoutToTextLeft() {this->SetBalloonLayout(ImageRight);}
00149   void SetBalloonLayoutToTextRight() {this->SetBalloonLayout(ImageLeft);}
00150   void SetBalloonLayoutToTextTop() {this->SetBalloonLayout(ImageBottom);}
00151   void SetBalloonLayoutToTextBottom() {this->SetBalloonLayout(ImageTop);}
00153 
00155 
00159   vtkSetVector2Macro(Offset,int);
00160   vtkGetVector2Macro(Offset,int);
00162 
00164 
00166   vtkSetClampMacro(Padding,int,0,100);
00167   vtkGetMacro(Padding,int);
00169 
00171 
00172   virtual void StartWidgetInteraction(double e[2]);
00173   virtual void EndWidgetInteraction(double e[2]);
00174   virtual void BuildRepresentation();
00176   
00178 
00179   virtual void ReleaseGraphicsResources(vtkWindow *w);
00180   virtual int RenderOverlay(vtkViewport *viewport);
00182 
00183 protected:
00184   vtkBalloonRepresentation();
00185   ~vtkBalloonRepresentation();
00186 
00187   // The balloon text and image
00188   char         *BalloonText;
00189   vtkImageData *BalloonImage;
00190 
00191   // The layout of the balloon
00192   int BalloonLayout;
00193 
00194   // Controlling placement
00195   int Padding;
00196   int Offset[2];
00197   int ImageSize[2];
00198 
00199   // Represent the text
00200   vtkTextMapper       *TextMapper;
00201   vtkActor2D          *TextActor;
00202   vtkTextProperty     *TextProperty;
00203   
00204   // Represent the image
00205   vtkTexture          *Texture;
00206   vtkPolyData         *TexturePolyData;
00207   vtkPoints           *TexturePoints;
00208   vtkPolyDataMapper2D *TextureMapper;
00209   vtkActor2D          *TextureActor;
00210   vtkProperty2D       *ImageProperty;
00211 
00212   // The frame
00213   vtkPoints           *FramePoints;
00214   vtkCellArray        *FramePolygon;
00215   vtkPolyData         *FramePolyData;
00216   vtkPolyDataMapper2D *FrameMapper;
00217   vtkActor2D          *FrameActor;
00218   vtkProperty2D       *FrameProperty;
00219   
00220   // Internal variable controlling rendering process
00221   int TextVisible;
00222   int ImageVisible;
00223   
00224   // Helper methods
00225   void AdjustImageSize(double imageSize[2]);
00226   void ScaleImage(double imageSize[2],double scale);
00227 
00228 private:
00229   vtkBalloonRepresentation(const vtkBalloonRepresentation&);  //Not implemented
00230   void operator=(const vtkBalloonRepresentation&);  //Not implemented
00231 };
00232 
00233 #endif