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
51class vtkRenderer;
52
53
54class VTKINTERACTIONWIDGETS_EXPORT vtkWidgetRepresentation : public vtkProp
55{
56public:
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);
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);
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 *) {}
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
193protected:
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
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
272private:
273 vtkWidgetRepresentation(const vtkWidgetRepresentation&) VTK_DELETE_FUNCTION;
274 void operator=(const vtkWidgetRepresentation&) VTK_DELETE_FUNCTION;
275};
276
277#endif
abstract API for pickers that can pick an instance of vtkProp
a list of nodes that form an assembly path
a simple class to control print indentation
Definition: vtkIndent.h:40
Class defines API to manage the picking process.
a list of Props
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:48
abstract specification for renderers
Definition: vtkRenderer.h:64
record modification and/or execution time
Definition: vtkTimeStamp.h:36
abstract specification for Viewports
Definition: vtkViewport.h:48
abstract class defines interface between the widget and widget representation classes
virtual int RenderOverlay(vtkViewport *vtkNotUsed(viewport))
void AdjustBounds(double bounds[6], double newBounds[6], double center[3])
virtual void GetVolumes(vtkPropCollection *)
virtual void ShallowCopy(vtkProp *prop)
Shallow copy of this vtkProp.
virtual void UnRegisterPickers()
Unregister internal pickers from the Picking Manager.
virtual void Highlight(int vtkNotUsed(highlightOn))
vtkPickingManager * GetPickingManager()
Return the picking manager associated on the context on which the widget representation currently bel...
virtual void SetRenderer(vtkRenderer *ren)
Subclasses of vtkWidgetRepresentation must implement these methods.
virtual int RenderOpaqueGeometry(vtkViewport *vtkNotUsed(viewport))
vtkWeakPointer< vtkRenderer > Renderer
virtual int RenderTranslucentPolygonalGeometry(vtkViewport *vtkNotUsed(viewport))
virtual void WidgetInteraction(double newEventPos[2])
virtual double * GetBounds()
Methods to make this class behave as a vtkProp.
virtual void EndWidgetInteraction(double newEventPos[2])
virtual int HasTranslucentPolygonalGeometry()
WARNING: INTERNAL METHOD - NOT INTENDED FOR GENERAL USE DO NOT USE THESE METHODS OUTSIDE OF THE RENDE...
virtual void RegisterPickers()
Register internal Pickers in the Picking Manager.
double SizeHandlesRelativeToViewport(double factor, double pos[3])
virtual void GetActors(vtkPropCollection *)
For some exporters and other other operations we must be able to collect all the actors or volumes.
virtual void StartWidgetInteraction(double eventPos[2])
virtual void PickersModified()
Update the pickers registered in the Picking Manager when pickers are modified.
virtual void ReleaseGraphicsResources(vtkWindow *)
WARNING: INTERNAL METHOD - NOT INTENDED FOR GENERAL USE Release any graphics resources that are being...
virtual void BuildRepresentation()=0
virtual int RenderVolumetricGeometry(vtkViewport *vtkNotUsed(viewport))
virtual int ComputeInteractionState(int X, int Y, int modify=0)
virtual vtkRenderer * GetRenderer()
virtual void PlaceWidget(double *vtkNotUsed(bounds[6]))
The following is a suggested API for widget representations.
void PrintSelf(ostream &os, vtkIndent indent)
Methods invoked by print to print information about the object including superclasses.
virtual void GetActors2D(vtkPropCollection *)
double SizeHandlesInPixels(double factor, double pos[3])
vtkAssemblyPath * GetAssemblyPath(double X, double Y, double Z, vtkAbstractPropPicker *picker)
Proceed to a pick, whether through the PickingManager if the picking is managed or directly using the...
window superclass for vtkRenderWindow
Definition: vtkWindow.h:35
@ center
Definition: vtkX3D.h:230
vtkSetMacro(IgnoreDriverBugs, bool)
Updates the extensions string.
vtkBooleanMacro(IgnoreDriverBugs, bool)
Updates the extensions string.
#define VTK_DOUBLE_MAX
Definition: vtkType.h:163