QtiPlot  0.9.8.2
PieCurve.h
Go to the documentation of this file.
1 /***************************************************************************
2  File : PieCurve.h
3  Project : QtiPlot
4  --------------------------------------------------------------------
5  Copyright : (C) 2004 - 2010 by Ion Vasilief
6  Email (use @ for *) : ion_vasilief*yahoo.fr
7  Description : Pie plot class
8 
9  ***************************************************************************/
10 
11 /***************************************************************************
12  * *
13  * This program is free software; you can redistribute it and/or modify *
14  * it under the terms of the GNU General Public License as published by *
15  * the Free Software Foundation; either version 2 of the License, or *
16  * (at your option) any later version. *
17  * *
18  * This program is distributed in the hope that it will be useful, *
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
21  * GNU General Public License for more details. *
22  * *
23  * You should have received a copy of the GNU General Public License *
24  * along with this program; if not, write to the Free Software *
25  * Foundation, Inc., 51 Franklin Street, Fifth Floor, *
26  * Boston, MA 02110-1301 USA *
27  * *
28  ***************************************************************************/
29 #include <qwt_plot.h>
30 #include "PlotCurve.h"
31 #include "LegendWidget.h"
32 
33 class PieLabel;
34 
36 class PieCurve: public DataCurve
37 {
38 public:
39  PieCurve(Table *t, const QString& name, int startRow, int endRow);
40  void clone(PieCurve* c);
41 
42  double viewAngle(){return d_view_angle;};
43  void setViewAngle(double a){d_view_angle = a;};
44 
45  double thickness(){return d_thickness;};
46  void setThickness(double t){d_thickness = t;};
47 
50 
53 
54  double startAzimuth(){return d_start_azimuth;};
55  void setStartAzimuth(double angle){d_start_azimuth = angle;};
56 
57  double labelsEdgeDistance(){return d_edge_dist;};
58  void setLabelsEdgeDistance(double d){d_edge_dist = d;};
59 
61  void setLabelsAutoFormat(bool on){d_auto_labeling = on;};
62 
63  bool labelsValuesFormat(){return d_values;};
64  void setLabelValuesFormat(bool on){d_values = on;};
65 
68 
69  bool labelCategories(){return d_categories;};
70  void setLabelCategories(bool on){d_categories = on;};
71 
74 
75  QColor color(int i) const;
76 
77  int radius(){return d_pie_ray;};
78  void setRadius(int size){d_pie_ray = size;};
79 
80  Qt::BrushStyle pattern(){return QwtPlotCurve::brush().style();};
81  void setBrushStyle(const Qt::BrushStyle& style);
82 
83  void setFirstColor(int index){d_first_color = index;};
84  int firstColor(){return d_first_color;};
85 
86  void loadData();
87  void initLabels();
88  void clearLabels();
89 
90  PieLabel* addLabel(PieLabel *l, bool clone = false);
91 
92  QList <PieLabel *> labelsList(){return d_texts_list;};
93 
94 private:
95  void draw(QPainter *painter,const QwtScaleMap &xMap,
96  const QwtScaleMap &yMap, int from, int to) const;
97  void drawSlices(QPainter *painter, const QwtScaleMap &xMap,
98  const QwtScaleMap &yMap, int from, int to) const;
99  void drawDisk(QPainter *painter, const QwtScaleMap &xMap, const QwtScaleMap &yMap) const;
100 
104  double d_view_angle;
105  double d_thickness;
107  double d_edge_dist;
110  bool d_values;
114  QList <PieLabel *> d_texts_list;
116  QVarLengthArray<int> d_table_rows;
117 };
118 
119 class PieLabel: public LegendWidget
120 {
121  Q_OBJECT
122 
123 public:
124  PieLabel(Graph *, PieCurve *pie = 0);
125 
126  QString customText();
127  void setCustomText(const QString& s){d_custom_text = s;};
128 
129  void setPieCurve(PieCurve *pie){d_pie_curve = pie;};
130 
131  QString saveToString();
132  static void restore(Graph *g, const QStringList& lst);
133 
134 private:
135  void closeEvent(QCloseEvent* e);
136 
138  QString d_custom_text;
139 };
PieCurve(Table *t, const QString &name, int startRow, int endRow)
Definition: PieCurve.cpp:44
double d_horizontal_offset
Definition: PieCurve.h:106
void setLabelPercentagesFormat(bool on)
Definition: PieCurve.h:67
bool labelsPercentagesFormat()
Definition: PieCurve.h:66
void setHorizontalOffset(double d)
Definition: PieCurve.h:49
int firstColor()
Definition: PieCurve.h:84
bool d_fixed_labels_pos
Definition: PieCurve.h:113
double horizontalOffset()
Definition: PieCurve.h:48
double d_thickness
Definition: PieCurve.h:105
void setBrushStyle(const Qt::BrushStyle &style)
Definition: PieCurve.cpp:384
bool d_counter_clockwise
Definition: PieCurve.h:108
A 2D-plotting widget.
Definition: Graph.h:123
void setLabelsEdgeDistance(double d)
Definition: PieCurve.h:58
double d_edge_dist
Definition: PieCurve.h:107
int radius()
Definition: PieCurve.h:77
void setViewAngle(double a)
Definition: PieCurve.h:43
Qt::BrushStyle pattern()
Definition: PieCurve.h:80
PieLabel * addLabel(PieLabel *l, bool clone=false)
Definition: PieCurve.cpp:431
void setLabelsAutoFormat(bool on)
Definition: PieCurve.h:61
bool counterClockwise()
Definition: PieCurve.h:51
virtual QString saveToString()
Definition: PlotCurve.cpp:1019
int endRow()
Definition: PlotCurve.h:145
bool labelsAutoFormat()
Definition: PieCurve.h:60
double d_view_angle
Definition: PieCurve.h:104
void clearLabels()
Definition: PieCurve.cpp:476
void setPieCurve(PieCurve *pie)
Definition: PieCurve.h:129
void drawSlices(QPainter *painter, const QwtScaleMap &xMap, const QwtScaleMap &yMap, int from, int to) const
Definition: PieCurve.cpp:197
Pie plot class.
Definition: PieCurve.h:36
bool d_auto_labeling
Definition: PieCurve.h:109
bool labelCategories()
Definition: PieCurve.h:69
void draw(QPainter *painter, const QwtScaleMap &xMap, const QwtScaleMap &yMap, int from, int to) const
Definition: PieCurve.cpp:97
double viewAngle()
Definition: PieCurve.h:42
QColor color(int i) const
Definition: PieCurve.cpp:379
Definition: LegendWidget.h:42
void setLabelValuesFormat(bool on)
Definition: PieCurve.h:64
void setFirstColor(int index)
Definition: PieCurve.h:83
bool d_values
Definition: PieCurve.h:110
QString d_custom_text
Definition: PieCurve.h:138
Definition: PlotCurve.h:96
void setFixedLabelsPosition(bool on)
Definition: PieCurve.h:73
void setCounterClockwise(bool on)
Definition: PieCurve.h:52
bool d_percentages
Definition: PieCurve.h:111
QList< PieLabel * > labelsList()
Definition: PieCurve.h:92
Definition: PieCurve.h:119
PieCurve * d_pie_curve
Definition: PieCurve.h:137
int startRow()
Definition: PlotCurve.h:144
void setRadius(int size)
Definition: PieCurve.h:78
QList< PieLabel * > d_texts_list
Definition: PieCurve.h:114
bool labelsValuesFormat()
Definition: PieCurve.h:63
void setLabelCategories(bool on)
Definition: PieCurve.h:70
void setThickness(double t)
Definition: PieCurve.h:46
void drawDisk(QPainter *painter, const QwtScaleMap &xMap, const QwtScaleMap &yMap) const
Definition: PieCurve.cpp:112
void initLabels()
Definition: PieCurve.cpp:454
QVarLengthArray< int > d_table_rows
Stores table row indices to be displayed in PieLabels if d_categories is true.
Definition: PieCurve.h:116
double startAzimuth()
Definition: PieCurve.h:54
MDI window providing a spreadsheet table with column logic.
Definition: Table.h:57
int d_first_color
Definition: PieCurve.h:102
void setCustomText(const QString &s)
Definition: PieCurve.h:127
bool d_categories
Definition: PieCurve.h:112
int d_pie_ray
Definition: PieCurve.h:101
void loadData()
Definition: PieCurve.cpp:394
bool fixedLabelsPosition()
Definition: PieCurve.h:72
double d_start_azimuth
Definition: PieCurve.h:103
void clone(PieCurve *c)
Definition: PieCurve.cpp:68
void setStartAzimuth(double angle)
Definition: PieCurve.h:55
double labelsEdgeDistance()
Definition: PieCurve.h:57
double thickness()
Definition: PieCurve.h:45