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