QwtPieCurve.h
Go to the documentation of this file.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 PieLabel* addLabel(PieLabel *l, bool clone = false);
00090
00091 QList <PieLabel *> labelsList(){return d_texts_list;};
00092
00093 private:
00094 void draw(QPainter *painter,const QwtScaleMap &xMap,
00095 const QwtScaleMap &yMap, int from, int to) const;
00096 void drawSlices(QPainter *painter, const QwtScaleMap &xMap,
00097 const QwtScaleMap &yMap, int from, int to) const;
00098 void drawDisk(QPainter *painter, const QwtScaleMap &xMap, const QwtScaleMap &yMap) const;
00099
00100 int d_pie_ray;
00101 int d_first_color;
00102 double d_start_azimuth;
00103 double d_view_angle;
00104 double d_thickness;
00105 double d_horizontal_offset;
00106 double d_edge_dist;
00107 bool d_counter_clockwise;
00108 bool d_auto_labeling;
00109 bool d_values;
00110 bool d_percentages;
00111 bool d_categories;
00112 bool d_fixed_labels_pos;
00113 QList <PieLabel *> d_texts_list;
00115 QVarLengthArray<int> d_table_rows;
00116 };
00117
00118 class PieLabel: public LegendWidget
00119 {
00120 Q_OBJECT
00121
00122 public:
00123 PieLabel(Graph *, QwtPieCurve *pie = 0);
00124
00125 QString customText();
00126 void setCustomText(const QString& s){d_custom_text = s;};
00127
00128 void setPieCurve(QwtPieCurve *pie){d_pie_curve = pie;};
00129
00130 QString saveToString();
00131 static void restore(Graph *g, const QStringList& lst);
00132
00133 private:
00134 void closeEvent(QCloseEvent* e);
00135
00136 QwtPieCurve *d_pie_curve;
00137 QString d_custom_text;
00138 };