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 /** 17 * @class vtkPlotPie 18 * @brief Class for drawing a Pie diagram. 19 * 20 * 21 */ 22 23 #ifndef vtkPlotPie_h 24 #define vtkPlotPie_h 25 26 #include "vtkChartsCoreModule.h" // For export macro 27 #include "vtkPlot.h" 28 #include "vtkSmartPointer.h" // To hold ColorSeries etc. 29 30 class vtkContext2D; 31 class vtkColorSeries; 32 class vtkPoints2D; 33 34 class vtkPlotPiePrivate; 35 36 class VTKCHARTSCORE_EXPORT vtkPlotPie : public vtkPlot 37 { 38 public: 39 vtkTypeMacro(vtkPlotPie, vtkPlot); 40 void PrintSelf(ostream& os, vtkIndent indent) override; 41 42 static vtkPlotPie* New(); 43 44 /** 45 * Paint event for the item. 46 */ 47 bool Paint(vtkContext2D* painter) override; 48 49 /** 50 * Paint legend event for the XY plot, called whenever the legend needs the 51 * plot items symbol/mark/line drawn. A rect is supplied with the lower left 52 * corner of the rect (elements 0 and 1) and with width x height (elements 2 53 * and 3). The plot can choose how to fill the space supplied. 54 */ 55 bool PaintLegend(vtkContext2D* painter, const vtkRectf& rect, int legendIndex) override; 56 57 /** 58 * Set the dimensions of the pie, arguments 1 and 2 are the x and y coordinate 59 * of the bottom corner. Arguments 3 and 4 are the width and height. 60 */ 61 void SetDimensions(int arg1, int arg2, int arg3, int arg4); 62 63 /** 64 * Set the dimensions of the pie, elements 0 and 1 are the x and y coordinate 65 * of the bottom corner. Elements 2 and 3 are the width and height. 66 */ 67 void SetDimensions(const int arg[4]); 68 69 ///@{ 70 /** 71 * Get the dimensions of the pie, elements 0 and 1 are the x and y coordinate 72 * of the bottom corner. Elements 2 and 3 are the width and height. 73 */ 74 vtkGetVector4Macro(Dimensions, int); 75 ///@} 76 77 /** 78 * Set the color series to use for the Pie. 79 */ 80 void SetColorSeries(vtkColorSeries* colorSeries); 81 82 /** 83 * Get the color series used. 84 */ 85 vtkColorSeries* GetColorSeries(); 86 87 /** 88 * Function to query a plot for the nearest point to the specified coordinate. 89 * Returns the index of the data series with which the point is associated or 90 * -1. 91 */ 92 vtkIdType GetNearestPoint(const vtkVector2f& point, const vtkVector2f& tolerance, 93 vtkVector2f* location, vtkIdType* segmentId) override; 94 using vtkPlot::GetNearestPoint; 95 96 protected: 97 vtkPlotPie(); 98 ~vtkPlotPie() override; 99 100 /** 101 * Update the table cache. 102 */ 103 bool UpdateTableCache(vtkTable* table); 104 105 int Dimensions[4]; 106 107 /** 108 * The color series to use for the pie. 109 */ 110 vtkSmartPointer<vtkColorSeries> ColorSeries; 111 112 /** 113 * Store a well packed set of angles for the wedges of the pie. 114 */ 115 vtkPoints2D* Points; 116 117 /** 118 * The point cache is marked dirty until it has been initialized. 119 */ 120 vtkTimeStamp BuildTime; 121 122 private: 123 vtkPlotPie(const vtkPlotPie&) = delete; 124 void operator=(const vtkPlotPie&) = delete; 125 126 vtkPlotPiePrivate* Private; 127 }; 128 129 #endif // vtkPlotPie_h 130