VTK
|
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 "vtkInteractionWidgetsModule.h" // For export macro 00063 #include "vtkWidgetRepresentation.h" 00064 00065 class vtkTextMapper; 00066 class vtkTextActor; 00067 class vtkTextProperty; 00068 class vtkPoints; 00069 class vtkCellArray; 00070 class vtkPolyData; 00071 class vtkPolyDataMapper2D; 00072 class vtkActor2D; 00073 class vtkProperty2D; 00074 class vtkImageData; 00075 class vtkTexture; 00076 class vtkPoints; 00077 class vtkPolyData; 00078 class vtkPolyDataMapper2D; 00079 class vtkActor2D; 00080 00081 class VTKINTERACTIONWIDGETS_EXPORT vtkBalloonRepresentation : public vtkWidgetRepresentation 00082 { 00083 public: 00085 static vtkBalloonRepresentation *New(); 00086 00088 00089 vtkTypeMacro(vtkBalloonRepresentation,vtkWidgetRepresentation); 00090 void PrintSelf(ostream& os, vtkIndent indent); 00092 00094 00095 virtual void SetBalloonImage(vtkImageData *img); 00096 vtkGetObjectMacro(BalloonImage,vtkImageData); 00098 00100 00101 vtkGetStringMacro(BalloonText); 00102 vtkSetStringMacro(BalloonText); 00104 00106 00110 vtkSetVector2Macro(ImageSize,int); 00111 vtkGetVector2Macro(ImageSize,int); 00113 00115 00116 virtual void SetTextProperty(vtkTextProperty *p); 00117 vtkGetObjectMacro(TextProperty,vtkTextProperty); 00119 00121 00123 virtual void SetFrameProperty(vtkProperty2D *p); 00124 vtkGetObjectMacro(FrameProperty,vtkProperty2D); 00126 00128 00129 virtual void SetImageProperty(vtkProperty2D *p); 00130 vtkGetObjectMacro(ImageProperty,vtkProperty2D); 00132 00133 //BTX 00134 enum {ImageLeft=0,ImageRight,ImageBottom,ImageTop}; 00135 //ETX 00137 00143 vtkSetMacro(BalloonLayout,int); 00144 vtkGetMacro(BalloonLayout,int); 00145 void SetBalloonLayoutToImageLeft() {this->SetBalloonLayout(ImageLeft);} 00146 void SetBalloonLayoutToImageRight() {this->SetBalloonLayout(ImageRight);} 00147 void SetBalloonLayoutToImageBottom() {this->SetBalloonLayout(ImageBottom);} 00148 void SetBalloonLayoutToImageTop() {this->SetBalloonLayout(ImageTop);} 00149 void SetBalloonLayoutToTextLeft() {this->SetBalloonLayout(ImageRight);} 00150 void SetBalloonLayoutToTextRight() {this->SetBalloonLayout(ImageLeft);} 00151 void SetBalloonLayoutToTextTop() {this->SetBalloonLayout(ImageBottom);} 00152 void SetBalloonLayoutToTextBottom() {this->SetBalloonLayout(ImageTop);} 00154 00156 00160 vtkSetVector2Macro(Offset,int); 00161 vtkGetVector2Macro(Offset,int); 00163 00165 00167 vtkSetClampMacro(Padding,int,0,100); 00168 vtkGetMacro(Padding,int); 00170 00172 00173 virtual void StartWidgetInteraction(double e[2]); 00174 virtual void EndWidgetInteraction(double e[2]); 00175 virtual void BuildRepresentation(); 00176 virtual int ComputeInteractionState(int X, int Y, int modify=0); 00178 00180 00181 virtual void ReleaseGraphicsResources(vtkWindow *w); 00182 virtual int RenderOverlay(vtkViewport *viewport); 00184 00187 enum _InteractionState {Outside=0, OnText, OnImage}; 00188 00189 protected: 00190 vtkBalloonRepresentation(); 00191 ~vtkBalloonRepresentation(); 00192 00193 // The balloon text and image 00194 char *BalloonText; 00195 vtkImageData *BalloonImage; 00196 00197 // The layout of the balloon 00198 int BalloonLayout; 00199 00200 // Controlling placement 00201 int Padding; 00202 int Offset[2]; 00203 int ImageSize[2]; 00204 00205 // Represent the text 00206 vtkTextMapper *TextMapper; 00207 vtkActor2D *TextActor; 00208 vtkTextProperty *TextProperty; 00209 00210 // Represent the image 00211 vtkTexture *Texture; 00212 vtkPolyData *TexturePolyData; 00213 vtkPoints *TexturePoints; 00214 vtkPolyDataMapper2D *TextureMapper; 00215 vtkActor2D *TextureActor; 00216 vtkProperty2D *ImageProperty; 00217 00218 // The frame 00219 vtkPoints *FramePoints; 00220 vtkCellArray *FramePolygon; 00221 vtkPolyData *FramePolyData; 00222 vtkPolyDataMapper2D *FrameMapper; 00223 vtkActor2D *FrameActor; 00224 vtkProperty2D *FrameProperty; 00225 00226 // Internal variable controlling rendering process 00227 int TextVisible; 00228 int ImageVisible; 00229 00230 // Helper methods 00231 void AdjustImageSize(double imageSize[2]); 00232 void ScaleImage(double imageSize[2],double scale); 00233 00234 private: 00235 vtkBalloonRepresentation(const vtkBalloonRepresentation&); //Not implemented 00236 void operator=(const vtkBalloonRepresentation&); //Not implemented 00237 }; 00238 00239 #endif