##// END OF EJS Templates
Fixes wrong shades zvalues
Michal Klocek -
r184:2e4df5890251
parent child
Show More
@@ -45,7 +45,7 int main(int argc, char *argv[])
45 45 axis.setGridPen(Qt::DashLine);
46 46
47 47 chartView->setDefaultAxisX(axis);
48 //axis.setShadesBrush(Qt::gray);
48 axis.setShadesBrush(Qt::gray);
49 49 chartView->setDefaultAxisY(axis);
50 50
51 51 window.setCentralWidget(chartView);
@@ -13,11 +13,13 m_ticks(4),
13 13 m_type(type),
14 14 m_labelsAngle(0),
15 15 m_shadesEnabled(true),
16 m_grid(this),
17 m_shades(this),
18 m_labels(this)
16 m_grid(parent),
17 m_shades(parent),
18 m_labels(parent)
19 19 {
20 20 //initial initialization
21 m_shades.setZValue(0);
22 m_grid.setZValue(2);
21 23 createItems();
22 24 }
23 25
@@ -73,6 +75,8 void AxisItem::updateDomain()
73 75 {
74 76 const qreal deltaX = m_rect.width() / m_ticks;
75 77
78 m_axis.setLine(m_rect.left(), m_rect.bottom(), m_rect.right(), m_rect.bottom());
79
76 80 for (int i = 0; i <= m_ticks; ++i) {
77 81
78 82 int x = i * deltaX + m_rect.left();
@@ -100,6 +104,8 void AxisItem::updateDomain()
100 104 {
101 105 const qreal deltaY = m_rect.height()/ m_ticks;
102 106
107 m_axis.setLine(m_rect.left() , m_rect.top(), m_rect.left(), m_rect.bottom());
108
103 109 for (int i = 0; i <= m_ticks; ++i) {
104 110
105 111 int y = i * -deltaY + m_rect.bottom();
@@ -131,6 +137,13 void AxisItem::updateDomain()
131 137
132 138 void AxisItem::handleAxisChanged(const QChartAxis& axis)
133 139 {
140 if(axis.isAxisVisible()) {
141 setAxisOpacity(100);
142 }
143 else {
144 setAxisOpacity(0);
145 }
146
134 147 if(axis.isGridVisible()) {
135 148 setGridOpacity(100);
136 149 }
@@ -168,6 +181,7 void AxisItem::handleAxisChanged(const QChartAxis& axis)
168 181 break;
169 182 }
170 183
184 setAxisPen(axis.axisPen());
171 185 setLabelsPen(axis.labelsPen());
172 186 setLabelsBrush(axis.labelsBrush());
173 187 setLabelsFont(axis.labelFont());
@@ -191,6 +205,16 void AxisItem::handleGeometryChanged(const QRectF& rect)
191 205 update();
192 206 }
193 207
208 void AxisItem::setAxisOpacity(qreal opacity)
209 {
210 m_axis.setOpacity(opacity);
211 }
212
213 qreal AxisItem::axisOpacity() const
214 {
215 return m_axis.opacity();
216 }
217
194 218 void AxisItem::setGridOpacity(qreal opacity)
195 219 {
196 220 m_grid.setOpacity(opacity);
@@ -267,6 +291,11 void AxisItem::setShadesPen(const QPen& pen)
267 291 }
268 292 }
269 293
294 void AxisItem::setAxisPen(const QPen& pen)
295 {
296 m_axis.setPen(pen);
297 }
298
270 299 void AxisItem::setGridPen(const QPen& pen)
271 300 {
272 301 foreach(QGraphicsItem* item , m_grid.childItems()) {
@@ -24,6 +24,9 public:
24 24
25 25 AxisType axisType() const {return m_type;};
26 26
27 void setAxisOpacity(qreal opacity);
28 qreal axisOpacity() const;
29
27 30 void setGridOpacity(qreal opacity);
28 31 qreal gridOpacity() const;
29 32
@@ -42,6 +45,7 public:
42 45 void setShadesBrush(const QBrush& brush);
43 46 void setShadesPen(const QPen& pen);
44 47
48 void setAxisPen(const QPen& pen);
45 49 void setGridPen(const QPen& pen);
46 50
47 51 void setLabelsPen(const QPen& pen);
@@ -67,6 +71,7 private:
67 71 QGraphicsItemGroup m_grid;
68 72 QGraphicsItemGroup m_shades;
69 73 QGraphicsItemGroup m_labels;
74 QGraphicsLineItem m_axis;
70 75
71 76 };
72 77
@@ -239,6 +239,7 void ChartTheme::decorate(QChartAxis& axis,AxisItem* item)
239 239
240 240 axis.setLabelsBrush(Qt::black);
241 241 axis.setLabelsPen(Qt::NoPen);
242 axis.setShadesPen(Qt::NoPen);
242 243 item->handleAxisChanged(axis);
243 244 }
244 245
@@ -22,11 +22,6 void QChartAxis::setAxisPen(const QPen& pen)
22 22 m_axisPen=pen;
23 23 }
24 24
25 void QChartAxis::setAxisBrush(const QBrush& brush)
26 {
27 m_axisBrush=brush;
28 }
29
30 25 void QChartAxis::setAxisVisible(bool visible)
31 26 {
32 27 m_axisVisible=visible;
General Comments 0
You need to be logged in to leave comments. Login now