mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-02 12:00:15 +02:00
TAChart: Extract TBasicPo.FindExtentInterval procedure
+ Minor refactoring. git-svn-id: trunk@40053 -
This commit is contained in:
parent
e755978110
commit
017e658f9c
@ -89,7 +89,7 @@ type
|
|||||||
function TitleIsStored: Boolean; virtual;
|
function TitleIsStored: Boolean; virtual;
|
||||||
|
|
||||||
public
|
public
|
||||||
function AxisToGraph(const APoint: TDoublePoint): TDoublePoint;
|
function AxisToGraph(const APoint: TDoublePoint): TDoublePoint; inline;
|
||||||
function AxisToGraphX(AX: Double): Double; override;
|
function AxisToGraphX(AX: Double): Double; override;
|
||||||
function AxisToGraphY(AY: Double): Double; override;
|
function AxisToGraphY(AY: Double): Double; override;
|
||||||
function GetAxisX: TChartAxis;
|
function GetAxisX: TChartAxis;
|
||||||
@ -242,26 +242,28 @@ type
|
|||||||
FUpBound: Integer;
|
FUpBound: Integer;
|
||||||
FUseReticule: Boolean;
|
FUseReticule: Boolean;
|
||||||
|
|
||||||
strict protected
|
|
||||||
procedure DrawLabels(ADrawer: IChartDrawer);
|
|
||||||
function GetLabelDataPoint(AIndex: Integer): TDoublePoint; virtual;
|
|
||||||
procedure UpdateGraphPoints(AIndex: Integer); overload; inline;
|
|
||||||
procedure UpdateGraphPoints(AIndex, ALo, AUp: Integer); overload;
|
|
||||||
protected
|
|
||||||
procedure AfterAdd; override;
|
|
||||||
procedure AfterDrawPointer(
|
procedure AfterDrawPointer(
|
||||||
ADrawer: IChartDrawer; AIndex: Integer; const APos: TPoint); virtual;
|
ADrawer: IChartDrawer; AIndex: Integer; const APos: TPoint); virtual;
|
||||||
|
procedure DrawLabels(ADrawer: IChartDrawer);
|
||||||
procedure DrawPointers(ADrawer: IChartDrawer);
|
procedure DrawPointers(ADrawer: IChartDrawer);
|
||||||
|
procedure FindExtentInterval(
|
||||||
|
const AExtent: TDoubleRect; AFilterByExtent: Boolean);
|
||||||
|
function GetLabelDataPoint(AIndex: Integer): TDoublePoint; virtual;
|
||||||
procedure GetLegendItemsRect(AItems: TChartLegendItems; ABrush: TBrush);
|
procedure GetLegendItemsRect(AItems: TChartLegendItems; ABrush: TBrush);
|
||||||
function GetXRange(AX: Double; AIndex: Integer): Double;
|
function GetXRange(AX: Double; AIndex: Integer): Double;
|
||||||
function GetZeroLevel: Double; virtual;
|
function GetZeroLevel: Double; virtual;
|
||||||
function NearestXNumber(var AIndex: Integer; ADir: Integer): Double;
|
function NearestXNumber(var AIndex: Integer; ADir: Integer): Double;
|
||||||
procedure PrepareGraphPoints(
|
procedure PrepareGraphPoints(
|
||||||
const AExtent: TDoubleRect; AFilterByExtent: Boolean);
|
const AExtent: TDoubleRect; AFilterByExtent: Boolean);
|
||||||
procedure UpdateMargins(ADrawer: IChartDrawer; var AMargins: TRect); override;
|
procedure UpdateGraphPoints(AIndex: Integer); overload; inline;
|
||||||
|
procedure UpdateGraphPoints(AIndex, ALo, AUp: Integer); overload;
|
||||||
procedure UpdateMinXRange;
|
procedure UpdateMinXRange;
|
||||||
|
|
||||||
property Pointer: TSeriesPointer read FPointer write SetPointer;
|
property Pointer: TSeriesPointer read FPointer write SetPointer;
|
||||||
|
protected
|
||||||
|
procedure AfterAdd; override;
|
||||||
|
procedure UpdateMargins(ADrawer: IChartDrawer; var AMargins: TRect); override;
|
||||||
|
|
||||||
public
|
public
|
||||||
destructor Destroy; override;
|
destructor Destroy; override;
|
||||||
public
|
public
|
||||||
@ -993,6 +995,27 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
// Find an interval of x-values intersecting the extent.
|
||||||
|
// Requires monotonic (but not necessarily increasing) axis transformation.
|
||||||
|
procedure TBasicPointSeries.FindExtentInterval(
|
||||||
|
const AExtent: TDoubleRect; AFilterByExtent: Boolean);
|
||||||
|
var
|
||||||
|
axisExtent: TDoubleInterval;
|
||||||
|
begin
|
||||||
|
FLoBound := 0;
|
||||||
|
FUpBound := Count - 1;
|
||||||
|
if AFilterByExtent then begin
|
||||||
|
with AExtent do
|
||||||
|
if IsRotated then
|
||||||
|
axisExtent := DoubleInterval(GraphToAxisY(a.Y), GraphToAxisY(b.Y))
|
||||||
|
else
|
||||||
|
axisExtent := DoubleInterval(GraphToAxisX(a.X), GraphToAxisX(b.X));
|
||||||
|
Source.FindBounds(axisExtent.FStart, axisExtent.FEnd, FLoBound, FUpBound);
|
||||||
|
FLoBound := Max(FLoBound - 1, 0);
|
||||||
|
FUpBound := Min(FUpBound + 1, Count - 1);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
function TBasicPointSeries.GetLabelDataPoint(AIndex: Integer): TDoublePoint;
|
function TBasicPointSeries.GetLabelDataPoint(AIndex: Integer): TDoublePoint;
|
||||||
begin
|
begin
|
||||||
Result := GetGraphPoint(AIndex);
|
Result := GetGraphPoint(AIndex);
|
||||||
@ -1129,23 +1152,9 @@ end;
|
|||||||
procedure TBasicPointSeries.PrepareGraphPoints(
|
procedure TBasicPointSeries.PrepareGraphPoints(
|
||||||
const AExtent: TDoubleRect; AFilterByExtent: Boolean);
|
const AExtent: TDoubleRect; AFilterByExtent: Boolean);
|
||||||
var
|
var
|
||||||
axisExtent: TDoubleInterval;
|
|
||||||
i: Integer;
|
i: Integer;
|
||||||
begin
|
begin
|
||||||
// Find an interval of x-values intersecting the extent.
|
FindExtentInterval(AExtent, AFilterByExtent);
|
||||||
// Requires monotonic (but not necessarily increasing) axis transformation.
|
|
||||||
FLoBound := 0;
|
|
||||||
FUpBound := Count - 1;
|
|
||||||
if AFilterByExtent then begin
|
|
||||||
with AExtent do
|
|
||||||
if IsRotated then
|
|
||||||
axisExtent := DoubleInterval(GraphToAxisY(a.Y), GraphToAxisY(b.Y))
|
|
||||||
else
|
|
||||||
axisExtent := DoubleInterval(GraphToAxisX(a.X), GraphToAxisX(b.X));
|
|
||||||
Source.FindBounds(axisExtent.FStart, axisExtent.FEnd, FLoBound, FUpBound);
|
|
||||||
FLoBound := Max(FLoBound - 1, 0);
|
|
||||||
FUpBound := Min(FUpBound + 1, Count - 1);
|
|
||||||
end;
|
|
||||||
|
|
||||||
SetLength(FGraphPoints, FUpBound - FLoBound + 1);
|
SetLength(FGraphPoints, FUpBound - FLoBound + 1);
|
||||||
if (AxisIndexX < 0) and (AxisIndexY < 0) then
|
if (AxisIndexX < 0) and (AxisIndexY < 0) then
|
||||||
|
Loading…
Reference in New Issue
Block a user