Hi Ivo,

I tried to implement your suggestion but I am not sure if it is what you 
expect. There are two patches attached to this mail. Probably you can apply 
them to current tip of repository. If that fails abbly them to commit 
8ddec3217899c93b0471e993e261fa22505ac8b6.

Please test and give feedback.

Oliver

Am Freitag, 30. März 2018, 12:53:29 CEST schrieb Ivo Reano:
> > Technically it's possible. But it will be quite a change. Is it really
> > worth
> > it?
> > 
> > Oliver
> 
> Look, if there were this function many "detectors of the Piedmont trail
> network" would decide to use QMS!
> At the moment I am teaching to the surveyors that all (elderly) CAI
> volunteers use QMS for the cleaning and preparation of GPS tracks.
> Someone must also check that the various paths are continuous from the
> logical point of view (they must have a common point (same but repeated)
> I'm doing this in order to present a reusable regional database (even from
> OSM, maybe ).
> So, yes, work would be very useful and appreciated.
> 
> Ivo

# HG changeset patch
# User kiozen
# Date 1522942740 -7200
#      Thu Apr 05 17:39:00 2018 +0200
# Branch LineEdit
# Node ID 4aa3f266f22a1f0afd5a15b6ae7f42e143edd2e3
# Parent  8ddec3217899c93b0471e993e261fa22505ac8b6
LineEdit: Use tracks as routing aid

diff -r 8ddec3217899 -r 4aa3f266f22a src/icons/32x32/T.png
Binary file src/icons/32x32/T.png has changed
diff -r 8ddec3217899 -r 4aa3f266f22a src/icons/48x48/T.png
Binary file src/icons/48x48/T.png has changed
diff -r 8ddec3217899 -r 4aa3f266f22a src/icons/T.svg
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/icons/T.svg	Thu Apr 05 17:39:00 2018 +0200
@@ -0,0 +1,74 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+
+<svg
+   xmlns:dc="http://purl.org/dc/elements/1.1/";
+   xmlns:cc="http://creativecommons.org/ns#";
+   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#";
+   xmlns:svg="http://www.w3.org/2000/svg";
+   xmlns="http://www.w3.org/2000/svg";
+   xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd";
+   xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape";
+   width="64px"
+   height="64px"
+   id="svg3513"
+   version="1.1"
+   inkscape:version="0.91 r13725"
+   sodipodi:docname="T.svg">
+  <defs
+     id="defs3515" />
+  <sodipodi:namedview
+     id="base"
+     pagecolor="#ffffff"
+     bordercolor="#666666"
+     borderopacity="1.0"
+     inkscape:pageopacity="0.0"
+     inkscape:pageshadow="2"
+     inkscape:zoom="5.5"
+     inkscape:cx="-22.090909"
+     inkscape:cy="1.6363636"
+     inkscape:current-layer="layer1"
+     showgrid="true"
+     inkscape:document-units="px"
+     inkscape:grid-bbox="true"
+     inkscape:window-width="1920"
+     inkscape:window-height="1015"
+     inkscape:window-x="0"
+     inkscape:window-y="0"
+     inkscape:window-maximized="1" />
+  <metadata
+     id="metadata3518">
+    <rdf:RDF>
+      <cc:Work
+         rdf:about="">
+        <dc:format>image/svg+xml</dc:format>
+        <dc:type
+           rdf:resource="http://purl.org/dc/dcmitype/StillImage"; />
+        <dc:title></dc:title>
+      </cc:Work>
+    </rdf:RDF>
+  </metadata>
+  <g
+     id="layer1"
+     inkscape:label="Layer 1"
+     inkscape:groupmode="layer">
+    <text
+       xml:space="preserve"
+       style="font-style:normal;font-weight:bold;font-size:40px;line-height:125%;font-family:Sans;-inkscape-font-specification:'Sans Bold';letter-spacing:0px;word-spacing:0px;fill:#000080;fill-opacity:1;stroke:none"
+       x="15.175071"
+       y="43.852806"
+       id="text3002"
+       sodipodi:linespacing="125%"><tspan
+         sodipodi:role="line"
+         id="tspan3004"
+         x="15.175071"
+         y="43.852806">T</tspan></text>
+    <rect
+       style="fill:none;stroke:none"
+       id="rect2998"
+       width="40"
+       height="40"
+       x="10.653586"
+       y="9.272728" />
+  </g>
+</svg>
diff -r 8ddec3217899 -r 4aa3f266f22a src/icons/V.svg
--- a/src/icons/V.svg	Wed Apr 04 17:38:39 2018 +0200
+++ b/src/icons/V.svg	Thu Apr 05 17:39:00 2018 +0200
@@ -13,7 +13,7 @@
    height="64px"
    id="svg3513"
    version="1.1"
