VTK
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 
00084   virtual vtkIdType GetNumberOfPlots();
00085 
00087   int GetPlotCorner(vtkPlot *plot);
00088 
00090   void SetPlotCorner(vtkPlot *plot, int corner);
00091 
00095   virtual vtkAxis* GetAxis(int axisIndex);
00096 
00098   virtual void SetShowLegend(bool visible);
00099 
00101   virtual vtkChartLegend* GetLegend();
00102 
00104   virtual void SetTooltip(vtkTooltipItem *tooltip);
00105 
00107   virtual vtkTooltipItem* GetTooltip();
00108 
00110   virtual vtkIdType GetNumberOfAxes();
00111 
00115   virtual void RecalculateBounds();
00116 
00122   virtual void SetSelectionMethod(int method);
00123 
00125 
00126   vtkSetMacro(DrawAxesAtOrigin, bool);
00127   vtkGetMacro(DrawAxesAtOrigin, bool);
00128   vtkBooleanMacro(DrawAxesAtOrigin, bool);
00130 
00132 
00134   vtkSetMacro(AutoAxes, bool);
00135   vtkGetMacro(AutoAxes, bool);
00136   vtkBooleanMacro(AutoAxes, bool);
00138 
00140 
00141   vtkSetMacro(HiddenAxisBorder, int);
00142   vtkGetMacro(HiddenAxisBorder, int);
00144 
00146 
00149   vtkSetMacro(ForceAxesToBounds, bool);
00150   vtkGetMacro(ForceAxesToBounds, bool);
00151   vtkBooleanMacro(ForceAxesToBounds, bool);
00153 
00155 
00161   vtkSetMacro(BarWidthFraction, float);
00162   vtkGetMacro(BarWidthFraction, float);
00164 
00166 
00167   virtual void SetTooltipInfo(const vtkContextMouseEvent &,
00168                               const vtkVector2d &,
00169                               vtkIdType, vtkPlot*,
00170                               vtkIdType segmentIndex = -1);
00172 
00173 //BTX
00175   virtual bool Hit(const vtkContextMouseEvent &mouse);
00176 
00178   virtual bool MouseEnterEvent(const vtkContextMouseEvent &mouse);
00179 
00181   virtual bool MouseMoveEvent(const vtkContextMouseEvent &mouse);
00182 
00184   virtual bool MouseLeaveEvent(const vtkContextMouseEvent &mouse);
00185 
00187   virtual bool MouseButtonPressEvent(const vtkContextMouseEvent &mouse);
00188 
00190   virtual bool MouseButtonReleaseEvent(const vtkContextMouseEvent &mouse);
00191 
00194   virtual bool MouseWheelEvent(const vtkContextMouseEvent &mouse, int delta);
00195 
00197 
00198   virtual bool KeyPressEvent(const vtkContextKeyEvent &key);
00199 //ETX
00201 
00202 //BTX
00203 protected:
00204   vtkChartXY();
00205   ~vtkChartXY();
00206 
00208   void RecalculatePlotTransforms();
00209 
00212   void RecalculatePlotBounds();
00213 
00217   virtual bool UpdateLayout(vtkContext2D* painter);
00218 
00222   virtual int GetLegendBorder(vtkContext2D* painter, int axisPosition);
00223 
00226   virtual void SetLegendPosition(const vtkRectf& rect);
00227 
00229   vtkSmartPointer<vtkChartLegend> Legend;
00230 
00233   vtkSmartPointer<vtkTooltipItem> Tooltip;
00234 
00236   bool PlotTransformValid;
00237 
00239   vtkRectf MouseBox;
00240 
00242   bool DrawBox;
00243 
00246   vtkContextPolygon SelectionPolygon;
00247 
00249   bool DrawSelectionPolygon;
00250 
00252   bool DrawNearestPoint;
00253 
00257   bool DrawAxesAtOrigin;
00258 
00260   bool AutoAxes;
00261 
00263   int HiddenAxisBorder;
00264 
00267   float BarWidthFraction;
00268 
00271   bool LayoutChanged;
00272 
00276   bool ForceAxesToBounds;
00277 
00278 private:
00279   vtkChartXY(const vtkChartXY &); // Not implemented.
00280   void operator=(const vtkChartXY &);   // Not implemented.
00281 
00282   vtkChartXYPrivate *ChartPrivate; // Private class where I hide my STL containers
00283 
00286   void CalculateBarPlots();
00287 
00289 
00292   bool LocatePointInPlots(const vtkContextMouseEvent &mouse,
00293                           int invokeEvent = -1);
00295 
00296   int LocatePointInPlot(const vtkVector2f &position,
00297                         const vtkVector2f &tolerance, vtkVector2f &plotPos,
00298                         vtkPlot *plot, vtkIdType &segmentIndex);
00299 
00301   bool RemovePlotFromCorners(vtkPlot *plot);
00302 
00303   void ZoomInAxes(vtkAxis *x, vtkAxis *y, float *orign, float *max);
00304 
00306 
00307   void TransformBoxOrPolygon(bool polygonMode, vtkTransform2D *transform,
00308                              const vtkVector2f &mousePosition,
00309                              vtkVector2f &min, vtkVector2f &max,
00310                              vtkContextPolygon &polygon);
00312 
00313 //ETX
00314 };
00315 
00317 
00320 struct vtkChartPlotData
00321 {
00322   vtkStdString SeriesName;
00323   vtkVector2f Position;
00324   vtkVector2i ScreenPosition;
00325   int Index;
00326 };
00328 
00329 #endif //__vtkChartXY_h