Better mouse handling + rotation wip
This commit is contained in:
177
PBMap.pb
177
PBMap.pb
@@ -55,6 +55,7 @@ DeclareModule PBMap
|
|||||||
Declare MapGadget(Gadget.i, X.i, Y.i, Width.i, Height.i)
|
Declare MapGadget(Gadget.i, X.i, Y.i, Width.i, Height.i)
|
||||||
Declare SetLocation(latitude.d, longitude.d, Zoom = -1, mode.i = #PB_Absolute)
|
Declare SetLocation(latitude.d, longitude.d, Zoom = -1, mode.i = #PB_Absolute)
|
||||||
Declare Drawing()
|
Declare Drawing()
|
||||||
|
Declare SetAngle(Angle.d, Mode = #PB_Absolute)
|
||||||
Declare SetZoom(Zoom.i, mode.i = #PB_Relative)
|
Declare SetZoom(Zoom.i, mode.i = #PB_Relative)
|
||||||
Declare ZoomToArea(MinY.d, MaxY.d, MinX.d, MaxX.d)
|
Declare ZoomToArea(MinY.d, MaxY.d, MinX.d, MaxX.d)
|
||||||
Declare ZoomToTracks(*Tracks)
|
Declare ZoomToTracks(*Tracks)
|
||||||
@@ -77,6 +78,7 @@ DeclareModule PBMap
|
|||||||
Declare.d GetLongitude()
|
Declare.d GetLongitude()
|
||||||
Declare.d MouseLatitude()
|
Declare.d MouseLatitude()
|
||||||
Declare.d MouseLongitude()
|
Declare.d MouseLongitude()
|
||||||
|
Declare.d GetAngle()
|
||||||
Declare.i GetZoom()
|
Declare.i GetZoom()
|
||||||
Declare.i GetMode()
|
Declare.i GetMode()
|
||||||
Declare SetMode(Mode.i = #MODE_DEFAULT)
|
Declare SetMode(Mode.i = #MODE_DEFAULT)
|
||||||
@@ -88,8 +90,8 @@ Module PBMap
|
|||||||
EnableExplicit
|
EnableExplicit
|
||||||
|
|
||||||
Structure PixelCoordinates
|
Structure PixelCoordinates
|
||||||
x.i
|
x.d
|
||||||
y.i
|
y.d
|
||||||
EndStructure
|
EndStructure
|
||||||
|
|
||||||
Structure Coordinates
|
Structure Coordinates
|
||||||
@@ -226,6 +228,7 @@ Module PBMap
|
|||||||
|
|
||||||
List Layers.Layer() ;
|
List Layers.Layer() ;
|
||||||
|
|
||||||
|
Angle.d
|
||||||
ZoomMin.i ; Min Zoom supported by server
|
ZoomMin.i ; Min Zoom supported by server
|
||||||
ZoomMax.i ; Max Zoom supported by server
|
ZoomMax.i ; Max Zoom supported by server
|
||||||
Zoom.i ; Current zoom
|
Zoom.i ; Current zoom
|
||||||
@@ -1167,7 +1170,7 @@ Module PBMap
|
|||||||
StrokePath(1)
|
StrokePath(1)
|
||||||
EndProcedure
|
EndProcedure
|
||||||
|
|
||||||
Procedure TrackPointer(x.i, y.i, dist.l)
|
Procedure DrawTrackPointer(x.i, y.i, dist.l)
|
||||||
Protected color.l
|
Protected color.l
|
||||||
color=RGBA(0, 0, 0, 255)
|
color=RGBA(0, 0, 0, 255)
|
||||||
MovePathCursor(x,y)
|
MovePathCursor(x,y)
|
||||||
@@ -1186,7 +1189,7 @@ Module PBMap
|
|||||||
DrawVectorText(Str(dist))
|
DrawVectorText(Str(dist))
|
||||||
EndProcedure
|
EndProcedure
|
||||||
|
|
||||||
Procedure TrackPointerFirst(x.i, y.i, dist.l)
|
Procedure DrawTrackPointerFirst(x.i, y.i, dist.l)
|
||||||
Protected color.l
|
Protected color.l
|
||||||
color=RGBA(0, 0, 0, 255)
|
color=RGBA(0, 0, 0, 255)
|
||||||
MovePathCursor(x,y)
|
MovePathCursor(x,y)
|
||||||
@@ -1257,9 +1260,9 @@ Module PBMap
|
|||||||
ForEach \Track()
|
ForEach \Track()
|
||||||
LatLon2PixelRel(@PBMap\TracksList()\Track(), @Pixel, PBMap\Zoom)
|
LatLon2PixelRel(@PBMap\TracksList()\Track(), @Pixel, PBMap\Zoom)
|
||||||
If ListIndex(\Track()) = 0
|
If ListIndex(\Track()) = 0
|
||||||
MovePathCursor(Pixel\X, Pixel\Y)
|
MovePathCursor(Pixel\x, Pixel\y)
|
||||||
Else
|
Else
|
||||||
AddPathLine(Pixel\X, Pixel\Y)
|
AddPathLine(Pixel\x, Pixel\y)
|
||||||
EndIf
|
EndIf
|
||||||
Next
|
Next
|
||||||
; \BoundingBox\x = PathBoundsX()
|
; \BoundingBox\x = PathBoundsX()
|
||||||
@@ -1297,11 +1300,13 @@ Module PBMap
|
|||||||
LatLon2PixelRel(@PBMap\TracksList()\Track(), @Pixel, PBMap\Zoom)
|
LatLon2PixelRel(@PBMap\TracksList()\Track(), @Pixel, PBMap\Zoom)
|
||||||
If Int(km) <> memKm
|
If Int(km) <> memKm
|
||||||
memKm = Int(km)
|
memKm = Int(km)
|
||||||
|
RotateCoordinates(Pixel\x, Pixel\y, -PBMap\Angle)
|
||||||
If Int(km) = 0
|
If Int(km) = 0
|
||||||
TrackPointerFirst(Pixel\X , Pixel\Y, Int(km))
|
DrawTrackPointerFirst(Pixel\x , Pixel\y, Int(km))
|
||||||
Else
|
Else
|
||||||
TrackPointer(Pixel\X , Pixel\Y, Int(km))
|
DrawTrackPointer(Pixel\x , Pixel\y, Int(km))
|
||||||
EndIf
|
EndIf
|
||||||
|
RotateCoordinates(Pixel\x, Pixel\y, PBMap\Angle)
|
||||||
EndIf
|
EndIf
|
||||||
Next
|
Next
|
||||||
EndIf
|
EndIf
|
||||||
@@ -1483,12 +1488,14 @@ Module PBMap
|
|||||||
ForEach PBMap\Markers()
|
ForEach PBMap\Markers()
|
||||||
If IsInDrawingBoundaries(*Drawing, @PBMap\Markers()\GeographicCoordinates)
|
If IsInDrawingBoundaries(*Drawing, @PBMap\Markers()\GeographicCoordinates)
|
||||||
LatLon2PixelRel(PBMap\Markers()\GeographicCoordinates, @Pixel, PBMap\Zoom)
|
LatLon2PixelRel(PBMap\Markers()\GeographicCoordinates, @Pixel, PBMap\Zoom)
|
||||||
If Pixel\X >= 0 And Pixel\Y >= 0 And Pixel\X < GadgetWidth(PBMap\Gadget) And Pixel\Y < GadgetHeight(PBMap\Gadget) ; Only if visible ^_^
|
If Pixel\x >= 0 And Pixel\y >= 0 And Pixel\x < GadgetWidth(PBMap\Gadget) And Pixel\y < GadgetHeight(PBMap\Gadget) ; Only if visible ^_^
|
||||||
|
RotateCoordinates(Pixel\x, Pixel\y, -PBMap\Angle)
|
||||||
If PBMap\Markers()\CallBackPointer > 0
|
If PBMap\Markers()\CallBackPointer > 0
|
||||||
CallFunctionFast(PBMap\Markers()\CallBackPointer, Pixel\X, Pixel\Y, PBMap\Markers()\Focus, PBMap\Markers()\Selected)
|
CallFunctionFast(PBMap\Markers()\CallBackPointer, Pixel\x, Pixel\y, PBMap\Markers()\Focus, PBMap\Markers()\Selected)
|
||||||
Else
|
Else
|
||||||
DrawMarker(Pixel\X, Pixel\Y, ListIndex(PBMap\Markers()), @PBMap\Markers())
|
DrawMarker(Pixel\x, Pixel\y, ListIndex(PBMap\Markers()), @PBMap\Markers())
|
||||||
EndIf
|
EndIf
|
||||||
|
RotateCoordinates(Pixel\x, Pixel\y, PBMap\Angle)
|
||||||
EndIf
|
EndIf
|
||||||
EndIf
|
EndIf
|
||||||
Next
|
Next
|
||||||
@@ -1558,6 +1565,9 @@ Module PBMap
|
|||||||
;***
|
;***
|
||||||
; Main drawing stuff
|
; Main drawing stuff
|
||||||
StartVectorDrawing(CanvasVectorOutput(PBMap\Gadget))
|
StartVectorDrawing(CanvasVectorOutput(PBMap\Gadget))
|
||||||
|
;Main rotation
|
||||||
|
RotateCoordinates(*Drawing\CenterX, *Drawing\CenterY, PBMap\Angle)
|
||||||
|
;Clearscreen
|
||||||
VectorSourceColor(RGBA(150, 150, 150, 255))
|
VectorSourceColor(RGBA(150, 150, 150, 255))
|
||||||
FillVectorOutput()
|
FillVectorOutput()
|
||||||
;TODO add in layers of tiles ;this way we can cache them as 0 base 1.n layers
|
;TODO add in layers of tiles ;this way we can cache them as 0 base 1.n layers
|
||||||
@@ -1565,21 +1575,22 @@ Module PBMap
|
|||||||
ForEach PBMap\Layers()
|
ForEach PBMap\Layers()
|
||||||
DrawTiles(*Drawing, ListIndex(PBMap\Layers()))
|
DrawTiles(*Drawing, ListIndex(PBMap\Layers()))
|
||||||
Next
|
Next
|
||||||
|
If PBMap\Options\ShowDegrees And PBMap\Zoom > 2
|
||||||
|
DrawDegrees(*Drawing, 192)
|
||||||
|
EndIf
|
||||||
If PBMap\Options\ShowTrack
|
If PBMap\Options\ShowTrack
|
||||||
DrawTracks(*Drawing)
|
DrawTracks(*Drawing)
|
||||||
EndIf
|
EndIf
|
||||||
If PBMap\Options\ShowMarkers
|
If PBMap\Options\ShowMarkers
|
||||||
DrawMarkers(*Drawing)
|
DrawMarkers(*Drawing)
|
||||||
EndIf
|
EndIf
|
||||||
|
ResetCoordinates()
|
||||||
If PBMap\Options\ShowPointer
|
If PBMap\Options\ShowPointer
|
||||||
DrawPointer(*Drawing)
|
DrawPointer(*Drawing)
|
||||||
EndIf
|
EndIf
|
||||||
If PBMap\Options\ShowDebugInfos
|
If PBMap\Options\ShowDebugInfos
|
||||||
DrawDebugInfos(*Drawing)
|
DrawDebugInfos(*Drawing)
|
||||||
EndIf
|
EndIf
|
||||||
If PBMap\Options\ShowDegrees And PBMap\Zoom > 2
|
|
||||||
DrawDegrees(*Drawing, 192)
|
|
||||||
EndIf
|
|
||||||
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
|
||||||
@@ -1724,6 +1735,16 @@ Module PBMap
|
|||||||
EndIf
|
EndIf
|
||||||
EndProcedure
|
EndProcedure
|
||||||
|
|
||||||
|
Procedure SetAngle(Angle.d, Mode = #PB_Absolute)
|
||||||
|
If Mode = #PB_Absolute
|
||||||
|
PBmap\Angle = Angle
|
||||||
|
Else
|
||||||
|
PBMap\Angle + Angle
|
||||||
|
PBMap\Angle = Mod(PBMap\Angle,360)
|
||||||
|
EndIf
|
||||||
|
PBMap\Redraw = #True
|
||||||
|
EndProcedure
|
||||||
|
|
||||||
Procedure SetCallBackLocation(CallBackLocation.i)
|
Procedure SetCallBackLocation(CallBackLocation.i)
|
||||||
PBMap\CallBackLocation = CallBackLocation
|
PBMap\CallBackLocation = CallBackLocation
|
||||||
EndProcedure
|
EndProcedure
|
||||||
@@ -1751,14 +1772,8 @@ Module PBMap
|
|||||||
ProcedureReturn PBMap\Mode
|
ProcedureReturn PBMap\Mode
|
||||||
EndProcedure
|
EndProcedure
|
||||||
|
|
||||||
;Zoom on x, y position relative to the canvas gadget
|
;Zoom on x, y pixel position from the center
|
||||||
Procedure SetZoomOnPosition(x, y, zoom)
|
Procedure ZoomOnPixel(x, y, zoom)
|
||||||
Protected MouseX.d, MouseY.d
|
|
||||||
Protected OldPx.d, OldPy.d, OldMx.d, OldMy.d, Px.d, Py.d
|
|
||||||
Protected CenterX = GadgetWidth(PBMap\Gadget) / 2
|
|
||||||
Protected CenterY = GadgetHeight(PBMap\Gadget) / 2
|
|
||||||
x - CenterX
|
|
||||||
y - CenterY
|
|
||||||
;*** First : Zoom
|
;*** First : Zoom
|
||||||
PBMap\Zoom + zoom
|
PBMap\Zoom + zoom
|
||||||
If PBMap\Zoom > PBMap\ZoomMax : PBMap\Zoom = PBMap\ZoomMax : ProcedureReturn : EndIf
|
If PBMap\Zoom > PBMap\ZoomMax : PBMap\Zoom = PBMap\ZoomMax : ProcedureReturn : EndIf
|
||||||
@@ -1780,7 +1795,16 @@ Module PBMap
|
|||||||
EndIf
|
EndIf
|
||||||
EndProcedure
|
EndProcedure
|
||||||
|
|
||||||
;Go to x, y position relative to the canvas gadget
|
;Zoom on x, y position relative to the canvas gadget
|
||||||
|
Procedure ZoomOnPixelRel(x, y, zoom)
|
||||||
|
Protected CenterX = GadgetWidth(PBMap\Gadget) / 2
|
||||||
|
Protected CenterY = GadgetHeight(PBMap\Gadget) / 2
|
||||||
|
x - CenterX
|
||||||
|
y - CenterY
|
||||||
|
ZoomOnPixel(x, y, zoom)
|
||||||
|
EndProcedure
|
||||||
|
|
||||||
|
;Go to x, y position relative to the canvas gadget left up
|
||||||
Procedure GotoPixelRel(x, y)
|
Procedure GotoPixelRel(x, y)
|
||||||
Protected CenterX = GadgetWidth(PBMap\Gadget) / 2
|
Protected CenterX = GadgetWidth(PBMap\Gadget) / 2
|
||||||
Protected CenterY = GadgetHeight(PBMap\Gadget) / 2
|
Protected CenterY = GadgetHeight(PBMap\Gadget) / 2
|
||||||
@@ -1798,6 +1822,19 @@ Module PBMap
|
|||||||
EndIf
|
EndIf
|
||||||
EndProcedure
|
EndProcedure
|
||||||
|
|
||||||
|
;Go to x, y position relative to the canvas gadget
|
||||||
|
Procedure GotoPixel(x, y)
|
||||||
|
PBMap\PixelCoordinates\x = x
|
||||||
|
PBMap\PixelCoordinates\y = y
|
||||||
|
Pixel2LatLon(@PBMap\PixelCoordinates, @PBMap\GeographicCoordinates, PBMap\Zoom)
|
||||||
|
; Start drawing
|
||||||
|
PBMap\Redraw = #True
|
||||||
|
; If CallBackLocation send Location to function
|
||||||
|
If PBMap\CallBackLocation > 0
|
||||||
|
CallFunctionFast(PBMap\CallBackLocation, @PBMap\GeographicCoordinates)
|
||||||
|
EndIf
|
||||||
|
EndProcedure
|
||||||
|
|
||||||
Procedure.d GetLatitude()
|
Procedure.d GetLatitude()
|
||||||
ProcedureReturn PBMap\GeographicCoordinates\Latitude
|
ProcedureReturn PBMap\GeographicCoordinates\Latitude
|
||||||
EndProcedure
|
EndProcedure
|
||||||
@@ -1807,9 +1844,11 @@ Module PBMap
|
|||||||
EndProcedure
|
EndProcedure
|
||||||
|
|
||||||
Procedure.i GetZoom()
|
Procedure.i GetZoom()
|
||||||
Protected Value.d
|
ProcedureReturn PBMap\Zoom
|
||||||
Value = PBMap\Zoom
|
EndProcedure
|
||||||
ProcedureReturn Value
|
|
||||||
|
Procedure.d GetAngle()
|
||||||
|
ProcedureReturn PBMap\Angle
|
||||||
EndProcedure
|
EndProcedure
|
||||||
|
|
||||||
Procedure NominatimGeoLocationQuery(Address.s, *ReturnPosition.GeographicCoordinates = 0)
|
Procedure NominatimGeoLocationQuery(Address.s, *ReturnPosition.GeographicCoordinates = 0)
|
||||||
@@ -1850,13 +1889,23 @@ Module PBMap
|
|||||||
EndProcedure
|
EndProcedure
|
||||||
|
|
||||||
Procedure CanvasEvents()
|
Procedure CanvasEvents()
|
||||||
Protected MouseX.i, MouseY.i
|
Protected CanvasMouseX.d, CanvasMouseY.d, MouseX.d, MouseY.d
|
||||||
Protected MarkerCoords.PixelCoordinates, *Tile.Tile, MapWidth = Pow(2, PBMap\Zoom) * PBMap\TileSize
|
Protected MarkerCoords.PixelCoordinates, *Tile.Tile, MapWidth = Pow(2, PBMap\Zoom) * PBMap\TileSize
|
||||||
Protected key.s, Touch.i
|
Protected key.s, Touch.i
|
||||||
Protected Pixel.PixelCoordinates
|
Protected Pixel.PixelCoordinates
|
||||||
Static CtrlKey
|
Static CtrlKey
|
||||||
PBMap\Moving = #False
|
PBMap\Moving = #False
|
||||||
|
CanvasMouseX = GetGadgetAttribute(PBMap\Gadget, #PB_Canvas_MouseX) - PBMap\Drawing\CenterX
|
||||||
|
CanvasMouseY = GetGadgetAttribute(PBMap\Gadget, #PB_Canvas_MouseY) - PBMap\Drawing\CenterY
|
||||||
|
StartVectorDrawing(CanvasVectorOutput(PBMap\Gadget))
|
||||||
|
RotateCoordinates(PBMap\Drawing\CenterX, PBMap\Drawing\CenterY, PBMap\Angle)
|
||||||
|
CanvasMouseX = ConvertCoordinateX(CanvasMouseX, CanvasMouseY, #PB_Coordinate_Device, #PB_Coordinate_User)
|
||||||
|
CanvasMouseY = ConvertCoordinateY(CanvasMouseX, CanvasMouseY, #PB_Coordinate_Device, #PB_Coordinate_User)
|
||||||
|
StopVectorDrawing()
|
||||||
Select EventType()
|
Select EventType()
|
||||||
|
Case #PB_EventType_Focus
|
||||||
|
PBMap\Drawing\CenterX = GadgetWidth(PBMap\Gadget) / 2
|
||||||
|
PBMap\Drawing\CenterY = GadgetHeight(PBMap\Gadget) / 2
|
||||||
Case #PB_EventType_KeyUp
|
Case #PB_EventType_KeyUp
|
||||||
Select GetGadgetAttribute(PBMap\Gadget, #PB_Canvas_Key)
|
Select GetGadgetAttribute(PBMap\Gadget, #PB_Canvas_Key)
|
||||||
Case #PB_Shortcut_Delete
|
Case #PB_Shortcut_Delete
|
||||||
@@ -1902,8 +1951,8 @@ Module PBMap
|
|||||||
EndIf
|
EndIf
|
||||||
Case #PB_EventType_LeftDoubleClick
|
Case #PB_EventType_LeftDoubleClick
|
||||||
LatLon2Pixel(@PBMap\GeographicCoordinates, @PBMap\PixelCoordinates, PBMap\Zoom)
|
LatLon2Pixel(@PBMap\GeographicCoordinates, @PBMap\PixelCoordinates, PBMap\Zoom)
|
||||||
MouseX = PBMap\PixelCoordinates\x - GadgetWidth(PBMap\Gadget) / 2 + GetGadgetAttribute(PBMap\Gadget, #PB_Canvas_MouseX)
|
MouseX = PBMap\PixelCoordinates\x + CanvasMouseX
|
||||||
MouseY = PBMap\PixelCoordinates\y - GadgetHeight(PBMap\Gadget) / 2 + GetGadgetAttribute(PBMap\Gadget, #PB_Canvas_MouseY)
|
MouseY = PBMap\PixelCoordinates\y + CanvasMouseY
|
||||||
;Clip MouseX to the map range (in X, the map is infinite)
|
;Clip MouseX to the map range (in X, the map is infinite)
|
||||||
MouseX = Mod(Mod(MouseX, MapWidth) + MapWidth, MapWidth)
|
MouseX = Mod(Mod(MouseX, MapWidth) + MapWidth, MapWidth)
|
||||||
Touch = #False
|
Touch = #False
|
||||||
@@ -1923,22 +1972,23 @@ Module PBMap
|
|||||||
EndIf
|
EndIf
|
||||||
Next
|
Next
|
||||||
If Not Touch
|
If Not Touch
|
||||||
GotoPixelRel(GetGadgetAttribute(PBMap\Gadget, #PB_Canvas_MouseX), GetGadgetAttribute(PBMap\Gadget, #PB_Canvas_MouseY))
|
GotoPixel(MouseX, MouseY)
|
||||||
EndIf
|
EndIf
|
||||||
Case #PB_EventType_MouseWheel
|
Case #PB_EventType_MouseWheel
|
||||||
If PBMap\Options\WheelMouseRelative
|
If PBMap\Options\WheelMouseRelative
|
||||||
;Relative zoom (centered on the mouse)
|
;Relative zoom (centered on the mouse)
|
||||||
SetZoomOnPosition(GetGadgetAttribute(PBMap\Gadget, #PB_Canvas_MouseX), GetGadgetAttribute(PBMap\Gadget, #PB_Canvas_MouseY), GetGadgetAttribute(PBMap\Gadget, #PB_Canvas_WheelDelta))
|
ZoomOnPixel(CanvasMouseX, CanvasMouseY, GetGadgetAttribute(PBMap\Gadget, #PB_Canvas_WheelDelta))
|
||||||
Else
|
Else
|
||||||
;Absolute zoom (centered on the center of the map)
|
;Absolute zoom (centered on the center of the map)
|
||||||
SetZoom(GetGadgetAttribute(PBMap\Gadget, #PB_Canvas_WheelDelta), #PB_Relative)
|
SetZoom(GetGadgetAttribute(PBMap\Gadget, #PB_Canvas_WheelDelta), #PB_Relative)
|
||||||
EndIf
|
EndIf
|
||||||
Case #PB_EventType_LeftButtonDown
|
Case #PB_EventType_LeftButtonDown
|
||||||
LatLon2Pixel(@PBMap\GeographicCoordinates, @PBMap\PixelCoordinates, PBMap\Zoom)
|
;LatLon2Pixel(@PBMap\GeographicCoordinates, @PBMap\PixelCoordinates, PBMap\Zoom)
|
||||||
MouseX = PBMap\PixelCoordinates\x - GadgetWidth(PBMap\Gadget) / 2 + GetGadgetAttribute(PBMap\Gadget, #PB_Canvas_MouseX)
|
;Mem cursor Coord
|
||||||
MouseY = PBMap\PixelCoordinates\y - GadgetHeight(PBMap\Gadget) / 2 + GetGadgetAttribute(PBMap\Gadget, #PB_Canvas_MouseY)
|
PBMap\MoveStartingPoint\x = CanvasMouseX
|
||||||
|
PBMap\MoveStartingPoint\y = CanvasMouseY
|
||||||
;Clip MouseX to the map range (in X, the map is infinite)
|
;Clip MouseX to the map range (in X, the map is infinite)
|
||||||
MouseX = Mod(Mod(MouseX, MapWidth) + MapWidth, MapWidth)
|
PBMap\MoveStartingPoint\x = Mod(Mod(PBMap\MoveStartingPoint\x, MapWidth) + MapWidth, MapWidth)
|
||||||
If PBMap\Mode = #MODE_DEFAULT Or PBMap\Mode = #MODE_SELECT
|
If PBMap\Mode = #MODE_DEFAULT Or PBMap\Mode = #MODE_SELECT
|
||||||
PBMap\EditMarker = #False
|
PBMap\EditMarker = #False
|
||||||
;Check if we select marker(s)
|
;Check if we select marker(s)
|
||||||
@@ -1963,14 +2013,14 @@ Module PBMap
|
|||||||
EndIf
|
EndIf
|
||||||
Next
|
Next
|
||||||
EndIf
|
EndIf
|
||||||
;Mem cursor Coord
|
|
||||||
PBMap\MoveStartingPoint\x = GetGadgetAttribute(PBMap\Gadget, #PB_Canvas_MouseX)
|
|
||||||
PBMap\MoveStartingPoint\y = GetGadgetAttribute(PBMap\Gadget, #PB_Canvas_MouseY)
|
|
||||||
Case #PB_EventType_MouseMove
|
Case #PB_EventType_MouseMove
|
||||||
PBMap\Moving = #True
|
PBMap\Moving = #True
|
||||||
|
; Drag
|
||||||
If PBMap\MoveStartingPoint\x <> - 1
|
If PBMap\MoveStartingPoint\x <> - 1
|
||||||
MouseX = GetGadgetAttribute(PBMap\Gadget, #PB_Canvas_MouseX) - PBMap\MoveStartingPoint\x
|
MouseX = CanvasMouseX - PBMap\MoveStartingPoint\x
|
||||||
MouseY = GetGadgetAttribute(PBMap\Gadget, #PB_Canvas_MouseY) - PBMap\MoveStartingPoint\y
|
MouseY = CanvasMouseY - PBMap\MoveStartingPoint\y
|
||||||
|
PBMap\MoveStartingPoint\x = CanvasMouseX
|
||||||
|
PBMap\MoveStartingPoint\y = CanvasMouseY
|
||||||
;Move selected markers
|
;Move selected markers
|
||||||
If PBMap\EditMarker And (PBMap\Mode = #MODE_DEFAULT Or PBMap\Mode = #MODE_SELECT)
|
If PBMap\EditMarker And (PBMap\Mode = #MODE_DEFAULT Or PBMap\Mode = #MODE_SELECT)
|
||||||
ForEach PBMap\Markers()
|
ForEach PBMap\Markers()
|
||||||
@@ -1994,13 +2044,12 @@ Module PBMap
|
|||||||
CallFunctionFast(PBMap\CallBackLocation, @PBMap\GeographicCoordinates)
|
CallFunctionFast(PBMap\CallBackLocation, @PBMap\GeographicCoordinates)
|
||||||
EndIf
|
EndIf
|
||||||
EndIf
|
EndIf
|
||||||
PBMap\MoveStartingPoint\x = GetGadgetAttribute(PBMap\Gadget, #PB_Canvas_MouseX)
|
|
||||||
PBMap\MoveStartingPoint\y = GetGadgetAttribute(PBMap\Gadget, #PB_Canvas_MouseY)
|
|
||||||
PBMap\Redraw = #True
|
PBMap\Redraw = #True
|
||||||
Else
|
Else
|
||||||
|
; Touch test
|
||||||
LatLon2Pixel(@PBMap\GeographicCoordinates, @PBMap\PixelCoordinates, PBMap\Zoom)
|
LatLon2Pixel(@PBMap\GeographicCoordinates, @PBMap\PixelCoordinates, PBMap\Zoom)
|
||||||
MouseX = PBMap\PixelCoordinates\x - GadgetWidth(PBMap\Gadget) / 2 + GetGadgetAttribute(PBMap\Gadget, #PB_Canvas_MouseX)
|
MouseX = PBMap\PixelCoordinates\x + CanvasMouseX
|
||||||
MouseY = PBMap\PixelCoordinates\y - GadgetHeight(PBMap\Gadget) / 2 + GetGadgetAttribute(PBMap\Gadget, #PB_Canvas_MouseY)
|
MouseY = PBMap\PixelCoordinates\y + CanvasMouseY
|
||||||
;Clip MouseX to the map range (in X, the map is infinite)
|
;Clip MouseX to the map range (in X, the map is infinite)
|
||||||
MouseX = Mod(Mod(MouseX, MapWidth) + MapWidth, MapWidth)
|
MouseX = Mod(Mod(MouseX, MapWidth) + MapWidth, MapWidth)
|
||||||
If PBMap\Mode = #MODE_DEFAULT Or PBMap\Mode = #MODE_SELECT Or PBMap\Mode = #MODE_EDIT
|
If PBMap\Mode = #MODE_DEFAULT Or PBMap\Mode = #MODE_SELECT Or PBMap\Mode = #MODE_EDIT
|
||||||
@@ -2010,10 +2059,10 @@ Module PBMap
|
|||||||
If Distance(MarkerCoords\x, MarkerCoords\y, MouseX, MouseY) < 8
|
If Distance(MarkerCoords\x, MarkerCoords\y, MouseX, MouseY) < 8
|
||||||
PBMap\Markers()\Focus = #True
|
PBMap\Markers()\Focus = #True
|
||||||
PBMap\Redraw = #True
|
PBMap\Redraw = #True
|
||||||
Else
|
ElseIf PBMap\Markers()\Focus
|
||||||
;If CtrlKey = #False
|
;If CtrlKey = #False
|
||||||
PBMap\Markers()\Focus = #False
|
PBMap\Markers()\Focus = #False
|
||||||
;EndIf
|
PBMap\Redraw = #True
|
||||||
EndIf
|
EndIf
|
||||||
Next
|
Next
|
||||||
;Check if mouse touch tracks
|
;Check if mouse touch tracks
|
||||||
@@ -2024,20 +2073,22 @@ Module PBMap
|
|||||||
If ListSize(\Track()) > 0
|
If ListSize(\Track()) > 0
|
||||||
If \Visible
|
If \Visible
|
||||||
StartVectorDrawing(CanvasVectorOutput(PBMap\Gadget))
|
StartVectorDrawing(CanvasVectorOutput(PBMap\Gadget))
|
||||||
|
RotateCoordinates(PBMap\Drawing\CenterX, PBMap\Drawing\CenterY, PBMap\Angle)
|
||||||
;Simulate tracks drawing
|
;Simulate tracks drawing
|
||||||
ForEach \Track()
|
ForEach \Track()
|
||||||
LatLon2PixelRel(@PBMap\TracksList()\Track(), @Pixel, PBMap\Zoom)
|
LatLon2Pixel(@PBMap\TracksList()\Track(), @Pixel, PBMap\Zoom)
|
||||||
If ListIndex(\Track()) = 0
|
If ListIndex(\Track()) = 0
|
||||||
MovePathCursor(Pixel\X, Pixel\Y)
|
MovePathCursor(Pixel\x, Pixel\y)
|
||||||
Else
|
Else
|
||||||
AddPathLine(Pixel\X, Pixel\Y)
|
AddPathLine(Pixel\x, Pixel\y)
|
||||||
EndIf
|
EndIf
|
||||||
Next
|
Next
|
||||||
If IsInsideStroke(GetGadgetAttribute(PBMap\Gadget, #PB_Canvas_MouseX), GetGadgetAttribute(PBMap\Gadget, #PB_Canvas_MouseY), \StrokeWidth)
|
If IsInsideStroke(MouseX, MouseY, \StrokeWidth)
|
||||||
\Focus = #True
|
\Focus = #True
|
||||||
PBMap\Redraw = #True
|
PBMap\Redraw = #True
|
||||||
Else
|
ElseIf \Focus
|
||||||
\Focus = #False
|
\Focus = #False
|
||||||
|
PBMap\Redraw = #True
|
||||||
EndIf
|
EndIf
|
||||||
StopVectorDrawing()
|
StopVectorDrawing()
|
||||||
EndIf
|
EndIf
|
||||||
@@ -2082,6 +2133,8 @@ Module PBMap
|
|||||||
BindGadgetEvent(PBMap\Gadget, @CanvasEvents())
|
BindGadgetEvent(PBMap\Gadget, @CanvasEvents())
|
||||||
AddWindowTimer(PBMap\Window, PBMap\Timer, PBMap\Options\TimerInterval)
|
AddWindowTimer(PBMap\Window, PBMap\Timer, PBMap\Options\TimerInterval)
|
||||||
BindEvent(#PB_Event_Timer, @TimerEvents())
|
BindEvent(#PB_Event_Timer, @TimerEvents())
|
||||||
|
PBMap\Drawing\CenterX = GadgetWidth(PBMap\Gadget) / 2
|
||||||
|
PBMap\Drawing\CenterX = GadgetHeight(PBMap\Gadget) / 2
|
||||||
EndProcedure
|
EndProcedure
|
||||||
|
|
||||||
; Creates a canvas and attach our map
|
; Creates a canvas and attach our map
|
||||||
@@ -2132,6 +2185,8 @@ CompilerIf #PB_Compiler_IsMainFile
|
|||||||
#Gdt_Right
|
#Gdt_Right
|
||||||
#Gdt_Up
|
#Gdt_Up
|
||||||
#Gdt_Down
|
#Gdt_Down
|
||||||
|
#Gdt_RotateLeft
|
||||||
|
#Gdt_RotateRight
|
||||||
#Button_4
|
#Button_4
|
||||||
#Button_5
|
#Button_5
|
||||||
#Combo_0
|
#Combo_0
|
||||||
@@ -2199,6 +2254,8 @@ CompilerIf #PB_Compiler_IsMainFile
|
|||||||
ResizeGadget(#Text_1,WindowWidth(#Window_0)-170,#PB_Ignore,#PB_Ignore,#PB_Ignore)
|
ResizeGadget(#Text_1,WindowWidth(#Window_0)-170,#PB_Ignore,#PB_Ignore,#PB_Ignore)
|
||||||
ResizeGadget(#Gdt_Left, WindowWidth(#Window_0) - 150 ,#PB_Ignore,#PB_Ignore,#PB_Ignore)
|
ResizeGadget(#Gdt_Left, WindowWidth(#Window_0) - 150 ,#PB_Ignore,#PB_Ignore,#PB_Ignore)
|
||||||
ResizeGadget(#Gdt_Right,WindowWidth(#Window_0) - 90 ,#PB_Ignore,#PB_Ignore,#PB_Ignore)
|
ResizeGadget(#Gdt_Right,WindowWidth(#Window_0) - 90 ,#PB_Ignore,#PB_Ignore,#PB_Ignore)
|
||||||
|
ResizeGadget(#Gdt_RotateLeft, WindowWidth(#Window_0) - 150 ,#PB_Ignore,#PB_Ignore,#PB_Ignore)
|
||||||
|
ResizeGadget(#Gdt_RotateRight,WindowWidth(#Window_0) - 90 ,#PB_Ignore,#PB_Ignore,#PB_Ignore)
|
||||||
ResizeGadget(#Gdt_Up, WindowWidth(#Window_0) - 120 ,#PB_Ignore,#PB_Ignore,#PB_Ignore)
|
ResizeGadget(#Gdt_Up, WindowWidth(#Window_0) - 120 ,#PB_Ignore,#PB_Ignore,#PB_Ignore)
|
||||||
ResizeGadget(#Gdt_Down, WindowWidth(#Window_0) - 120 ,#PB_Ignore,#PB_Ignore,#PB_Ignore)
|
ResizeGadget(#Gdt_Down, WindowWidth(#Window_0) - 120 ,#PB_Ignore,#PB_Ignore,#PB_Ignore)
|
||||||
ResizeGadget(#Text_2,WindowWidth(#Window_0)-170,#PB_Ignore,#PB_Ignore,#PB_Ignore)
|
ResizeGadget(#Text_2,WindowWidth(#Window_0)-170,#PB_Ignore,#PB_Ignore,#PB_Ignore)
|
||||||
@@ -2223,8 +2280,11 @@ CompilerIf #PB_Compiler_IsMainFile
|
|||||||
|
|
||||||
LoadFont(0, "Arial", 12)
|
LoadFont(0, "Arial", 12)
|
||||||
LoadFont(1, "Arial", 12, #PB_Font_Bold)
|
LoadFont(1, "Arial", 12, #PB_Font_Bold)
|
||||||
|
LoadFont(2, "Arial", 8)
|
||||||
|
|
||||||
TextGadget(#Text_1, 530, 50, 60, 15, "Movements")
|
TextGadget(#Text_1, 530, 50, 60, 15, "Movements")
|
||||||
|
ButtonGadget(#Gdt_RotateLeft, 550, 070, 30, 30, "LRot") : SetGadgetFont(#Gdt_RotateLeft, FontID(2))
|
||||||
|
ButtonGadget(#Gdt_RotateRight, 610, 070, 30, 30, "RRot") : SetGadgetFont(#Gdt_RotateRight, FontID(2))
|
||||||
ButtonGadget(#Gdt_Left, 550, 100, 30, 30, Chr($25C4)) : SetGadgetFont(#Gdt_Left, FontID(0))
|
ButtonGadget(#Gdt_Left, 550, 100, 30, 30, Chr($25C4)) : SetGadgetFont(#Gdt_Left, FontID(0))
|
||||||
ButtonGadget(#Gdt_Right, 610, 100, 30, 30, Chr($25BA)) : SetGadgetFont(#Gdt_Right, FontID(0))
|
ButtonGadget(#Gdt_Right, 610, 100, 30, 30, Chr($25BA)) : SetGadgetFont(#Gdt_Right, FontID(0))
|
||||||
ButtonGadget(#Gdt_Up, 580, 070, 30, 30, Chr($25B2)) : SetGadgetFont(#Gdt_Up, FontID(0))
|
ButtonGadget(#Gdt_Up, 580, 070, 30, 30, Chr($25B2)) : SetGadgetFont(#Gdt_Up, FontID(0))
|
||||||
@@ -2288,6 +2348,12 @@ CompilerIf #PB_Compiler_IsMainFile
|
|||||||
PBMap::SetLocation(0, 10* -360 / Pow(2, PBMap::GetZoom() + 8), 0, #PB_Relative)
|
PBMap::SetLocation(0, 10* -360 / Pow(2, PBMap::GetZoom() + 8), 0, #PB_Relative)
|
||||||
Case #Gdt_Right
|
Case #Gdt_Right
|
||||||
PBMap::SetLocation(0, 10* 360 / Pow(2, PBMap::GetZoom() + 8), 0, #PB_Relative)
|
PBMap::SetLocation(0, 10* 360 / Pow(2, PBMap::GetZoom() + 8), 0, #PB_Relative)
|
||||||
|
Case #Gdt_RotateLeft
|
||||||
|
PBMAP::SetAngle(-5,#PB_Relative)
|
||||||
|
PBMap::Refresh()
|
||||||
|
Case #Gdt_RotateRight
|
||||||
|
PBMAP::SetAngle(5,#PB_Relative)
|
||||||
|
PBMap::Refresh()
|
||||||
Case #Button_4
|
Case #Button_4
|
||||||
PBMap::SetZoom(1)
|
PBMap::SetZoom(1)
|
||||||
Case #Button_5
|
Case #Button_5
|
||||||
@@ -2362,8 +2428,9 @@ CompilerEndIf
|
|||||||
|
|
||||||
|
|
||||||
; IDE Options = PureBasic 5.50 (Windows - x64)
|
; IDE Options = PureBasic 5.50 (Windows - x64)
|
||||||
; CursorPosition = 10
|
; CursorPosition = 2094
|
||||||
; Folding = ----------------
|
; FirstLine = 2070
|
||||||
|
; Folding = -----------------
|
||||||
; EnableThread
|
; EnableThread
|
||||||
; EnableXP
|
; EnableXP
|
||||||
; EnableUnicode
|
; EnableUnicode
|
Reference in New Issue
Block a user