summaryrefslogtreecommitdiff
path: root/silx/gui/plot/PlotWindow.py
diff options
context:
space:
mode:
Diffstat (limited to 'silx/gui/plot/PlotWindow.py')
-rw-r--r--silx/gui/plot/PlotWindow.py87
1 files changed, 41 insertions, 46 deletions
diff --git a/silx/gui/plot/PlotWindow.py b/silx/gui/plot/PlotWindow.py
index 23ea399..b44a512 100644
--- a/silx/gui/plot/PlotWindow.py
+++ b/silx/gui/plot/PlotWindow.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
@@ -29,7 +29,7 @@ The :class:`PlotWindow` is a subclass of :class:`.PlotWidget`.
__authors__ = ["V.A. Sole", "T. Vincent"]
__license__ = "MIT"
-__date__ = "12/10/2018"
+__date__ = "21/12/2018"
import collections
import logging
@@ -217,10 +217,8 @@ class PlotWindow(PlotWidget):
# Make colorbar background white
self._colorbar.setAutoFillBackground(True)
- palette = self._colorbar.palette()
- palette.setColor(qt.QPalette.Background, qt.Qt.white)
- palette.setColor(qt.QPalette.Window, qt.Qt.white)
- self._colorbar.setPalette(palette)
+ self._sigAxesVisibilityChanged.connect(self._updateColorBarBackground)
+ self._updateColorBarBackground()
gridLayout = qt.QGridLayout()
gridLayout.setSpacing(0)
@@ -294,6 +292,43 @@ class PlotWindow(PlotWidget):
for action in toolbar.actions():
self.addAction(action)
+ def setBackgroundColor(self, color):
+ super(PlotWindow, self).setBackgroundColor(color)
+ self._updateColorBarBackground()
+
+ setBackgroundColor.__doc__ = PlotWidget.setBackgroundColor.__doc__
+
+ def setDataBackgroundColor(self, color):
+ super(PlotWindow, self).setDataBackgroundColor(color)
+ self._updateColorBarBackground()
+
+ setDataBackgroundColor.__doc__ = PlotWidget.setDataBackgroundColor.__doc__
+
+ def setForegroundColor(self, color):
+ super(PlotWindow, self).setForegroundColor(color)
+ self._updateColorBarBackground()
+
+ setForegroundColor.__doc__ = PlotWidget.setForegroundColor.__doc__
+
+ def _updateColorBarBackground(self):
+ """Update the colorbar background according to the state of the plot"""
+ if self._isAxesDisplayed():
+ color = self.getBackgroundColor()
+ else:
+ color = self.getDataBackgroundColor()
+ if not color.isValid():
+ # If no color defined, use the background one
+ color = self.getBackgroundColor()
+
+ foreground = self.getForegroundColor()
+
+ palette = self._colorbar.palette()
+ palette.setColor(qt.QPalette.Background, color)
+ palette.setColor(qt.QPalette.Window, color)
+ palette.setColor(qt.QPalette.WindowText, foreground)
+ palette.setColor(qt.QPalette.Text, foreground)
+ self._colorbar.setPalette(palette)
+
def getInteractiveModeToolBar(self):
"""Returns QToolBar controlling interactive mode.
@@ -457,10 +492,6 @@ class PlotWindow(PlotWidget):
return self._colorbar
# getters for dock widgets
- @property
- @deprecated(replacement="getLegendsDockWidget()", since_version="0.4.0")
- def legendsDockWidget(self):
- return self.getLegendsDockWidget()
def getLegendsDockWidget(self):
"""DockWidget with Legend panel"""
@@ -470,11 +501,6 @@ class PlotWindow(PlotWidget):
self.addTabbedDockWidget(self._legendsDockWidget)
return self._legendsDockWidget
- @property
- @deprecated(replacement="getCurvesRoiWidget()", since_version="0.4.0")
- def curvesROIDockWidget(self):
- return self.getCurvesRoiDockWidget()
-
def getCurvesRoiDockWidget(self):
# Undocumented for a "soft deprecation" in version 0.7.0
# (still used internally for lazy loading)
@@ -496,11 +522,6 @@ class PlotWindow(PlotWidget):
"""
return self.getCurvesRoiDockWidget().roiWidget
- @property
- @deprecated(replacement="getMaskToolsDockWidget()", since_version="0.4.0")
- def maskToolsDockWidget(self):
- return self.getMaskToolsDockWidget()
-
def getMaskToolsDockWidget(self):
"""DockWidget with image mask panel (lazy-loaded)."""
if self._maskToolsDockWidget is None:
@@ -539,11 +560,6 @@ class PlotWindow(PlotWidget):
def panModeAction(self):
return self.getInteractiveModeToolBar().getPanModeAction()
- @property
- @deprecated(replacement="getConsoleAction()", since_version="0.4.0")
- def consoleAction(self):
- return self.getConsoleAction()
-
def getConsoleAction(self):
"""QAction handling the IPython console activation.
@@ -563,11 +579,6 @@ class PlotWindow(PlotWidget):
self._consoleAction.setEnabled(False)
return self._consoleAction
- @property
- @deprecated(replacement="getCrosshairAction()", since_version="0.4.0")
- def crosshairAction(self):
- return self.getCrosshairAction()
-
def getCrosshairAction(self):
"""Action toggling crosshair cursor mode.
@@ -577,11 +588,6 @@ class PlotWindow(PlotWidget):
self._crosshairAction = actions.control.CrosshairAction(self, color='red')
return self._crosshairAction
- @property
- @deprecated(replacement="getMaskAction()", since_version="0.4.0")
- def maskAction(self):
- return self.getMaskAction()
-
def getMaskAction(self):
"""QAction toggling image mask dock widget
@@ -589,12 +595,6 @@ class PlotWindow(PlotWidget):
"""
return self.getMaskToolsDockWidget().toggleViewAction()
- @property
- @deprecated(replacement="getPanWithArrowKeysAction()",
- since_version="0.4.0")
- def panWithArrowKeysAction(self):
- return self.getPanWithArrowKeysAction()
-
def getPanWithArrowKeysAction(self):
"""Action toggling pan with arrow keys.
@@ -604,11 +604,6 @@ class PlotWindow(PlotWidget):
self._panWithArrowKeysAction = actions.control.PanWithArrowKeysAction(self)
return self._panWithArrowKeysAction
- @property
- @deprecated(replacement="getRoiAction()", since_version="0.4.0")
- def roiAction(self):
- return self.getRoiAction()
-
def getStatsAction(self):
if self._statsAction is None:
self._statsAction = qt.QAction('Curves stats', self)