# HG changeset patch # User Heiko Schlittermann (JUMPER) # Date 1327619920 -3600 # Node ID 2e161086568309bb0f80614a8793fd5a21c91be8 # Parent 1115791a4c3568ba9e310bd932365adcc98699e3 started working on plot diff -r 1115791a4c35 -r 2e1610865683 igc.pro --- a/igc.pro Thu Jan 26 16:26:12 2012 +0100 +++ b/igc.pro Fri Jan 27 00:18:40 2012 +0100 @@ -20,6 +20,6 @@ FORMS += ui/*.ui HEADERS += mainwindow.h \ - igc.h + igc.h plot.h SOURCES += main.cc mainwindow.cc \ - igc.cc + igc.cc plot.cc diff -r 1115791a4c35 -r 2e1610865683 mainwindow.cc --- a/mainwindow.cc Thu Jan 26 16:26:12 2012 +0100 +++ b/mainwindow.cc Fri Jan 27 00:18:40 2012 +0100 @@ -1,6 +1,6 @@ -#include "pch.h" #include "mainwindow.h" #include "ui_mainwindow.h" +#include "plot.h" using Qt::DefaultLocaleLongDate; @@ -80,11 +80,16 @@ t->setItem(r, V, new QTableWidgetItem(igc_.glider())); ++r; - -// ui->table->setItem(0, 1, new QTableWidgetItem(igc_.pilot())); - - qDebug() << igc_.device(); - qDebug() << igc_.pilot(); - qDebug() << igc_.date(); + showProfile(); } + +void MainWindow::showProfile() +{ + Plot *plot = new Plot(tr("Altitude"), this); + + plot->setXAxis(0, 100, 10); + plot->setYAxis(0, 200, 10); + ui->altitude->setScene(plot); + // ui->altitude->show(); +} diff -r 1115791a4c35 -r 2e1610865683 mainwindow.h --- a/mainwindow.h Thu Jan 26 16:26:12 2012 +0100 +++ b/mainwindow.h Fri Jan 27 00:18:40 2012 +0100 @@ -15,6 +15,7 @@ public slots: void open(const QString& = ""); private: + void showProfile(); Ui::MainWindow *ui; QFile currentFile_; diff -r 1115791a4c35 -r 2e1610865683 plot.cc --- /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; +} diff -r 1115791a4c35 -r 2e1610865683 plot.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/plot.h Fri Jan 27 00:18:40 2012 +0100 @@ -0,0 +1,20 @@ +#ifndef _plot_h +#define _plot_h + +#include "pch.h" + + +class Plot : public QGraphicsScene +{ + Q_OBJECT + public: + Plot(QObject *parent = 0); + void setXAxis(qreal max, qreal step = 0); + void setXAxis(qreal min, qreal max, qreal step = 0); + void setYAxis(qreal min, qreal max, qreal step = 0); + private: + static const QPointF zero; + +}; + +#endif diff -r 1115791a4c35 -r 2e1610865683 ui/mainwindow.ui --- a/ui/mainwindow.ui Thu Jan 26 16:26:12 2012 +0100 +++ b/ui/mainwindow.ui Fri Jan 27 00:18:40 2012 +0100 @@ -18,7 +18,7 @@ - 0 + 1 @@ -80,13 +80,13 @@ - + Altitude - +