VTK  9.3.20240419
vtkDistanceRepresentation.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2 // SPDX-License-Identifier: BSD-3-Clause
34 #ifndef vtkDistanceRepresentation_h
35 #define vtkDistanceRepresentation_h
36 
37 #include "vtkInteractionWidgetsModule.h" // For export macro
39 #include "vtkWrappingHints.h" // For VTK_MARSHALAUTO
40 
41 VTK_ABI_NAMESPACE_BEGIN
43 
44 class VTKINTERACTIONWIDGETS_EXPORT VTK_MARSHALAUTO vtkDistanceRepresentation
46 {
47 public:
49 
53  void PrintSelf(ostream& os, vtkIndent indent) override;
55 
60  virtual double GetDistance() = 0;
61 
63 
68  virtual void GetPoint1WorldPosition(double pos[3]) = 0;
69  virtual void GetPoint2WorldPosition(double pos[3]) = 0;
70  virtual double* GetPoint1WorldPosition() VTK_SIZEHINT(3) = 0;
71  virtual double* GetPoint2WorldPosition() VTK_SIZEHINT(3) = 0;
72  virtual void SetPoint1DisplayPosition(double pos[3]) = 0;
73  virtual void SetPoint2DisplayPosition(double pos[3]) = 0;
74  virtual void GetPoint1DisplayPosition(double pos[3]) = 0;
75  virtual void GetPoint2DisplayPosition(double pos[3]) = 0;
76  virtual void SetPoint1WorldPosition(double pos[3]) = 0;
77  virtual void SetPoint2WorldPosition(double pos[3]) = 0;
79 
81 
91  void SetHandleRepresentation(vtkHandleRepresentation* handle);
92  void InstantiateHandleRepresentation();
94 
96 
101  vtkGetObjectMacro(Point1Representation, vtkHandleRepresentation);
102  vtkGetObjectMacro(Point2Representation, vtkHandleRepresentation);
104 
106 
111  vtkSetClampMacro(Tolerance, int, 1, 100);
112  vtkGetMacro(Tolerance, int);
114 
116 
121  vtkSetStringMacro(LabelFormat);
122  vtkGetStringMacro(LabelFormat);
124 
126 
134  vtkSetMacro(Scale, double);
135  vtkGetMacro(Scale, double);
137 
139 
144  vtkSetMacro(RulerMode, vtkTypeBool);
145  vtkGetMacro(RulerMode, vtkTypeBool);
146  vtkBooleanMacro(RulerMode, vtkTypeBool);
148 
150 
154  vtkSetClampMacro(RulerDistance, double, 0, VTK_FLOAT_MAX);
155  vtkGetMacro(RulerDistance, double);
157 
159 
166  vtkSetClampMacro(NumberOfRulerTicks, int, 1, VTK_INT_MAX);
167  vtkGetMacro(NumberOfRulerTicks, int);
169 
170  // Used to communicate about the state of the representation
171  enum
172  {
173  Outside = 0,
175  NearP2
176  };
177 
179 
182  void BuildRepresentation() override;
183  int ComputeInteractionState(int X, int Y, int modify = 0) override;
184  void StartWidgetInteraction(double e[2]) override;
185  void WidgetInteraction(double e[2]) override;
187  unsigned long event, void* calldata) override;
189  unsigned long event, void* calldata) override;
191  unsigned long event, void* calldata, int modify = 0) override;
193 
194 protected:
197 
198  // The handle and the rep used to close the handles
202 
203  // Selection tolerance for the handles
205 
206  // Format for printing the distance
207  char* LabelFormat;
208 
209  // Scale to change from the VTK world coordinates to the desired coordinate
210  // system.
211  double Scale;
212 
213  // Ruler related stuff
217 
218 private:
220  void operator=(const vtkDistanceRepresentation&) = delete;
221 };
222 
223 VTK_ABI_NAMESPACE_END
224 #endif
define the API for widget / widget representation
represent the vtkDistanceWidget
int ComputeInteractionState(int X, int Y, int modify=0) override
These are methods that satisfy vtkWidgetRepresentation's API.
int ComputeComplexInteractionState(vtkRenderWindowInteractor *iren, vtkAbstractWidget *widget, unsigned long event, void *calldata, int modify=0) override
These are methods that satisfy vtkWidgetRepresentation's API.
virtual void GetPoint1WorldPosition(double pos[3])=0
Methods to Set/Get the coordinates of the two points defining this representation.
void StartComplexInteraction(vtkRenderWindowInteractor *iren, vtkAbstractWidget *widget, unsigned long event, void *calldata) override
These are methods that satisfy vtkWidgetRepresentation's API.
void PrintSelf(ostream &os, vtkIndent indent) override
Standard VTK methods.
virtual double GetDistance()=0
This representation and all subclasses must keep a distance consistent with the state of the widget.
virtual void GetPoint2WorldPosition(double pos[3])=0
Methods to Set/Get the coordinates of the two points defining this representation.
vtkHandleRepresentation * Point2Representation
virtual double * GetPoint1WorldPosition()=0
Methods to Set/Get the coordinates of the two points defining this representation.
vtkHandleRepresentation * HandleRepresentation
~vtkDistanceRepresentation() override
void BuildRepresentation() override
These are methods that satisfy vtkWidgetRepresentation's API.
void WidgetInteraction(double e[2]) override
These are methods that satisfy vtkWidgetRepresentation's API.
vtkHandleRepresentation * Point1Representation
void ComplexInteraction(vtkRenderWindowInteractor *iren, vtkAbstractWidget *widget, unsigned long event, void *calldata) override
These are methods that satisfy vtkWidgetRepresentation's API.
void StartWidgetInteraction(double e[2]) override
These are methods that satisfy vtkWidgetRepresentation's API.
abstract class for representing widget handles
a simple class to control print indentation
Definition: vtkIndent.h:108
platform-independent render window interaction including picking and frame rate control.
abstract class defines interface between the widget and widget representation classes
int vtkTypeBool
Definition: vtkABI.h:64
#define VTK_INT_MAX
Definition: vtkType.h:144
#define VTK_FLOAT_MAX
Definition: vtkType.h:152
#define VTK_SIZEHINT(...)
#define VTK_MARSHALAUTO