VTK
|
00001 /*========================================================================= 00002 00003 Program: Visualization Toolkit 00004 Module: vtkOrientationMarkerWidget.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 =========================================================================*/ 00077 #ifndef vtkOrientationMarkerWidget_h 00078 #define vtkOrientationMarkerWidget_h 00079 00080 #include "vtkInteractionWidgetsModule.h" // For export macro 00081 #include "vtkInteractorObserver.h" 00082 00083 class vtkActor2D; 00084 class vtkPolyData; 00085 class vtkProp; 00086 class vtkOrientationMarkerWidgetObserver; 00087 class vtkRenderer; 00088 00089 class VTKINTERACTIONWIDGETS_EXPORT vtkOrientationMarkerWidget : public vtkInteractorObserver 00090 { 00091 public: 00092 static vtkOrientationMarkerWidget* New(); 00093 vtkTypeMacro(vtkOrientationMarkerWidget, vtkInteractorObserver); 00094 void PrintSelf(ostream& os, vtkIndent indent); 00095 00097 00098 virtual void SetOrientationMarker(vtkProp *prop); 00099 vtkGetObjectMacro(OrientationMarker, vtkProp); 00101 00103 virtual void SetEnabled(int); 00104 00107 void ExecuteCameraUpdateEvent(vtkObject *o, unsigned long event, void *calldata); 00108 00110 00112 void SetInteractive(int state); 00113 vtkGetMacro(Interactive, int); 00114 vtkBooleanMacro(Interactive, int); 00116 00118 00121 void SetOutlineColor(double r, double g, double b); 00122 double *GetOutlineColor(); 00124 00126 00128 void SetViewport(double minX, double minY, double maxX, double maxY); 00129 double* GetViewport(); 00131 00133 00136 vtkSetClampMacro(Tolerance,int,1,10); 00137 vtkGetMacro(Tolerance,int); 00139 00140 protected: 00141 vtkOrientationMarkerWidget(); 00142 ~vtkOrientationMarkerWidget(); 00143 00144 vtkRenderer *Renderer; 00145 vtkProp *OrientationMarker; 00146 vtkPolyData *Outline; 00147 vtkActor2D *OutlineActor; 00148 00149 unsigned long StartEventObserverId; 00150 00151 static void ProcessEvents(vtkObject *object, unsigned long event, 00152 void *clientdata, void *calldata); 00153 00154 // ProcessEvents() dispatches to these methods. 00155 void OnLeftButtonDown(); 00156 void OnLeftButtonUp(); 00157 void OnMouseMove(); 00158 00159 // observer to update the renderer's camera 00160 vtkOrientationMarkerWidgetObserver *Observer; 00161 00162 int Interactive; 00163 int Tolerance; 00164 int Moving; 00165 00166 // used to compute relative movements 00167 int StartPosition[2]; 00168 00169 //BTX - manage the state of the widget 00170 int State; 00171 enum WidgetState 00172 { 00173 Outside = 0, 00174 Inside, 00175 Translating, 00176 AdjustingP1, 00177 AdjustingP2, 00178 AdjustingP3, 00179 AdjustingP4 00180 }; 00181 //ETX 00182 00183 00184 // use to determine what state the mouse is over, edge1 p1, etc. 00185 // returns a state from the WidgetState enum above 00186 int ComputeStateBasedOnPosition(int X, int Y, int *pos1, int *pos2); 00187 00188 // set the cursor to the correct shape based on State argument 00189 void SetCursor(int state); 00190 00191 // adjust the viewport depending on state 00192 void MoveWidget(int X, int Y); 00193 void ResizeTopLeft(int X, int Y); 00194 void ResizeTopRight(int X, int Y); 00195 void ResizeBottomLeft(int X, int Y); 00196 void ResizeBottomRight(int X, int Y); 00197 00198 void SquareRenderer(); 00199 void UpdateOutline(); 00200 00201 private: 00202 vtkOrientationMarkerWidget(const vtkOrientationMarkerWidget&); // Not implemented 00203 void operator=(const vtkOrientationMarkerWidget&); // Not implemented 00204 }; 00205 00206 #endif