Grouping using PolygonDrawing sample

Thanks a lot Walter.The problem has solved and is working fine.
But i have a new issue now : resizing.
I have used this http://gojs.net/extras/groupResizing.html.
Facing two problem.

  1. When trying to resizing any other Nodes except group,error is coming.
  2. When resizing Group,same problem as previous, Node is going out of Shape.

Well, you have all of the code there – when you debug it, can you figure out what is happening while resizing that is causing the error?

“resizingTool.computeMinSize”: function() {
var group = this.adornedObject.part;
var shape = group.resizeObject;
var membnds = group.diagram.computePartsBounds(group.memberParts);
membnds.addMargin(GroupMargin);
membnds.unionPoint(group.location);
return membnds.size;
}

Here the resizing is for group only.So when i am resizing any node ,getting error in the below line.
var membnds = group.diagram.computePartsBounds(group.memberParts);

EXCEPTION: Cannot read property ‘i’ of undefined.

OK, so if you debug it, what is undefined? And why?

I have tried that ResizingTool.computeMinSize override, and it works well for me. But I do notice now that the var shape = group.resizeObject; is superfluous and can be deleted.

Have you tried for single node? For group it is working but for single node it is giving error.
Because in group.diagram.computePartsBounds(group.memberParts) -
computePartsBounds takes collection and for single node collection i.e. group.memberParts
is undefiend.

There is no Node.memberParts property.

Yes.So i am trying like this.
“resizingTool.computeMinSize”: function() {
var group = this.adornedObject.part;
if(group instanceof go.Group){
var membnds = group.diagram.computePartsBounds(group.memberParts);
membnds.addMargin(GroupMargin);
membnds.unionPoint(group.location);
return membnds.size;
}
else{

}
},

But what should i return in else condition??(for single node)

Use Node.containingGroup.

No.I am asking if i have any node except group i.e.

When resizing it,then actually no need of resizingTool.computeMinSize.Then what should i do.
Or if it use resizingTool.computeMinSize, the which size i should return?

Whatever size seems appropriate to you.

Ok. Now what should i do for the 2nd problem :
When resizing Group,same problem as previous, Node is going out of Shape.

Step through stayInGroup to see why it is doing what it is doing.

Hi Walter Again I faced an issue with Polygon Boundary. If We make a polygon Boundary like below

here i created polygon boundary, outside object(Top Right Corner Rectangle) also added as member of the Boundary.for that i wrote logic like
var objectInsideShape = diagram.findObjectsIn(part.actualBounds,
function (x: any) {
var part = x.part;
var d = part.data;
if ((part instanceof go.Link || part instanceof go.Node) && !(part instanceof go.Group) ) {
return part;
}
return null;
},
null, false);

so. how can i avoid outside member as not part of the polygon boundary?

Why are you operating on the whole rectangular bounds when you really care about a node being inside or outside of a particular Shape?

I need only objects inside boundary. i found so many gojs methods findObjectAt ,findObjectsAt, findObjectsIn ,findPartAt. but except findObjectsIn, all other methods need particular node. i need all the objects inside boundary. which method i can use to solve this problem?

Could you describe your problem much more specifically and precisely, please? What you have said can be interpreted in many different manners.

3 posts were split to a new topic: Connecting links to groups

Regarding @Santanu044 Question I have the Same issue, While moving the Polygon Boundary it will take the all the inside and Outside Object also ,Its taking all Object like in Rectangle shape like a behavior of Group not in Boundary, Could you tell me where i need to change the Method belong to this issue. For the Reference i added attachment snaps for you.

have a look Once.Waiting for your Response,Thank you.

Hi Walter,i have a one polygon boundary as above and it contains the objects which are inside the polygon boundary,there is one more object outside the polygon boundary,the problem is when i select polygon boundary and then move i want only
whatever inside polygon boundary objects along with polygon boundary object ,but out side object are also moving.By default its taking rectangler boundary ,could you please provide any solution.Thank You

If you make the Polygon Boundary a Group object, and you add the objects inside of it as member nodes, moving the Polygon will automatically move the Nodes inside. This functionality is built into the group class.

For example try moving the group here: http://gojs.net/latest/samples/basic.html

You would want your group to not have a Placeholder.

There is no built in way to “find all objects within a polygon area” in GoJS. You could write such a method yourself, but it may take some experimentation.