Newbie in GoDiagram

Note that the “Child” in AddChildName and related methods refers to the part hierarchy formed by a GoGroup as the “parent” and the various GoObjects that it contains as the “children”.

It does not refer to any application-specific logical relationships you might be interested in defining between various nodes.

thanks for your help and sorry for trouble you all again. Thanks.

hi jake/walter,

By using coding, how do i select an existed node in the GoView and link to a newly created node? I'm using the MakeNode(PointF loc, string text) from the sample project.
GoBasicNode bn = new GoBasicNode();
GoDocument doc = new GoDocument();
bn.LabelSpot = GoObject.Middle; // use GoDocument.UserFlags as a persistent way to remember the next node counter

bn.Location = loc;

bn.Port.IsValidSelfNode = true;
GoView1.Document.Add(bn);
bn.LabelSpot = GoObject.Middle;
bn.Text = text;
if(doc.FindNode(text)!=null)
{
return (GoBasicNode) GoView1.Selection.Select(doc.FindNode(text));
}
else
return bn;

bn is the BasicNode you just created, so I don’t understand why you are using FindNode to select bn.

GoView.Selection.Select(bn);

return bn;

should work.

To connect two GoBasicNodes with a link:


   public GoLink ConnectNetworkNode(GoBasicNode a, GoBasicNode b) {
      if (a == null) return null;
      if (b == null) return null;
      GoLink l = new GoLink();
      l.FromPort = a.Port;
      l.ToPort = b.Port;
      Add(l);
      return l;
    }

I’ll leave finding the “other” GoBasicNode up to you, since I don’t know your requirements.

Dear Jake,

Sorry for not giving my requirement in detail enough. Basically, what i want is as below.
I'm drawing the nodes from the database. There will be many nodes inside GoView. The node will be cross linked. I would like to find a specific node in the GoView and then link it with other node. Please help.
thanks.

There’s no one way to do that.

If GoDocument.MaintainsPartID is true, each of those new nodes will have a unique PartID and you can use GoDocument.FindPart.
Or keep a hash table the way DataSetDemo does to map RowId to node.

Can I link the new node and old node without using the hashtable? is there a way? I want to use the GoDocument.Findpart;

ok… taking MinimalApp as a starting point, the red code shows use of PartID.

[code]
public MinimalApp() {
this.Text = "Minimal GoDiagram App";
// create a Go view (a Control) and add to the form
GoView myView = new GoView();
myView.Dock = DockStyle.Fill;
this.Controls.Add(myView);
myView.Document.MaintainsPartID = true;
myView.Document.LastPartID = 1;
// create two nodes for fun...
GoBasicNode node1 = new GoBasicNode();
// specify position, label and color
node1.Location = new PointF(100, 100);
node1.Text = "first";
node1.Editable = true; // first node is editable with F2 only
node1.Shape.BrushColor = Color.Blue;
// add to the document, not to the view
myView.Document.Add(node1);
int n1partid = node1.PartID; // node must be in doc before PartID is valid
GoBasicNode node2 = new GoBasicNode();
node2.Location = new PointF(200, 100);
node2.Text = "second";
node2.Label.Editable = true; // second node is editable by clicking only
node2.Shape.BrushColor = Color.Magenta;
myView.Document.Add(node2);
int n2partid = node2.PartID;
// ok, now find nodes based on PartID and add a link
object x1 = myView.Document.FindPart(n1partid);
GoBasicNode n1 = x1 as GoBasicNode;
object x2 = myView.Document.FindPart(n2partid);
GoBasicNode n2 = x2 as GoBasicNode;

if (n1 != null && n2 != null)
{
GoLink link = new GoLink();
myView.Document.Add(link);
link.FromPort = n1.Port;
link.ToPort = n2.Port;
}
}
[/code]
hi,
what does this "myView.Document.LastPartID = 1;" means?

It sets the initial starting point for PartID. Actually, by setting it to 1, I think the first PartID allocated to a node is 2.

Yes, I wouldn’t bother setting the GoDocument.LastPartID during normal usage. It’s really only needed when loading an existing document, for compatibility with the original editing environment.

Also, instead of remembering the node PartID, I would remember the port PartID. So:


int p1id = node1.Port.PartID;


int p2id = node2.Port.PartID;

