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