VTK
dox/Interaction/Widgets/vtkBorderRepresentation.h
Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    vtkBorderRepresentation.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 =========================================================================*/
00041 #ifndef __vtkBorderRepresentation_h
00042 #define __vtkBorderRepresentation_h
00043 
00044 #include "vtkInteractionWidgetsModule.h" // For export macro
00045 #include "vtkWidgetRepresentation.h"
00046 #include "vtkCoordinate.h" //Because of the viewport coordinate macro
00047 
00048 class vtkPoints;
00049 class vtkPolyData;
00050 class vtkTransform;
00051 class vtkTransformPolyDataFilter;
00052 class vtkPolyDataMapper2D;
00053 class vtkActor2D;
00054 class vtkProperty2D;
00055 
00056 
00057 class VTKINTERACTIONWIDGETS_EXPORT vtkBorderRepresentation : public vtkWidgetRepresentation
00058 {
00059 public:
00061   static vtkBorderRepresentation *New();
00062 
00064 
00065   vtkTypeMacro(vtkBorderRepresentation,vtkWidgetRepresentation);
00066   void PrintSelf(ostream& os, vtkIndent indent);
00068 
00070 
00077   vtkViewportCoordinateMacro(Position);
00078   vtkViewportCoordinateMacro(Position2);
00080 
00081 //BTX
00082   enum {BORDER_OFF=0,BORDER_ON,BORDER_ACTIVE};
00083 //ETX
00085 
00090   vtkSetClampMacro(ShowBorder,int,BORDER_OFF,BORDER_ACTIVE);
00091   vtkGetMacro(ShowBorder,int);
00092   void SetShowBorderToOff() {this->SetShowBorder(BORDER_OFF);}
00093   void SetShowBorderToOn() {this->SetShowBorder(BORDER_ON);}
00094   void SetShowBorderToActive() {this->SetShowBorder(BORDER_ACTIVE);}
00096 
00098 
00099   vtkGetObjectMacro(BorderProperty,vtkProperty2D);
00101 
00103 
00108   vtkSetMacro(ProportionalResize,int);
00109   vtkGetMacro(ProportionalResize,int);
00110   vtkBooleanMacro(ProportionalResize,int);
00112 
00114 
00117   vtkSetVector2Macro(MinimumSize,int);
00118   vtkGetVector2Macro(MinimumSize,int);
00119   vtkSetVector2Macro(MaximumSize,int);
00120   vtkGetVector2Macro(MaximumSize,int);
00122 
00124 
00127   vtkSetClampMacro(Tolerance,int,1,10);
00128   vtkGetMacro(Tolerance,int);
00130 
00132 
00134   vtkGetVectorMacro(SelectionPoint,double,2);
00136 
00138 
00141   vtkSetMacro(Moving,int);
00142   vtkGetMacro(Moving,int);
00143   vtkBooleanMacro(Moving,int);
00145 
00146 //BTX
00148 
00149   enum _InteractionState
00150   {
00151     Outside=0,
00152     Inside,
00153     AdjustingP0,
00154     AdjustingP1,
00155     AdjustingP2,
00156     AdjustingP3,
00157     AdjustingE0,
00158     AdjustingE1,
00159     AdjustingE2,
00160     AdjustingE3
00161   };
00162 //ETX
00164 
00166 
00168   virtual void BuildRepresentation();
00169   virtual void StartWidgetInteraction(double eventPos[2]);
00170   virtual void WidgetInteraction(double eventPos[2]);
00171   virtual void GetSize(double size[2])
00172     {size[0]=1.0; size[1]=1.0;}
00173   virtual int ComputeInteractionState(int X, int Y, int modify=0);
00175 
00177 
00179   virtual void GetActors2D(vtkPropCollection*);
00180   virtual void ReleaseGraphicsResources(vtkWindow*);
00181   virtual int RenderOverlay(vtkViewport*);
00182   virtual int RenderOpaqueGeometry(vtkViewport*);
00183   virtual int RenderTranslucentPolygonalGeometry(vtkViewport*);
00184   virtual int HasTranslucentPolygonalGeometry();
00186 
00187 protected:
00188   vtkBorderRepresentation();
00189   ~vtkBorderRepresentation();
00190 
00191   // Ivars
00192   int           ShowBorder;
00193   vtkProperty2D *BorderProperty;
00194   int           ProportionalResize;
00195   int           Tolerance;
00196   int           Moving;
00197   double        SelectionPoint[2];
00198 
00199   // Layout (position of lower left and upper right corners of border)
00200   vtkCoordinate *PositionCoordinate;
00201   vtkCoordinate *Position2Coordinate;
00202 
00203   // Sometimes subclasses must negotiate with their superclasses
00204   // to achieve the correct layout.
00205   int Negotiated;
00206   virtual void NegotiateLayout();
00207 
00208   // Keep track of start position when moving border
00209   double StartPosition[2];
00210 
00211   // Border representation. Subclasses may use the BWTransform class
00212   // to transform their geometry into the region surrounded by the border.
00213   vtkPoints                  *BWPoints;
00214   vtkPolyData                *BWPolyData;
00215   vtkTransform               *BWTransform;
00216   vtkTransformPolyDataFilter *BWTransformFilter;
00217   vtkPolyDataMapper2D        *BWMapper;
00218   vtkActor2D                 *BWActor;
00219 
00220   // Constraints on size
00221   int MinimumSize[2];
00222   int MaximumSize[2];
00223 
00224 private:
00225   vtkBorderRepresentation(const vtkBorderRepresentation&);  //Not implemented
00226   void operator=(const vtkBorderRepresentation&);  //Not implemented
00227 };
00228 
00229 #endif