Skip to content

Conversation

@tomvanmele
Copy link
Member

adding draw_collection to box artist

What type of change is this?

  • Bug fix in a backwards-compatible manner.
  • New feature in a backwards-compatible manner.
  • Breaking change: bug fix or new feature that involve incompatible API changes.
  • Other (e.g. doc update, configuration, etc)

Checklist

Put an x in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your code.

  • I added a line to the CHANGELOG.md file in the Unreleased section under the most fitting heading (e.g. Added, Changed, Removed).
  • I ran all tests on my computer and it's all green (i.e. invoke test).
  • I ran lint on my computer and there are no errors (i.e. invoke lint).
  • I added new functions/classes and made them available on a second-level import, e.g. compas.datastructures.Mesh.
  • I have added tests that prove my fix is effective or that my feature works.
  • I have added necessary documentation (if appropriate)

@tomvanmele
Copy link
Member Author

i just updated BoxArtist for now. perhaps you can review this one first until we fully agree on the format for the shape artists, and then i roll this out for all others on this PR...

@tomvanmele
Copy link
Member Author

just a few points for discussion:

  • should the faces of the boxes in the collection be grouped into joined meshes?
  • should the collection function also provide the option to show/hide other components than just the faces

Copy link
Member

@gonzalocasas gonzalocasas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a line to CHANGELOG.
Otherwise it LGTM!

About your questions: boxes are always closed, right? so I'd tend to assume it would display it as one mesh rather than individual faces, but I realize the usage and assumptions on this point changes a lot between teams, so maybe add the join_faces option like the MeshArtist has.

Regarding collection functions, having functional parity between single entity and collection would be nice (ie. the same show_* params on both ideally)

@tomvanmele
Copy link
Member Author

the reason behind the simplified functionality for the draw_collection function would be that the function is there for convenience and is meant to draw many objects fast, not necessarily withe all possible options, just the defaults. if more control is desired, the user can always use the draw function with artists for the individual boxes... what do you think @gonzalocasas ? otherwise, i am not sure there is much point to the collection variant.

@gonzalocasas
Copy link
Member

the reason behind the simplified functionality for the draw_collection function would be that the function is there for convenience and is meant to draw many objects fast, not necessarily withe all possible options, just the defaults. if more control is desired, the user can always use the draw function with artists for the individual boxes... what do you think @gonzalocasas ? otherwise, i am not sure there is much point to the collection variant.

Ah! Understood. I personally have never used these _collection variants, perhaps out of laziness or ignorance thou. If you want to try it as it is now, sounds good to me. At some point, we could gauge how much usage they get and if not much, we could get rid of them.

points = [{'pos': point, 'color': self.color} for point in vertices]
guids += compas_rhino.draw_points(points, layer=self.layer, clear=False, redraw=False)
if show_edges:
raise NotImplementedError
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i have left this open for now. the capsule doesn't actually have any edges. they could be generated to be able to visualize the wireframe. in general, the question is what the most relevant information is. i would argue that even showing the vertices is questionable...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Leaving this as an exception permanently results in kind of a strange user experience though. I would tend toward letting the user decide if he wants to see edges and vertices, even if it doesn't make sense. I find pretty senselessness preferable to runtime errors. But if you do choose to leave it this way, please mention in the documentation that it's not implemented.

@line.setter
def line(self, line):
self._line = line
self._line = Line(*line)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

while fixing this, i noticed that the capsule has a very different logic than for example the box. it doesn't have a local frame and is defined directly through a line defined by two points. perhaps that should become an alternative constructor. the default, like with the box, should accept a frame and the parameters that define the capsule in that frame. ideally this is the default for all shapes: a frame and parameters. alternative constructors allow to use direct geometrical inputs, but would then have to compute a frame from those internally...

@gonzalocasas @beverlylytle @Licini

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the suggestion makes sense to me

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will submit a proposal for this via a different PR

return guids

@staticmethod
def draw_collection(collection,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the collection methods offer very little advantage over the individual draw methods. since static methods are somewhat frowned upon anyway, perhaps the collection methods are not really necessary...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i tend to agree. it seems that really the only added functionality of draw_collection is the grouping, and it seems like that function should be pulled out, perhaps as a static method to the BaseArtist or maybe somewhere else. it seems reasonable that one may want to group objects of mixed type, ie a box and a mesh or two.

@circle.setter
def circle(self, circle):
self._circle = circle
self._circle = Circle(*circle)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

while fixing this bug, i noticed that the cone does not have a bottom face. should it?

Co-authored-by: beverlylytle <57254617+beverlylytle@users.noreply.github.com>
@tomvanmele
Copy link
Member Author

@gonzalocasas this thing is final now, so please let me know if it can be merged...

@tomvanmele tomvanmele merged commit 7d3e626 into master Oct 27, 2020
@tomvanmele tomvanmele deleted the compas-rhino-artists branch January 20, 2021 10:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants