# HG changeset patch # User Heiko Schlittermann (JUMPER) # Date 1327793920 -3600 # Node ID dfefb600349899be08552dc19b0a435647205816 # Parent 4d79c3f357ad2177ef9379ed28fa005c357507b1 Qwt seems to work diff -r 4d79c3f357ad -r dfefb6003498 i18n/igc.de_DE.ts --- a/i18n/igc.de_DE.ts Sat Jan 28 13:03:19 2012 +0100 +++ b/i18n/igc.de_DE.ts Sun Jan 29 00:38:40 2012 +0100 @@ -39,6 +39,7 @@ + Altitude Höhenprofil @@ -73,49 +74,54 @@ Über Qt - + Open IGC file IGC Datei Öffnen - + IGC files (*.igc);; All files (*) IGC Dateien (*.igc);; Alle Dateien (*) - + Ooops! Ooops! - + The file %1 cannot be opened: %2! Die Datei %1 kann nicht geöffnet werden: %2! - + opening %1 Öffnen von %1 - + Pilot Pilot - + Date Datum - + Glider Schirmtyp - + Place Ort + + + Weiter…? + Weiter...? + diff -r 4d79c3f357ad -r dfefb6003498 igc.h --- a/igc.h Sat Jan 28 13:03:19 2012 +0100 +++ b/igc.h Sun Jan 29 00:38:40 2012 +0100 @@ -62,7 +62,7 @@ QString glider() const { return glider_; } //!< type of glider QDate date() const { return date_; } //!< date of the record (start date?) - Fixes fixes() const { return fixes_; } //!< list of fixes + const Fixes& fixes() const { return fixes_; } //!< list of fixes Fix start() const { return start_; } //!< the very first fix Fix landing() const { return landing_; } //!< the very last fix diff -r 4d79c3f357ad -r dfefb6003498 igc.pro --- a/igc.pro Sat Jan 28 13:03:19 2012 +0100 +++ b/igc.pro Sun Jan 29 00:38:40 2012 +0100 @@ -2,7 +2,8 @@ # Automatically generated by qmake (2.01a) Sat Jan 21 23:39:20 2012 ###################################################################### -CONFIG += release precompile_header +CONFIG += debug precompile_header \ + qwt QT += webkit network QMAKE_EXTRA_TARGETS += doxy doc diff -r 4d79c3f357ad -r dfefb6003498 igc.pro.user --- a/igc.pro.user Sat Jan 28 13:03:19 2012 +0100 +++ b/igc.pro.user Sun Jan 29 00:38:40 2012 +0100 @@ -1,6 +1,6 @@ - + ProjectExplorer.Project.ActiveTarget diff -r 4d79c3f357ad -r dfefb6003498 main.cc --- a/main.cc Sat Jan 28 13:03:19 2012 +0100 +++ b/main.cc Sun Jan 29 00:38:40 2012 +0100 @@ -4,6 +4,8 @@ int main(int argc, char** argv) { + QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8")); + QTextCodec::setCodecForTr(QTextCodec::codecForCStrings()); QApplication app(argc, argv); QTranslator translator; diff -r 4d79c3f357ad -r dfefb6003498 mainwindow.cc --- a/mainwindow.cc Sat Jan 28 13:03:19 2012 +0100 +++ b/mainwindow.cc Sun Jan 29 00:38:40 2012 +0100 @@ -1,22 +1,38 @@ #include "mainwindow.h" +#include + #include "ui_mainwindow.h" #include "plot.h" + using Qt::DefaultLocaleLongDate; MainWindow::MainWindow(QWidget *parent) - : QMainWindow(parent), ui(new Ui::MainWindow) + : QMainWindow(parent), ui_(new Ui::MainWindow), + plot_(new QwtPlot(tr("Altitude"), this)) { - ui->setupUi(this); - connect(ui->actionAboutQt, SIGNAL(triggered()), qApp, SLOT(aboutQt())); - connect(ui->actionExit, SIGNAL(triggered()), qApp, SLOT(quit())); - connect(ui->actionOpen, SIGNAL(triggered()), this, SLOT(open())); + ui_->setupUi(this); + ui_->tabs->setCurrentIndex(0); // avoid changes done in the designer! + + // prepare the Qwt tab + plot_->setAxisTitle(plot_->yLeft, tr("Altitude")); + plot_->setAxisTitle(plot_->xBottom, tr("Time")); + ui_->qwt->setLayout(new QGridLayout); + ui_->qwt->layout()->addWidget(plot_); + +#ifndef MYPLOT + ui_->tabs->removeTab(1); // altitude +#endif + + connect(ui_->actionAboutQt, SIGNAL(triggered()), qApp, SLOT(aboutQt())); + connect(ui_->actionExit, SIGNAL(triggered()), qApp, SLOT(quit())); + connect(ui_->actionOpen, SIGNAL(triggered()), this, SLOT(open())); /* QNetworkProxy::setApplicationProxy(QNetworkProxy(QNetworkProxy::HttpProxy, "localhost", 3128)); - ui->view->load(QUrl("http://maps.google.com/")); + ui_->view->load(QUrl("http://maps.google.com/")); */ @@ -24,7 +40,7 @@ MainWindow::~MainWindow() { - delete ui; + delete ui_; } void MainWindow::open(const QString &s) @@ -60,7 +76,7 @@ // now let's fill the table - QTableWidget *t = ui->table; + QTableWidget *t = ui_->table; int r = 0; const int K = 0; const int V = 1; @@ -92,42 +108,47 @@ t->setItem(r, V, new QTableWidgetItem(igc_.start().longitude() + " / " + igc_.start().latitude())); ++r; - showProfile(); } void MainWindow::showProfile() { - Plot *plot = new Plot(this); + const Fixes f = igc_.fixes(); +#ifdef MYPLOT + QList< QPair > altitudesBaro; + QList< QPair > altitudesGPS; +#endif + QVector pointsGPS; + QVector pointsBaro; - /* - for (IGC::Iterator i = igc_.begin() - i != igc_.end(); - ++i) { - qDebug() << *i; - } - */ - - // get all the altitudes - const Fixes f = igc_.fixes(); - QList< QPair > altitudesBaro; - QList< QPair > altitudesGPS; - for (Fixes::const_iterator i = f.begin(); - i != f.end(); - i++) { - altitudesBaro << i->altitudeFix(Fix::baro); - altitudesGPS << i->altitudeFix(Fix::gps); - } + for (Fixes::const_iterator i = f.begin(); + i != f.end(); + i++) { +#ifdef MYPLOT + altitudesBaro << i->altitudeFix(Fix::baro); + altitudesGPS << i->altitudeFix(Fix::gps); +#endif + pointsGPS << QPointF(QTime().secsTo(i->time()), i->altitude(Fix::gps)); + pointsBaro << QPointF(QTime().secsTo(i->time()), i->altitude(Fix::baro)); + } - /* - plot->setXAxis(0, 100, 10); - plot->setYAxis(0, 200, 10); - */ - plot->draw(altitudesBaro.begin(), altitudesBaro.end()); - plot->draw(altitudesGPS.begin(), altitudesGPS.end()); - ui->altitude->setScene(plot); +#ifdef MYPLOT + myPlot_.draw(altitudesBaro.begin(), altitudesBaro.end()); + myPlot_.draw(altitudesGPS.begin(), altitudesGPS.end()); + ui_->altitude->setScene(&myPlot_); +#endif - // ui->altitude->show(); + QwtPlotCurve *gps = new QwtPlotCurve(tr("Altitude GPS")); + QwtPlotCurve *baro = new QwtPlotCurve(tr("Altitude barometric")); + QwtPointSeriesData *dataGPS = new QwtPointSeriesData(pointsGPS); + QwtPointSeriesData *dataBaro = new QwtPointSeriesData(pointsBaro); + + gps->setData(dataGPS); + baro->setData(dataBaro); + gps->attach(plot_); + baro->attach(plot_); + + // ui_->altitude->show(); } diff -r 4d79c3f357ad -r dfefb6003498 mainwindow.h --- a/mainwindow.h Sat Jan 28 13:03:19 2012 +0100 +++ b/mainwindow.h Sun Jan 29 00:38:40 2012 +0100 @@ -2,6 +2,9 @@ #define _mainwindow_h_ #include "pch.h" +#include + +#include "plot.h" #include "igc.h" namespace Ui { class MainWindow; } @@ -17,11 +20,15 @@ private: void showProfile(); - Ui::MainWindow *ui; + Ui::MainWindow *ui_; QFile currentFile_; QTextStream input_; - IGC igc_; + IGC igc_; +#ifdef MYPLOT + Plot *myplot_; +#endif + QwtPlot *plot_; }; diff -r 4d79c3f357ad -r dfefb6003498 ui/mainwindow.ui --- a/ui/mainwindow.ui Sat Jan 28 13:03:19 2012 +0100 +++ b/ui/mainwindow.ui Sun Jan 29 00:38:40 2012 +0100 @@ -17,6 +17,9 @@ + + true + QTabWidget::North @@ -24,7 +27,7 @@ QTabWidget::Rounded - 0 + 1 @@ -86,22 +89,6 @@ - - - Web - - - - - - - about:blank - - - - - - Altitude @@ -112,6 +99,11 @@ + + + Altitude by QWT + + @@ -159,13 +151,6 @@ - - - QWebView - QWidget -
QtWebKit/QWebView
-
-