-   inkscape:version="0.48.5 r10040"
+   inkscape:version="0.91 r13725"
    sodipodi:docname="V.svg">
   <defs
      id="defs3515" />
@@ -25,16 +25,16 @@
      inkscape:pageopacity="0.0"
      inkscape:pageshadow="2"
      inkscape:zoom="5.5"
-     inkscape:cx="6.6363636"
-     inkscape:cy="32"
+     inkscape:cx="-22.090909"
+     inkscape:cy="1.6363636"
      inkscape:current-layer="layer1"
      showgrid="true"
      inkscape:document-units="px"
      inkscape:grid-bbox="true"
      inkscape:window-width="1920"
-     inkscape:window-height="1012"
-     inkscape:window-x="-2"
-     inkscape:window-y="-3"
+     inkscape:window-height="1015"
+     inkscape:window-x="0"
+     inkscape:window-y="0"
      inkscape:window-maximized="1" />
   <metadata
      id="metadata3518">
@@ -54,7 +54,7 @@
      inkscape:groupmode="layer">
     <text
        xml:space="preserve"
-       style="font-size:40px;font-style:normal;font-weight:bold;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#000080;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans Bold"
+       style="font-style:normal;font-weight:bold;font-size:40px;line-height:125%;font-family:Sans;-inkscape-font-specification:'Sans Bold';letter-spacing:0px;word-spacing:0px;fill:#000080;fill-opacity:1;stroke:none"
        x="15.175071"
        y="43.852806"
        id="text3002"
diff -r 8ddec3217899 -r 4aa3f266f22a src/qmapshack/GeoMath.cpp
--- a/src/qmapshack/GeoMath.cpp	Wed Apr 04 17:38:39 2018 +0200
+++ b/src/qmapshack/GeoMath.cpp	Thu Apr 05 17:39:00 2018 +0200
@@ -305,6 +305,44 @@
     return dist;
 }
 
+qreal GPS_Math_DistPointPolyline(const QPolygonF& line, const QPointF& pt, qreal threshold)
+{
+    qreal d = threshold + 1;
+
+    const int len = line.size();
+    // see http://local.wasp.uwa.edu.au/~pbourke/geometry/pointline/
+    for(int i=1; i<len; ++i)
+    {
+        const QPointF &p1 = line[i-1];
+        const QPointF &p2 = line[i];
+
+        qreal dx = p2.x() - p1.x();
+        qreal dy = p2.y() - p1.y();
+
+        // distance between p1 and p2
+        qreal d_p1_p2 = qSqrt(dx * dx + dy * dy);
+
+        // ratio u the tangent point will divide d_p1_p2
+        qreal u = ((pt.x() - p1.x()) * dx + (pt.y() - p1.y()) * dy) / (d_p1_p2 * d_p1_p2);
+
+        if(u < 0.0 || u > 1.0)
+        {
+            continue;
+        }
+
+        // coord. (x,y) of the point on line defined by [p1,p2] close to pt
+        qreal x = p1.x() + u * dx;
+        qreal y = p1.y() + u * dy;
+
+        qreal distance = qSqrt((x - pt.x())*(x - pt.x()) + (y - pt.y())*(y - pt.y()));
+        if(distance < threshold)
+        {
+            d = threshold = distance;
+        }
+    }
+
+    return d;
+}
 
 
 struct segment
