VTK
|
00001 /*========================================================================= 00002 00003 Program: Visualization Toolkit 00004 Module: vtkAbstractPolygonalHandleRepresentation3D.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 =========================================================================*/ 00033 #ifndef vtkAbstractPolygonalHandleRepresentation3D_h 00034 #define vtkAbstractPolygonalHandleRepresentation3D_h 00035 00036 #include "vtkInteractionWidgetsModule.h" // For export macro 00037 #include "vtkHandleRepresentation.h" 00038 00039 class vtkProperty; 00040 class vtkPolyDataMapper; 00041 class vtkCellPicker; 00042 class vtkTransformPolyDataFilter; 00043 class vtkMatrixToLinearTransform; 00044 class vtkMatrix4x4; 00045 class vtkPolyData; 00046 class vtkAbstractTransform; 00047 class vtkActor; 00048 class vtkFollower; 00049 class vtkVectorText; 00050 00051 class VTKINTERACTIONWIDGETS_EXPORT vtkAbstractPolygonalHandleRepresentation3D 00052 : public vtkHandleRepresentation 00053 { 00054 public: 00055 00057 00058 vtkTypeMacro(vtkAbstractPolygonalHandleRepresentation3D,vtkHandleRepresentation); 00059 void PrintSelf(ostream& os, vtkIndent indent); 00061 00063 00064 virtual void SetWorldPosition(double p[3]); 00065 virtual void SetDisplayPosition(double p[3]); 00067 00069 00070 void SetHandle( vtkPolyData * ); 00071 vtkPolyData * GetHandle(); 00073 00075 00076 void SetProperty(vtkProperty*); 00077 void SetSelectedProperty(vtkProperty*); 00078 vtkGetObjectMacro(Property,vtkProperty); 00079 vtkGetObjectMacro(SelectedProperty,vtkProperty); 00081 00084 virtual vtkAbstractTransform * GetTransform(); 00085 00087 00089 virtual void BuildRepresentation(); 00090 virtual void StartWidgetInteraction(double eventPos[2]); 00091 virtual void WidgetInteraction(double eventPos[2]); 00092 virtual int ComputeInteractionState(int X, int Y, int modify=0); 00094 00096 00097 virtual void ShallowCopy(vtkProp *prop); 00098 virtual void DeepCopy(vtkProp *prop); 00099 virtual void GetActors(vtkPropCollection *); 00100 virtual void ReleaseGraphicsResources(vtkWindow *); 00101 virtual int RenderOpaqueGeometry(vtkViewport *viewport); 00102 virtual int RenderTranslucentPolygonalGeometry(vtkViewport *viewport); 00103 virtual int HasTranslucentPolygonalGeometry(); 00104 virtual double *GetBounds(); 00106 00108 00110 vtkSetMacro( LabelVisibility, int ); 00111 vtkGetMacro( LabelVisibility, int ); 00112 vtkBooleanMacro( LabelVisibility, int ); 00113 virtual void SetLabelText( const char * label ); 00114 virtual char * GetLabelText(); 00116 00118 00119 virtual void SetLabelTextScale( double scale[3] ); 00120 void SetLabelTextScale(double x, double y, double z) 00121 { 00122 double scale[3] = {x, y, z}; 00123 this->SetLabelTextScale(scale); 00124 } 00125 virtual double * GetLabelTextScale(); 00127 00129 00130 vtkGetObjectMacro( LabelTextActor, vtkFollower ); 00132 00136 virtual void SetUniformScale( double scale ); 00137 00139 00140 vtkSetMacro( HandleVisibility, int ); 00141 vtkGetMacro( HandleVisibility, int ); 00142 vtkBooleanMacro( HandleVisibility, int ); 00144 00145 void Highlight(int highlight); 00146 00148 00158 vtkSetMacro( SmoothMotion, int ); 00159 vtkGetMacro( SmoothMotion, int ); 00160 vtkBooleanMacro( SmoothMotion, int ); 00162 00163 protected: 00164 vtkAbstractPolygonalHandleRepresentation3D(); 00165 ~vtkAbstractPolygonalHandleRepresentation3D(); 00166 00167 vtkActor * Actor; 00168 vtkPolyDataMapper * Mapper; 00169 vtkTransformPolyDataFilter * HandleTransformFilter; 00170 vtkMatrixToLinearTransform * HandleTransform; 00171 vtkMatrix4x4 * HandleTransformMatrix; 00172 vtkCellPicker * HandlePicker; 00173 double LastPickPosition[3]; 00174 double LastEventPosition[2]; 00175 int ConstraintAxis; 00176 vtkProperty * Property; 00177 vtkProperty * SelectedProperty; 00178 int WaitingForMotion; 00179 int WaitCount; 00180 int HandleVisibility; 00181 00182 // Register internal Pickers within PickingManager 00183 virtual void RegisterPickers(); 00184 00185 // Methods to manipulate the cursor 00186 virtual void Translate(double *p1, double *p2); 00187 virtual void Scale(double *p1, double *p2, double eventPos[2]); 00188 virtual void MoveFocus(double *p1, double *p2); 00189 00190 void CreateDefaultProperties(); 00191 00192 // Given a motion vector defined by p1 --> p2 (p1 and p2 are in 00193 // world coordinates), the new display position of the handle center is 00194 // populated into requestedDisplayPos. This is again only a request for the 00195 // new display position. It is up to the point placer to deduce the 00196 // appropriate world co-ordinates that this display position will map into. 00197 // The placer may even disallow such a movement. 00198 // If "SmoothMotion" is OFF, the returned requestedDisplayPos is the same 00199 // as the event position, ie the location of the mouse cursor. If its OFF, 00200 // incremental offsets as described above are used to compute it. 00201 void MoveFocusRequest( double *p1, double *p2, 00202 double eventPos[2], double requestedDisplayPos[3] ); 00203 00204 int DetermineConstraintAxis(int constraint, double *x, double *startPickPos); 00205 00213 virtual void UpdateHandle(); 00214 00216 virtual void UpdateLabel(); 00217 00218 // Handle the label. 00219 int LabelVisibility; 00220 vtkFollower *LabelTextActor; 00221 vtkPolyDataMapper *LabelTextMapper; 00222 vtkVectorText *LabelTextInput; 00223 bool LabelAnnotationTextScaleInitialized; 00224 int SmoothMotion; 00225 00226 private: 00227 vtkAbstractPolygonalHandleRepresentation3D(const vtkAbstractPolygonalHandleRepresentation3D&); //Not implemented 00228 void operator=(const vtkAbstractPolygonalHandleRepresentation3D&); //Not implemented 00229 }; 00230 00231 #endif 00232 00233