VTK
/Users/kitware/Dashboards/MyTests/VTK_BLD_Release_docs/Utilities/Doxygen/dox/Charts/Core/vtkChartXY.h
Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    vtkChartXY.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 =========================================================================*/
00015 
00032 #ifndef vtkChartXY_h
00033 #define vtkChartXY_h
00034 
00035 #include "vtkChartsCoreModule.h" // For export macro
00036 #include "vtkChart.h"
00037 #include "vtkSmartPointer.h" // For SP ivars
00038 #include "vtkVector.h" // For vtkVector2f in struct
00039 #include "vtkContextPolygon.h" // For vtkContextPolygon
00040 
00041 class vtkPlot;
00042 class vtkAxis;
00043 class vtkPlotGrid;
00044 class vtkChartLegend;
00045 class vtkTooltipItem;
00046 class vtkChartXYPrivate; // Private class to keep my STL vector in...
00047 
00048 class VTKCHARTSCORE_EXPORT vtkChartXY : public vtkChart
00049 {
00050 public:
00051   vtkTypeMacro(vtkChartXY, vtkChart);
00052   virtual void PrintSelf(ostream &os, vtkIndent indent);
00053 
00055   static vtkChartXY *New();
00056 
00060   virtual void Update();
00061 
00064   virtual bool Paint(vtkContext2D *painter);
00065 
00067   virtual vtkPlot * AddPlot(int type);
00068 
00070   virtual vtkIdType AddPlot(vtkPlot* plot);
00071 
00074   virtual bool RemovePlot(vtkIdType index);
00075 
00077   virtual void ClearPlots();
00078 
00081   virtual vtkPlot* GetPlot(vtkIdType index);
00082 
00085   virtual vtkIdType GetPlotIndex(vtkPlot*);
00086 
00089   vtkIdType RaisePlot(vtkPlot* plot);
00090 
00094   virtual vtkIdType StackPlotAbove(vtkPlot* plot, vtkPlot* under);
00095 
00098   vtkIdType LowerPlot(vtkPlot* plot);
00099 
00103   virtual vtkIdType StackPlotUnder(vtkPlot* plot, vtkPlot* above);
00104 
00106   virtual vtkIdType GetNumberOfPlots();
00107 
00109   int GetPlotCorner(vtkPlot *plot);
00110 
00112   void SetPlotCorner(vtkPlot *plot, int corner);
00113 
00117   virtual vtkAxis* GetAxis(int axisIndex);
00118 
00120   virtual void SetShowLegend(bool visible);
00121 
00123   virtual vtkChartLegend* GetLegend();
00124 
00126   virtual void SetTooltip(vtkTooltipItem *tooltip);
00127 
00129   virtual vtkTooltipItem* GetTooltip();
00130 
00132   virtual vtkIdType GetNumberOfAxes();
00133 
00137   virtual void RecalculateBounds();
00138 
00144   virtual void SetSelectionMethod(int method);
00145 
00147 
00148   vtkSetMacro(DrawAxesAtOrigin, bool);
00149   vtkGetMacro(DrawAxesAtOrigin, bool);
00150   vtkBooleanMacro(DrawAxesAtOrigin, bool);
00152 
00154 
00156   vtkSetMacro(AutoAxes, bool);
00157   vtkGetMacro(AutoAxes, bool);
00158   vtkBooleanMacro(AutoAxes, bool);
00160 
00162 
00163   vtkSetMacro(HiddenAxisBorder, int);
00164   vtkGetMacro(HiddenAxisBorder, int);
00166 
00168 
00171   vtkSetMacro(ForceAxesToBounds, bool);
00172   vtkGetMacro(ForceAxesToBounds, bool);
00173   vtkBooleanMacro(ForceAxesToBounds, bool);
00175 
00177 
00183   vtkSetMacro(BarWidthFraction, float);
00184   vtkGetMacro(BarWidthFraction, float);
00186 
00188 
00189   virtual void SetTooltipInfo(const vtkContextMouseEvent &,
00190                               const vtkVector2d &,
00191                               vtkIdType, vtkPlot*,
00192                               vtkIdType segmentIndex = -1);
00194 
00195 //BTX
00197   virtual bool Hit(const vtkContextMouseEvent &mouse);
00198 
00200   virtual bool MouseEnterEvent(const vtkContextMouseEvent &mouse);
00201 
00203   virtual bool MouseMoveEvent(const vtkContextMouseEvent &mouse);
00204 
00206   virtual bool MouseLeaveEvent(const vtkContextMouseEvent &mouse);
00207 
00209   virtual bool MouseButtonPressEvent(const vtkContextMouseEvent &mouse);
00210 
00212   virtual bool MouseButtonReleaseEvent(const vtkContextMouseEvent &mouse);
00213 
00216   virtual bool MouseWheelEvent(const vtkContextMouseEvent &mouse, int delta);
00217 
00219 
00220   virtual bool KeyPressEvent(const vtkContextKeyEvent &key);
00221 //ETX
00223 
00224 //BTX
00225 protected:
00226   vtkChartXY();
00227   ~vtkChartXY();
00228 
00230   void RecalculatePlotTransforms();
00231 
00234   void RecalculatePlotBounds();
00235 
00239   virtual bool UpdateLayout(vtkContext2D* painter);
00240 
00244   virtual int GetLegendBorder(vtkContext2D* painter, int axisPosition);
00245 
00248   virtual void SetLegendPosition(const vtkRectf& rect);
00249 
00251   vtkSmartPointer<vtkChartLegend> Legend;
00252 
00255   vtkSmartPointer<vtkTooltipItem> Tooltip;
00256 
00258   bool PlotTransformValid;
00259 
00261   vtkRectf MouseBox;
00262 
00264   bool DrawBox;
00265 
00268   vtkContextPolygon SelectionPolygon;
00269 
00271   bool DrawSelectionPolygon;
00272 
00274   bool DrawNearestPoint;
00275 
00279   bool DrawAxesAtOrigin;
00280 
00282   bool AutoAxes;
00283 
00285   int HiddenAxisBorder;
00286 
00289   float BarWidthFraction;
00290 
00293   bool LayoutChanged;
00294 
00298   bool ForceAxesToBounds;
00299 
00300 private:
00301   vtkChartXY(const vtkChartXY &); // Not implemented.
00302   void operator=(const vtkChartXY &);   // Not implemented.
00303 
00304   vtkChartXYPrivate *ChartPrivate; // Private class where I hide my STL containers
00305 
00308   void CalculateBarPlots();
00309 
00311 
00314   bool LocatePointInPlots(const vtkContextMouseEvent &mouse,
00315                           int invokeEvent = -1);
00317 
00318   int LocatePointInPlot(const vtkVector2f &position,
00319                         const vtkVector2f &tolerance, vtkVector2f &plotPos,
00320                         vtkPlot *plot, vtkIdType &segmentIndex);
00321 
00323   bool RemovePlotFromCorners(vtkPlot *plot);
00324 
00325   void ZoomInAxes(vtkAxis *x, vtkAxis *y, float *orign, float *max);
00326 
00328 
00329   void TransformBoxOrPolygon(bool polygonMode, vtkTransform2D *transform,
00330                              const vtkVector2f &mousePosition,
00331                              vtkVector2f &min, vtkVector2f &max,
00332                              vtkContextPolygon &polygon);
00334 
00335 //ETX
00336 };
00337 
00339 
00342 struct vtkChartPlotData
00343 {
00344   vtkStdString SeriesName;
00345   vtkVector2f Position;
00346   vtkVector2i ScreenPosition;
00347   int Index;
00348 };
00350 
00351 #endif //vtkChartXY_h