equal
deleted
inserted
replaced
|
1 #include "plot.h" |
|
2 |
|
3 const QPointF Plot::zero(0, 0); |
|
4 |
|
5 |
|
6 Plot::Plot(QObject *parent) |
|
7 : QGraphicsScene(parent) |
|
8 { |
|
9 } |
|
10 |
|
11 void Plot::setXAxis(qreal min, qreal max, qreal step) |
|
12 { |
|
13 addLine(QLineF(zero, QPointF(max - min, 0))); |
|
14 if (!step) return; |
|
15 |
|
16 QLineF tick(QPointF(0, 0), QPointF(0, 4)); |
|
17 addLine(tick); |
|
18 |
|
19 for (qreal i = 0; i < max - min; i+= step) { |
|
20 tick.translate(step, 0); |
|
21 addLine(tick); |
|
22 } |
|
23 |
|
24 } |
|
25 |
|
26 void Plot::setYAxis(qreal min, qreal max, qreal step) |
|
27 { |
|
28 addLine(QLineF(zero, QPointF(0, -1 * (max - min)))); |
|
29 if (!step) return; |
|
30 } |