mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-06 11:26:00 +02:00
TAChart: Fix operation of DataPointDragTool for TPieSeries
git-svn-id: trunk@58466 -
This commit is contained in:
parent
5d541aec27
commit
13cf806532
@ -410,30 +410,20 @@ end;
|
|||||||
|
|
||||||
procedure TCustomPieSeries.MovePointEx(var AIndex: Integer;
|
procedure TCustomPieSeries.MovePointEx(var AIndex: Integer;
|
||||||
AXIndex, AYIndex: Integer; const ANewPos: TDoublePoint);
|
AXIndex, AYIndex: Integer; const ANewPos: TDoublePoint);
|
||||||
const
|
|
||||||
SENS = 25; // empirical sensitivity factor for dragging
|
|
||||||
var
|
var
|
||||||
idx: Integer;
|
idx: Integer;
|
||||||
p: TPoint;
|
p: TPoint;
|
||||||
vslice, vdrag: TDoublePoint;
|
r1, r2, dist: Double;
|
||||||
phi, dist: Double;
|
|
||||||
begin
|
begin
|
||||||
Unused(AIndex, AXIndex, AYIndex);
|
Unused(AIndex, AXIndex, AYIndex);
|
||||||
|
|
||||||
if FExploded then begin
|
if FExploded then begin
|
||||||
p := ParentChart.GraphToImage(ANewPos);
|
idx := FindContainingSlice(FDragOrigin);
|
||||||
idx := FindContainingSlice(p);
|
|
||||||
if idx > -1 then begin
|
if idx > -1 then begin
|
||||||
// Center angle of slice (runs in counter-clockwise direction)
|
p := ParentChart.GraphToImage(ANewPos);
|
||||||
phi := FSlices[idx].CenterAngle;
|
r1 := sqrt(PointDist(FDragOrigin, FCenter));
|
||||||
// Radial slice vector (unit length)
|
r2 := sqrt(PointDist(p, FCenter));
|
||||||
vslice := DoublePoint(cos(phi), sin(phi));
|
dist := Source.Item[idx]^.X + (r2 - r1) / FRadius;
|
||||||
// Direction vector of dragging
|
|
||||||
vdrag := ANewPos - ParentChart.ImageToGraph(FDragOrigin);
|
|
||||||
// Projection of dragging vector onto slice vector (length)
|
|
||||||
dist := DotProduct(vdrag, vslice);
|
|
||||||
// Add to distance parameter in source (x)
|
|
||||||
dist := Source.Item[idx]^.X + DotProduct(vdrag, vslice) / SENS;
|
|
||||||
if dist < 0 then dist := 0; // Don't let value go negative
|
if dist < 0 then dist := 0; // Don't let value go negative
|
||||||
ListSource.BeginUpdate;
|
ListSource.BeginUpdate;
|
||||||
try
|
try
|
||||||
@ -441,6 +431,7 @@ begin
|
|||||||
finally
|
finally
|
||||||
ListSource.EndUpdate;
|
ListSource.EndUpdate;
|
||||||
end;
|
end;
|
||||||
|
FDragOrigin := p;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
Loading…
Reference in New Issue
Block a user