difference between remove/freeAllSeries?

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
HMI
Newbie
Newbie
Posts: 32
Joined: Fri May 11, 2007 12:00 am

difference between remove/freeAllSeries?

Post by HMI » Wed Jun 13, 2007 11:53 am

Hi,

this is no actual problem, but I'm interested
in these procedures working.

I have a TCustomChart which opens a new form and
with a own copy procedure, I copy this TCustomChart.
After closing the new Form, I copy this chart back.

Code: Select all

  
 procedure TKoordSys3D.copy(p_koordSys: TKoordSys3D);
 var l_temp_height, l_temp_width, l_temp_top, l_temp_left, l_i : integer;
 begin
  l_temp_height := Height;
  l_temp_width := Width;
  l_temp_top := Top;
  l_temp_left := Left;

  Assign(p_koordSys);

  Height := l_temp_height;
  Width := l_temp_width;
  Top := l_temp_top;
  Left := l_temp_left;

  removeAllSeries();
    for l_i := 0 to p_koordSys.SeriesCount - 1 do
    begin
      AddSeries(CloneChartSeries(p_koordSys[l_i]));
    end;
end;
I noticed, if I use freeAllSeries(), then only the first(in my case a
TSurfaceSerie) Serie is shown.
But using RemoveAllSeries() all Series are visible.
This happens when I close the form(so in the secound copy
call)

If you cannot answer this, no problem.

Kind regards,
HMI

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Wed Jun 13, 2007 12:01 pm

Hi HMI,

RemoveAllSeries() only disconnects series from chart (sets series ParentChart property to NULL) and does not actually free series. To free all series connected to a specific chart, use FreeAllSeries().
Last edited by Narcís on Wed Jun 13, 2007 1:00 pm, edited 1 time in total.
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

HMI
Newbie
Newbie
Posts: 32
Joined: Fri May 11, 2007 12:00 am

Post by HMI » Wed Jun 13, 2007 12:12 pm

Yes, I know.
Before the loop, I remove/free the existing series. No problem so far.
But then I add new copys of Series from another Chart.

Where is the difference, if I remove or free the Series before?
The freed/removed Series shouldn't interfer with the knew one's, should they?

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Wed Jun 13, 2007 2:32 pm

Hi HMI,
Where is the difference, if I remove or free the Series before?
Using RemoveAllSeries, series are not disposed, only their ParentChart is set to null and series are removed from the series list but does not free any memory associated with them. FreAllSeries destroys all series and frees their associated memory.
The freed/removed Series shouldn't interfer with the knew one's, should they?
No, they shouldn't. Are you experiencing any problem in that aspect?
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

HMI
Newbie
Newbie
Posts: 32
Joined: Fri May 11, 2007 12:00 am

Post by HMI » Wed Jun 13, 2007 2:55 pm

narcis wrote:Hi HMI,
No, they shouldn't. Are you experiencing any problem in that aspect?
No, not Problems. But I experience this behaviour and want a
explanation about this because I'm curious. Thats what I wanted to
explain in this thread^^

I try to explain it again. This is my Copy procedure in my TCustomChart:

Code: Select all

 procedure TKoordSys3D.copy(p_koordSys: TKoordSys3D);
 var l_temp_height, l_temp_width, l_temp_top, l_temp_left, l_i : integer;
 begin
  l_temp_height := Height;
  l_temp_width := Width;
  l_temp_top := Top;
  l_temp_left := Left;

  Assign(p_koordSys);

  Height := l_temp_height;
  Width := l_temp_width;
  Top := l_temp_top;
  Left := l_temp_left;

  removeAllSeries();
  for l_i := 0 to p_koordSys.SeriesCount - 1 do
  begin
    AddSeries(CloneChartSeries(p_koordSys[l_i]));
    if p_koordSys[l_i].Visible then
      Series[l_i].Visible := true
    else
    begin
      Series[l_i].Visible := false;
      showmessage('blöubbbb');
    end;

  end;
 end;
And here I create a new Form,also in my TCustomChart, as you'll see:
(I pass my TCustomChart via the create procedure)

Code: Select all

 procedure TKoordSys3D.MyOnclick(p_sender:TObject);
 begin
  Frmgraphwindow2d := TFrmgraphwindow2d.create(self);
  Frmgraphwindow2d.ShowModal();
  copy(Frmgraphwindow2d.c_kSys3D); [b]// This is the secound call of the copy-procedure[/b]
  Frmgraphwindow2d.Free();
 end;
And this is the part where the copy procedure is called the first time:


And here is, when

Code: Select all

constructor TFrmgraphwindow2d.create(p_AOwner: TComponent);
begin
inherited create(p_AOwner);
 c_kSys3D := TKoordSys3D.create(self);
 c_kSys3D.copy(TKoordSys3D(p_AOwner));
 c_kSys3D.Parent := self;
 c_kSys3D.Visible := true;
 c_kSys3D.Width := 600;
 c_kSys3D.Height := 600;
 c_kSys3D.Left := 0;
 c_kSys3D.top := 75;
 c_kSys3D.enableOnClick(false);
 teeCom_details.Panel := c_kSys3D;

end;
Though, if I use removeAllSeries, there is no problem.
But if I use freeAllSeries there is only on Series left after
closing the Form(when the copy-procedure is called the secound time)

Hopefully now the case is clearer^^

Kind regards and a nice evening,
HMI

Post Reply