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

vtkLineWidget.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    $RCSfile: vtkLineWidget.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 =========================================================================*/
00079 #ifndef __vtkLineWidget_h
00080 #define __vtkLineWidget_h
00081 
00082 #include "vtk3DWidget.h"
00083 #include "vtkLineSource.h" // For passing calls to it
00084 
00085 class vtkActor;
00086 class vtkPolyDataMapper;
00087 class vtkPoints;
00088 class vtkPolyData;
00089 class vtkProp;
00090 class vtkProperty;
00091 class vtkSphereSource;
00092 class vtkCellPicker;
00093 class vtkPointWidget;
00094 class vtkPWCallback;
00095 class vtkPW1Callback;
00096 class vtkPW2Callback;
00097 
00098 class VTK_WIDGETS_EXPORT vtkLineWidget : public vtk3DWidget
00099 {
00100 public:
00102   static vtkLineWidget *New();
00103 
00104   vtkTypeRevisionMacro(vtkLineWidget,vtk3DWidget);
00105   void PrintSelf(ostream& os, vtkIndent indent);
00106 
00108 
00109   virtual void SetEnabled(int);
00110   virtual void PlaceWidget(double bounds[6]);
00111   void PlaceWidget()
00112     {this->Superclass::PlaceWidget();}
00113   void PlaceWidget(double xmin, double xmax, double ymin, double ymax, 
00114                    double zmin, double zmax)
00115     {this->Superclass::PlaceWidget(xmin,xmax,ymin,ymax,zmin,zmax);}
00117 
00119 
00120   void SetResolution(int r)
00121     { this->LineSource->SetResolution(r); }
00122   int GetResolution()
00123     { return this->LineSource->GetResolution(); }
00125 
00127 
00128   void SetPoint1(double x, double y, double z);
00129   void SetPoint1(double x[3]) 
00130     {this->SetPoint1(x[0], x[1], x[2]); }
00131   double* GetPoint1() 
00132     {return this->LineSource->GetPoint1();}
00133   void GetPoint1(double xyz[3]) 
00134     {this->LineSource->GetPoint1(xyz);}
00136 
00138 
00139   void SetPoint2(double x, double y, double z);
00140   void SetPoint2(double x[3]) 
00141     {this->SetPoint2(x[0], x[1], x[2]);}
00142   double* GetPoint2() 
00143     {return this->LineSource->GetPoint2();}
00144   void GetPoint2(double xyz[3]) 
00145     {this->LineSource->GetPoint2(xyz);}
00147 
00149 
00153   vtkSetClampMacro(Align, int, XAxis, None);
00154   vtkGetMacro(Align, int);
00155   void SetAlignToXAxis() { this->SetAlign(XAxis); }
00156   void SetAlignToYAxis() { this->SetAlign(YAxis); }
00157   void SetAlignToZAxis() { this->SetAlign(ZAxis); }
00158   void SetAlignToNone()  { this->SetAlign(None); }
00160 
00162 
00166   vtkSetMacro(ClampToBounds,int);
00167   vtkGetMacro(ClampToBounds,int);
00168   vtkBooleanMacro(ClampToBounds,int);
00170 
00176   void GetPolyData(vtkPolyData *pd);
00177 
00179 
00182   vtkGetObjectMacro(HandleProperty,vtkProperty);
00183   vtkGetObjectMacro(SelectedHandleProperty,vtkProperty);
00185   
00187 
00189   vtkGetObjectMacro(LineProperty,vtkProperty);
00190   vtkGetObjectMacro(SelectedLineProperty,vtkProperty);
00192   
00193 protected:
00194   vtkLineWidget();
00195   ~vtkLineWidget();
00196 
00197 //BTX - manage the state of the widget
00198   friend class vtkPWCallback;
00199 
00200   int State;
00201   enum WidgetState
00202   {
00203     Start=0,
00204     MovingHandle,
00205     MovingLine,
00206     Scaling,
00207     Outside
00208   };
00209 //ETX
00210     
00211   //handles the events
00212   static void ProcessEvents(vtkObject* object, 
00213                             unsigned long event,
00214                             void* clientdata, 
00215                             void* calldata);
00216 
00217   // ProcessEvents() dispatches to these methods.
00218   void OnLeftButtonDown();
00219   void OnLeftButtonUp();
00220   void OnMiddleButtonDown();
00221   void OnMiddleButtonUp();
00222   void OnRightButtonDown();
00223   void OnRightButtonUp();
00224   virtual void OnMouseMove();
00225 
00226   // controlling ivars
00227   int Align;
00228 
00229 //BTX
00230   enum AlignmentState {    
00231     XAxis,
00232     YAxis,
00233     ZAxis,
00234     None
00235   };
00236 //ETX
00237 
00238   // the line
00239   vtkActor          *LineActor;
00240   vtkPolyDataMapper *LineMapper;
00241   vtkLineSource     *LineSource;
00242   void HighlightLine(int highlight);
00243 
00244   // glyphs representing hot spots (e.g., handles)
00245   vtkActor          **Handle;
00246   vtkPolyDataMapper **HandleMapper;
00247   vtkSphereSource   **HandleGeometry;
00248 
00249   void BuildRepresentation();
00250   virtual void SizeHandles();
00251   void HandlesOn(double length);
00252   void HandlesOff();
00253   int HighlightHandle(vtkProp *prop); //returns cell id
00254   void HighlightHandles(int highlight);
00255   
00256   // Do the picking
00257   vtkCellPicker *HandlePicker;
00258   vtkCellPicker *LinePicker;
00259   vtkActor *CurrentHandle;
00260   double LastPosition[3];
00261   void  SetLinePosition(double x[3]);
00262   
00263   // Methods to manipulate the hexahedron.
00264   void Scale(double *p1, double *p2, int X, int Y);
00265   
00266   // Initial bounds
00267   int   ClampToBounds;
00268   void  ClampPosition(double x[3]);
00269   int   InBounds(double x[3]);
00270 
00271   // Properties used to control the appearance of selected objects and
00272   // the manipulator in general.
00273   vtkProperty *HandleProperty;
00274   vtkProperty *SelectedHandleProperty;
00275   vtkProperty *LineProperty;
00276   vtkProperty *SelectedLineProperty;
00277   void CreateDefaultProperties();
00278   
00279   void GenerateLine();
00280   
00281   // Methods for managing the point widgets used to control the endpoints
00282   vtkPointWidget *PointWidget;
00283   vtkPointWidget *PointWidget1;
00284   vtkPointWidget *PointWidget2;
00285   vtkPWCallback  *PWCallback;
00286   vtkPW1Callback *PW1Callback;
00287   vtkPW2Callback *PW2Callback;
00288   vtkPointWidget *CurrentPointWidget;
00289   void EnablePointWidget();
00290   void DisablePointWidget();
00291   int ForwardEvent(unsigned long event);
00292   
00293 private:
00294   vtkLineWidget(const vtkLineWidget&);  //Not implemented
00295   void operator=(const vtkLineWidget&);  //Not implemented
00296 };
00297 
00298 #endif

Generated on Mon Jan 21 23:07:38 2008 for VTK by  doxygen 1.4.3-20050530