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 "vtkInteractionWidgetsModule.h" // For export macro 00043 #include "vtkHandleRepresentation.h" 00044 00045 class vtkProperty; 00046 class vtkActor; 00047 class vtkPolyDataMapper; 00048 class vtkPolyData; 00049 class vtkGlyph3D; 00050 class vtkPoints; 00051 class vtkPolyData; 00052 class vtkPlane; 00053 class vtkPlaneCollection; 00054 class vtkPlanes; 00055 class vtkRenderer; 00056 00057 class VTKINTERACTIONWIDGETS_EXPORT vtkConstrainedPointHandleRepresentation : public vtkHandleRepresentation 00058 { 00059 public: 00061 static vtkConstrainedPointHandleRepresentation *New(); 00062 00064 00065 vtkTypeMacro(vtkConstrainedPointHandleRepresentation,vtkHandleRepresentation); 00066 void PrintSelf(ostream& os, vtkIndent indent); 00068 00070 00073 void SetCursorShape(vtkPolyData *cursorShape); 00074 vtkPolyData *GetCursorShape(); 00076 00078 00081 void SetActiveCursorShape(vtkPolyData *activeShape); 00082 vtkPolyData *GetActiveCursorShape(); 00084 00086 00089 vtkSetClampMacro(ProjectionNormal,int, 00090 vtkConstrainedPointHandleRepresentation::XAxis, 00091 vtkConstrainedPointHandleRepresentation::Oblique); 00092 vtkGetMacro(ProjectionNormal,int); 00094 00095 void SetProjectionNormalToXAxis() 00096 { this->SetProjectionNormal(vtkConstrainedPointHandleRepresentation::XAxis); } 00097 void SetProjectionNormalToYAxis() 00098 { this->SetProjectionNormal(vtkConstrainedPointHandleRepresentation::YAxis); } 00099 void SetProjectionNormalToZAxis() 00100 { this->SetProjectionNormal(vtkConstrainedPointHandleRepresentation::ZAxis); } 00101 void SetProjectionNormalToOblique() 00102 { this->SetProjectionNormal(vtkConstrainedPointHandleRepresentation::Oblique); } 00103 00105 00107 void SetObliquePlane(vtkPlane *); 00108 vtkGetObjectMacro(ObliquePlane, vtkPlane); 00110 00112 00116 void SetProjectionPosition(double position); 00117 vtkGetMacro(ProjectionPosition, double); 00119 00121 00127 void AddBoundingPlane(vtkPlane *plane); 00128 void RemoveBoundingPlane(vtkPlane *plane); 00129 void RemoveAllBoundingPlanes(); 00130 virtual void SetBoundingPlanes(vtkPlaneCollection*); 00131 vtkGetObjectMacro(BoundingPlanes,vtkPlaneCollection); 00132 void SetBoundingPlanes(vtkPlanes *planes); 00134 00138 virtual int CheckConstraint(vtkRenderer *renderer, double pos[2]); 00139 00141 00144 void SetPosition(double x, double y, double z); 00145 void SetPosition(double xyz[3]); 00146 double* GetPosition(); 00147 void GetPosition(double xyz[3]); 00149 00151 00153 vtkGetObjectMacro(Property,vtkProperty); 00155 00157 00159 vtkGetObjectMacro(SelectedProperty,vtkProperty); 00161 00163 00165 vtkGetObjectMacro(ActiveProperty,vtkProperty); 00167 00169 00172 virtual void SetRenderer(vtkRenderer *ren); 00173 virtual void BuildRepresentation(); 00174 virtual void StartWidgetInteraction(double eventPos[2]); 00175 virtual void WidgetInteraction(double eventPos[2]); 00176 virtual int ComputeInteractionState(int X, int Y, int modify); 00178 00181 virtual void SetDisplayPosition(double pos[3]); 00182 00184 00185 virtual void GetActors(vtkPropCollection *); 00186 virtual void ReleaseGraphicsResources(vtkWindow *); 00187 virtual int RenderOverlay(vtkViewport *viewport); 00188 virtual int RenderOpaqueGeometry(vtkViewport *viewport); 00189 virtual int RenderTranslucentPolygonalGeometry(vtkViewport *viewport); 00190 virtual int HasTranslucentPolygonalGeometry(); 00191 virtual void ShallowCopy(vtkProp* prop); 00193 00194 //BTX 00195 enum {XAxis=0,YAxis,ZAxis,Oblique}; 00196 //ETX 00197 00198 void Highlight(int highlight); 00199 00200 protected: 00201 vtkConstrainedPointHandleRepresentation(); 00202 ~vtkConstrainedPointHandleRepresentation(); 00203 00204 // Render the cursor 00205 vtkActor *Actor; 00206 vtkPolyDataMapper *Mapper; 00207 vtkGlyph3D *Glypher; 00208 vtkPolyData *CursorShape; 00209 vtkPolyData *ActiveCursorShape; 00210 vtkPolyData *FocalData; 00211 vtkPoints *FocalPoint; 00212 00213 // Support picking 00214 double LastPickPosition[3]; 00215 double LastEventPosition[2]; 00216 00217 // Methods to manipulate the cursor 00218 void Translate(double eventPos[2]); 00219 void Scale(double eventPos[2]); 00220 00221 00222 // Properties used to control the appearance of selected objects and 00223 // the manipulator in general. 00224 vtkProperty *Property; 00225 vtkProperty *SelectedProperty; 00226 vtkProperty *ActiveProperty; 00227 void CreateDefaultProperties(); 00228 00229 // Controlling vars 00230 int ProjectionNormal; 00231 double ProjectionPosition; 00232 int ProjectToPlane; 00233 vtkPlane *ObliquePlane; 00234 00235 vtkPlaneCollection *BoundingPlanes; 00236 00237 // Internal method for computing 3D location from 2D screen position 00238 int GetIntersectionPosition( double eventPos[2], 00239 double worldPos[3], 00240 double tolerance = 0.0, 00241 vtkRenderer *renderer=0); 00242 00243 // Internal method for getting the project normal as a vector 00244 void GetProjectionNormal( double normal[3] ); 00245 00246 // Internal method for getting the origin of the 00247 // constraining plane as a 3-tuple 00248 void GetProjectionOrigin( double origin[3] ); 00249 00250 00251 00252 // Distance between where the mouse event happens and where the 00253 // widget is focused - maintain this distance during interaction. 00254 double InteractionOffset[2]; 00255 00256 private: 00257 vtkConstrainedPointHandleRepresentation(const vtkConstrainedPointHandleRepresentation&); //Not implemented 00258 void operator=(const vtkConstrainedPointHandleRepresentation&); //Not implemented 00259 }; 00260 00261 #endif