From 717de5f6a3f500fc23d096583f01dc154de48695 Mon Sep 17 00:00:00 2001 From: djes Date: Fri, 30 Sep 2016 22:16:20 +0200 Subject: [PATCH] Lil track update --- PBMap.pb | 46 +++++++++++++++++++++++++++++++++++++++------- 1 file changed, 39 insertions(+), 7 deletions(-) diff --git a/PBMap.pb b/PBMap.pb index 7862ebd..b034bb4 100644 --- a/PBMap.pb +++ b/PBMap.pb @@ -64,6 +64,7 @@ DeclareModule PBMap Declare ClearTracks() Declare DeleteTrack(*Ptr) Declare DeleteSelectedTracks() + Declare SetTrackColour(*Ptr, Colour.i) Declare.i AddMarker(Latitude.d, Longitude.d, Identifier.s = "", Legend.s = "", color.l=-1, CallBackPointer.i = -1) Declare ClearMarkers() Declare DeleteMarker(*Ptr) @@ -1163,6 +1164,25 @@ Module PBMap DrawVectorText(Str(dist)) EndProcedure + Procedure TrackPointerFirst(x.i, y.i, dist.l) + Protected color.l + color=RGBA(0, 0, 0, 255) + MovePathCursor(x,y) + AddPathLine(-9,-17,#PB_Path_Relative) + AddPathLine(17,0,#PB_Path_Relative) + AddPathLine(-9,17,#PB_Path_Relative) + VectorSourceColor(color) + AddPathCircle(x,y-24,16) + FillPath() + VectorSourceColor(RGBA(255, 0, 0, 255)) + AddPathCircle(x,y-24,14) + FillPath() + VectorFont(FontID(PBMap\Font), 14) + MovePathCursor(x-VectorTextWidth(Str(dist))/2, y-24-VectorTextHeight(Str(dist))/2) + VectorSourceColor(RGBA(0, 0, 0, 255)) + DrawVectorText(Str(dist)) + EndProcedure + Procedure DeleteTrack(*Ptr) If *Ptr ChangeCurrentElement(PBMap\TracksList(), *Ptr) @@ -1184,6 +1204,14 @@ Module PBMap PBMap\Redraw = #True EndProcedure + Procedure SetTrackColour(*Ptr, Colour.i) + If *Ptr + ChangeCurrentElement(PBMap\TracksList(), *Ptr) + PBMap\TracksList()\Colour = Colour + PBMap\Redraw = #True + EndIf + EndProcedure + Procedure DrawTracks(*Drawing.DrawingParameters) Protected Pixel.PixelCoordinates Protected Location.GeographicCoordinates @@ -1229,7 +1257,7 @@ Module PBMap Next EndVectorLayer() ;Draw distances - If PBMap\Options\ShowTrackKms + If PBMap\Options\ShowTrackKms And PBMap\Zoom > 10 BeginVectorLayer() ForEach PBMap\TracksList() If \Visible @@ -1247,9 +1275,11 @@ Module PBMap LatLon2PixelRel(@PBMap\TracksList()\Track(), @Pixel, PBMap\Zoom) If Int(km) <> memKm memKm = Int(km) - If PBMap\Zoom > 10 + If Int(km) = 0 + TrackPointerFirst(Pixel\X , Pixel\Y, Int(km)) + Else TrackPointer(Pixel\X , Pixel\Y, Int(km)) - EndIf + EndIf EndIf Next EndIf @@ -2183,6 +2213,7 @@ CompilerIf #PB_Compiler_IsMainFile Define Event.i, Gadget.i, Quit.b = #False Define pfValue.d Define OpenSeaMap = 0, Degrees = 1 + Define *Track ;Our main gadget PBMap::InitPBMap(#Window_0) @@ -2219,7 +2250,8 @@ CompilerIf #PB_Compiler_IsMainFile Case #Button_5 PBMap::SetZoom( - 1) Case #Gdt_LoadGpx - PBMap::LoadGpxFile(OpenFileRequester("Choose a file to load", "", "Gpx|*.gpx", 0)) + *Track = PBMap::LoadGpxFile(OpenFileRequester("Choose a file to load", "", "Gpx|*.gpx", 0)) + PBMap::SetTrackColour(*Track, RGBA(Random(255), Random(255), Random(255), 128)) Case #StringLatitude, #StringLongitude Select EventType() Case #PB_EventType_Focus @@ -2280,8 +2312,8 @@ CompilerIf #PB_Compiler_IsMainFile CompilerEndIf ; IDE Options = PureBasic 5.50 (Windows - x64) -; CursorPosition = 2183 -; FirstLine = 2166 -; Folding = --------------- +; CursorPosition = 1156 +; FirstLine = 1144 +; Folding = ---------------- ; EnableThread ; EnableXP \ No newline at end of file