plot.cc
changeset 20 2e1610865683
child 23 8396f7857013
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plot.cc	Fri Jan 27 00:18:40 2012 +0100
@@ -0,0 +1,30 @@
+#include "plot.h"
+
+const QPointF Plot::zero(0, 0);
+
+
+Plot::Plot(QObject *parent)
+    : QGraphicsScene(parent)
+{
+}
+
+void Plot::setXAxis(qreal min, qreal max, qreal step)
+{
+    addLine(QLineF(zero, QPointF(max - min, 0)));
+    if (!step) return;
+
+    QLineF tick(QPointF(0, 0), QPointF(0, 4));
+    addLine(tick);
+
+    for (qreal i = 0; i < max - min; i+= step) {
+	tick.translate(step, 0);
+	addLine(tick);
+    }
+
+}
+
+void Plot::setYAxis(qreal min, qreal max, qreal step)
+{
+    addLine(QLineF(zero, QPointF(0, -1 * (max - min))));
+    if (!step) return;
+}