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 =========================================================================*/
41 #ifndef vtkWidgetRepresentation_h
42 #define vtkWidgetRepresentation_h
43 
44 #include "vtkInteractionWidgetsModule.h" // For export macro
45 #include "vtkProp.h"
46 #include "vtkWeakPointer.h" // needed for vtkWeakPointer iVar.
47 
49 class vtkPickingManager;
50 class vtkRenderer;
51 
52 
54 {
55 public:
57 
59  void PrintSelf(ostream& os, vtkIndent indent);
61 
63 
65  vtkBooleanMacro(PickingManaged, bool);
66  vtkSetMacro(PickingManaged, bool);
67  vtkGetMacro(PickingManaged, bool);
69 
71 
82  virtual void SetRenderer(vtkRenderer *ren);
83  virtual vtkRenderer* GetRenderer();
84  virtual void BuildRepresentation() = 0;
86 
88 
114  virtual void PlaceWidget(double* vtkNotUsed(bounds[6])) {}
115  virtual void StartWidgetInteraction(double eventPos[2]) { (void)eventPos; }
116  virtual void WidgetInteraction(double newEventPos[2]) { (void)newEventPos; }
117  virtual void EndWidgetInteraction(double newEventPos[2]) { (void)newEventPos; }
118  virtual int ComputeInteractionState(int X, int Y, int modify=0);
119  virtual int GetInteractionState()
120  {return this->InteractionState;}
121  virtual void Highlight(int vtkNotUsed(highlightOn)) {}
123 
125 
131  vtkSetClampMacro(PlaceFactor,double,0.01,VTK_DOUBLE_MAX);
132  vtkGetMacro(PlaceFactor,double);
134 
136 
144  vtkSetClampMacro(HandleSize,double,0.001,1000);
145  vtkGetMacro(HandleSize,double);
147 
149 
151  vtkGetMacro( NeedToRender, int );
152  vtkSetClampMacro( NeedToRender, int, 0, 1 );
153  vtkBooleanMacro( NeedToRender, int );
155 
157 
164  virtual double *GetBounds() {return NULL;}
165  virtual void ShallowCopy(vtkProp *prop);
166  virtual void GetActors(vtkPropCollection *) {}
167  virtual void GetActors2D(vtkPropCollection *) {}
168  virtual void GetVolumes(vtkPropCollection *) {}
170  virtual int RenderOverlay(vtkViewport *vtkNotUsed(viewport)) {return 0;}
171  virtual int RenderOpaqueGeometry(vtkViewport *vtkNotUsed(viewport)) {return 0;}
172  virtual int RenderTranslucentPolygonalGeometry(vtkViewport *vtkNotUsed(viewport)) {return 0;}
173  virtual int RenderVolumetricGeometry(vtkViewport *vtkNotUsed(viewport)) {return 0;}
174  virtual int HasTranslucentPolygonalGeometry() { return 0; }
176 
177 protected:
180 
181  // The renderer in which this widget is placed
183 
184  // The state of this representation based on a recent event
186 
187  // These are used to track the beginning of interaction with the representation
188  // It's dimensioned [3] because some events re processed in 3D.
189  double StartEventPosition[3];
190 
191  // Instance variable and members supporting suclasses
192  double PlaceFactor; // Used to control how widget is placed around bounding box
193  int Placed; // Indicate whether widget has been placed
194  void AdjustBounds(double bounds[6], double newBounds[6], double center[3]);
195  double InitialBounds[6]; //initial bounds on place widget (valid after PlaceWidget)
196  double InitialLength; //initial length on place widget
197 
198  // Sizing handles is tricky because the procedure requires information
199  // relative to the last pick, as well as a live renderer to perform
200  // coordinate conversions. In some cases, a pick is never made so handle
201  // sizing has to follow a different path. The following ivars help with
202  // this process.
203  int ValidPick; //indicate when valid picks are made
204 
205  // This variable controls whether the picking is managed by the Picking
206  // Manager or not. True by default.
208 
212  virtual void RegisterPickers();
213 
215  virtual void UnRegisterPickers();
216 
219  virtual void PickersModified();
220 
223  vtkPickingManager* GetPickingManager();
224 
226 
229  vtkAssemblyPath* GetAssemblyPath(double X, double Y, double Z,
230  vtkAbstractPropPicker* picker);
232 
233 
234  // Members use to control handle size. The two methods return a "radius"
235  // in world coordinates. Note that the HandleSize data member is used
236  // internal to the SizeHandles__() methods.
237  double HandleSize; //controlling relative size of widget handles
238  double SizeHandlesRelativeToViewport(double factor, double pos[3]);
239  double SizeHandlesInPixels(double factor,double pos[3]);
240 
241  // Try and reduce multiple renders
243 
244  // This is the time that the representation was built. This data member
245  // can be used to reduce the time spent building the widget.
247 
248 private:
249  vtkWidgetRepresentation(const vtkWidgetRepresentation&); //Not implemented
250  void operator=(const vtkWidgetRepresentation&); //Not implemented
251 };
252 
253 #endif
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:52
virtual int RenderOverlay(vtkViewport *vtkNotUsed(viewport))
void PrintSelf(ostream &os, vtkIndent indent)
virtual void EndWidgetInteraction(double newEventPos[2])
virtual void ShallowCopy(vtkProp *prop)
#define VTK_DOUBLE_MAX
Definition: vtkType.h:140
abstract specification for Viewports
Definition: vtkViewport.h:46
virtual void StartWidgetInteraction(double eventPos[2])
record modification and/or execution time
Definition: vtkTimeStamp.h:34
vtkWeakPointer< vtkRenderer > Renderer
abstract specification for renderers
Definition: vtkRenderer.h:62
virtual void ReleaseGraphicsResources(vtkWindow *)
abstract class defines interface between the widget and widget representation classes ...
a list of Props
window superclass for vtkRenderWindow
Definition: vtkWindow.h:36
#define VTKINTERACTIONWIDGETS_EXPORT
a list of nodes that form an assembly path
virtual int HasTranslucentPolygonalGeometry()
a simple class to control print indentation
Definition: vtkIndent.h:38
virtual void WidgetInteraction(double newEventPos[2])
virtual void GetActors(vtkPropCollection *)
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]))
virtual void Highlight(int vtkNotUsed(highlightOn))
virtual int RenderTranslucentPolygonalGeometry(vtkViewport *vtkNotUsed(viewport))