Harmonize wxGraphicsPathData::AddArcToPoint() behaviour across all ports

AddArcToPoint() on macOS port is implemented with native API (CGPathAddArcToPoint) so its behaviour should be considered as a reference for generic implementation used in another ports.

Closes #18086.
This commit is contained in:
Artur Wieczorek
2018-06-27 22:38:14 +02:00
parent c716b59783
commit 60669e9b50
3 changed files with 8 additions and 7 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

View File

@@ -50,9 +50,14 @@ public:
//@} //@}
/** /**
Appends a an arc to two tangents connecting (current) to (@a x1,@a y1) Adds an arc (of a circle with radius @a r) that is tangent
and (@a x1,@a y1) to (@a x2,@a y2), also a straight line from (current) to the line connecting current point and (@a x1, @a y1) and
to (@a x1,@a y1). to the line connecting (@a x1, @a y1) and (@a x2, @a y2).
If the current point and the starting point of the arc are different,
a straight line connecting these points is also appended.
After this call the current point will be at the ending point
of the arc.
@image html drawing-addarctopoint.png
*/ */
virtual void AddArcToPoint(wxDouble x1, wxDouble y1, wxDouble x2, virtual void AddArcToPoint(wxDouble x1, wxDouble y1, wxDouble x2,
wxDouble y2, wxDouble r); wxDouble y2, wxDouble r);

View File

@@ -479,7 +479,6 @@ void wxGraphicsPathData::AddArcToPoint( wxDouble x1, wxDouble y1 , wxDouble x2,
alpha == 0 || alpha == 180 || r == 0 ) alpha == 0 || alpha == 180 || r == 0 )
{ {
AddLineToPoint(p1.m_x, p1.m_y); AddLineToPoint(p1.m_x, p1.m_y);
AddLineToPoint(p2.m_x, p2.m_y);
return; return;
} }
@@ -489,8 +488,6 @@ void wxGraphicsPathData::AddArcToPoint( wxDouble x1, wxDouble y1 , wxDouble x2,
alpha = wxDegToRad(alpha); alpha = wxDegToRad(alpha);
wxDouble distT = r / sin(alpha) * (1.0 + cos(alpha)); // = r / tan(a/2) = r / sin(a/2) * cos(a/2) wxDouble distT = r / sin(alpha) * (1.0 + cos(alpha)); // = r / tan(a/2) = r / sin(a/2) * cos(a/2)
wxDouble distC = r / sin(alpha / 2.0); wxDouble distC = r / sin(alpha / 2.0);
wxASSERT_MSG( distT <= v1Length && distT <= v2Length,
wxS("Radius is too big to fit the arc to given points") );
// Calculate tangential points // Calculate tangential points
v1.Normalize(); v1.Normalize();
v2.Normalize(); v2.Normalize();
@@ -513,7 +510,6 @@ void wxGraphicsPathData::AddArcToPoint( wxDouble x1, wxDouble y1 , wxDouble x2,
AddLineToPoint(t1.m_x, t1.m_y); AddLineToPoint(t1.m_x, t1.m_y);
AddArc(c.m_x, c.m_y, r, wxDegToRad(a1), wxDegToRad(a2), drawClockwiseArc); AddArc(c.m_x, c.m_y, r, wxDegToRad(a1), wxDegToRad(a2), drawClockwiseArc);
AddLineToPoint(p2.m_x, p2.m_y);
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------