diff --git a/src/AnalysisSidebar.cpp b/src/AnalysisSidebar.cpp index 0658c3562..ffc0a1960 100644 --- a/src/AnalysisSidebar.cpp +++ b/src/AnalysisSidebar.cpp @@ -301,17 +301,18 @@ AnalysisSidebar::intervalPopup() QAction *actZoomInt = new QAction(tr("Zoom to interval"), context->athlete->intervalWidget); QAction *actEditInt = new QAction(tr("Edit interval"), context->athlete->intervalWidget); QAction *actDeleteInt = new QAction(tr("Delete interval"), context->athlete->intervalWidget); - //QAction *actCreateRouteInt = new QAction(tr("Create route for interval"), context->athlete->intervalWidget); + QAction *actCreateRouteInt = new QAction(tr("Create route for interval"), context->athlete->intervalWidget); connect(actZoomInt, SIGNAL(triggered(void)), this, SLOT(zoomIntervalSelected(void))); connect(actEditInt, SIGNAL(triggered(void)), this, SLOT(editIntervalSelected(void))); connect(actDeleteInt, SIGNAL(triggered(void)), this, SLOT(deleteIntervalSelected(void))); - //connect(actCreateRouteInt, SIGNAL(triggered(void)), this, SLOT(createRouteIntervalSelected(void))); + connect(actCreateRouteInt, SIGNAL(triggered(void)), this, SLOT(createRouteIntervalSelected(void))); menu.addAction(actZoomInt); menu.addAction(actEditInt); menu.addAction(actDeleteInt); - //menu.addAction(actCreateRouteInt); + menu.addSeparator(); + menu.addAction(actCreateRouteInt); } if (context->athlete->intervalWidget->selectedItems().count() > 1) { @@ -342,17 +343,24 @@ AnalysisSidebar::showIntervalMenu(const QPoint &pos) QAction *actZoomInt = new QAction(tr("Zoom to interval"), context->athlete->intervalWidget); QAction *actFrontInt = new QAction(tr("Bring to Front"), context->athlete->intervalWidget); QAction *actBackInt = new QAction(tr("Send to back"), context->athlete->intervalWidget); + QAction *actCreateRouteInt = new QAction(tr("Create route for interval"), context->athlete->intervalWidget); + connect(actEditInt, SIGNAL(triggered(void)), this, SLOT(editInterval(void))); connect(actDeleteInt, SIGNAL(triggered(void)), this, SLOT(deleteInterval(void))); connect(actZoomOut, SIGNAL(triggered(void)), this, SLOT(zoomOut(void))); connect(actZoomInt, SIGNAL(triggered(void)), this, SLOT(zoomInterval(void))); connect(actFrontInt, SIGNAL(triggered(void)), this, SLOT(frontInterval(void))); connect(actBackInt, SIGNAL(triggered(void)), this, SLOT(backInterval(void))); + connect(actCreateRouteInt, SIGNAL(triggered(void)), this, SLOT(createRouteIntervalSelected(void))); + menu.addAction(actZoomOut); menu.addAction(actZoomInt); menu.addAction(actEditInt); menu.addAction(actDeleteInt); + menu.addSeparator(); + menu.addAction(actCreateRouteInt); + menu.exec(context->athlete->intervalWidget->mapToGlobal(pos)); } } diff --git a/src/Route.cpp b/src/Route.cpp index 82b43b453..607becf35 100644 --- a/src/Route.cpp +++ b/src/Route.cpp @@ -24,12 +24,14 @@ #include "IntervalItem.h" #include "RouteParser.h" #include "RideFile.h" +#include "GProgressDialog.h" #include #include #include #include + #define tr(s) QObject::tr(s) #define pi 3.14159265358979323846 @@ -277,15 +279,10 @@ RouteSegment::searchRouteInAllRides(Context* context) // showing a progress bar as we go QTime elapsed; elapsed.start(); - QString title = tr("Searching route...\nStarted"); - //QProgressBar bar(title, tr("Abort"), 0, filenames.count(), context, NULL); - QProgressBar bar(context->mainWindow); - //bar.setWindowModality(Qt::WindowModal); - //bar.setMinimumDuration(0); - //bar.show(); + QString title = tr("Searching route"); + GProgressDialog *bar = NULL; int processed=0; - QApplication::processEvents(); // get that dialog up! while (iterator.hasNext()) { QString name = iterator.next(); @@ -299,11 +296,24 @@ RouteSegment::searchRouteInAllRides(Context* context) QString elapsedString = QString("%1:%2:%3").arg(elapsedtime/3600000,2) .arg((elapsedtime%3600000)/60000,2,10,QLatin1Char('0')) .arg((elapsedtime%60000)/1000,2,10,QLatin1Char('0')); - QString title = tr("Searching route...\nElapsed: %1\n%2").arg(elapsedString).arg(name); - bar.setStatusTip(title); - bar.setValue(++processed); + + // create the dialog if we need to show progress for long running uodate + if ((elapsedtime > 2000) && bar == NULL) { + bar = new GProgressDialog(title, 0, filenames.count(), context->mainWindow->init, context->mainWindow); + bar->show(); // lets hide until elapsed time is > 2 seconds + + // lets make sure it goes to the center! + QApplication::processEvents(); + } + + if (bar) { + QString title = tr("Searching route in all rides...\nElapsed: %1\n%2").arg(elapsedString).arg(name); + bar->setLabelText(title); + bar->setValue(++processed); + } QApplication::processEvents(); + ride = RideFileFactory::instance().openRideFile(context, file, errors); if (ride->isDataPresent(RideFile::lat)) { out << " with GPS datas " << "\r\n"; @@ -312,14 +322,20 @@ RouteSegment::searchRouteInAllRides(Context* context) else out << " no GPS datas " << "\r\n"; - /*if (bar.wasCanceled()) { + if (bar && bar->wasCanceled()) { out << "SEARCH NEW ROUTE CANCELED: " << QDateTime::currentDateTime().toString() + "\r\n"; break; - }*/ + } } + // now zap the progress bar + if (bar) delete bar; + // stop logging out << "SEARCH NEW ROUTE ENDS: " << QDateTime::currentDateTime().toString() + "\r\n"; + + QMessageBox::information(context->mainWindow, tr("Route"), tr("This route '%1' was found %2 times in %3 rides.").arg(this->getName()).arg(this->getRides().count()).arg(processed)); + log.close(); } @@ -472,21 +488,28 @@ Routes::searchRoutesInRide(RideFile* ride) void Routes::createRouteFromInterval(IntervalItem *activeInterval) { - qDebug() << "createRouteFromInterval"; - // create a new route for this interval - - + // create a new route int index = context->athlete->routes->newRoute("route"); RouteSegment *route = &context->athlete->routes->routes[index]; - double dist = 0, lastLat = 0, lastLon = 0, i = 0; + QString name = activeInterval->text(0).trimmed(); + if (name.contains("(")) + name = name.left(name.indexOf("(")).trimmed(); + + if (name.length()<4 || name.startsWith("Selection #") ) + name = QString(tr("Route #%1")).arg(context->athlete->routes->routes.length()); + + route->setName(name); + + // Construct the route with interval gps data + double dist = 0, lastLat = 0, lastLon = 0; foreach (RideFilePoint *point, activeInterval->ride->dataPoints()) { - if (point->secs >= activeInterval->start && point->secs < activeInterval->stop) { if (lastLat != 0 && lastLon != 0 && point->lat != 0 && point->lon != 0 && ceil(point->lat) != 180 && ceil(point->lon) != 180) { + // distance ith last point double _dist = route->distance(lastLat, lastLon, point->lat, point->lon); if (_dist>=0.001) @@ -500,11 +523,12 @@ Routes::createRouteFromInterval(IntervalItem *activeInterval) { } lastLat = point->lat; lastLon = point->lon; - i++; } } + // Search this route in all rides route->searchRouteInAllRides(context); + // Save routes writeRoutes(); } diff --git a/src/RouteItem.cpp b/src/RouteItem.cpp index 6d84d7b90..d52a633c6 100644 --- a/src/RouteItem.cpp +++ b/src/RouteItem.cpp @@ -1,5 +1,6 @@ /* - * Copyright (c) 2006 Sean C. Rhea (srhea@srhea.net) + * Copyright (c) 2011, 2014 Damien Grauser (Damien.Grauser@pev-geneve.ch) + * * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free diff --git a/src/RouteItem.h b/src/RouteItem.h index 97438d68f..9b714184f 100644 --- a/src/RouteItem.h +++ b/src/RouteItem.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006 Sean C. Rhea (srhea@srhea.net) + * Copyright (c) 2011, 2014 Damien Grauser (Damien.Grauser@pev-geneve.ch) * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free diff --git a/src/RouteParser.cpp b/src/RouteParser.cpp index bc297e515..496d6ee91 100644 --- a/src/RouteParser.cpp +++ b/src/RouteParser.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011 Damien Grauser (Damien.Grauser@pev-geneve.ch) + * Copyright (c) 2011, 2014 Damien Grauser (Damien.Grauser@pev-geneve.ch) * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free diff --git a/src/RouteParser.h b/src/RouteParser.h index aaf0b5ab3..c03c5d6ca 100644 --- a/src/RouteParser.h +++ b/src/RouteParser.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011 Damien Grauser (Damien.Grauser@pev-geneve.ch) + * Copyright (c) 2011, 2014 Damien Grauser (Damien.Grauser@pev-geneve.ch) * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free diff --git a/src/RouteWindow.cpp b/src/RouteWindow.cpp index f1142d1d8..08181b14b 100644 --- a/src/RouteWindow.cpp +++ b/src/RouteWindow.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011 Damien Grauser (Damien.Grauser@pev-geneve.ch) + * Copyright (c) 2011, 2014 Damien Grauser (Damien.Grauser@pev-geneve.ch) * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free diff --git a/src/RouteWindow.h b/src/RouteWindow.h index 678e2ab9f..d5a18d8cc 100644 --- a/src/RouteWindow.h +++ b/src/RouteWindow.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011 Damien Grauser (Damien.Grauser@pev-geneve.ch) + * Copyright (c) 2011, 2014 Damien Grauser (Damien.Grauser@pev-geneve.ch) * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free