LazMapViewer: Add area section plugin with demo. Allow to delete points in spreadmarker_demo

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@9588 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz 2025-01-15 09:59:45 +00:00
parent 3d1e300fcd
commit d89df48fd2
9 changed files with 1283 additions and 8 deletions

View File

@ -0,0 +1,89 @@
<?xml version="1.0" encoding="UTF-8"?>
<CONFIG>
<ProjectOptions>
<Version Value="12"/>
<PathDelim Value="\"/>
<General>
<SessionStorage Value="InProjectDir"/>
<Title Value="areaselection_demo"/>
<Scaled Value="True"/>
<ResourceType Value="res"/>
<UseXPManifest Value="True"/>
<XPManifest>
<DpiAware Value="True"/>
</XPManifest>
<Icon Value="0"/>
</General>
<BuildModes>
<Item Name="Default" Default="True"/>
</BuildModes>
<PublishOptions>
<Version Value="2"/>
<UseFileFilters Value="True"/>
</PublishOptions>
<RunParams>
<FormatVersion Value="2"/>
</RunParams>
<RequiredPackages>
<Item>
<PackageName Value="lazMapViewerPkg"/>
</Item>
<Item>
<PackageName Value="LCL"/>
</Item>
</RequiredPackages>
<Units>
<Unit>
<Filename Value="areaselection_demo.lpr"/>
<IsPartOfProject Value="True"/>
</Unit>
<Unit>
<Filename Value="main.pas"/>
<IsPartOfProject Value="True"/>
<ComponentName Value="Form1"/>
<HasResources Value="True"/>
<ResourceBaseClass Value="Form"/>
<UnitName Value="main"/>
</Unit>
<Unit>
<Filename Value="uareaselectionplugin.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="uAreaSelectionPlugin"/>
</Unit>
</Units>
</ProjectOptions>
<CompilerOptions>
<Version Value="11"/>
<PathDelim Value="\"/>
<Target>
<Filename Value="areaselection_demo"/>
</Target>
<SearchPaths>
<IncludeFiles Value="$(ProjOutDir)"/>
<UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/>
</SearchPaths>
<Linking>
<Debugging>
<DebugInfoType Value="dsDwarf3"/>
</Debugging>
<Options>
<Win32>
<GraphicApplication Value="True"/>
</Win32>
</Options>
</Linking>
</CompilerOptions>
<Debugging>
<Exceptions>
<Item>
<Name Value="EAbort"/>
</Item>
<Item>
<Name Value="ECodetoolError"/>
</Item>
<Item>
<Name Value="EFOpenError"/>
</Item>
</Exceptions>
</Debugging>
</CONFIG>

View File

@ -0,0 +1,24 @@
program areaselection_demo;
{$mode objfpc}{$H+}
uses
{$IFDEF UNIX}
cthreads,
{$ENDIF}
{$IFDEF HASAMIGA}
athreads,
{$ENDIF}
Interfaces, // this includes the LCL widgetset
Forms, Main, uAreaSelectionPlugin;
{$R *.res}
begin
RequireDerivedFormResource:=True;
Application.Scaled:=True;
Application.Initialize;
Application.CreateForm(TForm1, Form1);
Application.Run;
end.

View File

@ -0,0 +1,54 @@
object Form1: TForm1
Left = 324
Height = 323
Top = 119
Width = 429
Caption = 'Form1'
ClientHeight = 323
ClientWidth = 429
OnCreate = FormCreate
LCLVersion = '3.6.0.0'
object MapView1: TMapView
Left = 0
Height = 288
Top = 0
Width = 429
Active = True
Align = alClient
Cyclic = True
DownloadEngine = MapView1.BuiltInDLE
DrawingEngine = MapView1.BuiltInDE
Layers = <>
Font.Color = clBlack
MapProvider = 'OpenStreetMap Mapnik'
PluginManager = MvPluginManager1
end
object Panel1: TPanel
Left = 0
Height = 35
Top = 288
Width = 429
Align = alBottom
ClientHeight = 35
ClientWidth = 429
TabOrder = 1
object lblSelArea: TLabel
Left = 88
Height = 15
Top = 8
Width = 18
Caption = 'n/a'
end
object Label1: TLabel
Left = 8
Height = 15
Top = 8
Width = 74
Caption = 'Selected Area '
end
end
object MvPluginManager1: TMvPluginManager
Left = 320
Top = 24
end
end

View File

