VTK
/Users/kitware/Dashboards/MyTests/VTK_BLD_Release_docs/Utilities/Doxygen/dox/Interaction/Widgets/vtkPointWidget.h
Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    vtkPointWidget.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 =========================================================================*/
00072 #ifndef vtkPointWidget_h
00073 #define vtkPointWidget_h
00074 
00075 #include "vtkInteractionWidgetsModule.h" // For export macro
00076 #include "vtk3DWidget.h"
00077 #include "vtkCursor3D.h" // Needed for faster access to the Cursor3D
00078 
00079 class vtkActor;
00080 class vtkPolyDataMapper;
00081 class vtkCellPicker;
00082 class vtkPolyData;
00083 class vtkProperty;
00084 
00085 class VTKINTERACTIONWIDGETS_EXPORT vtkPointWidget : public vtk3DWidget
00086 {
00087 public:
00089   static vtkPointWidget *New();
00090 
00091   vtkTypeMacro(vtkPointWidget,vtk3DWidget);
00092   void PrintSelf(ostream& os, vtkIndent indent);
00093 
00095 
00096   virtual void SetEnabled(int);
00097   virtual void PlaceWidget(double bounds[6]);
00098   void PlaceWidget()
00099     {this->Superclass::PlaceWidget();}
00100   void PlaceWidget(double xmin, double xmax, double ymin, double ymax,
00101                    double zmin, double zmax)
00102     {this->Superclass::PlaceWidget(xmin,xmax,ymin,ymax,zmin,zmax);}
00104 
00107   void GetPolyData(vtkPolyData *pd);
00108 
00110 
00113   void SetPosition(double x, double y, double z)
00114     {this->Cursor3D->SetFocalPoint(x,y,z);}
00115   void SetPosition(double x[3])
00116     {this->SetPosition(x[0],x[1],x[2]);}
00117   double* GetPosition()
00118     {return this->Cursor3D->GetFocalPoint();}
00119   void GetPosition(double xyz[3])
00120     {this->Cursor3D->GetFocalPoint(xyz);}
00122 
00124 
00125   void SetOutline(int o)
00126     {this->Cursor3D->SetOutline(o);}
00127   int GetOutline()
00128     {return this->Cursor3D->GetOutline();}
00129   void OutlineOn()
00130     {this->Cursor3D->OutlineOn();}
00131   void OutlineOff()
00132     {this->Cursor3D->OutlineOff();}
00134 
00136 
00137   void SetXShadows(int o)
00138     {this->Cursor3D->SetXShadows(o);}
00139   int GetXShadows()
00140     {return this->Cursor3D->GetXShadows();}
00141   void XShadowsOn()
00142     {this->Cursor3D->XShadowsOn();}
00143   void XShadowsOff()
00144     {this->Cursor3D->XShadowsOff();}
00146 
00148 
00149   void SetYShadows(int o)
00150     {this->Cursor3D->SetYShadows(o);}
00151   int GetYShadows()
00152     {return this->Cursor3D->GetYShadows();}
00153   void YShadowsOn()
00154     {this->Cursor3D->YShadowsOn();}
00155   void YShadowsOff()
00156     {this->Cursor3D->YShadowsOff();}
00158 
00160 
00161   void SetZShadows(int o)
00162     {this->Cursor3D->SetZShadows(o);}
00163   int GetZShadows()
00164     {return this->Cursor3D->GetZShadows();}
00165   void ZShadowsOn()
00166     {this->Cursor3D->ZShadowsOn();}
00167   void ZShadowsOff()
00168     {this->Cursor3D->ZShadowsOff();}
00170 
00172 
00175   void SetTranslationMode(int mode)
00176     { this->Cursor3D->SetTranslationMode(mode); this->Cursor3D->Update(); }
00177   int GetTranslationMode()
00178     { return this->Cursor3D->GetTranslationMode(); }
00179   void TranslationModeOn()
00180     { this->SetTranslationMode(1); }
00181   void TranslationModeOff()
00182     { this->SetTranslationMode(0); }
00184 
00186 
00187   void AllOn()
00188     {
00189       this->OutlineOn();
00190       this->XShadowsOn();
00191       this->YShadowsOn();
00192       this->ZShadowsOn();
00193     }
00194   void AllOff()
00195     {
00196       this->OutlineOff();
00197       this->XShadowsOff();
00198       this->YShadowsOff();
00199       this->ZShadowsOff();
00200     }
00202 
00204 
00206   vtkGetObjectMacro(Property,vtkProperty);
00207   vtkGetObjectMacro(SelectedProperty,vtkProperty);
00209 
00211 
00215   vtkSetClampMacro(HotSpotSize,double,0.0,1.0);
00216   vtkGetMacro(HotSpotSize,double);
00218 
00219 protected:
00220   vtkPointWidget();
00221   ~vtkPointWidget();
00222 
00223 //BTX - manage the state of the widget
00224   friend class vtkLineWidget;
00225 
00226   int State;
00227   enum WidgetState
00228   {
00229     Start=0,
00230     Moving,
00231     Scaling,
00232     Translating,
00233     Outside
00234   };
00235 //ETX
00236 
00237   // Handles the events
00238   static void ProcessEvents(vtkObject* object,
00239                             unsigned long event,
00240                             void* clientdata,
00241                             void* calldata);
00242 
00243   // ProcessEvents() dispatches to these methods.
00244   virtual void OnMouseMove();
00245   virtual void OnLeftButtonDown();
00246   virtual void OnLeftButtonUp();
00247   virtual void OnMiddleButtonDown();
00248   virtual void OnMiddleButtonUp();
00249   virtual void OnRightButtonDown();
00250   virtual void OnRightButtonUp();
00251 
00252   // the cursor3D
00253   vtkActor          *Actor;
00254   vtkPolyDataMapper *Mapper;
00255   vtkCursor3D       *Cursor3D;
00256   void Highlight(int highlight);
00257 
00258   // Do the picking
00259   vtkCellPicker *CursorPicker;
00260 
00261   // Register internal Pickers within PickingManager
00262   virtual void RegisterPickers();
00263 
00264   // Methods to manipulate the cursor
00265   int ConstraintAxis;
00266   void Translate(double *p1, double *p2);
00267   void Scale(double *p1, double *p2, int X, int Y);
00268   void MoveFocus(double *p1, double *p2);
00269   int TranslationMode;
00270 
00271   // Properties used to control the appearance of selected objects and
00272   // the manipulator in general.
00273   vtkProperty *Property;
00274   vtkProperty *SelectedProperty;
00275   void CreateDefaultProperties();
00276 
00277   // The size of the hot spot.
00278   double HotSpotSize;
00279   int DetermineConstraintAxis(int constraint, double *x);
00280   int WaitingForMotion;
00281   int WaitCount;
00282 
00283 private:
00284   vtkPointWidget(const vtkPointWidget&);  //Not implemented
00285   void operator=(const vtkPointWidget&);  //Not implemented
00286 };
00287 
00288 #endif