LazMapViewer: Add new properties LineColor and LineWidth to TGpsTrack. Add demo showing several individually colored tracks. Add some utility functions.

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@8102 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2021-09-29 15:11:12 +00:00
parent 68da1ac936
commit 9fcf5de570
12 changed files with 14439 additions and 12 deletions

View File

@@ -16,7 +16,7 @@ unit mvGpsObj;
interface
uses
Classes, SysUtils,fgl,mvtypes,contnrs,syncobjs;
Classes, SysUtils, Graphics, fgl, mvtypes, contnrs, syncobjs;
const
NO_ELE = -10000000;
@@ -87,6 +87,9 @@ type
private
FDateTime: TDateTime;
FPoints: TGPSPointList;
FLineWidth: Double; // Line width in mm
FLineColor: TColor;
FVisible: Boolean;
function GetDateTime: TDateTime;
public
constructor Create;
@@ -97,6 +100,9 @@ type
property Points: TGPSPointList read FPoints;
property DateTime: TDateTime read GetDateTime write FDateTime;
property LineColor: TColor read FLineColor write FLineColor;
property Visible: Boolean read FVisible write FVisible;
property LineWidth: Double read FLineWidth write FLineWidth;
end;
TGPSObjList_ = specialize TFPGObjectList<TGPSObj>;
@@ -144,6 +150,7 @@ type
function Add(aItem: TGpsObj; AIdOwner: integer): integer;
procedure DeleteById(const Ids: Array of integer);
function FindTrackByID(const id: Integer): TGpsTrack;
procedure BeginUpdate;
procedure EndUpdate;
@@ -645,6 +652,19 @@ begin
end;
end;
function TGPSObjectList.FindTrackByID(const ID: Integer): TGpsTrack;
var
i: Integer;
begin
for i:=0 to pred(FItems.Count) do
if (ID = FItems[i].IdOwner) and (FItems[i] is TGpsTrack) then
begin
Result := TGpsTrack(FItems[i]);
exit;
end;
Result := nil;
end;
{ TGPSTrack }
@@ -662,6 +682,9 @@ constructor TGPSTrack.Create;
begin
inherited;
FPoints := TGPSPointList.Create(true);
FVisible := true;
FLineColor := clDefault; // --> use MapView.DefaultTrackColor
FLineWidth := -1; // --> use MapView.DefaultTrackWidth
end;
destructor TGPSTrack.Destroy;