diff -r 8ddec3217899 -r 4aa3f266f22a src/qmapshack/GeoMath.h
--- a/src/qmapshack/GeoMath.h	Wed Apr 04 17:38:39 2018 +0200
+++ b/src/qmapshack/GeoMath.h	Thu Apr 05 17:39:00 2018 +0200
@@ -76,6 +76,7 @@
 bool    GPS_Math_LineCrossesRect(const QPointF& p1, const QPointF& p2, const QRectF& rect);
 void    GPS_Math_SubPolyline(const QPointF& pt1, const QPointF& pt2, qint32 threshold, const QPolygonF& pixel, segment_t& result);
 qreal   GPS_Math_DistPointPolyline(const QPolygonF &points, const QPointF &q);
+qreal   GPS_Math_DistPointPolyline(const QPolygonF& line, const QPointF& pt, qreal threshold);
 
 #endif                           //GEOMATH_H
 
diff -r 8ddec3217899 -r 4aa3f266f22a src/qmapshack/gis/CGisWorkspace.cpp
--- a/src/qmapshack/gis/CGisWorkspace.cpp	Wed Apr 04 17:38:39 2018 +0200
+++ b/src/qmapshack/gis/CGisWorkspace.cpp	Thu Apr 05 17:39:00 2018 +0200
@@ -1168,3 +1168,21 @@
 }
 
 
+bool CGisWorkspace::findPolylineCloseBy(const QPointF& pt1, const QPointF& pt2, qint32 threshold, QPolygonF& polyline)
+{
+    QMutexLocker lock(&IGisItem::mutexItems);
+    for(int i = 0; i < treeWks->topLevelItemCount(); i++)
+    {
+        QTreeWidgetItem * item1 = treeWks->topLevelItem(i);
+        IGisProject * project = dynamic_cast<IGisProject*>(item1);
+        if(project)
+        {
+            if(project->findPolylineCloseBy(pt1, pt2, threshold, polyline))
+            {
+                return true;
+            }
+        }
+    }
+
+    return false;
+}
diff -r 8ddec3217899 -r 4aa3f266f22a src/qmapshack/gis/CGisWorkspace.h
--- a/src/qmapshack/gis/CGisWorkspace.h	Wed Apr 04 17:38:39 2018 +0200
+++ b/src/qmapshack/gis/CGisWorkspace.h	Thu Apr 05 17:39:00 2018 +0200
@@ -418,6 +418,8 @@
 
     void applyFilter();
 
+    bool findPolylineCloseBy(const QPointF& pt1, const QPointF& pt2, qint32 threshold, QPolygonF& polyline);
+
 signals:
     void sigChanged();
 
diff -r 8ddec3217899 -r 4aa3f266f22a src/qmapshack/gis/prj/IGisProject.cpp
--- a/src/qmapshack/gis/prj/IGisProject.cpp	Wed Apr 04 17:38:39 2018 +0200
+++ b/src/qmapshack/gis/prj/IGisProject.cpp	Thu Apr 05 17:39:00 2018 +0200
@@ -1201,3 +1201,18 @@
         }
     }
 }
+
+bool IGisProject::findPolylineCloseBy(const QPointF& pt1, const QPointF& pt2, qint32 threshold, QPolygonF& polyline)
+{
+
+    const int N = childCount();
+    for(int n = 0; n < N; n++)
+    {
+        CGisItemTrk * trk = dynamic_cast<CGisItemTrk*>(child(n));
+        if((trk != nullptr) && trk->findPolylineCloseBy(pt1, pt2, threshold, polyline))
+        {
+            return true;
+        }
+    }
+    return false;
+}
diff -r 8ddec3217899 -r 4aa3f266f22a src/qmapshack/gis/prj/IGisProject.h
--- a/src/qmapshack/gis/prj/IGisProject.h	Wed Apr 04 17:38:39 2018 +0200
+++ b/src/qmapshack/gis/prj/IGisProject.h	Thu Apr 05 17:39:00 2018 +0200
@@ -517,6 +517,8 @@
         autoSavePending = false;
     }
 
