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