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);
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  virtual double *GetBounds() {return NULL;}
182  virtual void ShallowCopy(vtkProp *prop);
183  virtual void GetActors(vtkPropCollection *) {}
184  virtual void GetActors2D(vtkPropCollection *) {}
185  virtual void GetVolumes(vtkPropCollection *) {}
187  virtual int RenderOverlay(vtkViewport *vtkNotUsed(viewport)) {return 0;}
188  virtual int RenderOpaqueGeometry(vtkViewport *vtkNotUsed(viewport)) {return 0;}
189  virtual int RenderTranslucentPolygonalGeometry(vtkViewport *vtkNotUsed(viewport)) {return 0;}
190  virtual int RenderVolumetricGeometry(vtkViewport *vtkNotUsed(viewport)) {return 0;}
191  virtual int HasTranslucentPolygonalGeometry() { return 0; }
192 
193 protected:
196 
197  // The renderer in which this widget is placed
199 
200  // The state of this representation based on a recent event
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.
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
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:50
virtual int RenderOverlay(vtkViewport *vtkNotUsed(viewport))
void PrintSelf(ostream &os, vtkIndent indent)
Methods invoked by print to print information about the object including superclasses.
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:163
abstract specification for Viewports
Definition: vtkViewport.h:47
virtual void StartWidgetInteraction(double eventPos[2])
record modification and/or execution time
Definition: vtkTimeStamp.h:35
vtkWeakPointer< vtkRenderer > Renderer
abstract specification for renderers
Definition: vtkRenderer.h:63
virtual void ReleaseGraphicsResources(vtkWindow *)
WARNING: INTERNAL METHOD - NOT INTENDED FOR GENERAL USE Release any graphics resources that are being...
abstract class defines interface between the widget and widget representation classes ...
a list of Props
window superclass for vtkRenderWindow
Definition: vtkWindow.h:37
virtual double * GetBounds()
Methods to make this class behave as a vtkProp.
a list of nodes that form an assembly path
virtual int HasTranslucentPolygonalGeometry()
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:39
virtual void WidgetInteraction(double newEventPos[2])
virtual void GetActors(vtkPropCollection *)
For some exporters and other other operations we must be able to collect all the actors or volumes...
vtkSetMacro(IgnoreDriverBugs, bool)
When set known driver bugs are ignored during driver feature detection.
virtual int RenderVolumetricGeometry(vtkViewport *vtkNotUsed(viewport))
virtual int RenderOpaqueGeometry(vtkViewport *vtkNotUsed(viewport))
abstract API for pickers that can pick an instance of vtkProp
virtual void GetActors2D(vtkPropCollection *)
virtual void GetVolumes(vtkPropCollection *)
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.
virtual int RenderTranslucentPolygonalGeometry(vtkViewport *vtkNotUsed(viewport))