1 #include "mainwindow.h" |
1 #include "mainwindow.h" |
|
2 #include <qwt_plot_curve.h> |
|
3 |
2 #include "ui_mainwindow.h" |
4 #include "ui_mainwindow.h" |
3 #include "plot.h" |
5 #include "plot.h" |
|
6 |
4 |
7 |
5 using Qt::DefaultLocaleLongDate; |
8 using Qt::DefaultLocaleLongDate; |
6 |
9 |
7 MainWindow::MainWindow(QWidget *parent) |
10 MainWindow::MainWindow(QWidget *parent) |
8 : QMainWindow(parent), ui(new Ui::MainWindow) |
11 : QMainWindow(parent), ui_(new Ui::MainWindow), |
|
12 plot_(new QwtPlot(tr("Altitude"), this)) |
9 { |
13 { |
10 ui->setupUi(this); |
14 ui_->setupUi(this); |
11 connect(ui->actionAboutQt, SIGNAL(triggered()), qApp, SLOT(aboutQt())); |
15 ui_->tabs->setCurrentIndex(0); // avoid changes done in the designer! |
12 connect(ui->actionExit, SIGNAL(triggered()), qApp, SLOT(quit())); |
|
13 connect(ui->actionOpen, SIGNAL(triggered()), this, SLOT(open())); |
|
14 |
16 |
|
17 // prepare the Qwt tab |
|
18 plot_->setAxisTitle(plot_->yLeft, tr("Altitude")); |
|
19 plot_->setAxisTitle(plot_->xBottom, tr("Time")); |
|
20 |
|
21 ui_->qwt->setLayout(new QGridLayout); |
|
22 ui_->qwt->layout()->addWidget(plot_); |
|
23 |
|
24 #ifndef MYPLOT |
|
25 ui_->tabs->removeTab(1); // altitude |
|
26 #endif |
|
27 |
|
28 connect(ui_->actionAboutQt, SIGNAL(triggered()), qApp, SLOT(aboutQt())); |
|
29 connect(ui_->actionExit, SIGNAL(triggered()), qApp, SLOT(quit())); |
|
30 connect(ui_->actionOpen, SIGNAL(triggered()), this, SLOT(open())); |
15 |
31 |
16 |
32 |
17 /* |
33 /* |
18 QNetworkProxy::setApplicationProxy(QNetworkProxy(QNetworkProxy::HttpProxy, "localhost", 3128)); |
34 QNetworkProxy::setApplicationProxy(QNetworkProxy(QNetworkProxy::HttpProxy, "localhost", 3128)); |
19 ui->view->load(QUrl("http://maps.google.com/")); |
35 ui_->view->load(QUrl("http://maps.google.com/")); |
20 */ |
36 */ |
21 |
37 |
22 |
38 |
23 } |
39 } |
24 |
40 |
25 MainWindow::~MainWindow() |
41 MainWindow::~MainWindow() |
26 { |
42 { |
27 delete ui; |
43 delete ui_; |
28 } |
44 } |
29 |
45 |
30 void MainWindow::open(const QString &s) |
46 void MainWindow::open(const QString &s) |
31 { |
47 { |
32 QString fileName; |
48 QString fileName; |
90 t->setRowCount(t->rowCount() + 1); |
106 t->setRowCount(t->rowCount() + 1); |
91 t->setItem(r, K, new QTableWidgetItem(tr("Place"))); |
107 t->setItem(r, K, new QTableWidgetItem(tr("Place"))); |
92 t->setItem(r, V, new QTableWidgetItem(igc_.start().longitude() + " / " + igc_.start().latitude())); |
108 t->setItem(r, V, new QTableWidgetItem(igc_.start().longitude() + " / " + igc_.start().latitude())); |
93 ++r; |
109 ++r; |
94 |
110 |
95 |
|
96 showProfile(); |
111 showProfile(); |
97 |
112 |
98 } |
113 } |
99 |
114 |
100 void MainWindow::showProfile() |
115 void MainWindow::showProfile() |
101 { |
116 { |
102 Plot *plot = new Plot(this); |
117 const Fixes f = igc_.fixes(); |
|
118 #ifdef MYPLOT |
|
119 QList< QPair<QTime, int> > altitudesBaro; |
|
120 QList< QPair<QTime, int> > altitudesGPS; |
|
121 #endif |
|
122 QVector<QPointF> pointsGPS; |
|
123 QVector<QPointF> pointsBaro; |
103 |
124 |
104 /* |
|
105 for (IGC::Iterator i = igc_.begin() |
|
106 i != igc_.end(); |
|
107 ++i) { |
|
108 qDebug() << *i; |
|
109 } |
|
110 */ |
|
111 |
125 |
112 // get all the altitudes |
126 for (Fixes::const_iterator i = f.begin(); |
113 const Fixes f = igc_.fixes(); |
127 i != f.end(); |
114 QList< QPair<QTime, int> > altitudesBaro; |
128 i++) { |
115 QList< QPair<QTime, int> > altitudesGPS; |
129 #ifdef MYPLOT |
|
130 altitudesBaro << i->altitudeFix(Fix::baro); |
|
131 altitudesGPS << i->altitudeFix(Fix::gps); |
|
132 #endif |
|
133 pointsGPS << QPointF(QTime().secsTo(i->time()), i->altitude(Fix::gps)); |
|
134 pointsBaro << QPointF(QTime().secsTo(i->time()), i->altitude(Fix::baro)); |
|
135 } |
116 |
136 |
117 for (Fixes::const_iterator i = f.begin(); |
137 #ifdef MYPLOT |
118 i != f.end(); |
138 myPlot_.draw(altitudesBaro.begin(), altitudesBaro.end()); |
119 i++) { |
139 myPlot_.draw(altitudesGPS.begin(), altitudesGPS.end()); |
120 altitudesBaro << i->altitudeFix(Fix::baro); |
140 ui_->altitude->setScene(&myPlot_); |
121 altitudesGPS << i->altitudeFix(Fix::gps); |
141 #endif |
122 } |
|
123 |
142 |
124 /* |
143 QwtPlotCurve *gps = new QwtPlotCurve(tr("Altitude GPS")); |
125 plot->setXAxis(0, 100, 10); |
144 QwtPlotCurve *baro = new QwtPlotCurve(tr("Altitude barometric")); |
126 plot->setYAxis(0, 200, 10); |
145 QwtPointSeriesData *dataGPS = new QwtPointSeriesData(pointsGPS); |
127 */ |
146 QwtPointSeriesData *dataBaro = new QwtPointSeriesData(pointsBaro); |
128 plot->draw(altitudesBaro.begin(), altitudesBaro.end()); |
147 |
129 plot->draw(altitudesGPS.begin(), altitudesGPS.end()); |
148 gps->setData(dataGPS); |
130 ui->altitude->setScene(plot); |
149 baro->setData(dataBaro); |
|
150 gps->attach(plot_); |
|
151 baro->attach(plot_); |
131 |
152 |
132 // ui->altitude->show(); |
153 // ui_->altitude->show(); |
133 } |
154 } |