00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00040 #ifndef __vtkLineRepresentation_h
00041 #define __vtkLineRepresentation_h
00042
00043 #include "vtkWidgetRepresentation.h"
00044
00045 class vtkActor;
00046 class vtkPolyDataMapper;
00047 class vtkLineSource;
00048 class vtkSphereSource;
00049 class vtkProperty;
00050 class vtkPolyData;
00051 class vtkPolyDataAlgorithm;
00052 class vtkPointHandleRepresentation3D;
00053 class vtkBox;
00054 class vtkFollower;
00055 class vtkVectorText;
00056 class vtkPolyDataMapper;
00057 class vtkCellPicker;
00058
00059 class VTK_WIDGETS_EXPORT vtkLineRepresentation : public vtkWidgetRepresentation
00060 {
00061 public:
00063 static vtkLineRepresentation *New();
00064
00066
00067 vtkTypeRevisionMacro(vtkLineRepresentation,vtkWidgetRepresentation);
00068 void PrintSelf(ostream& os, vtkIndent indent);
00070
00072
00075 void GetPoint1WorldPosition(double pos[3]);
00076 double* GetPoint1WorldPosition();
00077 void GetPoint1DisplayPosition(double pos[3]);
00078 double* GetPoint1DisplayPosition();
00079 void SetPoint1WorldPosition(double pos[3]);
00080 void SetPoint1DisplayPosition(double pos[3]);
00081 void GetPoint2DisplayPosition(double pos[3]);
00082 double* GetPoint2DisplayPosition();
00083 void GetPoint2WorldPosition(double pos[3]);
00084 double* GetPoint2WorldPosition();
00085 void SetPoint2WorldPosition(double pos[3]);
00086 void SetPoint2DisplayPosition(double pos[3]);
00088
00090
00098 void SetHandleRepresentation(vtkPointHandleRepresentation3D *handle);
00099 void InstantiateHandleRepresentation();
00101
00103
00104 vtkGetObjectMacro(Point1Representation,vtkPointHandleRepresentation3D);
00105 vtkGetObjectMacro(Point2Representation,vtkPointHandleRepresentation3D);
00106 vtkGetObjectMacro(LineHandleRepresentation,vtkPointHandleRepresentation3D);
00108
00110
00112 vtkGetObjectMacro(EndPointProperty,vtkProperty);
00113 vtkGetObjectMacro(SelectedEndPointProperty,vtkProperty);
00115
00117
00119 vtkGetObjectMacro(LineProperty,vtkProperty);
00120 vtkGetObjectMacro(SelectedLineProperty,vtkProperty);
00122
00124
00127 vtkSetClampMacro(Tolerance,int,1,100);
00128 vtkGetMacro(Tolerance,int);
00130
00132
00135 void SetResolution(int res);
00136 int GetResolution();
00138
00145 void GetPolyData(vtkPolyData *pd);
00146
00148
00149 virtual void PlaceWidget(double bounds[6]);
00150 virtual void BuildRepresentation();
00151 virtual int ComputeInteractionState(int X, int Y, int modify=0);
00152 virtual void StartWidgetInteraction(double e[2]);
00153 virtual void WidgetInteraction(double e[2]);
00154 virtual double *GetBounds();
00156
00158
00159 virtual void GetActors(vtkPropCollection *pc);
00160 virtual void ReleaseGraphicsResources(vtkWindow*);
00161 virtual int RenderOpaqueGeometry(vtkViewport*);
00162 virtual int RenderTranslucentPolygonalGeometry(vtkViewport*);
00163 virtual int HasTranslucentPolygonalGeometry();
00165
00166
00167 enum {Outside=0,OnP1,OnP2,TranslatingP1,TranslatingP2,OnLine,Scaling};
00168
00169
00171
00178 vtkSetClampMacro(InteractionState,int,Outside,Scaling);
00180
00182
00184 virtual void SetRepresentationState(int);
00185 vtkGetMacro(RepresentationState, int);
00187
00190 virtual unsigned long GetMTime();
00191
00193 virtual void SetRenderer(vtkRenderer *ren);
00194
00196
00197 vtkSetMacro( DistanceAnnotationVisibility, int );
00198 vtkGetMacro( DistanceAnnotationVisibility, int );
00199 vtkBooleanMacro( DistanceAnnotationVisibility, int );
00201
00203
00206 vtkSetStringMacro(DistanceAnnotationFormat);
00207 vtkGetStringMacro(DistanceAnnotationFormat);
00209
00211
00212 virtual void SetDistanceAnnotationScale( double scale[3] );
00213 virtual double * GetDistanceAnnotationScale();
00215
00217 double GetDistance();
00218
00219 protected:
00220 vtkLineRepresentation();
00221 ~vtkLineRepresentation();
00222
00223
00224 vtkPointHandleRepresentation3D *HandleRepresentation;
00225 vtkPointHandleRepresentation3D *Point1Representation;
00226 vtkPointHandleRepresentation3D *Point2Representation;
00227 vtkPointHandleRepresentation3D *LineHandleRepresentation;
00228
00229
00230 int RepresentationState;
00231
00232
00233 vtkActor *LineActor;
00234 vtkPolyDataMapper *LineMapper;
00235 vtkLineSource *LineSource;
00236
00237
00238 vtkActor **Handle;
00239 vtkPolyDataMapper **HandleMapper;
00240 vtkSphereSource **HandleGeometry;
00241
00242
00243
00244 vtkProperty *EndPointProperty;
00245 vtkProperty *SelectedEndPointProperty;
00246 vtkProperty *LineProperty;
00247 vtkProperty *SelectedLineProperty;
00248 void CreateDefaultProperties();
00249
00250
00251 int Tolerance;
00252
00253
00254 int ClampToBounds;
00255 void ClampPosition(double x[3]);
00256 void HighlightPoint(int ptId, int highlight);
00257 void HighlightLine(int highlight);
00258 int InBounds(double x[3]);
00259 void SizeHandles();
00260
00261
00262 double StartP1[3];
00263 double StartP2[3];
00264 double StartLineHandle[3];
00265 double Length;
00266 double LastEventPosition[3];
00267
00268
00269 vtkBox *BoundingBox;
00270
00271
00272
00273
00274
00275 int InitializedDisplayPosition;
00276
00277
00278 int DistanceAnnotationVisibility;
00279 char *DistanceAnnotationFormat;
00280
00281 vtkFollower *TextActor;
00282 vtkPolyDataMapper *TextMapper;
00283 vtkVectorText *TextInput;
00284 double Distance;
00285 bool AnnotationTextScaleInitialized;
00286
00287 vtkCellPicker *LinePicker;
00288
00289 private:
00290 vtkLineRepresentation(const vtkLineRepresentation&);
00291 void operator=(const vtkLineRepresentation&);
00292 };
00293
00294 #endif