+    bool findPolylineCloseBy(const QPointF& pt1, const QPointF& pt2, qint32 threshold, QPolygonF& polyline);
+
 protected:
     void genKey() const;
     virtual void setupName(const QString& defaultName);
diff -r 8ddec3217899 -r 4aa3f266f22a src/qmapshack/gis/trk/CGisItemTrk.cpp
--- a/src/qmapshack/gis/trk/CGisItemTrk.cpp	Wed Apr 04 17:38:39 2018 +0200
+++ b/src/qmapshack/gis/trk/CGisItemTrk.cpp	Thu Apr 05 17:39:00 2018 +0200
@@ -2702,3 +2702,17 @@
     }
 }
 
+
+bool CGisItemTrk::findPolylineCloseBy(const QPointF& pt1, const QPointF& pt2, qint32 threshold, QPolygonF& polyline)
+{
+    qreal dist1 = GPS_Math_DistPointPolyline(lineSimple, pt1, threshold);
+    qreal dist2 = GPS_Math_DistPointPolyline(lineSimple, pt2, threshold);
+
+    if(dist1 < threshold && dist2 < threshold)
+    {
+        trk.getPolyline(polyline);
+        threshold = qMin(dist1, dist2);
+    }
+
+    return !polyline.isEmpty();
+}
diff -r 8ddec3217899 -r 4aa3f266f22a src/qmapshack/gis/trk/CGisItemTrk.h
--- a/src/qmapshack/gis/trk/CGisItemTrk.h	Wed Apr 04 17:38:39 2018 +0200
+++ b/src/qmapshack/gis/trk/CGisItemTrk.h	Thu Apr 05 17:39:00 2018 +0200
@@ -561,6 +561,7 @@
      */
     void findWaypointsCloseBy(CProgressDialog &progress, quint32 &current);
 
+    bool findPolylineCloseBy(const QPointF& pt1, const QPointF& pt2, qint32 threshold, QPolygonF& polyline);
 private:
     /// no don't really use it, use CGisItemTrk(quint32 visuals) instead
     void updateHistory() override
diff -r 8ddec3217899 -r 4aa3f266f22a src/qmapshack/map/CMapIMG.cpp
--- a/src/qmapshack/map/CMapIMG.cpp	Wed Apr 04 17:38:39 2018 +0200
+++ b/src/qmapshack/map/CMapIMG.cpp	Thu Apr 05 17:39:00 2018 +0200
@@ -17,6 +17,7 @@
 **********************************************************************************************/
 
 #include "CMainWindow.h"
+#include "GeoMath.h"
 #include "canvas/CCanvas.h"
 #include "gis/Poi.h"
 #include "helpers/CDraw.h"
@@ -2548,44 +2549,6 @@
 }
 
 
-static qreal getDistance(const QPolygonF& line, const QPointF& pt, qreal threshold)
-{
-    qreal d = threshold + 1;
-
-    const int len = line.size();
-    // see http://local.wasp.uwa.edu.au/~pbourke/geometry/pointline/
-    for(int i=1; i<len; ++i)
-    {
-        const QPointF &p1 = line[i-1];
-        const QPointF &p2 = line[i];
-
-        qreal dx = p2.x() - p1.x();
-        qreal dy = p2.y() - p1.y();
-
-        // distance between p1 and p2
-        qreal d_p1_p2 = qSqrt(dx * dx + dy * dy);
-
-        // ratio u the tangent point will divide d_p1_p2
-        qreal u = ((pt.x() - p1.x()) * dx + (pt.y() - p1.y()) * dy) / (d_p1_p2 * d_p1_p2);
-
-        if(u < 0.0 || u > 1.0)
-        {
-            continue;
-        }
-
-        // coord. (x,y) of the point on line defined by [p1,p2] close to pt
-        qreal x = p1.x() + u * dx;
-        qreal y = p1.y() + u * dy;
-
-        qreal distance = qSqrt((x - pt.x())*(x - pt.x()) + (y - pt.y())*(y - pt.y()));
-        if(distance < threshold)
-        {
-            d = threshold = distance;
-        }
-    }
-
-    return d;
-}
 
 
 bool CMapIMG::findPolylineCloseBy(const QPointF& pt1, const QPointF& pt2, qint32 threshold, QPolygonF& polyline) /* override */
