fpvviewer: Much improves the zoom/position auto-adjustment of documents
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@2796 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
parent
eb04addd7e
commit
ef49aac4dc
@ -8,7 +8,7 @@ object frmFPVViewer: TfrmFPVViewer
|
||||
ClientWidth = 485
|
||||
OnCreate = FormCreate
|
||||
OnDestroy = FormDestroy
|
||||
LCLVersion = '1.1'
|
||||
LCLVersion = '1.3'
|
||||
object notebook: TNotebook
|
||||
Left = 0
|
||||
Height = 424
|
||||
|
@ -333,24 +333,25 @@ const
|
||||
FPVVIEWER_MIN_IMAGE_SIZE = 100;
|
||||
FPVVIEWER_SPACE_FOR_NEGATIVE_COORDS = 100;
|
||||
var
|
||||
CanvasSize: TPoint;
|
||||
lSpaceForNegCoords: TPoint;
|
||||
lCurPage: TvPage;
|
||||
lZoom: Double;
|
||||
lCanvasWidth: Integer;
|
||||
begin
|
||||
Render_PrepareFile();
|
||||
try
|
||||
// We need to be robust, because sometimes the document size won't be given
|
||||
// also give up drawing everything if we need more then 4MB of RAM for the image
|
||||
// and also give some space in the image to allow for negative coordinates
|
||||
if FVec.Width * spinScale.Value > FPVVIEWER_MAX_IMAGE_SIZE then CanvasSize.X := FPVVIEWER_MAX_IMAGE_SIZE
|
||||
else if FVec.Width < FPVVIEWER_MIN_IMAGE_SIZE then CanvasSize.X := Drawer.Width
|
||||
else CanvasSize.X := Round(FVec.Width * spinScale.Value);
|
||||
if CanvasSize.X < Drawer.Width then CanvasSize.X := Drawer.Width;
|
||||
lCurPage := FVec.GetPage(0);
|
||||
lCurPage.CalculateDocumentSize();
|
||||
|
||||
if FVec.Height * spinScale.Value > FPVVIEWER_MAX_IMAGE_SIZE then CanvasSize.Y := FPVVIEWER_MAX_IMAGE_SIZE
|
||||
else if FVec.Height < FPVVIEWER_MIN_IMAGE_SIZE then CanvasSize.Y := Drawer.Height
|
||||
else CanvasSize.Y := Round(FVec.Height * spinScale.Value);
|
||||
if CanvasSize.Y < Drawer.Height then CanvasSize.Y := Drawer.Height;
|
||||
|
||||
Render_DoRender(Drawer.Width, Drawer.Height, 4, 4, FVec.Width / Drawer.Width);
|
||||
lCanvasWidth := Drawer.Width;
|
||||
lZoom := (Drawer.Width / lCurPage.Width) * 0.8;
|
||||
spinScale.Value := lZoom;
|
||||
// Centralizes the image in the canvas
|
||||
lSpaceForNegCoords.X := Round(lCurPage.MinX * -1 * lZoom + Drawer.Width * 0.1);
|
||||
lSpaceForNegCoords.Y := Round(lCurPage.MinY * lZoom - Drawer.Height * 0.1);
|
||||
spinAdjustX.Value := lSpaceForNegCoords.X - FPVVIEWER_SPACE_FOR_NEGATIVE_COORDS;
|
||||
spinAdjustY.Value := lSpaceForNegCoords.Y + FPVVIEWER_SPACE_FOR_NEGATIVE_COORDS;
|
||||
Render_DoRender(Drawer.Width, Drawer.Height, lSpaceForNegCoords.X, lSpaceForNegCoords.Y, lZoom);
|
||||
finally
|
||||
Render_FreeFile();
|
||||
end;
|
||||
@ -559,10 +560,10 @@ begin
|
||||
FVec.GetPageAsVectorial(0).DrawBackground(Drawer.Drawing.Canvas);
|
||||
FVec.GetPageAsVectorial(0).Render(
|
||||
Drawer.Drawing.Canvas,
|
||||
FPVVIEWER_SPACE_FOR_NEGATIVE_COORDS + ADrawerPosX,
|
||||
Drawer.Drawing.Height - FPVVIEWER_SPACE_FOR_NEGATIVE_COORDS + ADrawerPosY,
|
||||
spinScale.Value,
|
||||
-1 * spinScale.Value);
|
||||
ADrawerPosX,
|
||||
Drawer.Drawing.Height + ADrawerPosY,
|
||||
AScale,
|
||||
-1 * AScale);
|
||||
Drawer.Invalidate;
|
||||
end;
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
<?xml version="1.0"?>
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<CONFIG>
|
||||
<ProjectOptions>
|
||||
<Version Value="9"/>
|
||||
@ -61,9 +61,11 @@
|
||||
</CompilerMessages>
|
||||
<CompilerPath Value="$(CompPath)"/>
|
||||
</Other>
|
||||
<LCLWidgetType Value="qt"/>
|
||||
</CompilerOptions>
|
||||
</Item3>
|
||||
<SharedMatrixOptions Count="1">
|
||||
<Item1 ID="669514139583" Modes="qt" Type="IDEMacro" MacroName="LCLWidgetType" Value="qt"/>
|
||||
</SharedMatrixOptions>
|
||||
</BuildModes>
|
||||
<PublishOptions>
|
||||
<Version Value="2"/>
|
||||
|
Loading…
Reference in New Issue
Block a user