summaryrefslogtreecommitdiff
path: root/silx/gui
diff options
context:
space:
mode:
Diffstat (limited to 'silx/gui')
-rw-r--r--silx/gui/data/DataViewer.py2
-rw-r--r--silx/gui/dialog/ColormapDialog.py9
-rw-r--r--silx/gui/fit/FitWidget.py10
-rwxr-xr-xsilx/gui/plot/PlotWidget.py3
-rw-r--r--silx/gui/plot/ProfileMainWindow.py3
-rw-r--r--silx/gui/plot/StatsWidget.py33
-rwxr-xr-xsilx/gui/plot/backends/BackendMatplotlib.py23
-rw-r--r--silx/gui/plot/items/shape.py2
-rw-r--r--silx/gui/plot/tools/profile/_BaseProfileToolBar.py2
-rw-r--r--silx/gui/plot3d/tools/PositionInfoWidget.py2
10 files changed, 62 insertions, 27 deletions
diff --git a/silx/gui/data/DataViewer.py b/silx/gui/data/DataViewer.py
index 67db5f9..bad4362 100644
--- a/silx/gui/data/DataViewer.py
+++ b/silx/gui/data/DataViewer.py
@@ -221,7 +221,7 @@ class DataViewer(qt.QFrame):
self.__numpySelection.setSelection(
previousSelection, previousPermutation)
except ValueError as e:
- _logger.error("Not restoring selection because: %s", e)
+ _logger.info("Not restoring selection because: %s", e)
if hasattr(data, "shape"):
isVisible = not (len(axisNames) == 1 and len(data.shape) == 1)
diff --git a/silx/gui/dialog/ColormapDialog.py b/silx/gui/dialog/ColormapDialog.py
index ed15947..dddec4c 100644
--- a/silx/gui/dialog/ColormapDialog.py
+++ b/silx/gui/dialog/ColormapDialog.py
@@ -1,7 +1,7 @@
# coding: utf-8
# /*##########################################################################
#
-# Copyright (c) 2004-2018 European Synchrotron Radiation Facility
+# Copyright (c) 2004-2019 European Synchrotron Radiation Facility
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
@@ -463,6 +463,7 @@ class ColormapDialog(qt.QDialog):
color='black',
symbol='o',
linestyle='-',
+ z=2,
resetzoom=False)
scale = self._plot.getXAxis().getScale()
@@ -702,7 +703,8 @@ class ColormapDialog(qt.QDialog):
legend="Histogram",
color='gray',
align='center',
- fill=True)
+ fill=True,
+ z=1)
self._updateMinMaxData()
def getColormap(self):
@@ -753,7 +755,8 @@ class ColormapDialog(qt.QDialog):
legend="Range",
color='gray',
align='center',
- fill=True)
+ fill=True,
+ z=1)
self._dataRange = minimum, positiveMin, maximum
self._updateMinMaxData()
diff --git a/silx/gui/fit/FitWidget.py b/silx/gui/fit/FitWidget.py
index 78230b1..c3804e1 100644
--- a/silx/gui/fit/FitWidget.py
+++ b/silx/gui/fit/FitWidget.py
@@ -1,7 +1,7 @@
# coding: utf-8
# /*##########################################################################
#
-# Copyright (c) 2004-2017 European Synchrotron Radiation Facility
+# Copyright (c) 2004-2020 European Synchrotron Radiation Facility
#
# This file is part of the PyMca X-ray Fluorescence Toolkit developed at
# the ESRF by the Software group.
@@ -315,8 +315,8 @@ class FitWidget(qt.QWidget):
configuration.update(self.configure())
def setdata(self, x, y, sigmay=None, xmin=None, xmax=None):
- warnings.warning("Method renamed to setData",
- DeprecationWarning)
+ warnings.warn("Method renamed to setData",
+ DeprecationWarning)
self.setData(x, y, sigmay, xmin, xmax)
def setData(self, x, y, sigmay=None, xmin=None, xmax=None):
@@ -525,8 +525,8 @@ class FitWidget(qt.QWidget):
self._emitSignal(ddict)
def startfit(self):
- warnings.warning("Method renamed to startFit",
- DeprecationWarning)
+ warnings.warn("Method renamed to startFit",
+ DeprecationWarning)
self.startFit()
def startFit(self):
diff --git a/silx/gui/plot/PlotWidget.py b/silx/gui/plot/PlotWidget.py
index 49e444a..e47249e 100755
--- a/silx/gui/plot/PlotWidget.py
+++ b/silx/gui/plot/PlotWidget.py
@@ -624,8 +624,7 @@ class PlotWidget(qt.QMainWindow):
# Add item to plot
self._content[key] = item
item._setPlot(self)
- if item.isVisible():
- self._itemRequiresUpdate(item)
+ self._itemRequiresUpdate(item)
if isinstance(item, items.DATA_ITEMS):
self._invalidateDataRange() # TODO handle this automatically
diff --git a/silx/gui/plot/ProfileMainWindow.py b/silx/gui/plot/ProfileMainWindow.py
index 39830d8..aaedd1c 100644
--- a/silx/gui/plot/ProfileMainWindow.py
+++ b/silx/gui/plot/ProfileMainWindow.py
@@ -1,7 +1,7 @@
# coding: utf-8
# /*##########################################################################
#
-# Copyright (c) 2017-2018 European Synchrotron Radiation Facility
+# Copyright (c) 2017-2020 European Synchrotron Radiation Facility
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
@@ -85,6 +85,7 @@ class ProfileMainWindow(qt.QMainWindow):
self._plot2D.setParent(None) # necessary to avoid widget destruction
if self._plot1D is None:
self._plot1D = Plot1D(backend=self._backend)
+ self._plot1D.setDataMargins(yMinMargin=0.1, yMaxMargin=0.1)
self._plot1D.setGraphYLabel('Profile')
self._plot1D.setGraphXLabel('')
self.setCentralWidget(self._plot1D)
diff --git a/silx/gui/plot/StatsWidget.py b/silx/gui/plot/StatsWidget.py
index 80bc05d..52b7e5c 100644
--- a/silx/gui/plot/StatsWidget.py
+++ b/silx/gui/plot/StatsWidget.py
@@ -424,7 +424,7 @@ class _StatsWidgetBase(object):
if self._displayOnlyActItem:
connections.append(
- (self._plotWrapper.sigCurrentChanged, self._updateItemObserve))
+ (self._plotWrapper.sigCurrentChanged, self._updateCurrentItem))
else:
connections += [
(self._plotWrapper.sigItemAdded, self._addItem),
@@ -441,6 +441,11 @@ class _StatsWidgetBase(object):
"""Reload table depending on mode"""
raise NotImplementedError('Base class')
+ def _updateCurrentItem(self, *args):
+ """specific callback for the sigCurrentChanged and with the
+ _displayOnlyActItem option."""
+ raise NotImplementedError('Base class')
+
def _updateStats(self, item):
"""Update displayed information for given plot item
@@ -643,8 +648,6 @@ class StatsTable(_StatsWidgetBase, TableWidget):
def _updateItemObserve(self, *args):
"""Reload table depending on mode"""
- if self.getUpdateMode() is UpdateMode.MANUAL:
- return
self._removeAllItems()
# Get selected or all items from the plot
@@ -657,6 +660,27 @@ class StatsTable(_StatsWidgetBase, TableWidget):
for item in items:
self._addItem(item)
+ def _updateCurrentItem(self, *args):
+ """specific callback for the sigCurrentChanged and with the
+ _displayOnlyActItem option.
+
+ Behavior: create the tableItems if does not exists.
+ If exists, update it only when we are in 'auto' mode"""
+ if self.getUpdateMode() is UpdateMode.MANUAL:
+ # when sigCurrentChanged is giving the current item
+ if len(args) > 0 and isinstance(args[0], (plotitems.Curve, plotitems.Histogram, plotitems.ImageData, plotitems.Scatter)):
+ item = args[0]
+ tableItems = self._itemToTableItems(item)
+ # if the table does not exists yet
+ if len(tableItems) == 0:
+ self._updateItemObserve()
+ else:
+ # in this case no current item
+ self._updateItemObserve(args)
+ else:
+ # auto mode
+ self._updateItemObserve(args)
+
def _plotCurrentChanged(self, current):
"""Handle change of current item and update selection in table
@@ -1392,6 +1416,9 @@ class _BaseLineStatsWidget(_StatsWidgetBase, qt.QWidget):
_item = items[0] if len(items) is 1 else None
self._setItem(_item)
+ def _updateCurrentItem(self):
+ self._updateItemObserve()
+
def _createLayout(self):
"""create an instance of the main QLayout"""
raise NotImplementedError('Base class')
diff --git a/silx/gui/plot/backends/BackendMatplotlib.py b/silx/gui/plot/backends/BackendMatplotlib.py
index 075f6aa..2336494 100755
--- a/silx/gui/plot/backends/BackendMatplotlib.py
+++ b/silx/gui/plot/backends/BackendMatplotlib.py
@@ -1094,13 +1094,16 @@ class BackendMatplotlib(BackendBase.BackendBase):
# Data <-> Pixel coordinates conversion
- def _mplQtYAxisCoordConversion(self, y):
+ def _mplQtYAxisCoordConversion(self, y, asint=True):
"""Qt origin (top) to/from matplotlib origin (bottom) conversion.
+ :param y:
+ :param bool asint: True to cast to int, False to keep as float
+
:rtype: float
"""
- height = self.fig.get_window_extent().height
- return height - y
+ value = self.fig.get_window_extent().height - y
+ return int(value) if asint else value
def dataToPixel(self, x, y, axis):
ax = self.ax2 if axis == "right" else self.ax
@@ -1109,7 +1112,7 @@ class BackendMatplotlib(BackendBase.BackendBase):
xPixel, yPixel = pixels.T
# Convert from matplotlib origin (bottom) to Qt origin (top)
- yPixel = self._mplQtYAxisCoordConversion(yPixel)
+ yPixel = self._mplQtYAxisCoordConversion(yPixel, asint=False)
return xPixel, yPixel
@@ -1117,7 +1120,7 @@ class BackendMatplotlib(BackendBase.BackendBase):
ax = self.ax2 if axis == "right" else self.ax
# Convert from Qt origin (top) to matplotlib origin (bottom)
- y = self._mplQtYAxisCoordConversion(y)
+ y = self._mplQtYAxisCoordConversion(y, asint=False)
inv = ax.transData.inverted()
x, y = inv.transform_point((x, y))
@@ -1126,10 +1129,10 @@ class BackendMatplotlib(BackendBase.BackendBase):
def getPlotBoundsInPixels(self):
bbox = self.ax.get_window_extent()
# Warning this is not returning int...
- return (bbox.xmin,
- self._mplQtYAxisCoordConversion(bbox.ymax),
- bbox.width,
- bbox.height)
+ return (int(bbox.xmin),
+ self._mplQtYAxisCoordConversion(bbox.ymax, asint=True),
+ int(bbox.width),
+ int(bbox.height))
def setAxesDisplayed(self, displayed):
"""Display or not the axes.
@@ -1263,7 +1266,7 @@ class BackendMatplotlibQt(FigureCanvasQTAgg, BackendMatplotlib):
def _onMouseMove(self, event):
if self._graphCursor:
lineh, linev = self._graphCursor
- if event.inaxes != self.ax and lineh.get_visible():
+ if event.inaxes not in (self.ax, self.ax2) and lineh.get_visible():
lineh.set_visible(False)
linev.set_visible(False)
self._plot._setDirtyPlot(overlayOnly=True)
diff --git a/silx/gui/plot/items/shape.py b/silx/gui/plot/items/shape.py
index e6dc529..8176be1 100644
--- a/silx/gui/plot/items/shape.py
+++ b/silx/gui/plot/items/shape.py
@@ -197,6 +197,8 @@ class BoundingRect(Item, YAxisMixIn):
self._updated(ItemChangedType.DATA)
def _getBounds(self):
+ if self.__bounds is None:
+ return None
plot = self.getPlot()
if plot is not None:
xPositive = plot.getXAxis()._isLogarithmic()
diff --git a/silx/gui/plot/tools/profile/_BaseProfileToolBar.py b/silx/gui/plot/tools/profile/_BaseProfileToolBar.py
index ced81da..75bb4c6 100644
--- a/silx/gui/plot/tools/profile/_BaseProfileToolBar.py
+++ b/silx/gui/plot/tools/profile/_BaseProfileToolBar.py
@@ -231,7 +231,7 @@ class _BaseProfileToolBar(qt.QToolBar):
profilePlot.addCurve(
xProfile, values, legend='Profile', color=self._color)
- self._showDefaultProfileWindow()
+ self._showDefaultProfileWindow()
def _showDefaultProfileWindow(self):
"""If profile window was created by this toolbar,
diff --git a/silx/gui/plot3d/tools/PositionInfoWidget.py b/silx/gui/plot3d/tools/PositionInfoWidget.py
index 52a6163..fc86a7f 100644
--- a/silx/gui/plot3d/tools/PositionInfoWidget.py
+++ b/silx/gui/plot3d/tools/PositionInfoWidget.py
@@ -189,7 +189,7 @@ class PositionInfoWidget(qt.QWidget):
return # No picked item
item = picking.getItem()
- self._itemLabel.setText(item.getName())
+ self._itemLabel.setText(item.getLabel())
positions = picking.getPositions('scene', copy=False)
x, y, z = positions[0]
self._xLabel.setText("%g" % x)