-
Notifications
You must be signed in to change notification settings - Fork 0
toolmanager and tools dont hold figure #8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: backend-refactor
Are you sure you want to change the base?
Conversation
FigureManager manages the Figure and not the Canvas, pt2
…nto fariza-gui-examples
Also reverted changes to tools example and fixed the example.
@OceanWolf I think this belongs here, just to make MEP27 consistent |
@fariza, if I remember correctly we had a discussion about this already on the main branch of MEP22. I think you originally passed the figmgr to toolmgr but changed it to canvas because people can run a toolmgr without a figmgr when it comes to embedding... The lines you change here I was just about to change myself. I just need to split my code up into commits and then I will upload it and you can tell me what you think. |
If I remember correctly I was passing both canvas and FigureManager. Later when we make the figure changeable figmanager will emit an event and
|
figure: `Figure` | ||
""" | ||
|
||
self._figure = figure |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about multifigure manager? It would make sense to me to change the toolmanager to relate to a different figure. Especially if they use a separate window for a toolbar like in your gui_elements
example.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What I was thinking, and I really think is the best way to do it, is to emit an event from FigureManager when the figure gets setted.
The tools that need to refresh information based on the figure will hook into that event, and store the figures in a local array or dictionary.
Having a reference to figure here makes me nervous.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, right now is not used anywhere, and leaving it there might just give ideas and then it would be impossible to change
I know it was me, but again, the more I see it the more I like the new way of not having local references to figure
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still don't feel convinced about this, I see FigureManager
, while a lot more flexible then before, it still functions very much as a neat and easy wrapper, as soon as you try to do anything complicated, like embedding, it falls apart and thus we shouldn't build MEP22 around it.
I would much rather emit an event from ToolManager
when the figure changes and/or don't let the tool keep the figure... ooh, actually, scrap that last bit, we can build in a figure updater callback into ToolBase
and descendent classes can override that updater method if they need to do anything extra.
If we go with that then I don't think we need to implement that now as we purely add a new feature, we don't change any existing structure, so it will remain fully BC.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That last bit of having a callback in the tools, is more or less what I was thinking. But I really prefer not to have a permanent reference to it and even less a setter.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ahh yes, I understand, sorry, getting confused as to where bits of code lie. Yes, I agree we shouldn't have this setter. For some reason I thought we had this bit of code in ToolManager
.
Yes, I completely agree we want to convert this setter in ToolBase
into just a callback that sets the figure.
Going back, I think I got confused because I saw it completely logical to have a figure setter in ToolManager
and instead of passing in a Canvas
or a FigureManager
into ToolManager
we just pass in a figure
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure how much MEP22 modifications I want to go into the MEP27 branch, I think we should keep it to a bare minimum of changes where:
a) overlap exists (i.e. the method calls between the two), and
b) API changes for interaction with the backends.
I.e. Just the things we consider we need to get right before we can start converting the other backends, because I see this main PR as the slowest link in the chain.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To make it clear I don't mind making the change from ToolManager(self.figure.canvas)
to ToolManager(self.figure)
here. I think that makes more sense and exists in the overlap of MEP27 and MEP22. Then again, perhaps easier to do it all in one go in a future PR, especially as this won't affect the backends... but your call on that.
Ok no problem |
I really don't think In the way I see it, If we let |
Hmm, how do you see I feel convinced that like try:
self.figure = figure_like.figure
self.figure_manager = figure_like
except:
self.figure = figure_like
self.figure_manager = None I just don't see the need right now and not sure if it will just lead to more confusion, with people falsely assume they have access to properties and methods that they don't have. |
I think Of course |
Again, if you think this doesn't belong here, I can make a PR to master. |
Hmm, I see it the other way around, I see You have explained "how", I just don't understand "why"... anyway, lets leave this for a future discussion... |
27885ad
to
1b61b42
Compare
eb514d5
to
cc0d4cd
Compare
620efb9
to
d842ee8
Compare
d842ee8
to
f857f7b
Compare
f857f7b
to
b061b9a
Compare
e7290fe
to
64f0c61
Compare
To avoid possible problems with somebody replacing the figure inside the tools or the toolmanager.
I replaced the attributes for properties in the tools