lazmapviewer: Add new downloadengine based on Synapse. Register download engines as new components. Publish property Downloadengine of the MapViewer.

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@6797 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2019-01-23 18:07:52 +00:00
parent 0a3e34cd0b
commit 06d1c3c0bf
7 changed files with 109 additions and 22 deletions

View File

@ -25,7 +25,7 @@ This is a fork of MapViewer by ti_dic (https://sourceforge.net/p/roadbook/code/c
</Item2> </Item2>
<Item3> <Item3>
<Filename Value="source/mvdragobj.pas"/> <Filename Value="source/mvdragobj.pas"/>
<UnitName Value="mvdragobj"/> <UnitName Value="mvDragObj"/>
</Item3> </Item3>
<Item4> <Item4>
<Filename Value="source/mvengine.pas"/> <Filename Value="source/mvengine.pas"/>
@ -37,7 +37,7 @@ This is a fork of MapViewer by ti_dic (https://sourceforge.net/p/roadbook/code/c
</Item5> </Item5>
<Item6> <Item6>
<Filename Value="source/mvgpsobj.pas"/> <Filename Value="source/mvgpsobj.pas"/>
<UnitName Value="mvgpsobj"/> <UnitName Value="mvGpsObj"/>
</Item6> </Item6>
<Item7> <Item7>
<Filename Value="source/mvjobqueue.pas"/> <Filename Value="source/mvjobqueue.pas"/>
@ -53,15 +53,15 @@ This is a fork of MapViewer by ti_dic (https://sourceforge.net/p/roadbook/code/c
</Item9> </Item9>
<Item10> <Item10>
<Filename Value="source/mvtypes.pas"/> <Filename Value="source/mvtypes.pas"/>
<UnitName Value="mvtypes"/> <UnitName Value="mvTypes"/>
</Item10> </Item10>
<Item11> <Item11>
<Filename Value="source/mvmapviewer.pas"/> <Filename Value="source/mvmapviewer.pas"/>
<UnitName Value="mvmapviewer"/> <UnitName Value="mvMapViewer"/>
</Item11> </Item11>
<Item12> <Item12>
<Filename Value="source/mvextradata.pas"/> <Filename Value="source/mvextradata.pas"/>
<UnitName Value="mvextradata"/> <UnitName Value="mvExtraData"/>
</Item12> </Item12>
<Item13> <Item13>
<Filename Value="source/mvdlefpc.pas"/> <Filename Value="source/mvdlefpc.pas"/>
@ -73,13 +73,10 @@ This is a fork of MapViewer by ti_dic (https://sourceforge.net/p/roadbook/code/c
<UnitName Value="mvMapViewerReg"/> <UnitName Value="mvMapViewerReg"/>
</Item14> </Item14>
</Files> </Files>
<RequiredPkgs Count="2"> <RequiredPkgs Count="1">
<Item1> <Item1>
<PackageName Value="LCLBase"/> <PackageName Value="LCLBase"/>
</Item1> </Item1>
<Item2>
<PackageName Value="FCL"/>
</Item2>
</RequiredPkgs> </RequiredPkgs>
<UsageOptions> <UsageOptions>
<UnitPath Value="$(PkgOutDir)"/> <UnitPath Value="$(PkgOutDir)"/>

View File

@ -0,0 +1,40 @@
<?xml version="1.0" encoding="UTF-8"?>
<CONFIG>
<Package Version="4">
<PathDelim Value="\"/>
<Name Value="lazMapViewer_Synapse"/>
<Type Value="RunAndDesignTime"/>
<CompilerOptions>
<Version Value="11"/>
<PathDelim Value="\"/>
<SearchPaths>
<UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)\"/>
</SearchPaths>
</CompilerOptions>
<Files Count="1">
<Item1>
<Filename Value="mvdlesynapse.pas"/>
<HasRegisterProc Value="True"/>
<UnitName Value="mvDLESynapse"/>
</Item1>
</Files>
<RequiredPkgs Count="3">
<Item1>
<PackageName Value="lazMapViewerPkg"/>
</Item1>
<Item2>
<PackageName Value="laz_synapse"/>
</Item2>
<Item3>
<PackageName Value="FCL"/>
</Item3>
</RequiredPkgs>
<UsageOptions>
<UnitPath Value="$(PkgOutDir)"/>
</UsageOptions>
<PublishOptions>
<Version Value="2"/>
<UseFileFilters Value="True"/>
</PublishOptions>
</Package>
</CONFIG>

View File

@ -0,0 +1,22 @@
{ This file was automatically created by Lazarus. Do not edit!
This source is only used to compile and install the package.
}
unit lazMapViewer_Synapse;
{$warn 5023 off : no warning about unused units}
interface
uses
mvDLESynapse, LazarusPackageIntf;
implementation
procedure Register;
begin
RegisterUnit('mvDLESynapse', @mvDLESynapse.Register);
end;
initialization
RegisterPackage('lazMapViewer_Synapse', @Register);
end.

View File

@ -14,7 +14,7 @@
You should have received a copy of the GNU Library General Public License You should have received a copy of the GNU Library General Public License
along with this library; if not, write to the Free Software Foundation, along with this library; if not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1335, USA.
} }
unit mvDLESynapse; unit mvDLESynapse;
@ -23,13 +23,13 @@ unit mvDLESynapse;
interface interface
uses uses
mvDownloadEngine,SysUtils, Classes, httpsend; mvDownloadEngine, SysUtils, Classes, httpsend;
type type
{ TMVDESynapse } { TMVDESynapse }
TMVDESynapse = class(TCustomDownloadEngine) TMVDESynapse = class(TMvCustomDownloadEngine)
private private
FProxyHost: string; FProxyHost: string;
FProxyPassword: string; FProxyPassword: string;
@ -40,15 +40,26 @@ type
procedure DownloadFile(const Url: string; str: TStream); override; procedure DownloadFile(const Url: string; str: TStream); override;
published published
property UseProxy: Boolean read FUseProxy write FUseProxy; property UseProxy: Boolean read FUseProxy write FUseProxy default false;
property ProxyHost: string read FProxyHost write FProxyHost; property ProxyHost: string read FProxyHost write FProxyHost;
property ProxyPort: Integer read FProxyPort write FProxyPort; property ProxyPort: Integer read FProxyPort write FProxyPort default 0;
property ProxyUsername: string read FProxyUsername write FProxyUsername; property ProxyUsername: string read FProxyUsername write FProxyUsername;
property ProxyPassword: string read FProxyPassword write FProxyPassword; property ProxyPassword: string read FProxyPassword write FProxyPassword;
end; end;
procedure Register;
implementation implementation
uses
mvTypes;
procedure Register;
begin
RegisterComponents(PALETTE_PAGE, [TMVDESynapse]);
end;
{ TMVDESynapse } { TMVDESynapse }
procedure TMVDESynapse.DownloadFile(const Url: string; str: TStream); procedure TMVDESynapse.DownloadFile(const Url: string; str: TStream);

View File

@ -46,6 +46,7 @@ Type
TMapView = class(TCustomControl) TMapView = class(TCustomControl)
private private
FDownloadEngine: TMvCustomDownloadEngine; FDownloadEngine: TMvCustomDownloadEngine;
FBuiltinDownloadEngine: TMvCustomDownloadEngine;
FEngine: TMapViewerEngine; FEngine: TMapViewerEngine;
{$IFDEF USE_RGBGRAPHICS} {$IFDEF USE_RGBGRAPHICS}
Buffer: TRGB32Bitmap; Buffer: TRGB32Bitmap;
@ -67,6 +68,7 @@ Type
function GetCacheOnDisk: boolean; function GetCacheOnDisk: boolean;
function GetCachePath: String; function GetCachePath: String;
function GetCenter: TRealPoint; function GetCenter: TRealPoint;
function GetDownloadEngine: TMvCustomDownloadEngine;
function GetMapProvider: String; function GetMapProvider: String;
function GetOnCenterMove: TNotifyEvent; function GetOnCenterMove: TNotifyEvent;
function GetOnChange: TNotifyEvent; function GetOnChange: TNotifyEvent;
@ -77,6 +79,7 @@ Type
procedure SetCacheOnDisk(AValue: boolean); procedure SetCacheOnDisk(AValue: boolean);
procedure SetCachePath(AValue: String); procedure SetCachePath(AValue: String);
procedure SetCenter(AValue: TRealPoint); procedure SetCenter(AValue: TRealPoint);
procedure SetDownloadEngine(AValue: TMvCustomDownloadEngine);
procedure SetInactiveColor(AValue: TColor); procedure SetInactiveColor(AValue: TColor);
procedure SetMapProvider(AValue: String); procedure SetMapProvider(AValue: String);
procedure SetOnCenterMove(AValue: TNotifyEvent); procedure SetOnCenterMove(AValue: TNotifyEvent);
@ -115,7 +118,6 @@ Type
procedure ZoomOnObj(obj: TGPSObj); procedure ZoomOnObj(obj: TGPSObj);
procedure WaitEndOfRendering; procedure WaitEndOfRendering;
property Center: TRealPoint read GetCenter write SetCenter; property Center: TRealPoint read GetCenter write SetCenter;
property DownloadEngine: TMvCustomDownloadEngine read FDownloadEngine;
property Engine: TMapViewerEngine read FEngine; property Engine: TMapViewerEngine read FEngine;
property GPSItems: TGPSObjectList read FGPSItems; property GPSItems: TGPSObjectList read FGPSItems;
published published
@ -123,6 +125,7 @@ Type
property Align; property Align;
property CacheOnDisk: boolean read GetCacheOnDisk write SetCacheOnDisk; property CacheOnDisk: boolean read GetCacheOnDisk write SetCacheOnDisk;
property CachePath: String read GetCachePath write SetCachePath; property CachePath: String read GetCachePath write SetCachePath;
property DownloadEngine: TMvCustomDownloadEngine read FDownloadEngine write FDownloadEngine;
property Height default 150; property Height default 150;
property InactiveColor: TColor read FInactiveColor write SetInactiveColor; property InactiveColor: TColor read FInactiveColor write SetInactiveColor;
property MapProvider: String read GetMapProvider write SetMapProvider; property MapProvider: String read GetMapProvider write SetMapProvider;
@ -335,6 +338,14 @@ begin
Result := Engine.Center; Result := Engine.Center;
end; end;
function TMapView.GetDownloadEngine: TMvCustomDownloadEngine;
begin
if FDownloadEngine = nil then
Result := FBuiltinDownloadEngine
else
Result := FDownloadEngine;
end;
function TMapView.GetMapProvider: String; function TMapView.GetMapProvider: String;
begin begin
result := Engine.MapProvider; result := Engine.MapProvider;
@ -380,6 +391,12 @@ begin
Engine.Center := AValue; Engine.Center := AValue;
end; end;
procedure TMapView.SetDownloadEngine(AValue: TMvCustomDownloadEngine);
begin
FDownloadEngine := AValue;
FEngine.DownloadEngine := GetDownloadEngine;
end;
procedure TMapView.SetInactiveColor(AValue: TColor); procedure TMapView.SetInactiveColor(AValue: TColor);
begin begin
if FInactiveColor = AValue then if FInactiveColor = AValue then
@ -736,7 +753,7 @@ begin
FGPSItems.OnModified := @OnGPSItemsModified; FGPSItems.OnModified := @OnGPSItemsModified;
FInactiveColor := clWhite; FInactiveColor := clWhite;
FEngine := TMapViewerEngine.Create(self); FEngine := TMapViewerEngine.Create(self);
FdownloadEngine := TMvDEFpc.Create(self); FBuiltinDownloadEngine := TMvDEFpc.Create(self);
{$IFDEF USE_RGBGRAPHICS} {$IFDEF USE_RGBGRAPHICS}
Buffer := TRGB32Bitmap.Create(Width,Height); Buffer := TRGB32Bitmap.Create(Width,Height);
{$ENDIF} {$ENDIF}
@ -747,7 +764,7 @@ begin
Engine.CacheOnDisk := true; Engine.CacheOnDisk := true;
Engine.OnDrawTile := @DoDrawTile; Engine.OnDrawTile := @DoDrawTile;
Engine.DrawTitleInGuiThread := false; Engine.DrawTitleInGuiThread := false;
Engine.DownloadEngine := FDownloadengine; Engine.DownloadEngine := FBuiltinDownloadEngine;
inherited Create(AOwner); inherited Create(AOwner);
Width := 150; Width := 150;
Height := 150; Height := 150;

View File

@ -14,14 +14,13 @@ implementation
{$R mvmapviewer_icons.res} {$R mvmapviewer_icons.res}
uses uses
mvGeoNames, mvMapViewer; mvTypes, mvGeoNames, mvMapViewer, mvDLEFpc;
procedure Register; procedure Register;
const
PALETTE = 'Misc';
begin begin
RegisterComponents(PALETTE, [TMapView]); RegisterComponents(PALETTE_PAGE, [TMapView]);
RegisterComponents(PALETTE, [TMvGeoNames]); RegisterComponents(PALETTE_PAGE, [TMvGeoNames]);
RegisterComponents(PALETTE_PAGE, [TMvDEFpc]);
end; end;
end. end.

View File

@ -29,6 +29,7 @@ uses
const const
TILE_SIZE = 256; TILE_SIZE = 256;
PALETTE_PAGE = 'Misc';
Type Type
{ TArea } { TArea }