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 
00181 
00183   virtual bool MouseWheelEvent(const vtkContextMouseEvent &mouse, int delta);
00184 //ETX
00186 
00187 //BTX
00188 protected:
00189   vtkChartXY();
00190   ~vtkChartXY();
00191 
00193   void RecalculatePlotTransforms();
00194 
00197   void RecalculatePlotBounds();
00198 
00202   virtual bool UpdateLayout(vtkContext2D* painter);
00203 
00207   virtual int GetLegendBorder(vtkContext2D* painter, int axisPosition);
00208 
00211   virtual void SetLegendPosition(const vtkRectf& rect);
00212 
00214   vtkSmartPointer<vtkChartLegend> Legend;
00215 
00218   vtkSmartPointer<vtkTooltipItem> Tooltip;
00219 
00221   bool PlotTransformValid;
00222 
00224   vtkRectf MouseBox;
00225 
00227   bool DrawBox;
00228 
00230   bool DrawNearestPoint;
00231 
00235   bool DrawAxesAtOrigin;
00236 
00238   bool AutoAxes;
00239 
00241   int HiddenAxisBorder;
00242 
00245   float BarWidthFraction;
00246 
00249   bool LayoutChanged;
00250 
00254   bool ForceAxesToBounds;
00255 
00256 private:
00257   vtkChartXY(const vtkChartXY &); // Not implemented.
00258   void operator=(const vtkChartXY &);   // Not implemented.
00259 
00260   vtkChartXYPrivate *ChartPrivate; // Private class where I hide my STL containers
00261 
00264   void CalculateBarPlots();
00265 
00267 
00270   bool LocatePointInPlots(const vtkContextMouseEvent &mouse,
00271                           int invokeEvent = -1);
00273 
00275   bool RemovePlotFromCorners(vtkPlot *plot);
00276 
00277   void ZoomInAxes(vtkAxis *x, vtkAxis *y, float *orign, float *max);
00278 
00279 //ETX
00280 };
00281 
00283 
00286 struct vtkChartPlotData
00287 {
00288   vtkStdString SeriesName;
00289   vtkVector2f Position;
00290   vtkVector2i ScreenPosition;
00291   int Index;
00292 };
00294 
00295 #endif //__vtkChartXY_h