schrodinger.ui.qt.navtoolbar module¶
Custom versions of the Matplotlib Qt Navigation toolbar
Copyright Schrodinger, LLC. All rights reserved.
- class schrodinger.ui.qt.navtoolbar.NavToolbar(canvas, parent, coordinates=True, allow_log=True, allow_linear=True, clipboard=True, toolitems=None)¶
Bases:
matplotlib.backends.backend_qt.NavigationToolbar2QT
A custom version of the Matplotlib Qt Navigation toolbar. Differences with the standard matplotlib toolbar include:
This class contains a “Copy to Clipboard” button
This class contains a modified “Figure options” dialog that can be configured to disallow log or linear axes
Cursor changes only affect the plot itself, not the whole application
- Variables
TOOL_ITEMS – use this constant for adding custom tool items to ensure the
toolitems
class variable is not modified
- TOOL_ITEMS = (('Home', 'Reset original view', 'home', 'home'), ('Back', 'Back to previous view', 'back', 'back'), ('Forward', 'Forward to next view', 'forward', 'forward'), (None, None, None, None), ('Pan', 'Left button pans, Right button zooms\nx/y fixes axis, CTRL fixes aspect', 'move', 'pan'), ('Zoom', 'Zoom to rectangle\nx/y fixes axis', 'zoom_to_rect', 'zoom'), ('Subplots', 'Configure subplots', 'subplots', 'configure_subplots'), ('Customize', 'Edit axis, curve and image parameters', 'qt4_editor_options', 'edit_parameters'), (None, None, None, None), ('Save', 'Save the figure', 'filesave', 'save_figure'))¶
- __init__(canvas, parent, coordinates=True, allow_log=True, allow_linear=True, clipboard=True, toolitems=None)¶
Create the toolbar
- Parameters
canvas (
schrodinger.mpl_backend_agg.FigureCanvasQTAgg
) – The matplotlib canvasparent (
QtWidgets.QWidget
) – The Qt parent widgetcoordinates (bool) – Whether the cursor coordinates should be shown on the right side of the toolbar
allow_log (bool) – Whether log axes should be selectable in the Figure Option dialog
allow_linear (bool) – Whether linear axes should be selectable in the Figure Option dialog
clipboard (bool) – Whether a copy to clipboard button should be included
toolitems (list(tuple)) – Custom tool items to be loaded
- copyImageToClipboard()¶
Copy an image of the plot to the clipboard
- set_cursor(cursor)¶
[Deprecated] Set the current cursor to one of the
Cursors
enums values.If required by the backend, this method should trigger an update in the backend event loop after the cursor is set, as this method may be called e.g. before a long-running task during which the GUI is not updated.
Deprecated since version 3.5: Use
FigureCanvasBase.set_cursor
instead.
- getSubplotDialog()¶
Return an instance of the widget to use inside the “Subplot Configuration Tool” dialog.
- showAdjustWindow()¶
Open the subplot configuration dialog, in a non-modal way; so that the user can interact with the main plot window while it is open. Only one instance of the dialog is allowed by this code.
- adjustWindowClosing()¶
- configure_subplots()¶
Fixes a bug in the NavigationToolbar2QTAgg that causes the Reset button to reset to the wrong “original” plot if it is first modified by the configure subplots button. EV 98504.
- set_message(message)¶
Sets the message in the toolbar, only puts a return in it if it would require the toolbar to expand horizontally to contain it.
- sizeHint()¶
Make sure that the message label is included in the sizehint calculation for height
- edit_parameters()¶
Open up the Customize plot dialog.
Fixes a bug in the matplotlib implementation (EV: 120930) for figures with multiple subplots without titles.
- editFigureOptions(axes)¶
Edit the matplotlib figure options for passed axes
- Parameters
axes (
matplotlib.axes.Axes
) – Axes selected by user to edit the figure options.
- resetPanZoom()¶
Reset any sticky buttons like pan or zoom
- class schrodinger.ui.qt.navtoolbar.SchrodingerSubplotTool(*args)¶
Bases:
matplotlib.backends.backend_qt.SubplotToolQt
- BETTER_LABELS = {'bottom': 'Bottom Margin', 'hspace': 'Vertical Gap\nBetween Plots', 'left': 'Left Margin', 'right': 'Right Margin', 'top': 'Top Margin', 'wspace': 'Horizontal Gap\nBetween Plots'}¶
- __init__(*args)¶
- class schrodinger.ui.qt.navtoolbar.FeedbackSubplotToolQt(targetfig, panel)¶
Bases:
matplotlib.backends.backend_qt.SubplotToolQt
Allows the parent panel to perform pre and post plot modification actions
- __init__(targetfig, panel)¶
- Parameters
panel (AppFramework object) – an object with setWaitCursor and restoreCursor methods
- funcleft(val)¶
Allow the parent panel to to pre and post plot modification actions
- funcright(val)¶
Allow the parent panel to to pre and post plot modification actions
- funcbottom(val)¶
Allow the parent panel to to pre and post plot modification actions
- functop(val)¶
Allow the parent panel to to pre and post plot modification actions
- funcwspace(val)¶
Allow the parent panel to to pre and post plot modification actions
- funchspace(val)¶
Allow the parent panel to to pre and post plot modification actions
- class schrodinger.ui.qt.navtoolbar.AtomInfoToolbar(canvas, parent, coordinates=True, **kwargs)¶
Bases:
schrodinger.ui.qt.navtoolbar.NavToolbar
Overrides the set_message class of the normal toolbar to enable the following enhancements:
Print the atom numbers and their distance.
Allow the user to turn off pan/zoom or zoom modes by clicking on the depressed toolbar button
Call the parent panel prePlotAction and postPlotAction methods before modifying the plot view in any way to allow the parent to properly prepare for the modification (create a wait cursor, add/remove plot features, etc.)
Used by residue_distance_map.py & pose_explorer_dir/multi_canvas_toolbar.py
- __init__(canvas, parent, coordinates=True, **kwargs)¶
Create a new toolbar instance
- Parameters
canvas (FigureCanvasQTAgg) – The canvas this toolbar belongs to
parent (CaDistanceGUI) – The parent panel that contains information about atoms and distances.
coordinates (bool) – not used
- set_message(event)¶
Place the atom numbers and distance between them that corresponds to the atoms currently under the cursor.
- Parameters
event (mouse move event) – the event object generated by the mouse movement
- getSubplotDialog()¶
Over-rides NavToolbar method, to initialize FeedbackSubplotToolQt class in order to use the wait cursor when configuring the plot.
- mouse_move(event)¶
Overwrites the parent routine to always call set_message with the x and y data for the event.
- Parameters
event (mouse move event) – the event object generated by the mouse movement
- isActive(actor)¶
Checks to see if the action with the name actor active, and if it is, returns it.
- Parameters
actor (str) – the name of the action to check. The name is what is returned by the action.text() method.
- Return type
Action object or False
- Returns
the Action object if it is active, or False if it is not