LazMapViewer: Fix loss of coordinate accuracy when dragging points at small zoom factor. Issue #39114.

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@9675 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz 2025-03-12 09:46:35 +00:00
parent adc968308b
commit 12eb71ee4e
2 changed files with 30 additions and 8 deletions

View File

@ -38,13 +38,16 @@ Type
FEndX,FEndY : integer;
FOnDrag: TDragEvent;
FOnEndDrag: TDragEvent;
function GetEndPt: TPoint;
function GetOfsPt: TPoint;
function GetStartPt: TPoint;
procedure SetDest(X,Y : Integer);
procedure SetLnkObj(AValue: TObject);
procedure SetOnDrag(AValue: TDragEvent);
procedure SetOnEndDrag(AValue: TDragEvent);
Procedure DostartDrag(X,Y: Integer);
Procedure DoStartDrag(X,Y: Integer);
Procedure DoDrag(X,Y: integer);
Procedure DoEndDrag(X,Y: integer);
Function HasMoved(X,Y: integer) : Boolean;
@ -58,12 +61,15 @@ Type
property OnDrag: TDragEvent read FOnDrag write SetOnDrag;
property OnEndDrag: TDragEvent read FOnEndDrag write SetOnEndDrag;
property OfsPt: TPoint read GetOfsPt;
property OfsX: integer read FOfsX;
property OfsY: integer read FOfsY;
property StartPt: TPoint read GetStartPt;
property StartX: integer read FStartX;
property StartY: integer read FStartY;
property MouseX: Integer read FMouseX;
property MouseY: integer read FMouseY;
property EndPt: TPoint read GetEndPt;
property EndX: integer read FEndX;
property EndY: integer read FEndY;
Property LnkObj: TObject Read FLnkObj write SetLnkObj;
@ -130,6 +136,21 @@ begin
FInDrag := False;
end;
function TDragObj.GetEndPt: TPoint;
begin
Result := Point(FEndX, FEndY);
end;
function TDragObj.GetOfsPt: TPoint;
begin
Result := Point(FOfsX, FOfsY);
end;
function TDragObj.GetStartPt: TPoint;
begin
Result := Point(FStartX, FStartY);
end;
function TDragObj.HasMoved(X, Y: integer): Boolean;
begin
Result := (X <> FStartX) or (Y <> FStartY);
@ -139,10 +160,10 @@ procedure TDragObj.AbortDrag;
begin
if FInDrag then
Begin
DoDrag(FstartX,FStartY);
DoDrag(FStartX, FStartY);
FInDrag := False;
FMouseDown := False;
FDragSrc :=nil;
FDragSrc := nil;
FStartSrc := nil;
FreeAndNil(FLnkObj);
end;

View File

@ -4781,7 +4781,7 @@ end;
procedure TMapEditMark.DoDrag(Sender: TDragObj);
var
I: Integer = 0;
RPt: TRealPoint;
RptStart, RPtEnd: TRealPoint;
MapPoint: TMapPoint;
begin
if not FDragStarted then
@ -4804,10 +4804,11 @@ begin
for MapPoint in FSelection.Points do
begin
MarkDirty;
Rpt := FMapView.ScreenToLatLon(FMapView.LatLonToScreen(FOrigins[I]) +
Point(Sender.OfsX, Sender.OfsY));
MapPoint.Longitude := RPt.Lon;
MapPoint.Latitude := RPt.Lat;
// Apply positions of drag start and end points from pixel space to real world space
RPtStart := FMapView.ScreenToLatLon(Sender.StartPt);
RPtEnd := FMapView.ScreenToLatLon(Sender.EndPt);
MapPoint.Longitude := FOrigins[I].Lon + (RPtEnd.Lon - RPtStart.Lon);
MapPoint.Latitude := FOrigins[I].Lat + (RPtEnd.Lat - RPtStart.Lat);
Inc(I);
end;
//FMapView.Invalidate; // No need to