Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members | Related Pages

Hybrid/vtkPointWidget.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    $RCSfile: vtkPointWidget.h,v $
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 =========================================================================*/
00076 #ifndef __vtkPointWidget_h
00077 #define __vtkPointWidget_h
00078 
00079 #include "vtk3DWidget.h"
00080 #include "vtkCursor3D.h" // Needed for faster access to the Cursor3D
00081 
00082 class vtkActor;
00083 class vtkPolyDataMapper;
00084 class vtkCellPicker;
00085 class vtkPolyData;
00086 class vtkProperty;
00087 
00088 class VTK_HYBRID_EXPORT vtkPointWidget : public vtk3DWidget
00089 {
00090 public:
00092   static vtkPointWidget *New();
00093 
00094   vtkTypeRevisionMacro(vtkPointWidget,vtk3DWidget);
00095   void PrintSelf(ostream& os, vtkIndent indent);
00096 
00098 
00099   virtual void SetEnabled(int);
00100   virtual void PlaceWidget(double bounds[6]);
00101   void PlaceWidget()
00102     {this->Superclass::PlaceWidget();}
00103   void PlaceWidget(double xmin, double xmax, double ymin, double ymax, 
00104                    double zmin, double zmax)
00105     {this->Superclass::PlaceWidget(xmin,xmax,ymin,ymax,zmin,zmax);}
00107 
00110   void GetPolyData(vtkPolyData *pd);
00111   
00113 
00116   void SetPosition(double x, double y, double z)
00117     {this->Cursor3D->SetFocalPoint(x,y,z);}
00118   void SetPosition(double x[3])
00119     {this->SetPosition(x[0],x[1],x[2]);}
00120   double* GetPosition() 
00121     {return this->Cursor3D->GetFocalPoint();}
00122   void GetPosition(double xyz[3]) 
00123     {this->Cursor3D->GetFocalPoint(xyz);}
00125 
00127 
00128   void SetOutline(int o)
00129     {this->Cursor3D->SetOutline(o);}
00130   int GetOutline()
00131     {return this->Cursor3D->GetOutline();}
00132   void OutlineOn()
00133     {this->Cursor3D->OutlineOn();}
00134   void OutlineOff()
00135     {this->Cursor3D->OutlineOff();}
00137 
00139 
00140   void SetXShadows(int o)
00141     {this->Cursor3D->SetXShadows(o);}
00142   int GetXShadows()
00143     {return this->Cursor3D->GetXShadows();}
00144   void XShadowsOn()
00145     {this->Cursor3D->XShadowsOn();}
00146   void XShadowsOff()
00147     {this->Cursor3D->XShadowsOff();}
00149 
00151 
00152   void SetYShadows(int o)
00153     {this->Cursor3D->SetYShadows(o);}
00154   int GetYShadows()
00155     {return this->Cursor3D->GetYShadows();}
00156   void YShadowsOn()
00157     {this->Cursor3D->YShadowsOn();}
00158   void YShadowsOff()
00159     {this->Cursor3D->YShadowsOff();}
00161 
00163 
00164   void SetZShadows(int o)
00165     {this->Cursor3D->SetZShadows(o);}
00166   int GetZShadows()
00167     {return this->Cursor3D->GetZShadows();}
00168   void ZShadowsOn()
00169     {this->Cursor3D->ZShadowsOn();}
00170   void ZShadowsOff()
00171     {this->Cursor3D->ZShadowsOff();}
00173 
00175 
00178   void SetTranslationMode(int mode)
00179     { this->Cursor3D->SetTranslationMode(mode); this->Cursor3D->Update(); }
00180   int GetTranslationMode()
00181     { return this->Cursor3D->GetTranslationMode(); }
00182   void TranslationModeOn()
00183     { this->SetTranslationMode(1); }
00184   void TranslationModeOff()
00185     { this->SetTranslationMode(0); }
00187   
00189 
00190   void AllOn()
00191     {
00192       this->OutlineOn();
00193       this->XShadowsOn();
00194       this->YShadowsOn();
00195       this->ZShadowsOn();
00196     }
00197   void AllOff()
00198     {
00199       this->OutlineOff();
00200       this->XShadowsOff();
00201       this->YShadowsOff();
00202       this->ZShadowsOff();
00203     }
00205 
00207 
00209   vtkGetObjectMacro(Property,vtkProperty);
00210   vtkGetObjectMacro(SelectedProperty,vtkProperty);
00212   
00214 
00218   vtkSetClampMacro(HotSpotSize,double,0.0,1.0);
00219   vtkGetMacro(HotSpotSize,double);
00221   
00222 protected:
00223   vtkPointWidget();
00224   ~vtkPointWidget();
00225 
00226 //BTX - manage the state of the widget
00227   friend class vtkLineWidget;
00228   
00229   int State;
00230   enum WidgetState
00231   {
00232     Start=0,
00233     Moving,
00234     Scaling,
00235     Translating,
00236     Outside
00237   };
00238 //ETX
00239     
00240   // Handles the events
00241   static void ProcessEvents(vtkObject* object, 
00242                             unsigned long event,
00243                             void* clientdata, 
00244                             void* calldata);
00245 
00246   // ProcessEvents() dispatches to these methods.
00247   void OnMouseMove();
00248   void OnLeftButtonDown();
00249   void OnLeftButtonUp();
00250   void OnMiddleButtonDown();
00251   void OnMiddleButtonUp();
00252   void OnRightButtonDown();
00253   void OnRightButtonUp();
00254   
00255   // the cursor3D
00256   vtkActor          *Actor;
00257   vtkPolyDataMapper *Mapper;
00258   vtkCursor3D       *Cursor3D;
00259   void Highlight(int highlight);
00260 
00261   // Do the picking
00262   vtkCellPicker *CursorPicker;
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