##// END OF EJS Templates
Remove setter for labelinBeetwen flag from axis
Michal Klocek -
r2118:7942a7e7245e
parent child
Show More
@@ -27,10 +27,10
27
27
28 QTCOMMERCIALCHART_BEGIN_NAMESPACE
28 QTCOMMERCIALCHART_BEGIN_NAMESPACE
29
29
30 ChartBarCategoryAxisX::ChartBarCategoryAxisX(QBarCategoryAxis *axis,ChartPresenter *presenter) : HorizontalAxis(axis,presenter),
30 ChartBarCategoryAxisX::ChartBarCategoryAxisX(QBarCategoryAxis *axis,ChartPresenter *presenter) : HorizontalAxis(axis,presenter,true),
31 m_categoriesAxis(axis)
31 m_categoriesAxis(axis)
32 {
32 {
33 setLabelBetweenTicks(true);
33
34 }
34 }
35
35
36 ChartBarCategoryAxisX::~ChartBarCategoryAxisX()
36 ChartBarCategoryAxisX::~ChartBarCategoryAxisX()
@@ -26,10 +26,9
26
26
27 QTCOMMERCIALCHART_BEGIN_NAMESPACE
27 QTCOMMERCIALCHART_BEGIN_NAMESPACE
28
28
29 ChartBarCategoryAxisY::ChartBarCategoryAxisY(QBarCategoryAxis *axis,ChartPresenter *presenter) : VerticalAxis(axis,presenter),
29 ChartBarCategoryAxisY::ChartBarCategoryAxisY(QBarCategoryAxis *axis,ChartPresenter *presenter) : VerticalAxis(axis,presenter,true),
30 m_categoriesAxis(axis)
30 m_categoriesAxis(axis)
31 {
31 {
32 setLabelBetweenTicks(true);
33 }
32 }
34
33
35 ChartBarCategoryAxisY::~ChartBarCategoryAxisY()
34 ChartBarCategoryAxisY::~ChartBarCategoryAxisY()
@@ -28,10 +28,9
28
28
29 QTCOMMERCIALCHART_BEGIN_NAMESPACE
29 QTCOMMERCIALCHART_BEGIN_NAMESPACE
30
30
31 ChartCategoryAxisX::ChartCategoryAxisX(QCategoryAxis *axis,ChartPresenter *presenter) : HorizontalAxis(axis,presenter),
31 ChartCategoryAxisX::ChartCategoryAxisX(QCategoryAxis *axis,ChartPresenter *presenter) : HorizontalAxis(axis,presenter,true),
32 m_axis(axis)
32 m_axis(axis)
33 {
33 {
34 setLabelBetweenTicks(true);
35 }
34 }
36
35
37 ChartCategoryAxisX::~ChartCategoryAxisX()
36 ChartCategoryAxisX::~ChartCategoryAxisX()
@@ -28,10 +28,9
28
28
29 QTCOMMERCIALCHART_BEGIN_NAMESPACE
29 QTCOMMERCIALCHART_BEGIN_NAMESPACE
30
30
31 ChartCategoryAxisY::ChartCategoryAxisY(QCategoryAxis *axis,ChartPresenter *presenter) : VerticalAxis(axis,presenter),
31 ChartCategoryAxisY::ChartCategoryAxisY(QCategoryAxis *axis,ChartPresenter *presenter) : VerticalAxis(axis,presenter,true),
32 m_axis(axis)
32 m_axis(axis)
33 {
33 {
34 setLabelBetweenTicks(true);
35 }
34 }
36
35
37 ChartCategoryAxisY::~ChartCategoryAxisY()
36 ChartCategoryAxisY::~ChartCategoryAxisY()
@@ -32,7 +32,7
32
32
33 QTCOMMERCIALCHART_BEGIN_NAMESPACE
33 QTCOMMERCIALCHART_BEGIN_NAMESPACE
34
34
35 ChartAxis::ChartAxis(QAbstractAxis *axis,ChartPresenter *presenter) : ChartElement(presenter),
35 ChartAxis::ChartAxis(QAbstractAxis *axis,ChartPresenter *presenter, bool intervalAxis) : ChartElement(presenter),
36 m_chartAxis(axis),
36 m_chartAxis(axis),
37 m_labelsAngle(0),
37 m_labelsAngle(0),
38 m_grid(new QGraphicsItemGroup(presenter->rootItem())),
38 m_grid(new QGraphicsItemGroup(presenter->rootItem())),
@@ -44,7 +44,7 ChartAxis::ChartAxis(QAbstractAxis *axis,ChartPresenter *presenter) : ChartEleme
44 m_max(0),
44 m_max(0),
45 m_animation(0),
45 m_animation(0),
46 m_labelPadding(5),
46 m_labelPadding(5),
47 m_labelBetween(false)
47 m_intervalAxis(intervalAxis)
48 {
48 {
49 //initial initialization
49 //initial initialization
50 m_arrow->setZValue(ChartPresenter::AxisZValue);
50 m_arrow->setZValue(ChartPresenter::AxisZValue);
@@ -78,7 +78,7 void ChartAxis::createItems(int count)
78 {
78 {
79 if (m_arrow->children().size() == 0)
79 if (m_arrow->children().size() == 0)
80 m_arrow->addToGroup(new AxisItem(this,presenter()->rootItem()));
80 m_arrow->addToGroup(new AxisItem(this,presenter()->rootItem()));
81 if (m_grid->children().size() == 0){
81 if (m_intervalAxis && m_grid->children().size() == 0){
82 for(int i = 0 ; i < 2 ;i ++)
82 for(int i = 0 ; i < 2 ;i ++)
83 m_grid->addToGroup(new QGraphicsLineItem(presenter()->rootItem()));
83 m_grid->addToGroup(new QGraphicsLineItem(presenter()->rootItem()));
84 }
84 }
@@ -415,11 +415,6 void ChartAxis::axisSelected()
415 //TODO: axis clicked;
415 //TODO: axis clicked;
416 }
416 }
417
417
418 void ChartAxis::setLabelBetweenTicks(bool enabled)
419 {
420 m_labelBetween=enabled;
421 }
422
423 Qt::Orientation ChartAxis::orientation() const
418 Qt::Orientation ChartAxis::orientation() const
424 {
419 {
425 return m_chartAxis->orientation();
420 return m_chartAxis->orientation();
@@ -48,7 +48,7 class ChartAxis : public ChartElement, public QGraphicsLayoutItem
48 Q_INTERFACES(QGraphicsLayoutItem)
48 Q_INTERFACES(QGraphicsLayoutItem)
49 public:
49 public:
50
50
51 ChartAxis(QAbstractAxis *axis, ChartPresenter *presenter);
51 ChartAxis(QAbstractAxis *axis, ChartPresenter *presenter, bool intervalAxis = false);
52 ~ChartAxis();
52 ~ChartAxis();
53
53
54 void setArrowOpacity(qreal opacity);
54 void setArrowOpacity(qreal opacity);
@@ -106,8 +106,8 public:
106 void setLabels(const QStringList& labels);
106 void setLabels(const QStringList& labels);
107 QStringList labels() const { return m_labelsList; }
107 QStringList labels() const { return m_labelsList; }
108
108
109 void setLabelBetweenTicks(bool enabled);
109 //this flag indicates that axis is used to show intervals it means labels are in between ticks
110 bool labelBetweenTicks() const { return m_labelBetween; }
110 bool intervalAxis() const { return m_intervalAxis; }
111
111
112 virtual QSizeF sizeHint(Qt::SizeHint which, const QSizeF &constraint = QSizeF()) const;
112 virtual QSizeF sizeHint(Qt::SizeHint which, const QSizeF &constraint = QSizeF()) const;
113
113
@@ -156,7 +156,7 private:
156 QString m_titleText;
156 QString m_titleText;
157 int m_labelPadding;
157 int m_labelPadding;
158 QStringList m_labelsList;
158 QStringList m_labelsList;
159 bool m_labelBetween;
159 bool m_intervalAxis;
160
160
161 friend class AxisAnimation;
161 friend class AxisAnimation;
162 friend class AxisItem;
162 friend class AxisItem;
@@ -25,7 +25,7
25
25
26 QTCOMMERCIALCHART_BEGIN_NAMESPACE
26 QTCOMMERCIALCHART_BEGIN_NAMESPACE
27
27
28 HorizontalAxis::HorizontalAxis(QAbstractAxis *axis, ChartPresenter *presenter):ChartAxis(axis,presenter)
28 HorizontalAxis::HorizontalAxis(QAbstractAxis *axis, ChartPresenter *presenter,bool intervalAxis):ChartAxis(axis,presenter,intervalAxis)
29 {
29 {
30 }
30 }
31
31
@@ -86,7 +86,7 void HorizontalAxis::updateGeometry()
86 tickItem->setLine(layout[i],axisRect.top(),layout[i],axisRect.top() + labelPadding());
86 tickItem->setLine(layout[i],axisRect.top(),layout[i],axisRect.top() + labelPadding());
87 }
87 }
88
88
89 if(labelBetweenTicks()&& i+1!=layout.size()) {
89 if(intervalAxis()&& i+1!=layout.size()) {
90 const qreal delta = (layout[i+1] - layout[i])/2;
90 const qreal delta = (layout[i+1] - layout[i])/2;
91 labelItem->setPos(layout[i] + delta - center.x(), labelItem->pos().y());
91 labelItem->setPos(layout[i] + delta - center.x(), labelItem->pos().y());
92 }
92 }
@@ -117,14 +117,14 void HorizontalAxis::updateGeometry()
117 if (x < gridRect.left() || x > gridRect.right()) {
117 if (x < gridRect.left() || x > gridRect.right()) {
118 gridItem->setVisible(false);
118 gridItem->setVisible(false);
119 tickItem->setVisible(false);
119 tickItem->setVisible(false);
120 if( labelBetweenTicks() && ( labelItem->pos().x() < gridRect.left() || labelItem->pos().x() + rect.width() > gridRect.right()))
120 if( intervalAxis() && ( labelItem->pos().x() < gridRect.left() || labelItem->pos().x() + rect.width() > gridRect.right()))
121 labelItem->setVisible(false);
121 labelItem->setVisible(false);
122 }
122 }
123
123
124 }
124 }
125
125
126 //begin/end grid line in case labels between
126 //begin/end grid line in case labels between
127 if(labelBetweenTicks()) {
127 if(intervalAxis()) {
128 QGraphicsLineItem *gridLine;
128 QGraphicsLineItem *gridLine;
129 gridLine = static_cast<QGraphicsLineItem*>(lines.at(layout.size()));
129 gridLine = static_cast<QGraphicsLineItem*>(lines.at(layout.size()));
130 gridLine->setLine(gridRect.right(), gridRect.top(), gridRect.right(), gridRect.bottom());
130 gridLine->setLine(gridRect.right(), gridRect.top(), gridRect.right(), gridRect.bottom());
@@ -37,7 +37,7 QTCOMMERCIALCHART_BEGIN_NAMESPACE
37 class HorizontalAxis : public ChartAxis
37 class HorizontalAxis : public ChartAxis
38 {
38 {
39 public:
39 public:
40 HorizontalAxis(QAbstractAxis *axis, ChartPresenter *presenter);
40 HorizontalAxis(QAbstractAxis *axis, ChartPresenter *presenter,bool intervalAxis = false);
41 ~HorizontalAxis();
41 ~HorizontalAxis();
42 protected:
42 protected:
43 void updateGeometry();
43 void updateGeometry();
@@ -24,7 +24,7
24
24
25 QTCOMMERCIALCHART_BEGIN_NAMESPACE
25 QTCOMMERCIALCHART_BEGIN_NAMESPACE
26
26
27 VerticalAxis::VerticalAxis(QAbstractAxis *axis, ChartPresenter *presenter):ChartAxis(axis,presenter)
27 VerticalAxis::VerticalAxis(QAbstractAxis *axis, ChartPresenter *presenter, bool intervalAxis):ChartAxis(axis,presenter,intervalAxis)
28 {
28 {
29
29
30 }
30 }
@@ -98,7 +98,7 void VerticalAxis::updateGeometry()
98 labelItem->setPos( axisRect.left() + labelPadding() , layout[i]-center.y());
98 labelItem->setPos( axisRect.left() + labelPadding() , layout[i]-center.y());
99 tickItem->setLine( axisRect.left(),layout[i], axisRect.left()+ labelPadding(),layout[i]);
99 tickItem->setLine( axisRect.left(),layout[i], axisRect.left()+ labelPadding(),layout[i]);
100 }
100 }
101 if(labelBetweenTicks()&& i+1!=layout.size()) {
101 if(intervalAxis()&& i+1!=layout.size()) {
102 const qreal delta = (layout[i+1] - layout[i])/2;
102 const qreal delta = (layout[i+1] - layout[i])/2;
103 labelItem->setPos(labelItem->pos().x() , layout[i] + delta - center.y());
103 labelItem->setPos(labelItem->pos().x() , layout[i] + delta - center.y());
104 }
104 }
@@ -128,13 +128,13 void VerticalAxis::updateGeometry()
128 if (y < gridRect.top() || y > gridRect.bottom()) {
128 if (y < gridRect.top() || y > gridRect.bottom()) {
129 gridItem->setVisible(false);
129 gridItem->setVisible(false);
130 tickItem->setVisible(false);
130 tickItem->setVisible(false);
131 if( labelBetweenTicks() && ( labelItem->pos().y() < gridRect.top() || labelItem->pos().y() + rect.height() > gridRect.bottom()))
131 if( intervalAxis() && ( labelItem->pos().y() < gridRect.top() || labelItem->pos().y() + rect.height() > gridRect.bottom()))
132 labelItem->setVisible(false);
132 labelItem->setVisible(false);
133 }
133 }
134
134
135 }
135 }
136 //begin/end grid line in case labels between
136 //begin/end grid line in case labels between
137 if(labelBetweenTicks()) {
137 if(intervalAxis()) {
138 QGraphicsLineItem *gridLine;
138 QGraphicsLineItem *gridLine;
139 gridLine = static_cast<QGraphicsLineItem*>(lines.at(layout.size()));
139 gridLine = static_cast<QGraphicsLineItem*>(lines.at(layout.size()));
140 gridLine->setLine(gridRect.left(), gridRect.top(), gridRect.right(), gridRect.top());
140 gridLine->setLine(gridRect.left(), gridRect.top(), gridRect.right(), gridRect.top());
@@ -37,7 +37,7 QTCOMMERCIALCHART_BEGIN_NAMESPACE
37 class VerticalAxis : public ChartAxis
37 class VerticalAxis : public ChartAxis
38 {
38 {
39 public:
39 public:
40 VerticalAxis(QAbstractAxis *axis, ChartPresenter *presenter);
40 VerticalAxis(QAbstractAxis *axis, ChartPresenter *presenter, bool intervalAxis = false);
41 ~VerticalAxis();
41 ~VerticalAxis();
42 protected:
42 protected:
43 void updateGeometry();
43 void updateGeometry();
General Comments 0
You need to be logged in to leave comments. Login now