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

# Hybrid/vtkImplicitPlaneWidget.h

Go to the documentation of this file.

    00001 /*=========================================================================
    00002
    00003   Program:   Visualization Toolkit
    00004   Module:    $RCSfile: vtkImplicitPlaneWidget.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 =========================================================================*/
    00090 #ifndef __vtkImplicitPlaneWidget_h
    00091 #define __vtkImplicitPlaneWidget_h
    00092
    00093 #include "vtkPolyDataSourceWidget.h"
    00094
    00095 class vtkActor;
    00096 class vtkPolyDataMapper;
    00097 class vtkCellPicker;
    00098 class vtkConeSource;
    00099 class vtkLineSource;
    00100 class vtkSphereSource;
    00101 class vtkTubeFilter;
    00102 class vtkPlane;
    00103 class vtkCutter;
    00104 class vtkProperty;
    00105 class vtkImageData;
    00106 class vtkOutlineFilter;
    00107 class vtkFeatureEdges;
    00108 class vtkPolyData;
    00109 class vtkTransform;
    00110
    00111 class VTK_HYBRID_EXPORT vtkImplicitPlaneWidget : public vtkPolyDataSourceWidget
    00112 {
    00113 public:
    00115   static vtkImplicitPlaneWidget *New();
    00116
    00117   vtkTypeRevisionMacro(vtkImplicitPlaneWidget,vtkPolyDataSourceWidget);
    00118   void PrintSelf(ostream& os, vtkIndent indent);
    00119
    00121
    00122   virtual void SetEnabled(int);
    00123   virtual void PlaceWidget(float bounds[6]);
    00124   void PlaceWidget()
    00125     {this->Superclass::PlaceWidget();}
    00127
    00129
    00130   void SetOrigin(float x, float y, float z);
    00131   void SetOrigin(float x[3]);
    00132   float* GetOrigin();
    00133   void GetOrigin(float xyz[3]);
    00135
    00137
    00138   void SetNormal(float x, float y, float z);
    00139   void SetNormal(float x[3]);
    00140   float* GetNormal();
    00141   void GetNormal(float xyz[3]);
    00143
    00145
    00149   void SetNormalToXAxis(int);
    00150   vtkGetMacro(NormalToXAxis,int);
    00151   vtkBooleanMacro(NormalToXAxis,int);
    00152   void SetNormalToYAxis(int);
    00153   vtkGetMacro(NormalToYAxis,int);
    00154   vtkBooleanMacro(NormalToYAxis,int);
    00155   void SetNormalToZAxis(int);
    00156   vtkGetMacro(NormalToZAxis,int);
    00157   vtkBooleanMacro(NormalToZAxis,int);
    00159
    00161
    00163   vtkSetMacro(Tubing,int);
    00164   vtkGetMacro(Tubing,int);
    00165   vtkBooleanMacro(Tubing,int);
    00167
    00169
    00173   void SetDrawPlane(int plane);
    00174   vtkGetMacro(DrawPlane,int);
    00175   vtkBooleanMacro(DrawPlane,int);
    00177
    00179
    00181   vtkSetMacro(OutlineTranslation,int);
    00182   vtkGetMacro(OutlineTranslation,int);
    00183   vtkBooleanMacro(OutlineTranslation,int);
    00185
    00188   void GetPolyData(vtkPolyData *pd);
    00189
    00192   vtkPolyDataSource* GetPolyDataSource();
    00193
    00198   void GetPlane(vtkPlane *plane);
    00199
    00203   void UpdatePlacement(void);
    00204
    00206
    00207   vtkGetObjectMacro(NormalProperty,vtkProperty);
    00208   vtkGetObjectMacro(SelectedNormalProperty,vtkProperty);
    00210
    00212
    00214   vtkGetObjectMacro(PlaneProperty,vtkProperty);
    00215   vtkGetObjectMacro(SelectedPlaneProperty,vtkProperty);
    00217
    00219
    00220   vtkGetObjectMacro(OutlineProperty,vtkProperty);
    00221   vtkGetObjectMacro(SelectedOutlineProperty,vtkProperty);
    00223
    00225
    00227   vtkGetObjectMacro(EdgesProperty,vtkProperty);
    00229
    00230 protected:
    00231   vtkImplicitPlaneWidget();
    00232   ~vtkImplicitPlaneWidget();
    00233
    00234 //BTX - manage the state of the widget
    00235   int State;
    00236   enum WidgetState
    00237   {
    00238     Start=0,
    00239     MovingPlane,
    00240     MovingOutline,
    00241     MovingOrigin,
    00242     Scaling,
    00243     Pushing,
    00244     Rotating,
    00245     Outside
    00246   };
    00247 //ETX
    00248
    00249   //handles the events
    00250   static void ProcessEvents(vtkObject* object, unsigned long event,
    00251                             void* clientdata, void* calldata);
    00252
    00253   // ProcessEvents() dispatches to these methods.
    00254   void OnLeftButtonDown();
    00255   void OnLeftButtonUp();
    00256   void OnMiddleButtonDown();
    00257   void OnMiddleButtonUp();
    00258   void OnRightButtonDown();
    00259   void OnRightButtonUp();
    00260   void OnMouseMove();
    00261
    00262   // Controlling ivars
    00263   int NormalToXAxis;
    00264   int NormalToYAxis;
    00265   int NormalToZAxis;
    00266   void UpdateRepresentation();
    00267
    00268   // The actual plane which is being manipulated
    00269   vtkPlane *Plane;
    00270
    00271   // The bounding box is represented by a single voxel image data
    00272   vtkImageData      *Box;
    00273   vtkOutlineFilter  *Outline;
    00274   vtkPolyDataMapper *OutlineMapper;
    00275   vtkActor          *OutlineActor;
    00276   void HighlightOutline(int highlight);
    00277   int OutlineTranslation; //whether the outline can be moved
    00278
    00279   // The cut plane is produced with a vtkCutter
    00280   vtkCutter         *Cutter;
    00281   vtkPolyDataMapper *CutMapper;
    00282   vtkActor          *CutActor;
    00283   int               DrawPlane;
    00284   void HighlightPlane(int highlight);
    00285
    00286   // Optional tubes are represented by extracting boundary edges and tubing
    00287   vtkFeatureEdges   *Edges;
    00288   vtkTubeFilter     *EdgesTuber;
    00289   vtkPolyDataMapper *EdgesMapper;
    00290   vtkActor          *EdgesActor;
    00291   int               Tubing; //control whether tubing is on
    00292
    00293   // The + normal cone
    00294   vtkConeSource     *ConeSource;
    00295   vtkPolyDataMapper *ConeMapper;
    00296   vtkActor          *ConeActor;
    00297   void HighlightNormal(int highlight);
    00298
    00299   // The + normal line
    00300   vtkLineSource     *LineSource;
    00301   vtkPolyDataMapper *LineMapper;
    00302   vtkActor          *LineActor;
    00303
    00304   // The - normal cone
    00305   vtkConeSource     *ConeSource2;
    00306   vtkPolyDataMapper *ConeMapper2;
    00307   vtkActor          *ConeActor2;
    00308
    00309   // The - normal line
    00310   vtkLineSource     *LineSource2;
    00311   vtkPolyDataMapper *LineMapper2;
    00312   vtkActor          *LineActor2;
    00313
    00314   // The origin positioning handle
    00315   vtkSphereSource   *Sphere;
    00316   vtkPolyDataMapper *SphereMapper;
    00317   vtkActor          *SphereActor;
    00318
    00319   // Do the picking
    00320   vtkCellPicker *Picker;
    00321
    00322   // Transform the normal (used for rotation)
    00323   vtkTransform *Transform;
    00324
    00325   // Methods to manipulate the plane
    00326   void ConstrainOrigin(float x[3]);
    00327   void Rotate(int X, int Y, double *p1, double *p2, double *vpn);
    00328   void TranslatePlane(double *p1, double *p2);
    00329   void TranslateOutline(double *p1, double *p2);
    00330   void TranslateOrigin(double *p1, double *p2);
    00331   void Push(double *p1, double *p2);
    00332   void Scale(double *p1, double *p2, int X, int Y);
    00333
    00334   // Properties used to control the appearance of selected objects and
    00335   // the manipulator in general.
    00336   vtkProperty *NormalProperty;
    00337   vtkProperty *SelectedNormalProperty;
    00338   vtkProperty *PlaneProperty;
    00339   vtkProperty *SelectedPlaneProperty;
    00340   vtkProperty *OutlineProperty;
    00341   vtkProperty *SelectedOutlineProperty;
    00342   vtkProperty *EdgesProperty;
    00343   void CreateDefaultProperties();
    00344
    00345   void GeneratePlane();
    00346   virtual void SizeHandles();
    00347
    00348 private:
    00349   vtkImplicitPlaneWidget(const vtkImplicitPlaneWidget&);  //Not implemented
    00350   void operator=(const vtkImplicitPlaneWidget&);  //Not implemented
    00351 };
    00352
    00353 #endif