## TSimpleGraph Issues (and wish list)

Please post bug reports, feature requests, or any question regarding the DELPHI AREA projects here.
Possible BUG
I have a SG and create a few nodes in it. The default Font of SG is used in the nodes. If I change the Font property of SG then the Font property on nodes changes as well becuase their font points to SG's font. This shouldn't be happen. Graph objects should have their individual font which initialy is a COPY of the default font of SG.

Kambiz, could you please verify this?
Fotis

kokkoras
Moderator

Posts: 317
Joined: March 12th, 2005, 11:19 pm
Location: Thessaloniki, Greece

I think this issue was discussed in another thread. As the result, in the next release the ParentFont property does not exist.
Kambiz

Kambiz

Posts: 2430
Joined: March 7th, 2003, 7:10 pm

Kambiz wrote:I think this issue was discussed in another thread. As the result, in the next release the ParentFont property does not exist.

I suggest to leave it, as it provides an initial font. In my app I use the following procedure to add a node:
Code: Select all
  myNode:= mySG.InsertNode(myRect, TRectangularNode);  myNode.Text:= 'Hello World';  myFont:= TFont.Create;  myFont.Name:= mySG.Font.Name;  myFont.Size:=  mySG.Font.Size;  // ....  goes like this for some more mySG.Font preperties  myNode.Font:= myFont;   myFont.Free;

That is, I create a new TFont instance, formating it according to SG.Font and point the font of the node to this font. Destroying the temporary font creates no problem (at least it seems so (?)) for the myNode.Font.

After that, changing the font of TSimpleGraph does not affect the nodes.
What do you think? Is it possible to use something similar in the library when you create a GraphObject? Besides, I happens when we change the font of an object using a FontDialog. After such a change the object's font is no longer connected to the font of SG. So why not doing it during object creation?
Fotis

kokkoras
Moderator

Posts: 317
Joined: March 12th, 2005, 11:19 pm
Location: Thessaloniki, Greece

For sure the initial font would be the control's font.

By the way, you do not need to write this amount of code, just set ParentFont property to False. In the other hand, to assign a font to another font object, use Assign method.
Kambiz

Kambiz

Posts: 2430
Joined: March 7th, 2003, 7:10 pm

Kambiz wrote:For sure the initial font would be the control's font.

Of which control? The one that hosts TSimpleGraph?
Kambiz wrote:In the other hand, to assign a font to another font object, use Assign method.
Thanks for the tip
Fotis

kokkoras
Moderator

Posts: 317
Joined: March 12th, 2005, 11:19 pm
Location: Thessaloniki, Greece

Contrary to what expected and to what Delphi help says, Assign does not do what it is supposed to. Trying this:
Code: Select all
  myFont:= TFont.Create;    myFont.Assign(mySG.Font);    myNode.Font:= myFont;   myFont.Free;

and later changing the SG.Font resulted in the same behaviour (node font changes as well). What's wrong?

edit: if I also set node's property ParentFont to false, then it works as desired. I couldn't figure out though what exactly does this ParentFont property do.
Fotis

kokkoras
Moderator

Posts: 317
Joined: March 12th, 2005, 11:19 pm
Location: Thessaloniki, Greece

There is a mistake in your code. Here is the correction:

Code: Select all
myFont:= TFont.Create; myFont.Assign(mySG.Font); myNode.Font.Assign(myFont);myFont.Free);

In the other hand, you do not need to create a temoporary font object. The following line does the same:

Code: Select all
myNode.Font.Assign(mySG.Font);

Although, even you do not need to do this assignment because this is already done in the constructor of the object.

By setting ParentFont to False, the object saves it's font information, and also changes in SG font doesn't change the object's font.
Kambiz

Kambiz

Posts: 2430
Joined: March 7th, 2003, 7:10 pm

Well, NOW I can say that SG.Font is very useful if combined with GraphObject.parentFont:=false. My format toolbar is set according to SG.Font when nothing is selected, SG.Font holds the font params for the new objects, while the toolbar displays proper font info when objects are selected and of caurse, allows the modification of font params for the selected.

14. I would like to have an OnSelectionChange event that will fire at the end of an action that modifies the list of selected objects. I am asking for this because the OnObjectSelect event of TSG fires as many times as are the selected objects. I can't figure out though how this could be implemented since objects are selected (deselected) incrementaly. I am thinking of an internal mode starting with the modification start and ending when modification end at which point the requested event fires.

Kambiz, is such an event feasible?
Fotis

kokkoras
Moderator

Posts: 317
Joined: March 12th, 2005, 11:19 pm
Location: Thessaloniki, Greece

It think it needs lot of work.
Kambiz

Kambiz

Posts: 2430
Joined: March 7th, 2003, 7:10 pm

Kambiz wrote:It think it needs lot of work.

That is my impression, too. Never mind. Thanks for the reply.
Fotis

kokkoras
Moderator

Posts: 317
Joined: March 12th, 2005, 11:19 pm
Location: Thessaloniki, Greece

Dirty Bug Report:

I have a TSG in the main form and I also have code in the OnObjectSelect event handler of TSG. For example, I make a call to SG.SelectedObjects.

When I am exiting my app with objects selected the app is exiting BUT with an EAccessViolation exception. Tracing the code reveals that execution is getting into the OnObjectSelect event handler where the exception occurs.

If no graph object is selected on exit, the app terminates gracefully.

I think the issue is related to how TSG is destroyed uppon application termination. The exact point of exception is not the SG.SelectedObjects call in the event handler. It occurs on the last line of TGraphObjectList.Delete(Index: Integer), that is, NotifyAction(Item, glRemoved); where Item=nil.

Any ideas?

edit: reproduced in a tiny app with the same behaviour
Fotis

kokkoras
Moderator

Posts: 317
Joined: March 12th, 2005, 11:19 pm
Location: Thessaloniki, Greece

Clear the graph before closing the application. OnCloseQuery can be a good place.
Kambiz

Kambiz

Posts: 2430
Joined: March 7th, 2003, 7:10 pm

Kambiz wrote:Clear the graph before closing the application. OnCloseQuery can be a good place.

Is it a bug or a feature?

edit: are you talking about the OnCloseQuery of the form?
Fotis

kokkoras
Moderator

Posts: 317
Joined: March 12th, 2005, 11:19 pm
Location: Thessaloniki, Greece

Yes!
Kambiz

Kambiz

Posts: 2430
Joined: March 7th, 2003, 7:10 pm

15. Add GDI+ support (for smooth curves)

edit: Consider the use of Graphics32 library instead.
Fotis

kokkoras
Moderator

Posts: 317
Joined: March 12th, 2005, 11:19 pm
Location: Thessaloniki, Greece

PreviousNext