Hi ,
I try to save the location of my nodes but i have an issue when i move my node the location is not correct . In my node template i show the X and Y .
In this sample i moved F1 and F2 the coordinate are corrects.
But if i move R1, the coordinate of F1 and F2 changed.
myLocalDiagram.nodeTemplateMap.add("Field",
GO(go.Node, go.Panel.Vertical, { locationSpot: go.Spot.Center, selectionObjectName:'selection' },
new go.Binding("location", "loc",<span ="apple-tab-span"="" style="white-space:pre"> </span>go.Point.parse).makeTwoWay(go.Point.stringify),
new go.Binding("text", "key"),
GO(go.Panel, go.Panel.Auto, { name: 'selection' },
GO(go.Shape, "RoundedRectangle",
{ fill: FieldColor, stroke: null }),
GO(go.Panel, go.Panel.Horizontal,
GO(go.Picture,
new go.Binding("source", "category", <span ="apple-tab-span"="" style="white-space:pre"> </span>nodeTypeImage), { width: 40, height: 40 }),
GO(go.TextBlock, textStyle(),
{ text: 'Field' },
new go.Binding("text", "text").makeTwoWay())
)),
<span ="apple-tab-span"="" style="white-space:pre"> </span> GO(go.TextBlock, textStyle(),
<span ="apple-tab-span"="" style="white-space:pre"> </span> new go.Binding("text", "loc", function (p) { return p; })
)
))
,
{
click: function (e, obj) { LeftLocalClick() }
}
)
);
myFullDiagram.nodeTemplateMap.add("Reservoir",
GO(go.Node, go.Panel.Vertical, { locationSpot: go.Spot.Center, selectionObjectName: <span ="apple-tab-span"="" style="white-space:pre"> </span>'selection' },
<span ="apple-tab-span"="" style="white-space:pre"> </span>new go.Binding("location", "loc", go.Point.parse).makeTwoWay(go.Point.stringify),
new go.Binding("text", "key"),
GO(go.Panel, go.Panel.Auto, { name: 'selection' },
GO(go.Shape, "RoundedRectangle",
{ fill: ReservoirColor, stroke: null }),
GO(go.Panel, go.Panel.Horizontal,
GO(go.Picture,
new go.Binding("source", "category", <span ="apple-tab-span"="" style="white-space:pre"> </span>nodeTypeImage), { width: 20, height: 20 }),
GO(go.TextBlock, textStyle(),
{ text: 'Reservoir' },
new go.Binding("text", "text").makeTwoWay()),
GO(go.TextBlock, textStyle(),
new go.Binding("text", "loc", function (p) {
return p;
}).makeTwoWay()
)
)),
,
{
click: function (e, obj) { LeftFullClick() }
}
)
);
I dont think that was a problem with the template.
May be the definition of my diagram.
myFullDiagram =
GO(go.Diagram, "myDiagramDiv", // each diagram refers to its DIV HTML element by id
{
initialScale: 0.4,
minScale: 0.1,
maxScale: 1.5,
contentAlignment: go.Spot.Center, // center the tree in the viewport
isReadOnly: false,// don't allow user to change the diagram
allowMove: true,
allowCopy: false,
allowDelete: false,
allowDrop: false,
allowGroup: false,
allowLink: false,
hasHorizontalScrollbar: false,
hasVerticalScrollbar: false,
layout: GO(go.TreeLayout,
{ angle: 90, sorting: go.TreeLayout.SortingAscending }),
click: function (e, obj) { ClickOnFullDiagram(e, obj) }
});
myFullDiagram.toolManager.dragSelectingTool.isPartialInclusion = true;
myFullDiagram.toolManager.dragSelectingTool.delay = 150,
myFullDiagram.grid.visible = false;
myFullDiagram.toolManager.draggingTool.isGridSnapEnabled = true;
myFullDiagram.initialContentAlignment = go.Spot.Center;