##// END OF EJS Templates
Fixes header guard style issues
Michal Klocek -
r969:db6eae90aaea
parent child
Show More
@@ -1,46 +1,46
1 /****************************************************************************
1 /****************************************************************************
2 **
2 **
3 ** Copyright (C) 2012 Digia Plc
3 ** Copyright (C) 2012 Digia Plc
4 ** All rights reserved.
4 ** All rights reserved.
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 **
6 **
7 ** This file is part of the Qt Commercial Charts Add-on.
7 ** This file is part of the Qt Commercial Charts Add-on.
8 **
8 **
9 ** $QT_BEGIN_LICENSE$
9 ** $QT_BEGIN_LICENSE$
10 ** Licensees holding valid Qt Commercial licenses may use this file in
10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 ** accordance with the Qt Commercial License Agreement provided with the
11 ** accordance with the Qt Commercial License Agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia.
13 ** a written agreement between you and Digia.
14 **
14 **
15 ** If you have questions regarding the use of this file, please use
15 ** If you have questions regarding the use of this file, please use
16 ** contact form at http://qt.digia.com
16 ** contact form at http://qt.digia.com
17 ** $QT_END_LICENSE$
17 ** $QT_END_LICENSE$
18 **
18 **
19 ****************************************************************************/
19 ****************************************************************************/
20
20
21 #ifndef AXISANIMATIONITEM_H_
21 #ifndef AXISANIMATION_H
22 #define AXISANIMATIONITEM_H_
22 #define AXISANIMATION_H
23
23
24 #include "axis_p.h"
24 #include "axis_p.h"
25 #include "chartanimation_p.h"
25 #include "chartanimation_p.h"
26
26
27
27
28 QTCOMMERCIALCHART_BEGIN_NAMESPACE
28 QTCOMMERCIALCHART_BEGIN_NAMESPACE
29
29
30 class AxisAnimation: public ChartAnimation
30 class AxisAnimation: public ChartAnimation
31 {
31 {
32 public:
32 public:
33 AxisAnimation(Axis *axis);
33 AxisAnimation(Axis *axis);
34 ~AxisAnimation();
34 ~AxisAnimation();
35 protected:
35 protected:
36 QVariant interpolated(const QVariant &from, const QVariant &to, qreal progress ) const;
36 QVariant interpolated(const QVariant &from, const QVariant &to, qreal progress ) const;
37 void updateCurrentValue(const QVariant &value );
37 void updateCurrentValue(const QVariant &value );
38 private:
38 private:
39 Axis *m_axis;
39 Axis *m_axis;
40 };
40 };
41
41
42 QTCOMMERCIALCHART_END_NAMESPACE
42 QTCOMMERCIALCHART_END_NAMESPACE
43
43
44
44
45
45
46 #endif /* AXISITEM_H_ */
46 #endif /* AXISITEM_H_ */
@@ -1,54 +1,54
1 /****************************************************************************
1 /****************************************************************************
2 **
2 **
3 ** Copyright (C) 2012 Digia Plc
3 ** Copyright (C) 2012 Digia Plc
4 ** All rights reserved.
4 ** All rights reserved.
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 **
6 **
7 ** This file is part of the Qt Commercial Charts Add-on.
7 ** This file is part of the Qt Commercial Charts Add-on.
8 **
8 **
9 ** $QT_BEGIN_LICENSE$
9 ** $QT_BEGIN_LICENSE$
10 ** Licensees holding valid Qt Commercial licenses may use this file in
10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 ** accordance with the Qt Commercial License Agreement provided with the
11 ** accordance with the Qt Commercial License Agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia.
13 ** a written agreement between you and Digia.
14 **
14 **
15 ** If you have questions regarding the use of this file, please use
15 ** If you have questions regarding the use of this file, please use
16 ** contact form at http://qt.digia.com
16 ** contact form at http://qt.digia.com
17 ** $QT_END_LICENSE$
17 ** $QT_END_LICENSE$
18 **
18 **
19 ****************************************************************************/
19 ****************************************************************************/
20
20
21 #ifndef BARANIMATION_P_H_
21 #ifndef BARANIMATION_P_H
22 #define BARANIMATION_P_H_
22 #define BARANIMATION_P_H
23
23
24 #include "chartanimation_p.h"
24 #include "chartanimation_p.h"
25 #include "barchartitem_p.h"
25 #include "barchartitem_p.h"
26
26
27 QTCOMMERCIALCHART_BEGIN_NAMESPACE
27 QTCOMMERCIALCHART_BEGIN_NAMESPACE
28
28
29 class BarChartItem;
29 class BarChartItem;
30 class QBarSet;
30 class QBarSet;
31 class BarSetAnimation;
31 class BarSetAnimation;
32
32
33 class BarAnimation : public ChartAnimation
33 class BarAnimation : public ChartAnimation
34 {
34 {
35 Q_OBJECT
35 Q_OBJECT
36
36
37 public:
37 public:
38 BarAnimation(BarChartItem *item);
38 BarAnimation(BarChartItem *item);
39 ~BarAnimation();
39 ~BarAnimation();
40
40
41 public: // from QVariantAnimation
41 public: // from QVariantAnimation
42 virtual QVariant interpolated(const QVariant &from, const QVariant &to, qreal progress) const;
42 virtual QVariant interpolated(const QVariant &from, const QVariant &to, qreal progress) const;
43 virtual void updateCurrentValue(const QVariant &value);
43 virtual void updateCurrentValue(const QVariant &value);
44
44
45 public Q_SLOTS:
45 public Q_SLOTS:
46
46
47 private:
47 private:
48 BarChartItem *m_item;
48 BarChartItem *m_item;
49 QHash<QBarSet *, BarSetAnimation *> m_animations;
49 QHash<QBarSet *, BarSetAnimation *> m_animations;
50 };
50 };
51
51
52 QTCOMMERCIALCHART_END_NAMESPACE
52 QTCOMMERCIALCHART_END_NAMESPACE
53
53
54 #endif
54 #endif
@@ -1,46 +1,46
1 /****************************************************************************
1 /****************************************************************************
2 **
2 **
3 ** Copyright (C) 2012 Digia Plc
3 ** Copyright (C) 2012 Digia Plc
4 ** All rights reserved.
4 ** All rights reserved.
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 **
6 **
7 ** This file is part of the Qt Commercial Charts Add-on.
7 ** This file is part of the Qt Commercial Charts Add-on.
8 **
8 **
9 ** $QT_BEGIN_LICENSE$
9 ** $QT_BEGIN_LICENSE$
10 ** Licensees holding valid Qt Commercial licenses may use this file in
10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 ** accordance with the Qt Commercial License Agreement provided with the
11 ** accordance with the Qt Commercial License Agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia.
13 ** a written agreement between you and Digia.
14 **
14 **
15 ** If you have questions regarding the use of this file, please use
15 ** If you have questions regarding the use of this file, please use
16 ** contact form at http://qt.digia.com
16 ** contact form at http://qt.digia.com
17 ** $QT_END_LICENSE$
17 ** $QT_END_LICENSE$
18 **
18 **
19 ****************************************************************************/
19 ****************************************************************************/
20
20
21 #ifndef CHARTANIMATION_H_
21 #ifndef CHARTANIMATION_H
22 #define CHARTANIMATION_H_
22 #define CHARTANIMATION_H
23
23
24 #include "qchartglobal.h"
24 #include "qchartglobal.h"
25 #include <QVariantAnimation>
25 #include <QVariantAnimation>
26
26
27 QTCOMMERCIALCHART_BEGIN_NAMESPACE
27 QTCOMMERCIALCHART_BEGIN_NAMESPACE
28
28
29 class ChartAnimation: public QVariantAnimation
29 class ChartAnimation: public QVariantAnimation
30 {
30 {
31 public:
31 public:
32 enum Animation { LineDrawAnimation, MoveDownAnimation, MoveUpAnimation };
32 enum Animation { LineDrawAnimation, MoveDownAnimation, MoveUpAnimation };
33 ChartAnimation(QObject *parent = 0):QVariantAnimation(parent), m_type(MoveDownAnimation){}
33 ChartAnimation(QObject *parent = 0):QVariantAnimation(parent), m_type(MoveDownAnimation){}
34 void setAnimationType(Animation type){
34 void setAnimationType(Animation type){
35 m_type=type;
35 m_type=type;
36 }
36 }
37 protected:
37 protected:
38 Animation m_type;
38 Animation m_type;
39
39
40 };
40 };
41
41
42 QTCOMMERCIALCHART_END_NAMESPACE
42 QTCOMMERCIALCHART_END_NAMESPACE
43
43
44
44
45
45
46 #endif /* AXISITEM_H_ */
46 #endif /* AXISITEM_H_ */
@@ -1,77 +1,78
1 /****************************************************************************
1 /****************************************************************************
2 **
2 **
3 ** Copyright (C) 2012 Digia Plc
3 ** Copyright (C) 2012 Digia Plc
4 ** All rights reserved.
4 ** All rights reserved.
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 **
6 **
7 ** This file is part of the Qt Commercial Charts Add-on.
7 ** This file is part of the Qt Commercial Charts Add-on.
8 **
8 **
9 ** $QT_BEGIN_LICENSE$
9 ** $QT_BEGIN_LICENSE$
10 ** Licensees holding valid Qt Commercial licenses may use this file in
10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 ** accordance with the Qt Commercial License Agreement provided with the
11 ** accordance with the Qt Commercial License Agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia.
13 ** a written agreement between you and Digia.
14 **
14 **
15 ** If you have questions regarding the use of this file, please use
15 ** If you have questions regarding the use of this file, please use
16 ** contact form at http://qt.digia.com
16 ** contact form at http://qt.digia.com
17 ** $QT_END_LICENSE$
17 ** $QT_END_LICENSE$
18 **
18 **
19 ****************************************************************************/
19 ****************************************************************************/
20
20
21 #ifndef CHARTANIMATOR_P_H_
21 #ifndef CHARTANIMATOR_P_H
22 #define CHARTANIMATOR_P_H_
22 #define CHARTANIMATOR_P_H
23
23 #include "qchartglobal.h"
24 #include "qchartglobal.h"
24 #include "chartanimation_p.h"
25 #include "chartanimation_p.h"
25 #include "piechartitem_p.h"
26 #include "piechartitem_p.h"
26 #include "barchartitem_p.h"
27 #include "barchartitem_p.h"
27 #include <QPointF>
28 #include <QPointF>
28
29
29 QTCOMMERCIALCHART_BEGIN_NAMESPACE
30 QTCOMMERCIALCHART_BEGIN_NAMESPACE
30
31
31 class ChartItem;
32 class ChartItem;
32 class Axis;
33 class Axis;
33 class AreaChartItem;
34 class AreaChartItem;
34 class SplineChartItem;
35 class SplineChartItem;
35 class ScatterChartItem;
36 class ScatterChartItem;
36 class LineChartItem;
37 class LineChartItem;
37 class XYChartItem;
38 class XYChartItem;
38
39
39 class ChartAnimator : public QObject {
40 class ChartAnimator : public QObject {
40
41
41 public:
42 public:
42 enum State{ShowState, ScrollUpState, ScrollDownState, ScrollLeftState, ScrollRightState, ZoomInState, ZoomOutState};
43 enum State{ShowState, ScrollUpState, ScrollDownState, ScrollLeftState, ScrollRightState, ZoomInState, ZoomOutState};
43
44
44 ChartAnimator(QObject *parent = 0);
45 ChartAnimator(QObject *parent = 0);
45 virtual ~ChartAnimator();
46 virtual ~ChartAnimator();
46
47
47 void addAnimation(Axis *item);
48 void addAnimation(Axis *item);
48 void addAnimation(PieChartItem *item);
49 void addAnimation(PieChartItem *item);
49 void addAnimation(ScatterChartItem *item);
50 void addAnimation(ScatterChartItem *item);
50 void addAnimation(LineChartItem *item);
51 void addAnimation(LineChartItem *item);
51 void addAnimation(SplineChartItem *item);
52 void addAnimation(SplineChartItem *item);
52 void addAnimation(BarChartItem *item);
53 void addAnimation(BarChartItem *item);
53 void removeAnimation(Chart *item);
54 void removeAnimation(Chart *item);
54
55
55 void animationStarted();
56 void animationStarted();
56 void updateLayout(XYChartItem *item, QVector<QPointF> &oldLayout, QVector<QPointF> &newLayout, int index);
57 void updateLayout(XYChartItem *item, QVector<QPointF> &oldLayout, QVector<QPointF> &newLayout, int index);
57 void updateLayout(SplineChartItem *item, QVector<QPointF> &oldPoints, QVector<QPointF> &newPoints, QVector<QPointF> &oldControlPoints, QVector<QPointF> &newContorlPoints, int index);
58 void updateLayout(SplineChartItem *item, QVector<QPointF> &oldPoints, QVector<QPointF> &newPoints, QVector<QPointF> &oldControlPoints, QVector<QPointF> &newContorlPoints, int index);
58 void updateLayout(Axis *item, QVector<qreal> &layout);
59 void updateLayout(Axis *item, QVector<qreal> &layout);
59
60
60 void addAnimation(PieChartItem *item, QPieSlice *slice, const PieSliceData &sliceData, bool isEmpty);
61 void addAnimation(PieChartItem *item, QPieSlice *slice, const PieSliceData &sliceData, bool isEmpty);
61 void removeAnimation(PieChartItem *item, QPieSlice *slice);
62 void removeAnimation(PieChartItem *item, QPieSlice *slice);
62 void updateLayout(PieChartItem *item, const PieLayout &layout);
63 void updateLayout(PieChartItem *item, const PieLayout &layout);
63 void updateLayout(PieChartItem *item, QPieSlice *slice, const PieSliceData &sliceData);
64 void updateLayout(PieChartItem *item, QPieSlice *slice, const PieSliceData &sliceData);
64
65
65 void updateLayout(BarChartItem *item, const QVector<QRectF> &oldLayout, const QVector<QRectF> &newLayout);
66 void updateLayout(BarChartItem *item, const QVector<QRectF> &oldLayout, const QVector<QRectF> &newLayout);
66
67
67 void setState(State state,const QPointF &point = QPointF());
68 void setState(State state,const QPointF &point = QPointF());
68
69
69 private:
70 private:
70 QMap<Chart *, ChartAnimation *> m_animations;
71 QMap<Chart *, ChartAnimation *> m_animations;
71 State m_state;
72 State m_state;
72 QPointF m_point;
73 QPointF m_point;
73 };
74 };
74
75
75 QTCOMMERCIALCHART_END_NAMESPACE
76 QTCOMMERCIALCHART_END_NAMESPACE
76
77
77 #endif
78 #endif
@@ -1,57 +1,57
1 /****************************************************************************
1 /****************************************************************************
2 **
2 **
3 ** Copyright (C) 2012 Digia Plc
3 ** Copyright (C) 2012 Digia Plc
4 ** All rights reserved.
4 ** All rights reserved.
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 **
6 **
7 ** This file is part of the Qt Commercial Charts Add-on.
7 ** This file is part of the Qt Commercial Charts Add-on.
8 **
8 **
9 ** $QT_BEGIN_LICENSE$
9 ** $QT_BEGIN_LICENSE$
10 ** Licensees holding valid Qt Commercial licenses may use this file in
10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 ** accordance with the Qt Commercial License Agreement provided with the
11 ** accordance with the Qt Commercial License Agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia.
13 ** a written agreement between you and Digia.
14 **
14 **
15 ** If you have questions regarding the use of this file, please use
15 ** If you have questions regarding the use of this file, please use
16 ** contact form at http://qt.digia.com
16 ** contact form at http://qt.digia.com
17 ** $QT_END_LICENSE$
17 ** $QT_END_LICENSE$
18 **
18 **
19 ****************************************************************************/
19 ****************************************************************************/
20
20
21 #ifndef PIEANIMATION_P_H_
21 #ifndef PIEANIMATION_P_H
22 #define PIEANIMATION_P_H_
22 #define PIEANIMATION_P_H
23
23
24 #include "chartanimation_p.h"
24 #include "chartanimation_p.h"
25 #include "piechartitem_p.h"
25 #include "piechartitem_p.h"
26 #include "piesliceanimation_p.h"
26 #include "piesliceanimation_p.h"
27
27
28 QTCOMMERCIALCHART_BEGIN_NAMESPACE
28 QTCOMMERCIALCHART_BEGIN_NAMESPACE
29
29
30 class PieChartItem;
30 class PieChartItem;
31
31
32 class PieAnimation : public ChartAnimation
32 class PieAnimation : public ChartAnimation
33 {
33 {
34 Q_OBJECT
34 Q_OBJECT
35
35
36 public:
36 public:
37 PieAnimation(PieChartItem *item);
37 PieAnimation(PieChartItem *item);
38 ~PieAnimation();
38 ~PieAnimation();
39 void updateValues(const PieLayout &newValues);
39 void updateValues(const PieLayout &newValues);
40 void updateValue(QPieSlice *slice, const PieSliceData &newValue);
40 void updateValue(QPieSlice *slice, const PieSliceData &newValue);
41 void addSlice(QPieSlice *slice, const PieSliceData &endValue, bool isEmpty);
41 void addSlice(QPieSlice *slice, const PieSliceData &endValue, bool isEmpty);
42 void removeSlice(QPieSlice *slice);
42 void removeSlice(QPieSlice *slice);
43
43
44 public: // from QVariantAnimation
44 public: // from QVariantAnimation
45 void updateCurrentValue(const QVariant &value);
45 void updateCurrentValue(const QVariant &value);
46
46
47 public Q_SLOTS:
47 public Q_SLOTS:
48 void destroySliceAnimationComplete();
48 void destroySliceAnimationComplete();
49
49
50 private:
50 private:
51 PieChartItem *m_item;
51 PieChartItem *m_item;
52 QHash<QPieSlice *, PieSliceAnimation *> m_animations;
52 QHash<QPieSlice *, PieSliceAnimation *> m_animations;
53 };
53 };
54
54
55 QTCOMMERCIALCHART_END_NAMESPACE
55 QTCOMMERCIALCHART_END_NAMESPACE
56
56
57 #endif
57 #endif
@@ -1,53 +1,53
1 /****************************************************************************
1 /****************************************************************************
2 **
2 **
3 ** Copyright (C) 2012 Digia Plc
3 ** Copyright (C) 2012 Digia Plc
4 ** All rights reserved.
4 ** All rights reserved.
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 **
6 **
7 ** This file is part of the Qt Commercial Charts Add-on.
7 ** This file is part of the Qt Commercial Charts Add-on.
8 **
8 **
9 ** $QT_BEGIN_LICENSE$
9 ** $QT_BEGIN_LICENSE$
10 ** Licensees holding valid Qt Commercial licenses may use this file in
10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 ** accordance with the Qt Commercial License Agreement provided with the
11 ** accordance with the Qt Commercial License Agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia.
13 ** a written agreement between you and Digia.
14 **
14 **
15 ** If you have questions regarding the use of this file, please use
15 ** If you have questions regarding the use of this file, please use
16 ** contact form at http://qt.digia.com
16 ** contact form at http://qt.digia.com
17 ** $QT_END_LICENSE$
17 ** $QT_END_LICENSE$
18 **
18 **
19 ****************************************************************************/
19 ****************************************************************************/
20
20
21 #ifndef PIESLICEANIMATION_P_H_
21 #ifndef PIESLICEANIMATION_P_H
22 #define PIESLICEANIMATION_P_H_
22 #define PIESLICEANIMATION_P_H
23
23
24 #include "piechartitem_p.h"
24 #include "piechartitem_p.h"
25 #include <QVariantAnimation>
25 #include <QVariantAnimation>
26
26
27 QTCOMMERCIALCHART_BEGIN_NAMESPACE
27 QTCOMMERCIALCHART_BEGIN_NAMESPACE
28
28
29 class PieChartItem;
29 class PieChartItem;
30 class QPieSlice;
30 class QPieSlice;
31
31
32 class PieSliceAnimation : public QVariantAnimation
32 class PieSliceAnimation : public QVariantAnimation
33 {
33 {
34 public:
34 public:
35 PieSliceAnimation(PieChartItem *item, QPieSlice *slice);
35 PieSliceAnimation(PieChartItem *item, QPieSlice *slice);
36 ~PieSliceAnimation();
36 ~PieSliceAnimation();
37 void setValue(const PieSliceData &startValue, const PieSliceData &endValue);
37 void setValue(const PieSliceData &startValue, const PieSliceData &endValue);
38 void updateValue(const PieSliceData &endValue);
38 void updateValue(const PieSliceData &endValue);
39 PieSliceData currentSliceValue();
39 PieSliceData currentSliceValue();
40
40
41 protected:
41 protected:
42 QVariant interpolated(const QVariant &start, const QVariant &end, qreal progress) const;
42 QVariant interpolated(const QVariant &start, const QVariant &end, qreal progress) const;
43 void updateCurrentValue(const QVariant &value);
43 void updateCurrentValue(const QVariant &value);
44
44
45 private:
45 private:
46 PieChartItem *m_item;
46 PieChartItem *m_item;
47 QPieSlice *m_slice;
47 QPieSlice *m_slice;
48 PieSliceData m_currentValue;
48 PieSliceData m_currentValue;
49 };
49 };
50
50
51 QTCOMMERCIALCHART_END_NAMESPACE
51 QTCOMMERCIALCHART_END_NAMESPACE
52
52
53 #endif
53 #endif
@@ -1,52 +1,52
1 /****************************************************************************
1 /****************************************************************************
2 **
2 **
3 ** Copyright (C) 2012 Digia Plc
3 ** Copyright (C) 2012 Digia Plc
4 ** All rights reserved.
4 ** All rights reserved.
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 **
6 **
7 ** This file is part of the Qt Commercial Charts Add-on.
7 ** This file is part of the Qt Commercial Charts Add-on.
8 **
8 **
9 ** $QT_BEGIN_LICENSE$
9 ** $QT_BEGIN_LICENSE$
10 ** Licensees holding valid Qt Commercial licenses may use this file in
10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 ** accordance with the Qt Commercial License Agreement provided with the
11 ** accordance with the Qt Commercial License Agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia.
13 ** a written agreement between you and Digia.
14 **
14 **
15 ** If you have questions regarding the use of this file, please use
15 ** If you have questions regarding the use of this file, please use
16 ** contact form at http://qt.digia.com
16 ** contact form at http://qt.digia.com
17 ** $QT_END_LICENSE$
17 ** $QT_END_LICENSE$
18 **
18 **
19 ****************************************************************************/
19 ****************************************************************************/
20
20
21 #ifndef SPLINEANIMATION_P_H_
21 #ifndef SPLINEANIMATION_P_H
22 #define SPLINEANIMATION_P_H_
22 #define SPLINEANIMATION_P_H
23 #include "chartanimation_p.h"
23 #include "chartanimation_p.h"
24 #include <QPointF>
24 #include <QPointF>
25
25
26 typedef QPair<QVector<QPointF >, QVector<QPointF > > SplineVector;
26 typedef QPair<QVector<QPointF >, QVector<QPointF > > SplineVector;
27
27
28 QTCOMMERCIALCHART_BEGIN_NAMESPACE
28 QTCOMMERCIALCHART_BEGIN_NAMESPACE
29
29
30 class SplineChartItem;
30 class SplineChartItem;
31
31
32 class SplineAnimation : public ChartAnimation
32 class SplineAnimation : public ChartAnimation
33 {
33 {
34 public:
34 public:
35
35
36 SplineAnimation(SplineChartItem *item);
36 SplineAnimation(SplineChartItem *item);
37 ~SplineAnimation();
37 ~SplineAnimation();
38 void setValues(QVector<QPointF> &oldPoints, QVector<QPointF> &newPoints, QVector<QPointF> &oldContorlPoints, QVector<QPointF> &newControlPoints, int index);
38 void setValues(QVector<QPointF> &oldPoints, QVector<QPointF> &newPoints, QVector<QPointF> &oldContorlPoints, QVector<QPointF> &newControlPoints, int index);
39
39
40 protected:
40 protected:
41 QVariant interpolated(const QVariant &start, const QVariant &end, qreal progress) const;
41 QVariant interpolated(const QVariant &start, const QVariant &end, qreal progress) const;
42 void updateCurrentValue(const QVariant &value);
42 void updateCurrentValue(const QVariant &value);
43
43
44 private:
44 private:
45 SplineVector m_oldSpline;
45 SplineVector m_oldSpline;
46 SplineChartItem *m_item;
46 SplineChartItem *m_item;
47 bool m_dirty;
47 bool m_dirty;
48 };
48 };
49
49
50 QTCOMMERCIALCHART_END_NAMESPACE
50 QTCOMMERCIALCHART_END_NAMESPACE
51
51
52 #endif
52 #endif
@@ -1,50 +1,51
1 /****************************************************************************
1 /****************************************************************************
2 **
2 **
3 ** Copyright (C) 2012 Digia Plc
3 ** Copyright (C) 2012 Digia Plc
4 ** All rights reserved.
4 ** All rights reserved.
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 **
6 **
7 ** This file is part of the Qt Commercial Charts Add-on.
7 ** This file is part of the Qt Commercial Charts Add-on.
8 **
8 **
9 ** $QT_BEGIN_LICENSE$
9 ** $QT_BEGIN_LICENSE$
10 ** Licensees holding valid Qt Commercial licenses may use this file in
10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 ** accordance with the Qt Commercial License Agreement provided with the
11 ** accordance with the Qt Commercial License Agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia.
13 ** a written agreement between you and Digia.
14 **
14 **
15 ** If you have questions regarding the use of this file, please use
15 ** If you have questions regarding the use of this file, please use
16 ** contact form at http://qt.digia.com
16 ** contact form at http://qt.digia.com
17 ** $QT_END_LICENSE$
17 ** $QT_END_LICENSE$
18 **
18 **
19 ****************************************************************************/
19 ****************************************************************************/
20
20
21 #ifndef XYCHARTANIMATION_P_H_
21 #ifndef XYANIMATION_P_H
22 #define XYCHARTANIMATION_P_H_
22 #define XYANIMATION_P_H
23
23 #include "chartanimation_p.h"
24 #include "chartanimation_p.h"
24 #include <QPointF>
25 #include <QPointF>
25
26
26 QTCOMMERCIALCHART_BEGIN_NAMESPACE
27 QTCOMMERCIALCHART_BEGIN_NAMESPACE
27
28
28 class XYChartItem;
29 class XYChartItem;
29
30
30 class XYAnimation : public ChartAnimation
31 class XYAnimation : public ChartAnimation
31 {
32 {
32 public:
33 public:
33 enum Animation { LineDrawAnimation, MoveDownAnimation, MoveUpAnimation };
34 enum Animation { LineDrawAnimation, MoveDownAnimation, MoveUpAnimation };
34 XYAnimation(XYChartItem *item);
35 XYAnimation(XYChartItem *item);
35 ~XYAnimation();
36 ~XYAnimation();
36 void setValues(QVector<QPointF> &oldPoints, QVector<QPointF> &newPoints,int index);
37 void setValues(QVector<QPointF> &oldPoints, QVector<QPointF> &newPoints,int index);
37
38
38 protected:
39 protected:
39 QVariant interpolated(const QVariant &start, const QVariant &end, qreal progress ) const;
40 QVariant interpolated(const QVariant &start, const QVariant &end, qreal progress ) const;
40 void updateCurrentValue (const QVariant &value );
41 void updateCurrentValue (const QVariant &value );
41
42
42 private:
43 private:
43 XYChartItem *m_item;
44 XYChartItem *m_item;
44 QVector<QPointF> m_oldPoints;
45 QVector<QPointF> m_oldPoints;
45 bool m_dirty;
46 bool m_dirty;
46 };
47 };
47
48
48 QTCOMMERCIALCHART_END_NAMESPACE
49 QTCOMMERCIALCHART_END_NAMESPACE
49
50
50 #endif
51 #endif
@@ -1,71 +1,71
1 /****************************************************************************
1 /****************************************************************************
2 **
2 **
3 ** Copyright (C) 2012 Digia Plc
3 ** Copyright (C) 2012 Digia Plc
4 ** All rights reserved.
4 ** All rights reserved.
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 **
6 **
7 ** This file is part of the Qt Commercial Charts Add-on.
7 ** This file is part of the Qt Commercial Charts Add-on.
8 **
8 **
9 ** $QT_BEGIN_LICENSE$
9 ** $QT_BEGIN_LICENSE$
10 ** Licensees holding valid Qt Commercial licenses may use this file in
10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 ** accordance with the Qt Commercial License Agreement provided with the
11 ** accordance with the Qt Commercial License Agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia.
13 ** a written agreement between you and Digia.
14 **
14 **
15 ** If you have questions regarding the use of this file, please use
15 ** If you have questions regarding the use of this file, please use
16 ** contact form at http://qt.digia.com
16 ** contact form at http://qt.digia.com
17 ** $QT_END_LICENSE$
17 ** $QT_END_LICENSE$
18 **
18 **
19 ****************************************************************************/
19 ****************************************************************************/
20
20
21 #ifndef QAREASERIES_H_
21 #ifndef QAREASERIES_H
22 #define QAREASERIES_H_
22 #define QAREASERIES_H
23
23
24 #include <qchartglobal.h>
24 #include <qchartglobal.h>
25 #include <qseries.h>
25 #include <qseries.h>
26 #include <QPen>
26 #include <QPen>
27 #include <QBrush>
27 #include <QBrush>
28
28
29 QTCOMMERCIALCHART_BEGIN_NAMESPACE
29 QTCOMMERCIALCHART_BEGIN_NAMESPACE
30 class QLineSeries;
30 class QLineSeries;
31 class QAreaSeriesPrivate;
31 class QAreaSeriesPrivate;
32
32
33 class QTCOMMERCIALCHART_EXPORT QAreaSeries : public QSeries
33 class QTCOMMERCIALCHART_EXPORT QAreaSeries : public QSeries
34 {
34 {
35 Q_OBJECT
35 Q_OBJECT
36 public:
36 public:
37 QAreaSeries(QLineSeries *upperSeries, QLineSeries *lowerSeries = 0);
37 QAreaSeries(QLineSeries *upperSeries, QLineSeries *lowerSeries = 0);
38 virtual ~QAreaSeries();
38 virtual ~QAreaSeries();
39
39
40 public:
40 public:
41 QSeries::QSeriesType type() const;
41 QSeries::QSeriesType type() const;
42
42
43 QLineSeries* upperSeries() const;
43 QLineSeries* upperSeries() const;
44 QLineSeries* lowerSeries() const;
44 QLineSeries* lowerSeries() const;
45
45
46 void setPen(const QPen &pen);
46 void setPen(const QPen &pen);
47 QPen pen() const;
47 QPen pen() const;
48
48
49 void setBrush(const QBrush &brush);
49 void setBrush(const QBrush &brush);
50 QBrush brush() const;
50 QBrush brush() const;
51
51
52 void setPointsVisible(bool visible);
52 void setPointsVisible(bool visible);
53 bool pointsVisible() const;
53 bool pointsVisible() const;
54
54
55 bool setModel(QAbstractItemModel* model);
55 bool setModel(QAbstractItemModel* model);
56 QAbstractItemModel* model() const;
56 QAbstractItemModel* model() const;
57
57
58 Q_SIGNALS:
58 Q_SIGNALS:
59 void clicked(const QPointF &point);
59 void clicked(const QPointF &point);
60 void selected();
60 void selected();
61
61
62 private:
62 private:
63 Q_DECLARE_PRIVATE(QAreaSeries);
63 Q_DECLARE_PRIVATE(QAreaSeries);
64 Q_DISABLE_COPY(QAreaSeries);
64 Q_DISABLE_COPY(QAreaSeries);
65 friend class AreaLegendMarker;
65 friend class AreaLegendMarker;
66 friend class AreaChartItem;
66 friend class AreaChartItem;
67 };
67 };
68
68
69 QTCOMMERCIALCHART_END_NAMESPACE
69 QTCOMMERCIALCHART_END_NAMESPACE
70
70
71 #endif
71 #endif
@@ -1,65 +1,65
1 /****************************************************************************
1 /****************************************************************************
2 **
2 **
3 ** Copyright (C) 2012 Digia Plc
3 ** Copyright (C) 2012 Digia Plc
4 ** All rights reserved.
4 ** All rights reserved.
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 **
6 **
7 ** This file is part of the Qt Commercial Charts Add-on.
7 ** This file is part of the Qt Commercial Charts Add-on.
8 **
8 **
9 ** $QT_BEGIN_LICENSE$
9 ** $QT_BEGIN_LICENSE$
10 ** Licensees holding valid Qt Commercial licenses may use this file in
10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 ** accordance with the Qt Commercial License Agreement provided with the
11 ** accordance with the Qt Commercial License Agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia.
13 ** a written agreement between you and Digia.
14 **
14 **
15 ** If you have questions regarding the use of this file, please use
15 ** If you have questions regarding the use of this file, please use
16 ** contact form at http://qt.digia.com
16 ** contact form at http://qt.digia.com
17 ** $QT_END_LICENSE$
17 ** $QT_END_LICENSE$
18 **
18 **
19 ****************************************************************************/
19 ****************************************************************************/
20
20
21 // W A R N I N G
21 // W A R N I N G
22 // -------------
22 // -------------
23 //
23 //
24 // This file is not part of the QtCommercial Chart API. It exists purely as an
24 // This file is not part of the QtCommercial Chart API. It exists purely as an
25 // implementation detail. This header file may change from version to
25 // implementation detail. This header file may change from version to
26 // version without notice, or even be removed.
26 // version without notice, or even be removed.
27 //
27 //
28 // We mean it.
28 // We mean it.
29
29
30 #ifndef QAREASERIES_P_H_
30 #ifndef QAREASERIES_P_H
31 #define QAREASERIES_P_H_
31 #define QAREASERIES_P_H
32
32
33 #include "qseries_p.h"
33 #include "qseries_p.h"
34
34
35 QTCOMMERCIALCHART_BEGIN_NAMESPACE
35 QTCOMMERCIALCHART_BEGIN_NAMESPACE
36
36
37 class QAreaSeries;
37 class QAreaSeries;
38
38
39 class QAreaSeriesPrivate: public QSeriesPrivate
39 class QAreaSeriesPrivate: public QSeriesPrivate
40 {
40 {
41 Q_OBJECT
41 Q_OBJECT
42
42
43 public:
43 public:
44 QAreaSeriesPrivate(QLineSeries *upperSeries, QLineSeries *lowerSeries,QAreaSeries* q);
44 QAreaSeriesPrivate(QLineSeries *upperSeries, QLineSeries *lowerSeries,QAreaSeries* q);
45
45
46 void scaleDomain(Domain& domain);
46 void scaleDomain(Domain& domain);
47 Chart* createGraphics(ChartPresenter* presenter);
47 Chart* createGraphics(ChartPresenter* presenter);
48 QList<LegendMarker*> createLegendMarker(QLegend* legend);
48 QList<LegendMarker*> createLegendMarker(QLegend* legend);
49
49
50 Q_SIGNALS:
50 Q_SIGNALS:
51 void updated();
51 void updated();
52
52
53 protected:
53 protected:
54 QBrush m_brush;
54 QBrush m_brush;
55 QPen m_pen;
55 QPen m_pen;
56 QLineSeries* m_upperSeries;
56 QLineSeries* m_upperSeries;
57 QLineSeries* m_lowerSeries;
57 QLineSeries* m_lowerSeries;
58 bool m_pointsVisible;
58 bool m_pointsVisible;
59 private:
59 private:
60 Q_DECLARE_PUBLIC(QAreaSeries);
60 Q_DECLARE_PUBLIC(QAreaSeries);
61 };
61 };
62
62
63 QTCOMMERCIALCHART_END_NAMESPACE
63 QTCOMMERCIALCHART_END_NAMESPACE
64
64
65 #endif
65 #endif
@@ -1,143 +1,143
1 /****************************************************************************
1 /****************************************************************************
2 **
2 **
3 ** Copyright (C) 2012 Digia Plc
3 ** Copyright (C) 2012 Digia Plc
4 ** All rights reserved.
4 ** All rights reserved.
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 **
6 **
7 ** This file is part of the Qt Commercial Charts Add-on.
7 ** This file is part of the Qt Commercial Charts Add-on.
8 **
8 **
9 ** $QT_BEGIN_LICENSE$
9 ** $QT_BEGIN_LICENSE$
10 ** Licensees holding valid Qt Commercial licenses may use this file in
10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 ** accordance with the Qt Commercial License Agreement provided with the
11 ** accordance with the Qt Commercial License Agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia.
13 ** a written agreement between you and Digia.
14 **
14 **
15 ** If you have questions regarding the use of this file, please use
15 ** If you have questions regarding the use of this file, please use
16 ** contact form at http://qt.digia.com
16 ** contact form at http://qt.digia.com
17 ** $QT_END_LICENSE$
17 ** $QT_END_LICENSE$
18 **
18 **
19 ****************************************************************************/
19 ****************************************************************************/
20
20
21 #ifndef AXISITEM_H_
21 #ifndef AXIS_H
22 #define AXISITEM_H_
22 #define AXIS_H
23
23
24 #include "qchartglobal.h"
24 #include "qchartglobal.h"
25 #include "chart_p.h"
25 #include "chart_p.h"
26 #include <QGraphicsItem>
26 #include <QGraphicsItem>
27
27
28 QTCOMMERCIALCHART_BEGIN_NAMESPACE
28 QTCOMMERCIALCHART_BEGIN_NAMESPACE
29
29
30 class QChartAxis;
30 class QChartAxis;
31 class ChartPresenter;
31 class ChartPresenter;
32
32
33 class Axis : public Chart
33 class Axis : public Chart
34 {
34 {
35 Q_OBJECT
35 Q_OBJECT
36 public:
36 public:
37 enum AxisType{X_AXIS,Y_AXIS};
37 enum AxisType{X_AXIS,Y_AXIS};
38
38
39 Axis(QChartAxis *axis, ChartPresenter *presenter, AxisType type = X_AXIS);
39 Axis(QChartAxis *axis, ChartPresenter *presenter, AxisType type = X_AXIS);
40 ~Axis();
40 ~Axis();
41
41
42 AxisType axisType() const { return m_type; }
42 AxisType axisType() const { return m_type; }
43
43
44 void setAxisOpacity(qreal opacity);
44 void setAxisOpacity(qreal opacity);
45 qreal axisOpacity() const;
45 qreal axisOpacity() const;
46
46
47 void setGridOpacity(qreal opacity);
47 void setGridOpacity(qreal opacity);
48 qreal gridOpacity() const;
48 qreal gridOpacity() const;
49
49
50 void setLabelsOpacity(qreal opacity);
50 void setLabelsOpacity(qreal opacity);
51 qreal labelsOpacity() const;
51 qreal labelsOpacity() const;
52
52
53 void setShadesOpacity(qreal opacity);
53 void setShadesOpacity(qreal opacity);
54 qreal shadesOpacity() const;
54 qreal shadesOpacity() const;
55
55
56 void setLabelsAngle(int angle);
56 void setLabelsAngle(int angle);
57 int labelsAngle()const { return m_labelsAngle; }
57 int labelsAngle()const { return m_labelsAngle; }
58
58
59 void setShadesBrush(const QBrush &brush);
59 void setShadesBrush(const QBrush &brush);
60 void setShadesPen(const QPen &pen);
60 void setShadesPen(const QPen &pen);
61
61
62 void setAxisPen(const QPen &pen);
62 void setAxisPen(const QPen &pen);
63 void setGridPen(const QPen &pen);
63 void setGridPen(const QPen &pen);
64
64
65 void setLabelsPen(const QPen &pen);
65 void setLabelsPen(const QPen &pen);
66 void setLabelsBrush(const QBrush &brush);
66 void setLabelsBrush(const QBrush &brush);
67 void setLabelsFont(const QFont &font);
67 void setLabelsFont(const QFont &font);
68
68
69 inline QRectF geometry() const { return m_rect; }
69 inline QRectF geometry() const { return m_rect; }
70 inline QVector<qreal> layout() { return m_layoutVector; }
70 inline QVector<qreal> layout() { return m_layoutVector; }
71
71
72 public Q_SLOTS:
72 public Q_SLOTS:
73 void handleAxisUpdated();
73 void handleAxisUpdated();
74 void handleAxisCategoriesUpdated();
74 void handleAxisCategoriesUpdated();
75 void handleRangeChanged(qreal min , qreal max,int tickCount);
75 void handleRangeChanged(qreal min , qreal max,int tickCount);
76 void handleGeometryChanged(const QRectF &size);
76 void handleGeometryChanged(const QRectF &size);
77
77
78
78
79 private:
79 private:
80 inline bool isEmpty();
80 inline bool isEmpty();
81 void createItems(int count);
81 void createItems(int count);
82 void deleteItems(int count);
82 void deleteItems(int count);
83
83
84 QVector<qreal> calculateLayout() const;
84 QVector<qreal> calculateLayout() const;
85 void updateLayout(QVector<qreal> &layout);
85 void updateLayout(QVector<qreal> &layout);
86 void setLayout(QVector<qreal> &layout);
86 void setLayout(QVector<qreal> &layout);
87
87
88 bool createLabels(QStringList &labels,qreal min, qreal max,int ticks) const;
88 bool createLabels(QStringList &labels,qreal min, qreal max,int ticks) const;
89 void axisSelected();
89 void axisSelected();
90
90
91 private:
91 private:
92 QChartAxis* m_chartAxis;
92 QChartAxis* m_chartAxis;
93 AxisType m_type;
93 AxisType m_type;
94 QRectF m_rect;
94 QRectF m_rect;
95 int m_labelsAngle;
95 int m_labelsAngle;
96 QScopedPointer<QGraphicsItemGroup> m_grid;
96 QScopedPointer<QGraphicsItemGroup> m_grid;
97 QScopedPointer<QGraphicsItemGroup> m_shades;
97 QScopedPointer<QGraphicsItemGroup> m_shades;
98 QScopedPointer<QGraphicsItemGroup> m_labels;
98 QScopedPointer<QGraphicsItemGroup> m_labels;
99 QScopedPointer<QGraphicsItemGroup> m_axis;
99 QScopedPointer<QGraphicsItemGroup> m_axis;
100 QVector<qreal> m_layoutVector;
100 QVector<qreal> m_layoutVector;
101 qreal m_min;
101 qreal m_min;
102 qreal m_max;
102 qreal m_max;
103 int m_ticksCount;
103 int m_ticksCount;
104
104
105 friend class AxisAnimation;
105 friend class AxisAnimation;
106 friend class AxisItem;
106 friend class AxisItem;
107
107
108 };
108 };
109
109
110 class AxisItem: public QGraphicsLineItem
110 class AxisItem: public QGraphicsLineItem
111 {
111 {
112
112
113 public:
113 public:
114 AxisItem(Axis *axis, QGraphicsItem *parent = 0) : QGraphicsLineItem(parent), m_axis(axis) {}
114 AxisItem(Axis *axis, QGraphicsItem *parent = 0) : QGraphicsLineItem(parent), m_axis(axis) {}
115
115
116 protected:
116 protected:
117 void mousePressEvent(QGraphicsSceneMouseEvent *event)
117 void mousePressEvent(QGraphicsSceneMouseEvent *event)
118 {
118 {
119 Q_UNUSED(event)
119 Q_UNUSED(event)
120 m_axis->axisSelected();
120 m_axis->axisSelected();
121 }
121 }
122
122
123 QRectF boundingRect() const
123 QRectF boundingRect() const
124 {
124 {
125 return shape().boundingRect();
125 return shape().boundingRect();
126 }
126 }
127
127
128 QPainterPath shape() const
128 QPainterPath shape() const
129 {
129 {
130 QPainterPath path = QGraphicsLineItem::shape();
130 QPainterPath path = QGraphicsLineItem::shape();
131 QRectF rect = path.boundingRect();
131 QRectF rect = path.boundingRect();
132 path.addRect(rect.adjusted(0,0,m_axis->axisType()!=Axis::X_AXIS?8:0,m_axis->axisType()!=Axis::Y_AXIS?8:0));
132 path.addRect(rect.adjusted(0,0,m_axis->axisType()!=Axis::X_AXIS?8:0,m_axis->axisType()!=Axis::Y_AXIS?8:0));
133 return path;
133 return path;
134 }
134 }
135
135
136 private:
136 private:
137 Axis* m_axis;
137 Axis* m_axis;
138
138
139 };
139 };
140
140
141 QTCOMMERCIALCHART_END_NAMESPACE
141 QTCOMMERCIALCHART_END_NAMESPACE
142
142
143 #endif /* AXISITEM_H_ */
143 #endif /* AXISITEM_H_ */
@@ -1,108 +1,108
1 /****************************************************************************
1 /****************************************************************************
2 **
2 **
3 ** Copyright (C) 2012 Digia Plc
3 ** Copyright (C) 2012 Digia Plc
4 ** All rights reserved.
4 ** All rights reserved.
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 **
6 **
7 ** This file is part of the Qt Commercial Charts Add-on.
7 ** This file is part of the Qt Commercial Charts Add-on.
8 **
8 **
9 ** $QT_BEGIN_LICENSE$
9 ** $QT_BEGIN_LICENSE$
10 ** Licensees holding valid Qt Commercial licenses may use this file in
10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 ** accordance with the Qt Commercial License Agreement provided with the
11 ** accordance with the Qt Commercial License Agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia.
13 ** a written agreement between you and Digia.
14 **
14 **
15 ** If you have questions regarding the use of this file, please use
15 ** If you have questions regarding the use of this file, please use
16 ** contact form at http://qt.digia.com
16 ** contact form at http://qt.digia.com
17 ** $QT_END_LICENSE$
17 ** $QT_END_LICENSE$
18 **
18 **
19 ****************************************************************************/
19 ****************************************************************************/
20
20
21 #ifndef QCHARTAXIS_H_
21 #ifndef QCHARTAXIS_H
22 #define QCHARTAXIS_H_
22 #define QCHARTAXIS_H
23
23
24 #include <qchartglobal.h>
24 #include <qchartglobal.h>
25 #include <qchartaxiscategories.h>
25 #include <qchartaxiscategories.h>
26 #include <QPen>
26 #include <QPen>
27 #include <QFont>
27 #include <QFont>
28
28
29 QTCOMMERCIALCHART_BEGIN_NAMESPACE
29 QTCOMMERCIALCHART_BEGIN_NAMESPACE
30
30
31 class QChartAxisPrivate;
31 class QChartAxisPrivate;
32
32
33 class QTCOMMERCIALCHART_EXPORT QChartAxis : public QObject
33 class QTCOMMERCIALCHART_EXPORT QChartAxis : public QObject
34 {
34 {
35 Q_OBJECT
35 Q_OBJECT
36 public:
36 public:
37
37
38 QChartAxis(QObject *parent =0);
38 QChartAxis(QObject *parent =0);
39 ~QChartAxis();
39 ~QChartAxis();
40
40
41 //axis handling
41 //axis handling
42 bool isAxisVisible() const;
42 bool isAxisVisible() const;
43 void setAxisVisible(bool visible);
43 void setAxisVisible(bool visible);
44 void setAxisPen(const QPen &pen);
44 void setAxisPen(const QPen &pen);
45 QPen axisPen() const;
45 QPen axisPen() const;
46
46
47 //grid handling
47 //grid handling
48 bool isGridLineVisible() const;
48 bool isGridLineVisible() const;
49 void setGridLineVisible(bool visible);
49 void setGridLineVisible(bool visible);
50 void setGridLinePen(const QPen &pen);
50 void setGridLinePen(const QPen &pen);
51 QPen gridLinePen() const;
51 QPen gridLinePen() const;
52
52
53 //labels handling
53 //labels handling
54 bool labelsVisible() const;
54 bool labelsVisible() const;
55 void setLabelsVisible(bool visible);
55 void setLabelsVisible(bool visible);
56 void setLabelsPen(const QPen &pen);
56 void setLabelsPen(const QPen &pen);
57 QPen labelsPen() const;
57 QPen labelsPen() const;
58 void setLabelsBrush(const QBrush &brush);
58 void setLabelsBrush(const QBrush &brush);
59 QBrush labelsBrush() const;
59 QBrush labelsBrush() const;
60 void setLabelsFont(const QFont &font);
60 void setLabelsFont(const QFont &font);
61 QFont labelsFont() const;
61 QFont labelsFont() const;
62 void setLabelsAngle(int angle);
62 void setLabelsAngle(int angle);
63 int labelsAngle() const;
63 int labelsAngle() const;
64
64
65 //shades handling
65 //shades handling
66 bool shadesVisible() const;
66 bool shadesVisible() const;
67 void setShadesVisible(bool visible);
67 void setShadesVisible(bool visible);
68 void setShadesPen(const QPen &pen);
68 void setShadesPen(const QPen &pen);
69 QPen shadesPen() const;
69 QPen shadesPen() const;
70 void setShadesBrush(const QBrush &brush);
70 void setShadesBrush(const QBrush &brush);
71 QBrush shadesBrush() const;
71 QBrush shadesBrush() const;
72 void setShadesOpacity(qreal opacity);
72 void setShadesOpacity(qreal opacity);
73 qreal shadesOpacity() const;
73 qreal shadesOpacity() const;
74
74
75 //range handling
75 //range handling
76 void setMin(qreal min);
76 void setMin(qreal min);
77 qreal min() const;
77 qreal min() const;
78 void setMax(qreal max);
78 void setMax(qreal max);
79 qreal max() const;
79 qreal max() const;
80 void setRange(qreal min, qreal max);
80 void setRange(qreal min, qreal max);
81
81
82 //ticks handling
82 //ticks handling
83 void setTicksCount(int count);
83 void setTicksCount(int count);
84 int ticksCount() const;
84 int ticksCount() const;
85
85
86 void setNiceNumbers(bool enable);
86 void setNiceNumbers(bool enable);
87 bool niceNumbers() const;
87 bool niceNumbers() const;
88
88
89 QChartAxisCategories* categories();
89 QChartAxisCategories* categories();
90
90
91 void show();
91 void show();
92 void hide();
92 void hide();
93
93
94 Q_SIGNALS:
94 Q_SIGNALS:
95 void minChanged(qreal min);
95 void minChanged(qreal min);
96 void maxChanged(qreal max);
96 void maxChanged(qreal max);
97 void rangeChanged(qreal min, qreal max);
97 void rangeChanged(qreal min, qreal max);
98 void ticksCountChanged(int count);
98 void ticksCountChanged(int count);
99
99
100 private:
100 private:
101 QScopedPointer<QChartAxisPrivate> d_ptr;
101 QScopedPointer<QChartAxisPrivate> d_ptr;
102 Q_DISABLE_COPY(QChartAxis);
102 Q_DISABLE_COPY(QChartAxis);
103 friend class ChartDataSet;
103 friend class ChartDataSet;
104 friend class Axis;
104 friend class Axis;
105 };
105 };
106
106
107 QTCOMMERCIALCHART_END_NAMESPACE
107 QTCOMMERCIALCHART_END_NAMESPACE
108 #endif /* QCHARTAXIS_H_ */
108 #endif /* QCHARTAXIS_H_ */
@@ -1,85 +1,85
1 /****************************************************************************
1 /****************************************************************************
2 **
2 **
3 ** Copyright (C) 2012 Digia Plc
3 ** Copyright (C) 2012 Digia Plc
4 ** All rights reserved.
4 ** All rights reserved.
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 **
6 **
7 ** This file is part of the Qt Commercial Charts Add-on.
7 ** This file is part of the Qt Commercial Charts Add-on.
8 **
8 **
9 ** $QT_BEGIN_LICENSE$
9 ** $QT_BEGIN_LICENSE$
10 ** Licensees holding valid Qt Commercial licenses may use this file in
10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 ** accordance with the Qt Commercial License Agreement provided with the
11 ** accordance with the Qt Commercial License Agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia.
13 ** a written agreement between you and Digia.
14 **
14 **
15 ** If you have questions regarding the use of this file, please use
15 ** If you have questions regarding the use of this file, please use
16 ** contact form at http://qt.digia.com
16 ** contact form at http://qt.digia.com
17 ** $QT_END_LICENSE$
17 ** $QT_END_LICENSE$
18 **
18 **
19 ****************************************************************************/
19 ****************************************************************************/
20
20
21 // W A R N I N G
21 // W A R N I N G
22 // -------------
22 // -------------
23 //
23 //
24 // This file is not part of the QtCommercial Chart API. It exists purely as an
24 // This file is not part of the QtCommercial Chart API. It exists purely as an
25 // implementation detail. This header file may change from version to
25 // implementation detail. This header file may change from version to
26 // version without notice, or even be removed.
26 // version without notice, or even be removed.
27 //
27 //
28 // We mean it.
28 // We mean it.
29
29
30 #ifndef QCHARTAXIS_P_H_
30 #ifndef QCHARTAXIS_P_H
31 #define QCHARTAXIS_P_H_
31 #define QCHARTAXIS_P_H
32
32
33 #include "qchartaxis.h"
33 #include "qchartaxis.h"
34
34
35 QTCOMMERCIALCHART_BEGIN_NAMESPACE
35 QTCOMMERCIALCHART_BEGIN_NAMESPACE
36
36
37 class QChartAxisPrivate : public QObject
37 class QChartAxisPrivate : public QObject
38 {
38 {
39 Q_OBJECT
39 Q_OBJECT
40 public:
40 public:
41 QChartAxisPrivate(QChartAxis *q);
41 QChartAxisPrivate(QChartAxis *q);
42 ~QChartAxisPrivate();
42 ~QChartAxisPrivate();
43
43
44 Q_SIGNALS:
44 Q_SIGNALS:
45 void updated();
45 void updated();
46 void changed(qreal min, qreal max, int tickCount,bool niceNumbers);
46 void changed(qreal min, qreal max, int tickCount,bool niceNumbers);
47
47
48 public Q_SLOTS:
48 public Q_SLOTS:
49 void handleAxisRangeChanged(qreal min, qreal max,int count);
49 void handleAxisRangeChanged(qreal min, qreal max,int count);
50
50
51 private:
51 private:
52 QChartAxis *q_ptr;
52 QChartAxis *q_ptr;
53
53
54 bool m_axisVisible;
54 bool m_axisVisible;
55 QPen m_axisPen;
55 QPen m_axisPen;
56 QBrush m_axisBrush;
56 QBrush m_axisBrush;
57
57
58 bool m_gridLineVisible;
58 bool m_gridLineVisible;
59 QPen m_gridLinePen;
59 QPen m_gridLinePen;
60
60
61 bool m_labelsVisible;
61 bool m_labelsVisible;
62 QPen m_labelsPen;
62 QPen m_labelsPen;
63 QBrush m_labelsBrush;
63 QBrush m_labelsBrush;
64 QFont m_labelsFont;
64 QFont m_labelsFont;
65 int m_labelsAngle;
65 int m_labelsAngle;
66
66
67 bool m_shadesVisible;
67 bool m_shadesVisible;
68 QPen m_shadesPen;
68 QPen m_shadesPen;
69 QBrush m_shadesBrush;
69 QBrush m_shadesBrush;
70 qreal m_shadesOpacity;
70 qreal m_shadesOpacity;
71
71
72 qreal m_min;
72 qreal m_min;
73 qreal m_max;
73 qreal m_max;
74
74
75 int m_ticksCount;
75 int m_ticksCount;
76 QChartAxisCategories m_category;
76 QChartAxisCategories m_category;
77
77
78 bool m_niceNumbers;
78 bool m_niceNumbers;
79
79
80 friend class QChartAxis;
80 friend class QChartAxis;
81 };
81 };
82
82
83 QTCOMMERCIALCHART_END_NAMESPACE
83 QTCOMMERCIALCHART_END_NAMESPACE
84
84
85 #endif
85 #endif
@@ -1,56 +1,56
1 /****************************************************************************
1 /****************************************************************************
2 **
2 **
3 ** Copyright (C) 2012 Digia Plc
3 ** Copyright (C) 2012 Digia Plc
4 ** All rights reserved.
4 ** All rights reserved.
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 **
6 **
7 ** This file is part of the Qt Commercial Charts Add-on.
7 ** This file is part of the Qt Commercial Charts Add-on.
8 **
8 **
9 ** $QT_BEGIN_LICENSE$
9 ** $QT_BEGIN_LICENSE$
10 ** Licensees holding valid Qt Commercial licenses may use this file in
10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 ** accordance with the Qt Commercial License Agreement provided with the
11 ** accordance with the Qt Commercial License Agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia.
13 ** a written agreement between you and Digia.
14 **
14 **
15 ** If you have questions regarding the use of this file, please use
15 ** If you have questions regarding the use of this file, please use
16 ** contact form at http://qt.digia.com
16 ** contact form at http://qt.digia.com
17 ** $QT_END_LICENSE$
17 ** $QT_END_LICENSE$
18 **
18 **
19 ****************************************************************************/
19 ****************************************************************************/
20
20
21 #ifndef QCHARTAXISCATEGORIES_H_
21 #ifndef QCHARTAXISCATEGORIES_H
22 #define QCHARTAXISCATEGORIES_H_
22 #define QCHARTAXISCATEGORIES_H
23
23
24 #include <qchartglobal.h>
24 #include <qchartglobal.h>
25 #include <qbarseries.h>
25 #include <qbarseries.h>
26
26
27 QTCOMMERCIALCHART_BEGIN_NAMESPACE
27 QTCOMMERCIALCHART_BEGIN_NAMESPACE
28
28
29 class QChartAxisCategoriesPrivate;
29 class QChartAxisCategoriesPrivate;
30
30
31 class QTCOMMERCIALCHART_EXPORT QChartAxisCategories : public QObject
31 class QTCOMMERCIALCHART_EXPORT QChartAxisCategories : public QObject
32 {
32 {
33 Q_OBJECT
33 Q_OBJECT
34 private:
34 private:
35 QChartAxisCategories();
35 QChartAxisCategories();
36 public:
36 public:
37 ~QChartAxisCategories();
37 ~QChartAxisCategories();
38
38
39 void insert(const QBarCategories &category);
39 void insert(const QBarCategories &category);
40 void insert(qreal value,QString label);
40 void insert(qreal value,QString label);
41 void remove(qreal value);
41 void remove(qreal value);
42 QList<qreal> values() const;
42 QList<qreal> values() const;
43 QString label(qreal value) const;
43 QString label(qreal value) const;
44 void clear();
44 void clear();
45 int count();
45 int count();
46
46
47 private:
47 private:
48 QScopedPointer<QChartAxisCategoriesPrivate> d_ptr;
48 QScopedPointer<QChartAxisCategoriesPrivate> d_ptr;
49 friend class QChartAxisPrivate;
49 friend class QChartAxisPrivate;
50 friend class Axis;
50 friend class Axis;
51 };
51 };
52
52
53
53
54 QTCOMMERCIALCHART_END_NAMESPACE
54 QTCOMMERCIALCHART_END_NAMESPACE
55
55
56 #endif /* QCHARTAXISCATEGORIES_H_ */
56 #endif /* QCHARTAXISCATEGORIES_H_ */
@@ -1,56 +1,56
1 /****************************************************************************
1 /****************************************************************************
2 **
2 **
3 ** Copyright (C) 2012 Digia Plc
3 ** Copyright (C) 2012 Digia Plc
4 ** All rights reserved.
4 ** All rights reserved.
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 **
6 **
7 ** This file is part of the Qt Commercial Charts Add-on.
7 ** This file is part of the Qt Commercial Charts Add-on.
8 **
8 **
9 ** $QT_BEGIN_LICENSE$
9 ** $QT_BEGIN_LICENSE$
10 ** Licensees holding valid Qt Commercial licenses may use this file in
10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 ** accordance with the Qt Commercial License Agreement provided with the
11 ** accordance with the Qt Commercial License Agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia.
13 ** a written agreement between you and Digia.
14 **
14 **
15 ** If you have questions regarding the use of this file, please use
15 ** If you have questions regarding the use of this file, please use
16 ** contact form at http://qt.digia.com
16 ** contact form at http://qt.digia.com
17 ** $QT_END_LICENSE$
17 ** $QT_END_LICENSE$
18 **
18 **
19 ****************************************************************************/
19 ****************************************************************************/
20
20
21 // W A R N I N G
21 // W A R N I N G
22 // -------------
22 // -------------
23 //
23 //
24 // This file is not part of the QtCommercial Chart API. It exists purely as an
24 // This file is not part of the QtCommercial Chart API. It exists purely as an
25 // implementation detail. This header file may change from version to
25 // implementation detail. This header file may change from version to
26 // version without notice, or even be removed.
26 // version without notice, or even be removed.
27 //
27 //
28 // We mean it.
28 // We mean it.
29
29
30 #ifndef QCHARTAXISCATEGORIES_P_H_
30 #ifndef QCHARTAXISCATEGORIES_P_H
31 #define QCHARTAXISCATEGORIES_P_H_
31 #define QCHARTAXISCATEGORIES_P_H
32
32
33 #include "qchartaxiscategories.h"
33 #include "qchartaxiscategories.h"
34
34
35 QTCOMMERCIALCHART_BEGIN_NAMESPACE
35 QTCOMMERCIALCHART_BEGIN_NAMESPACE
36
36
37 class QChartAxisCategoriesPrivate : public QObject
37 class QChartAxisCategoriesPrivate : public QObject
38 {
38 {
39 Q_OBJECT
39 Q_OBJECT
40 public:
40 public:
41 QChartAxisCategoriesPrivate(QChartAxisCategories *q);
41 QChartAxisCategoriesPrivate(QChartAxisCategories *q);
42 ~QChartAxisCategoriesPrivate();
42 ~QChartAxisCategoriesPrivate();
43
43
44 Q_SIGNALS:
44 Q_SIGNALS:
45 void updated();
45 void updated();
46
46
47 private:
47 private:
48 QChartAxisCategories *q_ptr;
48 QChartAxisCategories *q_ptr;
49 QMap<qreal,QString> m_map;
49 QMap<qreal,QString> m_map;
50 friend class QChartAxisCategories;
50 friend class QChartAxisCategories;
51
51
52 };
52 };
53
53
54 QTCOMMERCIALCHART_END_NAMESPACE
54 QTCOMMERCIALCHART_END_NAMESPACE
55
55
56 #endif
56 #endif
@@ -1,198 +1,198
1 /****************************************************************************
1 /****************************************************************************
2 **
2 **
3 ** Copyright (C) 2012 Digia Plc
3 ** Copyright (C) 2012 Digia Plc
4 ** All rights reserved.
4 ** All rights reserved.
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 **
6 **
7 ** This file is part of the Qt Commercial Charts Add-on.
7 ** This file is part of the Qt Commercial Charts Add-on.
8 **
8 **
9 ** $QT_BEGIN_LICENSE$
9 ** $QT_BEGIN_LICENSE$
10 ** Licensees holding valid Qt Commercial licenses may use this file in
10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 ** accordance with the Qt Commercial License Agreement provided with the
11 ** accordance with the Qt Commercial License Agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia.
13 ** a written agreement between you and Digia.
14 **
14 **
15 ** If you have questions regarding the use of this file, please use
15 ** If you have questions regarding the use of this file, please use
16 ** contact form at http://qt.digia.com
16 ** contact form at http://qt.digia.com
17 ** $QT_END_LICENSE$
17 ** $QT_END_LICENSE$
18 **
18 **
19 ****************************************************************************/
19 ****************************************************************************/
20
20
21 #include "barchartmodel_p.h"
22 #include "qbarset.h"
21 #include <limits.h>
23 #include <limits.h>
22 #include <QVector>
24 #include <QVector>
23 #include <QDebug>
25 #include <QDebug>
24 #include "barchartmodel_p.h"
25 #include "qbarset.h"
26
26
27 QTCOMMERCIALCHART_BEGIN_NAMESPACE
27 QTCOMMERCIALCHART_BEGIN_NAMESPACE
28
28
29 BarChartModel::BarChartModel(QStringList categories, QObject *parent) : QObject(parent),
29 BarChartModel::BarChartModel(QStringList categories, QObject *parent) : QObject(parent),
30 m_category(categories)
30 m_category(categories)
31 {
31 {
32 }
32 }
33
33
34 QStringList BarChartModel::category()
34 QStringList BarChartModel::category()
35 {
35 {
36 return m_category;
36 return m_category;
37 }
37 }
38
38
39 void BarChartModel::appendBarSet(QBarSet *set)
39 void BarChartModel::appendBarSet(QBarSet *set)
40 {
40 {
41 m_dataModel.append(set);
41 m_dataModel.append(set);
42 }
42 }
43
43
44 void BarChartModel::removeBarSet(QBarSet *set)
44 void BarChartModel::removeBarSet(QBarSet *set)
45 {
45 {
46 if (m_dataModel.contains(set)) {
46 if (m_dataModel.contains(set)) {
47 m_dataModel.removeOne(set);
47 m_dataModel.removeOne(set);
48 }
48 }
49 }
49 }
50
50
51 void BarChartModel::insertBarSet(int i, QBarSet *set)
51 void BarChartModel::insertBarSet(int i, QBarSet *set)
52 {
52 {
53 m_dataModel.insert(i, set);
53 m_dataModel.insert(i, set);
54 }
54 }
55
55
56 void BarChartModel::insertCategory(int i, QString category)
56 void BarChartModel::insertCategory(int i, QString category)
57 {
57 {
58 m_category.insert(i, category);
58 m_category.insert(i, category);
59 }
59 }
60
60
61 void BarChartModel::removeCategory(int i)
61 void BarChartModel::removeCategory(int i)
62 {
62 {
63 m_category.removeAt(i);
63 m_category.removeAt(i);
64 }
64 }
65
65
66 QBarSet* BarChartModel::barsetAt(int index) const
66 QBarSet* BarChartModel::barsetAt(int index) const
67 {
67 {
68 return m_dataModel.at(index);
68 return m_dataModel.at(index);
69 }
69 }
70
70
71 QList<QBarSet*> BarChartModel::barSets() const
71 QList<QBarSet*> BarChartModel::barSets() const
72 {
72 {
73 return m_dataModel;
73 return m_dataModel;
74 }
74 }
75
75
76 int BarChartModel::barsetCount() const
76 int BarChartModel::barsetCount() const
77 {
77 {
78 return m_dataModel.count();
78 return m_dataModel.count();
79 }
79 }
80
80
81 int BarChartModel::categoryCount() const
81 int BarChartModel::categoryCount() const
82 {
82 {
83 return m_category.count();
83 return m_category.count();
84 }
84 }
85
85
86 qreal BarChartModel::min() const
86 qreal BarChartModel::min() const
87 {
87 {
88 Q_ASSERT(m_dataModel.count() > 0);
88 Q_ASSERT(m_dataModel.count() > 0);
89 // TODO: make min and max members and update them when data changes.
89 // TODO: make min and max members and update them when data changes.
90 // This is slower since they are checked every time, even if data is same since previous call.
90 // This is slower since they are checked every time, even if data is same since previous call.
91 qreal min = INT_MAX;
91 qreal min = INT_MAX;
92
92
93 for (int i = 0; i < m_dataModel.count(); i++) {
93 for (int i = 0; i < m_dataModel.count(); i++) {
94 int itemCount = m_dataModel.at(i)->count();
94 int itemCount = m_dataModel.at(i)->count();
95 for (int j = 0; j < itemCount; j++) {
95 for (int j = 0; j < itemCount; j++) {
96 qreal temp = m_dataModel.at(i)->valueAt(j);
96 qreal temp = m_dataModel.at(i)->valueAt(j);
97 if (temp < min)
97 if (temp < min)
98 min = temp;
98 min = temp;
99 }
99 }
100 }
100 }
101 return min;
101 return min;
102 }
102 }
103
103
104 qreal BarChartModel::max() const
104 qreal BarChartModel::max() const
105 {
105 {
106 if (m_dataModel.count() == 0) return 0;
106 if (m_dataModel.count() == 0) return 0;
107 // TODO: make min and max members and update them when data changes.
107 // TODO: make min and max members and update them when data changes.
108 // This is slower since they are checked every time, even if data is same since previous call.
108 // This is slower since they are checked every time, even if data is same since previous call.
109 qreal max = INT_MIN;
109 qreal max = INT_MIN;
110
110
111 for (int i = 0; i < m_dataModel.count(); i++) {
111 for (int i = 0; i < m_dataModel.count(); i++) {
112 int itemCount = m_dataModel.at(i)->count();
112 int itemCount = m_dataModel.at(i)->count();
113 for (int j = 0; j < itemCount; j++) {
113 for (int j = 0; j < itemCount; j++) {
114 qreal temp = m_dataModel.at(i)->valueAt(j);
114 qreal temp = m_dataModel.at(i)->valueAt(j);
115 if (temp > max)
115 if (temp > max)
116 max = temp;
116 max = temp;
117 }
117 }
118 }
118 }
119
119
120 return max;
120 return max;
121 }
121 }
122
122
123 qreal BarChartModel::valueAt(int set, int category) const
123 qreal BarChartModel::valueAt(int set, int category) const
124 {
124 {
125 if ((set < 0) || (set >= m_dataModel.count())) {
125 if ((set < 0) || (set >= m_dataModel.count())) {
126 // No set, no value.
126 // No set, no value.
127 return 0;
127 return 0;
128 } else if ((category < 0) || (category >= m_dataModel.at(set)->count())) {
128 } else if ((category < 0) || (category >= m_dataModel.at(set)->count())) {
129 // No category, no value.
129 // No category, no value.
130 return 0;
130 return 0;
131 }
131 }
132
132
133 return m_dataModel.at(set)->valueAt(category);
133 return m_dataModel.at(set)->valueAt(category);
134 }
134 }
135
135
136 qreal BarChartModel::percentageAt(int set, int category) const
136 qreal BarChartModel::percentageAt(int set, int category) const
137 {
137 {
138 if ((set < 0) || (set >= m_dataModel.count())) {
138 if ((set < 0) || (set >= m_dataModel.count())) {
139 // No set, no value.
139 // No set, no value.
140 return 0;
140 return 0;
141 } else if ((category < 0) || (category >= m_dataModel.at(set)->count())) {
141 } else if ((category < 0) || (category >= m_dataModel.at(set)->count())) {
142 // No category, no value.
142 // No category, no value.
143 return 0;
143 return 0;
144 }
144 }
145
145
146 qreal value = m_dataModel.at(set)->valueAt(category);
146 qreal value = m_dataModel.at(set)->valueAt(category);
147 qreal total = categorySum(category);
147 qreal total = categorySum(category);
148 if ( qFuzzyCompare(total, 0) )
148 if ( qFuzzyCompare(total, 0) )
149 return 0;
149 return 0;
150
150
151 return value / total;
151 return value / total;
152 }
152 }
153
153
154 qreal BarChartModel::categorySum(int category) const
154 qreal BarChartModel::categorySum(int category) const
155 {
155 {
156 qreal sum(0);
156 qreal sum(0);
157 int count = m_dataModel.count(); // Count sets
157 int count = m_dataModel.count(); // Count sets
158
158
159 for (int set = 0; set < count; set++) {
159 for (int set = 0; set < count; set++) {
160 if (category < m_dataModel.at(set)->count())
160 if (category < m_dataModel.at(set)->count())
161 sum += m_dataModel.at(set)->valueAt(category);
161 sum += m_dataModel.at(set)->valueAt(category);
162 }
162 }
163 return sum;
163 return sum;
164 }
164 }
165
165
166 qreal BarChartModel::absoluteCategorySum(int category) const
166 qreal BarChartModel::absoluteCategorySum(int category) const
167 {
167 {
168 qreal sum(0);
168 qreal sum(0);
169 int count = m_dataModel.count(); // Count sets
169 int count = m_dataModel.count(); // Count sets
170
170
171 for (int set = 0; set < count; set++) {
171 for (int set = 0; set < count; set++) {
172 if (category < m_dataModel.at(set)->count())
172 if (category < m_dataModel.at(set)->count())
173 sum += qAbs(m_dataModel.at(set)->valueAt(category));
173 sum += qAbs(m_dataModel.at(set)->valueAt(category));
174 }
174 }
175 return sum;
175 return sum;
176 }
176 }
177
177
178 qreal BarChartModel::maxCategorySum() const
178 qreal BarChartModel::maxCategorySum() const
179 {
179 {
180 qreal max = INT_MIN;
180 qreal max = INT_MIN;
181 int count = categoryCount();
181 int count = categoryCount();
182
182
183 for (int col = 0; col < count; col++) {
183 for (int col = 0; col < count; col++) {
184 qreal sum = categorySum(col);
184 qreal sum = categorySum(col);
185 if (sum > max)
185 if (sum > max)
186 max = sum;
186 max = sum;
187 }
187 }
188 return max;
188 return max;
189 }
189 }
190
190
191 QString BarChartModel::categoryName(int category)
191 QString BarChartModel::categoryName(int category)
192 {
192 {
193 return m_category.at(category);
193 return m_category.at(category);
194 }
194 }
195
195
196 #include "moc_barchartmodel_p.cpp"
196 #include "moc_barchartmodel_p.cpp"
197
197
198 QTCOMMERCIALCHART_END_NAMESPACE No newline at end of file
198 QTCOMMERCIALCHART_END_NAMESPACE
@@ -1,52 +1,52
1 /****************************************************************************
1 /****************************************************************************
2 **
2 **
3 ** Copyright (C) 2012 Digia Plc
3 ** Copyright (C) 2012 Digia Plc
4 ** All rights reserved.
4 ** All rights reserved.
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 **
6 **
7 ** This file is part of the Qt Commercial Charts Add-on.
7 ** This file is part of the Qt Commercial Charts Add-on.
8 **
8 **
9 ** $QT_BEGIN_LICENSE$
9 ** $QT_BEGIN_LICENSE$
10 ** Licensees holding valid Qt Commercial licenses may use this file in
10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 ** accordance with the Qt Commercial License Agreement provided with the
11 ** accordance with the Qt Commercial License Agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia.
13 ** a written agreement between you and Digia.
14 **
14 **
15 ** If you have questions regarding the use of this file, please use
15 ** If you have questions regarding the use of this file, please use
16 ** contact form at http://qt.digia.com
16 ** contact form at http://qt.digia.com
17 ** $QT_END_LICENSE$
17 ** $QT_END_LICENSE$
18 **
18 **
19 ****************************************************************************/
19 ****************************************************************************/
20
20
21 // W A R N I N G
21 // W A R N I N G
22 // -------------
22 // -------------
23 //
23 //
24 // This file is not part of the QtCommercial Chart API. It exists purely as an
24 // This file is not part of the QtCommercial Chart API. It exists purely as an
25 // implementation detail. This header file may change from version to
25 // implementation detail. This header file may change from version to
26 // version without notice, or even be removed.
26 // version without notice, or even be removed.
27 //
27 //
28 // We mean it.
28 // We mean it.
29
29
30 #ifndef QPERCENTBARSERIES_P_H_
30 #ifndef QPERCENTBARSERIES_P_H
31 #define QPERCENTBARSERIES_P_H_
31 #define QPERCENTBARSERIES_P_H
32
32
33 #include "qbarseries_p.h"
33 #include "qbarseries_p.h"
34 #include "domain_p.h"
34 #include "domain_p.h"
35
35
36 QTCOMMERCIALCHART_BEGIN_NAMESPACE
36 QTCOMMERCIALCHART_BEGIN_NAMESPACE
37
37
38
38
39 class QPercentBarSeriesPrivate: public QBarSeriesPrivate
39 class QPercentBarSeriesPrivate: public QBarSeriesPrivate
40 {
40 {
41 public:
41 public:
42 QPercentBarSeriesPrivate(QBarCategories categories,QPercentBarSeries* q);
42 QPercentBarSeriesPrivate(QBarCategories categories,QPercentBarSeries* q);
43 void scaleDomain(Domain& domain);
43 void scaleDomain(Domain& domain);
44 Chart* createGraphics(ChartPresenter* presenter);
44 Chart* createGraphics(ChartPresenter* presenter);
45
45
46 private:
46 private:
47 Q_DECLARE_PUBLIC(QPercentBarSeries)
47 Q_DECLARE_PUBLIC(QPercentBarSeries)
48 };
48 };
49
49
50 QTCOMMERCIALCHART_END_NAMESPACE
50 QTCOMMERCIALCHART_END_NAMESPACE
51
51
52 #endif
52 #endif
@@ -1,52 +1,52
1 /****************************************************************************
1 /****************************************************************************
2 **
2 **
3 ** Copyright (C) 2012 Digia Plc
3 ** Copyright (C) 2012 Digia Plc
4 ** All rights reserved.
4 ** All rights reserved.
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 **
6 **
7 ** This file is part of the Qt Commercial Charts Add-on.
7 ** This file is part of the Qt Commercial Charts Add-on.
8 **
8 **
9 ** $QT_BEGIN_LICENSE$
9 ** $QT_BEGIN_LICENSE$
10 ** Licensees holding valid Qt Commercial licenses may use this file in
10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 ** accordance with the Qt Commercial License Agreement provided with the
11 ** accordance with the Qt Commercial License Agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia.
13 ** a written agreement between you and Digia.
14 **
14 **
15 ** If you have questions regarding the use of this file, please use
15 ** If you have questions regarding the use of this file, please use
16 ** contact form at http://qt.digia.com
16 ** contact form at http://qt.digia.com
17 ** $QT_END_LICENSE$
17 ** $QT_END_LICENSE$
18 **
18 **
19 ****************************************************************************/
19 ****************************************************************************/
20
20
21 // W A R N I N G
21 // W A R N I N G
22 // -------------
22 // -------------
23 //
23 //
24 // This file is not part of the QtCommercial Chart API. It exists purely as an
24 // This file is not part of the QtCommercial Chart API. It exists purely as an
25 // implementation detail. This header file may change from version to
25 // implementation detail. This header file may change from version to
26 // version without notice, or even be removed.
26 // version without notice, or even be removed.
27 //
27 //
28 // We mean it.
28 // We mean it.
29
29
30 #ifndef QSTACKEDBARSERIES_P_H_
30 #ifndef QSTACKEDBARSERIES_P_H
31 #define QSTACKEDBARSERIES_P_H_
31 #define QSTACKEDBARSERIES_P_H
32
32
33 #include "qbarseries_p.h"
33 #include "qbarseries_p.h"
34 #include "domain_p.h"
34 #include "domain_p.h"
35
35
36 QTCOMMERCIALCHART_BEGIN_NAMESPACE
36 QTCOMMERCIALCHART_BEGIN_NAMESPACE
37
37
38
38
39 class QStackedBarSeriesPrivate: public QBarSeriesPrivate
39 class QStackedBarSeriesPrivate: public QBarSeriesPrivate
40 {
40 {
41 public:
41 public:
42 QStackedBarSeriesPrivate(QBarCategories categories,QStackedBarSeries* q);
42 QStackedBarSeriesPrivate(QBarCategories categories,QStackedBarSeries* q);
43 Chart* createGraphics(ChartPresenter* presenter);
43 Chart* createGraphics(ChartPresenter* presenter);
44 void scaleDomain(Domain& domain);
44 void scaleDomain(Domain& domain);
45
45
46 private:
46 private:
47 Q_DECLARE_PUBLIC(QStackedBarSeries)
47 Q_DECLARE_PUBLIC(QStackedBarSeries)
48 };
48 };
49
49
50 QTCOMMERCIALCHART_END_NAMESPACE
50 QTCOMMERCIALCHART_END_NAMESPACE
51
51
52 #endif
52 #endif
@@ -1,55 +1,55
1 /****************************************************************************
1 /****************************************************************************
2 **
2 **
3 ** Copyright (C) 2012 Digia Plc
3 ** Copyright (C) 2012 Digia Plc
4 ** All rights reserved.
4 ** All rights reserved.
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 **
6 **
7 ** This file is part of the Qt Commercial Charts Add-on.
7 ** This file is part of the Qt Commercial Charts Add-on.
8 **
8 **
9 ** $QT_BEGIN_LICENSE$
9 ** $QT_BEGIN_LICENSE$
10 ** Licensees holding valid Qt Commercial licenses may use this file in
10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 ** accordance with the Qt Commercial License Agreement provided with the
11 ** accordance with the Qt Commercial License Agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia.
13 ** a written agreement between you and Digia.
14 **
14 **
15 ** If you have questions regarding the use of this file, please use
15 ** If you have questions regarding the use of this file, please use
16 ** contact form at http://qt.digia.com
16 ** contact form at http://qt.digia.com
17 ** $QT_END_LICENSE$
17 ** $QT_END_LICENSE$
18 **
18 **
19 ****************************************************************************/
19 ****************************************************************************/
20
20
21 #ifndef CHART_H_
21 #ifndef CHART_H
22 #define CHART_H_
22 #define CHART_H
23
23
24 #include "qchartglobal.h"
24 #include "qchartglobal.h"
25 #include <QRect>
25 #include <QRect>
26
26
27 QTCOMMERCIALCHART_BEGIN_NAMESPACE
27 QTCOMMERCIALCHART_BEGIN_NAMESPACE
28
28
29 class ChartAnimator;
29 class ChartAnimator;
30 class ChartPresenter;
30 class ChartPresenter;
31
31
32 class Chart: public QObject
32 class Chart: public QObject
33 {
33 {
34 Q_OBJECT
34 Q_OBJECT
35 public:
35 public:
36 explicit Chart(ChartPresenter *presenter);
36 explicit Chart(ChartPresenter *presenter);
37
37
38 public Q_SLOTS:
38 public Q_SLOTS:
39 virtual void handleGeometryChanged(const QRectF& rect);
39 virtual void handleGeometryChanged(const QRectF& rect);
40 virtual void handleDomainChanged(qreal minX,qreal maxX,qreal minY,qreal maxY);
40 virtual void handleDomainChanged(qreal minX,qreal maxX,qreal minY,qreal maxY);
41 virtual void rangeXChanged(qreal min, qreal max, int tickXCount);
41 virtual void rangeXChanged(qreal min, qreal max, int tickXCount);
42 virtual void rangeYChanged(qreal min, qreal max, int tickYCount);
42 virtual void rangeYChanged(qreal min, qreal max, int tickYCount);
43
43
44 void setAnimator(ChartAnimator* animator);
44 void setAnimator(ChartAnimator* animator);
45 ChartAnimator* animator() const;
45 ChartAnimator* animator() const;
46 ChartPresenter* presenter() const;
46 ChartPresenter* presenter() const;
47
47
48 private:
48 private:
49 ChartAnimator* m_animator;
49 ChartAnimator* m_animator;
50 ChartPresenter* m_presenter;
50 ChartPresenter* m_presenter;
51 };
51 };
52
52
53 QTCOMMERCIALCHART_END_NAMESPACE
53 QTCOMMERCIALCHART_END_NAMESPACE
54
54
55 #endif
55 #endif
@@ -1,55 +1,55
1 /****************************************************************************
1 /****************************************************************************
2 **
2 **
3 ** Copyright (C) 2012 Digia Plc
3 ** Copyright (C) 2012 Digia Plc
4 ** All rights reserved.
4 ** All rights reserved.
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 **
6 **
7 ** This file is part of the Qt Commercial Charts Add-on.
7 ** This file is part of the Qt Commercial Charts Add-on.
8 **
8 **
9 ** $QT_BEGIN_LICENSE$
9 ** $QT_BEGIN_LICENSE$
10 ** Licensees holding valid Qt Commercial licenses may use this file in
10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 ** accordance with the Qt Commercial License Agreement provided with the
11 ** accordance with the Qt Commercial License Agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia.
13 ** a written agreement between you and Digia.
14 **
14 **
15 ** If you have questions regarding the use of this file, please use
15 ** If you have questions regarding the use of this file, please use
16 ** contact form at http://qt.digia.com
16 ** contact form at http://qt.digia.com
17 ** $QT_END_LICENSE$
17 ** $QT_END_LICENSE$
18 **
18 **
19 ****************************************************************************/
19 ****************************************************************************/
20
20
21 #ifndef CHARTBACKGROUND_H_
21 #ifndef CHARTBACKGROUND_H
22 #define CHARTBACKGROUND_H_
22 #define CHARTBACKGROUND_H
23
23
24 #include "qchartglobal.h"
24 #include "qchartglobal.h"
25 #include <QGraphicsRectItem>
25 #include <QGraphicsRectItem>
26
26
27 QTCOMMERCIALCHART_BEGIN_NAMESPACE
27 QTCOMMERCIALCHART_BEGIN_NAMESPACE
28
28
29 class ChartBackground: public QGraphicsRectItem
29 class ChartBackground: public QGraphicsRectItem
30 {
30 {
31 public:
31 public:
32 ChartBackground(QGraphicsItem *parent =0);
32 ChartBackground(QGraphicsItem *parent =0);
33 ~ChartBackground();
33 ~ChartBackground();
34
34
35 void setDimeter(int dimater);
35 void setDimeter(int dimater);
36 int diameter() const;
36 int diameter() const;
37
37
38
38
39 protected:
39 protected:
40 void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
40 void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
41
41
42
42
43 private:
43 private:
44 int roundness(qreal size) const;
44 int roundness(qreal size) const;
45
45
46 private:
46 private:
47 int m_diameter;
47 int m_diameter;
48
48
49 };
49 };
50
50
51 QTCOMMERCIALCHART_END_NAMESPACE
51 QTCOMMERCIALCHART_END_NAMESPACE
52
52
53 #endif /* CHARTBACKGROUND_H_ */
53 #endif /* CHARTBACKGROUND_H_ */
54
54
55
55
@@ -1,73 +1,73
1 /****************************************************************************
1 /****************************************************************************
2 **
2 **
3 ** Copyright (C) 2012 Digia Plc
3 ** Copyright (C) 2012 Digia Plc
4 ** All rights reserved.
4 ** All rights reserved.
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 **
6 **
7 ** This file is part of the Qt Commercial Charts Add-on.
7 ** This file is part of the Qt Commercial Charts Add-on.
8 **
8 **
9 ** $QT_BEGIN_LICENSE$
9 ** $QT_BEGIN_LICENSE$
10 ** Licensees holding valid Qt Commercial licenses may use this file in
10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 ** accordance with the Qt Commercial License Agreement provided with the
11 ** accordance with the Qt Commercial License Agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia.
13 ** a written agreement between you and Digia.
14 **
14 **
15 ** If you have questions regarding the use of this file, please use
15 ** If you have questions regarding the use of this file, please use
16 ** contact form at http://qt.digia.com
16 ** contact form at http://qt.digia.com
17 ** $QT_END_LICENSE$
17 ** $QT_END_LICENSE$
18 **
18 **
19 ****************************************************************************/
19 ****************************************************************************/
20
20
21 #ifndef CHARTCONFIG_H_
21 #ifndef CHARTCONFIG_H
22 #define CHARTCONFIG_H_
22 #define CHARTCONFIG_H
23
23
24 #include "qchartglobal.h"
24 #include "qchartglobal.h"
25 #ifdef Q_CC_MSVC
25 #ifdef Q_CC_MSVC
26 // There is a problem with jom.exe currently. It does not seem to understand QMAKE_EXTRA_TARGETS properly.
26 // There is a problem with jom.exe currently. It does not seem to understand QMAKE_EXTRA_TARGETS properly.
27 // This is the case at least with shadow builds.
27 // This is the case at least with shadow builds.
28 // http://qt-project.org/wiki/jom
28 // http://qt-project.org/wiki/jom
29 const char *buildTime = __DATE__;
29 const char *buildTime = __DATE__;
30 const char *gitHead = "unknown";
30 const char *gitHead = "unknown";
31 #else
31 #else
32 #include "qchartversion_p.h"
32 #include "qchartversion_p.h"
33 #endif
33 #endif
34
34
35
35
36 QTCOMMERCIALCHART_BEGIN_NAMESPACE
36 QTCOMMERCIALCHART_BEGIN_NAMESPACE
37
37
38 class ChartConfig {
38 class ChartConfig {
39
39
40 private:
40 private:
41 ChartConfig(){
41 ChartConfig(){
42 #ifndef QT_NO_DEBUG
42 #ifndef QT_NO_DEBUG
43 qDebug()<<"buildTime" << buildTime;
43 qDebug()<<"buildTime" << buildTime;
44 qDebug()<<"gitHead" << gitHead;
44 qDebug()<<"gitHead" << gitHead;
45 #endif
45 #endif
46 m_instance = this;
46 m_instance = this;
47 }
47 }
48 public:
48 public:
49 static ChartConfig* instance(){
49 static ChartConfig* instance(){
50 if(!m_instance){
50 if(!m_instance){
51 m_instance= new ChartConfig();
51 m_instance= new ChartConfig();
52 }
52 }
53 return m_instance;
53 return m_instance;
54 }
54 }
55
55
56 QString compilationTime(){
56 QString compilationTime(){
57 return buildTime;
57 return buildTime;
58 }
58 }
59
59
60 QString compilationHead(){
60 QString compilationHead(){
61 return gitHead;
61 return gitHead;
62 }
62 }
63
63
64 private:
64 private:
65 static ChartConfig* m_instance;
65 static ChartConfig* m_instance;
66 };
66 };
67
67
68
68
69 ChartConfig* ChartConfig::m_instance=0;
69 ChartConfig* ChartConfig::m_instance=0;
70
70
71 QTCOMMERCIALCHART_END_NAMESPACE
71 QTCOMMERCIALCHART_END_NAMESPACE
72
72
73 #endif
73 #endif
@@ -1,90 +1,90
1 /****************************************************************************
1 /****************************************************************************
2 **
2 **
3 ** Copyright (C) 2012 Digia Plc
3 ** Copyright (C) 2012 Digia Plc
4 ** All rights reserved.
4 ** All rights reserved.
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 **
6 **
7 ** This file is part of the Qt Commercial Charts Add-on.
7 ** This file is part of the Qt Commercial Charts Add-on.
8 **
8 **
9 ** $QT_BEGIN_LICENSE$
9 ** $QT_BEGIN_LICENSE$
10 ** Licensees holding valid Qt Commercial licenses may use this file in
10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 ** accordance with the Qt Commercial License Agreement provided with the
11 ** accordance with the Qt Commercial License Agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia.
13 ** a written agreement between you and Digia.
14 **
14 **
15 ** If you have questions regarding the use of this file, please use
15 ** If you have questions regarding the use of this file, please use
16 ** contact form at http://qt.digia.com
16 ** contact form at http://qt.digia.com
17 ** $QT_END_LICENSE$
17 ** $QT_END_LICENSE$
18 **
18 **
19 ****************************************************************************/
19 ****************************************************************************/
20
20
21 // W A R N I N G
21 // W A R N I N G
22 // -------------
22 // -------------
23 //
23 //
24 // This file is not part of the QtCommercial Chart API. It exists purely as an
24 // This file is not part of the QtCommercial Chart API. It exists purely as an
25 // implementation detail. This header file may change from version to
25 // implementation detail. This header file may change from version to
26 // version without notice, or even be removed.
26 // version without notice, or even be removed.
27 //
27 //
28 // We mean it.
28 // We mean it.
29
29
30 #ifndef CHARTDATASET_P_H_
30 #ifndef CHARTDATASET_P_H
31 #define CHARTDATASET_P_H_
31 #define CHARTDATASET_P_H
32
32
33 #include "qseries.h"
33 #include "qseries.h"
34 #include "domain_p.h"
34 #include "domain_p.h"
35 #include <QVector>
35 #include <QVector>
36
36
37 QTCOMMERCIALCHART_BEGIN_NAMESPACE
37 QTCOMMERCIALCHART_BEGIN_NAMESPACE
38
38
39 class QChartAxis;
39 class QChartAxis;
40 class QBarSeries;
40 class QBarSeries;
41
41
42 class ChartDataSet : public QObject
42 class ChartDataSet : public QObject
43 {
43 {
44 Q_OBJECT
44 Q_OBJECT
45 public:
45 public:
46 ChartDataSet(QObject* parent=0);
46 ChartDataSet(QObject* parent=0);
47 virtual ~ChartDataSet();
47 virtual ~ChartDataSet();
48
48
49 void addSeries(QSeries* series,QChartAxis *axisY = 0);
49 void addSeries(QSeries* series,QChartAxis *axisY = 0);
50 void removeSeries(QSeries* series);
50 void removeSeries(QSeries* series);
51 void removeAllSeries();
51 void removeAllSeries();
52
52
53 void zoomInDomain(const QRectF& rect, const QSizeF& size);
53 void zoomInDomain(const QRectF& rect, const QSizeF& size);
54 void zoomOutDomain(const QRectF& rect, const QSizeF& size);
54 void zoomOutDomain(const QRectF& rect, const QSizeF& size);
55 void scrollDomain(int dx,int dy,const QSizeF& size);
55 void scrollDomain(int dx,int dy,const QSizeF& size);
56
56
57 int seriesCount(QSeries::QSeriesType type);
57 int seriesCount(QSeries::QSeriesType type);
58 int seriesIndex(QSeries *series);
58 int seriesIndex(QSeries *series);
59
59
60 Domain* domain(QSeries* series) const;
60 Domain* domain(QSeries* series) const;
61 Domain* domain(QChartAxis* axis) const;
61 Domain* domain(QChartAxis* axis) const;
62
62
63 QChartAxis* axisX() const { return m_axisX; }
63 QChartAxis* axisX() const { return m_axisX; }
64 QChartAxis* axisY(QSeries* series = 0) const;
64 QChartAxis* axisY(QSeries* series = 0) const;
65
65
66 Q_SIGNALS:
66 Q_SIGNALS:
67 void seriesAdded(QSeries* series,Domain* domain);
67 void seriesAdded(QSeries* series,Domain* domain);
68 void seriesRemoved(QSeries* series);
68 void seriesRemoved(QSeries* series);
69 void axisAdded(QChartAxis* axis,Domain* domain);
69 void axisAdded(QChartAxis* axis,Domain* domain);
70 void axisRemoved(QChartAxis* axis);
70 void axisRemoved(QChartAxis* axis);
71
71
72 private:
72 private:
73 QStringList createLabels(QChartAxis* axis,qreal min, qreal max);
73 QStringList createLabels(QChartAxis* axis,qreal min, qreal max);
74 void calculateDomain(QSeries* series,Domain* domain);
74 void calculateDomain(QSeries* series,Domain* domain);
75 void setupCategories(QBarSeries* series);
75 void setupCategories(QBarSeries* series);
76
76
77 private:
77 private:
78 QMap<QSeries*, QChartAxis*> m_seriesAxisMap;
78 QMap<QSeries*, QChartAxis*> m_seriesAxisMap;
79 QMap<QChartAxis*, Domain*> m_axisDomainMap;
79 QMap<QChartAxis*, Domain*> m_axisDomainMap;
80 QMap<int,QSeries*> m_indexSeriesMap;
80 QMap<int,QSeries*> m_indexSeriesMap;
81 QChartAxis* m_axisX;
81 QChartAxis* m_axisX;
82 QChartAxis* m_axisY;
82 QChartAxis* m_axisY;
83
83
84 int m_domainIndex;
84 int m_domainIndex;
85 bool m_axisXInitialized;
85 bool m_axisXInitialized;
86 };
86 };
87
87
88 QTCOMMERCIALCHART_END_NAMESPACE
88 QTCOMMERCIALCHART_END_NAMESPACE
89
89
90 #endif /* CHARTENGINE_P_H_ */
90 #endif /* CHARTENGINE_P_H_ */
@@ -1,39 +1,39
1 /****************************************************************************
1 /****************************************************************************
2 **
2 **
3 ** Copyright (C) 2012 Digia Plc
3 ** Copyright (C) 2012 Digia Plc
4 ** All rights reserved.
4 ** All rights reserved.
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 **
6 **
7 ** This file is part of the Qt Commercial Charts Add-on.
7 ** This file is part of the Qt Commercial Charts Add-on.
8 **
8 **
9 ** $QT_BEGIN_LICENSE$
9 ** $QT_BEGIN_LICENSE$
10 ** Licensees holding valid Qt Commercial licenses may use this file in
10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 ** accordance with the Qt Commercial License Agreement provided with the
11 ** accordance with the Qt Commercial License Agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia.
13 ** a written agreement between you and Digia.
14 **
14 **
15 ** If you have questions regarding the use of this file, please use
15 ** If you have questions regarding the use of this file, please use
16 ** contact form at http://qt.digia.com
16 ** contact form at http://qt.digia.com
17 ** $QT_END_LICENSE$
17 ** $QT_END_LICENSE$
18 **
18 **
19 ****************************************************************************/
19 ****************************************************************************/
20
20
21 #ifndef CHARTITEM_H_
21 #ifndef CHARTITEM_H
22 #define CHARTITEM_H_
22 #define CHARTITEM_H
23
23
24 #include "chart_p.h"
24 #include "chart_p.h"
25 #include "chartpresenter_p.h"
25 #include "chartpresenter_p.h"
26 #include <QGraphicsItem>
26 #include <QGraphicsItem>
27
27
28 QTCOMMERCIALCHART_BEGIN_NAMESPACE
28 QTCOMMERCIALCHART_BEGIN_NAMESPACE
29
29
30 class ChartItem : public QGraphicsItem, public Chart
30 class ChartItem : public QGraphicsItem, public Chart
31 {
31 {
32 enum ChartItemTypes{ AXIS_ITEM = UserType + 1, XYLINE_ITEM };
32 enum ChartItemTypes{ AXIS_ITEM = UserType + 1, XYLINE_ITEM };
33 public:
33 public:
34 ChartItem(ChartPresenter *presenter) : QGraphicsItem(presenter ? presenter->rootItem() : 0), Chart(presenter) {}
34 ChartItem(ChartPresenter *presenter) : QGraphicsItem(presenter ? presenter->rootItem() : 0), Chart(presenter) {}
35 };
35 };
36
36
37 QTCOMMERCIALCHART_END_NAMESPACE
37 QTCOMMERCIALCHART_END_NAMESPACE
38
38
39 #endif /* CHARTITEM_H_ */
39 #endif /* CHARTITEM_H_ */
@@ -1,402 +1,401
1 /****************************************************************************
1 /****************************************************************************
2 **
2 **
3 ** Copyright (C) 2012 Digia Plc
3 ** Copyright (C) 2012 Digia Plc
4 ** All rights reserved.
4 ** All rights reserved.
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 **
6 **
7 ** This file is part of the Qt Commercial Charts Add-on.
7 ** This file is part of the Qt Commercial Charts Add-on.
8 **
8 **
9 ** $QT_BEGIN_LICENSE$
9 ** $QT_BEGIN_LICENSE$
10 ** Licensees holding valid Qt Commercial licenses may use this file in
10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 ** accordance with the Qt Commercial License Agreement provided with the
11 ** accordance with the Qt Commercial License Agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia.
13 ** a written agreement between you and Digia.
14 **
14 **
15 ** If you have questions regarding the use of this file, please use
15 ** If you have questions regarding the use of this file, please use
16 ** contact form at http://qt.digia.com
16 ** contact form at http://qt.digia.com
17 ** $QT_END_LICENSE$
17 ** $QT_END_LICENSE$
18 **
18 **
19 ****************************************************************************/
19 ****************************************************************************/
20
20 #include "chartpresenter_p.h"
21 #include "qchart.h"
21 #include "qchart.h"
22 #include "qchart_p.h"
22 #include "qchart_p.h"
23 #include "qchartaxis.h"
23 #include "qchartaxis.h"
24 #include "chartpresenter_p.h"
25 #include "chartdataset_p.h"
24 #include "chartdataset_p.h"
26 #include "charttheme_p.h"
25 #include "charttheme_p.h"
27 #include "chartanimator_p.h"
26 #include "chartanimator_p.h"
28 #include "qseries_p.h"
27 #include "qseries_p.h"
29 #include "qareaseries.h"
28 #include "qareaseries.h"
30 #include "axis_p.h"
29 #include "axis_p.h"
31 #include "areachartitem_p.h"
30 #include "areachartitem_p.h"
32
31
33 QTCOMMERCIALCHART_BEGIN_NAMESPACE
32 QTCOMMERCIALCHART_BEGIN_NAMESPACE
34
33
35 ChartPresenter::ChartPresenter(QChart* chart,ChartDataSet* dataset):QObject(chart),
34 ChartPresenter::ChartPresenter(QChart* chart,ChartDataSet* dataset):QObject(chart),
36 m_chart(chart),
35 m_chart(chart),
37 m_animator(0),
36 m_animator(0),
38 m_dataset(dataset),
37 m_dataset(dataset),
39 m_chartTheme(0),
38 m_chartTheme(0),
40 m_chartRect(QRectF(QPoint(0,0),m_chart->size())),
39 m_chartRect(QRectF(QPoint(0,0),m_chart->size())),
41 m_options(QChart::NoAnimation),
40 m_options(QChart::NoAnimation),
42 m_minLeftMargin(0),
41 m_minLeftMargin(0),
43 m_minBottomMargin(0),
42 m_minBottomMargin(0),
44 m_backgroundItem(0),
43 m_backgroundItem(0),
45 m_titleItem(0),
44 m_titleItem(0),
46 m_marginBig(60),
45 m_marginBig(60),
47 m_marginSmall(20),
46 m_marginSmall(20),
48 m_marginTiny(10),
47 m_marginTiny(10),
49 m_chartMargins(QRect(m_marginBig,m_marginBig,0,0))
48 m_chartMargins(QRect(m_marginBig,m_marginBig,0,0))
50 {
49 {
51 }
50 }
52
51
53 ChartPresenter::~ChartPresenter()
52 ChartPresenter::~ChartPresenter()
54 {
53 {
55 delete m_chartTheme;
54 delete m_chartTheme;
56 }
55 }
57
56
58 void ChartPresenter::setGeometry(const QRectF& rect)
57 void ChartPresenter::setGeometry(const QRectF& rect)
59 {
58 {
60 m_rect = rect;
59 m_rect = rect;
61 Q_ASSERT(m_rect.isValid());
60 Q_ASSERT(m_rect.isValid());
62 updateLayout();
61 updateLayout();
63 }
62 }
64
63
65 void ChartPresenter::setMinimumMarginWidth(Axis* axis, qreal width)
64 void ChartPresenter::setMinimumMarginWidth(Axis* axis, qreal width)
66 {
65 {
67 switch(axis->axisType()){
66 switch(axis->axisType()){
68 case Axis::X_AXIS:
67 case Axis::X_AXIS:
69 {
68 {
70 if(width>m_chartRect.width()+ m_chartMargins.left()) {
69 if(width>m_chartRect.width()+ m_chartMargins.left()) {
71 m_minLeftMargin= width - m_chartRect.width();
70 m_minLeftMargin= width - m_chartRect.width();
72 updateLayout();
71 updateLayout();
73 }
72 }
74 break;
73 break;
75 }
74 }
76 case Axis::Y_AXIS:
75 case Axis::Y_AXIS:
77 {
76 {
78
77
79 if(m_minLeftMargin!=width){
78 if(m_minLeftMargin!=width){
80 m_minLeftMargin= width;
79 m_minLeftMargin= width;
81 updateLayout();
80 updateLayout();
82 }
81 }
83 break;
82 break;
84 }
83 }
85
84
86 }
85 }
87 }
86 }
88
87
89 void ChartPresenter::setMinimumMarginHeight(Axis* axis, qreal height)
88 void ChartPresenter::setMinimumMarginHeight(Axis* axis, qreal height)
90 {
89 {
91 switch(axis->axisType()){
90 switch(axis->axisType()){
92 case Axis::X_AXIS:
91 case Axis::X_AXIS:
93 {
92 {
94 if(m_minBottomMargin!=height) {
93 if(m_minBottomMargin!=height) {
95 m_minBottomMargin= height;
94 m_minBottomMargin= height;
96 updateLayout();
95 updateLayout();
97 }
96 }
98 break;
97 break;
99 }
98 }
100 case Axis::Y_AXIS:
99 case Axis::Y_AXIS:
101 {
100 {
102
101
103 if(height>m_chartMargins.bottom()+m_chartRect.height()){
102 if(height>m_chartMargins.bottom()+m_chartRect.height()){
104 m_minBottomMargin= height - m_chartRect.height();
103 m_minBottomMargin= height - m_chartRect.height();
105 updateLayout();
104 updateLayout();
106 }
105 }
107 break;
106 break;
108 }
107 }
109
108
110 }
109 }
111 }
110 }
112
111
113 void ChartPresenter::handleAxisAdded(QChartAxis* axis,Domain* domain)
112 void ChartPresenter::handleAxisAdded(QChartAxis* axis,Domain* domain)
114 {
113 {
115 Axis* item = new Axis(axis,this,axis==m_dataset->axisX()?Axis::X_AXIS : Axis::Y_AXIS);
114 Axis* item = new Axis(axis,this,axis==m_dataset->axisX()?Axis::X_AXIS : Axis::Y_AXIS);
116
115
117 if(m_options.testFlag(QChart::GridAxisAnimations)){
116 if(m_options.testFlag(QChart::GridAxisAnimations)){
118 m_animator->addAnimation(item);
117 m_animator->addAnimation(item);
119 }
118 }
120
119
121 if(axis==m_dataset->axisX()){
120 if(axis==m_dataset->axisX()){
122 m_chartTheme->decorate(axis,true);
121 m_chartTheme->decorate(axis,true);
123 QObject::connect(domain,SIGNAL(rangeXChanged(qreal,qreal,int)),item,SLOT(handleRangeChanged(qreal,qreal,int)));
122 QObject::connect(domain,SIGNAL(rangeXChanged(qreal,qreal,int)),item,SLOT(handleRangeChanged(qreal,qreal,int)));
124 //initialize
123 //initialize
125 item->handleRangeChanged(domain->minX(),domain->maxX(),domain->tickXCount());
124 item->handleRangeChanged(domain->minX(),domain->maxX(),domain->tickXCount());
126
125
127 }
126 }
128 else{
127 else{
129 m_chartTheme->decorate(axis,false);
128 m_chartTheme->decorate(axis,false);
130 QObject::connect(domain,SIGNAL(rangeYChanged(qreal,qreal,int)),item,SLOT(handleRangeChanged(qreal,qreal,int)));
129 QObject::connect(domain,SIGNAL(rangeYChanged(qreal,qreal,int)),item,SLOT(handleRangeChanged(qreal,qreal,int)));
131 //initialize
130 //initialize
132 item->handleRangeChanged(domain->minY(),domain->maxY(),domain->tickYCount());
131 item->handleRangeChanged(domain->minY(),domain->maxY(),domain->tickYCount());
133 }
132 }
134
133
135 QObject::connect(this,SIGNAL(geometryChanged(QRectF)),item,SLOT(handleGeometryChanged(QRectF)));
134 QObject::connect(this,SIGNAL(geometryChanged(QRectF)),item,SLOT(handleGeometryChanged(QRectF)));
136 //initialize
135 //initialize
137 item->handleGeometryChanged(m_chartRect);
136 item->handleGeometryChanged(m_chartRect);
138 m_axisItems.insert(axis, item);
137 m_axisItems.insert(axis, item);
139 }
138 }
140
139
141 void ChartPresenter::handleAxisRemoved(QChartAxis* axis)
140 void ChartPresenter::handleAxisRemoved(QChartAxis* axis)
142 {
141 {
143 Axis* item = m_axisItems.take(axis);
142 Axis* item = m_axisItems.take(axis);
144 Q_ASSERT(item);
143 Q_ASSERT(item);
145 if(m_animator) m_animator->removeAnimation(item);
144 if(m_animator) m_animator->removeAnimation(item);
146 delete item;
145 delete item;
147 }
146 }
148
147
149
148
150 void ChartPresenter::handleSeriesAdded(QSeries* series,Domain* domain)
149 void ChartPresenter::handleSeriesAdded(QSeries* series,Domain* domain)
151 {
150 {
152 Chart *item = series->d_ptr->createGraphics(this);
151 Chart *item = series->d_ptr->createGraphics(this);
153 Q_ASSERT(item);
152 Q_ASSERT(item);
154 QObject::connect(this,SIGNAL(geometryChanged(QRectF)),item,SLOT(handleGeometryChanged(QRectF)));
153 QObject::connect(this,SIGNAL(geometryChanged(QRectF)),item,SLOT(handleGeometryChanged(QRectF)));
155 QObject::connect(domain,SIGNAL(domainChanged(qreal,qreal,qreal,qreal)),item,SLOT(handleDomainChanged(qreal,qreal,qreal,qreal)));
154 QObject::connect(domain,SIGNAL(domainChanged(qreal,qreal,qreal,qreal)),item,SLOT(handleDomainChanged(qreal,qreal,qreal,qreal)));
156 //initialize
155 //initialize
157 item->handleDomainChanged(domain->minX(),domain->maxX(),domain->minY(),domain->maxY());
156 item->handleDomainChanged(domain->minX(),domain->maxX(),domain->minY(),domain->maxY());
158 if(m_chartRect.isValid()) item->handleGeometryChanged(m_chartRect);
157 if(m_chartRect.isValid()) item->handleGeometryChanged(m_chartRect);
159 m_chartItems.insert(series,item);
158 m_chartItems.insert(series,item);
160 }
159 }
161
160
162 void ChartPresenter::handleSeriesRemoved(QSeries* series)
161 void ChartPresenter::handleSeriesRemoved(QSeries* series)
163 {
162 {
164 Chart* item = m_chartItems.take(series);
163 Chart* item = m_chartItems.take(series);
165 Q_ASSERT(item);
164 Q_ASSERT(item);
166 if(m_animator) {
165 if(m_animator) {
167 //small hack to handle area animations
166 //small hack to handle area animations
168 if(series->type()==QSeries::SeriesTypeArea){
167 if(series->type()==QSeries::SeriesTypeArea){
169 QAreaSeries* areaSeries = static_cast<QAreaSeries*>(series);
168 QAreaSeries* areaSeries = static_cast<QAreaSeries*>(series);
170 AreaChartItem* area = static_cast<AreaChartItem*>(item);
169 AreaChartItem* area = static_cast<AreaChartItem*>(item);
171 m_animator->removeAnimation(area->upperLineItem());
170 m_animator->removeAnimation(area->upperLineItem());
172 if(areaSeries->lowerSeries()) m_animator->removeAnimation(area->lowerLineItem());
171 if(areaSeries->lowerSeries()) m_animator->removeAnimation(area->lowerLineItem());
173 }else
172 }else
174 m_animator->removeAnimation(item);
173 m_animator->removeAnimation(item);
175 }
174 }
176 delete item;
175 delete item;
177 }
176 }
178
177
179 void ChartPresenter::setTheme(QChart::ChartTheme theme,bool force)
178 void ChartPresenter::setTheme(QChart::ChartTheme theme,bool force)
180 {
179 {
181 if(m_chartTheme && m_chartTheme->id() == theme) return;
180 if(m_chartTheme && m_chartTheme->id() == theme) return;
182 delete m_chartTheme;
181 delete m_chartTheme;
183 m_chartTheme = ChartTheme::createTheme(theme);
182 m_chartTheme = ChartTheme::createTheme(theme);
184 m_chartTheme->setForced(force);
183 m_chartTheme->setForced(force);
185 m_chartTheme->decorate(m_chart);
184 m_chartTheme->decorate(m_chart);
186 m_chartTheme->decorate(m_chart->legend());
185 m_chartTheme->decorate(m_chart->legend());
187 resetAllElements();
186 resetAllElements();
188 }
187 }
189
188
190 QChart::ChartTheme ChartPresenter::theme()
189 QChart::ChartTheme ChartPresenter::theme()
191 {
190 {
192 return m_chartTheme->id();
191 return m_chartTheme->id();
193 }
192 }
194
193
195 void ChartPresenter::setAnimationOptions(QChart::AnimationOptions options)
194 void ChartPresenter::setAnimationOptions(QChart::AnimationOptions options)
196 {
195 {
197 if(m_options!=options) {
196 if(m_options!=options) {
198
197
199 m_options=options;
198 m_options=options;
200
199
201 if(m_options!=QChart::NoAnimation && !m_animator) {
200 if(m_options!=QChart::NoAnimation && !m_animator) {
202 m_animator= new ChartAnimator(this);
201 m_animator= new ChartAnimator(this);
203 }
202 }
204 resetAllElements();
203 resetAllElements();
205 }
204 }
206
205
207 }
206 }
208
207
209 void ChartPresenter::resetAllElements()
208 void ChartPresenter::resetAllElements()
210 {
209 {
211 QList<QChartAxis*> axisList = m_axisItems.uniqueKeys();
210 QList<QChartAxis*> axisList = m_axisItems.uniqueKeys();
212 QList<QSeries*> seriesList = m_chartItems.uniqueKeys();
211 QList<QSeries*> seriesList = m_chartItems.uniqueKeys();
213
212
214 foreach(QChartAxis* axis, axisList) {
213 foreach(QChartAxis* axis, axisList) {
215 handleAxisRemoved(axis);
214 handleAxisRemoved(axis);
216 handleAxisAdded(axis,m_dataset->domain(axis));
215 handleAxisAdded(axis,m_dataset->domain(axis));
217 }
216 }
218 foreach(QSeries* series, seriesList) {
217 foreach(QSeries* series, seriesList) {
219 handleSeriesRemoved(series);
218 handleSeriesRemoved(series);
220 handleSeriesAdded(series,m_dataset->domain(series));
219 handleSeriesAdded(series,m_dataset->domain(series));
221 }
220 }
222 }
221 }
223
222
224 void ChartPresenter::zoomIn()
223 void ChartPresenter::zoomIn()
225 {
224 {
226 QRectF rect = chartGeometry();
225 QRectF rect = chartGeometry();
227 rect.setWidth(rect.width()/2);
226 rect.setWidth(rect.width()/2);
228 rect.setHeight(rect.height()/2);
227 rect.setHeight(rect.height()/2);
229 rect.moveCenter(chartGeometry().center());
228 rect.moveCenter(chartGeometry().center());
230 zoomIn(rect);
229 zoomIn(rect);
231 }
230 }
232
231
233 void ChartPresenter::zoomIn(const QRectF& rect)
232 void ChartPresenter::zoomIn(const QRectF& rect)
234 {
233 {
235 QRectF r = rect.normalized();
234 QRectF r = rect.normalized();
236 r.translate(-m_chartMargins.topLeft());
235 r.translate(-m_chartMargins.topLeft());
237 if(m_animator) {
236 if(m_animator) {
238
237
239 QPointF point(r.center().x()/chartGeometry().width(),r.center().y()/chartGeometry().height());
238 QPointF point(r.center().x()/chartGeometry().width(),r.center().y()/chartGeometry().height());
240 m_animator->setState(ChartAnimator::ZoomInState,point);
239 m_animator->setState(ChartAnimator::ZoomInState,point);
241 }
240 }
242 m_dataset->zoomInDomain(r,chartGeometry().size());
241 m_dataset->zoomInDomain(r,chartGeometry().size());
243 if(m_animator) {
242 if(m_animator) {
244 m_animator->setState(ChartAnimator::ShowState);
243 m_animator->setState(ChartAnimator::ShowState);
245 }
244 }
246 }
245 }
247
246
248 void ChartPresenter::zoomOut()
247 void ChartPresenter::zoomOut()
249 {
248 {
250 if(m_animator)
249 if(m_animator)
251 {
250 {
252 m_animator->setState(ChartAnimator::ZoomOutState);
251 m_animator->setState(ChartAnimator::ZoomOutState);
253 }
252 }
254
253
255 QSizeF size = chartGeometry().size();
254 QSizeF size = chartGeometry().size();
256 QRectF rect = chartGeometry();
255 QRectF rect = chartGeometry();
257 rect.translate(-m_chartMargins.topLeft());
256 rect.translate(-m_chartMargins.topLeft());
258 m_dataset->zoomOutDomain(rect.adjusted(size.width()/4,size.height()/4,-size.width()/4,-size.height()/4),size);
257 m_dataset->zoomOutDomain(rect.adjusted(size.width()/4,size.height()/4,-size.width()/4,-size.height()/4),size);
259 //m_dataset->zoomOutDomain(m_zoomStack[m_zoomIndex-1],geometry().size());
258 //m_dataset->zoomOutDomain(m_zoomStack[m_zoomIndex-1],geometry().size());
260
259
261 if(m_animator){
260 if(m_animator){
262 m_animator->setState(ChartAnimator::ShowState);
261 m_animator->setState(ChartAnimator::ShowState);
263 }
262 }
264 }
263 }
265
264
266 void ChartPresenter::scroll(int dx,int dy)
265 void ChartPresenter::scroll(int dx,int dy)
267 {
266 {
268 if(m_animator){
267 if(m_animator){
269 if(dx<0) m_animator->setState(ChartAnimator::ScrollLeftState,QPointF());
268 if(dx<0) m_animator->setState(ChartAnimator::ScrollLeftState,QPointF());
270 if(dx>0) m_animator->setState(ChartAnimator::ScrollRightState,QPointF());
269 if(dx>0) m_animator->setState(ChartAnimator::ScrollRightState,QPointF());
271 if(dy<0) m_animator->setState(ChartAnimator::ScrollUpState,QPointF());
270 if(dy<0) m_animator->setState(ChartAnimator::ScrollUpState,QPointF());
272 if(dy>0) m_animator->setState(ChartAnimator::ScrollDownState,QPointF());
271 if(dy>0) m_animator->setState(ChartAnimator::ScrollDownState,QPointF());
273 }
272 }
274
273
275 m_dataset->scrollDomain(dx,dy,chartGeometry().size());
274 m_dataset->scrollDomain(dx,dy,chartGeometry().size());
276
275
277 if(m_animator){
276 if(m_animator){
278 m_animator->setState(ChartAnimator::ShowState);
277 m_animator->setState(ChartAnimator::ShowState);
279 }
278 }
280 }
279 }
281
280
282 QChart::AnimationOptions ChartPresenter::animationOptions() const
281 QChart::AnimationOptions ChartPresenter::animationOptions() const
283 {
282 {
284 return m_options;
283 return m_options;
285 }
284 }
286
285
287 void ChartPresenter::updateLayout()
286 void ChartPresenter::updateLayout()
288 {
287 {
289 if (!m_rect.isValid()) return;
288 if (!m_rect.isValid()) return;
290
289
291 // recalculate title size
290 // recalculate title size
292
291
293 QSize titleSize;
292 QSize titleSize;
294 int titlePadding=0;
293 int titlePadding=0;
295
294
296 if (m_titleItem) {
295 if (m_titleItem) {
297 titleSize= m_titleItem->boundingRect().size().toSize();
296 titleSize= m_titleItem->boundingRect().size().toSize();
298 }
297 }
299
298
300 //defaults
299 //defaults
301 m_chartMargins = QRect(QPoint(m_minLeftMargin>m_marginBig?m_minLeftMargin:m_marginBig,m_marginBig),QPoint(m_marginBig,m_minBottomMargin>m_marginBig?m_minBottomMargin:m_marginBig));
300 m_chartMargins = QRect(QPoint(m_minLeftMargin>m_marginBig?m_minLeftMargin:m_marginBig,m_marginBig),QPoint(m_marginBig,m_minBottomMargin>m_marginBig?m_minBottomMargin:m_marginBig));
302 titlePadding = m_chartMargins.top()/2;
301 titlePadding = m_chartMargins.top()/2;
303
302
304 QLegend* legend = m_chart->d_ptr->m_legend;
303 QLegend* legend = m_chart->d_ptr->m_legend;
305
304
306 // recalculate legend position
305 // recalculate legend position
307 if (legend->isAttachedToChart() && legend->isEnabled()) {
306 if (legend->isAttachedToChart() && legend->isEnabled()) {
308
307
309 QRect legendRect;
308 QRect legendRect;
310
309
311 // Reserve some space for legend
310 // Reserve some space for legend
312 switch (legend->alignment()) {
311 switch (legend->alignment()) {
313
312
314 case QLegend::AlignmentTop: {
313 case QLegend::AlignmentTop: {
315 int ledgendSize = legend->minHeight();
314 int ledgendSize = legend->minHeight();
316 int topPadding = 2*m_marginTiny + titleSize.height() + ledgendSize + m_marginTiny;
315 int topPadding = 2*m_marginTiny + titleSize.height() + ledgendSize + m_marginTiny;
317 m_chartMargins = QRect(QPoint(m_chartMargins.left(),topPadding),QPoint(m_chartMargins.right(),m_chartMargins.bottom()));
316 m_chartMargins = QRect(QPoint(m_chartMargins.left(),topPadding),QPoint(m_chartMargins.right(),m_chartMargins.bottom()));
318 m_legendMargins = QRect(QPoint(m_chartMargins.left(),topPadding - (ledgendSize + m_marginTiny)),QPoint(m_chartMargins.right(),m_rect.height()-topPadding + m_marginTiny));
317 m_legendMargins = QRect(QPoint(m_chartMargins.left(),topPadding - (ledgendSize + m_marginTiny)),QPoint(m_chartMargins.right(),m_rect.height()-topPadding + m_marginTiny));
319 titlePadding = m_marginTiny + m_marginTiny;
318 titlePadding = m_marginTiny + m_marginTiny;
320 break;
319 break;
321 }
320 }
322 case QLegend::AlignmentBottom: {
321 case QLegend::AlignmentBottom: {
323 int ledgendSize = legend->minHeight();
322 int ledgendSize = legend->minHeight();
324 int bottomPadding = m_marginTiny + m_marginSmall + ledgendSize + m_marginTiny + m_minBottomMargin;
323 int bottomPadding = m_marginTiny + m_marginSmall + ledgendSize + m_marginTiny + m_minBottomMargin;
325 m_chartMargins = QRect(QPoint(m_chartMargins.left(),m_chartMargins.top()),QPoint(m_chartMargins.right(),bottomPadding));
324 m_chartMargins = QRect(QPoint(m_chartMargins.left(),m_chartMargins.top()),QPoint(m_chartMargins.right(),bottomPadding));
326 m_legendMargins = QRect(QPoint(m_chartMargins.left(),m_rect.height()-bottomPadding + m_marginTiny + m_minBottomMargin),QPoint(m_chartMargins.right(),m_marginTiny + m_marginSmall));
325 m_legendMargins = QRect(QPoint(m_chartMargins.left(),m_rect.height()-bottomPadding + m_marginTiny + m_minBottomMargin),QPoint(m_chartMargins.right(),m_marginTiny + m_marginSmall));
327 titlePadding = m_chartMargins.top()/2;
326 titlePadding = m_chartMargins.top()/2;
328 break;
327 break;
329 }
328 }
330 case QLegend::AlignmentLeft: {
329 case QLegend::AlignmentLeft: {
331 int ledgendSize = legend->minWidth();
330 int ledgendSize = legend->minWidth();
332 int leftPadding = m_marginTiny + m_marginSmall + ledgendSize + m_marginTiny + m_minLeftMargin;
331 int leftPadding = m_marginTiny + m_marginSmall + ledgendSize + m_marginTiny + m_minLeftMargin;
333 m_chartMargins = QRect(QPoint(leftPadding,m_chartMargins.top()),QPoint(m_chartMargins.right(),m_chartMargins.bottom()));
332 m_chartMargins = QRect(QPoint(leftPadding,m_chartMargins.top()),QPoint(m_chartMargins.right(),m_chartMargins.bottom()));
334 m_legendMargins = QRect(QPoint(m_marginTiny + m_marginSmall,m_chartMargins.top()),QPoint(m_rect.width()-leftPadding + m_marginTiny + m_minLeftMargin,m_chartMargins.bottom()));
333 m_legendMargins = QRect(QPoint(m_marginTiny + m_marginSmall,m_chartMargins.top()),QPoint(m_rect.width()-leftPadding + m_marginTiny + m_minLeftMargin,m_chartMargins.bottom()));
335 titlePadding = m_chartMargins.top()/2;
334 titlePadding = m_chartMargins.top()/2;
336 break;
335 break;
337 }
336 }
338 case QLegend::AlignmentRight: {
337 case QLegend::AlignmentRight: {
339 int ledgendSize = legend->minWidth();
338 int ledgendSize = legend->minWidth();
340 int rightPadding = m_marginTiny + m_marginSmall + ledgendSize + m_marginTiny;
339 int rightPadding = m_marginTiny + m_marginSmall + ledgendSize + m_marginTiny;
341 m_chartMargins = QRect(QPoint(m_chartMargins.left(),m_chartMargins.top()),QPoint(rightPadding,m_chartMargins.bottom()));
340 m_chartMargins = QRect(QPoint(m_chartMargins.left(),m_chartMargins.top()),QPoint(rightPadding,m_chartMargins.bottom()));
342 m_legendMargins = QRect(QPoint(m_rect.width()- rightPadding+ m_marginTiny ,m_chartMargins.top()),QPoint(m_marginTiny + m_marginSmall,m_chartMargins.bottom()));
341 m_legendMargins = QRect(QPoint(m_rect.width()- rightPadding+ m_marginTiny ,m_chartMargins.top()),QPoint(m_marginTiny + m_marginSmall,m_chartMargins.bottom()));
343 titlePadding = m_chartMargins.top()/2;
342 titlePadding = m_chartMargins.top()/2;
344 break;
343 break;
345 }
344 }
346 default: {
345 default: {
347 break;
346 break;
348 }
347 }
349 }
348 }
350 }
349 }
351
350
352 if(m_rect.width()<2*(m_chartMargins.top()+m_chartMargins.bottom()) || m_rect.height()< 2*(m_chartMargins.top() + m_chartMargins.bottom()))
351 if(m_rect.width()<2*(m_chartMargins.top()+m_chartMargins.bottom()) || m_rect.height()< 2*(m_chartMargins.top() + m_chartMargins.bottom()))
353 {
352 {
354 m_chart->setMinimumSize(2*(m_chartMargins.top()+m_chartMargins.bottom()),2*(m_chartMargins.top() + m_chartMargins.bottom()));
353 m_chart->setMinimumSize(2*(m_chartMargins.top()+m_chartMargins.bottom()),2*(m_chartMargins.top() + m_chartMargins.bottom()));
355 return;
354 return;
356 }
355 }
357
356
358
357
359 // recalculate title position
358 // recalculate title position
360 if (m_titleItem) {
359 if (m_titleItem) {
361 QPointF center = m_rect.center() -m_titleItem->boundingRect().center();
360 QPointF center = m_rect.center() -m_titleItem->boundingRect().center();
362 m_titleItem->setPos(center.x(),titlePadding);
361 m_titleItem->setPos(center.x(),titlePadding);
363 }
362 }
364
363
365 //recalculate background gradient
364 //recalculate background gradient
366 if (m_backgroundItem) {
365 if (m_backgroundItem) {
367 m_backgroundItem->setRect(m_rect.adjusted(m_marginTiny,m_marginTiny, -m_marginTiny, -m_marginTiny));
366 m_backgroundItem->setRect(m_rect.adjusted(m_marginTiny,m_marginTiny, -m_marginTiny, -m_marginTiny));
368 }
367 }
369
368
370
369
371 QRectF chartRect = m_rect.adjusted(m_chartMargins.left(),m_chartMargins.top(),-m_chartMargins.right(),-m_chartMargins.bottom());
370 QRectF chartRect = m_rect.adjusted(m_chartMargins.left(),m_chartMargins.top(),-m_chartMargins.right(),-m_chartMargins.bottom());
372
371
373 legend->setGeometry(m_rect.adjusted(m_legendMargins.left(),m_legendMargins.top(),-m_legendMargins.right(),-m_legendMargins.bottom()));
372 legend->setGeometry(m_rect.adjusted(m_legendMargins.left(),m_legendMargins.top(),-m_legendMargins.right(),-m_legendMargins.bottom()));
374
373
375 if(m_chartRect!=chartRect){
374 if(m_chartRect!=chartRect){
376 m_chartRect=chartRect;
375 m_chartRect=chartRect;
377 emit geometryChanged(m_chartRect);
376 emit geometryChanged(m_chartRect);
378 }
377 }
379
378
380
379
381 }
380 }
382
381
383 void ChartPresenter::createChartBackgroundItem()
382 void ChartPresenter::createChartBackgroundItem()
384 {
383 {
385 if (!m_backgroundItem) {
384 if (!m_backgroundItem) {
386 m_backgroundItem = new ChartBackground(rootItem());
385 m_backgroundItem = new ChartBackground(rootItem());
387 m_backgroundItem->setPen(Qt::NoPen);
386 m_backgroundItem->setPen(Qt::NoPen);
388 m_backgroundItem->setZValue(ChartPresenter::BackgroundZValue);
387 m_backgroundItem->setZValue(ChartPresenter::BackgroundZValue);
389 }
388 }
390 }
389 }
391
390
392 void ChartPresenter::createChartTitleItem()
391 void ChartPresenter::createChartTitleItem()
393 {
392 {
394 if (!m_titleItem) {
393 if (!m_titleItem) {
395 m_titleItem = new QGraphicsSimpleTextItem(rootItem());
394 m_titleItem = new QGraphicsSimpleTextItem(rootItem());
396 m_titleItem->setZValue(ChartPresenter::BackgroundZValue);
395 m_titleItem->setZValue(ChartPresenter::BackgroundZValue);
397 }
396 }
398 }
397 }
399
398
400 #include "moc_chartpresenter_p.cpp"
399 #include "moc_chartpresenter_p.cpp"
401
400
402 QTCOMMERCIALCHART_END_NAMESPACE
401 QTCOMMERCIALCHART_END_NAMESPACE
@@ -1,125 +1,125
1 /****************************************************************************
1 /****************************************************************************
2 **
2 **
3 ** Copyright (C) 2012 Digia Plc
3 ** Copyright (C) 2012 Digia Plc
4 ** All rights reserved.
4 ** All rights reserved.
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 **
6 **
7 ** This file is part of the Qt Commercial Charts Add-on.
7 ** This file is part of the Qt Commercial Charts Add-on.
8 **
8 **
9 ** $QT_BEGIN_LICENSE$
9 ** $QT_BEGIN_LICENSE$
10 ** Licensees holding valid Qt Commercial licenses may use this file in
10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 ** accordance with the Qt Commercial License Agreement provided with the
11 ** accordance with the Qt Commercial License Agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia.
13 ** a written agreement between you and Digia.
14 **
14 **
15 ** If you have questions regarding the use of this file, please use
15 ** If you have questions regarding the use of this file, please use
16 ** contact form at http://qt.digia.com
16 ** contact form at http://qt.digia.com
17 ** $QT_END_LICENSE$
17 ** $QT_END_LICENSE$
18 **
18 **
19 ****************************************************************************/
19 ****************************************************************************/
20
20
21 #ifndef CHARTPRESENTER_H_
21 #ifndef CHARTPRESENTER_H
22 #define CHARTPRESENTER_H_
22 #define CHARTPRESENTER_H
23
23
24 #include "qchartglobal.h"
24 #include "qchartglobal.h"
25 #include "chartbackground_p.h" //TODO fix me
25 #include "chartbackground_p.h" //TODO fix me
26 #include "qchart.h" //becouse of QChart::ChartThemeId //TODO
26 #include "qchart.h" //becouse of QChart::ChartThemeId //TODO
27 #include "qchartaxis.h"
27 #include "qchartaxis.h"
28 #include <QRectF>
28 #include <QRectF>
29
29
30 QTCOMMERCIALCHART_BEGIN_NAMESPACE
30 QTCOMMERCIALCHART_BEGIN_NAMESPACE
31
31
32 class Chart;
32 class Chart;
33 class QSeries;
33 class QSeries;
34 class ChartDataSet;
34 class ChartDataSet;
35 class Domain;
35 class Domain;
36 class Axis;
36 class Axis;
37 class ChartTheme;
37 class ChartTheme;
38 class ChartAnimator;
38 class ChartAnimator;
39
39
40 class ChartPresenter: public QObject
40 class ChartPresenter: public QObject
41 {
41 {
42 Q_OBJECT
42 Q_OBJECT
43 public:
43 public:
44 enum ZValues {
44 enum ZValues {
45 BackgroundZValue = -1,
45 BackgroundZValue = -1,
46 ShadesZValue,
46 ShadesZValue,
47 GridZValue,
47 GridZValue,
48 LineChartZValue,
48 LineChartZValue,
49 BarSeriesZValue,
49 BarSeriesZValue,
50 ScatterSeriesZValue,
50 ScatterSeriesZValue,
51 PieSeriesZValue,
51 PieSeriesZValue,
52 AxisZValue,
52 AxisZValue,
53 LegendZValue
53 LegendZValue
54 };
54 };
55
55
56 ChartPresenter(QChart* chart,ChartDataSet *dataset);
56 ChartPresenter(QChart* chart,ChartDataSet *dataset);
57 virtual ~ChartPresenter();
57 virtual ~ChartPresenter();
58
58
59 ChartAnimator* animator() const { return m_animator; }
59 ChartAnimator* animator() const { return m_animator; }
60 ChartTheme *chartTheme() const { return m_chartTheme; }
60 ChartTheme *chartTheme() const { return m_chartTheme; }
61 ChartDataSet *dataSet() const { return m_dataset; }
61 ChartDataSet *dataSet() const { return m_dataset; }
62 QGraphicsItem* rootItem() const { return m_chart; }
62 QGraphicsItem* rootItem() const { return m_chart; }
63
63
64 void setTheme(QChart::ChartTheme theme,bool force = true);
64 void setTheme(QChart::ChartTheme theme,bool force = true);
65 QChart::ChartTheme theme();
65 QChart::ChartTheme theme();
66
66
67 void setAnimationOptions(QChart::AnimationOptions options);
67 void setAnimationOptions(QChart::AnimationOptions options);
68 QChart::AnimationOptions animationOptions() const;
68 QChart::AnimationOptions animationOptions() const;
69
69
70 void zoomIn();
70 void zoomIn();
71 void zoomIn(const QRectF& rect);
71 void zoomIn(const QRectF& rect);
72 void zoomOut();
72 void zoomOut();
73 void scroll(int dx,int dy);
73 void scroll(int dx,int dy);
74
74
75 void setGeometry(const QRectF& rect);
75 void setGeometry(const QRectF& rect);
76 QRectF chartGeometry() const { return m_chartRect; }
76 QRectF chartGeometry() const { return m_chartRect; }
77
77
78 void setMinimumMarginHeight(Axis* axis, qreal height);
78 void setMinimumMarginHeight(Axis* axis, qreal height);
79 void setMinimumMarginWidth(Axis* axis, qreal width);
79 void setMinimumMarginWidth(Axis* axis, qreal width);
80 qreal minimumLeftMargin() const { return m_minLeftMargin; }
80 qreal minimumLeftMargin() const { return m_minLeftMargin; }
81 qreal minimumBottomMargin() const { return m_minBottomMargin; }
81 qreal minimumBottomMargin() const { return m_minBottomMargin; }
82
82
83 public: //TODO: fix me
83 public: //TODO: fix me
84 void resetAllElements();
84 void resetAllElements();
85 void createChartBackgroundItem();
85 void createChartBackgroundItem();
86 void createChartTitleItem();
86 void createChartTitleItem();
87 QRectF margins() const { return m_chartMargins;}
87 QRectF margins() const { return m_chartMargins;}
88
88
89 public Q_SLOTS:
89 public Q_SLOTS:
90 void handleSeriesAdded(QSeries* series,Domain* domain);
90 void handleSeriesAdded(QSeries* series,Domain* domain);
91 void handleSeriesRemoved(QSeries* series);
91 void handleSeriesRemoved(QSeries* series);
92 void handleAxisAdded(QChartAxis* axis,Domain* domain);
92 void handleAxisAdded(QChartAxis* axis,Domain* domain);
93 void handleAxisRemoved(QChartAxis* axis);
93 void handleAxisRemoved(QChartAxis* axis);
94 void updateLayout();
94 void updateLayout();
95
95
96 Q_SIGNALS:
96 Q_SIGNALS:
97 void geometryChanged(const QRectF& rect);
97 void geometryChanged(const QRectF& rect);
98
98
99
99
100 private:
100 private:
101 QChart* m_chart;
101 QChart* m_chart;
102 ChartAnimator* m_animator;
102 ChartAnimator* m_animator;
103 ChartDataSet* m_dataset;
103 ChartDataSet* m_dataset;
104 ChartTheme *m_chartTheme;
104 ChartTheme *m_chartTheme;
105 QMap<QSeries*,Chart*> m_chartItems;
105 QMap<QSeries*,Chart*> m_chartItems;
106 QMap<QChartAxis*,Axis*> m_axisItems;
106 QMap<QChartAxis*,Axis*> m_axisItems;
107 QRectF m_rect;
107 QRectF m_rect;
108 QRectF m_chartRect;
108 QRectF m_chartRect;
109 QChart::AnimationOptions m_options;
109 QChart::AnimationOptions m_options;
110 qreal m_minLeftMargin;
110 qreal m_minLeftMargin;
111 qreal m_minBottomMargin;
111 qreal m_minBottomMargin;
112 public: //TODO: fixme
112 public: //TODO: fixme
113 ChartBackground* m_backgroundItem;
113 ChartBackground* m_backgroundItem;
114 QGraphicsSimpleTextItem* m_titleItem;
114 QGraphicsSimpleTextItem* m_titleItem;
115 int m_marginBig;
115 int m_marginBig;
116 int m_marginSmall;
116 int m_marginSmall;
117 int m_marginTiny;
117 int m_marginTiny;
118 QRectF m_chartMargins;
118 QRectF m_chartMargins;
119 QRectF m_legendMargins;
119 QRectF m_legendMargins;
120
120
121 };
121 };
122
122
123 QTCOMMERCIALCHART_END_NAMESPACE
123 QTCOMMERCIALCHART_END_NAMESPACE
124
124
125 #endif /* CHARTPRESENTER_H_ */
125 #endif /* CHARTPRESENTER_H_ */
@@ -1,91 +1,91
1 /****************************************************************************
1 /****************************************************************************
2 **
2 **
3 ** Copyright (C) 2012 Digia Plc
3 ** Copyright (C) 2012 Digia Plc
4 ** All rights reserved.
4 ** All rights reserved.
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 **
6 **
7 ** This file is part of the Qt Commercial Charts Add-on.
7 ** This file is part of the Qt Commercial Charts Add-on.
8 **
8 **
9 ** $QT_BEGIN_LICENSE$
9 ** $QT_BEGIN_LICENSE$
10 ** Licensees holding valid Qt Commercial licenses may use this file in
10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 ** accordance with the Qt Commercial License Agreement provided with the
11 ** accordance with the Qt Commercial License Agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia.
13 ** a written agreement between you and Digia.
14 **
14 **
15 ** If you have questions regarding the use of this file, please use
15 ** If you have questions regarding the use of this file, please use
16 ** contact form at http://qt.digia.com
16 ** contact form at http://qt.digia.com
17 ** $QT_END_LICENSE$
17 ** $QT_END_LICENSE$
18 **
18 **
19 ****************************************************************************/
19 ****************************************************************************/
20
20
21 #ifndef DOMAIN_H_
21 #ifndef DOMAIN_H
22 #define DOMAIN_H_
22 #define DOMAIN_H
23 #include "qchartglobal.h"
23 #include "qchartglobal.h"
24 #include <QRectF>
24 #include <QRectF>
25 #include <QSizeF>
25 #include <QSizeF>
26
26
27 QTCOMMERCIALCHART_BEGIN_NAMESPACE
27 QTCOMMERCIALCHART_BEGIN_NAMESPACE
28
28
29 class Domain: public QObject {
29 class Domain: public QObject {
30 Q_OBJECT
30 Q_OBJECT
31 public:
31 public:
32 explicit Domain(QObject* object=0);
32 explicit Domain(QObject* object=0);
33 virtual ~Domain();
33 virtual ~Domain();
34
34
35 void setRange(qreal minX, qreal maxX, qreal minY, qreal maxY);
35 void setRange(qreal minX, qreal maxX, qreal minY, qreal maxY);
36 void setRange(qreal minX, qreal maxX, qreal minY, qreal maxY, int tickXCount, int tickYCount);
36 void setRange(qreal minX, qreal maxX, qreal minY, qreal maxY, int tickXCount, int tickYCount);
37 void setRangeX(qreal min, qreal max);
37 void setRangeX(qreal min, qreal max);
38 void setRangeX(qreal min, qreal max, int tickCount);
38 void setRangeX(qreal min, qreal max, int tickCount);
39 void setRangeY(qreal min, qreal max);
39 void setRangeY(qreal min, qreal max);
40 void setRangeY(qreal min, qreal max, int tickCount);
40 void setRangeY(qreal min, qreal max, int tickCount);
41 void setMinX(qreal min);
41 void setMinX(qreal min);
42 void setMaxX(qreal max);
42 void setMaxX(qreal max);
43 void setMinY(qreal min);
43 void setMinY(qreal min);
44 void setMaxY(qreal max);
44 void setMaxY(qreal max);
45
45
46 qreal minX() const { return m_minX; }
46 qreal minX() const { return m_minX; }
47 qreal maxX() const { return m_maxX; }
47 qreal maxX() const { return m_maxX; }
48 qreal minY() const { return m_minY; }
48 qreal minY() const { return m_minY; }
49 qreal maxY() const { return m_maxY; }
49 qreal maxY() const { return m_maxY; }
50
50
51 qreal spanX() const;
51 qreal spanX() const;
52 qreal spanY() const;
52 qreal spanY() const;
53 bool isEmpty() const;
53 bool isEmpty() const;
54
54
55 int tickXCount() const {return m_tickXCount;}
55 int tickXCount() const {return m_tickXCount;}
56 int tickYCount() const {return m_tickYCount;}
56 int tickYCount() const {return m_tickYCount;}
57
57
58 friend bool operator== (const Domain &domain1, const Domain &domain2);
58 friend bool operator== (const Domain &domain1, const Domain &domain2);
59 friend bool operator!= (const Domain &domain1, const Domain &domain2);
59 friend bool operator!= (const Domain &domain1, const Domain &domain2);
60 friend QDebug operator<<(QDebug dbg, const Domain &domain);
60 friend QDebug operator<<(QDebug dbg, const Domain &domain);
61
61
62 void zoomIn(const QRectF& rect, const QSizeF& size);
62 void zoomIn(const QRectF& rect, const QSizeF& size);
63 void zoomOut(const QRectF& rect, const QSizeF& size);
63 void zoomOut(const QRectF& rect, const QSizeF& size);
64 void move(int dx,int dy,const QSizeF& size);
64 void move(int dx,int dy,const QSizeF& size);
65
65
66 Q_SIGNALS:
66 Q_SIGNALS:
67 void domainChanged(qreal minX, qreal maxX, qreal minY, qreal maxY);
67 void domainChanged(qreal minX, qreal maxX, qreal minY, qreal maxY);
68 void rangeXChanged(qreal min, qreal max, int tickXCount);
68 void rangeXChanged(qreal min, qreal max, int tickXCount);
69 void rangeYChanged(qreal min, qreal max, int tickYCount);
69 void rangeYChanged(qreal min, qreal max, int tickYCount);
70
70
71 public Q_SLOTS:
71 public Q_SLOTS:
72 void handleAxisXChanged(qreal min,qreal max,int tickXCount = 5,bool niceNumbers = false);
72 void handleAxisXChanged(qreal min,qreal max,int tickXCount = 5,bool niceNumbers = false);
73 void handleAxisYChanged(qreal min,qreal max,int tickYCount = 5,bool niceNumbers = false);
73 void handleAxisYChanged(qreal min,qreal max,int tickYCount = 5,bool niceNumbers = false);
74
74
75 private:
75 private:
76 void looseNiceNumbers(qreal &min, qreal &max, int &ticksCount);
76 void looseNiceNumbers(qreal &min, qreal &max, int &ticksCount);
77 qreal niceNumber(qreal x,bool celing);
77 qreal niceNumber(qreal x,bool celing);
78
78
79 private:
79 private:
80 qreal m_minX;
80 qreal m_minX;
81 qreal m_maxX;
81 qreal m_maxX;
82 qreal m_minY;
82 qreal m_minY;
83 qreal m_maxY;
83 qreal m_maxY;
84 int m_tickXCount;
84 int m_tickXCount;
85 int m_tickYCount;
85 int m_tickYCount;
86 bool m_niceNumbers;
86 bool m_niceNumbers;
87 };
87 };
88
88
89 QTCOMMERCIALCHART_END_NAMESPACE
89 QTCOMMERCIALCHART_END_NAMESPACE
90
90
91 #endif
91 #endif
@@ -1,72 +1,72
1 /****************************************************************************
1 /****************************************************************************
2 **
2 **
3 ** Copyright (C) 2012 Digia Plc
3 ** Copyright (C) 2012 Digia Plc
4 ** All rights reserved.
4 ** All rights reserved.
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 **
6 **
7 ** This file is part of the Qt Commercial Charts Add-on.
7 ** This file is part of the Qt Commercial Charts Add-on.
8 **
8 **
9 ** $QT_BEGIN_LICENSE$
9 ** $QT_BEGIN_LICENSE$
10 ** Licensees holding valid Qt Commercial licenses may use this file in
10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 ** accordance with the Qt Commercial License Agreement provided with the
11 ** accordance with the Qt Commercial License Agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia.
13 ** a written agreement between you and Digia.
14 **
14 **
15 ** If you have questions regarding the use of this file, please use
15 ** If you have questions regarding the use of this file, please use
16 ** contact form at http://qt.digia.com
16 ** contact form at http://qt.digia.com
17 ** $QT_END_LICENSE$
17 ** $QT_END_LICENSE$
18 **
18 **
19 ****************************************************************************/
19 ****************************************************************************/
20
20
21 // W A R N I N G
21 // W A R N I N G
22 // -------------
22 // -------------
23 //
23 //
24 // This file is not part of the QtCommercial Chart API. It exists purely as an
24 // This file is not part of the QtCommercial Chart API. It exists purely as an
25 // implementation detail. This header file may change from version to
25 // implementation detail. This header file may change from version to
26 // version without notice, or even be removed.
26 // version without notice, or even be removed.
27 //
27 //
28 // We mean it.
28 // We mean it.
29
29
30
30
31 #ifndef LEGENDSCROLLER_P_H_
31 #ifndef LEGENDSCROLLER_P_H
32 #define LEGENDSCROLLER_P_H_
32 #define LEGENDSCROLLER_P_H
33
33
34 #include "qlegend.h"
34 #include "qlegend.h"
35 #include "scroller_p.h"
35 #include "scroller_p.h"
36
36
37 QTCOMMERCIALCHART_BEGIN_NAMESPACE
37 QTCOMMERCIALCHART_BEGIN_NAMESPACE
38
38
39 class LegendScroller: public QLegend, public Scroller
39 class LegendScroller: public QLegend, public Scroller
40 {
40 {
41
41
42 public:
42 public:
43 LegendScroller(QChart *chart):QLegend(chart)
43 LegendScroller(QChart *chart):QLegend(chart)
44 {
44 {
45 }
45 }
46
46
47 void setOffset(const QPointF& point)
47 void setOffset(const QPointF& point)
48 {
48 {
49 QLegend::setOffset(point);
49 QLegend::setOffset(point);
50 }
50 }
51 QPointF offset() const
51 QPointF offset() const
52 {
52 {
53 return QLegend::offset();
53 return QLegend::offset();
54 }
54 }
55
55
56 void mousePressEvent(QGraphicsSceneMouseEvent* event){
56 void mousePressEvent(QGraphicsSceneMouseEvent* event){
57 Scroller::mousePressEvent(event);
57 Scroller::mousePressEvent(event);
58 //QLegend::mousePressEvent(event);
58 //QLegend::mousePressEvent(event);
59 }
59 }
60 void mouseMoveEvent(QGraphicsSceneMouseEvent* event){
60 void mouseMoveEvent(QGraphicsSceneMouseEvent* event){
61 Scroller::mouseMoveEvent(event);
61 Scroller::mouseMoveEvent(event);
62 //QLegend::mouseMoveEvent(event);
62 //QLegend::mouseMoveEvent(event);
63 }
63 }
64 void mouseReleaseEvent(QGraphicsSceneMouseEvent* event){
64 void mouseReleaseEvent(QGraphicsSceneMouseEvent* event){
65 Scroller::mouseReleaseEvent(event);
65 Scroller::mouseReleaseEvent(event);
66 //QLegend::mouseReleaseEvent(event);
66 //QLegend::mouseReleaseEvent(event);
67 }
67 }
68 };
68 };
69
69
70 QTCOMMERCIALCHART_END_NAMESPACE
70 QTCOMMERCIALCHART_END_NAMESPACE
71
71
72 #endif
72 #endif
@@ -1,77 +1,77
1 /****************************************************************************
1 /****************************************************************************
2 **
2 **
3 ** Copyright (C) 2012 Digia Plc
3 ** Copyright (C) 2012 Digia Plc
4 ** All rights reserved.
4 ** All rights reserved.
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 **
6 **
7 ** This file is part of the Qt Commercial Charts Add-on.
7 ** This file is part of the Qt Commercial Charts Add-on.
8 **
8 **
9 ** $QT_BEGIN_LICENSE$
9 ** $QT_BEGIN_LICENSE$
10 ** Licensees holding valid Qt Commercial licenses may use this file in
10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 ** accordance with the Qt Commercial License Agreement provided with the
11 ** accordance with the Qt Commercial License Agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia.
13 ** a written agreement between you and Digia.
14 **
14 **
15 ** If you have questions regarding the use of this file, please use
15 ** If you have questions regarding the use of this file, please use
16 ** contact form at http://qt.digia.com
16 ** contact form at http://qt.digia.com
17 ** $QT_END_LICENSE$
17 ** $QT_END_LICENSE$
18 **
18 **
19 ****************************************************************************/
19 ****************************************************************************/
20
20
21 // W A R N I N G
21 // W A R N I N G
22 // -------------
22 // -------------
23 //
23 //
24 // This file is not part of the QtCommercial Chart API. It exists purely as an
24 // This file is not part of the QtCommercial Chart API. It exists purely as an
25 // implementation detail. This header file may change from version to
25 // implementation detail. This header file may change from version to
26 // version without notice, or even be removed.
26 // version without notice, or even be removed.
27 //
27 //
28 // We mean it.
28 // We mean it.
29
29
30 #ifndef QLEGEND_P_H_
30 #ifndef QLEGEND_P_H
31 #define QLEGEND_P_H_
31 #define QLEGEND_P_H
32
32
33 #include "qlegend.h"
33 #include "qlegend.h"
34
34
35 QTCOMMERCIALCHART_BEGIN_NAMESPACE
35 QTCOMMERCIALCHART_BEGIN_NAMESPACE
36
36
37 class ChartPresenter;
37 class ChartPresenter;
38
38
39 class QLegendPrivate : public QObject
39 class QLegendPrivate : public QObject
40 {
40 {
41 Q_OBJECT
41 Q_OBJECT
42 public:
42 public:
43 QLegendPrivate(ChartPresenter *chart,QLegend *q);
43 QLegendPrivate(ChartPresenter *chart,QLegend *q);
44 ~QLegendPrivate();
44 ~QLegendPrivate();
45
45
46 void setOffset(qreal x, qreal y);
46 void setOffset(qreal x, qreal y);
47 void updateLayout();
47 void updateLayout();
48
48
49 public Q_SLOTS:
49 public Q_SLOTS:
50 void handleSeriesAdded(QSeries *series, Domain *domain);
50 void handleSeriesAdded(QSeries *series, Domain *domain);
51 void handleSeriesRemoved(QSeries *series);
51 void handleSeriesRemoved(QSeries *series);
52 void handleUpdateSeries(); //TODO remove this function
52 void handleUpdateSeries(); //TODO remove this function
53
53
54 private:
54 private:
55 QLegend *q_ptr;
55 QLegend *q_ptr;
56 ChartPresenter *m_presenter;
56 ChartPresenter *m_presenter;
57 QGraphicsItemGroup* m_markers;
57 QGraphicsItemGroup* m_markers;
58 QLegend::Alignments m_alignment;
58 QLegend::Alignments m_alignment;
59 QBrush m_brush;
59 QBrush m_brush;
60 QPen m_pen;
60 QPen m_pen;
61 QRectF m_rect;
61 QRectF m_rect;
62 qreal m_offsetX;
62 qreal m_offsetX;
63 qreal m_offsetY;
63 qreal m_offsetY;
64 qreal m_minWidth;
64 qreal m_minWidth;
65 qreal m_minHeight;
65 qreal m_minHeight;
66 qreal m_width;
66 qreal m_width;
67 qreal m_height;
67 qreal m_height;
68 bool m_attachedToChart;
68 bool m_attachedToChart;
69 bool m_backgroundVisible;
69 bool m_backgroundVisible;
70
70
71 friend class QLegend;
71 friend class QLegend;
72
72
73 };
73 };
74
74
75 QTCOMMERCIALCHART_END_NAMESPACE
75 QTCOMMERCIALCHART_END_NAMESPACE
76
76
77 #endif
77 #endif
@@ -1,52 +1,52
1 /****************************************************************************
1 /****************************************************************************
2 **
2 **
3 ** Copyright (C) 2012 Digia Plc
3 ** Copyright (C) 2012 Digia Plc
4 ** All rights reserved.
4 ** All rights reserved.
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 **
6 **
7 ** This file is part of the Qt Commercial Charts Add-on.
7 ** This file is part of the Qt Commercial Charts Add-on.
8 **
8 **
9 ** $QT_BEGIN_LICENSE$
9 ** $QT_BEGIN_LICENSE$
10 ** Licensees holding valid Qt Commercial licenses may use this file in
10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 ** accordance with the Qt Commercial License Agreement provided with the
11 ** accordance with the Qt Commercial License Agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia.
13 ** a written agreement between you and Digia.
14 **
14 **
15 ** If you have questions regarding the use of this file, please use
15 ** If you have questions regarding the use of this file, please use
16 ** contact form at http://qt.digia.com
16 ** contact form at http://qt.digia.com
17 ** $QT_END_LICENSE$
17 ** $QT_END_LICENSE$
18 **
18 **
19 ****************************************************************************/
19 ****************************************************************************/
20
20
21 #ifndef QLINESERIES_H_
21 #ifndef QLINESERIES_H
22 #define QLINESERIES_H_
22 #define QLINESERIES_H
23
23
24 #include <qchartglobal.h>
24 #include <qchartglobal.h>
25 #include <qxyseries.h>
25 #include <qxyseries.h>
26 #include <QPen>
26 #include <QPen>
27
27
28 QTCOMMERCIALCHART_BEGIN_NAMESPACE
28 QTCOMMERCIALCHART_BEGIN_NAMESPACE
29
29
30 class QLineSeriesPrivate;
30 class QLineSeriesPrivate;
31
31
32 class QTCOMMERCIALCHART_EXPORT QLineSeries : public QXYSeries
32 class QTCOMMERCIALCHART_EXPORT QLineSeries : public QXYSeries
33 {
33 {
34 public:
34 public:
35 explicit QLineSeries(QObject *parent=0);
35 explicit QLineSeries(QObject *parent=0);
36 ~QLineSeries();
36 ~QLineSeries();
37
37
38 QSeries::QSeriesType type() const;
38 QSeries::QSeriesType type() const;
39
39
40 protected:
40 protected:
41 QLineSeries(QLineSeriesPrivate &d,QObject *parent = 0);
41 QLineSeries(QLineSeriesPrivate &d,QObject *parent = 0);
42
42
43 private:
43 private:
44 Q_DECLARE_PRIVATE(QLineSeries);
44 Q_DECLARE_PRIVATE(QLineSeries);
45 Q_DISABLE_COPY(QLineSeries);
45 Q_DISABLE_COPY(QLineSeries);
46 friend class LineChartItem;
46 friend class LineChartItem;
47
47
48 };
48 };
49
49
50 QTCOMMERCIALCHART_END_NAMESPACE
50 QTCOMMERCIALCHART_END_NAMESPACE
51
51
52 #endif
52 #endif
@@ -1,50 +1,50
1 /****************************************************************************
1 /****************************************************************************
2 **
2 **
3 ** Copyright (C) 2012 Digia Plc
3 ** Copyright (C) 2012 Digia Plc
4 ** All rights reserved.
4 ** All rights reserved.
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 **
6 **
7 ** This file is part of the Qt Commercial Charts Add-on.
7 ** This file is part of the Qt Commercial Charts Add-on.
8 **
8 **
9 ** $QT_BEGIN_LICENSE$
9 ** $QT_BEGIN_LICENSE$
10 ** Licensees holding valid Qt Commercial licenses may use this file in
10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 ** accordance with the Qt Commercial License Agreement provided with the
11 ** accordance with the Qt Commercial License Agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia.
13 ** a written agreement between you and Digia.
14 **
14 **
15 ** If you have questions regarding the use of this file, please use
15 ** If you have questions regarding the use of this file, please use
16 ** contact form at http://qt.digia.com
16 ** contact form at http://qt.digia.com
17 ** $QT_END_LICENSE$
17 ** $QT_END_LICENSE$
18 **
18 **
19 ****************************************************************************/
19 ****************************************************************************/
20
20
21 // W A R N I N G
21 // W A R N I N G
22 // -------------
22 // -------------
23 //
23 //
24 // This file is not part of the QtCommercial Chart API. It exists purely as an
24 // This file is not part of the QtCommercial Chart API. It exists purely as an
25 // implementation detail. This header file may change from version to
25 // implementation detail. This header file may change from version to
26 // version without notice, or even be removed.
26 // version without notice, or even be removed.
27 //
27 //
28 // We mean it.
28 // We mean it.
29
29
30 #ifndef QLINESERIES_P_H_
30 #ifndef QLINESERIES_P_H
31 #define QLINESERIES_P_H_
31 #define QLINESERIES_P_H
32
32
33 #include "qxyseries_p.h"
33 #include "qxyseries_p.h"
34
34
35 QTCOMMERCIALCHART_BEGIN_NAMESPACE
35 QTCOMMERCIALCHART_BEGIN_NAMESPACE
36
36
37
37
38 class QLineSeriesPrivate: public QXYSeriesPrivate
38 class QLineSeriesPrivate: public QXYSeriesPrivate
39 {
39 {
40 public:
40 public:
41 QLineSeriesPrivate(QLineSeries* q);
41 QLineSeriesPrivate(QLineSeries* q);
42 Chart* createGraphics(ChartPresenter* presenter);
42 Chart* createGraphics(ChartPresenter* presenter);
43 private:
43 private:
44 Q_DECLARE_PUBLIC(QLineSeries);
44 Q_DECLARE_PUBLIC(QLineSeries);
45
45
46 };
46 };
47
47
48 QTCOMMERCIALCHART_END_NAMESPACE
48 QTCOMMERCIALCHART_END_NAMESPACE
49
49
50 #endif
50 #endif
@@ -1,219 +1,218
1 /****************************************************************************
1 /****************************************************************************
2 **
2 **
3 ** Copyright (C) 2012 Digia Plc
3 ** Copyright (C) 2012 Digia Plc
4 ** All rights reserved.
4 ** All rights reserved.
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 **
6 **
7 ** This file is part of the Qt Commercial Charts Add-on.
7 ** This file is part of the Qt Commercial Charts Add-on.
8 **
8 **
9 ** $QT_BEGIN_LICENSE$
9 ** $QT_BEGIN_LICENSE$
10 ** Licensees holding valid Qt Commercial licenses may use this file in
10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 ** accordance with the Qt Commercial License Agreement provided with the
11 ** accordance with the Qt Commercial License Agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia.
13 ** a written agreement between you and Digia.
14 **
14 **
15 ** If you have questions regarding the use of this file, please use
15 ** If you have questions regarding the use of this file, please use
16 ** contact form at http://qt.digia.com
16 ** contact form at http://qt.digia.com
17 ** $QT_END_LICENSE$
17 ** $QT_END_LICENSE$
18 **
18 **
19 ****************************************************************************/
19 ****************************************************************************/
20
20
21 #include "qchartview.h"
21 #include "qchartview.h"
22 #include "qchart_p.h"
23 #include "qchartview_p.h"
22 #include "qchartview_p.h"
23 #include "qchart_p.h"
24 #include <QGraphicsScene>
24 #include <QGraphicsScene>
25 #include <QRubberBand>
25 #include <QRubberBand>
26
26
27
28 /*!
27 /*!
29 \enum QChartView::RubberBand
28 \enum QChartView::RubberBand
30
29
31 This enum describes the different types of rubber bands that can be used for zoom rect selection
30 This enum describes the different types of rubber bands that can be used for zoom rect selection
32
31
33 \value NoRubberBand
32 \value NoRubberBand
34 \value VerticalRubberBand
33 \value VerticalRubberBand
35 \value HorizonalRubberBand
34 \value HorizonalRubberBand
36 \value RectangleRubberBand
35 \value RectangleRubberBand
37 */
36 */
38
37
39 /*!
38 /*!
40 \class QChartView
39 \class QChartView
41 \brief Standalone charting widget.
40 \brief Standalone charting widget.
42
41
43 QChartView is a standalone widget that can display charts. It does not require separate
42 QChartView is a standalone widget that can display charts. It does not require separate
44 QGraphicsScene to work. It manages the graphical representation of different types of
43 QGraphicsScene to work. It manages the graphical representation of different types of
45 QChartSeries and other chart related objects like QChartAxis and QChartLegend. If you want to
44 QChartSeries and other chart related objects like QChartAxis and QChartLegend. If you want to
46 display a chart in your existing QGraphicsScene, you can use the QChart class instead.
45 display a chart in your existing QGraphicsScene, you can use the QChart class instead.
47
46
48 \sa QChart
47 \sa QChart
49 */
48 */
50
49
51 QTCOMMERCIALCHART_BEGIN_NAMESPACE
50 QTCOMMERCIALCHART_BEGIN_NAMESPACE
52
51
53 /*!
52 /*!
54 Constructs a chartView object which is a child of a\a parent.
53 Constructs a chartView object which is a child of a\a parent.
55 */
54 */
56 QChartView::QChartView(QChart *chart,QWidget *parent) :
55 QChartView::QChartView(QChart *chart,QWidget *parent) :
57 QGraphicsView(parent),
56 QGraphicsView(parent),
58 d_ptr(new QChartViewPrivate())
57 d_ptr(new QChartViewPrivate())
59 {
58 {
60 Q_ASSERT(chart);
59 Q_ASSERT(chart);
61 d_ptr->m_scene = new QGraphicsScene(this);
60 d_ptr->m_scene = new QGraphicsScene(this);
62 d_ptr->m_chart = chart;
61 d_ptr->m_chart = chart;
63 setFrameShape(QFrame::NoFrame);
62 setFrameShape(QFrame::NoFrame);
64 setBackgroundRole(QPalette::Window);
63 setBackgroundRole(QPalette::Window);
65 setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
64 setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
66 setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
65 setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
67 setScene(d_ptr->m_scene);
66 setScene(d_ptr->m_scene);
68 d_ptr->m_scene->addItem(chart);
67 d_ptr->m_scene->addItem(chart);
69 setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
68 setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
70 }
69 }
71
70
72
71
73 /*!
72 /*!
74 Destroys the object and it's children, like QChartSeries and QChartAxis object added to it.
73 Destroys the object and it's children, like QChartSeries and QChartAxis object added to it.
75 */
74 */
76 QChartView::~QChartView()
75 QChartView::~QChartView()
77 {
76 {
78 }
77 }
79
78
80 /*!
79 /*!
81 Returns the pointer to the associated chart
80 Returns the pointer to the associated chart
82 */
81 */
83 QChart* QChartView::chart() const
82 QChart* QChartView::chart() const
84 {
83 {
85 return d_ptr->m_chart;
84 return d_ptr->m_chart;
86 }
85 }
87
86
88 /*!
87 /*!
89 Sets the RubberBandPlicy to \a rubberBand. Selected policy determines the way zooming is performed.
88 Sets the RubberBandPlicy to \a rubberBand. Selected policy determines the way zooming is performed.
90 */
89 */
91 void QChartView::setRubberBand(const RubberBands& rubberBand)
90 void QChartView::setRubberBand(const RubberBands& rubberBand)
92 {
91 {
93 d_ptr->m_rubberBandFlags=rubberBand;
92 d_ptr->m_rubberBandFlags=rubberBand;
94
93
95 if (!d_ptr->m_rubberBandFlags) {
94 if (!d_ptr->m_rubberBandFlags) {
96 delete d_ptr->m_rubberBand;
95 delete d_ptr->m_rubberBand;
97 d_ptr->m_rubberBand=0;
96 d_ptr->m_rubberBand=0;
98 return;
97 return;
99 }
98 }
100
99
101 if (!d_ptr->m_rubberBand) {
100 if (!d_ptr->m_rubberBand) {
102 d_ptr->m_rubberBand = new QRubberBand(QRubberBand::Rectangle, this);
101 d_ptr->m_rubberBand = new QRubberBand(QRubberBand::Rectangle, this);
103 d_ptr->m_rubberBand->setEnabled(true);
102 d_ptr->m_rubberBand->setEnabled(true);
104 }
103 }
105 }
104 }
106
105
107 /*!
106 /*!
108 Returns the RubberBandPolicy that is currently being used by the widget.
107 Returns the RubberBandPolicy that is currently being used by the widget.
109 */
108 */
110 QChartView::RubberBands QChartView::rubberBand() const
109 QChartView::RubberBands QChartView::rubberBand() const
111 {
110 {
112 return d_ptr->m_rubberBandFlags;
111 return d_ptr->m_rubberBandFlags;
113 }
112 }
114
113
115 /*!
114 /*!
116 If Left mouse button is pressed and the RubberBandPolicy is enabled the \a event is accepted and the rubber band is displayed on the screen allowing the user to select the zoom area.
115 If Left mouse button is pressed and the RubberBandPolicy is enabled the \a event is accepted and the rubber band is displayed on the screen allowing the user to select the zoom area.
117 If different mouse button is pressed and/or the RubberBandPolicy is disabled then the \a event is passed to QGraphicsView::mousePressEvent() implementation.
116 If different mouse button is pressed and/or the RubberBandPolicy is disabled then the \a event is passed to QGraphicsView::mousePressEvent() implementation.
118 */
117 */
119 void QChartView::mousePressEvent(QMouseEvent *event)
118 void QChartView::mousePressEvent(QMouseEvent *event)
120 {
119 {
121 if(d_ptr->m_rubberBand && d_ptr->m_rubberBand->isEnabled() && event->button() == Qt::LeftButton) {
120 if(d_ptr->m_rubberBand && d_ptr->m_rubberBand->isEnabled() && event->button() == Qt::LeftButton) {
122
121
123 int padding = d_ptr->m_chart->margins().top();
122 int padding = d_ptr->m_chart->margins().top();
124 QRect rect(padding, padding, width() - 2 * padding, height() - 2 * padding);
123 QRect rect(padding, padding, width() - 2 * padding, height() - 2 * padding);
125
124
126 if (rect.contains(event->pos())) {
125 if (rect.contains(event->pos())) {
127 d_ptr->m_rubberBandOrigin = event->pos();
126 d_ptr->m_rubberBandOrigin = event->pos();
128 d_ptr->m_rubberBand->setGeometry(QRect(d_ptr->m_rubberBandOrigin, QSize()));
127 d_ptr->m_rubberBand->setGeometry(QRect(d_ptr->m_rubberBandOrigin, QSize()));
129 d_ptr->m_rubberBand->show();
128 d_ptr->m_rubberBand->show();
130 event->accept();
129 event->accept();
131 }
130 }
132 }
131 }
133 else {
132 else {
134 QGraphicsView::mousePressEvent(event);
133 QGraphicsView::mousePressEvent(event);
135 }
134 }
136 }
135 }
137
136
138 /*!
137 /*!
139 If RubberBand rectange specification has been initiated in pressEvent then \a event data is used to update RubberBand geometry.
138 If RubberBand rectange specification has been initiated in pressEvent then \a event data is used to update RubberBand geometry.
140 In other case the defualt QGraphicsView::mouseMoveEvent implementation is called.
139 In other case the defualt QGraphicsView::mouseMoveEvent implementation is called.
141 */
140 */
142 void QChartView::mouseMoveEvent(QMouseEvent *event)
141 void QChartView::mouseMoveEvent(QMouseEvent *event)
143 {
142 {
144 if(d_ptr->m_rubberBand && d_ptr->m_rubberBand->isVisible()) {
143 if(d_ptr->m_rubberBand && d_ptr->m_rubberBand->isVisible()) {
145 QRectF margins = d_ptr->m_chart->margins();
144 QRectF margins = d_ptr->m_chart->margins();
146 QRectF geometry = d_ptr->m_chart->geometry();
145 QRectF geometry = d_ptr->m_chart->geometry();
147 QRectF rect =geometry.adjusted(margins.left(),margins.top(),-margins.right(),-margins.bottom());
146 QRectF rect =geometry.adjusted(margins.left(),margins.top(),-margins.right(),-margins.bottom());
148 int width = event->pos().x() - d_ptr->m_rubberBandOrigin.x();
147 int width = event->pos().x() - d_ptr->m_rubberBandOrigin.x();
149 int height = event->pos().y() - d_ptr->m_rubberBandOrigin.y();
148 int height = event->pos().y() - d_ptr->m_rubberBandOrigin.y();
150 if (!d_ptr->m_rubberBandFlags.testFlag(VerticalRubberBand)) {
149 if (!d_ptr->m_rubberBandFlags.testFlag(VerticalRubberBand)) {
151 d_ptr->m_rubberBandOrigin.setY(rect.top());
150 d_ptr->m_rubberBandOrigin.setY(rect.top());
152 height = rect.height();
151 height = rect.height();
153 }
152 }
154 if (!d_ptr->m_rubberBandFlags.testFlag(HorizonalRubberBand)) {
153 if (!d_ptr->m_rubberBandFlags.testFlag(HorizonalRubberBand)) {
155 d_ptr->m_rubberBandOrigin.setX(rect.left());
154 d_ptr->m_rubberBandOrigin.setX(rect.left());
156 width= rect.width();
155 width= rect.width();
157 }
156 }
158 d_ptr->m_rubberBand->setGeometry(QRect(d_ptr->m_rubberBandOrigin.x(),d_ptr->m_rubberBandOrigin.y(), width,height).normalized());
157 d_ptr->m_rubberBand->setGeometry(QRect(d_ptr->m_rubberBandOrigin.x(),d_ptr->m_rubberBandOrigin.y(), width,height).normalized());
159 }
158 }
160 else {
159 else {
161 QGraphicsView::mouseMoveEvent(event);
160 QGraphicsView::mouseMoveEvent(event);
162 }
161 }
163 }
162 }
164
163
165 /*!
164 /*!
166 If left mouse button is release and RubberBand is enabled then \a event is accepted and the view is zoomed in to rect specified by RubberBand
165 If left mouse button is release and RubberBand is enabled then \a event is accepted and the view is zoomed in to rect specified by RubberBand
167 If it is the right mouse button \a event then RubberBand is dissmissed and zoom is canceled.
166 If it is the right mouse button \a event then RubberBand is dissmissed and zoom is canceled.
168 */
167 */
169 void QChartView::mouseReleaseEvent(QMouseEvent *event)
168 void QChartView::mouseReleaseEvent(QMouseEvent *event)
170 {
169 {
171 if(d_ptr->m_rubberBand) {
170 if(d_ptr->m_rubberBand) {
172 if (event->button() == Qt::LeftButton && d_ptr->m_rubberBand->isVisible()) {
171 if (event->button() == Qt::LeftButton && d_ptr->m_rubberBand->isVisible()) {
173 d_ptr->m_rubberBand->hide();
172 d_ptr->m_rubberBand->hide();
174 QRect rect = d_ptr->m_rubberBand->geometry();
173 QRect rect = d_ptr->m_rubberBand->geometry();
175 d_ptr->m_chart->zoomIn(rect);
174 d_ptr->m_chart->zoomIn(rect);
176 event->accept();
175 event->accept();
177 }
176 }
178
177
179 if(event->button()==Qt::RightButton){
178 if(event->button()==Qt::RightButton){
180 d_ptr->m_chart->zoomOut();
179 d_ptr->m_chart->zoomOut();
181 event->accept();
180 event->accept();
182 }
181 }
183 }
182 }
184 else {
183 else {
185 QGraphicsView::mouseReleaseEvent(event);
184 QGraphicsView::mouseReleaseEvent(event);
186 }
185 }
187 }
186 }
188
187
189 /*!
188 /*!
190 Resizes and updates the chart area using the \a event data
189 Resizes and updates the chart area using the \a event data
191 */
190 */
192 void QChartView::resizeEvent(QResizeEvent *event)
191 void QChartView::resizeEvent(QResizeEvent *event)
193 {
192 {
194 QGraphicsView::resizeEvent(event);
193 QGraphicsView::resizeEvent(event);
195 d_ptr->m_chart->resize(size());
194 d_ptr->m_chart->resize(size());
196 setMinimumSize(d_ptr->m_chart->minimumSize().toSize());
195 setMinimumSize(d_ptr->m_chart->minimumSize().toSize());
197 setSceneRect(d_ptr->m_chart->geometry());
196 setSceneRect(d_ptr->m_chart->geometry());
198 }
197 }
199
198
200 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
199 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
201
200
202 QChartViewPrivate::QChartViewPrivate():
201 QChartViewPrivate::QChartViewPrivate():
203 m_scene(0),
202 m_scene(0),
204 m_chart(0),
203 m_chart(0),
205 m_presenter(0),
204 m_presenter(0),
206 m_rubberBand(0),
205 m_rubberBand(0),
207 m_rubberBandFlags(QChartView::NoRubberBand)
206 m_rubberBandFlags(QChartView::NoRubberBand)
208 {
207 {
209
208
210 }
209 }
211
210
212 QChartViewPrivate::~QChartViewPrivate()
211 QChartViewPrivate::~QChartViewPrivate()
213 {
212 {
214
213
215 }
214 }
216
215
217 #include "moc_qchartview.cpp"
216 #include "moc_qchartview.cpp"
218
217
219 QTCOMMERCIALCHART_END_NAMESPACE
218 QTCOMMERCIALCHART_END_NAMESPACE
@@ -1,55 +1,56
1 /****************************************************************************
1 /****************************************************************************
2 **
2 **
3 ** Copyright (C) 2012 Digia Plc
3 ** Copyright (C) 2012 Digia Plc
4 ** All rights reserved.
4 ** All rights reserved.
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 **
6 **
7 ** This file is part of the Qt Commercial Charts Add-on.
7 ** This file is part of the Qt Commercial Charts Add-on.
8 **
8 **
9 ** $QT_BEGIN_LICENSE$
9 ** $QT_BEGIN_LICENSE$
10 ** Licensees holding valid Qt Commercial licenses may use this file in
10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 ** accordance with the Qt Commercial License Agreement provided with the
11 ** accordance with the Qt Commercial License Agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia.
13 ** a written agreement between you and Digia.
14 **
14 **
15 ** If you have questions regarding the use of this file, please use
15 ** If you have questions regarding the use of this file, please use
16 ** contact form at http://qt.digia.com
16 ** contact form at http://qt.digia.com
17 ** $QT_END_LICENSE$
17 ** $QT_END_LICENSE$
18 **
18 **
19 ****************************************************************************/
19 ****************************************************************************/
20
20
21 // W A R N I N G
21 // W A R N I N G
22 // -------------
22 // -------------
23 //
23 //
24 // This file is not part of the QtCommercial Chart API. It exists purely as an
24 // This file is not part of the QtCommercial Chart API. It exists purely as an
25 // implementation detail. This header file may change from version to
25 // implementation detail. This header file may change from version to
26 // version without notice, or even be removed.
26 // version without notice, or even be removed.
27 //
27 //
28 // We mean it.
28 // We mean it.
29
29
30 #ifndef QCHARTVIEW_P_H
30 #ifndef QCHARTVIEW_P_H
31 #define QCHARTVIEW_P_H
31 #define QCHARTVIEW_P_H
32
32
33 #include "qchartview.h"
33 #include "qchartview.h"
34
34
35 class QGraphicsScene;
35 class QGraphicsScene;
36 class ChartPresenter;
36
37
37 QTCOMMERCIALCHART_BEGIN_NAMESPACE
38 QTCOMMERCIALCHART_BEGIN_NAMESPACE
38
39
39 class QChart;
40 class QChart;
40
41
41 struct QChartViewPrivate {
42 struct QChartViewPrivate {
42
43
43 QChartViewPrivate();
44 QChartViewPrivate();
44 ~QChartViewPrivate();
45 ~QChartViewPrivate();
45
46
46 QGraphicsScene *m_scene;
47 QGraphicsScene *m_scene;
47 QChart *m_chart;
48 QChart *m_chart;
48 ChartPresenter *m_presenter;
49 ChartPresenter *m_presenter;
49 QPoint m_rubberBandOrigin;
50 QPoint m_rubberBandOrigin;
50 QRubberBand *m_rubberBand;
51 QRubberBand *m_rubberBand;
51 QChartView::RubberBands m_rubberBandFlags;
52 QChartView::RubberBands m_rubberBandFlags;
52 };
53 };
53
54
54 QTCOMMERCIALCHART_END_NAMESPACE
55 QTCOMMERCIALCHART_END_NAMESPACE
55 #endif
56 #endif
@@ -1,65 +1,65
1 /****************************************************************************
1 /****************************************************************************
2 **
2 **
3 ** Copyright (C) 2012 Digia Plc
3 ** Copyright (C) 2012 Digia Plc
4 ** All rights reserved.
4 ** All rights reserved.
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 **
6 **
7 ** This file is part of the Qt Commercial Charts Add-on.
7 ** This file is part of the Qt Commercial Charts Add-on.
8 **
8 **
9 ** $QT_BEGIN_LICENSE$
9 ** $QT_BEGIN_LICENSE$
10 ** Licensees holding valid Qt Commercial licenses may use this file in
10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 ** accordance with the Qt Commercial License Agreement provided with the
11 ** accordance with the Qt Commercial License Agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia.
13 ** a written agreement between you and Digia.
14 **
14 **
15 ** If you have questions regarding the use of this file, please use
15 ** If you have questions regarding the use of this file, please use
16 ** contact form at http://qt.digia.com
16 ** contact form at http://qt.digia.com
17 ** $QT_END_LICENSE$
17 ** $QT_END_LICENSE$
18 **
18 **
19 ****************************************************************************/
19 ****************************************************************************/
20
20
21 // W A R N I N G
21 // W A R N I N G
22 // -------------
22 // -------------
23 //
23 //
24 // This file is not part of the QtCommercial Chart API. It exists purely as an
24 // This file is not part of the QtCommercial Chart API. It exists purely as an
25 // implementation detail. This header file may change from version to
25 // implementation detail. This header file may change from version to
26 // version without notice, or even be removed.
26 // version without notice, or even be removed.
27 //
27 //
28 // We mean it.
28 // We mean it.
29
29
30 #ifndef QSERIES_P_H_
30 #ifndef QSERIES_P_H
31 #define QSERIES_P_H_
31 #define QSERIES_P_H
32
32
33 #include "qseries.h"
33 #include "qseries.h"
34
34
35 class QAbstractItemModel;
35 class QAbstractItemModel;
36
36
37 QTCOMMERCIALCHART_BEGIN_NAMESPACE
37 QTCOMMERCIALCHART_BEGIN_NAMESPACE
38
38
39 class Domain;
39 class Domain;
40 class ChartPresenter;
40 class ChartPresenter;
41 class Chart;
41 class Chart;
42 class LegendMarker;
42 class LegendMarker;
43 class QLegend;
43 class QLegend;
44
44
45 class QSeriesPrivate : public QObject
45 class QSeriesPrivate : public QObject
46 {
46 {
47 public:
47 public:
48 QSeriesPrivate(QSeries *q);
48 QSeriesPrivate(QSeries *q);
49 ~QSeriesPrivate();
49 ~QSeriesPrivate();
50
50
51 virtual void scaleDomain(Domain& domain) = 0;
51 virtual void scaleDomain(Domain& domain) = 0;
52 virtual Chart* createGraphics(ChartPresenter* presenter) = 0;
52 virtual Chart* createGraphics(ChartPresenter* presenter) = 0;
53 virtual QList<LegendMarker*> createLegendMarker(QLegend* legend) = 0;
53 virtual QList<LegendMarker*> createLegendMarker(QLegend* legend) = 0;
54
54
55 protected:
55 protected:
56 QSeries *q_ptr;
56 QSeries *q_ptr;
57 QAbstractItemModel *m_model;
57 QAbstractItemModel *m_model;
58 QString m_name;
58 QString m_name;
59
59
60 friend class QSeries;
60 friend class QSeries;
61 };
61 };
62
62
63 QTCOMMERCIALCHART_END_NAMESPACE
63 QTCOMMERCIALCHART_END_NAMESPACE
64
64
65 #endif
65 #endif
@@ -1,52 +1,52
1 /****************************************************************************
1 /****************************************************************************
2 **
2 **
3 ** Copyright (C) 2012 Digia Plc
3 ** Copyright (C) 2012 Digia Plc
4 ** All rights reserved.
4 ** All rights reserved.
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 **
6 **
7 ** This file is part of the Qt Commercial Charts Add-on.
7 ** This file is part of the Qt Commercial Charts Add-on.
8 **
8 **
9 ** $QT_BEGIN_LICENSE$
9 ** $QT_BEGIN_LICENSE$
10 ** Licensees holding valid Qt Commercial licenses may use this file in
10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 ** accordance with the Qt Commercial License Agreement provided with the
11 ** accordance with the Qt Commercial License Agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia.
13 ** a written agreement between you and Digia.
14 **
14 **
15 ** If you have questions regarding the use of this file, please use
15 ** If you have questions regarding the use of this file, please use
16 ** contact form at http://qt.digia.com
16 ** contact form at http://qt.digia.com
17 ** $QT_END_LICENSE$
17 ** $QT_END_LICENSE$
18 **
18 **
19 ****************************************************************************/
19 ****************************************************************************/
20
20
21 // W A R N I N G
21 // W A R N I N G
22 // -------------
22 // -------------
23 //
23 //
24 // This file is not part of the QtCommercial Chart API. It exists purely as an
24 // This file is not part of the QtCommercial Chart API. It exists purely as an
25 // implementation detail. This header file may change from version to
25 // implementation detail. This header file may change from version to
26 // version without notice, or even be removed.
26 // version without notice, or even be removed.
27 //
27 //
28 // We mean it.
28 // We mean it.
29
29
30 #ifndef QSCATTERSERIES_P_H_
30 #ifndef QSCATTERSERIES_P_H
31 #define QSCATTERSERIES_P_H_
31 #define QSCATTERSERIES_P_H
32
32
33 #include "qxyseries_p.h"
33 #include "qxyseries_p.h"
34
34
35 QTCOMMERCIALCHART_BEGIN_NAMESPACE
35 QTCOMMERCIALCHART_BEGIN_NAMESPACE
36
36
37 class QScatterSeriesPrivate: public QXYSeriesPrivate
37 class QScatterSeriesPrivate: public QXYSeriesPrivate
38 {
38 {
39 public:
39 public:
40 QScatterSeriesPrivate(QScatterSeries* q);
40 QScatterSeriesPrivate(QScatterSeries* q);
41 Chart* createGraphics(ChartPresenter* presenter);
41 Chart* createGraphics(ChartPresenter* presenter);
42
42
43 private:
43 private:
44 QScatterSeries::MarkerShape m_shape;
44 QScatterSeries::MarkerShape m_shape;
45 qreal m_size;
45 qreal m_size;
46 Q_DECLARE_PUBLIC(QScatterSeries);
46 Q_DECLARE_PUBLIC(QScatterSeries);
47
47
48 };
48 };
49
49
50 QTCOMMERCIALCHART_END_NAMESPACE
50 QTCOMMERCIALCHART_END_NAMESPACE
51
51
52 #endif
52 #endif
@@ -1,140 +1,140
1 /****************************************************************************
1 /****************************************************************************
2 **
2 **
3 ** Copyright (C) 2012 Digia Plc
3 ** Copyright (C) 2012 Digia Plc
4 ** All rights reserved.
4 ** All rights reserved.
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 **
6 **
7 ** This file is part of the Qt Commercial Charts Add-on.
7 ** This file is part of the Qt Commercial Charts Add-on.
8 **
8 **
9 ** $QT_BEGIN_LICENSE$
9 ** $QT_BEGIN_LICENSE$
10 ** Licensees holding valid Qt Commercial licenses may use this file in
10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 ** accordance with the Qt Commercial License Agreement provided with the
11 ** accordance with the Qt Commercial License Agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia.
13 ** a written agreement between you and Digia.
14 **
14 **
15 ** If you have questions regarding the use of this file, please use
15 ** If you have questions regarding the use of this file, please use
16 ** contact form at http://qt.digia.com
16 ** contact form at http://qt.digia.com
17 ** $QT_END_LICENSE$
17 ** $QT_END_LICENSE$
18 **
18 **
19 ****************************************************************************/
19 ****************************************************************************/
20
20
21 #ifndef SCATTERPRESENTER_H
21 #ifndef SCATTERCHARTITEM_H
22 #define SCATTERPRESENTER_H
22 #define SCATTERCHARTITEM_H
23
23
24 #include "qchartglobal.h"
24 #include "qchartglobal.h"
25 #include "xychartitem_p.h"
25 #include "xychartitem_p.h"
26 #include <QGraphicsEllipseItem>
26 #include <QGraphicsEllipseItem>
27 #include <QPen>
27 #include <QPen>
28
28
29 QTCOMMERCIALCHART_BEGIN_NAMESPACE
29 QTCOMMERCIALCHART_BEGIN_NAMESPACE
30
30
31 class QScatterSeries;
31 class QScatterSeries;
32 class Marker;
32 class Marker;
33
33
34 class ScatterChartItem : public XYChartItem
34 class ScatterChartItem : public XYChartItem
35 {
35 {
36 Q_OBJECT
36 Q_OBJECT
37 public:
37 public:
38 explicit ScatterChartItem(QScatterSeries *series, ChartPresenter *presenter);
38 explicit ScatterChartItem(QScatterSeries *series, ChartPresenter *presenter);
39
39
40 public:
40 public:
41 //from QGraphicsItem
41 //from QGraphicsItem
42 QRectF boundingRect() const;
42 QRectF boundingRect() const;
43 void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
43 void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
44
44
45 void setPen(const QPen &pen);
45 void setPen(const QPen &pen);
46 void setBrush(const QBrush &brush);
46 void setBrush(const QBrush &brush);
47
47
48 void markerSelected(Marker *item);
48 void markerSelected(Marker *item);
49
49
50 public Q_SLOTS:
50 public Q_SLOTS:
51 void handleUpdated();
51 void handleUpdated();
52
52
53 private:
53 private:
54 void createPoints(int count);
54 void createPoints(int count);
55 void deletePoints(int count);
55 void deletePoints(int count);
56
56
57 protected:
57 protected:
58 void setLayout(QVector<QPointF> &points);
58 void setLayout(QVector<QPointF> &points);
59
59
60 private:
60 private:
61 QScatterSeries *m_series;
61 QScatterSeries *m_series;
62 QGraphicsItemGroup m_items;
62 QGraphicsItemGroup m_items;
63 int m_shape;
63 int m_shape;
64 int m_size;
64 int m_size;
65 QRectF m_rect;
65 QRectF m_rect;
66
66
67 };
67 };
68
68
69
69
70 class Marker: public QAbstractGraphicsShapeItem
70 class Marker: public QAbstractGraphicsShapeItem
71 {
71 {
72
72
73 public:
73 public:
74
74
75 Marker(QAbstractGraphicsShapeItem *item , ScatterChartItem *parent) : QAbstractGraphicsShapeItem(0) ,m_item(item), m_parent(parent), m_index(-1)
75 Marker(QAbstractGraphicsShapeItem *item , ScatterChartItem *parent) : QAbstractGraphicsShapeItem(0) ,m_item(item), m_parent(parent), m_index(-1)
76 {
76 {
77 }
77 }
78
78
79 ~Marker()
79 ~Marker()
80 {
80 {
81 delete m_item;
81 delete m_item;
82 }
82 }
83
83
84 void setIndex(int index)
84 void setIndex(int index)
85 {
85 {
86 m_index=index;
86 m_index=index;
87 }
87 }
88
88
89 int index() const
89 int index() const
90 {
90 {
91 return m_index;
91 return m_index;
92 }
92 }
93
93
94 QPainterPath shape() const
94 QPainterPath shape() const
95 {
95 {
96 return m_item->shape();
96 return m_item->shape();
97 }
97 }
98
98
99 QRectF boundingRect() const
99 QRectF boundingRect() const
100 {
100 {
101 return m_item->boundingRect();
101 return m_item->boundingRect();
102 }
102 }
103
103
104 bool contains(const QPointF &point) const
104 bool contains(const QPointF &point) const
105 {
105 {
106 return m_item->contains(point);
106 return m_item->contains(point);
107 }
107 }
108
108
109 void setPen(const QPen &pen)
109 void setPen(const QPen &pen)
110 {
110 {
111 m_item->setPen(pen);
111 m_item->setPen(pen);
112 }
112 }
113
113
114 void setBrush(const QBrush &brush)
114 void setBrush(const QBrush &brush)
115 {
115 {
116 m_item->setBrush(brush);
116 m_item->setBrush(brush);
117 }
117 }
118
118
119 void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
119 void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
120 {
120 {
121 m_item->paint(painter,option,widget);
121 m_item->paint(painter,option,widget);
122 }
122 }
123
123
124 protected:
124 protected:
125
125
126 void mousePressEvent(QGraphicsSceneMouseEvent *event)
126 void mousePressEvent(QGraphicsSceneMouseEvent *event)
127 {
127 {
128 Q_UNUSED(event)
128 Q_UNUSED(event)
129 m_parent->markerSelected(this);
129 m_parent->markerSelected(this);
130 }
130 }
131
131
132 private:
132 private:
133 QAbstractGraphicsShapeItem* m_item;
133 QAbstractGraphicsShapeItem* m_item;
134 ScatterChartItem* m_parent;
134 ScatterChartItem* m_parent;
135 int m_index;
135 int m_index;
136 };
136 };
137
137
138 QTCOMMERCIALCHART_END_NAMESPACE
138 QTCOMMERCIALCHART_END_NAMESPACE
139
139
140 #endif // SCATTERPRESENTER_H
140 #endif // SCATTERPRESENTER_H
@@ -1,106 +1,106
1 /****************************************************************************
1 /****************************************************************************
2 **
2 **
3 ** Copyright (C) 2012 Digia Plc
3 ** Copyright (C) 2012 Digia Plc
4 ** All rights reserved.
4 ** All rights reserved.
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 **
6 **
7 ** This file is part of the Qt Commercial Charts Add-on.
7 ** This file is part of the Qt Commercial Charts Add-on.
8 **
8 **
9 ** $QT_BEGIN_LICENSE$
9 ** $QT_BEGIN_LICENSE$
10 ** Licensees holding valid Qt Commercial licenses may use this file in
10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 ** accordance with the Qt Commercial License Agreement provided with the
11 ** accordance with the Qt Commercial License Agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia.
13 ** a written agreement between you and Digia.
14 **
14 **
15 ** If you have questions regarding the use of this file, please use
15 ** If you have questions regarding the use of this file, please use
16 ** contact form at http://qt.digia.com
16 ** contact form at http://qt.digia.com
17 ** $QT_END_LICENSE$
17 ** $QT_END_LICENSE$
18 **
18 **
19 ****************************************************************************/
19 ****************************************************************************/
20
20
21 // W A R N I N G
21 // W A R N I N G
22 // -------------
22 // -------------
23 //
23 //
24 // This file is not part of the QtCommercial Chart API. It exists purely as an
24 // This file is not part of the QtCommercial Chart API. It exists purely as an
25 // implementation detail. This header file may change from version to
25 // implementation detail. This header file may change from version to
26 // version without notice, or even be removed.
26 // version without notice, or even be removed.
27 //
27 //
28 // We mean it.
28 // We mean it.
29
29
30 #ifndef SCROLLER_P_H_
30 #ifndef SCROLLER_P_H
31 #define SCROLLER_P_H_
31 #define SCROLLER_P_H
32
32
33 #include "qchartglobal.h"
33 #include "qchartglobal.h"
34 #include <QBasicTimer>
34 #include <QBasicTimer>
35 #include <QTime>
35 #include <QTime>
36 #include <QPointF>
36 #include <QPointF>
37
37
38 class QGraphicsSceneMouseEvent;
38 class QGraphicsSceneMouseEvent;
39
39
40 QTCOMMERCIALCHART_BEGIN_NAMESPACE
40 QTCOMMERCIALCHART_BEGIN_NAMESPACE
41
41
42 class Scroller;
42 class Scroller;
43 class QLegend;
43 class QLegend;
44
44
45 class ScrollTicker : public QObject
45 class ScrollTicker : public QObject
46 {
46 {
47 public:
47 public:
48 ScrollTicker(Scroller *scroller,QObject *parent=0);
48 ScrollTicker(Scroller *scroller,QObject *parent=0);
49 void start(int interval);
49 void start(int interval);
50 void stop();
50 void stop();
51 protected:
51 protected:
52 void timerEvent(QTimerEvent *event);
52 void timerEvent(QTimerEvent *event);
53
53
54 private:
54 private:
55 QBasicTimer m_timer;
55 QBasicTimer m_timer;
56 Scroller *m_scroller;
56 Scroller *m_scroller;
57 };
57 };
58
58
59 class Scroller
59 class Scroller
60 {
60 {
61 public:
61 public:
62 enum State {
62 enum State {
63 Idle,
63 Idle,
64 Pressed,
64 Pressed,
65 Move,
65 Move,
66 Scroll,
66 Scroll,
67 Stop
67 Stop
68 };
68 };
69
69
70 Scroller();
70 Scroller();
71 virtual ~Scroller();
71 virtual ~Scroller();
72
72
73 virtual void setOffset(const QPointF& point) = 0;
73 virtual void setOffset(const QPointF& point) = 0;
74 virtual QPointF offset() const = 0;
74 virtual QPointF offset() const = 0;
75
75
76 public:
76 public:
77 void scrollTick();
77 void scrollTick();
78
78
79
79
80 public:
80 public:
81 void mousePressEvent(QGraphicsSceneMouseEvent* event);
81 void mousePressEvent(QGraphicsSceneMouseEvent* event);
82 void mouseMoveEvent(QGraphicsSceneMouseEvent* event);
82 void mouseMoveEvent(QGraphicsSceneMouseEvent* event);
83 void mouseReleaseEvent(QGraphicsSceneMouseEvent* event);
83 void mouseReleaseEvent(QGraphicsSceneMouseEvent* event);
84
84
85 private:
85 private:
86 void calculateSpeed(const QPointF& position);
86 void calculateSpeed(const QPointF& position);
87 void lowerSpeed(QPointF& speed,qreal maxSpeed=100);
87 void lowerSpeed(QPointF& speed,qreal maxSpeed=100);
88
88
89 private:
89 private:
90 ScrollTicker m_ticker;
90 ScrollTicker m_ticker;
91 State m_state;
91 State m_state;
92 QTime m_timeStamp;
92 QTime m_timeStamp;
93 QPointF m_press;
93 QPointF m_press;
94 QPointF m_offset;
94 QPointF m_offset;
95 QPointF m_speed;
95 QPointF m_speed;
96 QPointF m_distance;
96 QPointF m_distance;
97 QPointF m_fraction;
97 QPointF m_fraction;
98 int m_moveThreshold;
98 int m_moveThreshold;
99 int m_timeTreshold;
99 int m_timeTreshold;
100
100
101
101
102 };
102 };
103
103
104 QTCOMMERCIALCHART_END_NAMESPACE
104 QTCOMMERCIALCHART_END_NAMESPACE
105
105
106 #endif /* SCROLLER_P_H_ */
106 #endif /* SCROLLER_P_H_ */
@@ -1,57 +1,57
1 /****************************************************************************
1 /****************************************************************************
2 **
2 **
3 ** Copyright (C) 2012 Digia Plc
3 ** Copyright (C) 2012 Digia Plc
4 ** All rights reserved.
4 ** All rights reserved.
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 **
6 **
7 ** This file is part of the Qt Commercial Charts Add-on.
7 ** This file is part of the Qt Commercial Charts Add-on.
8 **
8 **
9 ** $QT_BEGIN_LICENSE$
9 ** $QT_BEGIN_LICENSE$
10 ** Licensees holding valid Qt Commercial licenses may use this file in
10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 ** accordance with the Qt Commercial License Agreement provided with the
11 ** accordance with the Qt Commercial License Agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia.
13 ** a written agreement between you and Digia.
14 **
14 **
15 ** If you have questions regarding the use of this file, please use
15 ** If you have questions regarding the use of this file, please use
16 ** contact form at http://qt.digia.com
16 ** contact form at http://qt.digia.com
17 ** $QT_END_LICENSE$
17 ** $QT_END_LICENSE$
18 **
18 **
19 ****************************************************************************/
19 ****************************************************************************/
20
20
21 // W A R N I N G
21 // W A R N I N G
22 // -------------
22 // -------------
23 //
23 //
24 // This file is not part of the QtCommercial Chart API. It exists purely as an
24 // This file is not part of the QtCommercial Chart API. It exists purely as an
25 // implementation detail. This header file may change from version to
25 // implementation detail. This header file may change from version to
26 // version without notice, or even be removed.
26 // version without notice, or even be removed.
27 //
27 //
28 // We mean it.
28 // We mean it.
29
29
30 #ifndef QSPLINESERIES_P_H_
30 #ifndef QSPLINESERIES_P_H
31 #define QSPLINESERIES_P_H_
31 #define QSPLINESERIES_P_H
32
32
33 #include "qlineseries_p.h"
33 #include "qlineseries_p.h"
34
34
35 QTCOMMERCIALCHART_BEGIN_NAMESPACE
35 QTCOMMERCIALCHART_BEGIN_NAMESPACE
36
36
37
37
38 class QSplineSeriesPrivate: public QLineSeriesPrivate
38 class QSplineSeriesPrivate: public QLineSeriesPrivate
39 {
39 {
40 Q_OBJECT
40 Q_OBJECT
41 public:
41 public:
42 Chart* createGraphics(ChartPresenter* presenter);
42 Chart* createGraphics(ChartPresenter* presenter);
43 QSplineSeriesPrivate(QSplineSeries* q);
43 QSplineSeriesPrivate(QSplineSeries* q);
44 void calculateControlPoints();
44 void calculateControlPoints();
45 QList<qreal> getFirstControlPoints(QList<qreal> rhs);
45 QList<qreal> getFirstControlPoints(QList<qreal> rhs);
46
46
47 public Q_SLOTS:
47 public Q_SLOTS:
48 void updateControlPoints();
48 void updateControlPoints();
49 public:
49 public:
50 QList<QPointF> m_controlPoints;
50 QList<QPointF> m_controlPoints;
51 private:
51 private:
52 Q_DECLARE_PUBLIC(QSplineSeries)
52 Q_DECLARE_PUBLIC(QSplineSeries)
53 };
53 };
54
54
55 QTCOMMERCIALCHART_END_NAMESPACE
55 QTCOMMERCIALCHART_END_NAMESPACE
56
56
57 #endif
57 #endif
@@ -1,61 +1,61
1 /****************************************************************************
1 /****************************************************************************
2 **
2 **
3 ** Copyright (C) 2012 Digia Plc
3 ** Copyright (C) 2012 Digia Plc
4 ** All rights reserved.
4 ** All rights reserved.
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 **
6 **
7 ** This file is part of the Qt Commercial Charts Add-on.
7 ** This file is part of the Qt Commercial Charts Add-on.
8 **
8 **
9 ** $QT_BEGIN_LICENSE$
9 ** $QT_BEGIN_LICENSE$
10 ** Licensees holding valid Qt Commercial licenses may use this file in
10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 ** accordance with the Qt Commercial License Agreement provided with the
11 ** accordance with the Qt Commercial License Agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia.
13 ** a written agreement between you and Digia.
14 **
14 **
15 ** If you have questions regarding the use of this file, please use
15 ** If you have questions regarding the use of this file, please use
16 ** contact form at http://qt.digia.com
16 ** contact form at http://qt.digia.com
17 ** $QT_END_LICENSE$
17 ** $QT_END_LICENSE$
18 **
18 **
19 ****************************************************************************/
19 ****************************************************************************/
20
20
21 #ifndef CHARTTHEMEBLUECEICY_P_H
21 #ifndef CHARTTHEMEBLUEICY_P_H
22 #define CHARTTHEMEBLUECEICY_P_H
22 #define CHARTTHEMEBLUEICY_P_H
23
23
24 #include "charttheme_p.h"
24 #include "charttheme_p.h"
25
25
26 QTCOMMERCIALCHART_BEGIN_NAMESPACE
26 QTCOMMERCIALCHART_BEGIN_NAMESPACE
27
27
28 class ChartThemeBlueIcy: public ChartTheme
28 class ChartThemeBlueIcy: public ChartTheme
29 {
29 {
30 public:
30 public:
31 ChartThemeBlueIcy() : ChartTheme(QChart::ChartThemeBlueIcy)
31 ChartThemeBlueIcy() : ChartTheme(QChart::ChartThemeBlueIcy)
32 {
32 {
33 // Series colors
33 // Series colors
34 m_seriesColors << QRgb(0x3daeda);
34 m_seriesColors << QRgb(0x3daeda);
35 m_seriesColors << QRgb(0x2685bf);
35 m_seriesColors << QRgb(0x2685bf);
36 m_seriesColors << QRgb(0x0c2673);
36 m_seriesColors << QRgb(0x0c2673);
37 m_seriesColors << QRgb(0x5f3dba);
37 m_seriesColors << QRgb(0x5f3dba);
38 m_seriesColors << QRgb(0x2fa3b4);
38 m_seriesColors << QRgb(0x2fa3b4);
39 generateSeriesGradients();
39 generateSeriesGradients();
40
40
41 // Background
41 // Background
42 QLinearGradient backgroundGradient(0.5, 0.0, 0.5, 1.0);
42 QLinearGradient backgroundGradient(0.5, 0.0, 0.5, 1.0);
43 backgroundGradient.setColorAt(0.0, QRgb(0xffffff));
43 backgroundGradient.setColorAt(0.0, QRgb(0xffffff));
44 backgroundGradient.setColorAt(1.0, QRgb(0xffffff));
44 backgroundGradient.setColorAt(1.0, QRgb(0xffffff));
45 backgroundGradient.setCoordinateMode(QGradient::ObjectBoundingMode);
45 backgroundGradient.setCoordinateMode(QGradient::ObjectBoundingMode);
46 m_chartBackgroundGradient = backgroundGradient;
46 m_chartBackgroundGradient = backgroundGradient;
47
47
48 // Axes and other
48 // Axes and other
49 m_titleBrush = QBrush(QRgb(0x404044));
49 m_titleBrush = QBrush(QRgb(0x404044));
50 m_axisLinePen = QPen(QRgb(0xd6d6d6));
50 m_axisLinePen = QPen(QRgb(0xd6d6d6));
51 m_axisLinePen.setWidth(2);
51 m_axisLinePen.setWidth(2);
52 m_axisLabelBrush = QBrush(QRgb(0x404044));
52 m_axisLabelBrush = QBrush(QRgb(0x404044));
53 m_gridLinePen = QPen(QRgb(0xe2e2e2));
53 m_gridLinePen = QPen(QRgb(0xe2e2e2));
54 m_gridLinePen.setWidth(1);
54 m_gridLinePen.setWidth(1);
55 m_backgroundShades = BackgroundShadesNone;
55 m_backgroundShades = BackgroundShadesNone;
56 }
56 }
57 };
57 };
58
58
59 QTCOMMERCIALCHART_END_NAMESPACE
59 QTCOMMERCIALCHART_END_NAMESPACE
60
60
61 #endif
61 #endif
@@ -1,60 +1,60
1 /****************************************************************************
1 /****************************************************************************
2 **
2 **
3 ** Copyright (C) 2012 Digia Plc
3 ** Copyright (C) 2012 Digia Plc
4 ** All rights reserved.
4 ** All rights reserved.
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 **
6 **
7 ** This file is part of the Qt Commercial Charts Add-on.
7 ** This file is part of the Qt Commercial Charts Add-on.
8 **
8 **
9 ** $QT_BEGIN_LICENSE$
9 ** $QT_BEGIN_LICENSE$
10 ** Licensees holding valid Qt Commercial licenses may use this file in
10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 ** accordance with the Qt Commercial License Agreement provided with the
11 ** accordance with the Qt Commercial License Agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia.
13 ** a written agreement between you and Digia.
14 **
14 **
15 ** If you have questions regarding the use of this file, please use
15 ** If you have questions regarding the use of this file, please use
16 ** contact form at http://qt.digia.com
16 ** contact form at http://qt.digia.com
17 ** $QT_END_LICENSE$
17 ** $QT_END_LICENSE$
18 **
18 **
19 ****************************************************************************/
19 ****************************************************************************/
20
20
21 #ifndef CHARTTHEMEHIGHLIGHT_P_H
21 #ifndef CHARTTHEMELIGHT_P_H
22 #define CHARTTHEMEHIGHLIGHT_P_H
22 #define CHARTTHEMELIGHT_P_H
23
23
24 #include "charttheme_p.h"
24 #include "charttheme_p.h"
25
25
26 QTCOMMERCIALCHART_BEGIN_NAMESPACE
26 QTCOMMERCIALCHART_BEGIN_NAMESPACE
27
27
28 class ChartThemeLight: public ChartTheme
28 class ChartThemeLight: public ChartTheme
29 {
29 {
30 public:
30 public:
31 ChartThemeLight() : ChartTheme(QChart::ChartThemeLight)
31 ChartThemeLight() : ChartTheme(QChart::ChartThemeLight)
32 {
32 {
33 // Series colors
33 // Series colors
34 m_seriesColors << QRgb(0x209fdf);
34 m_seriesColors << QRgb(0x209fdf);
35 m_seriesColors << QRgb(0x99ca53);
35 m_seriesColors << QRgb(0x99ca53);
36 m_seriesColors << QRgb(0xf6a625);
36 m_seriesColors << QRgb(0xf6a625);
37 m_seriesColors << QRgb(0x6d5fd5);
37 m_seriesColors << QRgb(0x6d5fd5);
38 m_seriesColors << QRgb(0xbf593e);
38 m_seriesColors << QRgb(0xbf593e);
39 generateSeriesGradients();
39 generateSeriesGradients();
40
40
41 // Background
41 // Background
42 QLinearGradient backgroundGradient;
42 QLinearGradient backgroundGradient;
43 backgroundGradient.setColorAt(0.0, QRgb(0xffffff));
43 backgroundGradient.setColorAt(0.0, QRgb(0xffffff));
44 backgroundGradient.setColorAt(1.0, QRgb(0xffffff));
44 backgroundGradient.setColorAt(1.0, QRgb(0xffffff));
45 backgroundGradient.setCoordinateMode(QGradient::ObjectBoundingMode);
45 backgroundGradient.setCoordinateMode(QGradient::ObjectBoundingMode);
46 m_chartBackgroundGradient = backgroundGradient;
46 m_chartBackgroundGradient = backgroundGradient;
47
47
48 // Axes and other
48 // Axes and other
49 m_axisLinePen = QPen(0xd6d6d6);
49 m_axisLinePen = QPen(0xd6d6d6);
50 m_axisLinePen.setWidth(1);
50 m_axisLinePen.setWidth(1);
51 m_axisLabelBrush = QBrush(QRgb(0x404044));
51 m_axisLabelBrush = QBrush(QRgb(0x404044));
52 m_gridLinePen = QPen(QRgb(0xe2e2e2));
52 m_gridLinePen = QPen(QRgb(0xe2e2e2));
53 m_gridLinePen.setWidth(1);
53 m_gridLinePen.setWidth(1);
54 m_backgroundShades = BackgroundShadesNone;
54 m_backgroundShades = BackgroundShadesNone;
55 }
55 }
56 };
56 };
57
57
58 QTCOMMERCIALCHART_END_NAMESPACE
58 QTCOMMERCIALCHART_END_NAMESPACE
59
59
60 #endif
60 #endif
@@ -1,97 +1,97
1 /****************************************************************************
1 /****************************************************************************
2 **
2 **
3 ** Copyright (C) 2012 Digia Plc
3 ** Copyright (C) 2012 Digia Plc
4 ** All rights reserved.
4 ** All rights reserved.
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 **
6 **
7 ** This file is part of the Qt Commercial Charts Add-on.
7 ** This file is part of the Qt Commercial Charts Add-on.
8 **
8 **
9 ** $QT_BEGIN_LICENSE$
9 ** $QT_BEGIN_LICENSE$
10 ** Licensees holding valid Qt Commercial licenses may use this file in
10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 ** accordance with the Qt Commercial License Agreement provided with the
11 ** accordance with the Qt Commercial License Agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia.
13 ** a written agreement between you and Digia.
14 **
14 **
15 ** If you have questions regarding the use of this file, please use
15 ** If you have questions regarding the use of this file, please use
16 ** contact form at http://qt.digia.com
16 ** contact form at http://qt.digia.com
17 ** $QT_END_LICENSE$
17 ** $QT_END_LICENSE$
18 **
18 **
19 ****************************************************************************/
19 ****************************************************************************/
20
20
21 #ifndef QXYSERIES_H_
21 #ifndef QXYSERIES_H
22 #define QXYSERIES_H_
22 #define QXYSERIES_H
23
23
24 #include <qchartglobal.h>
24 #include <qchartglobal.h>
25 #include <qseries.h>
25 #include <qseries.h>
26 #include <QPen>
26 #include <QPen>
27 #include <QBrush>
27 #include <QBrush>
28
28
29 class QModelIndex;
29 class QModelIndex;
30
30
31 QTCOMMERCIALCHART_BEGIN_NAMESPACE
31 QTCOMMERCIALCHART_BEGIN_NAMESPACE
32
32
33 class QXYSeriesPrivate;
33 class QXYSeriesPrivate;
34
34
35 class QTCOMMERCIALCHART_EXPORT QXYSeries : public QSeries
35 class QTCOMMERCIALCHART_EXPORT QXYSeries : public QSeries
36 {
36 {
37 Q_OBJECT
37 Q_OBJECT
38 protected:
38 protected:
39 explicit QXYSeries(QXYSeriesPrivate &d,QObject *parent = 0);
39 explicit QXYSeries(QXYSeriesPrivate &d,QObject *parent = 0);
40 ~QXYSeries();
40 ~QXYSeries();
41
41
42 public:
42 public:
43 void append(qreal x, qreal y);
43 void append(qreal x, qreal y);
44 void append(const QPointF &point);
44 void append(const QPointF &point);
45 void append(const QList<QPointF> points);
45 void append(const QList<QPointF> points);
46 void replace(qreal x,qreal y);
46 void replace(qreal x,qreal y);
47 void replace(const QPointF &point);
47 void replace(const QPointF &point);
48 void remove(qreal x);
48 void remove(qreal x);
49 void remove(qreal x, qreal y);
49 void remove(qreal x, qreal y);
50 void remove(const QPointF &point);
50 void remove(const QPointF &point);
51 void removeAll();
51 void removeAll();
52
52
53 int count() const;
53 int count() const;
54 qreal x(int pos) const;
54 qreal x(int pos) const;
55 qreal y(int pos) const;
55 qreal y(int pos) const;
56 QList<QPointF> data();
56 QList<QPointF> data();
57
57
58 QXYSeries& operator << (const QPointF &point);
58 QXYSeries& operator << (const QPointF &point);
59 QXYSeries& operator << (const QList<QPointF> points);
59 QXYSeries& operator << (const QList<QPointF> points);
60
60
61 void setPen(const QPen &pen);
61 void setPen(const QPen &pen);
62 QPen pen() const;
62 QPen pen() const;
63
63
64 void setBrush(const QBrush &brush);
64 void setBrush(const QBrush &brush);
65 QBrush brush() const;
65 QBrush brush() const;
66
66
67 void setPointsVisible(bool visible);
67 void setPointsVisible(bool visible);
68 bool pointsVisible() const;
68 bool pointsVisible() const;
69
69
70 bool setModel(QAbstractItemModel *model);
70 bool setModel(QAbstractItemModel *model);
71
71
72 virtual void setModelMapping(int modelX, int modelY, Qt::Orientation orientation = Qt::Vertical);
72 virtual void setModelMapping(int modelX, int modelY, Qt::Orientation orientation = Qt::Vertical);
73 virtual void setModelMappingRange(int first, int count = 0);
73 virtual void setModelMappingRange(int first, int count = 0);
74 int mapFirst() const;
74 int mapFirst() const;
75 int mapCount() const;
75 int mapCount() const;
76
76
77 private Q_SLOTS:
77 private Q_SLOTS:
78 void modelUpdated(QModelIndex topLeft, QModelIndex bottomRight);
78 void modelUpdated(QModelIndex topLeft, QModelIndex bottomRight);
79 void modelDataAboutToBeAdded(QModelIndex parent, int start, int end);
79 void modelDataAboutToBeAdded(QModelIndex parent, int start, int end);
80 void modelDataAdded(QModelIndex parent, int start, int end);
80 void modelDataAdded(QModelIndex parent, int start, int end);
81 void modelDataAboutToBeRemoved(QModelIndex parent, int start, int end);
81 void modelDataAboutToBeRemoved(QModelIndex parent, int start, int end);
82 void modelDataRemoved(QModelIndex parent, int start, int end);
82 void modelDataRemoved(QModelIndex parent, int start, int end);
83
83
84 Q_SIGNALS:
84 Q_SIGNALS:
85 void clicked(const QPointF &point);
85 void clicked(const QPointF &point);
86 void selected();
86 void selected();
87
87
88 private:
88 private:
89 Q_DECLARE_PRIVATE(QXYSeries);
89 Q_DECLARE_PRIVATE(QXYSeries);
90 Q_DISABLE_COPY(QXYSeries);
90 Q_DISABLE_COPY(QXYSeries);
91 friend class XYLegendMarker;
91 friend class XYLegendMarker;
92 friend class XYChartItem;
92 friend class XYChartItem;
93 };
93 };
94
94
95 QTCOMMERCIALCHART_END_NAMESPACE
95 QTCOMMERCIALCHART_END_NAMESPACE
96
96
97 #endif
97 #endif
@@ -1,79 +1,79
1 /****************************************************************************
1 /****************************************************************************
2 **
2 **
3 ** Copyright (C) 2012 Digia Plc
3 ** Copyright (C) 2012 Digia Plc
4 ** All rights reserved.
4 ** All rights reserved.
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
5 ** For any questions to Digia, please use contact form at http://qt.digia.com
6 **
6 **
7 ** This file is part of the Qt Commercial Charts Add-on.
7 ** This file is part of the Qt Commercial Charts Add-on.
8 **
8 **
9 ** $QT_BEGIN_LICENSE$
9 ** $QT_BEGIN_LICENSE$
10 ** Licensees holding valid Qt Commercial licenses may use this file in
10 ** Licensees holding valid Qt Commercial licenses may use this file in
11 ** accordance with the Qt Commercial License Agreement provided with the
11 ** accordance with the Qt Commercial License Agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia.
13 ** a written agreement between you and Digia.
14 **
14 **
15 ** If you have questions regarding the use of this file, please use
15 ** If you have questions regarding the use of this file, please use
16 ** contact form at http://qt.digia.com
16 ** contact form at http://qt.digia.com
17 ** $QT_END_LICENSE$
17 ** $QT_END_LICENSE$
18 **
18 **
19 ****************************************************************************/
19 ****************************************************************************/
20
20
21 // W A R N I N G
21 // W A R N I N G
22 // -------------
22 // -------------
23 //
23 //
24 // This file is not part of the QtCommercial Chart API. It exists purely as an
24 // This file is not part of the QtCommercial Chart API. It exists purely as an
25 // implementation detail. This header file may change from version to
25 // implementation detail. This header file may change from version to
26 // version without notice, or even be removed.
26 // version without notice, or even be removed.
27 //
27 //
28 // We mean it.
28 // We mean it.
29
29
30 #ifndef QXYSERIES_P_H_
30 #ifndef QXYSERIES_P_H
31 #define QXYSERIES_P_H_
31 #define QXYSERIES_P_H
32
32
33 #include "qseries_p.h"
33 #include "qseries_p.h"
34
34
35 QTCOMMERCIALCHART_BEGIN_NAMESPACE
35 QTCOMMERCIALCHART_BEGIN_NAMESPACE
36
36
37 class QXYSeries;
37 class QXYSeries;
38
38
39 class QXYSeriesPrivate: public QSeriesPrivate
39 class QXYSeriesPrivate: public QSeriesPrivate
40 {
40 {
41 Q_OBJECT
41 Q_OBJECT
42
42
43 public:
43 public:
44 QXYSeriesPrivate(QXYSeries* q);
44 QXYSeriesPrivate(QXYSeries* q);
45
45
46 void scaleDomain(Domain& domain);
46 void scaleDomain(Domain& domain);
47 QList<LegendMarker*> createLegendMarker(QLegend* legend);
47 QList<LegendMarker*> createLegendMarker(QLegend* legend);
48
48
49 Q_SIGNALS:
49 Q_SIGNALS:
50 void updated();
50 void updated();
51 void pointReplaced(int index);
51 void pointReplaced(int index);
52 void pointRemoved(int index);
52 void pointRemoved(int index);
53 void pointAdded(int index);
53 void pointAdded(int index);
54
54
55 protected:
55 protected:
56 QVector<qreal> m_x;
56 QVector<qreal> m_x;
57 QVector<qreal> m_y;
57 QVector<qreal> m_y;
58
58
59 QPen m_pen;
59 QPen m_pen;
60 QBrush m_brush;
60 QBrush m_brush;
61
61
62 int m_mapX;
62 int m_mapX;
63 int m_mapY;
63 int m_mapY;
64 int m_mapFirst;
64 int m_mapFirst;
65 int m_mapCount;
65 int m_mapCount;
66 bool m_mapLimited;
66 bool m_mapLimited;
67 Qt::Orientation m_mapOrientation;
67 Qt::Orientation m_mapOrientation;
68 int tempItemsRemoved;
68 int tempItemsRemoved;
69 bool m_pointsVisible;
69 bool m_pointsVisible;
70
70
71 private:
71 private:
72 Q_DECLARE_PUBLIC(QXYSeries);
72 Q_DECLARE_PUBLIC(QXYSeries);
73 friend class QScatterSeries;
73 friend class QScatterSeries;
74
74
75 };
75 };
76
76
77 QTCOMMERCIALCHART_END_NAMESPACE
77 QTCOMMERCIALCHART_END_NAMESPACE
78
78
79 #endif
79 #endif
General Comments 0
You need to be logged in to leave comments. Login now