|
@@ -35,7 +35,6 @@ type
|
|
function ToolUp: TRect; override;
|
|
function ToolUp: TRect; override;
|
|
function GetContextualToolbars: TContextualToolbars; override;
|
|
function GetContextualToolbars: TContextualToolbars; override;
|
|
function Render(VirtualScreen: TBGRABitmap; {%H-}VirtualScreenWidth, {%H-}VirtualScreenHeight: integer; BitmapToVirtualScreen: TBitmapToVirtualScreenFunction): TRect; override;
|
|
function Render(VirtualScreen: TBGRABitmap; {%H-}VirtualScreenWidth, {%H-}VirtualScreenHeight: integer; BitmapToVirtualScreen: TBitmapToVirtualScreenFunction): TRect; override;
|
|
- procedure BeforeGridSizeChange; override;
|
|
|
|
procedure AfterGridSizeChange({%H-}NewNbX,{%H-}NewNbY: Integer); override;
|
|
procedure AfterGridSizeChange({%H-}NewNbX,{%H-}NewNbY: Integer); override;
|
|
function ToolCommand(ACommand: TToolCommand): boolean; override;
|
|
function ToolCommand(ACommand: TToolCommand): boolean; override;
|
|
function ToolProvideCommand(ACommand: TToolCommand): boolean; override;
|
|
function ToolProvideCommand(ACommand: TToolCommand): boolean; override;
|
|
@@ -264,7 +263,7 @@ begin
|
|
if tex <> nil then
|
|
if tex <> nil then
|
|
begin
|
|
begin
|
|
|
|
|
|
- if Manager.ToolPerspectiveRepeat then
|
|
|
|
|
|
+ if poRepeat in Manager.PerspectiveOptions then
|
|
FCurrentBounds := rect(0,0,Manager.Image.Width,Manager.Image.Height)
|
|
FCurrentBounds := rect(0,0,Manager.Image.Width,Manager.Image.Height)
|
|
else
|
|
else
|
|
FCurrentBounds := GetShapeBounds([quad[0],quad[1],quad[2],quad[3]],1);
|
|
FCurrentBounds := GetShapeBounds([quad[0],quad[1],quad[2],quad[3]],1);
|
|
@@ -282,11 +281,11 @@ begin
|
|
dest.ClipRect := FCurrentBounds;
|
|
dest.ClipRect := FCurrentBounds;
|
|
end;
|
|
end;
|
|
|
|
|
|
- if Manager.ToolPerspectiveRepeat then
|
|
|
|
|
|
+ if poRepeat in Manager.PerspectiveOptions then
|
|
begin
|
|
begin
|
|
persp := TBGRAPerspectiveScannerTransform.Create(tex,[PointF(-0.5,-0.5),PointF(tex.Width-0.5,-0.5),
|
|
persp := TBGRAPerspectiveScannerTransform.Create(tex,[PointF(-0.5,-0.5),PointF(tex.Width-0.5,-0.5),
|
|
PointF(tex.Width-0.5,tex.Height-0.5),PointF(-0.5,tex.Height-0.5)],quadHQ);
|
|
PointF(tex.Width-0.5,tex.Height-0.5),PointF(-0.5,tex.Height-0.5)],quadHQ);
|
|
- persp.IncludeOppositePlane := Manager.ToolPerspectiveTwoPlanes;
|
|
|
|
|
|
+ persp.IncludeOppositePlane := poTwoPlanes in Manager.PerspectiveOptions;
|
|
dest.FillRect(0,0,dest.Width,dest.Height,persp,dmDrawWithTransparency);
|
|
dest.FillRect(0,0,dest.Width,dest.Height,persp,dmDrawWithTransparency);
|
|
persp.Free;
|
|
persp.Free;
|
|
end else
|
|
end else
|
|
@@ -313,7 +312,7 @@ function TToolTextureMapping.GetAdaptedTexture: TBGRABitmap;
|
|
var tx,ty: integer;
|
|
var tx,ty: integer;
|
|
precisionFactor: single;
|
|
precisionFactor: single;
|
|
begin
|
|
begin
|
|
- if Manager.ToolPerspectiveRepeat then //cannot optimize size
|
|
|
|
|
|
+ if poRepeat in Manager.PerspectiveOptions then //cannot optimize size
|
|
begin
|
|
begin
|
|
result := GetTexture;
|
|
result := GetTexture;
|
|
exit;
|
|
exit;
|
|
@@ -709,7 +708,7 @@ begin
|
|
end;
|
|
end;
|
|
if quadMoving then
|
|
if quadMoving then
|
|
begin
|
|
begin
|
|
- redraw := not Manager.ToolPerspectiveRepeat;
|
|
|
|
|
|
+ redraw := not (poRepeat in Manager.PerspectiveOptions);
|
|
if quadMovingBounds then
|
|
if quadMovingBounds then
|
|
begin
|
|
begin
|
|
oldBounds := ComputeBoundsPoints;
|
|
oldBounds := ComputeBoundsPoints;
|
|
@@ -823,28 +822,26 @@ begin
|
|
result := false;
|
|
result := false;
|
|
exit;
|
|
exit;
|
|
end;
|
|
end;
|
|
- setlength(DeformationGrid,Manager.DeformationGridNbY,Manager.DeformationGridNbX);
|
|
|
|
- setlength(DeformationGridTexCoord,Manager.DeformationGridNbY,Manager.DeformationGridNbX);
|
|
|
|
- for yb := 0 to Manager.DeformationGridNbY-1 do
|
|
|
|
- for xb := 0 to Manager.DeformationGridNbX-1 do
|
|
|
|
|
|
+ deformationGridNbX:= Manager.DeformationGridNbX;
|
|
|
|
+ deformationGridNbY:= Manager.DeformationGridNbY;
|
|
|
|
+ SetLength(DeformationGrid, deformationGridNbY, deformationGridNbX);
|
|
|
|
+ SetLength(DeformationGridTexCoord, deformationGridNbY, deformationGridNbX);
|
|
|
|
+ for yb := 0 to deformationGridNbY-1 do
|
|
|
|
+ for xb := 0 to deformationGridNbX-1 do
|
|
begin
|
|
begin
|
|
- DeformationGridTexCoord[yb,xb] := PointF(xb/(Manager.DeformationGridNbX-1)*layer.Width-0.5,
|
|
|
|
- yb/(Manager.DeformationGridNbY-1)*layer.Height-0.5);
|
|
|
|
|
|
+ DeformationGridTexCoord[yb,xb] := PointF(xb/(deformationGridNbX-1)*layer.Width-0.5,
|
|
|
|
+ yb/(deformationGridNbY-1)*layer.Height-0.5);
|
|
DeformationGrid[yb,xb] :=DeformationGridTexCoord[yb,xb];
|
|
DeformationGrid[yb,xb] :=DeformationGridTexCoord[yb,xb];
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
result := true;
|
|
result := true;
|
|
end;
|
|
end;
|
|
|
|
|
|
-procedure TToolDeformationGrid.BeforeGridSizeChange;
|
|
|
|
|
|
+procedure TToolDeformationGrid.AfterGridSizeChange(NewNbX,NewNbY: Integer);
|
|
begin
|
|
begin
|
|
ReleaseGrid;
|
|
ReleaseGrid;
|
|
DeformationGrid := nil;
|
|
DeformationGrid := nil;
|
|
DeformationGridTexCoord := nil;
|
|
DeformationGridTexCoord := nil;
|
|
-end;
|
|
|
|
-
|
|
|
|
-procedure TToolDeformationGrid.AfterGridSizeChange(NewNbX,NewNbY: Integer);
|
|
|
|
-begin
|
|
|
|
//grid will be created when needed
|
|
//grid will be created when needed
|
|
end;
|
|
end;
|
|
|
|
|
|
@@ -884,8 +881,8 @@ begin
|
|
begin
|
|
begin
|
|
ValidateAction;
|
|
ValidateAction;
|
|
DoingDeformation := false;
|
|
DoingDeformation := false;
|
|
- for yb := 0 to Manager.DeformationGridNbY-2 do
|
|
|
|
- for xb := 0 to Manager.DeformationGridNbX-2 do
|
|
|
|
|
|
+ for yb := 0 to deformationGridNbY-2 do
|
|
|
|
+ for xb := 0 to deformationGridNbX-2 do
|
|
DeformationGridTexCoord[yb,xb] := DeformationGrid[yb,xb];
|
|
DeformationGridTexCoord[yb,xb] := DeformationGrid[yb,xb];
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
@@ -913,8 +910,8 @@ begin
|
|
deformationGridY := 1;
|
|
deformationGridY := 1;
|
|
if DeformationGrid <> nil then
|
|
if DeformationGrid <> nil then
|
|
begin
|
|
begin
|
|
- for yb := 1 to Manager.DeformationGridNbY-2 do
|
|
|
|
- for xb := 1 to Manager.DeformationGridNbX-2 do
|
|
|
|
|
|
+ for yb := 1 to deformationGridNbY-2 do
|
|
|
|
+ for xb := 1 to deformationGridNbX-2 do
|
|
begin
|
|
begin
|
|
curDist := sqr(ptF.x-DeformationGrid[yb,xb].x)+sqr(ptF.y-DeformationGrid[yb,xb].y);
|
|
curDist := sqr(ptF.x-DeformationGrid[yb,xb].x)+sqr(ptF.y-DeformationGrid[yb,xb].y);
|
|
if curDist < minDist then
|
|
if curDist < minDist then
|
|
@@ -976,8 +973,8 @@ begin
|
|
|
|
|
|
layer := GetToolDrawingLayer;
|
|
layer := GetToolDrawingLayer;
|
|
backupLayer := GetBackupLayerIfExists;
|
|
backupLayer := GetBackupLayerIfExists;
|
|
- NbX := Manager.DeformationGridNbX;
|
|
|
|
- NbY := Manager.DeformationGridNbY;
|
|
|
|
|
|
+ NbX := deformationGridNbX;
|
|
|
|
+ NbY := deformationGridNbY;
|
|
|
|
|
|
DeformationGrid[deformationGridY,deformationGridX] := PointF(
|
|
DeformationGrid[deformationGridY,deformationGridX] := PointF(
|
|
DeformationGrid[deformationGridY,deformationGridX].X + ptF.X-deformationOrigin.X,
|
|
DeformationGrid[deformationGridY,deformationGridX].X + ptF.X-deformationOrigin.X,
|
|
@@ -1069,14 +1066,14 @@ var curPt,rightPt,downPt: TPointF;
|
|
begin
|
|
begin
|
|
result := EmptyRect;
|
|
result := EmptyRect;
|
|
if not ToolDeformationGridNeeded then exit;
|
|
if not ToolDeformationGridNeeded then exit;
|
|
- for xb := 0 to Manager.DeformationGridNbX-1 do
|
|
|
|
- for yb := 0 to Manager.DeformationGridNbY-1 do
|
|
|
|
|
|
+ for xb := 0 to deformationGridNbX-1 do
|
|
|
|
+ for yb := 0 to deformationGridNbY-1 do
|
|
begin
|
|
begin
|
|
curPt := BitmapToVirtualScreen(DeformationGrid[yb,xb]);
|
|
curPt := BitmapToVirtualScreen(DeformationGrid[yb,xb]);
|
|
if not deformationGridMoving or ((xb+1 >= deformationGridX) and (xb <= deformationGridX) and
|
|
if not deformationGridMoving or ((xb+1 >= deformationGridX) and (xb <= deformationGridX) and
|
|
(yb >= deformationGridY-1) and (yb <= deformationGridY+1)) then
|
|
(yb >= deformationGridY-1) and (yb <= deformationGridY+1)) then
|
|
begin
|
|
begin
|
|
- if (xb < Manager.DeformationGridNbX-1) and (yb > 0) and (yb < Manager.DeformationGridNbY-1) then
|
|
|
|
|
|
+ if (xb < deformationGridNbX-1) and (yb > 0) and (yb < deformationGridNbY-1) then
|
|
begin
|
|
begin
|
|
rightPt := BitmapToVirtualScreen(DeformationGrid[yb,xb+1]);
|
|
rightPt := BitmapToVirtualScreen(DeformationGrid[yb,xb+1]);
|
|
if Assigned(VirtualScreen) then NiceLine(VirtualScreen, curPt.X,curPt.Y, rightPt.X,rightPt.Y);
|
|
if Assigned(VirtualScreen) then NiceLine(VirtualScreen, curPt.X,curPt.Y, rightPt.X,rightPt.Y);
|
|
@@ -1089,7 +1086,7 @@ begin
|
|
if not deformationGridMoving or ((xb >= deformationGridX-1) and (xb <= deformationGridX+1) and
|
|
if not deformationGridMoving or ((xb >= deformationGridX-1) and (xb <= deformationGridX+1) and
|
|
(yb+1 >= deformationGridY) and (yb <= deformationGridY)) then
|
|
(yb+1 >= deformationGridY) and (yb <= deformationGridY)) then
|
|
begin
|
|
begin
|
|
- if (yb < Manager.DeformationGridNbY-1) and (xb > 0) and (xb < Manager.DeformationGridNbX-1) then
|
|
|
|
|
|
+ if (yb < deformationGridNbY-1) and (xb > 0) and (xb < deformationGridNbX-1) then
|
|
begin
|
|
begin
|
|
downPt := BitmapToVirtualScreen(DeformationGrid[yb+1,xb]);
|
|
downPt := BitmapToVirtualScreen(DeformationGrid[yb+1,xb]);
|
|
if Assigned(virtualScreen) then NiceLine(VirtualScreen, curPt.X,curPt.Y, downPt.X,downPt.Y);
|
|
if Assigned(virtualScreen) then NiceLine(VirtualScreen, curPt.X,curPt.Y, downPt.X,downPt.Y);
|
|
@@ -1100,8 +1097,8 @@ begin
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
- for xb := 1 to Manager.DeformationGridNbX-2 do
|
|
|
|
- for yb := 1 to Manager.DeformationGridNbY-2 do
|
|
|
|
|
|
+ for xb := 1 to deformationGridNbX-2 do
|
|
|
|
+ for yb := 1 to deformationGridNbY-2 do
|
|
begin
|
|
begin
|
|
if not deformationGridMoving or ((xb >= deformationGridX-1) and (xb <= deformationGridX+1) and
|
|
if not deformationGridMoving or ((xb >= deformationGridX-1) and (xb <= deformationGridX+1) and
|
|
(yb >= deformationGridY-1) and (yb <= deformationGridY+1)) then
|
|
(yb >= deformationGridY-1) and (yb <= deformationGridY+1)) then
|