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