Merge branch 'meganbkratz-ImageViewWork' into develop

This commit is contained in:
Luke Campagnola 2016-04-02 23:28:33 -07:00
commit eb625776c9
3 changed files with 42 additions and 5 deletions

View File

@ -48,6 +48,18 @@ data[:,50:60,50:60] += sig
## Display the data and assign each frame a time value from 1.0 to 3.0
imv.setImage(data, xvals=np.linspace(1., 3., data.shape[0]))
## Set a custom color map
colors = [
(0, 0, 0),
(45, 5, 61),
(84, 42, 55),
(150, 87, 60),
(208, 171, 141),
(255, 255, 255)
]
cmap = pg.ColorMap(pos=np.linspace(0.0, 1.0, 6), color=colors)
imv.setColorMap(cmap)
## Start Qt event loop unless running in interactive mode.
if __name__ == '__main__':
import sys

View File

@ -13,7 +13,6 @@ from ..python2_3 import cmp
__all__ = ['TickSliderItem', 'GradientEditorItem']
Gradients = OrderedDict([
('thermal', {'ticks': [(0.3333, (185, 0, 0, 255)), (0.6666, (255, 220, 0, 255)), (1, (255, 255, 255, 255)), (0, (0, 0, 0, 255))], 'mode': 'rgb'}),
('flame', {'ticks': [(0.2, (7, 0, 220, 255)), (0.5, (236, 0, 134, 255)), (0.8, (246, 246, 0, 255)), (1.0, (255, 255, 255, 255)), (0.0, (0, 0, 0, 255))], 'mode': 'rgb'}),
@ -25,6 +24,13 @@ Gradients = OrderedDict([
('grey', {'ticks': [(0.0, (0, 0, 0, 255)), (1.0, (255, 255, 255, 255))], 'mode': 'rgb'}),
])
def addGradientListToDocstring():
"""Decorator to add list of current pre-defined gradients to the end of a function docstring."""
def dec(fn):
fn.__doc__ = fn.__doc__ + str(Gradients.keys()).strip('[').strip(']')
return fn
return dec
class TickSliderItem(GraphicsWidget):
@ -471,11 +477,12 @@ class GradientEditorItem(TickSliderItem):
act = self.sender()
self.loadPreset(act.name)
@addGradientListToDocstring()
def loadPreset(self, name):
"""
Load a predefined gradient.
Load a predefined gradient. Currently defined gradients are:
"""## TODO: provide image with names of defined gradients
""" ## TODO: provide image with names of defined gradients
#global Gradients
self.restoreState(Gradients[name])

View File

@ -26,6 +26,7 @@ from ..graphicsItems.ROI import *
from ..graphicsItems.LinearRegionItem import *
from ..graphicsItems.InfiniteLine import *
from ..graphicsItems.ViewBox import *
from ..graphicsItems.GradientEditorItem import addGradientListToDocstring
from .. import ptime as ptime
from .. import debug as debug
from ..SignalProxy import SignalProxy
@ -718,3 +719,20 @@ class ImageView(QtGui.QWidget):
self.buildMenu()
self.menu.popup(QtGui.QCursor.pos())
def setColorMap(self, colormap):
"""Set the color map.
============= =========================================================
**Arguments**
colormap (A ColorMap() instance) The ColorMap to use for coloring
images.
============= =========================================================
"""
self.ui.histogram.gradient.setColorMap(colormap)
@addGradientListToDocstring()
def setPredefinedGradient(self, name):
"""Set one of the gradients defined in :class:`GradientEditorItem <pyqtgraph.graphicsItems.GradientEditorItem>`.
Currently available gradients are:
"""
self.ui.histogram.gradient.loadPreset(name)