started working on plot
authorHeiko Schlittermann (JUMPER) <hs@schlittermann.de>
Fri, 27 Jan 2012 00:18:40 +0100
changeset 20 2e1610865683
parent 19 1115791a4c35
child 21 f63eb1a58abd
started working on plot
igc.pro
mainwindow.cc
mainwindow.h
plot.cc
plot.h
ui/mainwindow.ui
--- 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
--- 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();
+}
--- 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_;
--- /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;
+}
--- /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
--- 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 @@
     <item row="0" column="0">
      <widget class="QTabWidget" name="tabWidget">
       <property name="currentIndex">
-       <number>0</number>
+       <number>1</number>
       </property>
       <widget class="QWidget" name="info">
        <attribute name="title">
@@ -80,13 +80,13 @@
         </item>
        </layout>
       </widget>
-      <widget class="QWidget" name="altitude">
+      <widget class="QWidget" name="widget">
        <attribute name="title">
         <string>Altitude</string>
        </attribute>
        <layout class="QGridLayout" name="gridLayout_3">
         <item row="0" column="0">
-         <widget class="QGraphicsView" name="graphicsView"/>
+         <widget class="QGraphicsView" name="altitude"/>
         </item>
        </layout>
       </widget>