Using PolygonDrawing sample i am trying to draw a group.So in finishShape method, i am making the node as group and the node inside the group as a member group.But The member node is not staying inside the group.When i am dragging the group or the member node, they are moving along not together.
GroupTemplate:
myDiagram.groupTemplate =
GO(go.Group,
new go.Binding(“location”, “loc”, go.Point.parse).makeTwoWay(go.Point.stringify),
GO(go.Panel, “Auto”,{ name: “PANEL” },
GO(go.Shape,
{ name: “SHAPE”, fill: “lightgray”, strokeWidth: 2},
new go.Binding(“angle”).makeTwoWay(),
new go.Binding(“geometryString”, “geo”).makeTwoWay(),
new go.Binding(“fill”),
new go.Binding(“stroke”),
new go.Binding(“strokeWidth”)
),
GO(go.Placeholder, { padding: 100 }),
)
);
finishShape method :
finishShape() {
var diagram = this.diagram;
var shape:go.Shape = this.temporaryShape();
if (shape !== null && this.archetypePartData() !== null) {
if (!diagram.lastInput.isTouchEvent) this.removeLastPoint();
var tempgeo = shape.geometry;
//getting the nodes inside the group.
var objectInsideShape = this.diagram.findObjectsIn(shape.actualBounds,
function (x: any) {
var part = x.part;
if ((part instanceof go.Link || part instanceof go.Node) && !(part instanceof go.Group) ) {
console.log(part.data)
return part;
}
return null;
},
null, true);
this.objectsInShape = objectInsideShape
// require 3 points (2 segments) if polygon; 2 points (1 segment) if polyline
if (tempgeo.figures.first().segments.count >= (this.isPolygon() ? 2 : 1)) {
var viewpt = diagram.viewportBounds.position;
var geo = tempgeo.copy();
if (this.isPolygon()) {
var segs = geo.figures.first().segments;
var seg = segs.elt(segs.count-1);
seg.isClosed = true;
}
// create the node data for the model
var d = diagram.model.copyNodeData(this.archetypePartData());
//creating the group
d["isGroup"] = true;
// adding data to model creates the actual Part
diagram.model.addNodeData(d);
var part = diagram.findPartForData(d);
//creating member node
objectInsideShape.each((e:go.Part) => e.data[“group”] = part.data[“uuid”]);
// assign the position for the whole Part
var pos = geo.normalize();
pos.x = viewpt.x - pos.x - shape.strokeWidth / 2;
pos.y = viewpt.y - pos.y - shape.strokeWidth / 2;
part.position = pos;
// assign the Shape.geometry
var shape1:any = part.findObject(“SHAPE”);
if (shape1 !== null) {
shape1.geometry = geo;
}
this.transactionResult = this.name;
}
}
}
this.stopTool();
};
so,the diagramJson is changing. i think the panel is not updating.Thats why when i am dragging the group,the member nodes are not moving.