@@ -2601,8 +2564,8 @@
             continue;
         }
 
-        qreal dist1 = ::getDistance(line.pixel, pt1, threshold);
-        qreal dist2 = ::getDistance(line.pixel, pt2, threshold);
+        qreal dist1 = GPS_Math_DistPointPolyline(line.pixel, pt1, threshold);
+        qreal dist2 = GPS_Math_DistPointPolyline(line.pixel, pt2, threshold);
 
         if(dist1 < threshold && dist2 < threshold)
         {
diff -r 8ddec3217899 -r 4aa3f266f22a src/qmapshack/mouse/line/ILineOp.cpp
--- a/src/qmapshack/mouse/line/ILineOp.cpp	Wed Apr 04 17:38:39 2018 +0200
+++ b/src/qmapshack/mouse/line/ILineOp.cpp	Thu Apr 05 17:39:00 2018 +0200
@@ -21,6 +21,7 @@
 #include "GeoMath.h"
 #include "canvas/CCanvas.h"
 #include "gis/CGisDraw.h"
+#include "gis/CGisWorkspace.h"
 #include "gis/rte/router/CRouterSetup.h"
 #include "mouse/line/ILineOp.h"
 #include "mouse/line/IMouseEditLine.h"
@@ -56,7 +57,7 @@
     {
         timerRouting->start();
     }
-    else if(parentHandler->useVectorRouting())
+    else if(parentHandler->useVectorRouting()||parentHandler->useTrackRouting())
     {
         slotTimeoutRouting();
     }
@@ -140,7 +141,7 @@
     subLinePixel1.clear();
     subLinePixel2.clear();
 
-    if(parentHandler->useVectorRouting() && (idx != NOIDX))
+    if((parentHandler->useVectorRouting()||parentHandler->useTrackRouting()) && (idx != NOIDX))
     {
         leadLineCoord1.clear();
         leadLineCoord2.clear();
@@ -151,7 +152,11 @@
         {
             const IGisLine::point_t& pt1 = points[idx - 1];
             const IGisLine::point_t& pt2 = points[idx];
-            if(canvas->findPolylineCloseBy(pt2.pixel, pt2.pixel, 10, leadLineCoord1))
+
+            bool res = parentHandler->useVectorRouting() ?
+                       canvas->findPolylineCloseBy(pt2.pixel, pt2.pixel, 10, leadLineCoord1) :
+                       CGisWorkspace::self().findPolylineCloseBy(pt2.pixel, pt2.pixel, 10, leadLineCoord1);
+            if(res)
             {
                 leadLinePixel1 = leadLineCoord1;
                 gis->convertRad2Px(leadLinePixel1);
@@ -166,7 +171,12 @@
         {
             const IGisLine::point_t& pt1 = points[idx];
             const IGisLine::point_t& pt2 = points[idx + 1];
-            if(canvas->findPolylineCloseBy(pt1.pixel, pt1.pixel, 10, leadLineCoord2))
+
+            bool res = parentHandler->useVectorRouting() ?
+                       canvas->findPolylineCloseBy(pt1.pixel, pt1.pixel, 10, leadLineCoord2) :
+                       CGisWorkspace::self().findPolylineCloseBy(pt1.pixel, pt1.pixel, 10, leadLineCoord2);
+
+            if(res)
             {
                 leadLinePixel2 = leadLineCoord2;
                 gis->convertRad2Px(leadLinePixel2);
@@ -211,7 +221,7 @@
     {
         showRoutingErrorMessage(msg);
     }
-    // that is a workaround for canvas loosing mousetracking caused by CProgressDialog being modal:
+    // that is a workaround for canvas loosing mouse tracking caused by CProgressDialog being modal:
     canvas->setMouseTracking(true);
 }
 
@@ -235,7 +245,7 @@
         }
         CCanvas::restoreOverrideCursor("ILineOp::finalizeOperation");
     }
-    else if(parentHandler->useVectorRouting())
+    else if(parentHandler->useVectorRouting()||parentHandler->useTrackRouting())
     {
         if(idx > 0)
         {
diff -r 8ddec3217899 -r 4aa3f266f22a src/qmapshack/mouse/line/IMouseEditLine.cpp
--- a/src/qmapshack/mouse/line/IMouseEditLine.cpp	Wed Apr 04 17:38:39 2018 +0200
+++ b/src/qmapshack/mouse/line/IMouseEditLine.cpp	Thu Apr 05 17:39:00 2018 +0200
@@ -84,6 +84,10 @@
     {
         mode = 2;
     }
+    else if(scrOptEditLine->toolTrackRoute->isChecked())
+    {
+        mode = 3;
+    }
 
     SETTINGS;
     cfg.setValue("Route/drawMode", mode);
@@ -109,6 +113,7 @@
     connect(scrOptEditLine->toolNoRoute,     &QPushButton::clicked, this, &IMouseEditLine::slotNoRouting    );
     connect(scrOptEditLine->toolAutoRoute,   &QPushButton::clicked, this, &IMouseEditLine::slotAutoRouting  );
     connect(scrOptEditLine->toolVectorRoute, &QPushButton::clicked, this, &IMouseEditLine::slotVectorRouting);
+    connect(scrOptEditLine->toolTrackRoute,  &QPushButton::clicked, this, &IMouseEditLine::slotTrackRouting );
 
     connect(scrOptEditLine->toolUndo,        &QPushButton::clicked, this, &IMouseEditLine::slotUndo         );
     connect(scrOptEditLine->toolRedo,        &QPushButton::clicked, this, &IMouseEditLine::slotRedo         );
@@ -128,6 +133,10 @@
     case 2:
         scrOptEditLine->toolVectorRoute->setChecked(true);
         break;
+
+    case 3:
+        scrOptEditLine->toolTrackRoute->setChecked(true);
+        break;
     }
 
     slotMovePoint();
@@ -154,6 +163,11 @@
     return scrOptEditLine->toolVectorRoute->isChecked();
 }
 
+bool IMouseEditLine::useTrackRouting() const
+{
+    return scrOptEditLine->toolTrackRoute->isChecked();
+}
+
 void IMouseEditLine::drawLine(const QPolygonF &l, const QColor color, int width, QPainter& p)
 {
     p.setPen(QPen(color, width, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin));
@@ -330,6 +344,11 @@
     canvas->reportStatus("Routino", QString());
 }
 
+void IMouseEditLine::slotTrackRouting()
+{
+    canvas->reportStatus(key.item, tr("<b>Track Routing</b><br/>Connect points with a line from a loaded track if possible.<br/>"));
+    canvas->reportStatus("Routino", QString());
+}
 
 void IMouseEditLine::changeCursor()
 {
diff -r 8ddec3217899 -r 4aa3f266f22a src/qmapshack/mouse/line/IMouseEditLine.h
--- a/src/qmapshack/mouse/line/IMouseEditLine.h	Wed Apr 04 17:38:39 2018 +0200
+++ b/src/qmapshack/mouse/line/IMouseEditLine.h	Thu Apr 05 17:39:00 2018 +0200
@@ -72,6 +72,7 @@
 
     bool useAutoRouting() const;
     bool useVectorRouting() const;
+    bool useTrackRouting() const;
 
     void storeToHistory(const SGisLine& line);
     void restoreFromHistory(SGisLine& line);
@@ -99,6 +100,7 @@
     void slotNoRouting();
     void slotAutoRouting();
     void slotVectorRouting();
+    void slotTrackRouting();
 
 
     virtual void slotAbort() = 0;
diff -r 8ddec3217899 -r 4aa3f266f22a src/qmapshack/mouse/line/IScrOptEditLine.ui
--- a/src/qmapshack/mouse/line/IScrOptEditLine.ui	Wed Apr 04 17:38:39 2018 +0200
+++ b/src/qmapshack/mouse/line/IScrOptEditLine.ui	Thu Apr 05 17:39:00 2018 +0200
@@ -278,6 +278,23 @@
           </property>
          </widget>
         </item>
+        <item>
+         <widget class="QToolButton" name="toolTrackRoute">
+          <property name="text">
+           <string>...</string>
+          </property>
+          <property name="icon">
+           <iconset resource="../../resources.qrc">
+            <normaloff>:/icons/32x32/T.png</normaloff>:/icons/32x32/T.png</iconset>
+          </property>
+          <property name="checkable">
+           <bool>true</bool>
+          </property>
+          <property name="autoExclusive">
+           <bool>true</bool>
+          </property>
+         </widget>
+        </item>
        </layout>
       </widget>
      </item>
diff -r 8ddec3217899 -r 4aa3f266f22a src/qmapshack/resources.qrc
--- a/src/qmapshack/resources.qrc	Wed Apr 04 17:38:39 2018 +0200
+++ b/src/qmapshack/resources.qrc	Thu Apr 05 17:39:00 2018 +0200
@@ -224,6 +224,7 @@
         <file>../icons/32x32/SmlProject.png</file>
         <file>../icons/32x32/SortName.png</file>
         <file>../icons/32x32/Start.png</file>
+        <file>../icons/32x32/T.png</file>
         <file>../icons/32x32/Tainted.png</file>
         <file>../icons/32x32/TcxProject.png</file>
         <file>../icons/32x32/Template.png</file>
@@ -457,6 +458,7 @@
         <file>../icons/48x48/SmlProject.png</file>
         <file>../icons/48x48/SortName.png</file>
         <file>../icons/48x48/Start.png</file>
+        <file>../icons/48x48/T.png</file>
         <file>../icons/48x48/Tainted.png</file>
         <file>../icons/48x48/TcxProject.png</file>
         <file>../icons/48x48/Template.png</file>
# HG changeset patch
# User kiozen
# Date 1522995583 -7200
#      Fri Apr 06 08:19:43 2018 +0200
# Branch LineEdit
# Node ID ece3a89244702d4f9c07d17313c0ade4b9e58e94
# Parent  4aa3f266f22a1f0afd5a15b6ae7f42e143edd2e3
fixes

diff -r 4aa3f266f22a -r ece3a8924470 src/qmapshack/gis/CGisWorkspace.cpp
--- a/src/qmapshack/gis/CGisWorkspace.cpp	Thu Apr 05 17:39:00 2018 +0200
+++ b/src/qmapshack/gis/CGisWorkspace.cpp	Fri Apr 06 08:19:43 2018 +0200
@@ -1177,12 +1177,9 @@
         IGisProject * project = dynamic_cast<IGisProject*>(item1);
         if(project)
         {
-            if(project->findPolylineCloseBy(pt1, pt2, threshold, polyline))
-            {
-                return true;
-            }
+            project->findPolylineCloseBy(pt1, pt2, threshold, polyline);
         }
     }
 
-    return false;
+    return !polyline.isEmpty();
 }
diff -r 4aa3f266f22a -r ece3a8924470 src/qmapshack/gis/prj/IGisProject.cpp
--- a/src/qmapshack/gis/prj/IGisProject.cpp	Thu Apr 05 17:39:00 2018 +0200
+++ b/src/qmapshack/gis/prj/IGisProject.cpp	Fri Apr 06 08:19:43 2018 +0200
@@ -1202,17 +1202,17 @@
     }
 }
 
