VTK
|
00001 /*========================================================================= 00002 00003 Program: Visualization Toolkit 00004 Module: vtkPointHandleRepresentation3D.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 =========================================================================*/ 00029 #ifndef __vtkPointHandleRepresentation3D_h 00030 #define __vtkPointHandleRepresentation3D_h 00031 00032 #include "vtkInteractionWidgetsModule.h" // For export macro 00033 #include "vtkHandleRepresentation.h" 00034 #include "vtkCursor3D.h" // Needed for delegation to cursor3D 00035 00036 class vtkCursor3D; 00037 class vtkProperty; 00038 class vtkActor; 00039 class vtkPolyDataMapper; 00040 class vtkCellPicker; 00041 00042 class VTKINTERACTIONWIDGETS_EXPORT vtkPointHandleRepresentation3D : public vtkHandleRepresentation 00043 { 00044 public: 00046 static vtkPointHandleRepresentation3D *New(); 00047 00049 00050 vtkTypeMacro(vtkPointHandleRepresentation3D,vtkHandleRepresentation); 00051 void PrintSelf(ostream& os, vtkIndent indent); 00053 00055 00060 virtual void SetWorldPosition(double p[3]); 00061 virtual void SetDisplayPosition(double p[3]); 00063 00065 00066 void SetOutline(int o) 00067 {this->Cursor3D->SetOutline(o);} 00068 int GetOutline() 00069 {return this->Cursor3D->GetOutline();} 00070 void OutlineOn() 00071 {this->Cursor3D->OutlineOn();} 00072 void OutlineOff() 00073 {this->Cursor3D->OutlineOff();} 00075 00077 00078 void SetXShadows(int o) 00079 {this->Cursor3D->SetXShadows(o);} 00080 int GetXShadows() 00081 {return this->Cursor3D->GetXShadows();} 00082 void XShadowsOn() 00083 {this->Cursor3D->XShadowsOn();} 00084 void XShadowsOff() 00085 {this->Cursor3D->XShadowsOff();} 00087 00089 00090 void SetYShadows(int o) 00091 {this->Cursor3D->SetYShadows(o);} 00092 int GetYShadows() 00093 {return this->Cursor3D->GetYShadows();} 00094 void YShadowsOn() 00095 {this->Cursor3D->YShadowsOn();} 00096 void YShadowsOff() 00097 {this->Cursor3D->YShadowsOff();} 00099 00101 00102 void SetZShadows(int o) 00103 {this->Cursor3D->SetZShadows(o);} 00104 int GetZShadows() 00105 {return this->Cursor3D->GetZShadows();} 00106 void ZShadowsOn() 00107 {this->Cursor3D->ZShadowsOn();} 00108 void ZShadowsOff() 00109 {this->Cursor3D->ZShadowsOff();} 00111 00113 00123 void SetTranslationMode(int mode); 00124 vtkGetMacro(TranslationMode,int); 00125 vtkBooleanMacro(TranslationMode,int); 00127 00129 00130 void AllOn() 00131 { 00132 this->OutlineOn(); 00133 this->XShadowsOn(); 00134 this->YShadowsOn(); 00135 this->ZShadowsOn(); 00136 } 00137 void AllOff() 00138 { 00139 this->OutlineOff(); 00140 this->XShadowsOff(); 00141 this->YShadowsOff(); 00142 this->ZShadowsOff(); 00143 } 00145 00147 00148 void SetProperty(vtkProperty*); 00149 void SetSelectedProperty(vtkProperty*); 00150 vtkGetObjectMacro(Property,vtkProperty); 00151 vtkGetObjectMacro(SelectedProperty,vtkProperty); 00153 00155 00159 vtkSetClampMacro(HotSpotSize,double,0.0,1.0); 00160 vtkGetMacro(HotSpotSize,double); 00162 00165 virtual void SetHandleSize(double size); 00166 00168 00170 virtual double *GetBounds(); 00171 virtual void BuildRepresentation(); 00172 virtual void StartWidgetInteraction(double eventPos[2]); 00173 virtual void WidgetInteraction(double eventPos[2]); 00174 virtual int ComputeInteractionState(int X, int Y, int modify=0); 00175 virtual void PlaceWidget(double bounds[6]); 00177 00179 00180 virtual void ShallowCopy(vtkProp *prop); 00181 virtual void DeepCopy(vtkProp *prop); 00182 virtual void GetActors(vtkPropCollection *); 00183 virtual void ReleaseGraphicsResources(vtkWindow *); 00184 virtual int RenderOpaqueGeometry(vtkViewport *viewport); 00185 virtual int RenderTranslucentPolygonalGeometry(vtkViewport *viewport); 00186 virtual int HasTranslucentPolygonalGeometry(); 00188 00189 void Highlight(int highlight); 00190 00192 00202 vtkSetMacro( SmoothMotion, int ); 00203 vtkGetMacro( SmoothMotion, int ); 00204 vtkBooleanMacro( SmoothMotion, int ); 00206 00207 protected: 00208 vtkPointHandleRepresentation3D(); 00209 ~vtkPointHandleRepresentation3D(); 00210 00211 // the cursor3D 00212 vtkActor *Actor; 00213 vtkPolyDataMapper *Mapper; 00214 vtkCursor3D *Cursor3D; 00215 00216 00217 // Do the picking 00218 vtkCellPicker *CursorPicker; 00219 double LastPickPosition[3]; 00220 double LastEventPosition[2]; 00221 00222 // Register internal Pickers within PickingManager 00223 virtual void RegisterPickers(); 00224 00225 // Methods to manipulate the cursor 00226 int ConstraintAxis; 00227 void Translate(double *p1, double *p2); 00228 void Scale(double *p1, double *p2, double eventPos[2]); 00229 void MoveFocus(double *p1, double *p2); 00230 void SizeBounds(); 00231 00232 // Given a motion vector defined by p1 --> p2 (p1 and p2 are in 00233 // world coordinates), the new display position of the handle center is 00234 // populated into requestedDisplayPos. This is again only a request for the 00235 // new display position. It is up to the point placer to deduce the 00236 // appropriate world co-ordinates that this display position will map into. 00237 // The placer may even disallow such a movement. 00238 // If "SmoothMotion" is OFF, the returned requestedDisplayPos is the same 00239 // as the event position, ie the location of the mouse cursor. If its OFF, 00240 // incremental offsets as described above are used to compute it. 00241 void MoveFocusRequest( double *p1, double *p2, 00242 double eventPos[2], double requestedDisplayPos[3] ); 00243 00244 // Properties used to control the appearance of selected objects and 00245 // the manipulator in general. 00246 vtkProperty *Property; 00247 vtkProperty *SelectedProperty; 00248 void CreateDefaultProperties(); 00249 00250 // The size of the hot spot. 00251 double HotSpotSize; 00252 int DetermineConstraintAxis(int constraint, double *x, double *startPoint); 00253 int WaitingForMotion; 00254 int WaitCount; 00255 00256 // Current handle sized (may reflect scaling) 00257 double CurrentHandleSize; 00258 00259 // Control how translation works 00260 int TranslationMode; 00261 00262 int SmoothMotion; 00263 00264 private: 00265 vtkPointHandleRepresentation3D(const vtkPointHandleRepresentation3D&); //Not implemented 00266 void operator=(const vtkPointHandleRepresentation3D&); //Not implemented 00267 }; 00268 00269 #endif