1 //                                               -*- C++ -*-
2 /**
3  *  @brief Pie class for piechart plots
4  *
5  *  Copyright 2005-2021 Airbus-EDF-IMACS-ONERA-Phimeca
6  *
7  *  This library is free software: you can redistribute it and/or modify
8  *  it under the terms of the GNU Lesser General Public License as published by
9  *  the Free Software Foundation, either version 3 of the License, or
10  *  (at your option) any later version.
11  *
12  *  This library is distributed in the hope that it will be useful,
13  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  *  GNU Lesser General Public License for more details.
16  *
17  *  You should have received a copy of the GNU Lesser General Public License
18  *  along with this library.  If not, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 #ifndef OPENTURNS_PIE_HXX
22 #define OPENTURNS_PIE_HXX
23 
24 #include "openturns/DrawableImplementation.hxx"
25 
26 BEGIN_NAMESPACE_OPENTURNS
27 
28 /**
29  * @class Pie
30  *
31  * The class describing a pie chart
32  * Instance of Drawable
33  */
34 
35 
36 class OT_API Pie : public DrawableImplementation
37 {
38 
39   CLASSNAME
40 
41 public:
42   /** Default constructor */
43   Pie();
44 
45   /** Default constructor */
46   explicit Pie(const Point & data);
47 
48   /** Constructor with parameters */
49   Pie(const Point & data,
50       const Description & labels);
51 
52   /** Constructor with parameters */
53   Pie(const Point & data,
54       const Description & labels,
55       const Point & center,
56       const Scalar & radius,
57       const Description & palette);
58 
59   /** String converter */
60   String __repr__() const override;
61 
62   /** Accessor for center */
63   Point getCenter() const override;
64   void setCenter(const Point & center) override;
65 
66   /** Accessor for radius */
67   Scalar getRadius() const override;
68   void setRadius(const Scalar radius) override;
69 
70   /** Accessor for labels */
71   Description getLabels() const override;
72   void setLabels(const Description & labels) override;
73 
74   /** Accessor for color palette */
75   Description getPalette() const override;
76   void setPalette(const Description & palette) override;
77 
78   /** Accessor for boundingbox */
79   Interval getBoundingBox() const override;
80 
81   /** Draw method */
82   String draw() const override;
83 
84   /** Clone method */
85   Pie * clone() const override;
86 
87   /** Build default palette */
88   void buildDefaultPalette();
89 
90   /** Build default labels */
91   void buildDefaultLabels();
92 
93   /** Check for color palette validity */
94   static Bool IsValidColorPalette(const Description & palette);
95 
96   /** Method save() stores the object through the StorageManager */
97   void save(Advocate & adv) const override;
98 
99   /** Method load() stores the object through the StorageManager */
100   void load(Advocate & adv) override;
101 
102 protected:
103   /** Check for data validity */
104   void checkData(const Point & data) const override;
105 
106 private:
107 
108   /** Collection of Strings representing the color palettes */
109   Description palette_;
110 
111   /** Radius of the Pie */
112   Scalar radius_;
113 
114   /** Centre of the Pie */
115   Point center_;
116 
117   /** Labels of the pie sectors */
118   Description labels_;
119 
120 }; /* class Pie */
121 
122 
123 
124 END_NAMESPACE_OPENTURNS
125 
126 #endif /* OPENTURNS_PIE_HXX */
127