本文整理汇总了Python中matplotlib.backends.backend_qt4agg.FigureCanvasQTAgg.setCursor方法的典型用法代码示例。如果您正苦于以下问题:Python FigureCanvasQTAgg.setCursor方法的具体用法?Python FigureCanvasQTAgg.setCursor怎么用?Python FigureCanvasQTAgg.setCursor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类matplotlib.backends.backend_qt4agg.FigureCanvasQTAgg
的用法示例。
在下文中一共展示了FigureCanvasQTAgg.setCursor方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: smileiQtPlot
# 需要导入模块: from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg [as 别名]
# 或者: from matplotlib.backends.backend_qt4agg.FigureCanvasQTAgg import setCursor [as 别名]
class smileiQtPlot(QWidget):
scalarDict=dict()
fieldDict=dict()
phaseDict=dict()
nplots=0
ax={}
dirName='.'
someCheckBoxChanged=True
pauseSignal=pyqtSignal()
shiftPressed=False
title=''
def __init__(self,parent,dirName):
super(smileiQtPlot, self).__init__()
self.setParent(parent)
uiFile=os.path.dirname(os.path.realpath(__file__))+'/smileiQtPlot.ui'
self.ui=uic.loadUi(uiFile,self)
self.dirName=dirName
self.smilei=Smilei(self.dirName)
self.parent=parent
self.parent.timer.timeout.connect(self.next)
self.parent.ui.next.released.connect(self.next)
self.parent.ui.previous.released.connect(self.previous)
self.parent.ui.first.released.connect(self.first)
self.parent.ui.last.released.connect(self.last)
self.pauseSignal.connect(self.parent.pause)
self.setWindowFlags(Qt.Window)
self.setWindowTitle(dirName)
self.step=0
self.ui.savePoints.setIcon(self.ui.style().standardIcon(QStyle.SP_DialogSaveButton))
self.ui.savePoints.released.connect(self.doSavePoints)
self.ui.tabWidget.currentChanged.connect(self.changeTab)
self.ui.autoScale.stateChanged.connect(self.doPlots)
self.fig = Figure()
self.ui.reload.setIcon(self.ui.style().standardIcon(QStyle.SP_BrowserReload))
self.ui.reload.released.connect(self.reloadAll)
self.canvas = FigureCanvas(self.fig)
self.canvas.setFocusPolicy(Qt.StrongFocus)
self.canvas.setFocus()
self.canvas.mpl_connect('motion_notify_event', self.on_movement)
self.canvas.mpl_connect('key_press_event', self.on_key_press)
self.canvas.mpl_connect('key_release_event', self.on_key_release)
self.canvas.mpl_connect('button_press_event', self.on_button_press)
self.toolbar = NavigationToolbar(self.canvas, self)
self.toolbar.setFixedHeight(18)
self.canvas.setCursor(Qt.CrossCursor)
self.ui.plotLayout.addWidget(self.toolbar)
self.ui.plotLayout.addWidget(self.canvas)
#retrieve stuff from namelist
self.cell_length=self.smilei.namelist.Main.cell_length[0]
self.timestep=self.smilei.namelist.Main.timestep
self.sim_length=self.smilei.namelist.Main.sim_length
#scalars
scalarSteps=[]
for scalar in self.smilei.Scalar().getScalars():
if len(scalarSteps) ==0:
scalarSteps=self.smilei.Scalar(scalar).getAvailableTimesteps()
else:
if not np.array_equal(scalarSteps,self.smilei.Scalar(scalar).getAvailableTimesteps()):
log.error("Problem reading scalarSteps %s"%scalar)
my_button= QCheckBox(scalar)
my_button.stateChanged.connect(self.checkBoxChanged)
self.ui.layoutScalars.addWidget(my_button)
self.ui.layoutScalars.addStretch()
#fields
self.fieldSteps=self.smilei.Field().getAvailableTimesteps()
if not np.array_equal(scalarSteps,self.fieldSteps):
newfieldSteps=[]
for i in range(0,min(len(scalarSteps),len(self.fieldSteps))):
if scalarSteps[i] == self.fieldSteps[i]:
newfieldSteps.append(scalarSteps[i])
else:
break
self.fieldSteps=newfieldSteps
log.warning("Problem reading fieldSteps")
for field in self.smilei.Field().getFields():
my_button= QCheckBox(field)
my_button.stateChanged.connect(self.checkBoxChanged)
self.ui.layoutFields.addWidget(my_button)
self.ui.layoutFields.addStretch()
#.........这里部分代码省略.........
示例2: setGraphCursorShape
# 需要导入模块: from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg [as 别名]
# 或者: from matplotlib.backends.backend_qt4agg.FigureCanvasQTAgg import setCursor [as 别名]
def setGraphCursorShape(self, cursor):
cursor = self._QT_CURSORS[cursor]
FigureCanvasQTAgg.setCursor(self, qt.QCursor(cursor))
示例3: smileiQtPlot
# 需要导入模块: from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg [as 别名]
# 或者: from matplotlib.backends.backend_qt4agg.FigureCanvasQTAgg import setCursor [as 别名]
class smileiQtPlot(QWidget):
scalarDict=dict()
fieldDict=dict()
phaseDict=dict()
fieldFile=None
phaseFile=None
nplots=0
ax={}
dirName=None
someCheckBoxChanged=True
pauseSignal=pyqtSignal()
shiftPressed=False
title=''
def __init__(self,parent,dirName):
super(smileiQtPlot, self).__init__()
self.setParent(parent)
uiFile=os.path.dirname(os.path.realpath(__file__))+'/smileiQtPlot.ui'
self.ui=uic.loadUi(uiFile,self)
self.dirName=dirName
self.parent=parent
self.parent.timer.timeout.connect(self.next)
self.parent.ui.next.released.connect(self.next)
self.parent.ui.previous.released.connect(self.previous)
self.parent.ui.first.released.connect(self.first)
self.parent.ui.last.released.connect(self.last)
self.pauseSignal.connect(self.parent.pause)
self.setWindowFlags(Qt.Window)
self.setWindowTitle(dirName)
self.step=0
self.ui.savePoints.setIcon(self.ui.style().standardIcon(QStyle.SP_DialogSaveButton))
self.ui.savePoints.released.connect(self.doSavePoints)
self.ui.tabWidget.currentChanged.connect(self.changeTab)
self.ui.autoScale.stateChanged.connect(self.doPlots)
self.fig = Figure()
self.ui.reload.setIcon(self.ui.style().standardIcon(QStyle.SP_BrowserReload))
self.ui.reload.released.connect(self.reloadAll)
self.canvas = FigureCanvas(self.fig)
self.canvas.setFocusPolicy(Qt.StrongFocus)
self.canvas.setFocus()
self.canvas.mpl_connect('motion_notify_event', self.on_movement)
self.canvas.mpl_connect('key_press_event', self.on_key_press)
self.canvas.mpl_connect('key_release_event', self.on_key_release)
self.canvas.mpl_connect('button_press_event', self.on_button_press)
self.toolbar = NavigationToolbar(self.canvas, self)
self.toolbar.setFixedHeight(18)
self.canvas.setCursor(Qt.CrossCursor)
self.ui.plotLayout.addWidget(self.canvas)
self.ui.plotLayout.addWidget(self.toolbar)
fname=os.path.join(dirName, "scalars.txt")
if os.path.isfile(fname) :
self.scalarData = np.loadtxt(fname)
names=[]
for line in open(fname):
li=line.strip()
if li.startswith("#"):
list=line.split()
names.append(list[-1])
scalars_names=names[1:-2]
for i in range(len(scalars_names)):
my_button= QCheckBox(scalars_names[i])
my_button.stateChanged.connect(self.checkBoxChanged)
self.ui.layoutScalars.addWidget(my_button)
self.ui.layoutScalars.addStretch()
else :
print "Problem reading ",fname
# self.deleteLater()
self.fieldSteps=[]
fname=os.path.join(dirName, "Fields.h5")
if os.path.isfile(fname) :
self.fieldFile=tb.openFile(fname)
self.cell_length=self.fieldFile.root._v_attrs.cell_length[0]
self.res_time=self.fieldFile.root._v_attrs.res_time
self.sim_length=self.fieldFile.root._v_attrs.sim_length
# JDT self.fieldEvery=self.fieldFile.root._v_attrs.every
first=True
for group in self.fieldFile.listNodes("/", classname='Group'):
self.fieldSteps.append(group._v_name)
if first:
first=False
#.........这里部分代码省略.........
示例4: Window
# 需要导入模块: from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg [as 别名]
# 或者: from matplotlib.backends.backend_qt4agg.FigureCanvasQTAgg import setCursor [as 别名]
#.........这里部分代码省略.........
if tsImage.pixels == np.array([]):
self.image = None
self.updateFigure()
return
self.image = tsImage.pixels
fname = tsImage.path
else:
fname = QtGui.QFileDialog.getOpenFileName(self, 'Open image', '/mnt/phenocam/a_data/TimeStreams/Borevitz/BVZ0036/BVZ0036-GC02L-C01~fullres-orig/2014/2014_06/2014_06_24/2014_06_24_08/')
app.processEvents()
if len(fname) == 0:
return
self.image = cv2.imread(str(fname))[:,:,::-1]
self.status.append('Loaded image from ' + str(fname))
# reset all outputs
# self.colorcardList = []
# self.trayList = []
# self.potList = []
self.isDistortionCorrected = False
if self.rotationAngle != None:
self.image = cd.rotateImage(self.image, self.rotationAngle + self.smaleRotationAngle)
# Undistort image if mapping available
if not self.isDistortionCorrected and self.UndistMapX != None and self.UndistMapY != None:
self.image = cv2.remap(self.image.astype(np.uint8), self.UndistMapX, self.UndistMapY, cv2.INTER_CUBIC)
self.isDistortionCorrected = True
self.updateFigure()
def changeCursor(self, event):
# cursor = Cursor(self.ax, useblit=True, color='red', linewidth=1)
self.canvas.setCursor(QtGui.QCursor(QtCore.Qt.CrossCursor ))
def updateFigure(self, image = None, resetFigure = False):
if self.image != None:
if image == None:
image = self.image
if self.ax == None:
self.ax = self.figure.add_subplot(111)
self.ax.figure.canvas.mpl_connect('button_press_event', self.onMouseClicked)
self.ax.figure.canvas.mpl_connect('motion_notify_event', self.onMouseMoves)
self.ax.figure.canvas.mpl_connect('figure_enter_event', self.changeCursor)
self.ax.hold(False)
if self.plotImg == None or resetFigure:
self.plotImg = self.ax.imshow(image)
else:
self.plotImg.set_data(image)
self.figure.tight_layout()
xs, ys = [], []
for Rect in self.colorcardList:
tl, bl, br, tr = Rect
xs = xs + [tl[0], bl[0], br[0], tr[0], tl[0], np.nan]
ys = ys + [tl[1], bl[1], br[1], tr[1], tl[1], np.nan]
for Rect in self.trayList:
tl, bl, br, tr = Rect
xs = xs + [tl[0], bl[0], br[0], tr[0], tl[0], np.nan]
ys = ys + [tl[1], bl[1], br[1], tr[1], tl[1], np.nan]
for Rect in self.potList:
tl, bl, br, tr = Rect
xs = xs + [tl[0], bl[0], br[0], tr[0], tl[0], np.nan]
ys = ys + [tl[1], bl[1], br[1], tr[1], tl[1], np.nan]
for x,y in self.leftClicks:
xs = xs + [x]
示例5: Window
# 需要导入模块: from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg [as 别名]
# 或者: from matplotlib.backends.backend_qt4agg.FigureCanvasQTAgg import setCursor [as 别名]
#.........这里部分代码省略.........
self.status.append('Loading image...')
app.processEvents()
self.image = cv2.imread(str(fname))[:,:,::-1]
self.status.append('Loaded image from ' + str(fname))
# reset all outputs
self.colorcardList = []
self.trayList = []
self.potList = []
self.rotationAngle = 0
self.isDistortionCorrected = False
# Undistort image if mapping available
if not self.isDistortionCorrected and self.UndistMapX != None and self.UndistMapY != None:
self.image = cv2.remap(self.image.astype(np.uint8), self.UndistMapX, self.UndistMapY, cv2.INTER_CUBIC)
self.isDistortionCorrected = True
if self.image != None:
if self.ax == None:
self.ax = self.figure.add_subplot(111)
self.ax.figure.canvas.mpl_connect('button_press_event', self.onMouseClicked)
self.ax.figure.canvas.mpl_connect('motion_notify_event', self.onMouseMoves)
self.ax.figure.canvas.mpl_connect('figure_enter_event', self.changeCursor)
self.ax.hold(False)
if self.plotImg == None:
self.plotImg = self.ax.imshow(self.image)
else:
self.plotImg.set_data(self.image)
self.figure.tight_layout()
self.canvas.draw()
def changeCursor(self, event):
# cursor = Cursor(self.ax, useblit=True, color='red', linewidth=1)
self.canvas.setCursor(QtGui.QCursor(QtCore.Qt.CrossCursor ))
def updateFigure(self):
xs, ys = [], []
for Rect in self.colorcardList:
tl, bl, br, tr = Rect
xs = xs + [tl[0], bl[0], br[0], tr[0], tl[0], np.nan]
ys = ys + [tl[1], bl[1], br[1], tr[1], tl[1], np.nan]
for Rect in self.trayList:
tl, bl, br, tr = Rect
xs = xs + [tl[0], bl[0], br[0], tr[0], tl[0], np.nan]
ys = ys + [tl[1], bl[1], br[1], tr[1], tl[1], np.nan]
for Rect in self.potList:
tl, bl, br, tr = Rect
xs = xs + [tl[0], bl[0], br[0], tr[0], tl[0], np.nan]
ys = ys + [tl[1], bl[1], br[1], tr[1], tl[1], np.nan]
for x,y in self.leftClicks:
xs = xs + [x]
ys = ys + [y]
# if self.crosshair != None:
# xs = xs + [np.nan, 0, self.image.shape[1], np.nan, self.crosshair[0], self.crosshair[0], np.nan]
# ys = ys + [np.nan, self.crosshair[1], self.crosshair[1], np.nan, 0, self.image.shape[0], np.nan]
if len(xs) > 0 and len(ys) > 0:
if self.plotRect == None:
self.ax.hold(True)
self.plotRect, = self.ax.plot(xs, ys, 'b')
self.ax.hold(False)
self.ax.set_xlim([0,self.image.shape[1]])
self.ax.set_ylim([0,self.image.shape[0]])
self.ax.invert_yaxis()
else:
self.plotRect.set_data(xs, ys)
self.canvas.draw()