本文整理匯總了Python中silx.gui.plot.PlotWidget.getGraphXLimits方法的典型用法代碼示例。如果您正苦於以下問題:Python PlotWidget.getGraphXLimits方法的具體用法?Python PlotWidget.getGraphXLimits怎麽用?Python PlotWidget.getGraphXLimits使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類silx.gui.plot.PlotWidget
的用法示例。
在下文中一共展示了PlotWidget.getGraphXLimits方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: RGBCorrelatorGraph
# 需要導入模塊: from silx.gui.plot import PlotWidget [as 別名]
# 或者: from silx.gui.plot.PlotWidget import getGraphXLimits [as 別名]
#.........這裏部分代碼省略.........
try:
outputFile = os.path.basename(outstr)
except:
outputFile = outstr
outputDir = os.path.dirname(outstr)
self.saveDirectory = outputDir
PyMcaDirs.outputDir = outputDir
#always overwrite for the time being
if len(outputFile) < len(extension[1:]):
outputFile += extension[1:]
elif outputFile[-4:] != extension[1:]:
outputFile += extension[1:]
outputFile = os.path.join(outputDir, outputFile)
if os.path.exists(outputFile):
try:
os.remove(outputFile)
except:
qt.QMessageBox.critical(self, "Save Error",
"Cannot overwrite existing file")
return
if filetype.upper() == "IMAGE":
self.saveGraphImage(outputFile, original=True)
elif filetype.upper() == "ZOOMEDIMAGE":
self.saveGraphImage(outputFile, original=False)
else:
self.saveGraphWidget(outputFile)
def saveGraphImage(self, filename, original=False):
format_ = filename[-3:].upper()
activeImage = self.graph.getActiveImage()
rgbdata = activeImage.getRgbaImageData()
# silx to pymca scale convention (a + b x)
xScale = activeImage.getOrigin()[0], activeImage.getScale()[0]
yScale = activeImage.getOrigin()[1], activeImage.getScale()[1]
if original:
# save whole image
bgradata = numpy.array(rgbdata, copy=True)
bgradata[:, :, 0] = rgbdata[:, :, 2]
bgradata[:, :, 2] = rgbdata[:, :, 0]
else:
shape = rgbdata.shape[:2]
xmin, xmax = self.graph.getGraphXLimits()
ymin, ymax = self.graph.getGraphYLimits()
# save zoomed image, for that we have to get the limits
r0, c0 = convertToRowAndColumn(xmin, ymin, shape, xScale=xScale, yScale=yScale, safe=True)
r1, c1 = convertToRowAndColumn(xmax, ymax, shape, xScale=xScale, yScale=yScale, safe=True)
row0 = int(min(r0, r1))
row1 = int(max(r0, r1))
col0 = int(min(c0, c1))
col1 = int(max(c0, c1))
if row1 < shape[0]:
row1 += 1
if col1 < shape[1]:
col1 += 1
tmpArray = rgbdata[row0:row1, col0:col1, :]
bgradata = numpy.array(tmpArray, copy=True, dtype=rgbdata.dtype)
bgradata[:, :, 0] = tmpArray[:, :, 2]
bgradata[:, :, 2] = tmpArray[:, :, 0]
if self.graph.isYAxisInverted():
qImage = qt.QImage(bgradata, bgradata.shape[1], bgradata.shape[0],
qt.QImage.Format_ARGB32)
else:
qImage = qt.QImage(bgradata, bgradata.shape[1], bgradata.shape[0],
qt.QImage.Format_ARGB32).mirrored(False, True)
pixmap = qt.QPixmap.fromImage(qImage)
if pixmap.save(filename, format_):
return
else:
qt.QMessageBox.critical(self, "Save Error",
"%s" % sys.exc_info()[1])
return
def saveGraphWidget(self, filename):
format_ = filename[-3:].upper()
if hasattr(qt.QPixmap, "grabWidget"):
# Qt4
pixmap = qt.QPixmap.grabWidget(self.graph.getWidgetHandle())
else:
# Qt5
pixmap = self.graph.getWidgetHandle().grab()
if pixmap.save(filename, format_):
return
else:
qt.QMessageBox.critical(self, "Save Error", "%s" % sys.exc_info()[1])
return
def setSaveDirectory(self, wdir):
if os.path.exists(wdir):
self.saveDirectory = wdir
return True
else:
return False
def selectColormap(self):
qt.QMessageBox.information(self, "Open", "Not implemented (yet)")
def _zoomBack(self, pos):
self.graph.getLimitsHistory().pop()