diff options
Diffstat (limited to 'silx/gui/plot/backends/BackendBase.py')
-rw-r--r-- | silx/gui/plot/backends/BackendBase.py | 39 |
1 files changed, 36 insertions, 3 deletions
diff --git a/silx/gui/plot/backends/BackendBase.py b/silx/gui/plot/backends/BackendBase.py index 74f96af..12561b2 100644 --- a/silx/gui/plot/backends/BackendBase.py +++ b/silx/gui/plot/backends/BackendBase.py @@ -31,10 +31,11 @@ This API is a simplified version of PyMca PlotBackend API. __authors__ = ["V.A. Sole", "T. Vincent"] __license__ = "MIT" -__date__ = "18/02/2016" +__date__ = "16/08/2017" import weakref +from ... import qt # Names for setCursor @@ -58,9 +59,12 @@ class BackendBase(object): self.__yLimits = {'left': (1., 100.), 'right': (1., 100.)} self.__yAxisInverted = False self.__keepDataAspectRatio = False + self._axesDisplayed = True # Store a weakref to get access to the plot state. self._setPlot(plot) + self.__zoomBackAction = None + @property def _plot(self): """The plot this backend is attached to.""" @@ -79,6 +83,18 @@ class BackendBase(object): """ self._plotRef = weakref.ref(plot) + # Default Qt context menu + + def contextMenuEvent(self, event): + """Override QWidget.contextMenuEvent to implement the context menu""" + if self.__zoomBackAction is None: + from ..actions.control import ZoomBackAction # Avoid cyclic import + self.__zoomBackAction = ZoomBackAction(plot=self._plot, + parent=self._plot) + menu = qt.QMenu(self) + menu.addAction(self.__zoomBackAction) + menu.exec_(event.globalPos()) + # Add methods def addCurve(self, x, y, legend, @@ -147,9 +163,9 @@ class BackendBase(object): :param int z: Layer on which to draw the image :param bool selectable: indicate if the image can be selected :param bool draggable: indicate if the image can be moved - :param colormap: Dictionary describing the colormap to use. + :param colormap: :class:`.Colormap` describing the colormap to use. Ignored if data is RGB(A). - :type colormap: dict or None + :type colormap: :class:`.Colormap` :param float alpha: Opacity of the image, as a float in range [0, 1]. :returns: The handle used by the backend to univocally access the image """ @@ -307,6 +323,8 @@ class BackendBase(object): def saveGraph(self, fileName, fileFormat, dpi): """Save the graph to a file (or a StringIO) + At least "png", "svg" are supported. + :param fileName: Destination :type fileName: String or StringIO or BytesIO :param str fileFormat: String specifying the format @@ -472,3 +490,18 @@ class BackendBase(object): :return: bounds as a 4-tuple of int: (left, top, width, height) """ raise NotImplementedError() + + def setAxesDisplayed(self, displayed): + """Display or not the axes. + + :param bool displayed: If `True` axes are displayed. If `False` axes + are not anymore visible and the margin used for them is removed. + """ + self._axesDisplayed = displayed + + def isAxesDisplayed(self): + """private because in some case it is possible that one of the two axes + are displayed and not the other. + This only check status set to axes from the public API + """ + return self._axesDisplayed
\ No newline at end of file |