Finishes fixing the arc to canvas drawing

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@1490 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
sekelsenmat
2011-02-10 07:44:38 +00:00
parent 59b3249cc1
commit 11f1066ff7
3 changed files with 42 additions and 23 deletions

View File

@ -114,6 +114,7 @@ var
CurCircle: TvCircle;
CurEllipse: TvEllipse;
CurArc: TvCircularArc;
FinalStartAngle, FinalEndAngle: double;
begin
{$ifdef FPVECTORIALDEBUG}
WriteLn(':>DrawFPVectorialToCanvas');
@ -198,14 +199,27 @@ begin
begin
CurArc := CurEntity as TvCircularArc;
{$ifdef USE_LCL_CANVAS}
// ToDo: Consider a X axis inversion
// If the Y axis is inverted, then we need to mirror our angles as well
if AMulY > 0 then
begin
FinalStartAngle := CurArc.StartAngle;
FinalEndAngle := CurArc.EndAngle;
end
else // AMulY is negative
begin
// Inverting the angles generates the correct result for Y axis inversion
FinalStartAngle := 360 - 1* CurArc.EndAngle;
FinalEndAngle := 360 - 1* CurArc.StartAngle;
end;
// Arc(ALeft, ATop, ARight, ABottom, Angle16Deg, Angle16DegLength: Integer);
ADest.Arc(
Round(ADestX + AmulX * (CurArc.CenterX - CurArc.Radius)),
Round(ADestY + AmulY * (CurArc.CenterY - CurArc.Radius)),
Round(ADestX + AmulX * (CurArc.CenterX + CurArc.Radius)),
Round(ADestY + AmulY * (CurArc.CenterY + CurArc.Radius)),
Round(16*CurArc.StartAngle),
Round(16*(CurArc.EndAngle - CurArc.StartAngle))
Round(16*FinalStartAngle),
Round(16*(FinalEndAngle - FinalStartAngle))
);
{$endif}
end;

View File

@ -9,7 +9,7 @@ object frmFPVViewer: TfrmFPVViewer
LCLVersion = '0.9.31'
object editFileName: TFileNameEdit
Left = 8
Height = 23
Height = 22
Top = 8
Width = 304
DialogOptions = []
@ -31,7 +31,7 @@ object frmFPVViewer: TfrmFPVViewer
end
object spinScale: TFloatSpinEdit
Left = 72
Height = 23
Height = 16
Top = 72
Width = 64
Increment = 1
@ -42,23 +42,23 @@ object frmFPVViewer: TfrmFPVViewer
end
object Label1: TLabel
Left = 8
Height = 16
Height = 17
Top = 79
Width = 47
Width = 56
Caption = 'Scale by:'
ParentColor = False
end
object Label2: TLabel
Left = 8
Height = 16
Height = 17
Top = 104
Width = 60
Width = 73
Caption = 'Start Pos X:'
ParentColor = False
end
object spinStartX: TSpinEdit
Left = 98
Height = 23
Height = 16
Top = 99
Width = 46
MaxValue = 1000
@ -67,7 +67,7 @@ object frmFPVViewer: TfrmFPVViewer
end
object spinStartY: TSpinEdit
Left = 240
Height = 23
Height = 16
Top = 99
Width = 50
MaxValue = 1000
@ -76,9 +76,9 @@ object frmFPVViewer: TfrmFPVViewer
end
object Label3: TLabel
Left = 152
Height = 16
Height = 17
Top = 104
Width = 60
Width = 72
Caption = 'Start Pos Y:'
ParentColor = False
end
@ -97,35 +97,34 @@ object frmFPVViewer: TfrmFPVViewer
AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom
Left = 0
Height = 340
Height = 345
Top = 128
Width = 370
Width = 375
PageIndex = 0
Anchors = [akTop, akLeft, akRight, akBottom]
BorderSpacing.Right = 5
BorderSpacing.Bottom = 5
TabOrder = 6
TabStop = True
object Page1: TPage
ClientWidth = 370
ClientHeight = 340
ClientWidth = 375
ClientHeight = 345
object imageView: TImage
AnchorSideRight.Control = Page1
AnchorSideRight.Side = asrBottom
AnchorSideBottom.Control = Page1
AnchorSideBottom.Side = asrBottom
Left = 8
Height = 327
Height = 332
Top = 8
Width = 357
Width = 362
Anchors = [akTop, akLeft, akRight, akBottom]
AutoSize = True
BorderSpacing.Right = 5
BorderSpacing.Bottom = 5
end
end
object Page2: TPage
ClientWidth = 2688
ClientHeight = 2504
ClientWidth = 21504
ClientHeight = 20032
object DXFTreeView: TTreeView
Left = 8
Height = 313

View File

@ -64,7 +64,13 @@ begin
Vec.ReadFromFile(editFileName.FileName, vfDXF);
imageView.Canvas.Brush.Color := clWhite;
imageView.Canvas.FillRect(0, 0, imageView.Width, imageView.Height);
DrawFPVectorialToCanvas(Vec, imageView.Canvas, spinStartX.Value, spinStartY.Value, spinScale.Value, spinScale.Value);
DrawFPVectorialToCanvas(
Vec,
imageView.Canvas,
spinStartX.Value,
spinStartY.Value + imageView.Height,
spinScale.Value,
-1 * spinScale.Value);
finally
Vec.Free;
end;