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 "vtkProp.h"
45 
46 class vtkRenderer;
47 
48 
50 {
51 public:
53 
55  void PrintSelf(ostream& os, vtkIndent indent);
57 
59 
67  virtual void SetRenderer(vtkRenderer *ren);
68  vtkGetObjectMacro(Renderer,vtkRenderer);
69  virtual void BuildRepresentation() = 0;
71 
73 
99  virtual void PlaceWidget(double* vtkNotUsed(bounds[6])) {}
100  virtual void StartWidgetInteraction(double eventPos[2]) { (void)eventPos; }
101  virtual void WidgetInteraction(double newEventPos[2]) { (void)newEventPos; }
102  virtual void EndWidgetInteraction(double newEventPos[2]) { (void)newEventPos; }
103  virtual int ComputeInteractionState(int X, int Y, int modify=0);
104  virtual int GetInteractionState()
105  {return this->InteractionState;}
106  virtual void Highlight(int vtkNotUsed(highlightOn)) {}
108 
110 
116  vtkSetClampMacro(PlaceFactor,double,0.01,VTK_DOUBLE_MAX);
117  vtkGetMacro(PlaceFactor,double);
119 
121 
129  vtkSetClampMacro(HandleSize,double,0.001,1000);
130  vtkGetMacro(HandleSize,double);
132 
134 
136  vtkGetMacro( NeedToRender, int );
137  vtkSetClampMacro( NeedToRender, int, 0, 1 );
138  vtkBooleanMacro( NeedToRender, int );
140 
142 
149  virtual double *GetBounds() {return NULL;}
150  virtual void ShallowCopy(vtkProp *prop);
151  virtual void GetActors(vtkPropCollection *) {}
152  virtual void GetActors2D(vtkPropCollection *) {}
153  virtual void GetVolumes(vtkPropCollection *) {}
155  virtual int RenderOverlay(vtkViewport *vtkNotUsed(viewport)) {return 0;}
156  virtual int RenderOpaqueGeometry(vtkViewport *vtkNotUsed(viewport)) {return 0;}
157  virtual int RenderTranslucentPolygonalGeometry(vtkViewport *vtkNotUsed(viewport)) {return 0;}
158  virtual int RenderVolumetricGeometry(vtkViewport *vtkNotUsed(viewport)) {return 0;}
159  virtual int HasTranslucentPolygonalGeometry() { return 0; }
161 
162 protected:
165 
166  // The renderer in which this widget is placed
168 
169  // The state of this representation based on a recent event
171 
172  // These are used to track the beginning of interaction with the representation
173  // It's dimensioned [3] because some events re processed in 3D.
174  double StartEventPosition[3];
175 
176  // Instance variable and members supporting suclasses
177  double PlaceFactor; // Used to control how widget is placed around bounding box
178  int Placed; // Indicate whether widget has been placed
179  void AdjustBounds(double bounds[6], double newBounds[6], double center[3]);
180  double InitialBounds[6]; //initial bounds on place widget (valid after PlaceWidget)
181  double InitialLength; //initial length on place widget
182 
183  // Sizing handles is tricky because the procedure requires information
184  // relative to the last pick, as well as a live renderer to perform
185  // coordinate conversions. In some cases, a pick is never made so handle
186  // sizing has to follow a different path. The following ivars help with
187  // this process.
188  int ValidPick; //indicate when valid picks are made
189 
190  // Members use to control handle size. The two methods return a "radius"
191  // in world coordinates. Note that the HandleSize data member is used
192  // internal to the SizeHandles__() methods.
193  double HandleSize; //controlling relative size of widget handles
194  double SizeHandlesRelativeToViewport(double factor, double pos[3]);
195  double SizeHandlesInPixels(double factor,double pos[3]);
196 
197  // Try and reduce multiple renders
199 
200  // This is the time that the representation was built. This data member
201  // can be used to reduce the time spent building the widget.
203 
204 private:
205  vtkWidgetRepresentation(const vtkWidgetRepresentation&); //Not implemented
206  void operator=(const vtkWidgetRepresentation&); //Not implemented
207 };
208 
209 #endif
abstract superclass for all actors, volumes and annotations
Definition: vtkProp.h:49
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:133
abstract specification for Viewports
Definition: vtkViewport.h:45
virtual void StartWidgetInteraction(double eventPos[2])
record modification and/or execution time
Definition: vtkTimeStamp.h:33
abstract specification for renderers
Definition: vtkRenderer.h:69
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:35
virtual int HasTranslucentPolygonalGeometry()
a simple class to control print indentation
Definition: vtkIndent.h:37
virtual void WidgetInteraction(double newEventPos[2])
#define VTK_WIDGETS_EXPORT
virtual void GetActors(vtkPropCollection *)
virtual int RenderVolumetricGeometry(vtkViewport *vtkNotUsed(viewport))
virtual int RenderOpaqueGeometry(vtkViewport *vtkNotUsed(viewport))
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))