-bool IGisProject::findPolylineCloseBy(const QPointF& pt1, const QPointF& pt2, qint32 threshold, QPolygonF& polyline)
+bool IGisProject::findPolylineCloseBy(const QPointF& pt1, const QPointF& pt2, qint32& threshold, QPolygonF& polyline)
 {
 
     const int N = childCount();
     for(int n = 0; n < N; n++)
     {
         CGisItemTrk * trk = dynamic_cast<CGisItemTrk*>(child(n));
-        if((trk != nullptr) && trk->findPolylineCloseBy(pt1, pt2, threshold, polyline))
+        if(trk != nullptr)
         {
-            return true;
+            trk->findPolylineCloseBy(pt1, pt2, threshold, polyline);
         }
     }
-    return false;
+    return !polyline.isEmpty();
 }
diff -r 4aa3f266f22a -r ece3a8924470 src/qmapshack/gis/prj/IGisProject.h
--- a/src/qmapshack/gis/prj/IGisProject.h	Thu Apr 05 17:39:00 2018 +0200
+++ b/src/qmapshack/gis/prj/IGisProject.h	Fri Apr 06 08:19:43 2018 +0200
@@ -517,7 +517,7 @@
         autoSavePending = false;
     }
 
-    bool findPolylineCloseBy(const QPointF& pt1, const QPointF& pt2, qint32 threshold, QPolygonF& polyline);
+    bool findPolylineCloseBy(const QPointF& pt1, const QPointF& pt2, qint32& threshold, QPolygonF& polyline);
 
 protected:
     void genKey() const;
