-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
MEP22 Navigation toolbar coexistence TODELETE #2759
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
Closed
Closed
Changes from 1 commit
Commits
Show all changes
38 commits
Select commit
Hold shift + click to select a range
dda0cdc
navigation and toolbar coexistence
fariza 10f5dc7
mod keypress in figuremanager
fariza 08a6020
extra files
fariza c6c0ad3
helper methods in toolbar and navigation
fariza 1fc29fa
Adding doc to base methods
fariza 979875e
property for active_toggle
fariza c5c4f0f
simulate click
fariza 97dfda7
pep8 backend_tools
fariza 6b647ad
activate renamed to trigger
fariza 99667aa
toggle tools using enable/disable from its trigger method
fariza 6c19579
simplifying _handle_toggle
fariza 0495aac
reducing number of locks
fariza fb46fc1
pep8 correction
fariza d49c431
changing toggle and persistent attributes for issubclass
fariza 5ba6210
bug in combined key press
fariza 7ca8626
untoggle zoom and pan from keypress while toggled
fariza dcc0f16
classmethods for default tools modification
fariza bc703e0
six fixes
fariza 68dc711
adding zaxis and some pep8
fariza bb9f1c7
removing legacy method dynamic update
fariza 2c2e649
tk backend
fariza a99367f
pep8
fariza 3d1be34
example working with Tk
fariza afdd34c
cleanup
fariza 5b49c7a
duplicate code in keymap tool initialization
fariza 773db88
grammar corrections
fariza 2ca6926
moving views and positions to tools
fariza 661417d
The views positions mixin automatically adds the clear as axobserver
fariza 90ab64f
bug when navigation was not defined
fariza 55dd149
Small refactor so that we first initiate the Navigation (ToolManager)…
OceanWolf 15ac091
Update for Sphinx documentation
OceanWolf 8cd241c
Moved default_tool initilisation to FigureManagerBase and cleaned.
OceanWolf 39f5b74
Fix navigation
OceanWolf b20dade
Temporary fix to backends
OceanWolf ff94301
Merge pull request #1 from OceanWolf/navigation-toolbar-coexistence-e…
fariza 2cb4501
removing persistent tools
fariza 9d3c977
removing unregister
fariza 6e0b7e6
change cursor inmediately after toggle
fariza File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
The views positions mixin automatically adds the clear as axobserver
- Loading branch information
commit 661417d949f4132d582e75fe790d1ffecdf7b46f
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -97,9 +97,9 @@ def set_figure(self, figure): | |
|
||
|
||
class ToolPersistentBase(ToolBase): | ||
"""Persisten tool | ||
"""Persistent tool | ||
|
||
Persistent Tools are keept alive after their initialization, | ||
Persistent Tools are kept alive after their initialization, | ||
a reference of the instance is kept by `navigation`. | ||
|
||
Notes | ||
|
@@ -287,20 +287,41 @@ def trigger(self, event): | |
|
||
|
||
class ViewsPositionsMixin(object): | ||
"""Mixin to handle changes in views and positions | ||
|
||
Tools that change the views and positions, use this mixin to | ||
keep track of the changes. | ||
""" | ||
|
||
views = WeakKeyDictionary() | ||
"""Record of views with Figure objects as keys""" | ||
|
||
positions = WeakKeyDictionary() | ||
"""Record of positions with Figure objects as keys""" | ||
|
||
def init_vp(self): | ||
"""Add a figure to the list of figures handled by this mixin | ||
|
||
To handle the views and positions for a given figure, this method | ||
has to be called at least once before any other method. | ||
|
||
The best way to call it is during the set_figure method of the tools | ||
""" | ||
if self.figure not in self.views: | ||
self.views[self.figure] = cbook.Stack() | ||
self.pos 10000 itions[self.figure] = cbook.Stack() | ||
# Define Home | ||
self.push_current() | ||
# Adding the clear method as axobserver, removes this burden from | ||
# the backend | ||
self.figure.add_axobserver(self.clear) | ||
|
||
@classmethod | ||
def clear(cls, figure): | ||
"""Reset the axes stack""" | ||
print('clear') | ||
if figure in cls.views: | ||
print('done clear') | ||
cls.views[figure].clear() | ||
cls.positions[figure].clear() | ||
|
||
|
@@ -375,12 +396,9 @@ def forward(self): | |
self.positions[self.figure].forward() | ||
|
||
|
||
def clear_views_positions(figure): | ||
ViewsPositionsMixin.clear(figure) | ||
|
||
|
||
class ViewsPositionsBase(ViewsPositionsMixin, ToolBase): | ||
# Simple base to avoid repeating code on Home, Back and Forward | ||
# Not of much use for other tools, so not documented | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please document everything. |
||
_on_trigger = None | ||
|
||
def set_figure(self, *args): | ||
|
@@ -435,6 +453,8 @@ class SaveFigureBase(ToolBase): | |
|
||
|
||
class ZoomPanBase(ViewsPositionsMixin, ToolToggleBase): | ||
# Base class to group common functionality between zoom and pan | ||
# Not of much use for other tools, so not documented | ||
def __init__(self, *args): | ||
ToolToggleBase.__init__(self, *args) | ||
self.init_vp() | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,8 +31,7 @@ def fn_name(): return sys._getframe(1).f_code.co_name | |
from matplotlib.backend_bases import RendererBase, GraphicsContextBase, \ | ||
FigureManagerBase, FigureCanvasBase, NavigationToolbar2, cursors, TimerBase | ||
from matplotlib.backend_bases import ShowBase, ToolbarBase, NavigationBase | ||
from matplotlib.backend_tools import SaveFigureBase, ConfigureSubplotsBase, \ | ||
clear_views_positions | ||
from matplotlib.backend_tools import SaveFigureBase, ConfigureSubplotsBase | ||
|
||
from matplotlib.cbook import is_string_like, is_writable_file_like | ||
from matplotlib.colors import colorConverter | ||
|
@@ -439,7 +438,7 @@ def destroy(*args): | |
def notify_axes_change(fig): | ||
'this will be called whenever the current axes is changed' | ||
if self.navigation is not None: | ||
clear_views_positions(fig) | ||
pass | ||
elif self.toolbar is not None: self.toolbar.update() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please un-fold if statements. |
||
self.canvas.figure.add_axobserver(notify_axes_change) | ||
|
||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Can you add some documentation to these classes to explain what they do; and/or why/how one should use them? It would save my brain some pain and for future developers to know what functionality they can expect by using these classes :).
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.
Smaller PRs are easy to review. Send small and clear changes one at a time. We take it from there