VTK
|
00001 /*========================================================================= 00002 00003 Program: Visualization Toolkit 00004 Module: vtkConstrainedPointHandleRepresentation.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 =========================================================================*/ 00039 #ifndef __vtkConstrainedPointHandleRepresentation_h 00040 #define __vtkConstrainedPointHandleRepresentation_h 00041 00042 #include "vtkHandleRepresentation.h" 00043 00044 class vtkProperty; 00045 class vtkActor; 00046 class vtkPolyDataMapper; 00047 class vtkPolyData; 00048 class vtkGlyph3D; 00049 class vtkPoints; 00050 class vtkPolyData; 00051 class vtkPlane; 00052 class vtkPlaneCollection; 00053 class vtkPlanes; 00054 class vtkRenderer; 00055 00056 class VTK_WIDGETS_EXPORT vtkConstrainedPointHandleRepresentation : public vtkHandleRepresentation 00057 { 00058 public: 00060 static vtkConstrainedPointHandleRepresentation *New(); 00061 00063 00064 vtkTypeMacro(vtkConstrainedPointHandleRepresentation,vtkHandleRepresentation); 00065 void PrintSelf(ostream& os, vtkIndent indent); 00067 00069 00072 void SetCursorShape(vtkPolyData *cursorShape); 00073 vtkPolyData *GetCursorShape(); 00075 00077 00080 void SetActiveCursorShape(vtkPolyData *activeShape); 00081 vtkPolyData *GetActiveCursorShape(); 00083 00085 00088 vtkSetClampMacro(ProjectionNormal,int, 00089 vtkConstrainedPointHandleRepresentation::XAxis, 00090 vtkConstrainedPointHandleRepresentation::Oblique); 00091 vtkGetMacro(ProjectionNormal,int); 00093 00094 void SetProjectionNormalToXAxis() 00095 { this->SetProjectionNormal(vtkConstrainedPointHandleRepresentation::XAxis); } 00096 void SetProjectionNormalToYAxis() 00097 { this->SetProjectionNormal(vtkConstrainedPointHandleRepresentation::YAxis); } 00098 void SetProjectionNormalToZAxis() 00099 { this->SetProjectionNormal(vtkConstrainedPointHandleRepresentation::ZAxis); } 00100 void SetProjectionNormalToOblique() 00101 { this->SetProjectionNormal(vtkConstrainedPointHandleRepresentation::Oblique); } 00102 00104 00106 void SetObliquePlane(vtkPlane *); 00107 vtkGetObjectMacro(ObliquePlane, vtkPlane); 00109 00111 00115 void SetProjectionPosition(double position); 00116 vtkGetMacro(ProjectionPosition, double); 00118 00120 00126 void AddBoundingPlane(vtkPlane *plane); 00127 void RemoveBoundingPlane(vtkPlane *plane); 00128 void RemoveAllBoundingPlanes(); 00129 virtual void SetBoundingPlanes(vtkPlaneCollection*); 00130 vtkGetObjectMacro(BoundingPlanes,vtkPlaneCollection); 00131 void SetBoundingPlanes(vtkPlanes *planes); 00133 00137 virtual int CheckConstraint(vtkRenderer *renderer, double pos[2]); 00138 00140 00143 void SetPosition(double x, double y, double z); 00144 void SetPosition(double xyz[3]); 00145 double* GetPosition(); 00146 void GetPosition(double xyz[3]); 00148 00150 00152 vtkGetObjectMacro(Property,vtkProperty); 00154 00156 00158 vtkGetObjectMacro(SelectedProperty,vtkProperty); 00160 00162 00164 vtkGetObjectMacro(ActiveProperty,vtkProperty); 00166 00168 00171 virtual void SetRenderer(vtkRenderer *ren); 00172 virtual void BuildRepresentation(); 00173 virtual void StartWidgetInteraction(double eventPos[2]); 00174 virtual void WidgetInteraction(double eventPos[2]); 00175 virtual int ComputeInteractionState(int X, int Y, int modify); 00177 00180 virtual void SetDisplayPosition(double pos[3]); 00181 00183 00184 virtual void GetActors(vtkPropCollection *); 00185 virtual void ReleaseGraphicsResources(vtkWindow *); 00186 virtual int RenderOverlay(vtkViewport *viewport); 00187 virtual int RenderOpaqueGeometry(vtkViewport *viewport); 00188 virtual int RenderTranslucentPolygonalGeometry(vtkViewport *viewport); 00189 virtual int HasTranslucentPolygonalGeometry(); 00190 virtual void ShallowCopy(vtkProp* prop); 00192 00193 //BTX 00194 enum {XAxis=0,YAxis,ZAxis,Oblique}; 00195 //ETX 00196 00197 void Highlight(int highlight); 00198 00199 protected: 00200 vtkConstrainedPointHandleRepresentation(); 00201 ~vtkConstrainedPointHandleRepresentation(); 00202 00203 // Render the cursor 00204 vtkActor *Actor; 00205 vtkPolyDataMapper *Mapper; 00206 vtkGlyph3D *Glypher; 00207 vtkPolyData *CursorShape; 00208 vtkPolyData *ActiveCursorShape; 00209 vtkPolyData *FocalData; 00210 vtkPoints *FocalPoint; 00211 00212 // Support picking 00213 double LastPickPosition[3]; 00214 double LastEventPosition[2]; 00215 00216 // Methods to manipulate the cursor 00217 void Translate(double eventPos[2]); 00218 void Scale(double eventPos[2]); 00219 00220 00221 // Properties used to control the appearance of selected objects and 00222 // the manipulator in general. 00223 vtkProperty *Property; 00224 vtkProperty *SelectedProperty; 00225 vtkProperty *ActiveProperty; 00226 void CreateDefaultProperties(); 00227 00228 // Controlling vars 00229 int ProjectionNormal; 00230 double ProjectionPosition; 00231 int ProjectToPlane; 00232 vtkPlane *ObliquePlane; 00233 00234 vtkPlaneCollection *BoundingPlanes; 00235 00236 // Internal method for computing 3D location from 2D screen position 00237 int GetIntersectionPosition( double eventPos[2], 00238 double worldPos[3], 00239 double tolerance = 0.0, 00240 vtkRenderer *renderer=0); 00241 00242 // Internal method for getting the project normal as a vector 00243 void GetProjectionNormal( double normal[3] ); 00244 00245 // Internal method for getting the origin of the 00246 // constraining plane as a 3-tuple 00247 void GetProjectionOrigin( double origin[3] ); 00248 00249 00250 00251 // Distance between where the mouse event happens and where the 00252 // widget is focused - maintain this distance during interaction. 00253 double InteractionOffset[2]; 00254 00255 private: 00256 vtkConstrainedPointHandleRepresentation(const vtkConstrainedPointHandleRepresentation&); //Not implemented 00257 void operator=(const vtkConstrainedPointHandleRepresentation&); //Not implemented 00258 }; 00259 00260 #endif