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);
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 
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
vtkWidgetRepresentation::StartWidgetInteraction
virtual void StartWidgetInteraction(double eventPos[2])
Definition: vtkWidgetRepresentation.h:130
vtkWidgetRepresentation::ShallowCopy
virtual void ShallowCopy(vtkProp *prop)
Shallow copy of this vtkProp.
vtkWidgetRepresentation::Renderer
vtkWeakPointer< vtkRenderer > Renderer
Definition: vtkWidgetRepresentation.h:198
vtkWidgetRepresentation::EndWidgetInteraction
virtual void EndWidgetInteraction(double newEventPos[2])
Definition: vtkWidgetRepresentation.h:132
vtkWidgetRepresentation::GetPickingManager
vtkPickingManager * GetPickingManager()
Return the picking manager associated on the context on which the widget representation currently bel...
vtkWidgetRepresentation::Placed
int Placed
Definition: vtkWidgetRepresentation.h:209
vtkWidgetRepresentation::SetRenderer
virtual void SetRenderer(vtkRenderer *ren)
Subclasses of vtkWidgetRepresentation must implement these methods.
vtkWidgetRepresentation::SizeHandlesInPixels
double SizeHandlesInPixels(double factor, double pos[3])
vtkTimeStamp
record modification and/or execution time
Definition: vtkTimeStamp.h:36
vtkWidgetRepresentation
abstract class defines interface between the widget and widget representation classes
Definition: vtkWidgetRepresentation.h:55
vtkWidgetRepresentation::GetAssemblyPath
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...
vtkX3D::center
@ center
Definition: vtkX3D.h:230
vtkWidgetRepresentation::ValidPick
int ValidPick
Definition: vtkWidgetRepresentation.h:219
vtkWidgetRepresentation::BuildRepresentation
virtual void BuildRepresentation()=0
vtkAssemblyPath
a list of nodes that form an assembly path
Definition: vtkAssemblyPath.h:42
vtkProp.h
vtkWidgetRepresentation::NeedToRender
int NeedToRender
Definition: vtkWidgetRepresentation.h:266
vtkWidgetRepresentation::InteractionState
int InteractionState
Definition: vtkWidgetRepresentation.h:201
vtkWindow
window superclass for vtkRenderWindow
Definition: vtkWindow.h:35
vtkWidgetRepresentation::GetRenderer
virtual vtkRenderer * GetRenderer()
vtkWidgetRepresentation::ReleaseGraphicsResources
virtual void ReleaseGraphicsResources(vtkWindow *)
WARNING: INTERNAL METHOD - NOT INTENDED FOR GENERAL USE Release any graphics resources that are being...
Definition: vtkWidgetRepresentation.h:186
vtkWidgetRepresentation::GetBounds
virtual double * GetBounds()
Methods to make this class behave as a vtkProp.
Definition: vtkWidgetRepresentation.h:181
vtkWidgetRepresentation::HasTranslucentPolygonalGeometry
virtual int HasTranslucentPolygonalGeometry()
WARNING: INTERNAL METHOD - NOT INTENDED FOR GENERAL USE DO NOT USE THESE METHODS OUTSIDE OF THE RENDE...
Definition: vtkWidgetRepresentation.h:191
vtkWidgetRepresentation::WidgetInteraction
virtual void WidgetInteraction(double newEventPos[2])
Definition: vtkWidgetRepresentation.h:131
vtkWidgetRepresentation::SizeHandlesRelativeToViewport
double SizeHandlesRelativeToViewport(double factor, double pos[3])
vtkWidgetRepresentation::~vtkWidgetRepresentation
~vtkWidgetRepresentation()
vtkWidgetRepresentation::PickersModified
virtual void PickersModified()
Update the pickers registered in the Picking Manager when pickers are modified.
vtkWidgetRepresentation::GetInteractionState
virtual int GetInteractionState()
Definition: vtkWidgetRepresentation.h:134
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:40
vtkWidgetRepresentation::RegisterPickers
virtual void RegisterPickers()
Register internal Pickers in the Picking Manager.
vtkWidgetRepresentation::GetActors
virtual void GetActors(vtkPropCollection *)
For some exporters and other other operations we must be able to collect all the actors or volumes.
Definition: vtkWidgetRepresentation.h:183
vtkWidgetRepresentation::RenderOpaqueGeometry
virtual int RenderOpaqueGeometry(vtkViewport *vtkNotUsed(viewport))
Definition: vtkWidgetRepresentation.h:188
vtkWidgetRepresentation::BuildTime
vtkTimeStamp BuildTime
Definition: vtkWidgetRepresentation.h:270
vtkWeakPointer.h
vtkWidgetRepresentation::UnRegisterPickers
virtual void UnRegisterPickers()
Unregister internal pickers from the Picking Manager.
vtkViewport
abstract specification for Viewports
Definition: vtkViewport.h:48
vtkAbstractPropPicker
abstract API for pickers that can pick an instance of vtkProp
Definition: vtkAbstractPropPicker.h:80
vtkBooleanMacro
vtkBooleanMacro(IgnoreDriverBugs, bool)
Updates the extensions string.
vtkWidgetRepresentation::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent)
Methods invoked by print to print information about the object including superclasses.
vtkSetMacro
vtkSetMacro(IgnoreDriverBugs, bool)
Updates the extensions string.
vtkProp
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:48
vtkWidgetRepresentation::GetVolumes
virtual void GetVolumes(vtkPropCollection *)
Definition: vtkWidgetRepresentation.h:185
vtkWidgetRepresentation::PlaceWidget
virtual void PlaceWidget(double *vtkNotUsed(bounds[6]))
The following is a suggested API for widget representations.
Definition: vtkWidgetRepresentation.h:129
vtkWidgetRepresentation::PickingManaged
bool PickingManaged
Definition: vtkWidgetRepresentation.h:223
vtkWidgetRepresentation::AdjustBounds
void AdjustBounds(double bounds[6], double newBounds[6], double center[3])
vtkWidgetRepresentation::PlaceFactor
double PlaceFactor
Definition: vtkWidgetRepresentation.h:208
vtkWidgetRepresentation::GetActors2D
virtual void GetActors2D(vtkPropCollection *)
Definition: vtkWidgetRepresentation.h:184
vtkWidgetRepresentation::vtkWidgetRepresentation
vtkWidgetRepresentation()
vtkRenderer
abstract specification for renderers
Definition: vtkRenderer.h:64
vtkWidgetRepresentation::HandleSize
double HandleSize
Definition: vtkWidgetRepresentation.h:261
vtkWidgetRepresentation::RenderVolumetricGeometry
virtual int RenderVolumetricGeometry(vtkViewport *vtkNotUsed(viewport))
Definition: vtkWidgetRepresentation.h:190
vtkWidgetRepresentation::RenderTranslucentPolygonalGeometry
virtual int RenderTranslucentPolygonalGeometry(vtkViewport *vtkNotUsed(viewport))
Definition: vtkWidgetRepresentation.h:189
vtkWidgetRepresentation::RenderOverlay
virtual int RenderOverlay(vtkViewport *vtkNotUsed(viewport))
Definition: vtkWidgetRepresentation.h:187
vtkPropCollection
a list of Props
Definition: vtkPropCollection.h:39
VTK_DOUBLE_MAX
#define VTK_DOUBLE_MAX
Definition: vtkType.h:163
vtkWidgetRepresentation::ComputeInteractionState
virtual int ComputeInteractionState(int X, int Y, int modify=0)
vtkWeakPointer< vtkRenderer >
vtkWidgetRepresentation::InitialLength
double InitialLength
Definition: vtkWidgetRepresentation.h:212
vtkWidgetRepresentation::Highlight
virtual void Highlight(int vtkNotUsed(highlightOn))
Definition: vtkWidgetRepresentation.h:136
vtkPickingManager
Class defines API to manage the picking process.
Definition: vtkPickingManager.h:86