@@ -14,20 +14,20 Axis::Axis(QChartAxis *axis,ChartPresenter *presenter,AxisType type) : Chart(pre | |||
|
14 | 14 | m_chartAxis(axis), |
|
15 | 15 | m_type(type), |
|
16 | 16 | m_labelsAngle(0), |
|
17 | m_grid(presenter->rootItem()), | |
|
18 | m_shades(presenter->rootItem()), | |
|
19 | m_labels(presenter->rootItem()), | |
|
20 | m_axis(presenter->rootItem()), | |
|
17 | m_grid(new QGraphicsItemGroup(presenter->rootItem())), | |
|
18 | m_shades(new QGraphicsItemGroup(presenter->rootItem())), | |
|
19 | m_labels(new QGraphicsItemGroup(presenter->rootItem())), | |
|
20 | m_axis(new QGraphicsItemGroup(presenter->rootItem())), | |
|
21 | 21 | m_min(0), |
|
22 | 22 | m_max(0), |
|
23 | 23 | m_ticksCount(0) |
|
24 | 24 | { |
|
25 | 25 | //initial initialization |
|
26 |
m_axis |
|
|
27 |
m_axis |
|
|
26 | m_axis->setZValue(ChartPresenter::AxisZValue); | |
|
27 | m_axis->setHandlesChildEvents(false); | |
|
28 | 28 | |
|
29 |
m_shades |
|
|
30 |
m_grid |
|
|
29 | m_shades->setZValue(ChartPresenter::ShadesZValue); | |
|
30 | m_grid->setZValue(ChartPresenter::GridZValue); | |
|
31 | 31 | |
|
32 | 32 | connect(m_chartAxis,SIGNAL(updated()),this,SLOT(handleAxisUpdated())); |
|
33 | 33 | connect(m_chartAxis->categories(),SIGNAL(updated()),this,SLOT(handleAxisCategoriesUpdated())); |
@@ -42,22 +42,22 Axis::~Axis() | |||
|
42 | 42 | void Axis::createItems(int count) |
|
43 | 43 | { |
|
44 | 44 | |
|
45 |
if (m_axis |
|
|
46 |
m_axis |
|
|
45 | if (m_axis->children().size() == 0) | |
|
46 | m_axis->addToGroup(new AxisItem(this)); | |
|
47 | 47 | for (int i = 0; i < count; ++i) { |
|
48 |
m_grid |
|
|
49 |
m_labels |
|
|
50 |
m_axis |
|
|
51 |
if ((m_grid |
|
|
48 | m_grid->addToGroup(new QGraphicsLineItem()); | |
|
49 | m_labels->addToGroup(new QGraphicsSimpleTextItem()); | |
|
50 | m_axis->addToGroup(new QGraphicsLineItem()); | |
|
51 | if ((m_grid->childItems().size())%2 && m_grid->childItems().size()>2) m_shades->addToGroup(new QGraphicsRectItem()); | |
|
52 | 52 | } |
|
53 | 53 | } |
|
54 | 54 | |
|
55 | 55 | void Axis::deleteItems(int count) |
|
56 | 56 | { |
|
57 |
QList<QGraphicsItem *> lines = m_grid |
|
|
58 |
QList<QGraphicsItem *> labels = m_labels |
|
|
59 |
QList<QGraphicsItem *> shades = m_shades |
|
|
60 |
QList<QGraphicsItem *> axis = m_axis |
|
|
57 | QList<QGraphicsItem *> lines = m_grid->childItems(); | |
|
58 | QList<QGraphicsItem *> labels = m_labels->childItems(); | |
|
59 | QList<QGraphicsItem *> shades = m_shades->childItems(); | |
|
60 | QList<QGraphicsItem *> axis = m_axis->childItems(); | |
|
61 | 61 | |
|
62 | 62 | for (int i = 0; i < count; ++i) { |
|
63 | 63 | if (lines.size()%2 && lines.size() > 1) delete(shades.takeLast()); |
@@ -111,47 +111,47 bool Axis::createLabels(QStringList &labels,qreal min, qreal max,int ticks) cons | |||
|
111 | 111 | |
|
112 | 112 | void Axis::setAxisOpacity(qreal opacity) |
|
113 | 113 | { |
|
114 |
m_axis |
|
|
114 | m_axis->setOpacity(opacity); | |
|
115 | 115 | } |
|
116 | 116 | |
|
117 | 117 | qreal Axis::axisOpacity() const |
|
118 | 118 | { |
|
119 |
return m_axis |
|
|
119 | return m_axis->opacity(); | |
|
120 | 120 | } |
|
121 | 121 | |
|
122 | 122 | void Axis::setGridOpacity(qreal opacity) |
|
123 | 123 | { |
|
124 |
m_grid |
|
|
124 | m_grid->setOpacity(opacity); | |
|
125 | 125 | } |
|
126 | 126 | |
|
127 | 127 | qreal Axis::gridOpacity() const |
|
128 | 128 | { |
|
129 |
return m_grid |
|
|
129 | return m_grid->opacity(); | |
|
130 | 130 | } |
|
131 | 131 | |
|
132 | 132 | void Axis::setLabelsOpacity(qreal opacity) |
|
133 | 133 | { |
|
134 |
m_labels |
|
|
134 | m_labels->setOpacity(opacity); | |
|
135 | 135 | } |
|
136 | 136 | |
|
137 | 137 | qreal Axis::labelsOpacity() const |
|
138 | 138 | { |
|
139 |
return m_labels |
|
|
139 | return m_labels->opacity(); | |
|
140 | 140 | } |
|
141 | 141 | |
|
142 | 142 | void Axis::setShadesOpacity(qreal opacity) |
|
143 | 143 | { |
|
144 |
m_shades |
|
|
144 | m_shades->setOpacity(opacity); | |
|
145 | 145 | } |
|
146 | 146 | |
|
147 | 147 | qreal Axis::shadesOpacity() const |
|
148 | 148 | { |
|
149 |
return m_shades |
|
|
149 | return m_shades->opacity(); | |
|
150 | 150 | } |
|
151 | 151 | |
|
152 | 152 | void Axis::setLabelsAngle(int angle) |
|
153 | 153 | { |
|
154 |
foreach(QGraphicsItem* item , m_labels |
|
|
154 | foreach(QGraphicsItem* item , m_labels->childItems()) { | |
|
155 | 155 | item->setRotation(angle); |
|
156 | 156 | } |
|
157 | 157 | |
@@ -160,49 +160,49 void Axis::setLabelsAngle(int angle) | |||
|
160 | 160 | |
|
161 | 161 | void Axis::setLabelsPen(const QPen &pen) |
|
162 | 162 | { |
|
163 |
foreach(QGraphicsItem* item , m_labels |
|
|
163 | foreach(QGraphicsItem* item , m_labels->childItems()) { | |
|
164 | 164 | static_cast<QGraphicsSimpleTextItem*>(item)->setPen(pen); |
|
165 | 165 | } |
|
166 | 166 | } |
|
167 | 167 | |
|
168 | 168 | void Axis::setLabelsBrush(const QBrush &brush) |
|
169 | 169 | { |
|
170 |
foreach(QGraphicsItem* item , m_labels |
|
|
170 | foreach(QGraphicsItem* item , m_labels->childItems()) { | |
|
171 | 171 | static_cast<QGraphicsSimpleTextItem*>(item)->setBrush(brush); |
|
172 | 172 | } |
|
173 | 173 | } |
|
174 | 174 | |
|
175 | 175 | void Axis::setLabelsFont(const QFont &font) |
|
176 | 176 | { |
|
177 |
foreach(QGraphicsItem* item , m_labels |
|
|
177 | foreach(QGraphicsItem* item , m_labels->childItems()) { | |
|
178 | 178 | static_cast<QGraphicsSimpleTextItem*>(item)->setFont(font); |
|
179 | 179 | } |
|
180 | 180 | } |
|
181 | 181 | |
|
182 | 182 | void Axis::setShadesBrush(const QBrush &brush) |
|
183 | 183 | { |
|
184 |
foreach(QGraphicsItem* item , m_shades |
|
|
184 | foreach(QGraphicsItem* item , m_shades->childItems()) { | |
|
185 | 185 | static_cast<QGraphicsRectItem*>(item)->setBrush(brush); |
|
186 | 186 | } |
|
187 | 187 | } |
|
188 | 188 | |
|
189 | 189 | void Axis::setShadesPen(const QPen &pen) |
|
190 | 190 | { |
|
191 |
foreach(QGraphicsItem* item , m_shades |
|
|
191 | foreach(QGraphicsItem* item , m_shades->childItems()) { | |
|
192 | 192 | static_cast<QGraphicsRectItem*>(item)->setPen(pen); |
|
193 | 193 | } |
|
194 | 194 | } |
|
195 | 195 | |
|
196 | 196 | void Axis::setAxisPen(const QPen &pen) |
|
197 | 197 | { |
|
198 |
foreach(QGraphicsItem* item , m_axis |
|
|
198 | foreach(QGraphicsItem* item , m_axis->childItems()) { | |
|
199 | 199 | static_cast<QGraphicsLineItem*>(item)->setPen(pen); |
|
200 | 200 | } |
|
201 | 201 | } |
|
202 | 202 | |
|
203 | 203 | void Axis::setGridPen(const QPen &pen) |
|
204 | 204 | { |
|
205 |
foreach(QGraphicsItem* item , m_grid |
|
|
205 | foreach(QGraphicsItem* item , m_grid->childItems()) { | |
|
206 | 206 | static_cast<QGraphicsLineItem*>(item)->setPen(pen); |
|
207 | 207 | } |
|
208 | 208 | } |
@@ -254,10 +254,10 void Axis::setLayout(QVector<qreal> &layout) | |||
|
254 | 254 | |
|
255 | 255 | bool categories = createLabels(ticksList,m_min,m_max,layout.size()); |
|
256 | 256 | |
|
257 |
|
|
|
258 |
|
|
|
259 |
|
|
|
260 |
|
|
|
257 | QList<QGraphicsItem *> lines = m_grid->childItems(); | |
|
258 | QList<QGraphicsItem *> labels = m_labels->childItems(); | |
|
259 | QList<QGraphicsItem *> shades = m_shades->childItems(); | |
|
260 | QList<QGraphicsItem *> axis = m_axis->childItems(); | |
|
261 | 261 | |
|
262 | 262 | Q_ASSERT(labels.size() == ticksList.size()); |
|
263 | 263 | Q_ASSERT(layout.size() == ticksList.size()); |
@@ -72,10 +72,10 private: | |||
|
72 | 72 | AxisType m_type; |
|
73 | 73 | QRectF m_rect; |
|
74 | 74 | int m_labelsAngle; |
|
75 | QGraphicsItemGroup m_grid; | |
|
76 | QGraphicsItemGroup m_shades; | |
|
77 | QGraphicsItemGroup m_labels; | |
|
78 | QGraphicsItemGroup m_axis; | |
|
75 | QGraphicsItemGroup *m_grid; | |
|
76 | QGraphicsItemGroup *m_shades; | |
|
77 | QGraphicsItemGroup *m_labels; | |
|
78 | QGraphicsItemGroup *m_axis; | |
|
79 | 79 | QVector<qreal> m_layoutVector; |
|
80 | 80 | qreal m_min; |
|
81 | 81 | qreal m_max; |
General Comments 0
You need to be logged in to leave comments.
Login now