Simplegraph - how to work with the field "Data"?

Please post bug reports, feature requests, or any question regarding the DELPHI AREA products here.

Simplegraph - how to work with the field "Data"?

Postby slavapro » October 6th, 2010, 2:45 am

Hello All!

The objects Node and Link is have the field DATA (TPointer). I would like to store additional parameters (Trecord or TObject) in these objects.

1. Will save the settings when you save SimpleGraph?

2. Please give sample code to work with these field.

Thanks in advance,
slavapro
slavapro
Active Member
Active Member
 
Posts: 16
Joined: June 27th, 2008, 2:38 pm

Re: Simplegraph - how to work with the field "Data"?

Postby Kambiz » October 6th, 2010, 3:05 am

Use OnObjectWrite event to save additional data of objects to the output stream, and use OnObjectRead event to load the additional data from the input stream.
Kambiz
User avatar
Kambiz
Administrator
Administrator
 
Posts: 2408
Joined: March 7th, 2003, 7:10 pm

Re: Simplegraph - how to work with the field "Data"?

Postby slavapro » October 6th, 2010, 11:58 am

Thanks for the quick response!

However, the description of the process is very scant. Could you give an example code?
slavapro
Active Member
Active Member
 
Posts: 16
Joined: June 27th, 2008, 2:38 pm

Re: Simplegraph - how to work with the field "Data"?

Postby Kambiz » October 6th, 2010, 12:23 pm

It's very simple.

Code: Select all
type
  PExtraObjectData = ^TExtraObjectData;
  TExtraObjectData = record
    CreationDate: TDateTime;
    ModifiedDate: TDateTime;
  end;

procedure TForm1.SimpleGraph1ObjectWrite(Graph: TSimpleGraph;
  GraphObject: TGraphObject; Stream: TStream);
begin
  if Assigned(GraphObject.Data) then
    Stream.Write(GraphObject.Data^, SizeOf(TExtraObjectData));
end;

procedure TForm1.SimpleGraph1ObjectRead(Graph: TSimpleGraph;
  GraphObject: TGraphObject; Stream: TStream);
begin
  if not Assigned(GraphObject.Data) then
    GraphObject.Data := AllocMem(SizeOf(TExtraObjectData));
  Stream.Read(GraphObject.Data^, SizeOf(TExtraObjectData));
end;
Kambiz
User avatar
Kambiz
Administrator
Administrator
 
Posts: 2408
Joined: March 7th, 2003, 7:10 pm

Re: Simplegraph - how to work with the field "Data"?

Postby slavapro » October 6th, 2010, 12:59 pm

Thank you!
Really very simple.
slavapro
Active Member
Active Member
 
Posts: 16
Joined: June 27th, 2008, 2:38 pm


Return to DELPHI AREA Products

Who is online

Users browsing this forum: No registered users and 1 guest

cron