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

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