VTK
dox/Interaction/Widgets/vtkSphereHandleRepresentation.h
Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    vtkSphereHandleRepresentation.h
00005 
00006   Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
00007   All rights reserved.
00008   See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
00009 
00010      This software is distributed WITHOUT ANY WARRANTY; without even
00011      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
00012      PURPOSE.  See the above copyright notice for more information.
00013 
00014 =========================================================================*/
00029 #ifndef __vtkSphereHandleRepresentation_h
00030 #define __vtkSphereHandleRepresentation_h
00031 
00032 #include "vtkInteractionWidgetsModule.h" // For export macro
00033 #include "vtkHandleRepresentation.h"
00034 #include "vtkSphereSource.h" // Needed for delegation to sphere
00035 
00036 class vtkSphereSource;
00037 class vtkProperty;
00038 class vtkActor;
00039 class vtkPolyDataMapper;
00040 class vtkCellPicker;
00041 
00042 class VTKINTERACTIONWIDGETS_EXPORT vtkSphereHandleRepresentation
00043                         : public vtkHandleRepresentation
00044 {
00045 public:
00047   static vtkSphereHandleRepresentation *New();
00048 
00050 
00051   vtkTypeMacro(vtkSphereHandleRepresentation,vtkHandleRepresentation);
00052   void PrintSelf(ostream& os, vtkIndent indent);
00054 
00056 
00061   virtual void SetWorldPosition(double p[3]);
00062   virtual void SetDisplayPosition(double p[3]);
00064 
00066 
00072   vtkSetMacro(TranslationMode,int);
00073   vtkGetMacro(TranslationMode,int);
00074   vtkBooleanMacro(TranslationMode,int);
00076 
00077   void SetSphereRadius(double);
00078   double GetSphereRadius();
00079 
00081 
00082   void SetProperty(vtkProperty*);
00083   void SetSelectedProperty(vtkProperty*);
00084   vtkGetObjectMacro(Property,vtkProperty);
00085   vtkGetObjectMacro(SelectedProperty,vtkProperty);
00087 
00089 
00093   vtkSetClampMacro(HotSpotSize,double,0.0,1.0);
00094   vtkGetMacro(HotSpotSize,double);
00096 
00099   virtual void SetHandleSize(double size);
00100 
00102 
00104   virtual double *GetBounds();
00105   virtual void BuildRepresentation();
00106   virtual void StartWidgetInteraction(double eventPos[2]);
00107   virtual void WidgetInteraction(double eventPos[2]);
00108   virtual int ComputeInteractionState(int X, int Y, int modify=0);
00109   virtual void PlaceWidget(double bounds[6]);
00111 
00113 
00114   virtual void ShallowCopy(vtkProp *prop);
00115   virtual void DeepCopy(vtkProp *prop);
00116   virtual void GetActors(vtkPropCollection *);
00117   virtual void ReleaseGraphicsResources(vtkWindow *);
00118   virtual int RenderOpaqueGeometry(vtkViewport *viewport);
00119   virtual int RenderTranslucentPolygonalGeometry(vtkViewport *viewport);
00120   virtual int HasTranslucentPolygonalGeometry();
00122 
00123   void Highlight(int highlight);
00124 protected:
00125   vtkSphereHandleRepresentation();
00126   ~vtkSphereHandleRepresentation();
00127 
00128   // the cursor3D
00129   vtkActor          *Actor;
00130   vtkPolyDataMapper *Mapper;
00131   vtkSphereSource   *Sphere;
00132   // void Highlight(int highlight);
00133 
00134   // Do the picking
00135   vtkCellPicker *CursorPicker;
00136   double LastPickPosition[3];
00137   double LastEventPosition[2];
00138 
00139   // Register internal Pickers within PickingManager
00140   virtual void RegisterPickers();
00141 
00142   // Methods to manipulate the cursor
00143   int  ConstraintAxis;
00144   void Translate(double *p1, double *p2);
00145   void Scale(double *p1, double *p2, double eventPos[2]);
00146   void MoveFocus(double *p1, double *p2);
00147   void SizeBounds();
00148 
00149   // Properties used to control the appearance of selected objects and
00150   // the manipulator in general.
00151   vtkProperty *Property;
00152   vtkProperty *SelectedProperty;
00153   void         CreateDefaultProperties();
00154 
00155   // The size of the hot spot.
00156   double HotSpotSize;
00157   int    DetermineConstraintAxis(int constraint, double *x);
00158   int    WaitingForMotion;
00159   int    WaitCount;
00160 
00161   // Current handle sized (may reflect scaling)
00162   double CurrentHandleSize;
00163 
00164   // Control how translation works
00165   int TranslationMode;
00166 
00167 private:
00168   vtkSphereHandleRepresentation(const vtkSphereHandleRepresentation&);  //Not implemented
00169   void operator=(const vtkSphereHandleRepresentation&);  //Not implemented
00170 };
00171 
00172 #endif