VTK
vtkSphereHandleRepresentation.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkSphereHandleRepresentation.h
5 
6  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7  All rights reserved.
8  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9 
10  This software is distributed WITHOUT ANY WARRANTY; without even
11  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12  PURPOSE. See the above copyright notice for more information.
13 
14 =========================================================================*/
27 #ifndef vtkSphereHandleRepresentation_h
28 #define vtkSphereHandleRepresentation_h
29 
30 #include "vtkInteractionWidgetsModule.h" // For export macro
32 #include "vtkSphereSource.h" // Needed for delegation to sphere
33 
34 class vtkSphereSource;
35 class vtkProperty;
36 class vtkActor;
37 class vtkPolyDataMapper;
38 class vtkCellPicker;
39 
40 class VTKINTERACTIONWIDGETS_EXPORT vtkSphereHandleRepresentation
42 {
43 public:
48 
50 
54  void PrintSelf(ostream& os, vtkIndent indent) override;
56 
58 
65  void SetWorldPosition(double p[3]) override;
66  void SetDisplayPosition(double p[3]) override;
68 
70 
78  vtkSetMacro(TranslationMode,vtkTypeBool);
79  vtkGetMacro(TranslationMode,vtkTypeBool);
80  vtkBooleanMacro(TranslationMode,vtkTypeBool);
82 
83  void SetSphereRadius(double);
84  double GetSphereRadius();
85 
87 
90  void SetProperty(vtkProperty*);
91  void SetSelectedProperty(vtkProperty*);
92  vtkGetObjectMacro(Property,vtkProperty);
93  vtkGetObjectMacro(SelectedProperty,vtkProperty);
95 
97 
103  vtkSetClampMacro(HotSpotSize,double,0.0,1.0);
104  vtkGetMacro(HotSpotSize,double);
106 
111  void SetHandleSize(double size) override;
112 
114 
117  double *GetBounds() VTK_SIZEHINT(6) override;
118  void BuildRepresentation() override;
119  void StartWidgetInteraction(double eventPos[2]) override;
120  void WidgetInteraction(double eventPos[2]) override;
121  int ComputeInteractionState(int X, int Y, int modify=0) override;
122  void PlaceWidget(double bounds[6]) override;
124 
126 
129  void ShallowCopy(vtkProp *prop) override;
130  void DeepCopy(vtkProp *prop) override;
131  void GetActors(vtkPropCollection *) override;
132  void ReleaseGraphicsResources(vtkWindow *) override;
133  int RenderOpaqueGeometry(vtkViewport *viewport) override;
134  int RenderTranslucentPolygonalGeometry(vtkViewport *viewport) override;
135  int HasTranslucentPolygonalGeometry() override;
137 
138  void Highlight(int highlight) override;
139 
140  /*
141  * Register internal Pickers within PickingManager
142  */
143  void RegisterPickers() override;
144 
145 protected:
147  ~vtkSphereHandleRepresentation() override;
148 
149  // the cursor3D
150  vtkActor *Actor;
153  // void Highlight(int highlight);
154 
155  // Do the picking
156  vtkCellPicker *CursorPicker;
157  double LastPickPosition[3];
158  double LastEventPosition[2];
159 
160  // Methods to manipulate the cursor
161  int ConstraintAxis;
162  void Translate(double *p1, double *p2);
163  void Scale(double *p1, double *p2, double eventPos[2]);
164  void MoveFocus(double *p1, double *p2);
165  void SizeBounds();
166 
167  // Properties used to control the appearance of selected objects and
168  // the manipulator in general.
169  vtkProperty *Property;
170  vtkProperty *SelectedProperty;
171  void CreateDefaultProperties();
172 
173  // The size of the hot spot.
174  double HotSpotSize;
175  int DetermineConstraintAxis(int constraint, double *x);
176  int WaitingForMotion;
177  int WaitCount;
178 
179  // Current handle sized (may reflect scaling)
180  double CurrentHandleSize;
181 
182  // Control how translation works
183  vtkTypeBool TranslationMode;
184 
185 private:
187  void operator=(const vtkSphereHandleRepresentation&) = delete;
188 };
189 
190 #endif
vtkPolyDataMapper
map vtkPolyData to graphics primitives
Definition: vtkPolyDataMapper.h:36
vtkX3D::Sphere
Definition: vtkX3D.h:64
vtkObject::New
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on.
vtkHandleRepresentation::SetWorldPosition
virtual void SetWorldPosition(double pos[3])
vtkHandleRepresentation
abstract class for representing widget handles
Definition: vtkHandleRepresentation.h:55
vtkHandleRepresentation.h
vtkWidgetRepresentation::SetHandleSize
virtual void SetHandleSize(double)
Set/Get the factor that controls the size of the handles that appear as part of the widget (if any).
vtkWindow
window superclass for vtkRenderWindow
Definition: vtkWindow.h:34
vtkHandleRepresentation::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkWidgetRepresentation::GetBounds
double * GetBounds() override
Methods to make this class behave as a vtkProp.
Definition: vtkWidgetRepresentation.h:215
VTK_SIZEHINT
#define VTK_SIZEHINT(...)
Definition: vtkWrappingHints.h:42
vtkSphereSource
create a polygonal sphere centered at the origin
Definition: vtkSphereSource.h:40
vtkSphereHandleRepresentation
A spherical rendition of point in 3D space.
Definition: vtkSphereHandleRepresentation.h:40
vtkActor
represents an object (geometry & properties) in a rendered scene
Definition: vtkActor.h:45
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:33
vtkX3D::size
Definition: vtkX3D.h:253
vtkSphereSource.h
vtkViewport
abstract specification for Viewports
Definition: vtkViewport.h:44
vtkProp
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:46
vtkHandleRepresentation::SetDisplayPosition
virtual void SetDisplayPosition(double pos[3])
Handles usually have their coordinates set in display coordinates (generally by an associated widget)...
vtkProperty
represent surface properties of a geometric object
Definition: vtkProperty.h:60
vtkPropCollection
an ordered list of Props
Definition: vtkPropCollection.h:35
vtkCellPicker
ray-cast cell picker for all kinds of Prop3Ds
Definition: vtkCellPicker.h:63
vtkTypeBool
int vtkTypeBool
Definition: vtkABI.h:69