VTK
vtkWidgetRepresentation.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkWidgetRepresentation.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 =========================================================================*/
42 #ifndef vtkWidgetRepresentation_h
43 #define vtkWidgetRepresentation_h
44 
45 #include "vtkInteractionWidgetsModule.h" // For export macro
46 #include "vtkProp.h"
47 #include "vtkWeakPointer.h" // needed for vtkWeakPointer iVar.
48 
50 class vtkPickingManager;
51 class vtkRenderer;
52 
53 
54 class VTKINTERACTIONWIDGETS_EXPORT vtkWidgetRepresentation : public vtkProp
55 {
56 public:
58 
62  void PrintSelf(ostream& os, vtkIndent indent) VTK_OVERRIDE;
64 
66 
70  vtkBooleanMacro(PickingManaged, bool);
71  vtkSetMacro(PickingManaged, bool);
72  vtkGetMacro(PickingManaged, bool);
74 
76 
92  virtual void SetRenderer(vtkRenderer *ren);
93  virtual vtkRenderer* GetRenderer();
94  virtual void BuildRepresentation() = 0;
96 
129  virtual void PlaceWidget(double* vtkNotUsed(bounds[6])) {}
130  virtual void StartWidgetInteraction(double eventPos[2]) { (void)eventPos; }
131  virtual void WidgetInteraction(double newEventPos[2]) { (void)newEventPos; }
132  virtual void EndWidgetInteraction(double newEventPos[2]) { (void)newEventPos; }
133  virtual int ComputeInteractionState(int X, int Y, int modify=0);
134  virtual int GetInteractionState()
135  {return this->InteractionState;}
136  virtual void Highlight(int vtkNotUsed(highlightOn)) {}
137 
139 
146  vtkSetClampMacro(PlaceFactor,double,0.01,VTK_DOUBLE_MAX);
147  vtkGetMacro(PlaceFactor,double);
149 
151 
160  vtkSetClampMacro(HandleSize,double,0.001,1000);
161  vtkGetMacro(HandleSize,double);
163 
165 
169  vtkGetMacro( NeedToRender, int );
170  vtkSetClampMacro( NeedToRender, int, 0, 1 );
171  vtkBooleanMacro( NeedToRender, int );
173 
181  double *GetBounds() VTK_OVERRIDE {return NULL;}
182  void ShallowCopy(vtkProp *prop) VTK_OVERRIDE;
183  void GetActors(vtkPropCollection *) VTK_OVERRIDE {}
184  void GetActors2D(vtkPropCollection *) VTK_OVERRIDE {}
185  void GetVolumes(vtkPropCollection *) VTK_OVERRIDE {}
186  void ReleaseGraphicsResources(vtkWindow *) VTK_OVERRIDE {}
187  int RenderOverlay(vtkViewport *vtkNotUsed(viewport)) VTK_OVERRIDE {return 0;}
188  int RenderOpaqueGeometry(vtkViewport *vtkNotUsed(viewport)) VTK_OVERRIDE {return 0;}
189  int RenderTranslucentPolygonalGeometry(vtkViewport *vtkNotUsed(viewport)) VTK_OVERRIDE {return 0;}
190  int RenderVolumetricGeometry(vtkViewport *vtkNotUsed(viewport)) VTK_OVERRIDE {return 0;}
191  int HasTranslucentPolygonalGeometry() VTK_OVERRIDE { return 0; }
192 
193 protected:
195  ~vtkWidgetRepresentation() VTK_OVERRIDE;
196 
197  // The renderer in which this widget is placed
199 
200  // The state of this representation based on a recent event
201  int InteractionState;
202 
203  // These are used to track the beginning of interaction with the representation
204  // It's dimensioned [3] because some events re processed in 3D.
205  double StartEventPosition[3];
206 
207  // Instance variable and members supporting suclasses
208  double PlaceFactor; // Used to control how widget is placed around bounding box
209  int Placed; // Indicate whether widget has been placed
210  void AdjustBounds(double bounds[6], double newBounds[6], double center[3]);
211  double InitialBounds[6]; //initial bounds on place widget (valid after PlaceWidget)
212  double InitialLength; //initial length on place widget
213 
214  // Sizing handles is tricky because the procedure requires information
215  // relative to the last pick, as well as a live renderer to perform
216  // coordinate conversions. In some cases, a pick is never made so handle
217  // sizing has to follow a different path. The following ivars help with
218  // this process.
219  int ValidPick; //indicate when valid picks are made
220 
221  // This variable controls whether the picking is managed by the Picking
222  // Manager or not. True by default.
223  bool PickingManaged;
224 
230  virtual void RegisterPickers();
231 
235  virtual void UnRegisterPickers();
236 
241  virtual void PickersModified();
242 
247  vtkPickingManager* GetPickingManager();
248 
254  vtkAssemblyPath* GetAssemblyPath(double X, double Y, double Z,
255  vtkAbstractPropPicker* picker);
256 
257 
258  // Members use to control handle size. The two methods return a "radius"
259  // in world coordinates. Note that the HandleSize data member is used
260  // internal to the SizeHandles__() methods.
261  double HandleSize; //controlling relative size of widget handles
262  double SizeHandlesRelativeToViewport(double factor, double pos[3]);
263  double SizeHandlesInPixels(double factor,double pos[3]);
264 
265  // Try and reduce multiple renders
266  int NeedToRender;
267 
268  // This is the time that the representation was built. This data member
269  // can be used to reduce the time spent building the widget.
271 
272 private:
273  vtkWidgetRepresentation(const vtkWidgetRepresentation&) VTK_DELETE_FUNCTION;
274  void operator=(const vtkWidgetRepresentation&) VTK_DELETE_FUNCTION;
275 };
276 
277 #endif
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:44
vtkTimeStamp BuildTime
virtual void EndWidgetInteraction(double newEventPos[2])
Class defines API to manage the picking process.
virtual void ShallowCopy(vtkProp *prop)
Shallow copy of this vtkProp.
#define VTK_DOUBLE_MAX
Definition: vtkType.h:167
abstract specification for Viewports
Definition: vtkViewport.h:44
void GetActors2D(vtkPropCollection *) override
virtual void StartWidgetInteraction(double eventPos[2])
record modification and/or execution time
Definition: vtkTimeStamp.h:32
abstract specification for renderers
Definition: vtkRenderer.h:57
abstract class defines interface between the widget and widget representation classes ...
double * GetBounds() override
Methods to make this class behave as a vtkProp.
an ordered list of Props
void GetVolumes(vtkPropCollection *) override
window superclass for vtkRenderWindow
Definition: vtkWindow.h:34
int RenderTranslucentPolygonalGeometry(vtkViewport *vtkNotUsed(viewport)) override
a list of nodes that form an assembly path
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
int HasTranslucentPolygonalGeometry() override
WARNING: INTERNAL METHOD - NOT INTENDED FOR GENERAL USE DO NOT USE THESE METHODS OUTSIDE OF THE RENDE...
a simple class to control print indentation
Definition: vtkIndent.h:33
a weak reference to a vtkObject.
void ReleaseGraphicsResources(vtkWindow *) override
WARNING: INTERNAL METHOD - NOT INTENDED FOR GENERAL USE Release any graphics resources that are being...
virtual void WidgetInteraction(double newEventPos[2])
int RenderOpaqueGeometry(vtkViewport *vtkNotUsed(viewport)) override
vtkSetMacro(IgnoreDriverBugs, bool)
When set known driver bugs are ignored during driver feature detection.
int RenderOverlay(vtkViewport *vtkNotUsed(viewport)) override
abstract API for pickers that can pick an instance of vtkProp
virtual void PlaceWidget(double *vtkNotUsed(bounds[6]))
The following is a suggested API for widget representations.
virtual void Highlight(int vtkNotUsed(highlightOn))
vtkBooleanMacro(IgnoreDriverBugs, bool)
When set known driver bugs are ignored during driver feature detection.
void GetActors(vtkPropCollection *) override
For some exporters and other other operations we must be able to collect all the actors or volumes...
int RenderVolumetricGeometry(vtkViewport *vtkNotUsed(viewport)) override