VTK
dox/Interaction/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 "vtkInteractionWidgetsModule.h" // For export macro
00047 #include "vtkBiDimensionalRepresentation.h"
00048 
00049 class vtkHandleRepresentation;
00050 class vtkCellArray;
00051 class vtkPoints;
00052 class vtkPolyData;
00053 class vtkPolyDataMapper2D;
00054 class vtkTextMapper;
00055 class vtkActor2D;
00056 class vtkProperty2D;
00057 class vtkTextProperty;
00058 
00059 
00060 class VTKINTERACTIONWIDGETS_EXPORT vtkBiDimensionalRepresentation2D : public vtkBiDimensionalRepresentation
00061 {
00062 public:
00064   static vtkBiDimensionalRepresentation2D *New();
00065 
00067 
00068   vtkTypeMacro(vtkBiDimensionalRepresentation2D,vtkBiDimensionalRepresentation);
00069   void PrintSelf(ostream& os, vtkIndent indent);
00071 
00073 
00075   vtkGetObjectMacro(LineProperty,vtkProperty2D);
00076   vtkGetObjectMacro(SelectedLineProperty,vtkProperty2D);
00078 
00080 
00082   vtkGetObjectMacro(TextProperty,vtkTextProperty);
00084 
00085 //BTX -- used to communicate about the state of the representation
00086   enum {Outside=0,NearP1,NearP2,NearP3,NearP4,OnL1Inner,OnL1Outer,OnL2Inner,OnL2Outer,OnCenter};
00087 //ETX
00088 
00090 
00091   virtual void BuildRepresentation();
00092   virtual int ComputeInteractionState(int X, int Y, int modify=0);
00093   virtual void StartWidgetDefinition(double e[2]);
00094   virtual void Point2WidgetInteraction(double e[2]);
00095   virtual void Point3WidgetInteraction(double e[2]);
00096   virtual void StartWidgetManipulation(double e[2]);
00097   virtual void WidgetInteraction(double e[2]);
00098   virtual void Highlight(int highlightOn);
00100 
00102 
00103   virtual void ReleaseGraphicsResources(vtkWindow *w);
00104   virtual int RenderOverlay(vtkViewport *viewport);
00106 
00108   char* GetLabelText();
00109 
00111 
00112   double* GetLabelPosition();
00113   void GetLabelPosition(double pos[3]);
00114   void GetWorldLabelPosition(double pos[3]);
00116 
00117 protected:
00118   vtkBiDimensionalRepresentation2D();
00119   ~vtkBiDimensionalRepresentation2D();
00120 
00121   // Keep track if modifier is set
00122   int Modifier;
00123 
00124   // Geometry of the lines
00125   vtkCellArray        *LineCells;
00126   vtkPoints           *LinePoints;
00127   vtkPolyData         *LinePolyData;
00128   vtkPolyDataMapper2D *LineMapper;
00129   vtkActor2D          *LineActor;
00130   vtkProperty2D       *LineProperty;
00131   vtkProperty2D       *SelectedLineProperty;
00132 
00133   // The labels for the line lengths
00134   vtkTextProperty *TextProperty;
00135   vtkTextMapper   *TextMapper;
00136   vtkActor2D      *TextActor;
00137 
00138   // Internal variables
00139   double P1World[3];
00140   double P2World[3];
00141   double P3World[3];
00142   double P4World[3];
00143   double P21World[3];
00144   double P43World[3];
00145   double T21;
00146   double T43;
00147   double CenterWorld[3];
00148   double StartEventPositionWorld[4];
00149 
00150   // Helper method
00151   void ProjectOrthogonalPoint(double x[4], double y[3], double x1[3], double x2[3], double x21[3],
00152                               double dir, double xP[3]);
00153 
00154 private:
00155   vtkBiDimensionalRepresentation2D(const vtkBiDimensionalRepresentation2D&);  //Not implemented
00156   void operator=(const vtkBiDimensionalRepresentation2D&);  //Not implemented
00157 };
00158 
00159 #endif