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

vtkBoxWidget.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    $RCSfile: vtkBoxWidget.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 =========================================================================*/
00085 #ifndef __vtkBoxWidget_h
00086 #define __vtkBoxWidget_h
00087 
00088 #include "vtk3DWidget.h"
00089 
00090 class vtkActor;
00091 class vtkCellPicker;
00092 class vtkPlanes;
00093 class vtkPoints;
00094 class vtkPolyData;
00095 class vtkPolyDataMapper;
00096 class vtkProp;
00097 class vtkProperty;
00098 class vtkSphereSource;
00099 class vtkTransform;
00100 
00101 class VTK_HYBRID_EXPORT vtkBoxWidget : public vtk3DWidget
00102 {
00103 public:
00105   static vtkBoxWidget *New();
00106 
00107   vtkTypeRevisionMacro(vtkBoxWidget,vtk3DWidget);
00108   void PrintSelf(ostream& os, vtkIndent indent);
00109 
00111 
00112   virtual void SetEnabled(int);
00113   virtual void PlaceWidget(float bounds[6]);
00114   void PlaceWidget()
00115     {this->Superclass::PlaceWidget();}
00116   void PlaceWidget(float xmin, float xmax, float ymin, float ymax, 
00117                    float zmin, float zmax)
00118     {this->Superclass::PlaceWidget(xmin,xmax,ymin,ymax,zmin,zmax);}
00120 
00121 
00128   void GetPlanes(vtkPlanes *planes);
00129 
00131 
00134   vtkSetMacro(InsideOut,int);
00135   vtkGetMacro(InsideOut,int);
00136   vtkBooleanMacro(InsideOut,int);
00138 
00144   void GetTransform(vtkTransform *t);
00145 
00154   void GetPolyData(vtkPolyData *pd);
00155 
00157 
00159   vtkGetObjectMacro(HandleProperty,vtkProperty);
00160   vtkGetObjectMacro(SelectedHandleProperty,vtkProperty);
00162   
00164 
00166   vtkGetObjectMacro(FaceProperty,vtkProperty);
00167   vtkGetObjectMacro(SelectedFaceProperty,vtkProperty);
00169   
00171 
00173   vtkGetObjectMacro(OutlineProperty,vtkProperty);
00174   vtkGetObjectMacro(SelectedOutlineProperty,vtkProperty);
00176   
00178 
00180   vtkSetMacro(OutlineFaceWires,int);
00181   vtkGetMacro(OutlineFaceWires,int);
00182   vtkBooleanMacro(OutlineFaceWires,int);
00184 
00186 
00189   vtkSetMacro(OutlineCursorWires,int);
00190   vtkGetMacro(OutlineCursorWires,int);
00191   vtkBooleanMacro(OutlineCursorWires,int);
00193 
00195 
00197   vtkSetMacro(TranslationEnabled,int);
00198   vtkGetMacro(TranslationEnabled,int);
00199   vtkBooleanMacro(TranslationEnabled,int);
00200   vtkSetMacro(ScalingEnabled,int);
00201   vtkGetMacro(ScalingEnabled,int);
00202   vtkBooleanMacro(ScalingEnabled,int);
00203   vtkSetMacro(RotationEnabled,int);
00204   vtkGetMacro(RotationEnabled,int);
00205   vtkBooleanMacro(RotationEnabled,int);
00207 
00208 protected:
00209   vtkBoxWidget();
00210   ~vtkBoxWidget();
00211 
00212 //BTX - manage the state of the widget
00213   int State;
00214   enum WidgetState
00215   {
00216     Start=0,
00217     Moving,
00218     Scaling,
00219     Outside
00220   };
00221 //ETX
00222     
00223   // Handles the events
00224   static void ProcessEvents(vtkObject* object, 
00225                             unsigned long event,
00226                             void* clientdata, 
00227                             void* calldata);
00228 
00229   // ProcessEvents() dispatches to these methods.
00230   void OnMouseMove();
00231   void OnLeftButtonDown();
00232   void OnLeftButtonUp();
00233   void OnMiddleButtonDown();
00234   void OnMiddleButtonUp();
00235   void OnRightButtonDown();
00236   void OnRightButtonUp();
00237   
00238   // the hexahedron (6 faces)
00239   vtkActor          *HexActor;
00240   vtkPolyDataMapper *HexMapper;
00241   vtkPolyData       *HexPolyData;
00242   vtkPoints         *Points;  //used by others as well
00243   double             N[6][3]; //the normals of the faces
00244 
00245   // A face of the hexahedron
00246   vtkActor          *HexFace;
00247   vtkPolyDataMapper *HexFaceMapper;
00248   vtkPolyData       *HexFacePolyData;
00249 
00250   // glyphs representing hot spots (e.g., handles)
00251   vtkActor          **Handle;
00252   vtkPolyDataMapper **HandleMapper;
00253   vtkSphereSource   **HandleGeometry;
00254   void PositionHandles();
00255   void HandlesOn(double length);
00256   void HandlesOff();
00257   int HighlightHandle(vtkProp *prop); //returns cell id
00258   void HighlightFace(int cellId);
00259   void HighlightOutline(int highlight);
00260   void ComputeNormals();
00261   virtual void SizeHandles();
00262   
00263   // wireframe outline
00264   vtkActor          *HexOutline;
00265   vtkPolyDataMapper *OutlineMapper;
00266   vtkPolyData       *OutlinePolyData;
00267 
00268   // Do the picking
00269   vtkCellPicker *HandlePicker;
00270   vtkCellPicker *HexPicker;
00271   vtkActor *CurrentHandle;
00272   int      CurrentHexFace;
00273   
00274   // Methods to manipulate the hexahedron.
00275   void Translate(double *p1, double *p2);
00276   void Scale(double *p1, double *p2, int X, int Y);
00277   void Rotate(int X, int Y, double *p1, double *p2, double *vpn);
00278   void MovePlusXFace(double *p1, double *p2);
00279   void MoveMinusXFace(double *p1, double *p2);
00280   void MovePlusYFace(double *p1, double *p2);
00281   void MoveMinusYFace(double *p1, double *p2);
00282   void MovePlusZFace(double *p1, double *p2);
00283   void MoveMinusZFace(double *p1, double *p2);
00284 
00285   void MoveFace(double *p1, double *p2, double *h1, double *h2, 
00286                 double *x1, double *x2, double *x3, double *x4,
00287                 double *x5);
00288   
00289   // Transform the hexahedral points (used for rotations)
00290   vtkTransform *Transform;
00291   
00292   // Properties used to control the appearance of selected objects and
00293   // the manipulator in general.
00294   vtkProperty *HandleProperty;
00295   vtkProperty *SelectedHandleProperty;
00296   vtkProperty *FaceProperty;
00297   vtkProperty *SelectedFaceProperty;
00298   vtkProperty *OutlineProperty;
00299   vtkProperty *SelectedOutlineProperty;
00300   void CreateDefaultProperties();
00301   
00302   // Control the orientation of the normals
00303   int InsideOut;
00304   int OutlineFaceWires;
00305   int OutlineCursorWires;
00306   void GenerateOutline();
00307   
00308   // Control whether scaling, rotation, and translation are supported
00309   int TranslationEnabled;
00310   int ScalingEnabled;
00311   int RotationEnabled;
00312 
00313 private:
00314   vtkBoxWidget(const vtkBoxWidget&);  //Not implemented
00315   void operator=(const vtkBoxWidget&);  //Not implemented
00316 };
00317 
00318 #endif