Commit 1c8579d4 authored by Luke Campagnola's avatar Luke Campagnola
Browse files

- Bugfixes:

    Fixed exporters to automatically add filename extension.
    Fixed ViewBox 'auto pan' option.
- Other minor edits.
parent c4019b90
......@@ -22,7 +22,7 @@ class CSVExporter(Exporter):
def export(self, fileName=None):
if not isinstance(self.item, pg.PlotItem):
raise Exception("Matplotlib export currently only works with plot items")
raise Exception("Must have a PlotItem selected for CSV export.")
if fileName is None:
self.fileSaveDialog(filter=["*.csv", "*.tsv"])
......
......@@ -54,8 +54,13 @@ class Exporter(object):
fileName = str(fileName)
global LastExportDirectory
LastExportDirectory = os.path.split(fileName)[0]
self.export(fileName=fileName, **self.fileDialog.opts)
ext = os.path.splitext(fileName)[1].lower()
selectedExt = str(self.fileDialog.selectedNameFilter()).lstrip('*').lower()
if ext != selectedExt:
fileName = fileName + selectedExt
self.export(fileName=fileName, **self.fileDialog.opts)
def getScene(self):
if isinstance(self.item, pg.GraphicsScene):
......
......@@ -63,7 +63,7 @@ class ImageExporter(Exporter):
self.getScene().render(painter, QtCore.QRectF(targetRect), sourceRect)
finally:
self.setExportMode(False)
self.png.save(fileName)
painter.end()
self.png.save(fileName)
\ No newline at end of file
......@@ -172,6 +172,8 @@ class AxisItem(GraphicsWidget):
return asUnicode("<span style='%s'>%s</span>") % (style, s)
def setHeight(self, h=None):
"""Set the height of this axis reserved for ticks and tick labels.
The height of the axis label is automatically added."""
if h is None:
h = self.textHeight + max(0, self.tickLength)
if self.label.isVisible():
......@@ -182,6 +184,8 @@ class AxisItem(GraphicsWidget):
def setWidth(self, w=None):
"""Set the width of this axis reserved for ticks and tick labels.
The width of the axis label is automatically added."""
if w is None:
w = max(0, self.tickLength) + 40
if self.label.isVisible():
......
......@@ -554,10 +554,10 @@ class ViewBox(GraphicsWidget):
## Make corrections to range
xr = childRange[ax]
if xr is not None:
if self.state['autoPan'][0]:
if self.state['autoPan'][ax]:
x = sum(xr) * 0.5
#x = childRect.center().x()
w2 = (targetRect[0][1]-targetRect[0][0]) / 2.
w2 = (targetRect[ax][1]-targetRect[ax][0]) / 2.
#childRect.setLeft(x-w2)
#childRect.setRight(x+w2)
childRange[ax] = [x-w2, x+w2]
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment