LazMapViewer: Simplify selection of drawing and download engines.

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@9491 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz 2024-10-22 15:32:55 +00:00
parent a204dfcd7a
commit aa7a12a74a
4 changed files with 39 additions and 67 deletions

View File

@ -21,19 +21,6 @@ type
Label2: TLabel;
procedure cbDownloadEngineChange(Sender: TObject);
procedure cbDrawingEngineChange(Sender: TObject);
private
FRGBGraphicsDrawingEngine: TMvRGBGraphicsDrawingEngine;
FBGRADrawingEngine: TMvBGRADrawingEngine;
FLCLDrawingEngine: TMvLCLDrawingEngine;
FSynapseDownloadEngine: TMvDESynapse;
FFpHttpClientDownloadEngine: TMvDEFPC;
{$IFDEF MSWINDOWS}
FWinDownloadEngine: TMvDEWin;
{$ENDIF}
public
destructor Destroy; override;
end;
implementation
@ -42,67 +29,34 @@ implementation
{ TCfgFrame_with_addons }
destructor TCfgFrame_with_addons.Destroy;
begin
FreeAndNil(FRGBGraphicsDrawingEngine);
FreeAndNil(FBGRADrawingEngine);
FreeAndNil(FSynapseDownloadEngine);
FreeAndNil(FFpHttpClientDownloadEngine);
{$IFDEF MSWINDOWS}
FreeAndNil(FWinDownloadEngine);
{$ENDIF}
inherited;
end;
procedure TCfgFrame_with_addons.cbDrawingEngineChange(Sender: TObject);
begin
if not MapView.UsesDefaultDrawingEngine then
MapView.DrawingEngine.Free;
case cbDrawingEngine.ItemIndex of
0: MapView.DrawingEngine := nil;
1: begin
if FRGBGraphicsDrawingEngine = nil then
FRGBGraphicsDrawingEngine := TMvRGBGraphicsDrawingEngine.Create(self);
MapView.DrawingEngine := FRGBGraphicsDrawingEngine;
end;
2: begin
if FBGRADrawingEngine = nil then
FBGRADrawingEngine := TMvBGRADrawingEngine.Create(self);
MapView.DrawingEngine := FBGRADrawingEngine;
end;
3: begin
if FLCLDrawingEngine = nil then
FLCLDrawingEngine := TMvLCLDrawingEngine.Create(self);
MapView.DrawingEngine := FLCLDrawingEngine;
end;
1: MapView.DrawingEngine := TMvRGBGraphicsDrawingEngine.Create(Self);
2: MapView.DrawingEngine := TMvBGRADrawingEngine.Create(self);
3: MapView.DrawingEngine := TMvLCLDrawingEngine.Create(self);
end;
DoUpdateLayers;
end;
procedure TCfgFrame_with_addons.cbDownloadEngineChange(Sender: TObject);
begin
if not MapView.UsesDefaultDownloadEngine then
MapView.DownloadEngine.Free;
case cbDownloadEngine.ItemIndex of
0: MapView.DownloadEngine := nil;
1: begin
if FSynapseDownloadEngine = nil then
FSynapseDownloadEngine := TMvDESynapse.Create(self);
MapView.DownloadEngine := FSynapseDownloadEngine;
end;
2: begin
if FFpHttpClientDownloadEngine = nil then
FFpHttpClientDownloadEngine := TMvDEFPC.Create(self);
MapView.DownloadEngine := FFpHttpClientDownloadEngine;
end;
3: begin
{$IFDEF MSWINDOWS}
if FWinDownloadEngine = nil then
FWinDownloadEngine := TMvDEWin.Create(Self);
MapView.DownloadEngine := FWinDownloadEngine;
{$ELSE}
ShowMessage('WinInet download engine can only be used in Windows.');
{$ENDIF}
end;
4: begin
MapView.DownloadEngine := TMvDECache.Create(self);
end;
1: MapView.DownloadEngine := TMvDESynapse.Create(self);
2: MapView.DownloadEngine := TMvDEFPC.Create(self);
3: {$IFDEF MSWINDOWS}
MapView.DownloadEngine := TMvDEWin.Create(self);
{$ELSE}
MapView.DownloadEngine := nil;
ShowMessage('WinInet download engine can only be used in Windows.');
{$ENDIF}
4: MapView.DownloadEngine := TMvDECache.Create(self);
end;
UpdateDownloadEngineProxy;
end;

View File

@ -12,8 +12,8 @@ uses
begin
RequireDerivedFormResource:=True;
Application.Title:='MapViewer_Demo_with_Addons';
Application.Scaled:=True;
Application.Title := 'MapViewer_Demo_with_Addons';
Application.Scaled := True;
Application.Initialize;
Application.CreateForm(TMainForm, MainForm);
Application.CreateForm(TGPSListViewer, GPSListViewer);

View File

@ -195,7 +195,6 @@ begin
raise EInvalidGraphic.Create('PNG/JPG expected.');
try
rawImg.Init;
//rawImg.Description.Init_BPP24_B8G8R8_BIO_TTB(TILE_SIZE, TILE_SIZE);
rawImg.Description.Init_BPP32_B8G8R8A8_BIO_TTB(TILE_SIZE, TILE_SIZE);
FImage := TLazIntfImage.Create(rawImg, True);
try

View File

@ -595,6 +595,8 @@ type
function ScreenToLonLat(aPt: TPoint): TRealPoint; deprecated 'Use ScreenToLatLon';
procedure CenterOnObj(obj: TGPSObj);
procedure Redraw; inline;
function UsesDefaultDownloadEngine: Boolean;
function UsesDefaultDrawingEngine: Boolean;
procedure ZoomOnArea(const aArea: TRealArea);
procedure ZoomOnObj(obj: TGPSObj);
procedure WaitEndOfRendering;
@ -2092,6 +2094,11 @@ begin
Result := FDownloadEngine;
end;
function TMapView.UsesDefaultdownloadEngine: Boolean;
begin
Result := FDownloadEngine <> FBuiltinDownloadEngine;
end;
function TMapView.GetDrawingEngine: TMvCustomDrawingEngine;
begin
if FDrawingEngine = nil then
@ -2100,6 +2107,11 @@ begin
Result := FDrawingEngine;
end;
function TMapView.UsesDefaultDrawingEngine: Boolean;
begin
Result := FDrawingEngine <> FBuiltinDrawingEngine;
end;
function TMapView.GetDrawPreviewTiles: Boolean;
begin
Result := Engine.DrawPreviewTiles;
@ -2504,8 +2516,15 @@ end;
procedure TMapView.Notification(AComponent: TComponent; Operation: TOperation);
begin
inherited;
if (AComponent = FPOIImages) and (Operation = opRemove) then
FPOIImages := nil;
if (Operation = opRemove) then
begin
if (AComponent = FPOIImages) then
FPOIImages := nil;
if (AComponent = FDownloadEngine) then
DownloadEngine := nil;
if (AComponent = FDrawingEngine) then
DrawingEngine := nil;
end;
end;
procedure TMapView.DblClick;