scenic icon indicating copy to clipboard operation
scenic copied to clipboard

def group(graph_or_primitive, builder, opts \\ []) has no function definition for primitive

Open tcoopman opened this issue 5 years ago • 3 comments

other functions with the same argument graph_or_primitive also have a definition with a Primitive struct, but it seems this is not implemented for group.

I'm not sure if group should not expect a primitive or if it's just not implemented?

Next to stating the issue, I'm also adding my problem here. I'm trying to use Graph.modify to update a complete group but I have no idea how to do it.

This is some simplified code:

Graph.build()
|> ....
|> group(
  fn g -> builds_many(g), id: :sample
)

def builds_many(g) do
  g
  |> rrect(...)
end

And on an update I want to basically replace the group sample by doing builds_many again.

These are the things I tried:

  • Using Graph.modify, but this has the problem that I get a primitive (a group) and rrect can only take a Primitive of round_rect not group.
  • First deleting the old Primitive with Graph.delete, then building a new graph (It's not possible to just create a group from nothing), creating a new group and then try to add this graph to the main graph, but Graph.add expects a primitive so this doesn't work
  • using Graph.map, but this action also passes a Primitive

I'm probably missing something here, but I'm still struggling with it, and that's the reason I stumbled on this issue.

tcoopman avatar Sep 09 '18 09:09 tcoopman

Good issue. Requires a think.

Do you expect that you would need to re-declare everything in the group or simply add/delete things from it. The items in a group are ordered, so that matters.

boydm avatar Sep 10 '18 06:09 boydm

For my use case, I would actually love to simply replace the complete group (or everything that's inside the group) but I'm not sure if this is the best for performance.

tcoopman avatar Sep 10 '18 07:09 tcoopman

I have gotten around this - for now - by replaing the whole group. Not ideal but it works and its pretty quick.

cboebel avatar Feb 11 '19 03:02 cboebel