VTK
dox/Widgets/vtkBiDimensionalRepresentation2D.h
Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    vtkBiDimensionalRepresentation2D.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 =========================================================================*/
00043 #ifndef __vtkBiDimensionalRepresentation2D_h
00044 #define __vtkBiDimensionalRepresentation2D_h
00045 
00046 #include "vtkBiDimensionalRepresentation.h"
00047 
00048 class vtkHandleRepresentation;
00049 class vtkCellArray;
00050 class vtkPoints;
00051 class vtkPolyData;
00052 class vtkPolyDataMapper2D;
00053 class vtkTextMapper;
00054 class vtkActor2D;
00055 class vtkProperty2D;
00056 class vtkTextProperty;
00057 
00058 
00059 class VTK_WIDGETS_EXPORT vtkBiDimensionalRepresentation2D : public vtkBiDimensionalRepresentation
00060 {
00061 public:
00063   static vtkBiDimensionalRepresentation2D *New();
00064 
00066 
00067   vtkTypeMacro(vtkBiDimensionalRepresentation2D,vtkBiDimensionalRepresentation);
00068   void PrintSelf(ostream& os, vtkIndent indent);
00070 
00072 
00074   vtkGetObjectMacro(LineProperty,vtkProperty2D);
00075   vtkGetObjectMacro(SelectedLineProperty,vtkProperty2D);
00077 
00079 
00081   vtkGetObjectMacro(TextProperty,vtkTextProperty);
00083 
00084 //BTX -- used to communicate about the state of the representation
00085   enum {Outside=0,NearP1,NearP2,NearP3,NearP4,OnL1Inner,OnL1Outer,OnL2Inner,OnL2Outer,OnCenter};
00086 //ETX
00087 
00089 
00090   virtual void BuildRepresentation();
00091   virtual int ComputeInteractionState(int X, int Y, int modify=0);
00092   virtual void StartWidgetDefinition(double e[2]);
00093   virtual void Point2WidgetInteraction(double e[2]);
00094   virtual void Point3WidgetInteraction(double e[2]);
00095   virtual void StartWidgetManipulation(double e[2]);
00096   virtual void WidgetInteraction(double e[2]);
00097   virtual void Highlight(int highlightOn);
00099 
00101 
00102   virtual void ReleaseGraphicsResources(vtkWindow *w);
00103   virtual int RenderOverlay(vtkViewport *viewport);
00105 
00107   char* GetLabelText();
00108 
00110 
00111   double* GetLabelPosition();
00112   void GetLabelPosition(double pos[3]);
00113   void GetWorldLabelPosition(double pos[3]);
00115 
00116 protected:
00117   vtkBiDimensionalRepresentation2D();
00118   ~vtkBiDimensionalRepresentation2D();
00119 
00120   // Keep track if modifier is set
00121   int Modifier;
00122 
00123   // Geometry of the lines
00124   vtkCellArray        *LineCells;
00125   vtkPoints           *LinePoints;
00126   vtkPolyData         *LinePolyData;
00127   vtkPolyDataMapper2D *LineMapper;
00128   vtkActor2D          *LineActor;
00129   vtkProperty2D       *LineProperty;
00130   vtkProperty2D       *SelectedLineProperty;
00131 
00132   // The labels for the line lengths
00133   vtkTextProperty *TextProperty;
00134   vtkTextMapper   *TextMapper;
00135   vtkActor2D      *TextActor;
00136 
00137   // Internal variables
00138   double P1World[3];
00139   double P2World[3];
00140   double P3World[3];
00141   double P4World[3];
00142   double P21World[3];
00143   double P43World[3];
00144   double T21;
00145   double T43;
00146   double CenterWorld[3];
00147   double StartEventPositionWorld[4];
00148 
00149   // Helper method
00150   void ProjectOrthogonalPoint(double x[4], double y[3], double x1[3], double x2[3], double x21[3], 
00151                               double dir, double xP[3]);
00152 
00153 private:
00154   vtkBiDimensionalRepresentation2D(const vtkBiDimensionalRepresentation2D&);  //Not implemented
00155   void operator=(const vtkBiDimensionalRepresentation2D&);  //Not implemented
00156 };
00157 
00158 #endif