(djes) implemented the new functions by Yves86

This commit is contained in:
djes
2017-06-15 17:08:14 +02:00
parent 4183dcd59b
commit 552763d346

View File

@@ -96,6 +96,9 @@ DeclareModule PBMap
Declare Error(msg.s) Declare Error(msg.s)
Declare Refresh() Declare Refresh()
Declare.i ClearDiskCache() Declare.i ClearDiskCache()
Declare SetCallBackMarker(*CallBackLocation)
Declare SetCallBackLeftClic(*CallBackLocation)
EndDeclareModule EndDeclareModule
Module PBMap Module PBMap
@@ -128,7 +131,6 @@ Module PBMap
Download.i Download.i
Time.i Time.i
Size.i Size.i
Mutex.i
EndStructure EndStructure
Structure BoundingBox Structure BoundingBox
@@ -193,7 +195,8 @@ Module PBMap
ProxyPort.s ProxyPort.s
ProxyUser.s ProxyUser.s
ProxyPassword.s ProxyPassword.s
ShowDegrees.i ShowDegrees.i
ShowZoom.i
ShowDebugInfos.i ShowDebugInfos.i
ShowScale.i ShowScale.i
ShowTrack.i ShowTrack.i
@@ -209,6 +212,7 @@ Module PBMap
Warning.i ; Warning requesters Warning.i ; Warning requesters
ShowMarkersNb.i ShowMarkersNb.i
ShowMarkersLegend.i ShowMarkersLegend.i
ShowTrackSelection.i ; YA to show or not track selection
; Drawing stuff ; Drawing stuff
StrokeWidthTrackDefault.i StrokeWidthTrackDefault.i
; Colours ; Colours
@@ -273,6 +277,8 @@ Module PBMap
CallBackLocation.i ; @Procedure(latitude.d,lontitude.d) CallBackLocation.i ; @Procedure(latitude.d,lontitude.d)
CallBackMainPointer.i ; @Procedure(X.i, Y.i) to DrawPointer (you must use VectorDrawing lib) CallBackMainPointer.i ; @Procedure(X.i, Y.i) to DrawPointer (you must use VectorDrawing lib)
CallBackMarker.i ; @Procedure (latitude.d,lontitude.d) pour connaitre la nouvelle position du marqueur (YA)
CallBackLeftClic.i ; @Procdeure (latitude.d,lontitude.d) pour connaitre la position lors du clic gauche (YA)
PixelCoordinates.PixelCoordinates ; Actual focus point coords in pixels (global) PixelCoordinates.PixelCoordinates ; Actual focus point coords in pixels (global)
MoveStartingPoint.PixelCoordinates ; Start mouse position coords when dragging the map MoveStartingPoint.PixelCoordinates ; Start mouse position coords when dragging the map
@@ -712,6 +718,8 @@ Module PBMap
SelBool(WheelMouseRelative) SelBool(WheelMouseRelative)
Case "showdegrees" Case "showdegrees"
SelBool(ShowDegrees) SelBool(ShowDegrees)
Case "showzoom"
SelBool(ShowZoom)
Case "showdebuginfos" Case "showdebuginfos"
SelBool(ShowDebugInfos) SelBool(ShowDebugInfos)
Case "showscale" Case "showscale"
@@ -722,6 +730,8 @@ Module PBMap
SelBool(ShowPointer) SelBool(ShowPointer)
Case "showtrack" Case "showtrack"
SelBool(ShowTrack) SelBool(ShowTrack)
Case "showtrackselection"
SelBool(ShowTrackSelection)
Case "showmarkersnb" Case "showmarkersnb"
SelBool(ShowMarkersNb) SelBool(ShowMarkersNb)
Case "showmarkerslegend" Case "showmarkerslegend"
@@ -787,12 +797,16 @@ Module PBMap
ProcedureReturn GetBoolString(\ShowDebugInfos) ProcedureReturn GetBoolString(\ShowDebugInfos)
Case "showscale" Case "showscale"
ProcedureReturn GetBoolString(\ShowScale) ProcedureReturn GetBoolString(\ShowScale)
Case "showzoom"
ProcedureReturn GetBoolString(\ShowZoom)
Case "showmarkers" Case "showmarkers"
ProcedureReturn GetBoolString(\ShowMarkers) ProcedureReturn GetBoolString(\ShowMarkers)
Case "showpointer" Case "showpointer"
ProcedureReturn GetBoolString(\ShowPointer) ProcedureReturn GetBoolString(\ShowPointer)
Case "showtrack" Case "showtrack"
ProcedureReturn GetBoolString(\ShowTrack) ProcedureReturn GetBoolString(\ShowTrack)
Case "showtrackselection"
ProcedureReturn GetBoolString(\ShowTrackSelection)
Case "showmarkersnb" Case "showmarkersnb"
ProcedureReturn GetBoolString(\ShowMarkersNb) ProcedureReturn GetBoolString(\ShowMarkersNb)
Case "showmarkerslegend" Case "showmarkerslegend"
@@ -842,9 +856,11 @@ Module PBMap
WritePreferenceInteger("ShowDegrees", \ShowDegrees) WritePreferenceInteger("ShowDegrees", \ShowDegrees)
WritePreferenceInteger("ShowDebugInfos", \ShowDebugInfos) WritePreferenceInteger("ShowDebugInfos", \ShowDebugInfos)
WritePreferenceInteger("ShowScale", \ShowScale) WritePreferenceInteger("ShowScale", \ShowScale)
WritePreferenceInteger("ShowZoom", \ShowZoom)
WritePreferenceInteger("ShowMarkers", \ShowMarkers) WritePreferenceInteger("ShowMarkers", \ShowMarkers)
WritePreferenceInteger("ShowPointer", \ShowPointer) WritePreferenceInteger("ShowPointer", \ShowPointer)
WritePreferenceInteger("ShowTrack", \ShowTrack) WritePreferenceInteger("ShowTrack", \ShowTrack)
WritePreferenceInteger("ShowTrackSelection", \ShowTrackSelection)
WritePreferenceInteger("ShowTrackKms", \ShowTrackKms) WritePreferenceInteger("ShowTrackKms", \ShowTrackKms)
WritePreferenceInteger("ShowMarkersNb", \ShowMarkersNb) WritePreferenceInteger("ShowMarkersNb", \ShowMarkersNb)
WritePreferenceInteger("ShowMarkersLegend", \ShowMarkersLegend) WritePreferenceInteger("ShowMarkersLegend", \ShowMarkersLegend)
@@ -908,9 +924,11 @@ Module PBMap
\ShowDegrees = ReadPreferenceInteger("ShowDegrees", #False) \ShowDegrees = ReadPreferenceInteger("ShowDegrees", #False)
\ShowDebugInfos = ReadPreferenceInteger("ShowDebugInfos", #False) \ShowDebugInfos = ReadPreferenceInteger("ShowDebugInfos", #False)
\ShowScale = ReadPreferenceInteger("ShowScale", #False) \ShowScale = ReadPreferenceInteger("ShowScale", #False)
\ShowZoom = ReadPreferenceInteger("ShowZoom", #True)
\ShowMarkers = ReadPreferenceInteger("ShowMarkers", #True) \ShowMarkers = ReadPreferenceInteger("ShowMarkers", #True)
\ShowPointer = ReadPreferenceInteger("ShowPointer", #True) \ShowPointer = ReadPreferenceInteger("ShowPointer", #True)
\ShowTrack = ReadPreferenceInteger("ShowTrack", #True) \ShowTrack = ReadPreferenceInteger("ShowTrack", #True)
\ShowTrackSelection = ReadPreferenceInteger("ShowTrackSelection", #False)
\ShowTrackKms = ReadPreferenceInteger("ShowTrackKms", #False) \ShowTrackKms = ReadPreferenceInteger("ShowTrackKms", #False)
\ShowMarkersNb = ReadPreferenceInteger("ShowMarkersNb", #True) \ShowMarkersNb = ReadPreferenceInteger("ShowMarkersNb", #True)
\ShowMarkersLegend = ReadPreferenceInteger("ShowMarkersLegend", #False) \ShowMarkersLegend = ReadPreferenceInteger("ShowMarkersLegend", #False)
@@ -1495,6 +1513,12 @@ Module PBMap
StrokePath(1) StrokePath(1)
EndProcedure EndProcedure
Procedure DrawZoom(x.i, y.i)
VectorFont(FontID(PBMap\Font), 20)
VectorSourceColor(RGBA(0, 0, 0,150))
MovePathCursor(x,y)
DrawVectorText(Str(GetZoom()))
EndProcedure
;-*** Tracks ;-*** Tracks
Procedure DrawTrackPointer(x.d, y.d, dist.l) Procedure DrawTrackPointer(x.d, y.d, dist.l)
@@ -1604,11 +1628,20 @@ Module PBMap
VectorSourceColor(\Colour) VectorSourceColor(\Colour)
EndIf EndIf
StrokePath(\StrokeWidth, #PB_Path_RoundEnd|#PB_Path_RoundCorner) StrokePath(\StrokeWidth, #PB_Path_RoundEnd|#PB_Path_RoundCorner)
; YA pour marquer chaque point d'un rond
ForEach \Track()
LatLon2PixelRel(@PBMap\TracksList()\Track(), @Pixel, PBMap\Zoom)
AddPathCircle(Pixel\x,Pixel\y,(\StrokeWidth / 4))
Next
VectorSourceColor(RGBA(255, 255, 0, 255))
StrokePath(1)
EndIf EndIf
EndIf EndIf
Next Next
EndVectorLayer() EndVectorLayer()
; Draw distances ;Draw distances
If PBMap\Options\ShowTrackKms And PBMap\Zoom > 10 If PBMap\Options\ShowTrackKms And PBMap\Zoom > 10
BeginVectorLayer() BeginVectorLayer()
ForEach PBMap\TracksList() ForEach PBMap\TracksList()
@@ -1947,6 +1980,9 @@ Module PBMap
If PBMap\Options\ShowScale If PBMap\Options\ShowScale
DrawScale(*Drawing, 10, GadgetHeight(PBMAP\Gadget) - 20, 192) DrawScale(*Drawing, 10, GadgetHeight(PBMAP\Gadget) - 20, 192)
EndIf EndIf
If PBMap\Options\ShowZoom
DrawZoom(GadgetWidth(PBMap\Gadget) - 30, 5) ; ajout YA - affiche le niveau de zoom
EndIf
DrawOSMCopyright(*Drawing) DrawOSMCopyright(*Drawing)
StopVectorDrawing() StopVectorDrawing()
EndProcedure EndProcedure
@@ -2095,6 +2131,14 @@ Module PBMap
PBMap\CallBackMainPointer = CallBackMainPointer PBMap\CallBackMainPointer = CallBackMainPointer
EndProcedure EndProcedure
Procedure SetCallBackMarker(CallBackLocation.i)
PBMap\CallBackMarker = CallBackLocation
EndProcedure
Procedure SetCallBackLeftClic(CallBackLocation.i)
PBMap\CallBackLeftClic = CallBackLocation
EndProcedure
Procedure SetMapScaleUnit(ScaleUnit.i = PBMAP::#SCALE_KM) Procedure SetMapScaleUnit(ScaleUnit.i = PBMAP::#SCALE_KM)
PBMap\Options\ScaleUnit = ScaleUnit PBMap\Options\ScaleUnit = ScaleUnit
PBMap\Redraw = #True PBMap\Redraw = #True
@@ -2250,6 +2294,7 @@ Module PBMap
Protected key.s, Touch.i Protected key.s, Touch.i
Protected Pixel.PixelCoordinates Protected Pixel.PixelCoordinates
Static CtrlKey Static CtrlKey
Protected Location.GeographicCoordinates
CanvasMouseX = GetGadgetAttribute(PBMap\Gadget, #PB_Canvas_MouseX) - PBMap\Drawing\RadiusX CanvasMouseX = GetGadgetAttribute(PBMap\Gadget, #PB_Canvas_MouseX) - PBMap\Drawing\RadiusX
CanvasMouseY = GetGadgetAttribute(PBMap\Gadget, #PB_Canvas_MouseY) - PBMap\Drawing\RadiusY CanvasMouseY = GetGadgetAttribute(PBMap\Gadget, #PB_Canvas_MouseY) - PBMap\Drawing\RadiusY
; rotation wip ; rotation wip
@@ -2370,6 +2415,18 @@ Module PBMap
EndIf EndIf
Next Next
EndIf EndIf
; YA pour s<>lectionner un point de la trace avec le clic gauche
If PBMap\EditMarker = #False
Location\Latitude = GetMouseLatitude()
Location\Longitude = GetMouseLongitude()
If PBMap\CallBackLeftClic > 0
CallFunctionFast(PBMap\CallBackLeftClic, @Location)
EndIf
; ajout YA // change la forme du pointeur de souris pour les d<>placements de la carte
SetGadgetAttribute(PBMap\Gadget,#PB_Canvas_Cursor,#PB_Cursor_Hand)
Else
SetGadgetAttribute(PBMap\Gadget,#PB_Canvas_Cursor,#PB_Cursor_Default) ; ajout YA pour remettre le pointeur souris en normal
EndIf
Case #PB_EventType_MouseMove Case #PB_EventType_MouseMove
; Drag ; Drag
If PBMap\Dragging If PBMap\Dragging
@@ -2423,6 +2480,7 @@ Module PBMap
EndIf EndIf
Next Next
; Check if mouse touch tracks ; Check if mouse touch tracks
If PBMap\Options\ShowTrackSelection ; YA ajout pour <20>viter la s<>lection de la trace
With PBMap\TracksList() With PBMap\TracksList()
; Trace Track ; Trace Track
If ListSize(PBMap\TracksList()) > 0 If ListSize(PBMap\TracksList()) > 0
@@ -2454,10 +2512,20 @@ Module PBMap
EndWith EndWith
EndIf EndIf
EndIf EndIf
EndIf
Case #PB_EventType_LeftButtonUp Case #PB_EventType_LeftButtonUp
SetGadgetAttribute(PBMap\Gadget,#PB_Canvas_Cursor,#PB_Cursor_Default) ; ajout YA pour remettre le pointeur souris en normal
; PBMap\MoveStartingPoint\x = - 1 ; PBMap\MoveStartingPoint\x = - 1
PBMap\Dragging = #False PBMap\Dragging = #False
PBMap\Redraw = #True PBMap\Redraw = #True
;YA pour connaitre les coordonn<6E>es d'un marqueur apr<70>s d<>placement
ForEach PBMap\Markers()
If PBMap\Markers()\Selected = #True
If PBMap\CallBackMarker > 0
CallFunctionFast(PBMap\CallBackMarker, @PBMap\Markers()\GeographicCoordinates)
EndIf
EndIf
Next
Case #PB_MAP_REDRAW Case #PB_MAP_REDRAW
PBMap\Redraw = #True PBMap\Redraw = #True
Case #PB_MAP_RETRY Case #PB_MAP_RETRY
@@ -2727,9 +2795,9 @@ CompilerIf #PB_Compiler_IsMainFile
; Our main gadget ; Our main gadget
PBMap::InitPBMap(#Window_0) PBMap::InitPBMap(#Window_0)
PBMap::SetOption("ShowDegrees", "1") : Degrees = 0 PBMap::SetOption("ShowDegrees", "1") : Degrees = 0
PBMap::SetOption("ShowDebugInfos", "1") PBMap::SetOption("ShowDebugInfos", "0")
PBMap::SetDebugLevel(5) PBMap::SetDebugLevel(5)
PBMap::SetOption("Verbose", "1") PBMap::SetOption("Verbose", "0")
PBMap::SetOption("ShowScale", "1") PBMap::SetOption("ShowScale", "1")
PBMap::SetOption("Warning", "1") PBMap::SetOption("Warning", "1")
PBMap::SetOption("ShowMarkersLegend", "1") PBMap::SetOption("ShowMarkersLegend", "1")
@@ -2872,9 +2940,9 @@ CompilerIf #PB_Compiler_IsMainFile
CompilerEndIf CompilerEndIf
; IDE Options = PureBasic 5.60 (Windows - x64) ; IDE Options = PureBasic 5.60 (Windows - x64)
; CursorPosition = 2552 ; CursorPosition = 2797
; FirstLine = 2548 ; FirstLine = 2794
; Folding = ------------------- ; Folding = --------------------
; EnableThread ; EnableThread
; EnableXP ; EnableXP
; CompileSourceDirectory ; CompileSourceDirectory