~showard314/ubuntu/natty/qtiplot/Python2.7_fix

« back to all changes in this revision

Viewing changes to qtiplot/src/QwtPieCurve.h

  • Committer: Bazaar Package Importer
  • Author(s): Fathi Boudra
  • Date: 2008-04-04 15:11:55 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20080404151155-rjp12ziov4tryj0o
Tags: 0.9.4-1
* New upstream release.
* Refresh patches.
* Remove 04_homepage_url patch. Merged upstream.

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
    File                 : QwtPieCurve.h
3
3
    Project              : QtiPlot
4
4
    --------------------------------------------------------------------
5
 
    Copyright            : (C) 2006 by Ion Vasilief, Tilman Hoener zu Siederdissen
6
 
    Email (use @ for *)  : ion_vasilief*yahoo.fr, thzs*gmx.net
 
5
    Copyright            : (C) 2004 - 2008 by Ion Vasilief
 
6
    Email (use @ for *)  : ion_vasilief*yahoo.fr
7
7
    Description          : Pie plot class
8
8
 
9
9
 ***************************************************************************/
28
28
 ***************************************************************************/
29
29
#include <qwt_plot.h>
30
30
#include "PlotCurve.h"
 
31
#include "LegendWidget.h"
31
32
 
 
33
class PieLabel;
 
34
        
32
35
//! Pie plot class
33
36
class QwtPieCurve: public DataCurve
34
37
{
35
38
public:
36
39
        QwtPieCurve(Table *t, const QString& name, int startRow, int endRow);
37
 
 
38
 
public slots:
 
40
    void clone(QwtPieCurve* 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
 
 
48
    double horizontalOffset(){return d_horizontal_offset;};
 
49
    void setHorizontalOffset(double d){d_horizontal_offset = d;};
 
50
 
 
51
        bool counterClockwise(){return d_counter_clockwise;};
 
52
        void setCounterClockwise(bool on){d_counter_clockwise = on;};
 
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
 
 
60
    bool labelsAutoFormat(){return d_auto_labeling;};
 
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
 
 
66
    bool labelsPercentagesFormat(){return d_percentages;};
 
67
    void setLabelPercentagesFormat(bool on){d_percentages = on;};
 
68
 
 
69
        bool labelCategories(){return d_categories;};
 
70
    void setLabelCategories(bool on){d_categories = on;};
 
71
        
 
72
    bool fixedLabelsPosition(){return d_fixed_labels_pos;};
 
73
    void setFixedLabelsPosition(bool on){d_fixed_labels_pos = on;};
 
74
 
39
75
        QColor color(int i) const;
40
76
 
41
 
        int ray(){return d_pie_ray;};
42
 
        void setRay(int size){d_pie_ray = size; updateBoundingRect();};
 
77
        int radius(){return d_pie_ray;};
 
78
        void setRadius(int size){d_pie_ray = size;};
43
79
 
44
80
        Qt::BrushStyle pattern(){return QwtPlotCurve::brush().style();};
45
81
        void setBrushStyle(const Qt::BrushStyle& style);
48
84
        int firstColor(){return d_first_color;};
49
85
 
50
86
        void loadData();
51
 
        void updateBoundingRect();
 
87
        void initLabels();
 
88
        
 
89
        void addLabel(PieLabel *l, bool clone = false);
 
90
        void removeLabel(PieLabel *l);
 
91
        
 
92
        QList <PieLabel *> labelsList(){return d_texts_list;};
52
93
 
53
94
private:
54
95
        void draw(QPainter *painter,const QwtScaleMap &xMap,
55
96
                const QwtScaleMap &yMap, int from, int to) const;
56
 
 
57
 
        void drawPie(QPainter *painter, const QwtScaleMap &xMap,
 
97
        void drawSlices(QPainter *painter, const QwtScaleMap &xMap,
58
98
                const QwtScaleMap &yMap, int from, int to) const;
59
 
 
60
 
        int d_pie_ray, d_first_color;
61
 
        //! Keeps track of the left side position of the pie bounding rectangle in scale coordinates.
62
 
        double d_left_coord;
 
99
        void drawDisk(QPainter *painter, const QwtScaleMap &xMap, const QwtScaleMap &yMap) const;
 
100
 
 
101
        int d_pie_ray;
 
102
        int d_first_color;
 
103
        double d_start_azimuth;
 
104
        double d_view_angle;
 
105
        double d_thickness;
 
106
        double d_horizontal_offset;
 
107
        double d_edge_dist;
 
108
        bool d_counter_clockwise;
 
109
        bool d_auto_labeling;
 
110
        bool d_values;
 
111
        bool d_percentages;
 
112
        bool d_categories;
 
113
        bool d_fixed_labels_pos;
 
114
        QList <PieLabel *> d_texts_list;
 
115
        //! Stores table row indices to be displayed in PieLabels if d_categories is true.
 
116
        QVarLengthArray<int> d_table_rows;
 
117
};
 
118
 
 
119
class PieLabel: public LegendWidget
 
120
{
 
121
        Q_OBJECT
 
122
 
 
123
public:
 
124
    PieLabel(Plot *, QwtPieCurve *pie = 0);
 
125
 
 
126
        QString customText();
 
127
        void setCustomText(const QString& s){d_custom_text = s;};
 
128
        
 
129
        void setPieCurve(QwtPieCurve *pie){d_pie_curve = pie;};
 
130
        
 
131
private:
 
132
        void closeEvent(QCloseEvent* e);
 
133
 
 
134
        QwtPieCurve *d_pie_curve;
 
135
        QString d_custom_text;
63
136
};