VTK
|
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 "vtkInteractionWidgetsModule.h" // For export macro 00045 #include "vtkProp.h" 00046 #include "vtkWeakPointer.h" // needed for vtkWeakPointer iVar. 00047 00048 class vtkAbstractPropPicker; 00049 class vtkPickingManager; 00050 class vtkRenderer; 00051 00052 00053 class VTKINTERACTIONWIDGETS_EXPORT vtkWidgetRepresentation : public vtkProp 00054 { 00055 public: 00057 00058 vtkTypeMacro(vtkWidgetRepresentation,vtkProp); 00059 void PrintSelf(ostream& os, vtkIndent indent); 00061 00063 00065 vtkBooleanMacro(PickingManaged, bool); 00066 vtkSetMacro(PickingManaged, bool); 00067 vtkGetMacro(PickingManaged, bool); 00069 00071 00079 virtual void SetRenderer(vtkRenderer *ren); 00080 virtual vtkRenderer* GetRenderer(); 00081 virtual void BuildRepresentation() = 0; 00083 00085 00111 virtual void PlaceWidget(double* vtkNotUsed(bounds[6])) {} 00112 virtual void StartWidgetInteraction(double eventPos[2]) { (void)eventPos; } 00113 virtual void WidgetInteraction(double newEventPos[2]) { (void)newEventPos; } 00114 virtual void EndWidgetInteraction(double newEventPos[2]) { (void)newEventPos; } 00115 virtual int ComputeInteractionState(int X, int Y, int modify=0); 00116 virtual int GetInteractionState() 00117 {return this->InteractionState;} 00118 virtual void Highlight(int vtkNotUsed(highlightOn)) {} 00120 00122 00128 vtkSetClampMacro(PlaceFactor,double,0.01,VTK_DOUBLE_MAX); 00129 vtkGetMacro(PlaceFactor,double); 00131 00133 00141 vtkSetClampMacro(HandleSize,double,0.001,1000); 00142 vtkGetMacro(HandleSize,double); 00144 00146 00148 vtkGetMacro( NeedToRender, int ); 00149 vtkSetClampMacro( NeedToRender, int, 0, 1 ); 00150 vtkBooleanMacro( NeedToRender, int ); 00152 00154 00161 virtual double *GetBounds() {return NULL;} 00162 virtual void ShallowCopy(vtkProp *prop); 00163 virtual void GetActors(vtkPropCollection *) {} 00164 virtual void GetActors2D(vtkPropCollection *) {} 00165 virtual void GetVolumes(vtkPropCollection *) {} 00166 virtual void ReleaseGraphicsResources(vtkWindow *) {} 00167 virtual int RenderOverlay(vtkViewport *vtkNotUsed(viewport)) {return 0;} 00168 virtual int RenderOpaqueGeometry(vtkViewport *vtkNotUsed(viewport)) {return 0;} 00169 virtual int RenderTranslucentPolygonalGeometry(vtkViewport *vtkNotUsed(viewport)) {return 0;} 00170 virtual int RenderVolumetricGeometry(vtkViewport *vtkNotUsed(viewport)) {return 0;} 00171 virtual int HasTranslucentPolygonalGeometry() { return 0; } 00173 00174 protected: 00175 vtkWidgetRepresentation(); 00176 ~vtkWidgetRepresentation(); 00177 00178 // The renderer in which this widget is placed 00179 vtkWeakPointer<vtkRenderer> Renderer; 00180 00181 // The state of this representation based on a recent event 00182 int InteractionState; 00183 00184 // These are used to track the beginning of interaction with the representation 00185 // It's dimensioned [3] because some events re processed in 3D. 00186 double StartEventPosition[3]; 00187 00188 // Instance variable and members supporting suclasses 00189 double PlaceFactor; // Used to control how widget is placed around bounding box 00190 int Placed; // Indicate whether widget has been placed 00191 void AdjustBounds(double bounds[6], double newBounds[6], double center[3]); 00192 double InitialBounds[6]; //initial bounds on place widget (valid after PlaceWidget) 00193 double InitialLength; //initial length on place widget 00194 00195 // Sizing handles is tricky because the procedure requires information 00196 // relative to the last pick, as well as a live renderer to perform 00197 // coordinate conversions. In some cases, a pick is never made so handle 00198 // sizing has to follow a different path. The following ivars help with 00199 // this process. 00200 int ValidPick; //indicate when valid picks are made 00201 00202 // This variable controls whether the picking is managed by the Picking 00203 // Manager or not. True by default. 00204 bool PickingManaged; 00205 00209 virtual void RegisterPickers(); 00210 00212 virtual void UnRegisterPickers(); 00213 00216 virtual void PickersModified(); 00217 00220 vtkPickingManager* GetPickingManager(); 00221 00223 00226 vtkAssemblyPath* GetAssemblyPath(double X, double Y, double Z, 00227 vtkAbstractPropPicker* picker); 00229 00230 00231 // Members use to control handle size. The two methods return a "radius" 00232 // in world coordinates. Note that the HandleSize data member is used 00233 // internal to the SizeHandles__() methods. 00234 double HandleSize; //controlling relative size of widget handles 00235 double SizeHandlesRelativeToViewport(double factor, double pos[3]); 00236 double SizeHandlesInPixels(double factor,double pos[3]); 00237 00238 // Try and reduce multiple renders 00239 int NeedToRender; 00240 00241 // This is the time that the representation was built. This data member 00242 // can be used to reduce the time spent building the widget. 00243 vtkTimeStamp BuildTime; 00244 00245 private: 00246 vtkWidgetRepresentation(const vtkWidgetRepresentation&); //Not implemented 00247 void operator=(const vtkWidgetRepresentation&); //Not implemented 00248 }; 00249 00250 #endif