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; CurCircle: TvCircle;
CurEllipse: TvEllipse; CurEllipse: TvEllipse;
CurArc: TvCircularArc; CurArc: TvCircularArc;
FinalStartAngle, FinalEndAngle: double;
begin begin
{$ifdef FPVECTORIALDEBUG} {$ifdef FPVECTORIALDEBUG}
WriteLn(':>DrawFPVectorialToCanvas'); WriteLn(':>DrawFPVectorialToCanvas');
@ -198,14 +199,27 @@ begin
begin begin
CurArc := CurEntity as TvCircularArc; CurArc := CurEntity as TvCircularArc;
{$ifdef USE_LCL_CANVAS} {$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); // Arc(ALeft, ATop, ARight, ABottom, Angle16Deg, Angle16DegLength: Integer);
ADest.Arc( ADest.Arc(
Round(ADestX + AmulX * (CurArc.CenterX - CurArc.Radius)), Round(ADestX + AmulX * (CurArc.CenterX - CurArc.Radius)),
Round(ADestY + AmulY * (CurArc.CenterY - CurArc.Radius)), Round(ADestY + AmulY * (CurArc.CenterY - CurArc.Radius)),
Round(ADestX + AmulX * (CurArc.CenterX + CurArc.Radius)), Round(ADestX + AmulX * (CurArc.CenterX + CurArc.Radius)),
Round(ADestY + AmulY * (CurArc.CenterY + CurArc.Radius)), Round(ADestY + AmulY * (CurArc.CenterY + CurArc.Radius)),
Round(16*CurArc.StartAngle), Round(16*FinalStartAngle),
Round(16*(CurArc.EndAngle - CurArc.StartAngle)) Round(16*(FinalEndAngle - FinalStartAngle))
); );
{$endif} {$endif}
end; end;

View File

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

View File

@ -64,7 +64,13 @@ begin
Vec.ReadFromFile(editFileName.FileName, vfDXF); Vec.ReadFromFile(editFileName.FileName, vfDXF);
imageView.Canvas.Brush.Color := clWhite; imageView.Canvas.Brush.Color := clWhite;
imageView.Canvas.FillRect(0, 0, imageView.Width, imageView.Height); 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 finally
Vec.Free; Vec.Free;
end; end;