LazMapViewer: TMapLayersPropertyEditor form added.
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@9268 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
parent
7f604013a0
commit
3689d1f46d
74
components/lazmapviewer/source/mvlayerspropeditform.lfm
Normal file
74
components/lazmapviewer/source/mvlayerspropeditform.lfm
Normal file
@ -0,0 +1,74 @@
|
||||
inherited LayersPropertyEditForm: TLayersPropertyEditForm
|
||||
Left = 350
|
||||
Height = 343
|
||||
Top = 250
|
||||
Width = 320
|
||||
Caption = 'LayersPropertyEditForm'
|
||||
ClientHeight = 343
|
||||
ClientWidth = 320
|
||||
inherited ToolBar1: TToolBar
|
||||
Height = 52
|
||||
Width = 320
|
||||
inherited DividerToolButton: TToolButton
|
||||
Height = 50
|
||||
end
|
||||
inherited MoveUpButton: TToolButton
|
||||
Left = 116
|
||||
end
|
||||
inherited MoveDownButton: TToolButton
|
||||
Left = 171
|
||||
end
|
||||
end
|
||||
inherited CollectionListBox: TListBox
|
||||
Height = 244
|
||||
Top = 52
|
||||
Width = 320
|
||||
OnClick = CollectionListBoxClick
|
||||
end
|
||||
object Panel1: TPanel[2]
|
||||
Left = 0
|
||||
Height = 47
|
||||
Top = 296
|
||||
Width = 320
|
||||
Align = alBottom
|
||||
ClientHeight = 47
|
||||
ClientWidth = 320
|
||||
ParentColor = False
|
||||
TabOrder = 2
|
||||
object btnLoad: TBitBtn
|
||||
AnchorSideLeft.Control = Panel1
|
||||
AnchorSideTop.Control = Panel1
|
||||
AnchorSideBottom.Control = Panel1
|
||||
AnchorSideBottom.Side = asrBottom
|
||||
Left = 6
|
||||
Height = 35
|
||||
Top = 6
|
||||
Width = 94
|
||||
Anchors = [akTop, akLeft, akBottom]
|
||||
BorderSpacing.Around = 5
|
||||
Caption = 'Load'
|
||||
Enabled = False
|
||||
OnClick = btnLoadClick
|
||||
TabOrder = 0
|
||||
end
|
||||
object btnSave: TBitBtn
|
||||
AnchorSideLeft.Control = btnLoad
|
||||
AnchorSideLeft.Side = asrBottom
|
||||
AnchorSideTop.Control = Panel1
|
||||
AnchorSideBottom.Control = Panel1
|
||||
AnchorSideBottom.Side = asrBottom
|
||||
Left = 105
|
||||
Height = 35
|
||||
Top = 6
|
||||
Width = 94
|
||||
Anchors = [akTop, akLeft, akBottom]
|
||||
BorderSpacing.Around = 5
|
||||
Caption = 'Save'
|
||||
Enabled = False
|
||||
OnClick = btnSaveClick
|
||||
TabOrder = 1
|
||||
end
|
||||
end
|
||||
inherited ActionList1: TActionList[3]
|
||||
end
|
||||
end
|
151
components/lazmapviewer/source/mvlayerspropeditform.pas
Normal file
151
components/lazmapviewer/source/mvlayerspropeditform.pas
Normal file
@ -0,0 +1,151 @@
|
||||
unit mvLayersPropEditForm;
|
||||
|
||||
{$mode ObjFPC}{$H+}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, Forms, Controls, Graphics, Dialogs, ExtCtrls, Buttons,
|
||||
CollectionPropEditForm, mvMapViewer, mvGpsObj, mvTypes;
|
||||
|
||||
type
|
||||
|
||||
{ TLayersPropertyEditForm }
|
||||
|
||||
TLayersPropertyEditForm = class(TCollectionPropertyEditorForm)
|
||||
btnLoad: TBitBtn;
|
||||
btnSave: TBitBtn;
|
||||
Panel1: TPanel;
|
||||
procedure btnLoadClick(Sender: TObject);
|
||||
procedure btnSaveClick(Sender: TObject);
|
||||
procedure CollectionListBoxClick(Sender: TObject);
|
||||
private
|
||||
procedure UpdateVisuals;
|
||||
procedure Modified;
|
||||
procedure SaveToFile(AFileName: String; ALayer: TMapLayer);
|
||||
procedure LoadFromFile(AFileName: String; ALayer: TMapLayer);
|
||||
public
|
||||
|
||||
end;
|
||||
|
||||
var
|
||||
LayersPropertyEditForm: TLayersPropertyEditForm;
|
||||
|
||||
implementation
|
||||
|
||||
uses mvGPX, PropEdits;
|
||||
|
||||
|
||||
{$R *.lfm}
|
||||
|
||||
{ TLayersPropertyEditForm }
|
||||
|
||||
procedure TLayersPropertyEditForm.CollectionListBoxClick(Sender: TObject);
|
||||
begin
|
||||
inherited;
|
||||
UpdateVisuals;
|
||||
end;
|
||||
|
||||
procedure TLayersPropertyEditForm.btnSaveClick(Sender: TObject);
|
||||
var
|
||||
I: Integer;
|
||||
L: TMapLayer;
|
||||
begin
|
||||
if not Assigned(Collection) then
|
||||
Exit;
|
||||
I := CollectionListBox.ItemIndex;
|
||||
L := Collection.Items[I] as TMapLayer;
|
||||
with TSaveDialog.Create(Nil) do
|
||||
try
|
||||
DefaultExt := '.gpx';
|
||||
Filter := 'GPX file|*.gpx|All files|*.*';
|
||||
Options := Options + [ofOverwritePrompt, ofEnableSizing];
|
||||
FileName := L.Caption;
|
||||
if Execute then
|
||||
SaveToFile(FileName, L);
|
||||
finally
|
||||
Free;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TLayersPropertyEditForm.btnLoadClick(Sender: TObject);
|
||||
var
|
||||
I: Integer;
|
||||
L: TMapLayer;
|
||||
begin
|
||||
if not Assigned(Collection) then
|
||||
Exit;
|
||||
I := CollectionListBox.ItemIndex;
|
||||
L := Collection.Items[I] as TMapLayer;
|
||||
with TOpenDialog.Create(Nil) do
|
||||
try
|
||||
DefaultExt := '.gpx';
|
||||
Filter := 'GPX file|*.gpx|All files|*.*';
|
||||
if Execute then
|
||||
LoadFromFile(FileName, L);
|
||||
finally
|
||||
Free;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TLayersPropertyEditForm.UpdateVisuals;
|
||||
var
|
||||
I: Integer;
|
||||
begin
|
||||
I := CollectionListBox.ItemIndex;
|
||||
btnLoad.Enabled := (Collection <> Nil) {and btnLoad.Visible};
|
||||
btnSave.Enabled := (Collection <> Nil) {and btnSave.Visible};
|
||||
end;
|
||||
|
||||
procedure TLayersPropertyEditForm.Modified;
|
||||
begin
|
||||
if GlobalDesignHook <> nil then
|
||||
GlobalDesignHook.Modified(Self);
|
||||
end;
|
||||
|
||||
procedure TLayersPropertyEditForm.SaveToFile(AFileName: String; ALayer: TMapLayer);
|
||||
begin
|
||||
TGpxWriter.SaveToFile(AFileName, ALayer.ComboLayer);
|
||||
end;
|
||||
|
||||
procedure TLayersPropertyEditForm.LoadFromFile(AFileName: String;
|
||||
ALayer: TMapLayer);
|
||||
var
|
||||
List: TGpsObjectList;
|
||||
LBounds: TRealArea;
|
||||
I: Integer;
|
||||
|
||||
procedure AddPoint(APoint: TGPSPoint);
|
||||
begin
|
||||
with ALayer.PointsOfInterest.Add as TPointOfInterest do
|
||||
begin
|
||||
Caption := APoint.Name;
|
||||
Longitude := APoint.Lon;
|
||||
Latitude := APoint.Lat;
|
||||
Elevation := APoint.Elevation;
|
||||
DateTime := APoint.DateTime;
|
||||
end;
|
||||
end;
|
||||
|
||||
begin
|
||||
with TGpxReader.Create do
|
||||
try
|
||||
List := TGPSObjectList.Create;
|
||||
try
|
||||
LoadFromFile(AFileName, List, LBounds);
|
||||
for I := 0 to Pred(List.Count) do
|
||||
if List[I] is TGPSPoint then
|
||||
AddPoint(TGPSPoint(List[I]))
|
||||
else
|
||||
{TODO};
|
||||
finally
|
||||
List.Free;
|
||||
end;
|
||||
finally
|
||||
Free;
|
||||
end;
|
||||
Modified;
|
||||
end;
|
||||
|
||||
end.
|
||||
|
Loading…
Reference in New Issue
Block a user