Remove TAEngine unit and TSeriesList class

Auto-update chart when one of its series is destroyed

patch by Alexander Klenin 
http://bugs.freepascal.org/view.php?id=12589

git-svn-id: trunk@17289 -
This commit is contained in:
darius 2008-11-08 21:08:01 +00:00
parent 5d167a14f7
commit cde07c30e6
6 changed files with 49 additions and 91 deletions

1
.gitattributes vendored
View File

@ -1407,7 +1407,6 @@ components/tachart/demo/unit1.lrs svneol=native#text/plain
components/tachart/demo/unit1.pas svneol=native#text/plain
components/tachart/tachartlazaruspkg.lpk svneol=native#text/plain
components/tachart/tachartlazaruspkg.pas svneol=native#text/plain
components/tachart/taengine.pas svneol=native#text/plain
components/tachart/tagraph.lrs svneol=native#text/plain
components/tachart/tagraph.pas svneol=native#text/plain
components/tachart/taseries.pas svneol=native#text/plain

View File

@ -28,14 +28,10 @@
<UnitName Value="TASeries"/>
</Item1>
<Item2>
<Filename Value="taengine.pas"/>
<UnitName Value="TAEngine"/>
</Item2>
<Item3>
<Filename Value="tagraph.pas"/>
<HasRegisterProc Value="True"/>
<UnitName Value="TAGraph"/>
</Item3>
</Item2>
</Files>
<Type Value="RunAndDesignTime"/>
<RequiredPkgs Count="2">

View File

@ -7,7 +7,7 @@ unit TAChartLazarusPkg;
interface
uses
TASeries, TAEngine, TAGraph, LazarusPackageIntf;
TASeries, TAGraph, LazarusPackageIntf;
implementation

View File

@ -1,54 +0,0 @@
{
/***************************************************************************
TAEngine.pp
----------
Component Library Standard Graph Helper Functions / Classes
***************************************************************************/
*****************************************************************************
* *
* See the file COPYING.modifiedLGPL.txt, included in this distribution, *
* for details about the copyright. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
* *
*****************************************************************************
Authors: Luís Rodrigues and Philippe Martinole
}
unit TAEngine;
interface
uses Classes;
type
//not completetly implemented (only TPieSeries - not all)
TSeriesMarksStyle=( smsValue, { 1234 }
smsPercent, { 12 % }
smsLabel, { Cars }
smsLabelPercent, { Cars 12 % }
smsLabelValue, { Cars 1234 }
smsLegend, { ? }
smsPercentTotal, { 12 % of 1234 }
smsLabelPercentTotal, { Cars 12 % of 1234 }
smsXValue); { 21/6/1996 }
TSeriesList = class(TList)
private
// function Add(Item: TASeries): Integer; override;
end;
implementation
end.

View File

@ -35,7 +35,7 @@ uses
{$ELSE}
Windows,
{$ENDIF}
SysUtils, Classes, Controls, Graphics, Dialogs, StdCtrls, TAEngine, Clipbrd;
SysUtils, Classes, Controls, Graphics, Dialogs, StdCtrls, Clipbrd;
const
MinDouble=-1.7e308;
@ -193,7 +193,7 @@ type
TmpBrush: TBrush;
TmpPen: TPen;
TmpFont: TFont;
FSeries:TSeriesList; // List of series
FSeries: TFPList; // List of series
FMirrorX:Boolean; // From right to left ?
YMarkWidth:Integer; // Depend on Y marks
FXGraphMin,FYGraphMin:Double; // Graph coordinates of limits
@ -332,7 +332,7 @@ type
property ChartHeight: Integer read GetChartHeight;
property ChartWidth: Integer read GetChartWidth;
property Series: TSeriesList read FSeries write FSeries;
property Series: TFPList read FSeries write FSeries;
published
{ Déclarations publiées }
procedure StyleChanged(Sender: TObject);
@ -899,7 +899,7 @@ begin
XMarkOld:=-1;
YMarkOld:=-1;
Series:=TSeriesList.Create;
Series := TFPList.Create;
YMarkWidth:=10;
@ -952,32 +952,29 @@ end;
destructor TChart.Destroy;
var
MySerie:TChartSeries;
i,c: integer;
i: Integer;
begin
if FSeries.Count > 0 then begin
c := FSeries.Count - 1;
for i := 0 to c do begin
TChartSeries(FSeries.Items[0]).Free;
FSeries.Delete( 0 );
end;
end;
for i := 0 to FSeries.Count - 1 do
with TChartSeries(FSeries.Items[i]) do begin
ParentChart := nil; // Prevent auto-update of the chart by series.
Free;
end;
FSeries.Free;
FGraphBrush.Free;
FSeries.Free;
FGraphBrush.Free;
TmpBrush.Destroy;
TmpPen.Destroy;
TmpFont.Destroy;
TmpBrush.Destroy;
TmpPen.Destroy;
TmpFont.Destroy;
FLegend.Destroy;
FTitle.Destroy;
FFoot.Destroy;
LeftAxis.Destroy;
BottomAxis.Destroy;
FFrame.Destroy;
FLegend.Destroy;
FTitle.Destroy;
FFoot.Destroy;
LeftAxis.Destroy;
BottomAxis.Destroy;
FFrame.Destroy;
inherited Destroy;
inherited Destroy;
end;
procedure TChart.StyleChanged(Sender: TObject);

View File

@ -35,17 +35,29 @@ uses
{$ELSE}
Windows,
{$ENDIF}
classes, graphics, tagraph, taengine, sysutils, dialogs;
Classes, Dialogs, Graphics, sysutils, TAGraph;
const
clTAColor = clScrollBar;
type
//not completetly implemented (only TPieSeries - not all)
TSeriesMarksStyle = (
smsValue, { 1234 }
smsPercent, { 12 % }
smsLabel, { Cars }
smsLabelPercent, { Cars 12 % }
smsLabelValue, { Cars 1234 }
smsLegend, { ? }
smsPercentTotal, { 12 % of 1234 }
smsLabelPercentTotal, { Cars 12 % of 1234 }
smsXValue); { 21/6/1996 }
ChartCoord = record
x, y: double;
Color: tcolor;
Text: string;
x, y: Double;
Color: TColor;
Text: String;
end;
PChartCoord = ^ChartCoord;
@ -217,6 +229,8 @@ type
property Active;
end;
{ TSerie }
TSerie = class(TChartSeries)
private
FPointer: TSeriesPointer;
@ -333,6 +347,11 @@ destructor TChartSeries.Destroy;
var
i: Integer;
begin
if ParentChart <> nil then
ParentChart.Series.Remove(Self);
UpdateParentChart;
ParentChart := nil;
for i := 0 to FCoordList.Count - 1 do
Dispose(PChartCoord(FCoordList.Items[i]));
FCoordList.Free;
@ -593,6 +612,7 @@ end;
destructor TSerie.Destroy;
begin
FPointer.Free;
inherited Destroy;
end;
@ -781,7 +801,7 @@ begin
(yi1 >= YMin) and (yi1 <= YMax) and
(xi1 >= XMin) and (xi1 <= XMax)
then
FPointer.draw(ACanvas, xi1, yi1, SeriesColor);
FPointer.Draw(ACanvas, xi1, yi1, SeriesColor);
end;