VTK
dox/Widgets/vtkWidgetRepresentation.h
Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    vtkWidgetRepresentation.h
00005 
00006   Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
00007   All rights reserved.
00008   See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
00009 
00010      This software is distributed WITHOUT ANY WARRANTY; without even
00011      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
00012      PURPOSE.  See the above copyright notice for more information.
00013 
00014 =========================================================================*/
00041 #ifndef __vtkWidgetRepresentation_h
00042 #define __vtkWidgetRepresentation_h
00043 
00044 #include "vtkProp.h"
00045 
00046 class vtkRenderer;
00047 
00048 
00049 class VTK_WIDGETS_EXPORT vtkWidgetRepresentation : public vtkProp
00050 {
00051 public:
00053 
00054   vtkTypeMacro(vtkWidgetRepresentation,vtkProp);
00055   void PrintSelf(ostream& os, vtkIndent indent);
00057 
00059 
00067   virtual void SetRenderer(vtkRenderer *ren);
00068   vtkGetObjectMacro(Renderer,vtkRenderer);
00069   virtual void BuildRepresentation() = 0;
00071 
00073 
00099   virtual void PlaceWidget(double* vtkNotUsed(bounds[6])) {}
00100   virtual void StartWidgetInteraction(double eventPos[2]) { (void)eventPos; }
00101   virtual void WidgetInteraction(double newEventPos[2]) { (void)newEventPos; }
00102   virtual void EndWidgetInteraction(double newEventPos[2]) { (void)newEventPos; }
00103   virtual int ComputeInteractionState(int X, int Y, int modify=0);
00104   virtual int GetInteractionState()
00105     {return this->InteractionState;}
00106   virtual void Highlight(int vtkNotUsed(highlightOn)) {}
00108 
00110 
00116   vtkSetClampMacro(PlaceFactor,double,0.01,VTK_DOUBLE_MAX);
00117   vtkGetMacro(PlaceFactor,double);
00119 
00121 
00129   vtkSetClampMacro(HandleSize,double,0.001,1000);
00130   vtkGetMacro(HandleSize,double);
00132 
00134 
00136   vtkGetMacro( NeedToRender, int );
00137   vtkSetClampMacro( NeedToRender, int, 0, 1 );
00138   vtkBooleanMacro( NeedToRender, int );
00140   
00142 
00149   virtual double *GetBounds() {return NULL;}
00150   virtual void ShallowCopy(vtkProp *prop);
00151   virtual void GetActors(vtkPropCollection *) {}
00152   virtual void GetActors2D(vtkPropCollection *) {}
00153   virtual void GetVolumes(vtkPropCollection *) {}
00154   virtual void ReleaseGraphicsResources(vtkWindow *) {}
00155   virtual int RenderOverlay(vtkViewport *vtkNotUsed(viewport)) {return 0;}
00156   virtual int RenderOpaqueGeometry(vtkViewport *vtkNotUsed(viewport)) {return 0;}
00157   virtual int RenderTranslucentPolygonalGeometry(vtkViewport *vtkNotUsed(viewport)) {return 0;}
00158   virtual int RenderVolumetricGeometry(vtkViewport *vtkNotUsed(viewport)) {return 0;}
00159   virtual int HasTranslucentPolygonalGeometry() { return 0; }
00161   
00162 protected:
00163   vtkWidgetRepresentation();
00164   ~vtkWidgetRepresentation();
00165 
00166   // The renderer in which this widget is placed
00167   vtkRenderer *Renderer;
00168 
00169   // The state of this representation based on a recent event
00170   int InteractionState;
00171 
00172   // These are used to track the beginning of interaction with the representation
00173   // It's dimensioned [3] because some events re processed in 3D.
00174   double StartEventPosition[3];
00175 
00176   // Instance variable and members supporting suclasses
00177   double PlaceFactor; // Used to control how widget is placed around bounding box
00178   int    Placed; // Indicate whether widget has been placed
00179   void   AdjustBounds(double bounds[6], double newBounds[6], double center[3]);
00180   double InitialBounds[6]; //initial bounds on place widget (valid after PlaceWidget)
00181   double InitialLength; //initial length on place widget
00182 
00183   // Sizing handles is tricky because the procedure requires information
00184   // relative to the last pick, as well as a live renderer to perform
00185   // coordinate conversions. In some cases, a pick is never made so handle
00186   // sizing has to follow a different path. The following ivars help with
00187   // this process.
00188   int    ValidPick; //indicate when valid picks are made
00189 
00190   // Members use to control handle size. The two methods return a "radius"
00191   // in world coordinates. Note that the HandleSize data member is used
00192   // internal to the SizeHandles__() methods.
00193   double HandleSize; //controlling relative size of widget handles
00194   double SizeHandlesRelativeToViewport(double factor, double pos[3]);
00195   double SizeHandlesInPixels(double factor,double pos[3]);
00196   
00197   // Try and reduce multiple renders
00198   int NeedToRender;
00199   
00200   // This is the time that the representation was built. This data member
00201   // can be used to reduce the time spent building the widget.
00202   vtkTimeStamp  BuildTime;
00203 
00204 private:
00205   vtkWidgetRepresentation(const vtkWidgetRepresentation&);  //Not implemented
00206   void operator=(const vtkWidgetRepresentation&);  //Not implemented
00207 };
00208 
00209 #endif