mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-30 00:11:51 +02:00
TAChart: Fix TCustomPieSeries.FindContainingSlice if one of the pies has size 0. Issue #36332, based on patch by TK.
git-svn-id: trunk@62282 -
This commit is contained in:
parent
a1cbba291f
commit
09c0c58381
@ -661,11 +661,19 @@ begin
|
||||
end;
|
||||
|
||||
function TCustomPieSeries.FindContainingSlice(const APoint: TPoint): Integer;
|
||||
const
|
||||
Neighbors: array[0..7] of TPoint = (
|
||||
(x:-1; y:-1), (x:0; y:-1), (x:1; y:-1),
|
||||
(x:-1; y:0), (x:1; y:0),
|
||||
(x:-1; y:1), (x:0; y:1), (x:1; y:1)
|
||||
);
|
||||
var
|
||||
c: TPoint;
|
||||
pointAngle: Double;
|
||||
minAngle, maxAngle: Double;
|
||||
ps: TPieSlice;
|
||||
innerRadius: Integer;
|
||||
neighbor: TPoint;
|
||||
begin
|
||||
innerRadius := CalcInnerRadius;
|
||||
for ps in FSlices do begin
|
||||
@ -680,7 +688,18 @@ begin
|
||||
if not InRange(sqr(c.X) + sqr(c.Y), sqr(innerRadius), sqr(FRadius)) then
|
||||
continue;
|
||||
pointAngle := NormalizeAngle(ArcTan2(-c.Y, c.X));
|
||||
if ps.FNextAngle <= ps.FPrevAngle then begin
|
||||
if ps.FNextAngle = ps.FPrevAngle then begin
|
||||
minAngle := pointAngle;
|
||||
maxAngle := pointAngle;
|
||||
for neighbor in Neighbors do begin
|
||||
pointAngle := NormalizeAngle(ArcTan2(-c.Y + neighbor.Y, c.X + neighbor.X));
|
||||
minAngle := Min(minAngle, pointAngle);
|
||||
maxAngle := Max(maxAngle, pointAngle);
|
||||
end;
|
||||
if InRange(ps.FPrevAngle, minAngle, maxAngle) then
|
||||
exit(ps.FOrigIndex);
|
||||
end else
|
||||
if ps.FNextAngle < ps.FPrevAngle then begin
|
||||
if InRange(pointAngle, ps.FPrevAngle - TWO_PI, ps.FNextAngle) or
|
||||
InRange(pointAngle, ps.FPrevAngle, ps.FNextAngle + TWO_PI)
|
||||
then
|
||||
|
Loading…
Reference in New Issue
Block a user