Hybrid/vtkPlaneWidget.h Source File

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

# Hybrid/vtkPlaneWidget.h

Go to the documentation of this file.

    00001 /*=========================================================================
    00002
    00003   Program:   Visualization Toolkit
    00004   Module:    $RCSfile: vtkPlaneWidget.h,v $
    00005   Language:  C++
    00006
    00007   Copyright (c) 1993-2002 Ken Martin, Will Schroeder, Bill Lorensen
    00008   All rights reserved.
    00009   See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
    00010
    00011      This software is distributed WITHOUT ANY WARRANTY; without even
    00012      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
    00013      PURPOSE.  See the above copyright notice for more information.
    00014
    00015 =========================================================================*/
    00101 #ifndef __vtkPlaneWidget_h
    00102 #define __vtkPlaneWidget_h
    00103
    00104 #include "vtkPolyDataSourceWidget.h"
    00105
    00106 class vtkActor;
    00107 class vtkCellPicker;
    00108 class vtkConeSource;
    00109 class vtkLineSource;
    00110 class vtkPlaneSource;
    00111 class vtkPoints;
    00112 class vtkPolyData;
    00113 class vtkPolyDataMapper;
    00114 class vtkProp;
    00115 class vtkProperty;
    00116 class vtkSphereSource;
    00117 class vtkTransform;
    00118 class vtkPlane;
    00119
    00120 #define VTK_PLANE_OFF 0
    00121 #define VTK_PLANE_OUTLINE 1
    00122 #define VTK_PLANE_WIREFRAME 2
    00123 #define VTK_PLANE_SURFACE 3
    00124
    00125 class VTK_HYBRID_EXPORT vtkPlaneWidget : public vtkPolyDataSourceWidget
    00126 {
    00127 public:
    00129   static vtkPlaneWidget *New();
    00130
    00131   vtkTypeRevisionMacro(vtkPlaneWidget,vtkPolyDataSourceWidget);
    00132   void PrintSelf(ostream& os, vtkIndent indent);
    00133
    00135
    00136   virtual void SetEnabled(int);
    00137   virtual void PlaceWidget(float bounds[6]);
    00138   void PlaceWidget()
    00139     {this->Superclass::PlaceWidget();}
    00141
    00143
    00144   void SetResolution(int r);
    00145   int GetResolution();
    00147
    00149
    00150   void SetOrigin(float x, float y, float z);
    00151   void SetOrigin(float x[3]);
    00152   float* GetOrigin();
    00153   void GetOrigin(float xyz[3]);
    00155
    00157
    00159   void SetPoint1(float x, float y, float z);
    00160   void SetPoint1(float x[3]);
    00161   float* GetPoint1();
    00162   void GetPoint1(float xyz[3]);
    00164
    00166
    00168   void SetPoint2(float x, float y, float z);
    00169   void SetPoint2(float x[3]);
    00170   float* GetPoint2();
    00171   void GetPoint2(float xyz[3]);
    00173
    00175
    00176   void SetCenter(float x, float y, float z);
    00177   void SetCenter(float x[3]);
    00178   float* GetCenter();
    00179   void GetCenter(float xyz[3]);
    00181
    00183
    00184   void SetNormal(float x, float y, float z);
    00185   void SetNormal(float x[3]);
    00186   float* GetNormal();
    00187   void GetNormal(float xyz[3]);
    00189
    00191
    00196   vtkSetClampMacro(Representation,int,VTK_PLANE_OFF,VTK_PLANE_SURFACE);
    00197   vtkGetMacro(Representation,int);
    00198   void SetRepresentationToOff()
    00199     {this->SetRepresentation(VTK_PLANE_OFF);}
    00200   void SetRepresentationToOutline()
    00201     {this->SetRepresentation(VTK_PLANE_OUTLINE);}
    00202   void SetRepresentationToWireframe()
    00203     {this->SetRepresentation(VTK_PLANE_WIREFRAME);}
    00204   void SetRepresentationToSurface()
    00205     {this->SetRepresentation(VTK_PLANE_SURFACE);}
    00207
    00209
    00213   vtkSetMacro(NormalToXAxis,int);
    00214   vtkGetMacro(NormalToXAxis,int);
    00215   vtkBooleanMacro(NormalToXAxis,int);
    00216   vtkSetMacro(NormalToYAxis,int);
    00217   vtkGetMacro(NormalToYAxis,int);
    00218   vtkBooleanMacro(NormalToYAxis,int);
    00219   vtkSetMacro(NormalToZAxis,int);
    00220   vtkGetMacro(NormalToZAxis,int);
    00221   vtkBooleanMacro(NormalToZAxis,int);
    00223
    00231   void GetPolyData(vtkPolyData *pd);
    00232
    00238   void GetPlane(vtkPlane *plane);
    00239
    00245   vtkPolyDataSource* GetPolyDataSource();
    00246
    00249   void UpdatePlacement(void);
    00250
    00252
    00255   vtkGetObjectMacro(HandleProperty,vtkProperty);
    00256   vtkGetObjectMacro(SelectedHandleProperty,vtkProperty);
    00258
    00260
    00262   virtual void SetPlaneProperty(vtkProperty*);
    00263   vtkGetObjectMacro(PlaneProperty,vtkProperty);
    00264   vtkGetObjectMacro(SelectedPlaneProperty,vtkProperty);
    00266
    00267 protected:
    00268   vtkPlaneWidget();
    00269   ~vtkPlaneWidget();
    00270
    00271 //BTX - manage the state of the widget
    00272   int State;
    00273   enum WidgetState
    00274   {
    00275     Start=0,
    00276     Moving,
    00277     Scaling,
    00278     Pushing,
    00279     Rotating,
    00280     Outside
    00281   };
    00282 //ETX
    00283
    00284   //handles the events
    00285   static void ProcessEvents(vtkObject* object,
    00286                             unsigned long event,
    00287                             void* clientdata,
    00288                             void* calldata);
    00289
    00290   // ProcessEvents() dispatches to these methods.
    00291   void OnLeftButtonDown();
    00292   void OnLeftButtonUp();
    00293   void OnMiddleButtonDown();
    00294   void OnMiddleButtonUp();
    00295   void OnRightButtonDown();
    00296   void OnRightButtonUp();
    00297   void OnMouseMove();
    00298
    00299   // controlling ivars
    00300   int NormalToXAxis;
    00301   int NormalToYAxis;
    00302   int NormalToZAxis;
    00303   int Representation;
    00304   void SelectRepresentation();
    00305
    00306   // the plane
    00307   vtkActor          *PlaneActor;
    00308   vtkPolyDataMapper *PlaneMapper;
    00309   vtkPlaneSource    *PlaneSource;
    00310   vtkPolyData       *PlaneOutline;
    00311   void HighlightPlane(int highlight);
    00312
    00313   // glyphs representing hot spots (e.g., handles)
    00314   vtkActor          **Handle;
    00315   vtkPolyDataMapper **HandleMapper;
    00316   vtkSphereSource   **HandleGeometry;
    00317   void PositionHandles();
    00318   void HandlesOn(double length);
    00319   void HandlesOff();
    00320   int HighlightHandle(vtkProp *prop); //returns cell id
    00321   virtual void SizeHandles();
    00322
    00323   // the normal cone
    00324   vtkActor          *ConeActor;
    00325   vtkPolyDataMapper *ConeMapper;
    00326   vtkConeSource     *ConeSource;
    00327   void HighlightNormal(int highlight);
    00328
    00329   // the normal line
    00330   vtkActor          *LineActor;
    00331   vtkPolyDataMapper *LineMapper;
    00332   vtkLineSource     *LineSource;
    00333
    00334   // the normal cone
    00335   vtkActor          *ConeActor2;
    00336   vtkPolyDataMapper *ConeMapper2;
    00337   vtkConeSource     *ConeSource2;
    00338
    00339   // the normal line
    00340   vtkActor          *LineActor2;
    00341   vtkPolyDataMapper *LineMapper2;
    00342   vtkLineSource     *LineSource2;
    00343
    00344   // Do the picking
    00345   vtkCellPicker *HandlePicker;
    00346   vtkCellPicker *PlanePicker;
    00347   vtkActor *CurrentHandle;
    00348
    00349   // Methods to manipulate the hexahedron.
    00350   void MoveOrigin(double *p1, double *p2);
    00351   void MovePoint1(double *p1, double *p2);
    00352   void MovePoint2(double *p1, double *p2);
    00353   void MovePoint3(double *p1, double *p2);
    00354   void Rotate(int X, int Y, double *p1, double *p2, double *vpn);
    00355   void Scale(double *p1, double *p2, int X, int Y);
    00356   void Translate(double *p1, double *p2);
    00357   void Push(double *p1, double *p2);
    00358
    00359   // Plane normal, normalized
    00360   float Normal[3];
    00361
    00362   // Transform the hexahedral points (used for rotations)
    00363   vtkTransform *Transform;
    00364
    00365   // Properties used to control the appearance of selected objects and
    00366   // the manipulator in general.
    00367   vtkProperty *HandleProperty;
    00368   vtkProperty *SelectedHandleProperty;
    00369   vtkProperty *PlaneProperty;
    00370   vtkProperty *SelectedPlaneProperty;
    00371   void CreateDefaultProperties();
    00372
    00373   void GeneratePlane();
    00374
    00375 private:
    00376   vtkPlaneWidget(const vtkPlaneWidget&);  //Not implemented
    00377   void operator=(const vtkPlaneWidget&);  //Not implemented
    00378 };
    00379
    00380 #endif