From 711ece5e3a718c47646650e163d45ed1418664c0 Mon Sep 17 00:00:00 2001 From: Olavi Pulkkinen Date: Wed, 31 Mar 2010 12:11:55 +0300 Subject: [PATCH] Corrected route drawing dialog to use mxl-file reading route points. --- Client/mainwindow.cpp | 2 ++ Client/mainwindow.h | 2 ++ Client/routedialog.cpp | 55 +++++++++++++++++++++++++++++++++++++++++++++--- 3 files changed, 56 insertions(+), 3 deletions(-) diff --git a/Client/mainwindow.cpp b/Client/mainwindow.cpp index d4df9c8..78e71c9 100644 --- a/Client/mainwindow.cpp +++ b/Client/mainwindow.cpp @@ -24,6 +24,7 @@ MainWindow::MainWindow(QWidget *parent) : QCoreApplication::setOrganizationDomain("fudeco.com"); QCoreApplication::setApplicationName("Speed Freak"); + routeDialog = new RouteDialog; creditsDialog = new CreditsDialog; routeSaveDialog = new RouteSaveDialog; settingsDialog = new SettingsDialog; @@ -47,6 +48,7 @@ MainWindow::~MainWindow() delete ui; delete routeSaveDialog; + delete routeDialog; if(!accstart) delete accstart; diff --git a/Client/mainwindow.h b/Client/mainwindow.h index f05a62c..16272c0 100644 --- a/Client/mainwindow.h +++ b/Client/mainwindow.h @@ -21,6 +21,7 @@ #include "accelerationstart.h" #include "topresultdialog.h" #include "httpclient.h" +#include "routedialog.h" namespace Ui { class MainWindow; @@ -39,6 +40,7 @@ public: accelerationstart* accstart; TopResultDialog *topResultDialog; HttpClient *httpClient; + RouteDialog *routeDialog; protected: void changeEvent(QEvent *e); diff --git a/Client/routedialog.cpp b/Client/routedialog.cpp index 5a680aa..0735753 100644 --- a/Client/routedialog.cpp +++ b/Client/routedialog.cpp @@ -367,10 +367,11 @@ bool RouteDialog::readRouteFromFile( QString &routeFile) QString rivi; QFile file; - QString fileName = QFileDialog::getOpenFileName(this, - tr("Read Route"), "./", tr("Route Files (*.txt)")); + //QString fileName = QFileDialog::getOpenFileName(this, + // tr("Read Route"), "./", tr("Route Files (*.txt)")); - file.setFileName( fileName); + //file.setFileName( fileName); + file.setFileName( "routetemp.xml"); if (!file.open(QIODevice::ReadOnly)) { QMessageBox::about(0, "Error", "File not found"); @@ -378,11 +379,58 @@ bool RouteDialog::readRouteFromFile( QString &routeFile) } vertexList.clear(); + while(!file.atEnd()) { + int count; + bool allRead; + QString astr1, astr2, astr3, astr4; QString str1, str2, str3, str4; rivi = file.readLine(); + allRead = false; + count = 0; + while( !allRead) + { + astr1 = rivi.section(" ", count*4+1, count*4+1); // latitude="" + astr2 = rivi.section(" ", count*4+2, count*4+2); // longitude="" + astr3 = rivi.section(" ", count*4+3, count*4+3); // altitude="" + astr4 = rivi.section(" ", count*4+4, count*4+4); // speed="" + + { + double x, y, z, v; + str1 = astr1.section('"',1,1); + str2 = astr2.section('"',1,1); + str3 = astr3.section('"',1,1); + str4 = astr4.section('"',1,1); + //QString str = QString("%1 %2 %3 %4").arg(str1).arg(str2).arg(str3).arg(str4); + //QMessageBox::about(0, "LUKEE", str); + /* */ + + if (str1.length() > 0) + { + x = str2.toDouble();// latitude y-value + y = str1.toDouble();// longitude x-value + z = str3.toDouble();// altitude z-value + v = str4.toDouble();// speed m/s + // QString str = QString("%1 %2 %3 %4").arg(x).arg(y).arg(z).arg(v); + // QMessageBox::about(0, "LUKEE", str); + temp.setX( x); // Longitude + temp.setY( y); // Latitude + temp.setZ( z); // altitude + temp.setV( v); + + vertexList.append(temp); + count++; + } + else + { + allRead = true; + } + } + } + // Older version + /* str1 = rivi.section(" ", 0, 0); if (str1.compare("Start:") != 0 && str1.compare("Stop:") != 0) { @@ -408,6 +456,7 @@ bool RouteDialog::readRouteFromFile( QString &routeFile) vertexList.append(temp); } } + */ } file.close(); -- 1.7.9.5