GoPort p1 = myView.Document.FindPart(p1id) as GoPort;
GoPort p2 = myView.Document.FindPart(p2id) as GoPort;
if (p1 != null && p2 != null) {
GoLink link = new GoLink();
link.FromPort = p1;
link.ToPort = p2;
// …set other link properties…
myView.Document.Add(link);
}

hi,

Can i set the Port.PartID a value? Thanks.

hi, what is the diff betwen Port.PartID and Node.PartID?

Can i set the Port.PartID a value?

You can get/set PartID if you want, but GoDocument.FindPart won't work unless MaintainsPartID is true. (FindPart uses a Hashtable that is only maintained when MaintainsPartID is true.)
> what is the diff betwen Port.PartID and Node.PartID?
There's no difference in the IDs, just the object the unique ID is tagged to. Both GoNode and GoPort support IGoIdentifiablePart.

What are the differneces between findpart() and findnode()?

thanks.
FindNode uses the IGoLabeledPart interface to get the node.Text, and searches that.
FindPart is searching IGoIdentifiablePart.PartID.

Hi,

I have a big question here. Hope that you can help me to solve it.
I'm trying to use the example that you recommended to me earlier. I used the functions like LinkNode(), MakeNode(). I'm using the "Layered Digraph Auto Layout".
HS750020.01 HS750020.06 SPLT
HS750020.01 HS751032.01 MRLT
HS750020.01 HS750068.01 MRLT
HS750020.01 HS750037.03 MRLT
HS750020.01 HS750029.04 MRLT
HS750020.01 HS750025.01 MRLT
HS750020.01 HS750020.01 MRLT
HS750020.01 HS750020.01 MRLT
HS750020.01 HS750020.01 MRLT
HS750020.01 HS750020.01 MRLT
HS750020.01 HS750020.01 MRLT
HS750020.05 HS750020.98 SPLT
HS750020.06 HS750020.01 MRLT
HS750020.04 HS750020.96 SPLT
HS750020 HS750020.05 SPLT
HS750020 HS750020.04 SPLT
HS750020 HS750020.03 SPLT
HS750020 HS750020.02 SPLT
HS750020 HS750020.01 SPLT
HS750020.03 HS750020.99 SPLT
HS750020.02 HS750020.97 SPLT
I have the data as above and wish to draw out the relationship diagram out of these big data. The relationship diagram starts with node "HS750020". There will be SPLT (split) or MRLT (merge) between the nodes. For this example, the output should be something like this. You can ignore the MRLT and SPLT
HS750025.01 --------|
HS750020.01 --------|
HS750020.01 --------|
HS750020.01 --------|
HS750020.01 --------|
HS750020.01 --------|
HS750029.04 --------|
HS750037.03 --------|
HS750068.01 --------| MRLT
HS751032.01 --------| ---------------------
| |
HS750020 -- HS750020.01 -- HS750020.06
-- HS750020.02 -- HS750020.97
-- HS750020.03 -- HS750020.99
-- HS750020.04 -- HS750020.96
-- HS750020.05 -- HS750020.98
SPLT SPLT
Your help is very much appreciated. Thanks

Sorry, but what’s your question ? What you have there doesn’t look like a layout you’re going to get out of Layered Digraph, but it’s a little hard to tell exactly.

Hi, my question here is how do i manipulate the data that i have, to draw out a node relationship diagram for the whole data. Let me explain the data to you.

eg. HS750020.01 HS750020.06 SPLT
This means that HS750020.01 will split from the HS750020.06. So, the diagram will look like this HS750020.01 --> HS750020.06
eg. HS750020.01 HS750068.01 MRLT
This means that HS750068.01 will merge into HS750020.01. So, the diagram will look like this HS750068.01 -->HS750020.01
However i doesn't know how do use back the same node after it is drawn in the GoView.
eg. HS750020 --> HS750020.01 (were drawn in the GoView)
then, i want to mixed this HS750020.01-->HS750020.06 to the above, which become
HS750020 --> HS750020.01 -->HS750020.06
I doesn't want to create two same node in the GoView.
By the way, is there a way that i can attach file in the forum?
Your help is much appreciated. Thanks.

You can upload pictures if you click the “post reply” button on the bottom right. (the Quick Reply doesn’t have the upload feature)