TAChart: Extract TChartRange.Intersect helper procedure

git-svn-id: trunk@32801 -
This commit is contained in:
ask 2011-10-10 13:34:55 +00:00
parent 82df2f14a7
commit 274955e748
2 changed files with 10 additions and 6 deletions

View File

@ -540,12 +540,7 @@ begin
FValueMin := GetTransform.GraphToAxis(FValueMin); FValueMin := GetTransform.GraphToAxis(FValueMin);
FValueMax := GetTransform.GraphToAxis(FValueMax); FValueMax := GetTransform.GraphToAxis(FValueMax);
EnsureOrder(FValueMin, FValueMax); EnsureOrder(FValueMin, FValueMax);
with Marks.Range do begin Marks.Range.Intersect(FValueMin, FValueMax);
if UseMin then
FValueMin := Math.Max(Min, FValueMin);
if UseMax then
FValueMax := Math.Min(Max, FValueMax);
end;
d := MakeValuesInRangeParams(FValueMin, FValueMax); d := MakeValuesInRangeParams(FValueMin, FValueMax);
FValueMin := GetTransform.AxisToGraph(FValueMin); FValueMin := GetTransform.AxisToGraph(FValueMin);
FValueMax := GetTransform.AxisToGraph(FValueMax); FValueMax := GetTransform.AxisToGraph(FValueMax);

View File

@ -320,6 +320,7 @@ type
public public
procedure Assign(ASource: TPersistent); override; procedure Assign(ASource: TPersistent); override;
procedure CheckBoundsOrder; procedure CheckBoundsOrder;
procedure Intersect(var AMin, AMax: Double);
published published
property Max: Double index 2 read GetBounds write SetBounds stored IsBoundsStored; property Max: Double index 2 read GetBounds write SetBounds stored IsBoundsStored;
property Min: Double index 1 read GetBounds write SetBounds stored IsBoundsStored; property Min: Double index 1 read GetBounds write SetBounds stored IsBoundsStored;
@ -1064,6 +1065,14 @@ begin
Result := FUseBounds[AIndex]; Result := FUseBounds[AIndex];
end; end;
procedure TChartRange.Intersect(var AMin, AMax: Double);
begin
if UseMin and (Min > AMin) then
AMin := Min;
if UseMax and (Max < AMax)then
AMax := Max;
end;
function TChartRange.IsBoundsStored(AIndex: Integer): Boolean; function TChartRange.IsBoundsStored(AIndex: Integer): Boolean;
begin begin
Result := FBounds[AIndex] <> 0; Result := FBounds[AIndex] <> 0;