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 
00092   virtual void SetShowBorder(int border);
00093   virtual int GetShowBorderMinValue();
00094   virtual int GetShowBorderMaxValue();
00095   virtual int GetShowBorder();
00096   void SetShowBorderToOff() {this->SetShowBorder(BORDER_OFF);}
00097   void SetShowBorderToOn() {this->SetShowBorder(BORDER_ON);}
00098   void SetShowBorderToActive() {this->SetShowBorder(BORDER_ACTIVE);}
00100 
00102 
00104   vtkSetClampMacro(ShowVerticalBorder,int,BORDER_OFF,BORDER_ACTIVE);
00105   vtkGetMacro(ShowVerticalBorder,int);
00107 
00109 
00111   vtkSetClampMacro(ShowHorizontalBorder,int,BORDER_OFF,BORDER_ACTIVE);
00112   vtkGetMacro(ShowHorizontalBorder,int);
00114 
00116 
00117   vtkGetObjectMacro(BorderProperty,vtkProperty2D);
00119 
00121 
00126   vtkSetMacro(ProportionalResize,int);
00127   vtkGetMacro(ProportionalResize,int);
00128   vtkBooleanMacro(ProportionalResize,int);
00130 
00132 
00135   vtkSetVector2Macro(MinimumSize,int);
00136   vtkGetVector2Macro(MinimumSize,int);
00137   vtkSetVector2Macro(MaximumSize,int);
00138   vtkGetVector2Macro(MaximumSize,int);
00140 
00142 
00145   vtkSetClampMacro(Tolerance,int,1,10);
00146   vtkGetMacro(Tolerance,int);
00148 
00150 
00152   vtkGetVectorMacro(SelectionPoint,double,2);
00154 
00156 
00159   vtkSetMacro(Moving,int);
00160   vtkGetMacro(Moving,int);
00161   vtkBooleanMacro(Moving,int);
00163 
00164 //BTX
00166 
00167   enum _InteractionState
00168   {
00169     Outside=0,
00170     Inside,
00171     AdjustingP0,
00172     AdjustingP1,
00173     AdjustingP2,
00174     AdjustingP3,
00175     AdjustingE0,
00176     AdjustingE1,
00177     AdjustingE2,
00178     AdjustingE3
00179   };
00180 //ETX
00182 
00184 
00186   virtual void BuildRepresentation();
00187   virtual void StartWidgetInteraction(double eventPos[2]);
00188   virtual void WidgetInteraction(double eventPos[2]);
00189   virtual void GetSize(double size[2])
00190     {size[0]=1.0; size[1]=1.0;}
00191   virtual int ComputeInteractionState(int X, int Y, int modify=0);
00193 
00195 
00197   virtual void GetActors2D(vtkPropCollection*);
00198   virtual void ReleaseGraphicsResources(vtkWindow*);
00199   virtual int RenderOverlay(vtkViewport*);
00200   virtual int RenderOpaqueGeometry(vtkViewport*);
00201   virtual int RenderTranslucentPolygonalGeometry(vtkViewport*);
00202   virtual int HasTranslucentPolygonalGeometry();
00204 
00205 protected:
00206   vtkBorderRepresentation();
00207   ~vtkBorderRepresentation();
00208 
00209   // Ivars
00210   int           ShowVerticalBorder;
00211   int           ShowHorizontalBorder;
00212   vtkProperty2D *BorderProperty;
00213   int           ProportionalResize;
00214   int           Tolerance;
00215   int           Moving;
00216   double        SelectionPoint[2];
00217 
00218   // Layout (position of lower left and upper right corners of border)
00219   vtkCoordinate *PositionCoordinate;
00220   vtkCoordinate *Position2Coordinate;
00221 
00222   // Sometimes subclasses must negotiate with their superclasses
00223   // to achieve the correct layout.
00224   int Negotiated;
00225   virtual void NegotiateLayout();
00226 
00227   // Update the border visibility based on InteractionState.
00228   // See Also: SetShowHorizontalBorder(), SetShowHorizontalBorder(),
00229   // ComputeInteractionState()
00230   virtual void UpdateShowBorder();
00231 
00232   // Keep track of start position when moving border
00233   double StartPosition[2];
00234 
00235   // Border representation. Subclasses may use the BWTransform class
00236   // to transform their geometry into the region surrounded by the border.
00237   vtkPoints                  *BWPoints;
00238   vtkPolyData                *BWPolyData;
00239   vtkTransform               *BWTransform;
00240   vtkTransformPolyDataFilter *BWTransformFilter;
00241   vtkPolyDataMapper2D        *BWMapper;
00242   vtkActor2D                 *BWActor;
00243 
00244   // Constraints on size
00245   int MinimumSize[2];
00246   int MaximumSize[2];
00247 
00248 private:
00249   vtkBorderRepresentation(const vtkBorderRepresentation&);  //Not implemented
00250   void operator=(const vtkBorderRepresentation&);  //Not implemented
00251 };
00252 
00253 #endif