##// END OF EJS Templates
Adds opacity to shades
Michal Klocek -
r188:81d9e3777fdd
parent child
Show More
@@ -1,56 +1,62
1 1 #include <QApplication>
2 2 #include <QMainWindow>
3 3 #include <qchartview.h>
4 4 #include <qlinechartseries.h>
5 5 #include <qchart.h>
6 6 #include <qchartaxis.h>
7 7 #include <cmath>
8 8
9 9 QTCOMMERCIALCHART_USE_NAMESPACE
10 10
11 11 #define PI 3.14159265358979
12 12
13 13 int main(int argc, char *argv[])
14 14 {
15 15 QApplication a(argc, argv);
16 16
17 17 QMainWindow window;
18 18
19 19 QLineChartSeries* series0 = new QLineChartSeries();
20 20 QPen blue(Qt::blue);
21 21 blue.setWidth(3);
22 22 series0->setPen(blue);
23 23 QLineChartSeries* series1 = new QLineChartSeries();
24 24 QPen red(Qt::red);
25 25 red.setWidth(3);
26 26 series1->setPen(red);
27 27
28 28 int numPoints = 100;
29 29
30 30 for (int x = 0; x <= numPoints; ++x) {
31 31 series0->add(x, fabs(sin(PI/50*x)*100));
32 32 series1->add(x, fabs(cos(PI/50*x)*100));
33 33 }
34 34
35 35 QChartView* chartView = new QChartView(&window);
36 36
37 37 chartView->setRenderHint(QPainter::Antialiasing);
38 38 chartView->setTitle("Basic line chart example");
39 39 chartView->addSeries(series0);
40 40 chartView->addSeries(series1);
41 chartView->setChartBackgroundBrush(Qt::white);
41
42
43 QLinearGradient backgroundGradient;
44 backgroundGradient.setColorAt(0.0, Qt::white);
45 backgroundGradient.setColorAt(1.0, QRgb(0xffff80));
46 backgroundGradient.setCoordinateMode(QGradient::ObjectBoundingMode);
47 chartView->setChartBackgroundBrush(backgroundGradient);
42 48
43 49 QChartAxis axis = chartView->defaultAxisX();
44 50 axis.setLabelsOrientation(QChartAxis::LabelsOrientationSlide);
45 51 axis.setGridPen(Qt::DashLine);
46 52
47 53 chartView->setDefaultAxisX(axis);
48 axis.setShadesBrush(Qt::lightGray);
54 axis.setShadesBrush(Qt::yellow);
49 55 chartView->setDefaultAxisY(axis);
50 56
51 57 window.setCentralWidget(chartView);
52 58 window.resize(400, 300);
53 59 window.show();
54 60
55 61 return a.exec();
56 62 }
@@ -1,318 +1,320
1 1 #include "axisitem_p.h"
2 2 #include "qchartaxis.h"
3 3 #include <QPainter>
4 4 #include <QDebug>
5 5
6 6 static int label_padding = 5;
7 7
8 8 QTCOMMERCIALCHART_BEGIN_NAMESPACE
9 9
10 10 AxisItem::AxisItem(AxisType type,QGraphicsItem* parent) :
11 11 ChartItem(parent),
12 12 m_ticks(4),
13 13 m_type(type),
14 14 m_labelsAngle(0),
15 15 m_shadesEnabled(true),
16 16 m_grid(parent),
17 17 m_shades(parent),
18 18 m_labels(parent)
19 19 {
20 20 //initial initialization
21 21 m_shades.setZValue(0);
22 22 m_grid.setZValue(2);
23 23 createItems();
24 24 }
25 25
26 26 AxisItem::~AxisItem()
27 27 {
28 28 }
29 29
30 30 QRectF AxisItem::boundingRect() const
31 31 {
32 32 return m_rect;
33 33 }
34 34
35 35 void AxisItem::createItems()
36 36 {
37 37 for (int i = 0; i <= m_ticks; ++i) {
38 38 m_grid.addToGroup(new QGraphicsLineItem(this));
39 39 m_labels.addToGroup(new QGraphicsSimpleTextItem(this));
40 40 if(i%2) m_shades.addToGroup(new QGraphicsRectItem(this));
41 41 }
42 42 }
43 43
44 44 void AxisItem::clear()
45 45 {
46 46 foreach(QGraphicsItem* item , m_shades.childItems()) {
47 47 delete item;
48 48 }
49 49
50 50 foreach(QGraphicsItem* item , m_grid.childItems()) {
51 51 delete item;
52 52 }
53 53
54 54 foreach(QGraphicsItem* item , m_labels.childItems()) {
55 55 delete item;
56 56 }
57 57
58 58 }
59 59
60 60 void AxisItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
61 61 {
62 62
63 63 }
64 64
65 65 void AxisItem::updateDomain()
66 66 {
67 67
68 68 QList<QGraphicsItem *> lines = m_grid.childItems();
69 69 QList<QGraphicsItem *> labels = m_labels.childItems();
70 70 QList<QGraphicsItem *> shades = m_shades.childItems();
71 71
72 72 switch (m_type)
73 73 {
74 74 case X_AXIS:
75 75 {
76 76 const qreal deltaX = m_rect.width() / m_ticks;
77 77
78 78 m_axis.setLine(m_rect.left(), m_rect.bottom(), m_rect.right(), m_rect.bottom());
79 79
80 80 for (int i = 0; i <= m_ticks; ++i) {
81 81
82 82 int x = i * deltaX + m_rect.left();
83 83
84 84 qreal label = m_domain.m_minX + (i * m_domain.spanX()/ m_ticks);
85 85
86 86 QGraphicsLineItem *lineItem = static_cast<QGraphicsLineItem*>(lines.at(i));
87 87 lineItem->setLine(x, m_rect.top(), x, m_rect.bottom());
88 88
89 89 QGraphicsSimpleTextItem *labelItem = static_cast<QGraphicsSimpleTextItem*>(labels.at(i));
90 90 labelItem->setText(QString::number(label));
91 91 QPointF center = labelItem->boundingRect().center();
92 92 labelItem->setTransformOriginPoint(center.x(), center.y());
93 93 labelItem->setPos(x - center.x(), m_rect.bottom() + label_padding);
94 94
95 95 if(i%2){
96 96 QGraphicsRectItem *rectItem = static_cast<QGraphicsRectItem*>(shades.at(i/2));
97 97 rectItem->setRect(x,m_rect.top(),deltaX,m_rect.height());
98 rectItem->setOpacity( 0.5 );
98 99 }
99 100 }
100 101 }
101 102 break;
102 103
103 104 case Y_AXIS:
104 105 {
105 106 const qreal deltaY = m_rect.height()/ m_ticks;
106 107
107 108 m_axis.setLine(m_rect.left() , m_rect.top(), m_rect.left(), m_rect.bottom());
108 109
109 110 for (int i = 0; i <= m_ticks; ++i) {
110 111
111 112 int y = i * -deltaY + m_rect.bottom();
112 113
113 114 qreal label = m_domain.m_minY + (i * m_domain.spanY()/ m_ticks);
114 115
115 116 QGraphicsLineItem *lineItem = static_cast<QGraphicsLineItem*>(lines.at(i));
116 117 lineItem->setLine(m_rect.left() , y, m_rect.right(), y);
117 118
118 119 QGraphicsSimpleTextItem *labelItem = static_cast<QGraphicsSimpleTextItem*>(labels.at(i));
119 120 labelItem->setText(QString::number(label));
120 121 QPointF center = labelItem->boundingRect().center();
121 122 labelItem->setTransformOriginPoint(center.x(), center.y());
122 123 labelItem->setPos(m_rect.left() - labelItem->boundingRect().width() - label_padding , y-center.y());
123 124
124 125
125 126 if(i%2){
126 127 QGraphicsRectItem *rectItem = static_cast<QGraphicsRectItem*>(shades.at(i/2));
127 128 rectItem->setRect(m_rect.left(),y,m_rect.width(),deltaY);
129
128 130 }
129 131 }
130 132 }
131 133 break;
132 134 default:
133 135 qDebug()<<"Unknown axis type";
134 136 break;
135 137 }
136 138 }
137 139
138 140 void AxisItem::handleAxisChanged(const QChartAxis& axis)
139 141 {
140 142 if(axis.isAxisVisible()) {
141 143 setAxisOpacity(100);
142 144 }
143 145 else {
144 146 setAxisOpacity(0);
145 147 }
146 148
147 149 if(axis.isGridVisible()) {
148 150 setGridOpacity(100);
149 151 }
150 152 else {
151 153 setGridOpacity(0);
152 154 }
153 155
154 156 if(axis.isLabelsVisible())
155 157 {
156 158 setLabelsOpacity(100);
157 159 }
158 160 else {
159 161 setLabelsOpacity(0);
160 162 }
161 163
162 164 if(axis.isShadesVisible()) {
163 setShadesOpacity(100);
165 setShadesOpacity(axis.shadesOpacity());
164 166 }
165 167 else {
166 168 setShadesOpacity(0);
167 169 }
168 170
169 171 switch(axis.labelsOrientation())
170 172 {
171 173 case QChartAxis::LabelsOrientationHorizontal:
172 174 setLabelsAngle(0);
173 175 break;
174 176 case QChartAxis::LabelsOrientationVertical:
175 177 setLabelsAngle(90);
176 178 break;
177 179 case QChartAxis::LabelsOrientationSlide:
178 180 setLabelsAngle(-45);
179 181 break;
180 182 default:
181 183 break;
182 184 }
183 185
184 186 setAxisPen(axis.axisPen());
185 187 setLabelsPen(axis.labelsPen());
186 188 setLabelsBrush(axis.labelsBrush());
187 189 setLabelsFont(axis.labelFont());
188 190 setGridPen(axis.gridPen());
189 191 setShadesPen(axis.shadesPen());
190 192 setShadesBrush(axis.shadesBrush());
191 193
192 194 }
193 195
194 196 void AxisItem::handleDomainChanged(const Domain& domain)
195 197 {
196 198 m_domain = domain;
197 199 updateDomain();
198 200 update();
199 201 }
200 202
201 203 void AxisItem::handleGeometryChanged(const QRectF& rect)
202 204 {
203 205 m_rect = rect;
204 206 updateDomain();
205 207 update();
206 208 }
207 209
208 210 void AxisItem::setAxisOpacity(qreal opacity)
209 211 {
210 212 m_axis.setOpacity(opacity);
211 213 }
212 214
213 215 qreal AxisItem::axisOpacity() const
214 216 {
215 217 return m_axis.opacity();
216 218 }
217 219
218 220 void AxisItem::setGridOpacity(qreal opacity)
219 221 {
220 222 m_grid.setOpacity(opacity);
221 223 }
222 224
223 225
224 226 qreal AxisItem::gridOpacity() const
225 227 {
226 228 return m_grid.opacity();
227 229 }
228 230
229 231 void AxisItem::setLabelsOpacity(qreal opacity)
230 232 {
231 233 m_labels.setOpacity(opacity);
232 234 }
233 235
234 236 qreal AxisItem::labelsOpacity() const
235 237 {
236 238 return m_labels.opacity();
237 239 }
238 240
239 241 void AxisItem::setShadesOpacity(qreal opacity)
240 242 {
241 243 m_shades.setOpacity(opacity);
242 244 }
243 245
244 246 qreal AxisItem::shadesOpacity() const
245 247 {
246 248 return m_shades.opacity();
247 249 }
248 250
249 251 void AxisItem::setLabelsAngle(int angle)
250 252 {
251 253 foreach(QGraphicsItem* item , m_labels.childItems()) {
252 254 QPointF center = item->boundingRect().center();
253 255 item->setRotation(angle);
254 256 }
255 257
256 258 m_labelsAngle=angle;
257 259 }
258 260
259 261 void AxisItem::setLabelsPen(const QPen& pen)
260 262 {
261 263 foreach(QGraphicsItem* item , m_labels.childItems()) {
262 264 static_cast<QGraphicsSimpleTextItem*>(item)->setPen(pen);
263 265 }
264 266 }
265 267
266 268 void AxisItem::setLabelsBrush(const QBrush& brush)
267 269 {
268 270 foreach(QGraphicsItem* item , m_labels.childItems()) {
269 271 static_cast<QGraphicsSimpleTextItem*>(item)->setBrush(brush);
270 272 }
271 273 }
272 274
273 275 void AxisItem::setLabelsFont(const QFont& font)
274 276 {
275 277 foreach(QGraphicsItem* item , m_labels.childItems()) {
276 278 static_cast<QGraphicsSimpleTextItem*>(item)->setFont(font);
277 279 }
278 280 }
279 281
280 282 void AxisItem::setShadesBrush(const QBrush& brush)
281 283 {
282 284 foreach(QGraphicsItem* item , m_shades.childItems()) {
283 285 static_cast<QGraphicsRectItem*>(item)->setBrush(brush);
284 286 }
285 287 }
286 288
287 289 void AxisItem::setShadesPen(const QPen& pen)
288 290 {
289 291 foreach(QGraphicsItem* item , m_shades.childItems()) {
290 292 static_cast<QGraphicsRectItem*>(item)->setPen(pen);
291 293 }
292 294 }
293 295
294 296 void AxisItem::setAxisPen(const QPen& pen)
295 297 {
296 298 m_axis.setPen(pen);
297 299 }
298 300
299 301 void AxisItem::setGridPen(const QPen& pen)
300 302 {
301 303 foreach(QGraphicsItem* item , m_grid.childItems()) {
302 304 static_cast<QGraphicsLineItem*>(item)->setPen(pen);
303 305 }
304 306 }
305 307
306 308 void AxisItem::setTicks(int count)
307 309 {
308 310 if(count!=m_ticks){
309 311 clear();
310 312 m_ticks=count;
311 313 createItems();
312 314 }
313 315 }
314 316
315 317 //TODO "nice numbers algorithm"
316 318 #include "moc_axisitem_p.cpp"
317 319
318 320 QTCOMMERCIALCHART_END_NAMESPACE
@@ -1,246 +1,247
1 1 #include "charttheme_p.h"
2 2 #include "qchart.h"
3 3 #include "qchartaxis.h"
4 4
5 5
6 6 //series
7 7 #include "barchartseries.h"
8 8 #include "stackedbarchartseries.h"
9 9 #include "percentbarchartseries.h"
10 10 #include "qlinechartseries.h"
11 11 #include "qscatterseries.h"
12 12 #include "qpieseries.h"
13 13
14 14 //items
15 15 #include "axisitem_p.h"
16 16 #include "bargroup.h"
17 17 #include "stackedbargroup.h"
18 18 #include "linechartitem_p.h"
19 19 #include "percentbargroup.h"
20 20 #include "scatterpresenter.h"
21 21 #include "piepresenter.h"
22 22
23 23 //themes
24 24 #include "chartthemevanilla_p.h"
25 25 #include "chartthemeicy_p.h"
26 26 #include "chartthemegrayscale_p.h"
27 27 #include "chartthemescientific_p.h"
28 28
29 29
30 30 QTCOMMERCIALCHART_BEGIN_NAMESPACE
31 31
32 32 /* TODO
33 33 case QChart::ChartThemeUnnamed1:
34 34 m_seriesThemes.append(SeriesTheme(QColor(QRgb(0xff3fa9f5)), 2));
35 35 m_seriesThemes.append(SeriesTheme(QColor(QRgb(0xff7AC943)), 2));
36 36 m_seriesThemes.append(SeriesTheme(QColor(QRgb(0xffFF931E)), 2));
37 37 m_seriesThemes.append(SeriesTheme(QColor(QRgb(0xffFF1D25)), 2));
38 38 m_seriesThemes.append(SeriesTheme(QColor(QRgb(0xffFF7BAC)), 2));
39 39
40 40 m_gradientStartColor = QColor(QRgb(0xfff3dc9e));
41 41 m_gradientEndColor = QColor(QRgb(0xffafafaf));
42 42 */
43 43
44 44 ChartTheme::ChartTheme(QChart::ChartTheme id)
45 45 {
46 46 m_id = id;
47 47 m_seriesColor.append(QRgb(0xff000000));
48 48 m_seriesColor.append(QRgb(0xff707070));
49 49 m_gradientStartColor = QColor(QRgb(0xffffffff));
50 50 m_gradientEndColor = QColor(QRgb(0xffafafaf));
51 51 }
52 52
53 53
54 54 ChartTheme* ChartTheme::createTheme(QChart::ChartTheme theme)
55 55 {
56 56 switch(theme) {
57 57 case QChart::ChartThemeDefault:
58 58 return new ChartTheme();
59 59 case QChart::ChartThemeVanilla:
60 60 return new ChartThemeVanilla();
61 61 case QChart::ChartThemeIcy:
62 62 return new ChartThemeIcy();
63 63 case QChart::ChartThemeGrayscale:
64 64 return new ChartThemeGrayscale();
65 65 case QChart::ChartThemeScientific:
66 66 return new ChartThemeScientific();
67 67 }
68 68 }
69 69
70 70 void ChartTheme::decorate(QChart* chart)
71 71 {
72 72 QLinearGradient backgroundGradient;
73 73 backgroundGradient.setColorAt(0.0, m_gradientStartColor);
74 74 backgroundGradient.setColorAt(1.0, m_gradientEndColor);
75 75 backgroundGradient.setCoordinateMode(QGradient::ObjectBoundingMode);
76 76 chart->setChartBackgroundBrush(backgroundGradient);
77 77 }
78 78 //TODO helper to by removed later
79 79 void ChartTheme::decorate(ChartItem* item, QChartSeries* series,int count)
80 80 {
81 81 switch(series->type())
82 82 {
83 83 case QChartSeries::SeriesTypeLine: {
84 84 QLineChartSeries* s = static_cast<QLineChartSeries*>(series);
85 85 LineChartItem* i = static_cast<LineChartItem*>(item);
86 86 decorate(i,s,count);
87 87 break;
88 88 }
89 89 case QChartSeries::SeriesTypeBar: {
90 90 BarChartSeries* b = static_cast<BarChartSeries*>(series);
91 91 BarGroup* i = static_cast<BarGroup*>(item);
92 92 decorate(i,b,count);
93 93 break;
94 94 }
95 95 case QChartSeries::SeriesTypeStackedBar: {
96 96 StackedBarChartSeries* s = static_cast<StackedBarChartSeries*>(series);
97 97 StackedBarGroup* i = static_cast<StackedBarGroup*>(item);
98 98 decorate(i,s,count);
99 99 break;
100 100 }
101 101 case QChartSeries::SeriesTypePercentBar: {
102 102 PercentBarChartSeries* s = static_cast<PercentBarChartSeries*>(series);
103 103 PercentBarGroup* i = static_cast<PercentBarGroup*>(item);
104 104 decorate(i,s,count);
105 105 break;
106 106 }
107 107 case QChartSeries::SeriesTypePie: {
108 108 QPieSeries* s = static_cast<QPieSeries*>(series);
109 109 PiePresenter* i = static_cast<PiePresenter*>(item);
110 110 decorate(i,s,count);
111 111 break;
112 112 }
113 113 default:
114 114 qDebug()<<"Wrong item to be decorated by theme";
115 115 break;
116 116 }
117 117
118 118 }
119 119
120 120 void ChartTheme::decorate(LineChartItem* item, QLineChartSeries* series,int count)
121 121 {
122 122 QPen pen;
123 123 if(pen != series->pen()){
124 124 item->setPen(series->pen());
125 125 return;
126 126 }
127 127 pen.setColor(m_seriesColor.at(count%m_seriesColor.size()));
128 128 pen.setWidthF(2);
129 129 item->setPen(pen);
130 130 }
131 131
132 132 void ChartTheme::decorate(BarGroup* item, BarChartSeries* series,int count)
133 133 {
134 134 // TODO: better way to descide series color and remove hard coded colors.
135 135 item->resetBrushes();
136 136 for (int i=0; i<m_seriesColor.count(); i++) {
137 137 QBrush brush(m_seriesColor.at(i));
138 138 item->addBrush(brush);
139 139 }
140 140 item->addBrush(QBrush(QColor(255,0,0,128)));
141 141 item->addBrush(QBrush(QColor(255,255,0,128)));
142 142 item->addBrush(QBrush(QColor(0,255,0,128)));
143 143 item->addBrush(QBrush(QColor(0,0,255,128)));
144 144 item->addBrush(QBrush(QColor(255,128,0,128)));
145 145 }
146 146
147 147 void ChartTheme::decorate(StackedBarGroup* item, StackedBarChartSeries* series,int count)
148 148 {
149 149 // TODO: better way to descide series color and remove hard coded colors.
150 150 item->resetBrushes();
151 151 for (int i=0; i<m_seriesColor.count(); i++) {
152 152 QBrush brush(m_seriesColor.at(i));
153 153 item->addBrush(brush);
154 154 }
155 155 item->addBrush(QBrush(QColor(255,0,0,128)));
156 156 item->addBrush(QBrush(QColor(255,255,0,128)));
157 157 item->addBrush(QBrush(QColor(0,255,0,128)));
158 158 item->addBrush(QBrush(QColor(0,0,255,128)));
159 159 item->addBrush(QBrush(QColor(255,128,0,128)));
160 160 }
161 161
162 162 void ChartTheme::decorate(PercentBarGroup* item, PercentBarChartSeries* series,int count)
163 163 {
164 164 // TODO: better way to descide series color and remove hard coded colors.
165 165 item->resetBrushes();
166 166 for (int i=0; i<m_seriesColor.count(); i++) {
167 167 QBrush brush(m_seriesColor.at(i));
168 168 item->addBrush(brush);
169 169 }
170 170 item->addBrush(QBrush(QColor(255,0,0,128)));
171 171 item->addBrush(QBrush(QColor(255,255,0,128)));
172 172 item->addBrush(QBrush(QColor(0,255,0,128)));
173 173 item->addBrush(QBrush(QColor(0,0,255,128)));
174 174 item->addBrush(QBrush(QColor(255,128,0,128)));
175 175 }
176 176
177 177 void ChartTheme::decorate(ScatterPresenter* presenter, QScatterSeries* series, int count)
178 178 {
179 179 Q_ASSERT(presenter);
180 180 Q_ASSERT(series);
181 181
182 182 presenter->m_markerPen.setColor(m_seriesColor.at(count % m_seriesColor.size()));
183 183
184 184 // QPen pen;
185 185 // if(pen != series->pen()){
186 186 // item->setPen(series->pen());
187 187 // return;
188 188 // }
189 189 // pen.setColor(m_seriesColor.at(count%m_seriesColor.size()));
190 190 // pen.setWidthF(2);
191 191 // item->setPen(pen);
192 192 }
193 193
194 194 void ChartTheme::decorate(PiePresenter* item, QPieSeries* series, int /*count*/)
195 195 {
196 196 // create a list of slice colors based on current theme
197 197 int i = 0;
198 198 QList<QColor> colors;
199 199 while (colors.count() < series->count()) {
200 200
201 201 // get base color
202 202 QColor c = m_seriesColor[i++];
203 203 i = i % m_seriesColor.count();
204 204
205 205 // -1 means achromatic color -> cannot manipulate lightness
206 206 // TODO: find a better way to randomize lightness
207 207 if (c.toHsv().hue() == -1)
208 208 qWarning() << "ChartTheme::decorate() warning: achromatic theme color";
209 209
210 210 // randomize lightness
211 211 qreal f = 50 + (qrand() % 100); // 50 is 50% darker, 100 is the same, 150 is 50% lighter
212 212 c = c.lighter(f);
213 213
214 214 // find duplicates
215 215 bool isUnique = true;
216 216 foreach (QColor color, colors) {
217 217 if (c == color)
218 218 isUnique = false;
219 219 }
220 220
221 221 // add to array if unique
222 222 //if (isUnique)
223 223 colors << c;
224 224 }
225 225
226 226 // finally update colors
227 227 foreach (QPieSliceId id, series->ids()) {
228 228 QPieSlice s = series->slice(id);
229 229 s.setPen(QPen(Qt::black)); // TODO: get from theme
230 230 s.setBrush(colors.takeFirst());
231 231 series->update(s);
232 232 }
233 233 }
234 234
235 235
236 236 void ChartTheme::decorate(QChartAxis& axis,AxisItem* item)
237 237 {
238 238 //TODO: dummy defults for now
239 239
240 240 axis.setLabelsBrush(Qt::black);
241 241 axis.setLabelsPen(Qt::NoPen);
242 242 axis.setShadesPen(Qt::NoPen);
243 axis.setShadesOpacity(0.5);
243 244 item->handleAxisChanged(axis);
244 245 }
245 246
246 247 QTCOMMERCIALCHART_END_NAMESPACE
@@ -1,81 +1,86
1 1 #include "qchartaxis.h"
2 2
3 3 QTCOMMERCIALCHART_BEGIN_NAMESPACE
4 4
5 5 QChartAxis::QChartAxis():
6 6 m_axisVisible(true),
7 7 m_gridVisible(true),
8 8 m_labelsVisible(true),
9 m_shadesVisible(true)
9 m_shadesVisible(true),
10 m_shadesOpacity(1.0)
10 11 {
11 12 // TODO Auto-generated constructor stub
12 13
13 14 }
14 15
15 16 QChartAxis::~QChartAxis()
16 17 {
17 18 // TODO Auto-generated destructor stub
18 19 }
19 20
20 21 void QChartAxis::setAxisPen(const QPen& pen)
21 22 {
22 23 m_axisPen=pen;
23 24 }
24 25
25 26 void QChartAxis::setAxisVisible(bool visible)
26 27 {
27 28 m_axisVisible=visible;
28 29 }
29 30
30 31 void QChartAxis::setGridVisible(bool visible)
31 32 {
32 33 m_gridVisible=visible;
33 34 }
34 35
35 36 void QChartAxis::setGridPen(const QPen& pen)
36 37 {
37 38 m_gridPen=pen;
38 39 }
39 40
40 41 void QChartAxis::setLabelsVisible(bool visible)
41 42 {
42 43 m_labelsVisible=visible;
43 44 }
44 45
45 46 void QChartAxis::setLabelsPen(const QPen& pen)
46 47 {
47 48 m_labelsPen=pen;
48 49 }
49 50
50 51 void QChartAxis::setLabelsBrush(const QBrush& brush)
51 52 {
52 53 m_labelsBrush=brush;
53 54 }
54 55
55 56 void QChartAxis::setLabelsFont(const QFont& font)
56 57 {
57 58 m_labelsFont=font;
58 59 }
59 60
60 61 void QChartAxis::setLabelsOrientation(LabelsOrientation orientation)
61 62 {
62 63 m_labelsOrientation=orientation;
63 64 }
64 65
65 66 void QChartAxis::setShadesVisible(bool visible)
66 67 {
67 68 m_shadesVisible=visible;
68 69 }
69 70
70 71 void QChartAxis::setShadesPen(const QPen& pen)
71 72 {
72 73 m_shadesPen=pen;
73 74 }
74 75
75 76 void QChartAxis::setShadesBrush(const QBrush& brush)
76 77 {
77 78 m_shadesBrush=brush;
78 79 }
79 80
81 void QChartAxis::setShadesOpacity(qreal opacity)
82 {
83 m_shadesOpacity=opacity;
84 }
80 85
81 86 QTCOMMERCIALCHART_END_NAMESPACE
@@ -1,76 +1,82
1 1 #ifndef QCHARTAXIS_H_
2 2 #define QCHARTAXIS_H_
3 3
4 4 #include <qchartglobal.h>
5 5 #include <QPen>
6 6 #include <QFont>
7 7
8 8
9 9 QTCOMMERCIALCHART_BEGIN_NAMESPACE
10 10
11 11 class QTCOMMERCIALCHART_EXPORT QChartAxis
12 12 {
13 13 public:
14 14 enum LabelsOrientation{ LabelsOrientationHorizontal, LabelsOrientationVertical , LabelsOrientationSlide };
15 15
16 16 QChartAxis();
17 17 virtual ~QChartAxis();
18 18
19 19 //axis
20 20 bool isAxisVisible() const { return m_axisVisible;};
21 21 void setAxisVisible(bool visible);
22 22 void setAxisPen(const QPen& pen);
23 23 QPen axisPen() const { return m_axisPen;};
24 24 void setAxisBrush(const QBrush& brush);
25 25 QBrush axisBrush() const { return m_axisBrush;};
26 26
27 27 //grid
28 28 bool isGridVisible() const { return m_gridVisible;};
29 29 void setGridVisible(bool visible);
30 30 void setGridPen(const QPen& pen);
31 31 QPen gridPen() const {return m_gridPen;}
32 32
33 33 //labels
34 34 bool isLabelsVisible() const { return m_labelsVisible;};
35 35 void setLabelsVisible(bool visible);
36 36 void setLabelsPen(const QPen& pen);
37 37 QPen labelsPen() const { return m_labelsPen;}
38 38 void setLabelsBrush(const QBrush& brush);
39 39 QBrush labelsBrush() const { return m_labelsBrush;}
40 40 void setLabelsFont(const QFont& font);
41 41 QFont labelFont() const { return m_labelsFont;}
42 42 void setLabelsOrientation(LabelsOrientation orientation);
43 43 LabelsOrientation labelsOrientation() const { return m_labelsOrientation;};
44 44
45 45 //shades
46 46 bool isShadesVisible() const { return m_shadesVisible;};
47 47 void setShadesVisible(bool visible);
48 48 void setShadesPen(const QPen& pen);
49 49 QPen shadesPen() const { return m_shadesPen;}
50 50 void setShadesBrush(const QBrush& brush);
51 51 QBrush shadesBrush() const { return m_shadesBrush;}
52 void setShadesOpacity(qreal opacity);
53 qreal shadesOpacity() const { return m_shadesOpacity;}
54
52 55
53 56
54 57 private:
55 58
56 59 bool m_axisVisible;
57 60 QPen m_axisPen;
58 61 QBrush m_axisBrush;
59 62
60 63 bool m_gridVisible;
61 64 QPen m_gridPen;
62 65
63 66 bool m_labelsVisible;
64 67 QPen m_labelsPen;
65 68 QBrush m_labelsBrush;
66 69 QFont m_labelsFont;
67 70
68 71 bool m_shadesVisible;
69 72 QPen m_shadesPen;
70 73 QBrush m_shadesBrush;
71 74
75 qreal m_shadesOpacity;
76
77
72 78 LabelsOrientation m_labelsOrientation;
73 79 };
74 80
75 81 QTCOMMERCIALCHART_END_NAMESPACE
76 82 #endif /* QCHARTAXIS_H_ */
General Comments 0
You need to be logged in to leave comments. Login now