@ -0,0 +1,69 @@
unit Main;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, Forms, Controls, Graphics, Dialogs, ExtCtrls, StdCtrls,
mvMapViewer, mvPluginCommon, uAreaSelectionPlugin, mvTypes;
type
{ TForm1 }
TForm1 = class(TForm)
Label1: TLabel;
lblSelArea: TLabel;
MapView1: TMapView;
MvPluginManager1: TMvPluginManager;
Panel1: TPanel;
procedure FormCreate(Sender: TObject);
private
FAreaSelectionPlugin : TAreaSelectionPlugin;
procedure OnSelectedAreaChanged(Sender : TObject);
procedure OnSelectedAreaChanging(Sender : TObject; ANewArea : TRealArea; var Allow : Boolean);
public
end;
var
Form1: TForm1;
implementation
{$R *.lfm}
{ TForm1 }
procedure TForm1.FormCreate(Sender: TObject);
begin
FAreaSelectionPlugin := TAreaSelectionPlugin.Create(MvPluginManager1);
FAreaSelectionPlugin.MapView := MapView1;
FAreaSelectionPlugin.OnSelectedAreaChanged:= @OnSelectedAreaChanged;
FAreaSelectionPlugin.OnSelectedAreaChanging:= @OnSelectedAreaChanging;
end;
procedure TForm1.OnSelectedAreaChanged(Sender: TObject);
begin
lblSelArea.Caption := Format('Left %1.2f, Top %1.2f, Right %1.2f, Bottom %1.2f',[
FAreaSelectionPlugin.SelectedArea.TopLeft.Lon,
FAreaSelectionPlugin.SelectedArea.TopLeft.Lat,
FAreaSelectionPlugin.SelectedArea.BottomRight.Lon,
FAreaSelectionPlugin.SelectedArea.BottomRight.Lat
]);
end;
procedure TForm1.OnSelectedAreaChanging(Sender: TObject; ANewArea: TRealArea;
var Allow: Boolean);
begin
lblSelArea.Caption := Format('Left %1.2f, Top %1.2f, Right %1.2f, Bottom %1.2f',[
ANewArea.TopLeft.Lon,
ANewArea.TopLeft.Lat,
ANewArea.BottomRight.Lon,
ANewArea.BottomRight.Lat
]);
end;
end.

View File

@ -6,11 +6,11 @@ object MainForm: TMainForm
Caption = 'Spread Marker Demo'
ClientHeight = 473
ClientWidth = 669
LCLVersion = '4.99.0.0'
OnCreate = FormCreate
LCLVersion = '3.6.0.0'
object MapView: TMapView
Left = 0
Height = 473
Height = 447
Top = 0
Width = 669
Active = True
@ -23,6 +23,24 @@ object MainForm: TMainForm
MapProvider = 'OpenStreetMap Mapnik'
PluginManager = PluginManager
end
object Panel1: TPanel
Left = 0
Height = 26
Top = 447
Width = 669
Align = alBottom
ClientHeight = 26
ClientWidth = 669
TabOrder = 1
object CheckBox1: TCheckBox
Left = 8
Height = 19
Top = 0
Width = 257
Caption = 'Delete some of the spreaded markers on click'
TabOrder = 0
end
end
object PluginManager: TMvPluginManager
Left = 408
Top = 104

View File

@ -6,7 +6,7 @@ interface
uses
Classes, SysUtils,
Forms, Controls, Graphics, Dialogs,
Forms, Controls, Graphics, Dialogs, ExtCtrls, StdCtrls,
mvMapViewer, mvPluginCommon, mvPlugins, mvGPSObj, mvspreadmarker_plugin;
type
@ -14,7 +14,9 @@ type
{ TMainForm }
TMainForm = class(TForm)
CheckBox1: TCheckBox;
MapView: TMapView;
Panel1: TPanel;
PluginManager: TMvPluginManager;
DraggableMarkerPlugin: TDraggableMarkerPlugin;
MvPluginManager1DraggableMarkerPlugin2: TDraggableMarkerPlugin;
@ -92,6 +94,7 @@ var
ndx : Integer;
i : Integer;
begin
if not CheckBox1.Checked then Exit;
if Button <> mbLeft then Exit;
if (not Handled) and SpreadMarkerPlugin.SpreadModeActive[AMapView] then
begin

View File

@ -108,12 +108,12 @@
<IsPartOfProject Value="True"/>
</Unit>
<Unit>
<Filename Value="main.pas"/>
<Filename Value="unit1.pas"/>
<IsPartOfProject Value="True"/>
<ComponentName Value="MainForm"/>
<HasResources Value="True"/>
<ResourceBaseClass Value="Form"/>
<UnitName Value="Main"/>
<UnitName Value="Unit1"/>
</Unit>
</Units>
</ProjectOptions>

View File

@ -1,4 +1,4 @@
program SpreadMarker_Demo;
program spreadmarkerdemo;
{$mode objfpc}{$H+}
@ -10,14 +10,14 @@ uses
athreads,
{$ENDIF}
Interfaces, // this includes the LCL widgetset
Forms, main
Forms, Main
{ you can add units after this };
{$R *.res}
begin
RequireDerivedFormResource:=True;
Application.Scaled := True;
Application.Scaled:=True;
Application.Initialize;
Application.CreateForm(TMainForm, MainForm);
Application.Run;