LazMapViewer: Improved usability of Map Points Editor.

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@9672 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz 2025-03-10 22:28:35 +00:00
parent d46dae3faa
commit e8c36f1bc2
2 changed files with 135 additions and 68 deletions

View File

@ -1,25 +1,25 @@
object MapViewerPathEditForm: TMapViewerPathEditForm
Left = 749
Left = 1036
Height = 227
Top = 324
Width = 324
Top = 315
Width = 413
AutoSize = True
BorderStyle = bsSizeToolWin
Caption = 'MapViewer Path Editor'
ClientHeight = 227
ClientWidth = 324
ClientWidth = 413
LCLVersion = '4.99.0.0'
OnActivate = FormActivate
OnShow = FormShow
object pnlFrame: TPanel
Left = 0
Height = 161
Height = 157
Top = 28
Width = 324
Width = 413
Align = alClient
BevelOuter = bvNone
ClientHeight = 161
ClientWidth = 324
ClientHeight = 157
ClientWidth = 413
TabOrder = 0
object lblSelectedLayer: TLabel
AnchorSideTop.Control = cbSelectedLayer
@ -27,7 +27,7 @@ object MapViewerPathEditForm: TMapViewerPathEditForm
AnchorSideRight.Control = cbSelectedLayer
Left = 32
Height = 15
Top = 121
Top = 127
Width = 31
Alignment = taRightJustify
Anchors = [akTop, akRight]
@ -42,12 +42,12 @@ object MapViewerPathEditForm: TMapViewerPathEditForm
AnchorSideRight.Side = asrBottom
Left = 68
Height = 23
Top = 117
Width = 253
Top = 123
Width = 342
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Top = 3
BorderSpacing.Top = 6
BorderSpacing.Right = 3
BorderSpacing.Bottom = 3
BorderSpacing.Bottom = 6
ItemHeight = 15
ParentColor = True
ParentShowHint = False
@ -63,28 +63,28 @@ object MapViewerPathEditForm: TMapViewerPathEditForm
AnchorSideRight.Control = pnlFrame
AnchorSideRight.Side = asrBottom
Left = 3
Height = 111
Height = 114
Top = 3
Width = 318
Width = 407
Anchors = [akTop, akLeft, akRight]
AutoSize = True
BorderSpacing.Around = 3
BevelInner = bvRaised
BevelOuter = bvLowered
ClientHeight = 111
ClientWidth = 318
ClientHeight = 114
ClientWidth = 407
TabOrder = 1
object lblSelectedPt: TLabel
AnchorSideLeft.Control = pnlSel
AnchorSideTop.Control = cbSelectedPt
AnchorSideTop.Side = asrCenter
AnchorSideRight.Control = cbSelectedPt
Left = 8
Left = 14
Height = 15
Top = 9
Width = 51
Alignment = taRightJustify
BorderSpacing.Left = 6
BorderSpacing.Left = 12
BorderSpacing.Right = 6
Caption = 'Selection:'
ParentColor = False
@ -95,10 +95,10 @@ object MapViewerPathEditForm: TMapViewerPathEditForm
AnchorSideTop.Control = pnlSel
AnchorSideRight.Control = pnlSel
AnchorSideRight.Side = asrBottom
Left = 65
Left = 71
Height = 23
Top = 5
Width = 248
Width = 331
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Top = 3
BorderSpacing.Right = 3
@ -110,29 +110,30 @@ object MapViewerPathEditForm: TMapViewerPathEditForm
TabOrder = 0
end
object lblLat: TLabel
AnchorSideLeft.Control = pnlSel
AnchorSideTop.Control = cbLat
AnchorSideTop.Side = asrCenter
AnchorSideRight.Control = cbLat
Left = 40
AnchorSideRight.Control = lblSelectedPt
AnchorSideRight.Side = asrBottom
Left = 19
Height = 15
Top = 35
Width = 19
Width = 46
Alignment = taRightJustify
Anchors = [akTop, akRight]
BorderSpacing.Right = 6
Caption = 'Lat:'
BorderSpacing.Left = 6
Caption = 'Latitude:'
ParentColor = False
end
object cbLat: TEdit
AnchorSideLeft.Control = cbSelectedPt
AnchorSideTop.Control = cbSelectedPt
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = pnlSel
AnchorSideRight.Side = asrBottom
Left = 65
Left = 71
Height = 23
Top = 31
Width = 131
Width = 115
BorderSpacing.Top = 3
BorderSpacing.Right = 3
BorderSpacing.Bottom = 3
@ -146,15 +147,16 @@ object MapViewerPathEditForm: TMapViewerPathEditForm
object lblLon: TLabel
AnchorSideTop.Control = cbLon
AnchorSideTop.Side = asrCenter
AnchorSideRight.Control = cbLon
Left = 36
AnchorSideRight.Control = lblSelectedPt
AnchorSideRight.Side = asrBottom
Left = 8
Height = 15
Top = 61
Width = 23
Width = 57
Alignment = taRightJustify
Anchors = [akTop, akRight]
BorderSpacing.Right = 6
Caption = 'Lon:'
BorderSpacing.Left = 6
Caption = 'Longitude:'
ParentColor = False
end
object cbLon: TEdit
@ -164,10 +166,10 @@ object MapViewerPathEditForm: TMapViewerPathEditForm
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = pnlSel
AnchorSideRight.Side = asrBottom
Left = 65
Left = 71
Height = 23
Top = 57
Width = 131
Width = 115
BorderSpacing.Right = 3
BorderSpacing.Bottom = 3
ParentShowHint = False
@ -183,53 +185,56 @@ object MapViewerPathEditForm: TMapViewerPathEditForm
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = pnlSel
AnchorSideRight.Side = asrBottom
Left = 65
Left = 71
Height = 23
Top = 83
Width = 248
Width = 331
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Top = 3
BorderSpacing.Right = 3
BorderSpacing.Bottom = 3
BorderSpacing.Bottom = 6
TabOrder = 3
OnEditingDone = edCaptionEditingDone
end
object lblCaption: TLabel
AnchorSideTop.Control = edCaption
AnchorSideTop.Side = asrCenter
AnchorSideRight.Control = edCaption
Left = 17
AnchorSideRight.Control = lblSelectedPt
AnchorSideRight.Side = asrBottom
Left = 20
Height = 15
Top = 87
Width = 42
Width = 45
Alignment = taRightJustify
Anchors = [akTop, akRight]
BorderSpacing.Right = 6
Caption = 'Caption'
BorderSpacing.Left = 6
Caption = 'Caption:'
end
end
end
object pnlInfo: TPanel
Left = 0
Height = 38
Top = 189
Width = 324
Height = 39
Top = 188
Width = 413
Align = alBottom
AutoSize = True
ClientHeight = 38
ClientWidth = 324
BevelOuter = bvNone
ClientHeight = 39
ClientWidth = 413
TabOrder = 1
object lblInfoTitle: TLabel
AnchorSideLeft.Control = pnlInfo
AnchorSideTop.Control = pnlInfo
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Side = asrBottom
Left = 4
Left = 6
Height = 15
Top = 4
Top = 3
Width = 59
BorderSpacing.Left = 3
BorderSpacing.Left = 6
BorderSpacing.Top = 3
BorderSpacing.Right = 3
BorderSpacing.Right = 6
Caption = 'lblInfotitle'
Font.Style = [fsBold]
Layout = tlCenter
@ -239,11 +244,11 @@ object MapViewerPathEditForm: TMapViewerPathEditForm
AnchorSideLeft.Control = lblInfoTitle
AnchorSideTop.Control = lblInfoTitle
AnchorSideTop.Side = asrBottom
Left = 4
Left = 6
Height = 15
Top = 19
Top = 18
Width = 55
BorderSpacing.Bottom = 3
BorderSpacing.Bottom = 6
Caption = 'lblInfoText'
end
end
@ -251,7 +256,7 @@ object MapViewerPathEditForm: TMapViewerPathEditForm
Left = 0
Height = 28
Top = 0
Width = 324
Width = 413
AutoSize = True
ButtonHeight = 28
ButtonWidth = 28
@ -271,15 +276,15 @@ object MapViewerPathEditForm: TMapViewerPathEditForm
Top = 0
Action = actNewPOI
end
object tbNewArea: TToolButton
object tbNewTrack: TToolButton
Left = 57
Top = 0
Action = actNewArea
Action = actNewTrack
end
object tbNewTrack: TToolButton
object tbNewArea: TToolButton
Left = 85
Top = 0
Action = actNewTrack
Action = actNewArea
end
object ToolButton6: TToolButton
Left = 113
@ -316,10 +321,20 @@ object MapViewerPathEditForm: TMapViewerPathEditForm
Action = actZoomOut
end
end
object Bevel: TBevel
Left = 3
Height = 3
Top = 185
Width = 407
Align = alBottom
BorderSpacing.Left = 3
BorderSpacing.Right = 3
Shape = bsTopLine
end
object alEditActions: TActionList
Images = ilImages
Left = 112
Top = 48
Left = 128
Top = 40
object actZoomIn: TAction
Caption = 'Zoom In'
Hint = 'Zoom In'
@ -380,8 +395,8 @@ object MapViewerPathEditForm: TMapViewerPathEditForm
end
object ilImages: TImageList
Scaled = True
Left = 240
Top = 48
Left = 272
Top = 40
Bitmap = {
4C7A080000001000000010000000970800000000000078DAED987B5054F715C7
31A689669C4E53AB12291A3133A2409DFCD1496C6C9B76D28E694D334D42C768

View File

@ -5,7 +5,7 @@ unit mvMapViewerPathEditForm;
interface
uses
Classes, ComCtrls, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls,
Classes, SysUtils, Math, Forms, Controls, Graphics, Dialogs, StdCtrls, ComCtrls,
ExtCtrls, Buttons, ActnList, mvMapViewer, mvGpsObj, mvTypes, Types;
type
@ -24,6 +24,7 @@ type
actZoomOut: TAction;
actZoomIn: TAction;
alEditActions: TActionList;
Bevel: TBevel;
cbLon: TEdit;
cbSelectedLayer: TComboBox;
cbSelectedPt: TEdit;
@ -76,6 +77,8 @@ type
FTempPolyLine: TGPSPolyLine;
FEditMode: TMapViewerPathEditMode;
FSkipAPoint: Boolean;
FActivated: Boolean;
procedure AddTempPolylineOrRevert(ANewEditMode: TMapViewerPathEditMode);
procedure SetEditMode(AValue: TMapViewerPathEditMode);
procedure CancelAddMode;
procedure AddTempPoint;
@ -140,21 +143,29 @@ end;
procedure TMapViewerPathEditForm.actSelectExecute(Sender: TObject);
begin
if (FTempPolyLine <> nil) and (FTempPolyLine.Points.Count > 0) then
AddTempPolyLineOrRevert(pemSelect);
EditMode := pemSelect;
end;
procedure TMapViewerPathEditForm.actNewPOIExecute(Sender: TObject);
begin
if (FTempPolyLine <> nil) and (FTempPolyLine.Points.Count > 0) then
AddTempPolyLineOrRevert(pemAddPOI);
EditMode := pemAddPOI;
end;
procedure TMapViewerPathEditForm.actNewTrackExecute(Sender: TObject);
begin
if (FTempPolyLine <> nil) and (FTempPolyLine.Points.Count > 0) then
AddTempPolyLineOrRevert(pemAddTrack);
EditMode := pemAddTrack;
end;
procedure TMapViewerPathEditForm.actNewAreaExecute(Sender: TObject);
begin
if (FTempPolyLine <> nil) and (FTempPolyLine.Points.Count > 0) then
AddTempPolyLineOrRevert(pemAddArea);
EditMode := pemAddArea;
end;
@ -274,6 +285,36 @@ begin
UpdateControls;
end;
{ When points for a new track or a new area are being added, but the user
selects another edit mode ("ANewEditMode"), the already prepared points
would be lost. --> We ask whether the track/area should be used or discarded. }
procedure TMapViewerPathEditForm.AddTempPolylineOrRevert(ANewEditMode: TMapViewerPathEditMode);
const
TRACK_AREA: array[boolean] of String = ('track', 'area');
var
msg: String;
begin
msg := Format(
'Click OK to really add the new %0:s.' + LineEnding +
'Click Cancel to discard the new %0:s.', [
TRACK_AREA[FEditMode = pemAddArea]
]);
if MessageDlg(msg, mtConfirmation, [mbOK, mbCancel], 0) = mrOK then
begin
case FEditMode of
pemAddArea: NewAreaFromTemp;
pemAddTrack: NewTrackFromTemp;
end;
// Tool button checked state was changed in previous command --> restore it.
case ANewEditMode of
pemSelect: actSelect.Checked := true;
pemAddPOI: actNewPOI.Checked := true;
pemAddArea: actNewArea.Checked := true;
pemAddTrack: actNewTrack.Checked := true;
end;
end;
end;
procedure TMapViewerPathEditForm.cbLatLonEditingDone(Sender: TObject);
var
E: TEdit;
@ -348,8 +389,18 @@ begin
end;
procedure TMapViewerPathEditForm.FormActivate(Sender: TObject);
var
w: Integer;
begin
if not FActivated then
begin
AutoSize := false;
w := MaxValue([lblSelectedPt.Width, lblLat.Width, lblLon.Width, lblCaption.Width]);
cbSelectedPt.Left := w + lblSelectedPt.BorderSpacing.Left + lblSelectedPt.BorderSpacing.Right;
cbSelectedLayer.Left := cbSelectedPt.Left + pnlSel.Left;
AutoSize := true;
FActivated := true;
end;
end;
procedure TMapViewerPathEditForm.FormShow(Sender: TObject);
@ -500,7 +551,8 @@ begin
FTempPolyLine.Points.Add(TGPSPoint.CreateFrom(RealPt));
if EditMode = pemAddPOI then
NewPOIFromTemp
else if ssCtrl in GetKeyShiftState then
else
if ssCtrl in GetKeyShiftState then
case EditMode of
pemAddTrack: NewTrackFromTemp;
pemAddArea: NewAreaFromTemp;