VTK
dox/Interaction/Widgets/vtkAffineRepresentation2D.h
Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    vtkAffineRepresentation2D.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 =========================================================================*/
00046 #ifndef __vtkAffineRepresentation2D_h
00047 #define __vtkAffineRepresentation2D_h
00048 
00049 #include "vtkInteractionWidgetsModule.h" // For export macro
00050 #include "vtkAffineRepresentation.h"
00051 
00052 class vtkProperty2D;
00053 class vtkActor2D;
00054 class vtkPolyDataMapper2D;
00055 class vtkPolyData;
00056 class vtkPoints;
00057 class vtkCellArray;
00058 class vtkTextProperty;
00059 class vtkLeaderActor2D;
00060 class vtkTextMapper;
00061 class vtkActor2D;
00062 
00063 
00064 class VTKINTERACTIONWIDGETS_EXPORT vtkAffineRepresentation2D : public vtkAffineRepresentation
00065 {
00066 public:
00068   static vtkAffineRepresentation2D *New();
00069 
00071 
00072   vtkTypeMacro(vtkAffineRepresentation2D,vtkAffineRepresentation);
00073   void PrintSelf(ostream& os, vtkIndent indent);
00075 
00077 
00082   vtkSetClampMacro(BoxWidth,int,10,VTK_INT_MAX);
00083   vtkGetMacro(BoxWidth,int);
00084   vtkSetClampMacro(CircleWidth,int,10,VTK_INT_MAX);
00085   vtkGetMacro(CircleWidth,int);
00086   vtkSetClampMacro(AxesWidth,int,10,VTK_INT_MAX);
00087   vtkGetMacro(AxesWidth,int);
00089 
00091 
00094   void SetOrigin(double o[3]) {this->SetOrigin(o[0],o[1],o[2]);}
00095   void SetOrigin(double ox, double oy, double oz);
00096   vtkGetVector3Macro(Origin,double);
00098 
00105   virtual void GetTransform(vtkTransform *t);
00106 
00108 
00109   void SetProperty(vtkProperty2D*);
00110   void SetSelectedProperty(vtkProperty2D*);
00111   void SetTextProperty(vtkTextProperty*);
00112   vtkGetObjectMacro(Property,vtkProperty2D);
00113   vtkGetObjectMacro(SelectedProperty,vtkProperty2D);
00114   vtkGetObjectMacro(TextProperty,vtkTextProperty);
00116 
00118 
00122   vtkSetMacro(DisplayText,int);
00123   vtkGetMacro(DisplayText,int);
00124   vtkBooleanMacro(DisplayText,int);
00126 
00128 
00133   virtual void PlaceWidget(double bounds[6]);
00134   virtual void StartWidgetInteraction(double eventPos[2]);
00135   virtual void WidgetInteraction(double eventPos[2]);
00136   virtual void EndWidgetInteraction(double eventPos[2]);
00137   virtual int ComputeInteractionState(int X, int Y, int modify=0);
00138   virtual void BuildRepresentation();
00140 
00142 
00143   virtual void ShallowCopy(vtkProp *prop);
00144   virtual void GetActors2D(vtkPropCollection *);
00145   virtual void ReleaseGraphicsResources(vtkWindow *);
00146   virtual int RenderOverlay(vtkViewport *viewport);
00148 
00149 protected:
00150   vtkAffineRepresentation2D();
00151   ~vtkAffineRepresentation2D();
00152 
00153   // Methods to manipulate the cursor
00154   void Translate(double eventPos[2]);
00155   void Scale(double eventPos[2]);
00156   void Rotate(double eventPos[2]);
00157   void Shear(double eventPos[2]);
00158   void Highlight(int highlight);
00159   void UpdateText(const char *text, double eventPos[2]);
00160 
00161   // The width of the widget in normalized viewport coordinates.
00162   int BoxWidth;
00163   int CircleWidth;
00164   int AxesWidth;
00165 
00166   // Display text
00167   int DisplayText;
00168 
00169   // Internal variables for bookkeeping (in display coordinates unless noted)
00170   double CurrentWidth;
00171   double CurrentRadius;
00172   double CurrentAxesWidth;
00173 
00174   // The internal transformation matrix
00175   vtkTransform *CurrentTransform;
00176   vtkTransform *TotalTransform;
00177   vtkTransform *TempTransform;
00178   double Origin[4]; //the current origin in world coordinates
00179   double DisplayOrigin[3]; //the current origin in display coordinates
00180   double CurrentTranslation[3]; //translation this movement
00181   double StartWorldPosition[4]; //Start event position converted to world
00182   double StartAngle; //The starting angle (always positive)
00183   double CurrentAngle;
00184   double CurrentScale[2];
00185   double CurrentShear[2];
00186   void   ApplyShear(); //helper method to apply shear to matrix
00187 
00188   // Properties used to control the appearance of selected objects and
00189   // the manipulator in general.
00190   vtkProperty2D   *Property;
00191   vtkProperty2D   *SelectedProperty;
00192   vtkTextProperty *TextProperty;
00193   void             CreateDefaultProperties();
00194   double           Opacity;
00195   double           SelectedOpacity;
00196 
00197   // Support picking
00198   double LastEventPosition[2];
00199 
00200   // These are the classes that form the geometric representation -----------
00201   // The label
00202   vtkTextMapper *TextMapper;
00203   vtkActor2D    *TextActor;
00204 
00205   // The outer box
00206   vtkPoints           *BoxPoints;
00207   vtkCellArray        *BoxCellArray;
00208   vtkPolyData         *Box;
00209   vtkPolyDataMapper2D *BoxMapper;
00210   vtkActor2D          *BoxActor;
00211 
00212   vtkPoints           *HBoxPoints;
00213   vtkCellArray        *HBoxCellArray;
00214   vtkPolyData         *HBox;
00215   vtkPolyDataMapper2D *HBoxMapper;
00216   vtkActor2D          *HBoxActor;
00217 
00218   // The circle
00219   vtkPoints           *CirclePoints;
00220   vtkCellArray        *CircleCellArray;
00221   vtkPolyData         *Circle;
00222   vtkPolyDataMapper2D *CircleMapper;
00223   vtkActor2D          *CircleActor;
00224 
00225   vtkPoints           *HCirclePoints;
00226   vtkCellArray        *HCircleCellArray;
00227   vtkPolyData         *HCircle;
00228   vtkPolyDataMapper2D *HCircleMapper;
00229   vtkActor2D          *HCircleActor;
00230 
00231   // The translation axes
00232   vtkLeaderActor2D    *XAxis;
00233   vtkLeaderActor2D    *YAxis;
00234   vtkLeaderActor2D    *HXAxis;
00235   vtkLeaderActor2D    *HYAxis;
00236 
00237 private:
00238   vtkAffineRepresentation2D(const vtkAffineRepresentation2D&);  //Not implemented
00239   void operator=(const vtkAffineRepresentation2D&);  //Not implemented
00240 };
00241 
00242 #endif