vtkMimxPlaceLocalAxesWidget.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003 Program:   MIMX Meshing Toolkit
00004 Module:    $RCSfile: vtkMimxPlaceLocalAxesWidget.h,v $
00005 Language:  C++
00006 
00007 Date:      $Date: 2008/07/26 20:30:55 $
00008 Version:   $Revision: 1.6 $
00009 
00010 
00011  Musculoskeletal Imaging, Modelling and Experimentation (MIMX)
00012  Center for Computer Aided Design
00013  The University of Iowa
00014  Iowa City, IA 52242
00015  http://www.ccad.uiowa.edu/mimx/
00016  
00017 Copyright (c) The University of Iowa. All rights reserved.
00018 See MIMXCopyright.txt or http://www.ccad.uiowa.edu/mimx/Copyright.htm for details.
00019 
00020 This software is distributed WITHOUT ANY WARRANTY; without even 
00021 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
00022 PURPOSE.  See the above copyright notices for more information.
00023 
00024 =========================================================================*/
00025 // .NAME vtkMimxPlaceLocalAxesWidget - orthogonal hexahedron 3D widget
00026 // .SECTION Description
00027 // This 3D widget defines a region of interest that is represented by an
00028 // arbitrarily oriented hexahedron with interior face angles of 90 degrees
00029 // (orthogonal faces). The object creates 7 handles that can be moused on and
00030 // manipulated. The first six correspond to the six faces, the seventh is in
00031 // the center of the hexahedron. In addition, a bounding box outline is shown,
00032 // the "faces" of which can be selected for object rotation or scaling. A
00033 // nice feature of the object is that the vtkMimxPlaceLocalAxesWidget, like any 3D widget,
00034 // will work with the current interactor style. That is, if vtkMimxPlaceLocalAxesWidget does
00035 // not handle an event, then all other registered observers (including the
00036 // interactor style) have an opportunity to process the event. Otherwise, the
00037 // vtkMimxPlaceLocalAxesWidget will terminate the processing of the event that it handles.
00038 //
00039 // To use this object, just invoke SetInteractor() with the argument of the
00040 // method a vtkRenderWindowInteractor.  You may also wish to invoke
00041 // "PlaceWidget()" to initially position the widget. The interactor will act
00042 // normally until the "i" key (for "interactor") is pressed, at which point the
00043 // vtkMimxPlaceLocalAxesWidget will appear. (See superclass documentation for information
00044 // about changing this behavior.) By grabbing the six face handles (use the
00045 // left mouse button), faces can be moved. By grabbing the center handle
00046 // (with the left mouse button), the entire hexahedron can be
00047 // translated. (Translation can also be employed by using the
00048 // "shift-left-mouse-button" combination inside of the widget.) Scaling is
00049 // achieved by using the right mouse button "up" the render window (makes the
00050 // widget bigger) or "down" the render window (makes the widget smaller). To
00051 // rotate vtkMimxPlaceLocalAxesWidget, pick a face (but not a face handle) and move the left
00052 // mouse. (Note: the mouse button must be held down during manipulation.)
00053 // Events that occur outside of the widget (i.e., no part of the widget is
00054 // picked) are propagated to any other registered obsevers (such as the
00055 // interaction style).  Turn off the widget by pressing the "i" key again.
00056 // (See the superclass documentation on key press activiation.)
00057 //
00058 // The vtkMimxPlaceLocalAxesWidget is very flexible. It can be used to select, cut, clip, or
00059 // perform any other operation that depends on an implicit function (use the
00060 // GetPlanes() method); or it can be used to transform objects using a linear
00061 // transformation (use the GetTransform() method). Typical usage of the
00062 // widget is to make use of the StartInteractionEvent, InteractionEvent, and
00063 // EndInteractionEvent events. The InteractionEvent is called on mouse
00064 // motion; the other two events are called on button down and button up 
00065 // (either left or right button).
00066 //
00067 // Some additional features of this class include the ability to control the
00068 // rendered properties of the widget. You can set the properties of the
00069 // selected and unselected representations of the parts of the widget. For
00070 // example, you can set the property for the handles, faces, and outline in
00071 // their normal and selected states.
00072 
00073 // .SECTION Caveats
00074 // Note that handles can be picked even when they are "behind" other actors.
00075 // This is an intended feature and not a bug.
00076 //
00077 // The box widget can be oriented by specifying a transformation matrix.
00078 // This transformation is applied to the initial bounding box as defined by
00079 // the PlaceWidget() method. DO NOT ASSUME that the transformation is applied
00080 // to a unit box centered at the origin; this is wrong!
00081 
00082 // .SECTION See Also
00083 // vtk3DWidget vtkPointWidget vtkLineWidget vtkPlaneWidget 
00084 // vtkImplicitPlaneWidget vtkImagePlaneWidget
00085 
00086 #ifndef __vtkMimxPlaceLocalAxesWidget_h
00087 #define __vtkMimxPlaceLocalAxesWidget_h
00088 
00089 #include "vtk3DWidget.h"
00090 #include "vtkActor.h"
00091 
00092 #include "vtkKWEntryWithLabel.h"
00093 #include "vtkKWMenuButtonWithLabel.h"
00094 #include "vtkMimxWidgetsWin32Header.h"
00095 
00096 
00097 class vtkActor;
00098 class vtkCellPicker;
00099 class vtkIdList;
00100 class vtkPlanes;
00101 class vtkPoints;
00102 class vtkPolyData;
00103 class vtkDataSetMapper;
00104 class vtkProp;
00105 class vtkProperty;
00106 class vtkSphereSource;
00107 class vtkTransform;
00108 class vtkUnstructuredGrid;
00109 class vtkLocalAxesActor;
00110 
00111 //class vtkKWEntryWithLabel;
00112 
00113 class VTK_MIMXWIDGETS_EXPORT vtkMimxPlaceLocalAxesWidget : public vtk3DWidget
00114 {
00115 public:
00116   // Description:
00117   // Instantiate the object.
00118   static vtkMimxPlaceLocalAxesWidget *New();
00119 
00120   vtkTypeRevisionMacro(vtkMimxPlaceLocalAxesWidget,vtk3DWidget);
00121   void PrintSelf(ostream& os, vtkIndent indent);
00122 
00123   // Description:
00124   // Methods that satisfy the superclass' API.
00125   virtual void SetEnabled(int);
00126   virtual void PlaceWidget(double bounds[6]);
00127   void PlaceWidget()
00128     {this->Superclass::PlaceWidget();}
00129   void PlaceWidget(double xmin, double xmax, double ymin, double ymax, 
00130                    double zmin, double zmax)
00131     {this->Superclass::PlaceWidget(xmin,xmax,ymin,ymax,zmin,zmax);}
00132 
00133   // Description:
00134   // Get the planes describing the implicit function defined by the box
00135   // widget. The user must provide the instance of the class vtkPlanes. Note
00136   // that vtkPlanes is a subclass of vtkImplicitFunction, meaning that it can
00137   // be used by a variety of filters to perform clipping, cutting, and
00138   // selection of data.  (The direction of the normals of the planes can be
00139   // reversed enabling the InsideOut flag.)
00140   //void GetPlanes(vtkPlanes *planes);
00141 
00142   // Description:
00143   // Set/Get the InsideOut flag. When off, the normals point out of the
00144   // box. When on, the normals point into the hexahedron.  InsideOut
00145   // is off by default.
00146   //vtkSetMacro(InsideOut,int);
00147   //vtkGetMacro(InsideOut,int);
00148   //vtkBooleanMacro(InsideOut,int);
00149 
00150   // Description:
00151   // Retrieve a linear transform characterizing the transformation of the
00152   // box. Note that the transformation is relative to where PlaceWidget
00153   // was initially called. This method modifies the transform provided. The
00154   // transform can be used to control the position of vtkProp3D's, as well as
00155   // other transformation operations (e.g., vtkTranformPolyData).
00156   //virtual void GetTransform(vtkTransform *t);
00157 
00158   // Description:
00159   // Set the position, scale and orientation of the box widget using the
00160   // transform specified. Note that the transformation is relative to 
00161   // where PlaceWidget was initially called (i.e., the original bounding
00162   // box). 
00163   //virtual void SetTransform(vtkTransform* t);
00164 
00165   // Description:
00166   // Grab the polydata (including points) that define the box widget. The
00167   // polydata consists of 6 quadrilateral faces and 15 points. The first
00168   // eight points define the eight corner vertices; the next six define the
00169   // -x,+x, -y,+y, -z,+z face points; and the final point (the 15th out of 15
00170   // points) defines the center of the hexahedron. These point values are
00171   // guaranteed to be up-to-date when either the InteractionEvent or
00172   // EndInteractionEvent events are invoked. The user provides the
00173   // vtkPolyData and the points and cells are added to it.
00174   //void GetPolyData(vtkPolyData *pd);
00175 
00176   // Description:
00177   // Get the handle properties (the little balls are the handles). The 
00178   // properties of the handles when selected and normal can be 
00179   // set.
00180   vtkGetObjectMacro(LocalAxesActor,vtkLocalAxesActor);
00181   //vtkGetObjectMacro(SelectedHandleProperty,vtkProperty);
00182 
00183   // Description:
00184   // Switches handles (the spheres) on or off by manipulating the actor
00185   // visibility.
00186   //void HandlesOn();
00187   //void HandlesOff();
00188   
00189   // Description:
00190   // Get the face properties (the faces of the box). The 
00191   // properties of the face when selected and normal can be 
00192   // set.
00193   //vtkGetObjectMacro(FaceProperty,vtkProperty);
00194   //vtkGetObjectMacro(SelectedFaceProperty,vtkProperty);
00195   
00196   // Description:
00197   // Get the outline properties (the outline of the box). The 
00198   // properties of the outline when selected and normal can be 
00199   // set.
00200   //vtkGetObjectMacro(OutlineProperty,vtkProperty);
00201   //vtkGetObjectMacro(SelectedOutlineProperty,vtkProperty);
00202   
00203   // Description:
00204   // Control the representation of the outline. This flag enables
00205   // face wires. By default face wires are off.
00206   //void SetOutlineFaceWires(int);
00207   //vtkGetMacro(OutlineFaceWires,int);
00208   //void OutlineFaceWiresOn() {this->SetOutlineFaceWires(1);}
00209   //void OutlineFaceWiresOff() {this->SetOutlineFaceWires(0);}
00210 
00211   // Description:
00212   // Control the representation of the outline. This flag enables
00213   // the cursor lines running between the handles. By default cursor
00214   // wires are on.
00215  /* void SetOutlineCursorWires(int);
00216   vtkGetMacro(OutlineCursorWires,int);
00217   void OutlineCursorWiresOn() {this->SetOutlineCursorWires(1);}
00218   void OutlineCursorWiresOff() {this->SetOutlineCursorWires(0);}*/
00219 
00220   // Description:
00221   // Control the behavior of the widget. Translation, rotation, and
00222   // scaling can all be enabled and disabled.
00223   //vtkSetMacro(TranslationEnabled,int);
00224   //vtkGetMacro(TranslationEnabled,int);
00225   //vtkBooleanMacro(TranslationEnabled,int);
00226   //vtkSetMacro(ScalingEnabled,int);
00227   //vtkGetMacro(ScalingEnabled,int);
00228   //vtkBooleanMacro(ScalingEnabled,int);
00229   //vtkSetMacro(RotationEnabled,int);
00230   //vtkGetMacro(RotationEnabled,int);
00231   //vtkBooleanMacro(RotationEnabled,int);
00232   virtual void SetInput(vtkDataSet*);
00233   vtkSetObjectMacro(InputActor, vtkActor);
00234   vtkGetMacro(PickedCell, int);
00235   
00236   int GetMeshSeedX();
00237   int GetMeshSeedY();
00238   int GetMeshSeedZ();
00239 
00240   vtkSetObjectMacro(XMeshSeed, vtkKWEntryWithLabel);
00241   vtkSetObjectMacro(YMeshSeed, vtkKWEntryWithLabel);
00242   vtkSetObjectMacro(ZMeshSeed, vtkKWEntryWithLabel);
00243   vtkSetObjectMacro(SelectionTypeWidget, vtkKWMenuButtonWithLabel);
00244 
00245 protected:
00246   vtkMimxPlaceLocalAxesWidget();
00247   ~vtkMimxPlaceLocalAxesWidget();
00248   vtkUnstructuredGrid *UGrid;
00249 
00250 //BTX - manage the state of the widget
00251   int State;
00252   enum WidgetState
00253   {
00254     Start=0,
00255     Moving,
00256     //Scaling,
00257     Outside
00258   };
00259 //ETX
00260     
00261   // Handles the events
00262   static void ProcessEvents(vtkObject* object, 
00263                             unsigned long event,
00264                             void* clientdata, 
00265                             void* calldata);
00266 
00267   // ProcessEvents() dispatches to these methods.
00268   virtual void OnMouseMove();
00269   virtual void OnLeftButtonDown();
00270   virtual void OnLeftButtonUp();
00271   virtual void OnMiddleButtonDown();
00272   virtual void OnMiddleButtonUp();
00273   void Initialize();
00274   virtual void OnRightButtonDown();
00275   virtual void OnRightButtonUp();
00276   
00277   // the hexahedron (6 faces)
00278   vtkActor          *CellActor;
00279   vtkActor                      *InputActor;
00280   vtkDataSetMapper *CellMapper;
00281   vtkUnstructuredGrid       *CellDataSet;
00282   //vtkPoints         *Points;  //used by others as well
00283   //double             N[6][3]; //the normals of the faces
00284 
00285   // A face of the hexahedron
00286  /* vtkActor          *HexFace;
00287   vtkPolyDataMapper *HexFaceMapper;
00288   vtkPolyData       *HexFacePolyData;*/
00289 
00290   // glyphs representing hot spots (e.g., handles)
00291   //vtkActor          **Handle;
00292   //vtkPolyDataMapper **HandleMapper;
00293   //vtkSphereSource   **HandleGeometry;
00294   //virtual void PositionHandles();
00295   //int HighlightHandle(vtkProp *prop); //returns cell id
00296   //void HighlightFace(int cellId);
00297   //void HighlightOutline(int highlight);
00298   //void ComputeNormals();
00299   //virtual void SizeHandles();
00300   
00301   // wireframe outline
00302  /* vtkActor          *HexOutline;
00303   vtkPolyDataMapper *OutlineMapper;
00304   vtkPolyData       *OutlinePolyData;*/
00305 
00306   // Do the picking
00307   //vtkCellPicker *HandlePicker;
00308   vtkCellPicker *CellPicker;
00309  /* vtkActor *CurrentHandle;
00310   int      CurrentHexFace;*/
00311   
00312   // Methods to manipulate the hexahedron.
00313  /* virtual void Translate(double *p1, double *p2);
00314   virtual void Scale(double *p1, double *p2, int X, int Y);
00315   virtual void Rotate(int X, int Y, double *p1, double *p2, double *vpn);
00316   void MovePlusXFace(double *p1, double *p2);
00317   void MoveMinusXFace(double *p1, double *p2);
00318   void MovePlusYFace(double *p1, double *p2);
00319   void MoveMinusYFace(double *p1, double *p2);
00320   void MovePlusZFace(double *p1, double *p2);
00321   void MoveMinusZFace(double *p1, double *p2);*/
00322 
00323   //"dir" is the direction in which the face can be moved i.e. the axis passing
00324   //through the center
00325   //void MoveFace(double *p1, double *p2, double *dir, 
00326   //              double *x1, double *x2, double *x3, double *x4,
00327   //              double *x5);
00330   //void GetDirection(const double Nx[3],const double Ny[3], 
00331   //                  const double Nz[3], double dir[3]);
00332 
00333   // Transform the hexahedral points (used for rotations)
00334   //vtkTransform *Transform;
00335   //
00338   //vtkProperty *HandleProperty;
00339   //vtkProperty *SelectedHandleProperty;
00340   //vtkProperty *FaceProperty;
00341   //vtkProperty *SelectedFaceProperty;
00342   //vtkProperty *OutlineProperty;
00343   //vtkProperty *SelectedOutlineProperty;
00344   //void CreateDefaultProperties();
00345   
00346   // Control the orientation of the normals
00347   //int InsideOut;
00348   //int OutlineFaceWires;
00349   //int OutlineCursorWires;
00350   //void GenerateOutline();
00351   
00352   // Control whether scaling, rotation, and translation are supported
00353   //int TranslationEnabled;
00354   //int ScalingEnabled;
00355   //int RotationEnabled;
00356   vtkLocalAxesActor *LocalAxesActor;
00357   int PickedCell;
00358 
00359   vtkKWEntryWithLabel *XMeshSeed;
00360   vtkKWEntryWithLabel *YMeshSeed;
00361   vtkKWEntryWithLabel *ZMeshSeed;
00362   vtkKWMenuButtonWithLabel *SelectionTypeWidget;
00363   
00364   
00365 private:
00366   vtkMimxPlaceLocalAxesWidget(const vtkMimxPlaceLocalAxesWidget&);  //Not implemented
00367   void operator=(const vtkMimxPlaceLocalAxesWidget&);  //Not implemented
00368 };
00369 
00370 #endif

Generated on 6 Apr 2011 for Slicer3 by  doxygen 1.6.1