mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-29 09:30:37 +02:00
TAChart: Move notificaction mechanism from TCustomChartSource to its new parent TBasicChartSource.
git-svn-id: trunk@51599 -
This commit is contained in:
parent
602ffd06d0
commit
69e99f6102
@ -128,6 +128,21 @@ type
|
|||||||
function ToImage(AX: Double): Integer; inline;
|
function ToImage(AX: Double): Integer; inline;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
TBasicChartSource = class(TComponent)
|
||||||
|
strict private
|
||||||
|
FBroadcaster: TBroadcaster;
|
||||||
|
FUpdateCount: Integer;
|
||||||
|
strict protected
|
||||||
|
procedure Notify;
|
||||||
|
public
|
||||||
|
constructor Create(AOwner: TComponent); override;
|
||||||
|
destructor Destroy; override;
|
||||||
|
procedure BeginUpdate;
|
||||||
|
procedure EndUpdate; virtual;
|
||||||
|
function IsUpdating: Boolean; inline;
|
||||||
|
property Broadcaster: TBroadcaster read FBroadcaster;
|
||||||
|
end;
|
||||||
|
|
||||||
TCustomChartSource = class;
|
TCustomChartSource = class;
|
||||||
|
|
||||||
TCustomChartSourceEnumerator = class
|
TCustomChartSourceEnumerator = class
|
||||||
@ -142,16 +157,14 @@ type
|
|||||||
property Current: PChartDataItem read GetCurrent;
|
property Current: PChartDataItem read GetCurrent;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
TCustomChartSource = class(TComponent)
|
TCustomChartSource = class(TBasicChartSource)
|
||||||
strict private
|
strict private
|
||||||
FBroadcaster: TBroadcaster;
|
|
||||||
FUpdateCount: Integer;
|
|
||||||
|
|
||||||
procedure SortValuesInRange(
|
procedure SortValuesInRange(
|
||||||
var AValues: TChartValueTextArray; AStart, AEnd: Integer);
|
var AValues: TChartValueTextArray; AStart, AEnd: Integer);
|
||||||
strict protected
|
strict protected
|
||||||
FExtent: TDoubleRect;
|
FExtent: TDoubleRect;
|
||||||
FExtentIsValid: Boolean;
|
FExtentIsValid: Boolean;
|
||||||
|
FUpdateCount: Integer;
|
||||||
FValuesTotal: Double;
|
FValuesTotal: Double;
|
||||||
FValuesTotalIsValid: Boolean;
|
FValuesTotalIsValid: Boolean;
|
||||||
FYCount: Cardinal;
|
FYCount: Cardinal;
|
||||||
@ -161,17 +174,13 @@ type
|
|||||||
function GetLink(AIndex: Integer): PChartLinkItem; virtual; abstract;
|
function GetLink(AIndex: Integer): PChartLinkItem; virtual; abstract;
|
||||||
function GetLinkCount: Integer; virtual; abstract;
|
function GetLinkCount: Integer; virtual; abstract;
|
||||||
procedure InvalidateCaches;
|
procedure InvalidateCaches;
|
||||||
procedure Notify;
|
|
||||||
procedure SetYCount(AValue: Cardinal); virtual; abstract;
|
procedure SetYCount(AValue: Cardinal); virtual; abstract;
|
||||||
public
|
public
|
||||||
constructor Create(AOwner: TComponent); override;
|
constructor Create(AOwner: TComponent); override;
|
||||||
destructor Destroy; override;
|
|
||||||
public
|
public
|
||||||
procedure AfterDraw; virtual;
|
procedure AfterDraw; virtual;
|
||||||
procedure BeforeDraw; virtual;
|
procedure BeforeDraw; virtual;
|
||||||
procedure BeginUpdate;
|
|
||||||
procedure EndUpdate; virtual;
|
procedure EndUpdate; virtual;
|
||||||
function IsUpdating: Boolean; inline;
|
|
||||||
public
|
public
|
||||||
class procedure CheckFormat(const AFormat: String);
|
class procedure CheckFormat(const AFormat: String);
|
||||||
function Extent: TDoubleRect; virtual;
|
function Extent: TDoubleRect; virtual;
|
||||||
@ -190,7 +199,6 @@ type
|
|||||||
function XOfMax: Double;
|
function XOfMax: Double;
|
||||||
function XOfMin: Double;
|
function XOfMin: Double;
|
||||||
|
|
||||||
property Broadcaster: TBroadcaster read FBroadcaster;
|
|
||||||
property Count: Integer read GetCount;
|
property Count: Integer read GetCount;
|
||||||
property Item[AIndex: Integer]: PChartDataItem read GetItem; default;
|
property Item[AIndex: Integer]: PChartDataItem read GetItem; default;
|
||||||
property Link[AIndex: Integer]: PChartLinkItem read GetLink;
|
property Link[AIndex: Integer]: PChartLinkItem read GetLink;
|
||||||
@ -449,6 +457,44 @@ begin
|
|||||||
YList[AIndex - 1] := AValue;
|
YList[AIndex - 1] := AValue;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
{ TBaisChartSource }
|
||||||
|
|
||||||
|
constructor TBasicChartSource.Create(AOwner: TComponent);
|
||||||
|
begin
|
||||||
|
inherited Create(AOwner);
|
||||||
|
FBroadcaster := TBroadcaster.Create;
|
||||||
|
end;
|
||||||
|
|
||||||
|
destructor TBasicChartSource.Destroy;
|
||||||
|
begin
|
||||||
|
FreeAndNil(FBroadcaster);
|
||||||
|
inherited Destroy;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TBasicChartSource.BeginUpdate;
|
||||||
|
begin
|
||||||
|
Inc(FUpdateCount);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TBasicChartSource.EndUpdate;
|
||||||
|
begin
|
||||||
|
Dec(FUpdateCount);
|
||||||
|
if FUpdateCount > 0 then exit;
|
||||||
|
Notify;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TBasicChartSource.IsUpdating: Boolean; inline;
|
||||||
|
begin
|
||||||
|
Result := FUpdateCount > 0;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TBasicChartSource.Notify;
|
||||||
|
begin
|
||||||
|
if not IsUpdating then
|
||||||
|
FBroadcaster.Broadcast(Self);
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
{ TChartSourceBuffer }
|
{ TChartSourceBuffer }
|
||||||
|
|
||||||
procedure TChartSourceBuffer.AddFirst(const AItem: TChartDataItem);
|
procedure TChartSourceBuffer.AddFirst(const AItem: TChartDataItem);
|
||||||
@ -596,11 +642,6 @@ begin
|
|||||||
// empty
|
// empty
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCustomChartSource.BeginUpdate;
|
|
||||||
begin
|
|
||||||
Inc(FUpdateCount);
|
|
||||||
end;
|
|
||||||
|
|
||||||
class procedure TCustomChartSource.CheckFormat(const AFormat: String);
|
class procedure TCustomChartSource.CheckFormat(const AFormat: String);
|
||||||
begin
|
begin
|
||||||
Format(AFormat, [0.0, 0.0, '', 0.0, 0.0]);
|
Format(AFormat, [0.0, 0.0, '', 0.0, 0.0]);
|
||||||
@ -609,16 +650,9 @@ end;
|
|||||||
constructor TCustomChartSource.Create(AOwner: TComponent);
|
constructor TCustomChartSource.Create(AOwner: TComponent);
|
||||||
begin
|
begin
|
||||||
inherited Create(AOwner);
|
inherited Create(AOwner);
|
||||||
FBroadcaster := TBroadcaster.Create;
|
|
||||||
FYCount := 1;
|
FYCount := 1;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
destructor TCustomChartSource.Destroy;
|
|
||||||
begin
|
|
||||||
FreeAndNil(FBroadcaster);
|
|
||||||
inherited;
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TCustomChartSource.EndUpdate;
|
procedure TCustomChartSource.EndUpdate;
|
||||||
begin
|
begin
|
||||||
Dec(FUpdateCount);
|
Dec(FUpdateCount);
|
||||||
@ -761,17 +795,6 @@ begin
|
|||||||
Result := false;
|
Result := false;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TCustomChartSource.IsUpdating: Boolean; inline;
|
|
||||||
begin
|
|
||||||
Result := FUpdateCount > 0;
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TCustomChartSource.Notify;
|
|
||||||
begin
|
|
||||||
if not IsUpdating then
|
|
||||||
FBroadcaster.Broadcast(Self);
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TCustomChartSource.SortValuesInRange(
|
procedure TCustomChartSource.SortValuesInRange(
|
||||||
var AValues: TChartValueTextArray; AStart, AEnd: Integer);
|
var AValues: TChartValueTextArray; AStart, AEnd: Integer);
|
||||||
var
|
var
|
||||||
|
Loading…
Reference in New Issue
Block a user