VTK
/Users/kitware/Dashboards/MyTests/VTK_BLD_Release_docs/Utilities/Doxygen/dox/Charts/Core/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 "vtkChartsCoreModule.h" // For export macro
00033 #include "vtkContextItem.h"
00034 #include "vtkRect.h"         // For vtkRectf
00035 #include "vtkStdString.h"    // For vtkStdString ivars
00036 #include "vtkSmartPointer.h" // For SP ivars
00037 
00038 class vtkTransform2D;
00039 class vtkContextScene;
00040 class vtkPlot;
00041 class vtkAxis;
00042 class vtkBrush;
00043 class vtkTextProperty;
00044 class vtkChartLegend;
00045 
00046 class vtkInteractorStyle;
00047 class vtkAnnotationLink;
00048 
00049 class VTKCHARTSCORE_EXPORT vtkChart : public vtkContextItem
00050 {
00051 public:
00052   vtkTypeMacro(vtkChart, vtkContextItem);
00053   virtual void PrintSelf(ostream &os, vtkIndent indent);
00054 
00055 //BTX
00057 
00058   enum {
00059     LINE,
00060     POINTS,
00061     BAR,
00062     STACKED,
00063     BAG,
00064     FUNCTIONALBAG};
00066 
00068 
00074   enum {
00075     PAN = 0,
00076     ZOOM,
00077     ZOOM_AXIS,
00078     SELECT,
00079     SELECT_RECTANGLE = SELECT,
00080     SELECT_POLYGON,
00081     NOTIFY
00082     };
00084 
00086 
00087   enum EventIds {
00088     UpdateRange = 1002
00089   };
00090 //ETX
00092 
00095   virtual bool Paint(vtkContext2D *painter) = 0;
00096 
00098   virtual vtkPlot* AddPlot(int type);
00099 
00102   virtual vtkIdType AddPlot(vtkPlot* plot);
00103 
00106   virtual bool RemovePlot(vtkIdType index);
00107 
00111   virtual bool RemovePlotInstance(vtkPlot* plot);
00112 
00114   virtual void ClearPlots();
00115 
00118   virtual vtkPlot* GetPlot(vtkIdType index);
00119 
00121   virtual vtkIdType GetNumberOfPlots();
00122 
00126   virtual vtkAxis* GetAxis(int axisIndex);
00127 
00129   virtual vtkIdType GetNumberOfAxes();
00130 
00134   virtual void RecalculateBounds();
00135 
00137 
00143   enum {
00144     SELECTION_ROWS,
00145     SELECTION_PLOTS,
00146     SELECTION_COLUMNS
00147   };
00149 
00151 
00157   virtual void SetSelectionMethod(int method);
00158   virtual int GetSelectionMethod();
00160 
00162   virtual void SetAnnotationLink(vtkAnnotationLink *link);
00163 
00165 
00166   vtkGetObjectMacro(AnnotationLink, vtkAnnotationLink);
00168 
00170 
00171   vtkSetVector2Macro(Geometry, int);
00172   vtkGetVector2Macro(Geometry, int);
00174 
00176 
00177   vtkSetVector2Macro(Point1, int);
00178   vtkGetVector2Macro(Point1, int);
00180 
00182 
00183   vtkSetVector2Macro(Point2, int);
00184   vtkGetVector2Macro(Point2, int);
00186 
00188 
00189   virtual void SetShowLegend(bool visible);
00190   virtual bool GetShowLegend();
00192 
00195   virtual vtkChartLegend * GetLegend();
00196 
00198 
00199   virtual void SetTitle(const vtkStdString &title);
00200   virtual vtkStdString GetTitle();
00202 
00204 
00206   vtkGetObjectMacro(TitleProperties, vtkTextProperty);
00208 
00210 
00211   void SetBottomBorder(int border);
00212   void SetTopBorder(int border);
00213   void SetLeftBorder(int border);
00214   void SetRightBorder(int border);
00216 
00218   void SetBorders(int left, int bottom, int right, int top);
00219 
00223   void SetSize(const vtkRectf &rect);
00224 
00226   vtkRectf GetSize();
00227 
00229 
00230   enum {
00231     FILL_SCENE,  // Attempt to fill the entire scene.
00232     FILL_RECT,   // Attempt to supply the supplied vtkRectf in Size.
00233     AXES_TO_RECT // Put the corners of the axes on the vtkRectf in Size.
00234   };
00236 
00238 
00241   vtkSetMacro(LayoutStrategy, int);
00242   vtkGetMacro(LayoutStrategy, int);
00244 
00246 
00248   virtual void SetAutoSize(bool isAutoSized)
00249   {
00250     this->LayoutStrategy = isAutoSized ? vtkChart::FILL_SCENE :
00251                                          vtkChart::FILL_RECT;
00252   }
00253   virtual bool GetAutoSize()
00254   {
00255     return this->LayoutStrategy == vtkChart::FILL_SCENE ? true : false;
00256   }
00258 
00260 
00265   vtkSetMacro(RenderEmpty, bool);
00266   vtkGetMacro(RenderEmpty, bool);
00268 
00276   virtual void SetActionToButton(int action, int button);
00277 
00281   virtual int GetActionToButton(int action);
00282 
00286   virtual void SetClickActionToButton(int action, int button);
00287 
00291   virtual int GetClickActionToButton(int action);
00292 
00294 
00295   void SetBackgroundBrush(vtkBrush *brush);
00296   vtkBrush* GetBackgroundBrush();
00298 
00300 
00304   virtual void SetSelectionMode(int);
00305   vtkGetMacro(SelectionMode, int);
00307 
00308 protected:
00309   vtkChart();
00310   ~vtkChart();
00311 
00313 
00317   bool CalculatePlotTransform(vtkAxis *x, vtkAxis *y,
00318                               vtkTransform2D *transform);
00320 
00322 
00324   bool CalculateUnscaledPlotTransform(vtkAxis *x, vtkAxis *y,
00325                                       vtkTransform2D *transform);
00327 
00330   void AttachAxisRangeListener(vtkAxis*);
00331 
00332   void AxisRangeForwarderCallback(vtkObject*,unsigned long, void*);
00333 
00335   vtkAnnotationLink *AnnotationLink;
00336 
00338   int Geometry[2];
00339 
00341   int Point1[2];
00342 
00344   int Point2[2];
00345 
00347   bool ShowLegend;
00348 
00350   vtkStdString Title;
00351 
00353   vtkTextProperty* TitleProperties;
00354 
00355   vtkRectf Size;
00356   // The layout strategy to employ when fitting the chart into the space.
00357   int LayoutStrategy;
00358   bool RenderEmpty;
00359 
00361   vtkSmartPointer<vtkBrush> BackgroundBrush;
00362 
00363   // The mode when the chart is doing selection.
00364   int SelectionMode;
00365 
00366   // How plot selections are handled, SELECTION_ROWS (default) or
00367   // SELECTION_PLOTS - based on the plot that created the selection.
00368   int SelectionMethod;
00369 
00371 
00372   class MouseActions
00373     {
00374   public:
00375     MouseActions();
00376     enum { MaxAction = 5 };
00377     short& Pan() { return Data[0]; }
00378     short& Zoom() { return Data[1]; }
00379     short& ZoomAxis() { return Data[2]; }
00380     short& Select() { return Data[3]; }
00381     short& SelectPolygon() { return Data[4]; }
00382     short& operator[](int index) { return Data[index]; }
00383     short Data[MaxAction];
00384     };
00385   class MouseClickActions
00386     {
00387   public:
00388     MouseClickActions();
00389     short& Notify() { return Data[0]; }
00390     short& Select() { return Data[1]; }
00391     short& operator[](int index) { return Data[index]; }
00392     short Data[2];
00393     };
00395 
00396   MouseActions Actions;
00397   MouseClickActions ActionsClick;
00398 
00399 private:
00400   vtkChart(const vtkChart &); // Not implemented.
00401   void operator=(const vtkChart &);   // Not implemented.
00402 };
00403 
00404 #endif //vtkChart_h