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 "vtkRenderingAnnotationModule.h" // For export macro 00049 #include "vtkActor2D.h" 00050 00051 class vtkPoints; 00052 class vtkCellArray; 00053 class vtkPolyData; 00054 class vtkPolyDataMapper2D; 00055 class vtkTextMapper; 00056 class vtkTextProperty; 00057 00058 class VTKRENDERINGANNOTATION_EXPORT vtkLeaderActor2D : public vtkActor2D 00059 { 00060 public: 00061 vtkTypeMacro(vtkLeaderActor2D,vtkActor2D); 00062 void PrintSelf(ostream& os, vtkIndent indent); 00063 00065 static vtkLeaderActor2D *New(); 00066 00068 00078 vtkSetMacro(Radius,double); 00079 vtkGetMacro(Radius,double); 00081 00083 00085 vtkSetStringMacro(Label); 00086 vtkGetStringMacro(Label); 00088 00090 00091 virtual void SetLabelTextProperty(vtkTextProperty *p); 00092 vtkGetObjectMacro(LabelTextProperty,vtkTextProperty); 00094 00096 00098 vtkSetClampMacro(LabelFactor, double, 0.1, 2.0); 00099 vtkGetMacro(LabelFactor, double); 00101 00102 //BTX 00103 // Enums defined to support methods for control of arrow placement and 00104 // and appearance of arrow heads. 00105 enum {VTK_ARROW_NONE=0,VTK_ARROW_POINT1,VTK_ARROW_POINT2,VTK_ARROW_BOTH}; 00106 enum {VTK_ARROW_FILLED=0,VTK_ARROW_OPEN,VTK_ARROW_HOLLOW}; 00107 //ETX 00108 00110 00112 vtkSetClampMacro(ArrowPlacement,int,VTK_ARROW_NONE,VTK_ARROW_BOTH); 00113 vtkGetMacro(ArrowPlacement,int); 00114 void SetArrowPlacementToNone() {this->SetArrowPlacement(VTK_ARROW_NONE);} 00115 void SetArrowPlacementToPoint1() {this->SetArrowPlacement(VTK_ARROW_POINT1);} 00116 void SetArrowPlacementToPoint2() {this->SetArrowPlacement(VTK_ARROW_POINT2);} 00117 void SetArrowPlacementToBoth() {this->SetArrowPlacement(VTK_ARROW_BOTH);} 00119 00121 00124 vtkSetClampMacro(ArrowStyle,int,VTK_ARROW_FILLED,VTK_ARROW_HOLLOW); 00125 vtkGetMacro(ArrowStyle,int); 00126 void SetArrowStyleToFilled() {this->SetArrowStyle(VTK_ARROW_FILLED);} 00127 void SetArrowStyleToOpen() {this->SetArrowStyle(VTK_ARROW_OPEN);} 00128 void SetArrowStyleToHollow() {this->SetArrowStyle(VTK_ARROW_HOLLOW);} 00130 00132 00134 vtkSetClampMacro(ArrowLength,double,0.0,1.0); 00135 vtkGetMacro(ArrowLength,double); 00136 vtkSetClampMacro(ArrowWidth,double,0.0,1.0); 00137 vtkGetMacro(ArrowWidth,double); 00139 00141 00145 vtkSetClampMacro(MinimumArrowSize,double,1.0,VTK_FLOAT_MAX); 00146 vtkGetMacro(MinimumArrowSize,double); 00147 vtkSetClampMacro(MaximumArrowSize,double,1.0,VTK_FLOAT_MAX); 00148 vtkGetMacro(MaximumArrowSize,double); 00150 00152 00156 vtkSetMacro(AutoLabel,int); 00157 vtkGetMacro(AutoLabel,int); 00158 vtkBooleanMacro(AutoLabel,int); 00160 00162 00163 vtkSetStringMacro(LabelFormat); 00164 vtkGetStringMacro(LabelFormat); 00166 00168 00170 vtkGetMacro(Length,double); 00171 vtkGetMacro(Angle,double); 00173 00175 00176 int RenderOverlay(vtkViewport* viewport); 00177 int RenderOpaqueGeometry(vtkViewport* viewport); 00178 virtual int RenderTranslucentPolygonalGeometry(vtkViewport *) {return 0;} 00180 00182 virtual int HasTranslucentPolygonalGeometry(); 00183 00184 void ReleaseGraphicsResources(vtkWindow *); 00185 void ShallowCopy(vtkProp *prop); 00186 00187 protected: 00188 vtkLeaderActor2D(); 00189 ~vtkLeaderActor2D(); 00190 00191 // Internal helper methods 00192 virtual void BuildLeader(vtkViewport *viewport); 00193 int SetFontSize(vtkViewport *viewport, vtkTextMapper *textMapper, 00194 int *targetSize, double factor, int *stringSize); 00195 int ClipLeader(double xL[3], int stringSize[2], double p1[3], double ray[3], 00196 double c1[3], double c2[3]); 00197 void BuildCurvedLeader(double p1[3], double p2[3], double ray[3], double rayLength, 00198 double theta, vtkViewport *viewport, int viewportChanged); 00199 int InStringBox(double center[3], int stringSize[2], double x[3]); 00200 00201 00202 // Characteristics of the leader 00203 double Radius; 00204 double Length; 00205 double Angle; 00206 00207 int AutoLabel; 00208 char *LabelFormat; 00209 char *Label; 00210 double LabelFactor; 00211 vtkTextMapper *LabelMapper; 00212 vtkActor2D *LabelActor; 00213 vtkTextProperty *LabelTextProperty; 00214 00215 int ArrowPlacement; 00216 int ArrowStyle; 00217 double ArrowLength; 00218 double ArrowWidth; 00219 double MinimumArrowSize; 00220 double MaximumArrowSize; 00221 00222 vtkPoints *LeaderPoints; 00223 vtkCellArray *LeaderLines; 00224 vtkCellArray *LeaderArrows; 00225 vtkPolyData *Leader; 00226 vtkPolyDataMapper2D *LeaderMapper; 00227 vtkActor2D *LeaderActor; 00228 00229 // Internal ivars for tracking whether to rebuild 00230 int LastPosition[2]; 00231 int LastPosition2[2]; 00232 int LastSize[2]; 00233 vtkTimeStamp BuildTime; 00234 00235 private: 00236 vtkLeaderActor2D(const vtkLeaderActor2D&); // Not implemented. 00237 void operator=(const vtkLeaderActor2D&); // Not implemented. 00238 }; 00239 00240 00241 #endif