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 
79  virtual void SetRenderer(vtkRenderer *ren);
80  virtual vtkRenderer* GetRenderer();
81  virtual void BuildRepresentation() = 0;
83 
85 
111  virtual void PlaceWidget(double* vtkNotUsed(bounds[6])) {}
112  virtual void StartWidgetInteraction(double eventPos[2]) { (void)eventPos; }
113  virtual void WidgetInteraction(double newEventPos[2]) { (void)newEventPos; }
114  virtual void EndWidgetInteraction(double newEventPos[2]) { (void)newEventPos; }
115  virtual int ComputeInteractionState(int X, int Y, int modify=0);
116  virtual int GetInteractionState()
117  {return this->InteractionState;}
118  virtual void Highlight(int vtkNotUsed(highlightOn)) {}
120 
122 
128  vtkSetClampMacro(PlaceFactor,double,0.01,VTK_DOUBLE_MAX);
129  vtkGetMacro(PlaceFactor,double);
131 
133 
141  vtkSetClampMacro(HandleSize,double,0.001,1000);
142  vtkGetMacro(HandleSize,double);
144 
146 
148  vtkGetMacro( NeedToRender, int );
149  vtkSetClampMacro( NeedToRender, int, 0, 1 );
150  vtkBooleanMacro( NeedToRender, int );
152 
154 
161  virtual double *GetBounds() {return NULL;}
162  virtual void ShallowCopy(vtkProp *prop);
163  virtual void GetActors(vtkPropCollection *) {}
164  virtual void GetActors2D(vtkPropCollection *) {}
165  virtual void GetVolumes(vtkPropCollection *) {}
167  virtual int RenderOverlay(vtkViewport *vtkNotUsed(viewport)) {return 0;}
168  virtual int RenderOpaqueGeometry(vtkViewport *vtkNotUsed(viewport)) {return 0;}
169  virtual int RenderTranslucentPolygonalGeometry(vtkViewport *vtkNotUsed(viewport)) {return 0;}
170  virtual int RenderVolumetricGeometry(vtkViewport *vtkNotUsed(viewport)) {return 0;}
171  virtual int HasTranslucentPolygonalGeometry() { return 0; }
173 
174 protected:
177 
178  // The renderer in which this widget is placed
180 
181  // The state of this representation based on a recent event
183 
184  // These are used to track the beginning of interaction with the representation
185  // It's dimensioned [3] because some events re processed in 3D.
186  double StartEventPosition[3];
187 
188  // Instance variable and members supporting suclasses
189  double PlaceFactor; // Used to control how widget is placed around bounding box
190  int Placed; // Indicate whether widget has been placed
191  void AdjustBounds(double bounds[6], double newBounds[6], double center[3]);
192  double InitialBounds[6]; //initial bounds on place widget (valid after PlaceWidget)
193  double InitialLength; //initial length on place widget
194 
195  // Sizing handles is tricky because the procedure requires information
196  // relative to the last pick, as well as a live renderer to perform
197  // coordinate conversions. In some cases, a pick is never made so handle
198  // sizing has to follow a different path. The following ivars help with
199  // this process.
200  int ValidPick; //indicate when valid picks are made
201 
202  // This variable controls whether the picking is managed by the Picking
203  // Manager or not. True by default.
205 
209  virtual void RegisterPickers();
210 
212  virtual void UnRegisterPickers();
213 
216  virtual void PickersModified();
217 
220  vtkPickingManager* GetPickingManager();
221 
223 
226  vtkAssemblyPath* GetAssemblyPath(double X, double Y, double Z,
227  vtkAbstractPropPicker* picker);
229 
230 
231  // Members use to control handle size. The two methods return a "radius"
232  // in world coordinates. Note that the HandleSize data member is used
233  // internal to the SizeHandles__() methods.
234  double HandleSize; //controlling relative size of widget handles
235  double SizeHandlesRelativeToViewport(double factor, double pos[3]);
236  double SizeHandlesInPixels(double factor,double pos[3]);
237 
238  // Try and reduce multiple renders
240 
241  // This is the time that the representation was built. This data member
242  // can be used to reduce the time spent building the widget.
244 
245 private:
246  vtkWidgetRepresentation(const vtkWidgetRepresentation&); //Not implemented
247  void operator=(const vtkWidgetRepresentation&); //Not implemented
248 };
249 
250 #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:142
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:63
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))