|
@@ -217,6 +217,8 @@ type
|
|
procedure RequestPenFillUpdate(Sender: TObject);
|
|
procedure RequestPenFillUpdate(Sender: TObject);
|
|
procedure AdjustToolbarTop;
|
|
procedure AdjustToolbarTop;
|
|
procedure UpdateSplineToolbar;
|
|
procedure UpdateSplineToolbar;
|
|
|
|
+ function SnapToGrid(APoint: TPointF): TPointF;
|
|
|
|
+ function ImgCoordToOriginalCoord(APoint: TPointF): TPointF;
|
|
public
|
|
public
|
|
{ public declarations }
|
|
{ public declarations }
|
|
img: TBGRALazPaintImage;
|
|
img: TBGRALazPaintImage;
|
|
@@ -413,7 +415,7 @@ begin
|
|
|
|
|
|
if not justDown and not Assigned(newShape) then
|
|
if not justDown and not Assigned(newShape) then
|
|
begin
|
|
begin
|
|
- newStartPoint := AffineMatrixInverse(AffineMatrixTranslation(-0.5,-0.5)*vectorTransform*AffineMatrixTranslation(0.5,0.5))*imgPtF;
|
|
|
|
|
|
+ newStartPoint := ImgCoordToOriginalCoord(imgPtF);
|
|
newButton := Button;
|
|
newButton := Button;
|
|
justDown := true;
|
|
justDown := true;
|
|
end;
|
|
end;
|
|
@@ -636,7 +638,7 @@ begin
|
|
img.MouseMove(Shift, imgPtF.X, imgPtF.Y, cur, handled);
|
|
img.MouseMove(Shift, imgPtF.X, imgPtF.Y, cur, handled);
|
|
UpdateViewCursor(cur);
|
|
UpdateViewCursor(cur);
|
|
|
|
|
|
- ptF := AffineMatrixInverse(AffineMatrixTranslation(-0.5,-0.5)*vectorTransform*AffineMatrixTranslation(0.5,0.5))*imgPtF;
|
|
|
|
|
|
+ ptF := ImgCoordToOriginalCoord(imgPtF);
|
|
if justDown and not Assigned(newShape) and IsCreateShapeTool(currentTool) and
|
|
if justDown and not Assigned(newShape) and IsCreateShapeTool(currentTool) and
|
|
(VectLen(ptF-newStartPoint) >= EditorPointSize) then
|
|
(VectLen(ptF-newStartPoint) >= EditorPointSize) then
|
|
begin
|
|
begin
|
|
@@ -1493,18 +1495,27 @@ begin
|
|
end;
|
|
end;
|
|
|
|
|
|
procedure TForm1.SetEditorGrid(AActive: boolean);
|
|
procedure TForm1.SetEditorGrid(AActive: boolean);
|
|
|
|
+var pixelCentered: boolean;
|
|
begin
|
|
begin
|
|
if Assigned(img) and Assigned(img.OriginalEditor) then
|
|
if Assigned(img) and Assigned(img.OriginalEditor) then
|
|
begin
|
|
begin
|
|
- if zoomFactor > 4 then
|
|
|
|
|
|
+ if Assigned(vectorOriginal) and Assigned(vectorOriginal.SelectedShape) then
|
|
|
|
+ pixelCentered:= vectorOriginal.SelectedShape.PreferPixelCentered
|
|
|
|
+ else if PaintToolClass[currentTool]<>nil then
|
|
|
|
+ pixelCentered:= PaintToolClass[currentTool].PreferPixelCentered;
|
|
|
|
+
|
|
|
|
+ if zoomFactor >= 2.1 then
|
|
img.OriginalEditor.GridMatrix := AffineMatrixTranslation(-0.5,-0.5)*
|
|
img.OriginalEditor.GridMatrix := AffineMatrixTranslation(-0.5,-0.5)*
|
|
vectorTransform*AffineMatrixTranslation(0.5,0.5)*
|
|
vectorTransform*AffineMatrixTranslation(0.5,0.5)*
|
|
AffineMatrixScale(0.5,0.5)
|
|
AffineMatrixScale(0.5,0.5)
|
|
else
|
|
else
|
|
|
|
+ if pixelCentered then
|
|
img.OriginalEditor.GridMatrix := AffineMatrixTranslation(-0.5,-0.5)*
|
|
img.OriginalEditor.GridMatrix := AffineMatrixTranslation(-0.5,-0.5)*
|
|
- vectorTransform*AffineMatrixTranslation(0.5,0.5);
|
|
|
|
|
|
+ vectorTransform*AffineMatrixTranslation(0.5,0.5)
|
|
|
|
+ else
|
|
|
|
+ img.OriginalEditor.GridMatrix := AffineMatrixTranslation(-0.5,-0.5)*vectorTransform;
|
|
|
|
|
|
- img.OriginalEditor.GridActive := AActive;
|
|
|
|
|
|
+ img.OriginalEditor.GridActive := AActive or (zoomFactor < 2.1);
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
|
|
|
|
@@ -1579,6 +1590,22 @@ begin
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
+function TForm1.SnapToGrid(APoint: TPointF): TPointF;
|
|
|
|
+begin
|
|
|
|
+ if Assigned(img) and Assigned(img.OriginalEditor) and img.OriginalEditor.GridActive then
|
|
|
|
+ result := img.OriginalEditor.SnapToGrid(APoint, false)
|
|
|
|
+ else
|
|
|
|
+ result := APoint;
|
|
|
|
+end;
|
|
|
|
+
|
|
|
|
+function TForm1.ImgCoordToOriginalCoord(APoint: TPointF): TPointF;
|
|
|
|
+begin
|
|
|
|
+ if Assigned(img) and Assigned(img.OriginalEditor) and img.OriginalEditor.GridActive then
|
|
|
|
+ result := SnapToGrid(AffineMatrixInverse(vectorTransform)*APoint)
|
|
|
|
+ else
|
|
|
|
+ result := SnapToGrid(AffineMatrixInverse(AffineMatrixTranslation(-0.5,-0.5)*vectorTransform*AffineMatrixTranslation(0.5,0.5))*APoint);
|
|
|
|
+end;
|
|
|
|
+
|
|
procedure TForm1.DoCopy;
|
|
procedure TForm1.DoCopy;
|
|
begin
|
|
begin
|
|
if Assigned(vectorOriginal) and Assigned(vectorOriginal.SelectedShape) then
|
|
if Assigned(vectorOriginal) and Assigned(vectorOriginal.SelectedShape) then
|