mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-01 23:00:27 +02:00
TAChart: Replace TZoomDragTool.Proportional property with RatioLimit, allowing single-axis zooming
git-svn-id: trunk@29676 -
This commit is contained in:
parent
68dcc4d090
commit
10ae7cdbb1
@ -151,18 +151,26 @@ type
|
|||||||
read FAnimationSteps write FAnimationSteps default 0;
|
read FAnimationSteps write FAnimationSteps default 0;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
TZoomRatioLimit = (zrlNone, zrlProportional, zrlFixedX, zrlFixedY);
|
||||||
|
|
||||||
{ TZoomDragTool }
|
{ TZoomDragTool }
|
||||||
|
|
||||||
TZoomDragTool = class(TBasicZoomTool)
|
TZoomDragTool = class(TBasicZoomTool)
|
||||||
private
|
private
|
||||||
FProportional: Boolean;
|
FRatioLimit: TZoomRatioLimit;
|
||||||
FSelectionRect: TRect;
|
FSelectionRect: TRect;
|
||||||
|
function GetProportional: Boolean;
|
||||||
|
procedure SetProportional(AValue: Boolean);
|
||||||
public
|
public
|
||||||
procedure MouseDown(APoint: TPoint); override;
|
procedure MouseDown(APoint: TPoint); override;
|
||||||
procedure MouseMove(APoint: TPoint); override;
|
procedure MouseMove(APoint: TPoint); override;
|
||||||
procedure MouseUp(APoint: TPoint); override;
|
procedure MouseUp(APoint: TPoint); override;
|
||||||
published
|
published
|
||||||
property Proportional: Boolean read FProportional write FProportional default false;
|
property Proportional: Boolean
|
||||||
|
read GetProportional write SetProportional stored false default false;
|
||||||
|
deprecated;
|
||||||
|
property RatioLimit: TZoomRatioLimit
|
||||||
|
read FRatioLimit write FRatioLimit default zrlNone;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ TZoomClickTool }
|
{ TZoomClickTool }
|
||||||
@ -378,6 +386,8 @@ begin
|
|||||||
RegisterPropertyEditor(
|
RegisterPropertyEditor(
|
||||||
TypeInfo(TChartTools), TChartToolset, 'Tools', TToolsPropertyEditor);
|
TypeInfo(TChartTools), TChartToolset, 'Tools', TToolsPropertyEditor);
|
||||||
RegisterComponentEditor(TChartToolset, TToolsComponentEditor);
|
RegisterComponentEditor(TChartToolset, TToolsComponentEditor);
|
||||||
|
RegisterPropertyEditor(
|
||||||
|
TypeInfo(Boolean), TZoomDragTool, 'Proportional', THiddenPropertyEditor);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure RegisterChartToolClass(
|
procedure RegisterChartToolClass(
|
||||||
@ -773,6 +783,11 @@ end;
|
|||||||
|
|
||||||
{ TZoomDragTool }
|
{ TZoomDragTool }
|
||||||
|
|
||||||
|
function TZoomDragTool.GetProportional: Boolean;
|
||||||
|
begin
|
||||||
|
Result := RatioLimit = zrlProportional;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TZoomDragTool.MouseDown(APoint: TPoint);
|
procedure TZoomDragTool.MouseDown(APoint: TPoint);
|
||||||
begin
|
begin
|
||||||
if not FChart.AllowZoom then exit;
|
if not FChart.AllowZoom then exit;
|
||||||
@ -801,17 +816,31 @@ var
|
|||||||
newSize, oldSize: TDoublePoint;
|
newSize, oldSize: TDoublePoint;
|
||||||
coeff: Double;
|
coeff: Double;
|
||||||
begin
|
begin
|
||||||
if not Proportional then exit;
|
case RatioLimit of
|
||||||
newSize := ext.b - ext.a;
|
zrlNone: exit;
|
||||||
oldSize := FChart.LogicalExtent.b - FChart.LogicalExtent.a;
|
zrlProportional: begin
|
||||||
coeff := newSize.Y * oldSize.X;
|
newSize := ext.b - ext.a;
|
||||||
if coeff = 0 then exit;
|
oldSize := FChart.LogicalExtent.b - FChart.LogicalExtent.a;
|
||||||
coeff := newSize.X * oldSize.Y / coeff;
|
coeff := newSize.Y * oldSize.X;
|
||||||
if coeff = 0 then exit;
|
if coeff = 0 then exit;
|
||||||
if coeff > 1 then
|
coeff := newSize.X * oldSize.Y / coeff;
|
||||||
ExpandRange(ext.a.Y, ext.b.Y, (coeff - 1) / 2)
|
if coeff = 0 then exit;
|
||||||
else
|
if coeff > 1 then
|
||||||
ExpandRange(ext.a.X, ext.b.X, (1 / coeff - 1) / 2);
|
ExpandRange(ext.a.Y, ext.b.Y, (coeff - 1) / 2)
|
||||||
|
else
|
||||||
|
ExpandRange(ext.a.X, ext.b.X, (1 / coeff - 1) / 2);
|
||||||
|
end;
|
||||||
|
zrlFixedX:
|
||||||
|
with FChart.GetFullExtent do begin
|
||||||
|
ext.a.X := a.X;
|
||||||
|
ext.b.X := b.X;
|
||||||
|
end;
|
||||||
|
zrlFixedY:
|
||||||
|
with FChart.GetFullExtent do begin
|
||||||
|
ext.a.Y := a.Y;
|
||||||
|
ext.b.Y := b.Y;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
@ -833,6 +862,14 @@ begin
|
|||||||
Handled;
|
Handled;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TZoomDragTool.SetProportional(AValue: Boolean);
|
||||||
|
begin
|
||||||
|
if AValue then
|
||||||
|
RatioLimit := zrlProportional
|
||||||
|
else
|
||||||
|
RatioLimit := zrlNone;
|
||||||
|
end;
|
||||||
|
|
||||||
{ TReticuleTool }
|
{ TReticuleTool }
|
||||||
|
|
||||||
procedure TReticuleTool.MouseMove(APoint: TPoint);
|
procedure TReticuleTool.MouseMove(APoint: TPoint);
|
||||||
|
Loading…
Reference in New Issue
Block a user