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 
47 class vtkRenderer;
48 
49 
50 class VTKINTERACTIONWIDGETS_EXPORT vtkWidgetRepresentation : public vtkProp
51 {
52 public:
54 
56  void PrintSelf(ostream& os, vtkIndent indent);
58 
60 
68  virtual void SetRenderer(vtkRenderer *ren);
69  vtkGetObjectMacro(Renderer,vtkRenderer);
70  virtual void BuildRepresentation() = 0;
72 
74 
100  virtual void PlaceWidget(double* vtkNotUsed(bounds[6])) {}
101  virtual void StartWidgetInteraction(double eventPos[2]) { (void)eventPos; }
102  virtual void WidgetInteraction(double newEventPos[2]) { (void)newEventPos; }
103  virtual void EndWidgetInteraction(double newEventPos[2]) { (void)newEventPos; }
104  virtual int ComputeInteractionState(int X, int Y, int modify=0);
105  virtual int GetInteractionState()
106  {return this->InteractionState;}
107  virtual void Highlight(int vtkNotUsed(highlightOn)) {}
109 
111 
117  vtkSetClampMacro(PlaceFactor,double,0.01,VTK_DOUBLE_MAX);
118  vtkGetMacro(PlaceFactor,double);
120 
122 
130  vtkSetClampMacro(HandleSize,double,0.001,1000);
131  vtkGetMacro(HandleSize,double);
133 
135 
137  vtkGetMacro( NeedToRender, int );
138  vtkSetClampMacro( NeedToRender, int, 0, 1 );
139  vtkBooleanMacro( NeedToRender, int );
141 
143 
150  virtual double *GetBounds() {return NULL;}
151  virtual void ShallowCopy(vtkProp *prop);
152  virtual void GetActors(vtkPropCollection *) {}
153  virtual void GetActors2D(vtkPropCollection *) {}
154  virtual void GetVolumes(vtkPropCollection *) {}
156  virtual int RenderOverlay(vtkViewport *vtkNotUsed(viewport)) {return 0;}
157  virtual int RenderOpaqueGeometry(vtkViewport *vtkNotUsed(viewport)) {return 0;}
158  virtual int RenderTranslucentPolygonalGeometry(vtkViewport *vtkNotUsed(viewport)) {return 0;}
159  virtual int RenderVolumetricGeometry(vtkViewport *vtkNotUsed(viewport)) {return 0;}
160  virtual int HasTranslucentPolygonalGeometry() { return 0; }
162 
163 protected:
166 
167  // The renderer in which this widget is placed
169 
170  // The state of this representation based on a recent event
172 
173  // These are used to track the beginning of interaction with the representation
174  // It's dimensioned [3] because some events re processed in 3D.
175  double StartEventPosition[3];
176 
177  // Instance variable and members supporting suclasses
178  double PlaceFactor; // Used to control how widget is placed around bounding box
179  int Placed; // Indicate whether widget has been placed
180  void AdjustBounds(double bounds[6], double newBounds[6], double center[3]);
181  double InitialBounds[6]; //initial bounds on place widget (valid after PlaceWidget)
182  double InitialLength; //initial length on place widget
183 
184  // Sizing handles is tricky because the procedure requires information
185  // relative to the last pick, as well as a live renderer to perform
186  // coordinate conversions. In some cases, a pick is never made so handle
187  // sizing has to follow a different path. The following ivars help with
188  // this process.
189  int ValidPick; //indicate when valid picks are made
190 
191  // Members use to control handle size. The two methods return a "radius"
192  // in world coordinates. Note that the HandleSize data member is used
193  // internal to the SizeHandles__() methods.
194  double HandleSize; //controlling relative size of widget handles
195  double SizeHandlesRelativeToViewport(double factor, double pos[3]);
196  double SizeHandlesInPixels(double factor,double pos[3]);
197 
198  // Try and reduce multiple renders
200 
201  // This is the time that the representation was built. This data member
202  // can be used to reduce the time spent building the widget.
204 
205 private:
206  vtkWidgetRepresentation(const vtkWidgetRepresentation&); //Not implemented
207  void operator=(const vtkWidgetRepresentation&); //Not implemented
208 };
209 
210 #endif