From e05872d079a81dd0fa9acdf69f1b569264436124 Mon Sep 17 00:00:00 2001 From: wp_xxyyzz Date: Tue, 25 Apr 2023 21:31:28 +0000 Subject: [PATCH] LazMapViewer: Simplify drawing of tracks. git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@8811 8e941d3f-bd1b-0410-a28a-d453659cc2b4 --- .../lazmapviewer/source/mvmapviewer.pas | 29 +++++++------------ 1 file changed, 10 insertions(+), 19 deletions(-) diff --git a/components/lazmapviewer/source/mvmapviewer.pas b/components/lazmapviewer/source/mvmapviewer.pas index d13ad2e29..e3dc36111 100644 --- a/components/lazmapviewer/source/mvmapviewer.pas +++ b/components/lazmapviewer/source/mvmapviewer.pas @@ -626,10 +626,9 @@ end; procedure TMapView.DrawTrack(const Area: TRealArea; trk: TGPSTrack); var - Old,New: TPoint; i: integer; - aPt: TRealPoint; - LastInside, IsInside: boolean; + iPt1, iPt2: TPoint; + pt1, pt2: TRealPoint; trkColor: TColor; trkWidth: Integer; begin @@ -657,25 +656,17 @@ begin trkWidth := mmToPx(trk.LineWidth); if trkWidth < 1 then trkWidth := 1; - LastInside := false; DrawingEngine.PenColor := trkColor; DrawingEngine.PenWidth := trkWidth; - for i:=0 to pred(trk.Points.Count) do + pt1 := trk.Points[0].RealPoint; + iPt1 := Engine.LonLatToScreen(pt1); + for i := 1 to pred(trk.Points.Count) do begin - aPt := trk.Points[i].RealPoint; - IsInside := PtInsideArea(aPt,Area); - if IsInside or LastInside then - begin - New := Engine.LonLatToScreen(aPt); - if i > 0 then - begin - if not LastInside then - Old := Engine.LonLatToScreen(trk.Points[pred(i)].RealPoint); - DrawingEngine.Line(Old.X, Old.Y, New.X, New.Y); - end; - Old := New; - LastInside := IsInside; - end; + pt2 := trk.Points[i].RealPoint; + iPt2 := Engine.LonLatToScreen(pt2); + DrawingEngine.Line(iPt1.X, iPt1.Y, iPt2.X, iPt2.Y); + pt1 := pt2; + iPt1 := iPt2; end; finally GPSItems.Unlock;