FullControlXYZ / fullcontrol

Python version of FullControl for toolpath design (and more) - the readme below is best source of information
GNU General Public License v3.0
672 stars 78 forks source link

visualise: plotly: expose the Figure object #91

Open ES-Alexander opened 5 months ago

ES-Alexander commented 5 months ago

Fixes #90, per this comment

⚠️ Untested, so it's likely worth checking that it actually works for the main use-cases:

  1. plotting and displaying a new Figure (standard behaviour)
  2. plotting, displaying, and returning a Figure (extended behaviour)
  3. plotting and returning a Figure, with controls.show = False (new behaviour)
  4. inputting a preconfigured Figure (new behaviour)
fullcontrol-xyz commented 4 months ago

Very interesting to see this.

There is an additional use case of no plotting at all - only returning raw data. This is a very useful output so does need to remain, but I understand your statement in the issue #90 that it's bad practice to have conditional return types.

In fact, the fc.transform() function already has multiple return types, but that seems like a logical rule-break since a transformation to gcode or to a visualisation are clearly not going to return the same thing. However, I do see that tranforming to 'plot', and then having a second-condition for the returned object type can get confusing.

It may be best practice to move that functionality out of the 'plot' transform option. It could be a new standalone transform option of 'plot_data'. I mean that the user writes fc.transform(steps, 'plot_data') instead of the current approach of fc.transform(steps, 'plot', fc.GcodeControls(raw_data=True)

What are your thoughts?

Fixes #90, per this comment

⚠️ Untested, so it's likely worth checking that it actually works for the main use-cases:

  1. plotting and displaying a new Figure (standard behaviour)
  2. plotting, displaying, and returning a Figure (extended behaviour)
  3. plotting and returning a Figure, with controls.show = False (new behaviour)
  4. inputting a preconfigured Figure (new behaviour)