VTK
dox/Charts/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 "vtkChart.h"
00036 #include "vtkSmartPointer.h" // For SP ivars
00037 #include "vtkVector.h" // For vtkVector2f in struct
00038 
00039 class vtkPlot;
00040 class vtkAxis;
00041 class vtkPlotGrid;
00042 class vtkChartLegend;
00043 class vtkTooltipItem;
00044 class vtkChartXYPrivate; // Private class to keep my STL vector in...
00045 
00046 class VTK_CHARTS_EXPORT vtkChartXY : public vtkChart
00047 {
00048 public:
00049   vtkTypeMacro(vtkChartXY, vtkChart);
00050   virtual void PrintSelf(ostream &os, vtkIndent indent);
00051 
00053   static vtkChartXY *New();
00054 
00058   virtual void Update();
00059 
00062   virtual bool Paint(vtkContext2D *painter);
00063 
00065   virtual vtkPlot * AddPlot(int type);
00066 
00068   virtual vtkIdType AddPlot(vtkPlot* plot);
00069 
00072   virtual bool RemovePlot(vtkIdType index);
00073 
00075   virtual void ClearPlots();
00076 
00079   virtual vtkPlot* GetPlot(vtkIdType index);
00080 
00082   virtual vtkIdType GetNumberOfPlots();
00083 
00085   int GetPlotCorner(vtkPlot *plot);
00086 
00088   void SetPlotCorner(vtkPlot *plot, int corner);
00089 
00093   virtual vtkAxis* GetAxis(int axisIndex);
00094 
00096   virtual void SetShowLegend(bool visible);
00097 
00099   virtual vtkChartLegend* GetLegend();
00100 
00102   virtual vtkTooltipItem* GetTooltip();
00103 
00105   virtual vtkIdType GetNumberOfAxes();
00106 
00110   virtual void RecalculateBounds();
00111 
00113 
00114   vtkSetMacro(DrawAxesAtOrigin, bool);
00115   vtkGetMacro(DrawAxesAtOrigin, bool);
00116   vtkBooleanMacro(DrawAxesAtOrigin, bool);
00118 
00120 
00122   vtkSetMacro(AutoAxes, bool);
00123   vtkGetMacro(AutoAxes, bool);
00124   vtkBooleanMacro(AutoAxes, bool);
00126 
00128 
00129   vtkSetMacro(HiddenAxisBorder, int);
00130   vtkGetMacro(HiddenAxisBorder, int);
00132 
00134 
00137   vtkSetMacro(ForceAxesToBounds, bool);
00138   vtkGetMacro(ForceAxesToBounds, bool);
00139   vtkBooleanMacro(ForceAxesToBounds, bool);
00141 
00143 
00149   vtkSetMacro(BarWidthFraction, float);
00150   vtkGetMacro(BarWidthFraction, float);
00152 
00154 
00155   virtual void SetTooltipInfo(const vtkContextMouseEvent &,
00156                               const vtkVector2f &,
00157                               vtkIdType, vtkPlot*,
00158                               vtkIdType segmentIndex = -1);
00160 
00161 //BTX
00163   virtual bool Hit(const vtkContextMouseEvent &mouse);
00164 
00166   virtual bool MouseEnterEvent(const vtkContextMouseEvent &mouse);
00167 
00169   virtual bool MouseMoveEvent(const vtkContextMouseEvent &mouse);
00170 
00172   virtual bool MouseLeaveEvent(const vtkContextMouseEvent &mouse);
00173 
00175   virtual bool MouseButtonPressEvent(const vtkContextMouseEvent &mouse);
00176 
00178   virtual bool MouseButtonReleaseEvent(const vtkContextMouseEvent &mouse);
00179 
00182   virtual bool MouseWheelEvent(const vtkContextMouseEvent &mouse, int delta);
00183 
00185 
00186   virtual bool KeyPressEvent(const vtkContextKeyEvent &key);
00187 //ETX
00189 
00190 //BTX
00191 protected:
00192   vtkChartXY();
00193   ~vtkChartXY();
00194 
00196   void RecalculatePlotTransforms();
00197 
00200   void RecalculatePlotBounds();
00201 
00205   virtual bool UpdateLayout(vtkContext2D* painter);
00206 
00210   virtual int GetLegendBorder(vtkContext2D* painter, int axisPosition);
00211 
00214   virtual void SetLegendPosition(const vtkRectf& rect);
00215 
00217   vtkSmartPointer<vtkChartLegend> Legend;
00218 
00221   vtkSmartPointer<vtkTooltipItem> Tooltip;
00222 
00224   bool PlotTransformValid;
00225 
00227   vtkRectf MouseBox;
00228 
00230   bool DrawBox;
00231 
00233   bool DrawNearestPoint;
00234 
00238   bool DrawAxesAtOrigin;
00239 
00241   bool AutoAxes;
00242 
00244   int HiddenAxisBorder;
00245 
00248   float BarWidthFraction;
00249 
00252   bool LayoutChanged;
00253 
00257   bool ForceAxesToBounds;
00258 
00259 private:
00260   vtkChartXY(const vtkChartXY &); // Not implemented.
00261   void operator=(const vtkChartXY &);   // Not implemented.
00262 
00263   vtkChartXYPrivate *ChartPrivate; // Private class where I hide my STL containers
00264 
00267   void CalculateBarPlots();
00268 
00270 
00273   bool LocatePointInPlots(const vtkContextMouseEvent &mouse,
00274                           int invokeEvent = -1);
00276 
00278   bool RemovePlotFromCorners(vtkPlot *plot);
00279 
00280   void ZoomInAxes(vtkAxis *x, vtkAxis *y, float *orign, float *max);
00281 
00282 //ETX
00283 };
00284 
00286 
00289 struct vtkChartPlotData
00290 {
00291   vtkStdString SeriesName;
00292   vtkVector2f Position;
00293   vtkVector2i ScreenPosition;
00294   int Index;
00295 };
00297 
00298 #endif //__vtkChartXY_h