Page 1 of 2

shapes in my TDBTree have incorrect coordinates

Posted: Thu Nov 05, 2015 10:04 am
by 7727823
I have a problem in my DBTree concerning node placement on the canvas when the tree loads. Some of the leaf nodes exhibit a strange behaviour where their canvas coordinates are set to the top of the tree. The nodes are always leaf nodes, and consistently the same nodes on each startup. They only exhibit this behaviour when hidden by an unexpanded parent node.
The erroneous nodes are hidden but capture onClickShape events that were meant for the root node (clicking root node after startup selects hidden node X instead of root node as expected. Expanding X's parent shows X as selected in the tree and updates X's coordinates to the node's correct position).

I load the tree from a database table specifying parent and text fields, and using an integer as primary key on the table.

I am fairly new to working with TeeTree; is there a checklist for ensuring the tree is correctly loaded and initialized?
I work in Delphi XE using TeeTree2

Re: shapes in my TDBTree have incorrect coordinates

Posted: Fri Nov 06, 2015 4:18 pm
by yeray
Hello,

I'd suggest you to take a look at the TeeTree demo here:
TeeTreeDemo.zip
(310.71 KiB) Downloaded 497 times
If you still find problems with it, please try to arrange a simple example project we can run as-is to reproduce the problem here.

Thanks in advance.

Re: shapes in my TDBTree have incorrect coordinates

Posted: Mon Dec 07, 2015 2:05 pm
by 7727823
Hey there. I have succeeded in isolating the problem to a small example project.

It appears to happen if the Expanded property is set True on a child of an unexpanded note
How can I send you the sample project?

Re: shapes in my TDBTree have incorrect coordinates

Posted: Wed Dec 09, 2015 11:33 am
by yeray
Hello,

You can attach it in here in the forum.
As an alternative, you can also post your files at our upload page.

Re: shapes in my TDBTree have incorrect coordinates

Posted: Mon Dec 14, 2015 2:41 pm
by 7727823
I couldn't upload the file here, first it said maximum size 4MB exceeded. After fitting the project to this requirement it says maximum allowed size 512KB.. (You might want to have a look at that)

I've posted the files to your upload page by name bjarke moeholt, hopefully you can find them there.

In the project I've sent you, we use BDE database engine to establish a connection to and DBTree to visualize the contents of a database table. When setting the TTreeNodeShape.Expanded on nodes at level 1, we experience hidden shapes in unexpected places

Re: shapes in my TDBTree have incorrect coordinates

Posted: Tue Dec 15, 2015 8:47 am
by yeray
Hello,
HGG_User wrote:I couldn't upload the file here, first it said maximum size 4MB exceeded. After fitting the project to this requirement it says maximum allowed size 512KB.. (You might want to have a look at that)
The maximum file size allowed in these forums is 512KB.
I'm not sure what could be the message you got at first. If you get it again, please take a screenshot of it.
HGG_User wrote:I've posted the files to your upload page by name bjarke moeholt, hopefully you can find them there.

In the project I've sent you, we use BDE database engine to establish a connection to and DBTree to visualize the contents of a database table. When setting the TTreeNodeShape.Expanded on nodes at level 1, we experience hidden shapes in unexpected places
I get an error when your application tries to Open the FQuery:
Project SelectMapT.exe raised exception class EDBEngineError with message 'Unknown user name or password.
unavailable database
Alias: DB2350953'.
So I'm not able to reproduce the problem here.
Could you please simplify the application so we can reproduce the problem here?

Re: shapes in my TDBTree have incorrect coordinates

Posted: Tue Dec 15, 2015 2:54 pm
by 7727823
Since the problem is related to a DBTree component, a database engine to establish a connection to the database is needed. What database engine are you using?
The project assumes BDE is installed. It is available for free at http://cc.embarcadero.com/item/27573
The maximum file size allowed in these forums is 512KB.
I'm not sure what could be the message you got at first. If you get it again, please take a screenshot of it.
I've attached a screenshot to this post. Produced by attempting to upload a 5MB file:
Upload_Size_Error.png
Upload_Size_Error.png (90.52 KiB) Viewed 17161 times

Re: shapes in my TDBTree have incorrect coordinates

Posted: Wed Dec 16, 2015 6:08 pm
by yeray
Hello,
HGG_User wrote:Since the problem is related to a DBTree component, a database engine to establish a connection to the database is needed.
From the initial post I understood the problem was on TeeTree behaviour once the data is loaded, not in the loading process. In that case, creating some shapes manually would be a simpler example, if still reproducing the problem.
HGG_User wrote:What database engine are you using?
The project assumes BDE is installed. It is available for free at http://cc.embarcadero.com/item/27573
The project uses DB and DBTables. I'm trying it with RAD XE (that comes with BDE) and the project builds fine. However I get the mentioned error at runtime, when the Query tried to connect.
Do you have access to a second machine to check if that test project runs on it?
I've attached a screenshot to this post. Produced by attempting to upload a 5MB file:
Thanks for the screenshot. We'll check that.

Re: shapes in my TDBTree have incorrect coordinates

Posted: Tue Dec 22, 2015 9:18 am
by 7727823
The project uses DB and DBTables. I'm trying it with RAD XE (that comes with BDE) and the project builds fine. However I get the mentioned error at runtime, when the Query tried to connect.
Do you have access to a second machine to check if that test project runs on it?
ugh, this is turning into a database connectivity issue which is missing the point :/ We use Firebird 2.5 and BDE to connect to the database.
In case you are still having issues connecting, could you change the example to do what you normally do to connect databases in your end? Our focus should remain on the contents of the table and not the access tools

Re: shapes in my TDBTree have incorrect coordinates

Posted: Tue Dec 22, 2015 1:16 pm
by yeray
Hello,

I'm still finding problems with datasource you provided.
Could you please arrange a simple example project manually populating the tree?

Re: shapes in my TDBTree have incorrect coordinates

Posted: Tue Jan 05, 2016 1:01 pm
by 7727823
Ok, lets try again.. This time we're loading from xml, saving some space and working around database connectivity.

Re: shapes in my TDBTree have incorrect coordinates

Posted: Thu Jan 07, 2016 10:04 am
by yeray
Hello,

I could run your project and I've seen a single node on the tree.
Deppending on where I click, the information below changes, but the tree isn't expanded:
workspace.png
workspace.png (5.12 KiB) Viewed 17042 times
map.png
map.png (5.41 KiB) Viewed 17042 times
ssv.png
ssv.png (5.61 KiB) Viewed 17040 times
I see you aren't assigning parents on the nodes.
Modifying your FormCreate to assign the parents according to the xml, I get this:
working.png
working.png (16.86 KiB) Viewed 17038 times

Code: Select all

procedure TForm12.FormCreate(Sender: TObject);
var
  NewShape      : TTreeNodeShape;
  ParentShape   : TTreeNodeShape;
  Workspace     : Integer;
  Parent        : Integer;
begin
  CDS.LoadFromFile( ExtractFilePath( Application.ExeName ) + 'Workspacetbl.xml' );
  DBTree1.DataSet := CDS as Tdataset;
  DBTree1.Refresh;
  while not CDS.EOF do begin                             //Loop through the Query
    Workspace:=CDS.FieldByName('Workspace').AsInteger;
    //this is where we provoke the error: Expand all level 1 nodes and unexpand the rest.
    NewShape:=FindNode(DBTree1,Workspace);
    NewShape.Expanded := NewShape.Level=1;

    Parent:=CDS.FieldByName('Parent').AsInteger;
    ParentShape:=FindNode(DBTree1,Parent);
    NewShape.Parent:=ParentShape;

    CDS.Next;
  end;
  //MessageDlg('Error preparations completed: On our end, we have an invisible node overlapping the root node approx at the text field'
  //+ ' click to verify this', mtInformation, [mbOk], 0);
end;

Re: shapes in my TDBTree have incorrect coordinates

Posted: Fri Jan 08, 2016 11:14 am
by 7727823
I'm glad you are able to reproduce our problem. As you can see, the richedit mirrors the node properties of the last clicked node. When that changes it is because the Sender node of the onClick-events varies depending on where you click, despite the fact that, according to the GUI, we are clicking the same (and only) displayed node each time. It follows that some nodes are misplaced in the tree in the current state.

Expanding the tree corrects the subnode placement so that we are able to select the root node correctly. I'd guess its the redraw that corrects the incorrect node positions.
I see you aren't assigning parents on the nodes.
Modifying your FormCreate to assign the parents according to the xml, I get this:
You confuse me. We are assigning node parents design-time using the TDBTree ParentField property. Since the DBTree component should mirror the tree structure from a database table, I assume this is sufficient (it's not??)

Re: shapes in my TDBTree have incorrect coordinates

Posted: Mon Jan 11, 2016 4:10 pm
by yeray
Hello,

Excuse me I misunderstood it.
I see if you expand level 0 then everything seems to work fine. Ie, expanding levels 0, 1 and 3:

Code: Select all

NewShape.Expanded := (NewShape.Level=3) or (NewShape.Level=1) or (NewShape.Level=0);
However, I can reproduce the problem if I don't expand level 0 but I do expand any other level.

Could you please confirm it?

Re: shapes in my TDBTree have incorrect coordinates

Posted: Tue Jan 12, 2016 10:34 am
by 7727823
using

Code: Select all

NewShape.Expanded := (NewShape.Level=3) or (NewShape.Level=1) or (NewShape.Level=0);
also seems to work on my end