00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #include <qwt_plot.h>
00030 #include "PlotCurve.h"
00031 #include "LegendWidget.h"
00032
00033 class PieLabel;
00034
00036 class QwtPieCurve: public DataCurve
00037 {
00038 public:
00039 QwtPieCurve(Table *t, const QString& name, int startRow, int endRow);
00040 void clone(QwtPieCurve* c);
00041
00042 double viewAngle(){return d_view_angle;};
00043 void setViewAngle(double a){d_view_angle = a;};
00044
00045 double thickness(){return d_thickness;};
00046 void setThickness(double t){d_thickness = t;};
00047
00048 double horizontalOffset(){return d_horizontal_offset;};
00049 void setHorizontalOffset(double d){d_horizontal_offset = d;};
00050
00051 bool counterClockwise(){return d_counter_clockwise;};
00052 void setCounterClockwise(bool on){d_counter_clockwise = on;};
00053
00054 double startAzimuth(){return d_start_azimuth;};
00055 void setStartAzimuth(double angle){d_start_azimuth = angle;};
00056
00057 double labelsEdgeDistance(){return d_edge_dist;};
00058 void setLabelsEdgeDistance(double d){d_edge_dist = d;};
00059
00060 bool labelsAutoFormat(){return d_auto_labeling;};
00061 void setLabelsAutoFormat(bool on){d_auto_labeling = on;};
00062
00063 bool labelsValuesFormat(){return d_values;};
00064 void setLabelValuesFormat(bool on){d_values = on;};
00065
00066 bool labelsPercentagesFormat(){return d_percentages;};
00067 void setLabelPercentagesFormat(bool on){d_percentages = on;};
00068
00069 bool labelCategories(){return d_categories;};
00070 void setLabelCategories(bool on){d_categories = on;};
00071
00072 bool fixedLabelsPosition(){return d_fixed_labels_pos;};
00073 void setFixedLabelsPosition(bool on){d_fixed_labels_pos = on;};
00074
00075 QColor color(int i) const;
00076
00077 int radius(){return d_pie_ray;};
00078 void setRadius(int size){d_pie_ray = size;};
00079
00080 Qt::BrushStyle pattern(){return QwtPlotCurve::brush().style();};
00081 void setBrushStyle(const Qt::BrushStyle& style);
00082
00083 void setFirstColor(int index){d_first_color = index;};
00084 int firstColor(){return d_first_color;};
00085
00086 void loadData();
00087 void initLabels();
00088
00089 void addLabel(PieLabel *l, bool clone = false);
00090 void removeLabel(PieLabel *l);
00091
00092 QList <PieLabel *> labelsList(){return d_texts_list;};
00093
00094 private:
00095 void draw(QPainter *painter,const QwtScaleMap &xMap,
00096 const QwtScaleMap &yMap, int from, int to) const;
00097 void drawSlices(QPainter *painter, const QwtScaleMap &xMap,
00098 const QwtScaleMap &yMap, int from, int to) const;
00099 void drawDisk(QPainter *painter, const QwtScaleMap &xMap, const QwtScaleMap &yMap) const;
00100
00101 int d_pie_ray;
00102 int d_first_color;
00103 double d_start_azimuth;
00104 double d_view_angle;
00105 double d_thickness;
00106 double d_horizontal_offset;
00107 double d_edge_dist;
00108 bool d_counter_clockwise;
00109 bool d_auto_labeling;
00110 bool d_values;
00111 bool d_percentages;
00112 bool d_categories;
00113 bool d_fixed_labels_pos;
00114 QList <PieLabel *> d_texts_list;
00116 QVarLengthArray<int> d_table_rows;
00117 };
00118
00119 class PieLabel: public LegendWidget
00120 {
00121 Q_OBJECT
00122
00123 public:
00124 PieLabel(Graph *, QwtPieCurve *pie = 0);
00125
00126 QString customText();
00127 void setCustomText(const QString& s){d_custom_text = s;};
00128
00129 void setPieCurve(QwtPieCurve *pie){d_pie_curve = pie;};
00130
00131 private:
00132 void closeEvent(QCloseEvent* e);
00133
00134 QwtPieCurve *d_pie_curve;
00135 QString d_custom_text;
00136 };