1 /*=========================================================================
2 
3   Program:   Visualization Toolkit
4   Module:    vtkPlotPie.h
5 
6   Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7   All rights reserved.
8   See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9 
10      This software is distributed WITHOUT ANY WARRANTY; without even
11      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12      PURPOSE.  See the above copyright notice for more information.
13 
14 =========================================================================*/
15 
16 // .NAME vtkPlotPie - Class for drawing a Pie diagram.
17 //
18 // .SECTION Description
19 
20 #ifndef vtkPlotPie_h
21 #define vtkPlotPie_h
22 
23 #include "vtkChartsCoreModule.h" // For export macro
24 #include "vtkPlot.h"
25 #include "vtkSmartPointer.h" // To hold ColorSeries etc.
26 
27 class vtkContext2D;
28 class vtkColorSeries;
29 class vtkPoints2D;
30 
31 class vtkPlotPiePrivate;
32 
33 class VTKCHARTSCORE_EXPORT vtkPlotPie : public vtkPlot
34 {
35 public:
36   vtkTypeMacro(vtkPlotPie, vtkPlot);
37   virtual void PrintSelf(ostream &os, vtkIndent indent);
38 
39   static vtkPlotPie *New();
40 
41   // Description:
42   // Paint event for the item.
43   virtual bool Paint(vtkContext2D *painter);
44 
45   // Description:
46   // Paint legend event for the XY plot, called whenever the legend needs the
47   // plot items symbol/mark/line drawn. A rect is supplied with the lower left
48   // corner of the rect (elements 0 and 1) and with width x height (elements 2
49   // and 3). The plot can choose how to fill the space supplied.
50   bool PaintLegend(vtkContext2D *painter, const vtkRectf& rect, int legendIndex);
51 
52   // Description:
53   // Set the dimensions of the pie, arguments 1 and 2 are the x and y coordinate
54   // of the bottom corner. Arguments 3 and 4 are the width and height.
55   void SetDimensions(int arg1, int arg2, int arg3, int arg4);
56 
57   // Description:
58   // Set the dimensions of the pie, elements 0 and 1 are the x and y coordinate
59   // of the bottom corner. Elements 2 and 3 are the width and height.
60   void SetDimensions(int arg[4]);
61 
62   // Description:
63   // Get the dimensions of the pie, elements 0 and 1 are the x and y coordinate
64   // of the bottom corner. Elements 2 and 3 are the width and height.
65   vtkGetVector4Macro(Dimensions, int);
66 
67   // Description:
68   // Set the color series to use for the Pie.
69   void SetColorSeries(vtkColorSeries *colorSeries);
70 
71   // Description:
72   // Get the color series used.
73   vtkColorSeries *GetColorSeries();
74 
75 //BTX
76   // Description:
77   // Function to query a plot for the nearest point to the specified coordinate.
78   // Returns the index of the data series with which the point is associated or
79   // -1.
80   virtual vtkIdType GetNearestPoint(const vtkVector2f& point,
81                                     const vtkVector2f& tolerance,
82                                     vtkVector2f* location);
83 
84 protected:
85   vtkPlotPie();
86   ~vtkPlotPie();
87 
88   // Description:
89   // Update the table cache.
90   bool UpdateTableCache(vtkTable *table);
91 
92   int Dimensions[4];
93 
94   // Description:
95   // The color series to use for the pie.
96   vtkSmartPointer<vtkColorSeries> ColorSeries;
97 
98   // Description:
99   // Store a well packed set of angles for the wedges of the pie.
100   vtkPoints2D *Points;
101 
102   // Description:
103   // The point cache is marked dirty until it has been initialized.
104   vtkTimeStamp BuildTime;
105 
106 private:
107   vtkPlotPie(const vtkPlotPie &);     // Not implemented.
108   void operator=(const vtkPlotPie &); // Not implemented.
109 
110   vtkPlotPiePrivate *Private;
111 //ETX
112 };
113 
114 #endif //vtkPlotPie_h
115