commit
6d05a2f8e1
@ -44,12 +44,18 @@ class HDF5Exporter(Exporter):
|
|||||||
data = []
|
data = []
|
||||||
|
|
||||||
appendAllX = self.params['columnMode'] == '(x,y) per plot'
|
appendAllX = self.params['columnMode'] == '(x,y) per plot'
|
||||||
for i,c in enumerate(self.item.curves):
|
#print dir(self.item.curves[0])
|
||||||
|
tlen = 0
|
||||||
|
for i, c in enumerate(self.item.curves):
|
||||||
d = c.getData()
|
d = c.getData()
|
||||||
|
if i > 0 and len(d[0]) != tlen:
|
||||||
|
raise ValueError ("HDF5 Export requires all curves in plot to have same length")
|
||||||
if appendAllX or i == 0:
|
if appendAllX or i == 0:
|
||||||
data.append(d[0])
|
data.append(d[0])
|
||||||
|
tlen = len(d[0])
|
||||||
data.append(d[1])
|
data.append(d[1])
|
||||||
|
|
||||||
|
|
||||||
fdata = numpy.array(data).astype('double')
|
fdata = numpy.array(data).astype('double')
|
||||||
dset = fd.create_dataset(dsname, data=fdata)
|
dset = fd.create_dataset(dsname, data=fdata)
|
||||||
fd.close()
|
fd.close()
|
||||||
|
@ -27,6 +27,7 @@ class ImageExporter(Exporter):
|
|||||||
{'name': 'height', 'type': 'int', 'value': int(tr.height()), 'limits': (0, None)},
|
{'name': 'height', 'type': 'int', 'value': int(tr.height()), 'limits': (0, None)},
|
||||||
{'name': 'antialias', 'type': 'bool', 'value': True},
|
{'name': 'antialias', 'type': 'bool', 'value': True},
|
||||||
{'name': 'background', 'type': 'color', 'value': bg},
|
{'name': 'background', 'type': 'color', 'value': bg},
|
||||||
|
{'name': 'invertValue', 'type': 'bool', 'value': False}
|
||||||
])
|
])
|
||||||
self.params.param('width').sigValueChanged.connect(self.widthChanged)
|
self.params.param('width').sigValueChanged.connect(self.widthChanged)
|
||||||
self.params.param('height').sigValueChanged.connect(self.heightChanged)
|
self.params.param('height').sigValueChanged.connect(self.heightChanged)
|
||||||
@ -67,13 +68,15 @@ class ImageExporter(Exporter):
|
|||||||
w, h = self.params['width'], self.params['height']
|
w, h = self.params['width'], self.params['height']
|
||||||
if w == 0 or h == 0:
|
if w == 0 or h == 0:
|
||||||
raise Exception("Cannot export image with size=0 (requested export size is %dx%d)" % (w,h))
|
raise Exception("Cannot export image with size=0 (requested export size is %dx%d)" % (w,h))
|
||||||
bg = np.empty((self.params['width'], self.params['height'], 4), dtype=np.ubyte)
|
bg = np.empty((self.params['height'], self.params['width'], 4), dtype=np.ubyte)
|
||||||
color = self.params['background']
|
color = self.params['background']
|
||||||
bg[:,:,0] = color.blue()
|
bg[:,:,0] = color.blue()
|
||||||
bg[:,:,1] = color.green()
|
bg[:,:,1] = color.green()
|
||||||
bg[:,:,2] = color.red()
|
bg[:,:,2] = color.red()
|
||||||
bg[:,:,3] = color.alpha()
|
bg[:,:,3] = color.alpha()
|
||||||
self.png = fn.makeQImage(bg, alpha=True)
|
|
||||||
|
self.png = fn.makeQImage(bg, alpha=True, copy=False, transpose=False)
|
||||||
|
self.bg = bg
|
||||||
|
|
||||||
## set resolution of image:
|
## set resolution of image:
|
||||||
origTargetRect = self.getTargetRect()
|
origTargetRect = self.getTargetRect()
|
||||||
@ -91,6 +94,12 @@ class ImageExporter(Exporter):
|
|||||||
self.setExportMode(False)
|
self.setExportMode(False)
|
||||||
painter.end()
|
painter.end()
|
||||||
|
|
||||||
|
if self.params['invertValue']:
|
||||||
|
mn = bg[...,:3].min(axis=2)
|
||||||
|
mx = bg[...,:3].max(axis=2)
|
||||||
|
d = (255 - mx) - mn
|
||||||
|
bg[...,:3] += d[...,np.newaxis]
|
||||||
|
|
||||||
if copy:
|
if copy:
|
||||||
QtGui.QApplication.clipboard().setImage(self.png)
|
QtGui.QApplication.clipboard().setImage(self.png)
|
||||||
elif toBytes:
|
elif toBytes:
|
||||||
|
Loading…
Reference in New Issue
Block a user