diff -r 4aa3f266f22a -r ece3a8924470 src/qmapshack/gis/trk/CGisItemTrk.cpp
--- a/src/qmapshack/gis/trk/CGisItemTrk.cpp	Thu Apr 05 17:39:00 2018 +0200
+++ b/src/qmapshack/gis/trk/CGisItemTrk.cpp	Fri Apr 06 08:19:43 2018 +0200
@@ -2703,7 +2703,7 @@
 }
 
 
-bool CGisItemTrk::findPolylineCloseBy(const QPointF& pt1, const QPointF& pt2, qint32 threshold, QPolygonF& polyline)
+bool CGisItemTrk::findPolylineCloseBy(const QPointF& pt1, const QPointF& pt2, qint32& threshold, QPolygonF& polyline)
 {
     qreal dist1 = GPS_Math_DistPointPolyline(lineSimple, pt1, threshold);
     qreal dist2 = GPS_Math_DistPointPolyline(lineSimple, pt2, threshold);
diff -r 4aa3f266f22a -r ece3a8924470 src/qmapshack/gis/trk/CGisItemTrk.h
--- a/src/qmapshack/gis/trk/CGisItemTrk.h	Thu Apr 05 17:39:00 2018 +0200
+++ b/src/qmapshack/gis/trk/CGisItemTrk.h	Fri Apr 06 08:19:43 2018 +0200
@@ -561,7 +561,7 @@
      */
     void findWaypointsCloseBy(CProgressDialog &progress, quint32 &current);
 
-    bool findPolylineCloseBy(const QPointF& pt1, const QPointF& pt2, qint32 threshold, QPolygonF& polyline);
+    bool findPolylineCloseBy(const QPointF& pt1, const QPointF& pt2, qint32 &threshold, QPolygonF& polyline);
 private:
     /// no don't really use it, use CGisItemTrk(quint32 visuals) instead
     void updateHistory() override
diff -r 4aa3f266f22a -r ece3a8924470 src/qmapshack/mouse/line/IScrOptEditLine.ui
--- a/src/qmapshack/mouse/line/IScrOptEditLine.ui	Thu Apr 05 17:39:00 2018 +0200
+++ b/src/qmapshack/mouse/line/IScrOptEditLine.ui	Fri Apr 06 08:19:43 2018 +0200
@@ -280,6 +280,9 @@
         </item>
         <item>
          <widget class="QToolButton" name="toolTrackRoute">
+          <property name="toolTip">
+           <string>Connect points with a line from a loaded track if possible.</string>
+          </property>
           <property name="text">
            <string>...</string>
           </property>
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Qlandkartegt-users mailing list
Qlandkartegt-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/qlandkartegt-users

Reply via email to