VTK
|
00001 /*========================================================================= 00002 00003 Program: Visualization Toolkit 00004 Module: vtkLeaderActor2D.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 =========================================================================*/ 00045 #ifndef __vtkLeaderActor2D_h 00046 #define __vtkLeaderActor2D_h 00047 00048 #include "vtkActor2D.h" 00049 00050 class vtkPoints; 00051 class vtkCellArray; 00052 class vtkPolyData; 00053 class vtkPolyDataMapper2D; 00054 class vtkTextMapper; 00055 class vtkTextProperty; 00056 00057 class VTK_RENDERING_EXPORT vtkLeaderActor2D : public vtkActor2D 00058 { 00059 public: 00060 vtkTypeMacro(vtkLeaderActor2D,vtkActor2D); 00061 void PrintSelf(ostream& os, vtkIndent indent); 00062 00064 static vtkLeaderActor2D *New(); 00065 00067 00077 vtkSetMacro(Radius,double); 00078 vtkGetMacro(Radius,double); 00080 00082 00084 vtkSetStringMacro(Label); 00085 vtkGetStringMacro(Label); 00087 00089 00090 virtual void SetLabelTextProperty(vtkTextProperty *p); 00091 vtkGetObjectMacro(LabelTextProperty,vtkTextProperty); 00093 00095 00097 vtkSetClampMacro(LabelFactor, double, 0.1, 2.0); 00098 vtkGetMacro(LabelFactor, double); 00100 00101 //BTX 00102 // Enums defined to support methods for control of arrow placement and 00103 // and appearance of arrow heads. 00104 enum {VTK_ARROW_NONE=0,VTK_ARROW_POINT1,VTK_ARROW_POINT2,VTK_ARROW_BOTH}; 00105 enum {VTK_ARROW_FILLED=0,VTK_ARROW_OPEN,VTK_ARROW_HOLLOW}; 00106 //ETX 00107 00109 00111 vtkSetClampMacro(ArrowPlacement,int,VTK_ARROW_NONE,VTK_ARROW_BOTH); 00112 vtkGetMacro(ArrowPlacement,int); 00113 void SetArrowPlacementToNone() {this->SetArrowPlacement(VTK_ARROW_NONE);} 00114 void SetArrowPlacementToPoint1() {this->SetArrowPlacement(VTK_ARROW_POINT1);} 00115 void SetArrowPlacementToPoint2() {this->SetArrowPlacement(VTK_ARROW_POINT2);} 00116 void SetArrowPlacementToBoth() {this->SetArrowPlacement(VTK_ARROW_BOTH);} 00118 00120 00123 vtkSetClampMacro(ArrowStyle,int,VTK_ARROW_FILLED,VTK_ARROW_HOLLOW); 00124 vtkGetMacro(ArrowStyle,int); 00125 void SetArrowStyleToFilled() {this->SetArrowStyle(VTK_ARROW_FILLED);} 00126 void SetArrowStyleToOpen() {this->SetArrowStyle(VTK_ARROW_OPEN);} 00127 void SetArrowStyleToHollow() {this->SetArrowStyle(VTK_ARROW_HOLLOW);} 00129 00131 00133 vtkSetClampMacro(ArrowLength,double,0.0,1.0); 00134 vtkGetMacro(ArrowLength,double); 00135 vtkSetClampMacro(ArrowWidth,double,0.0,1.0); 00136 vtkGetMacro(ArrowWidth,double); 00138 00140 00144 vtkSetClampMacro(MinimumArrowSize,double,1.0,VTK_LARGE_FLOAT); 00145 vtkGetMacro(MinimumArrowSize,double); 00146 vtkSetClampMacro(MaximumArrowSize,double,1.0,VTK_LARGE_FLOAT); 00147 vtkGetMacro(MaximumArrowSize,double); 00149 00151 00155 vtkSetMacro(AutoLabel,int); 00156 vtkGetMacro(AutoLabel,int); 00157 vtkBooleanMacro(AutoLabel,int); 00159 00161 00162 vtkSetStringMacro(LabelFormat); 00163 vtkGetStringMacro(LabelFormat); 00165 00167 00169 vtkGetMacro(Length,double); 00170 vtkGetMacro(Angle,double); 00172 00174 00175 int RenderOverlay(vtkViewport* viewport); 00176 int RenderOpaqueGeometry(vtkViewport* viewport); 00177 virtual int RenderTranslucentPolygonalGeometry(vtkViewport *) {return 0;} 00179 00181 virtual int HasTranslucentPolygonalGeometry(); 00182 00183 void ReleaseGraphicsResources(vtkWindow *); 00184 void ShallowCopy(vtkProp *prop); 00185 00186 protected: 00187 vtkLeaderActor2D(); 00188 ~vtkLeaderActor2D(); 00189 00190 // Internal helper methods 00191 virtual void BuildLeader(vtkViewport *viewport); 00192 int SetFontSize(vtkViewport *viewport, vtkTextMapper *textMapper, 00193 int *targetSize, double factor, int *stringSize); 00194 int ClipLeader(double xL[3], int stringSize[2], double p1[3], double ray[3], 00195 double c1[3], double c2[3]); 00196 void BuildCurvedLeader(double p1[3], double p2[3], double ray[3], double rayLength, 00197 double theta, vtkViewport *viewport, int viewportChanged); 00198 int InStringBox(double center[3], int stringSize[2], double x[3]); 00199 00200 00201 // Characteristics of the leader 00202 double Radius; 00203 double Length; 00204 double Angle; 00205 00206 int AutoLabel; 00207 char *LabelFormat; 00208 char *Label; 00209 double LabelFactor; 00210 vtkTextMapper *LabelMapper; 00211 vtkActor2D *LabelActor; 00212 vtkTextProperty *LabelTextProperty; 00213 00214 int ArrowPlacement; 00215 int ArrowStyle; 00216 double ArrowLength; 00217 double ArrowWidth; 00218 double MinimumArrowSize; 00219 double MaximumArrowSize; 00220 00221 vtkPoints *LeaderPoints; 00222 vtkCellArray *LeaderLines; 00223 vtkCellArray *LeaderArrows; 00224 vtkPolyData *Leader; 00225 vtkPolyDataMapper2D *LeaderMapper; 00226 vtkActor2D *LeaderActor; 00227 00228 // Internal ivars for tracking whether to rebuild 00229 int LastPosition[2]; 00230 int LastPosition2[2]; 00231 int LastSize[2]; 00232 vtkTimeStamp BuildTime; 00233 00234 private: 00235 vtkLeaderActor2D(const vtkLeaderActor2D&); // Not implemented. 00236 void operator=(const vtkLeaderActor2D&); // Not implemented. 00237 }; 00238 00239 00240 #endif