VTK
dox/Charts/vtkChart.h
Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    vtkChart.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 
00029 #ifndef __vtkChart_h
00030 #define __vtkChart_h
00031 
00032 #include "vtkContextItem.h"
00033 #include "vtkRect.h"         // For vtkRectf
00034 #include "vtkStdString.h"    // For vtkStdString ivars
00035 #include "vtkSmartPointer.h" // For SP ivars
00036 
00037 class vtkTransform2D;
00038 class vtkContextScene;
00039 class vtkPlot;
00040 class vtkAxis;
00041 class vtkBrush;
00042 class vtkTextProperty;
00043 class vtkChartLegend;
00044 
00045 class vtkInteractorStyle;
00046 class vtkAnnotationLink;
00047 
00048 class VTK_CHARTS_EXPORT vtkChart : public vtkContextItem
00049 {
00050 public:
00051   vtkTypeMacro(vtkChart, vtkContextItem);
00052   virtual void PrintSelf(ostream &os, vtkIndent indent);
00053 
00054 //BTX
00056 
00057   enum {
00058     LINE,
00059     POINTS,
00060     BAR,
00061     STACKED};
00063 
00065 
00066   enum {
00067     PAN = 0,
00068     ZOOM,
00069     SELECT,
00070     NOTIFY
00071     };
00073 
00075 
00076   enum EventIds {
00077     UpdateRange = 1002
00078   };
00079 //ETX
00081 
00084   virtual bool Paint(vtkContext2D *painter) = 0;
00085 
00087   virtual vtkPlot* AddPlot(int type);
00088 
00091   virtual vtkIdType AddPlot(vtkPlot* plot);
00092 
00095   virtual bool RemovePlot(vtkIdType index);
00096 
00100   virtual bool RemovePlotInstance(vtkPlot* plot);
00101 
00103   virtual void ClearPlots();
00104 
00107   virtual vtkPlot* GetPlot(vtkIdType index);
00108 
00110   virtual vtkIdType GetNumberOfPlots();
00111 
00115   virtual vtkAxis* GetAxis(int axisIndex);
00116 
00118   virtual vtkIdType GetNumberOfAxes();
00119 
00123   virtual void RecalculateBounds();
00124 
00126   virtual void SetAnnotationLink(vtkAnnotationLink *link);
00127 
00129 
00130   vtkGetObjectMacro(AnnotationLink, vtkAnnotationLink);
00132 
00134 
00135   vtkSetVector2Macro(Geometry, int);
00136   vtkGetVector2Macro(Geometry, int);
00138 
00140 
00141   vtkSetVector2Macro(Point1, int);
00142   vtkGetVector2Macro(Point1, int);
00144 
00146 
00147   vtkSetVector2Macro(Point2, int);
00148   vtkGetVector2Macro(Point2, int);
00150 
00152 
00153   virtual void SetShowLegend(bool visible);
00154   virtual bool GetShowLegend();
00156 
00159   virtual vtkChartLegend * GetLegend();
00160 
00162 
00163   virtual void SetTitle(const vtkStdString &title);
00164   virtual vtkStdString GetTitle();
00166 
00168 
00170   vtkGetObjectMacro(TitleProperties, vtkTextProperty);
00172 
00174 
00175   void SetBottomBorder(int border);
00176   void SetTopBorder(int border);
00177   void SetLeftBorder(int border);
00178   void SetRightBorder(int border);
00180 
00182   void SetBorders(int left, int bottom, int right, int top);
00183 
00187   void SetSize(const vtkRectf &rect);
00188 
00190   vtkRectf GetSize();
00191 
00193 
00194   enum {
00195     FILL_SCENE,  // Attempt to fill the entire scene.
00196     FILL_RECT,   // Attempt to supply the supplied vtkRectf in Size.
00197     AXES_TO_RECT // Put the corners of the axes on the vtkRectf in Size.
00198   };
00200 
00202 
00205   vtkSetMacro(LayoutStrategy, int);
00206   vtkGetMacro(LayoutStrategy, int);
00208 
00210 
00212   virtual void SetAutoSize(bool isAutoSized)
00213   {
00214     this->LayoutStrategy = isAutoSized ? vtkChart::FILL_SCENE :
00215                                          vtkChart::FILL_RECT;
00216   }
00217   virtual bool GetAutoSize()
00218   {
00219     return this->LayoutStrategy == vtkChart::FILL_SCENE ? true : false;
00220   }
00222 
00224 
00229   vtkSetMacro(RenderEmpty, bool);
00230   vtkGetMacro(RenderEmpty, bool);
00232 
00240   virtual void SetActionToButton(int action, int button);
00241 
00245   virtual int GetActionToButton(int action);
00246 
00250   virtual void SetClickActionToButton(int action, int button);
00251 
00255   virtual int GetClickActionToButton(int action);
00256 
00258 
00259   void SetBackgroundBrush(vtkBrush *brush);
00260   vtkBrush* GetBackgroundBrush();
00262 
00264 
00268   virtual void SetSelectionMode(int);
00269   vtkGetMacro(SelectionMode, int);
00271 
00272 protected:
00273   vtkChart();
00274   ~vtkChart();
00275 
00277 
00281   bool CalculatePlotTransform(vtkAxis *x, vtkAxis *y,
00282                               vtkTransform2D *transform);
00284 
00287   void AttachAxisRangeListener(vtkAxis*);
00288 
00289   void AxisRangeForwarderCallback(vtkObject*,unsigned long, void*);
00290 
00292   vtkAnnotationLink *AnnotationLink;
00293 
00295   int Geometry[2];
00296 
00298   int Point1[2];
00299 
00301   int Point2[2];
00302 
00304   bool ShowLegend;
00305 
00307   vtkStdString Title;
00308 
00310   vtkTextProperty* TitleProperties;
00311 
00312   vtkRectf Size;
00313   // The layout strategy to employ when fitting the chart into the space.
00314   int LayoutStrategy;
00315   bool RenderEmpty;
00316 
00318   vtkSmartPointer<vtkBrush> BackgroundBrush;
00319 
00320   // The mode when the chart is doing selection.
00321   int SelectionMode;
00322 
00324 
00325   class MouseActions
00326     {
00327   public:
00328     MouseActions();
00329     short& Pan() { return Data[0]; }
00330     short& Zoom() { return Data[1]; }
00331     short& Select() { return Data[2]; }
00332     short& operator[](int index) { return Data[index]; }
00333     short Data[3];
00334     };
00335   class MouseClickActions
00336     {
00337   public:
00338     MouseClickActions();
00339     short& Notify() { return Data[0]; }
00340     short& Select() { return Data[1]; }
00341     short& operator[](int index) { return Data[index]; }
00342     short Data[2];
00343     };
00345 
00346   MouseActions Actions;
00347   MouseClickActions ActionsClick;
00348 
00349 private:
00350   vtkChart(const vtkChart &); // Not implemented.
00351   void operator=(const vtkChart &);   // Not implemented.
00352 };
00353 
00354 #endif //__vtkChart_h