本文整理汇总了Python中guiqwt.plot.PlotManager.get_default_tool方法的典型用法代码示例。如果您正苦于以下问题:Python PlotManager.get_default_tool方法的具体用法?Python PlotManager.get_default_tool怎么用?Python PlotManager.get_default_tool使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类guiqwt.plot.PlotManager
的用法示例。
在下文中一共展示了PlotManager.get_default_tool方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Plot_Start_New
# 需要导入模块: from guiqwt.plot import PlotManager [as 别名]
# 或者: from guiqwt.plot.PlotManager import get_default_tool [as 别名]
def Plot_Start_New(widget,PLOT_DEFINE,COLORS,x1,x2,y1,y2):
newmanager = PlotManager(widget)
newplots = []
newcurves = {}
for name in PLOT_DEFINE:
plot = CurvePlot()
#设置图表颜色
plot.setStyleSheet('''QWidget{
border: 1px solid #32435E;
border-radius: 3px;
font-size:11pt;
color:white;
font-family:"Microsoft YaHei UI";
/* padding: 0 8px; */
background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,
stop: 0 #080B10,
stop: 1.0 #212C3F);
selection-background-color: #0A246A;
} '''
)
plot.axisScaleDraw(CurvePlot.Y_LEFT).setMinimumExtent(20)
newplots.append(plot)
newmanager.add_plot(plot)
plot.plot_id = id(plot)
for curve_color, curve_name in map(None,COLORS,name):
if u"状态" in curve_name or u"打角/100" in curve_name :
newcurves[curve_name] = guiqwt_make.curve([0], [0],markerfacecolor = 'black', markeredgecolor=curve_color, title=curve_name,marker = 'Diamond',linestyle = 'NoPen',markersize = 6)
else:
newcurves[curve_name] = guiqwt_make.curve([0], [0], color=curve_color, title=curve_name)
plot.add_item(newcurves[curve_name])
#设置X轴y轴
plot.set_axis_limits(newcurves[curve_name].yAxis(),y1,y2)
plot.set_axis_limits(newcurves[curve_name].xAxis(),x1,x2)
plot.add_item(guiqwt_make.legend("BL"))
newmanager.register_standard_tools()
newmanager.get_default_tool().activate()
return (newmanager,newplots,newcurves)
示例2: Window
# 需要导入模块: from guiqwt.plot import PlotManager [as 别名]
# 或者: from guiqwt.plot.PlotManager import get_default_tool [as 别名]
class Window(QMainWindow):
def __init__(self, wintitle):
super(Window, self).__init__()
self.default_tool = None
self.plots = []
self.itemlist = PlotItemList(None)
self.contrast = ContrastAdjustment(None)
self.xcsw = XCrossSection(None)
self.ycsw = YCrossSection(None)
self.manager = PlotManager(self)
self.toolbar = QToolBar(_("Tools"), self)
self.manager.add_toolbar(self.toolbar, "default")
self.toolbar.setMovable(True)
self.toolbar.setFloatable(True)
self.addToolBar(Qt.TopToolBarArea, self.toolbar)
frame = QFrame(self)
self.setCentralWidget(frame)
self.layout = QGridLayout()
layout = QVBoxLayout(frame)
frame.setLayout(layout)
layout.addLayout(self.layout)
self.frame = frame
self.setWindowTitle(wintitle)
self.setWindowIcon(get_icon('guiqwt.svg'))
def closeEvent(self, event):
global _figures, _current_fig, _current_axes
figure_title = to_text_string(self.windowTitle())
if _figures.pop(figure_title) == _current_fig:
_current_fig = None
_current_axes = None
self.itemlist.close()
self.contrast.close()
self.xcsw.close()
self.ycsw.close()
event.accept()
def add_plot(self, i, j, plot):
self.layout.addWidget(plot, i, j)
self.manager.add_plot(plot)
self.plots.append(plot)
def replot(self):
for plot in self.plots:
plot.replot()
item = plot.get_default_item()
if item is not None:
plot.set_active_item(item)
item.unselect()
def add_panels(self, images=False):
self.manager.add_panel(self.itemlist)
if images:
for panel in (self.ycsw, self.xcsw, self.contrast):
panel.hide()
self.manager.add_panel(panel)
def register_tools(self, images=False):
if images:
self.manager.register_all_image_tools()
else:
self.manager.register_all_curve_tools()
def display(self):
self.show()
self.replot()
self.manager.get_default_tool().activate()
self.manager.update_tools_status()
示例3: RealtimeDemo
# 需要导入模块: from guiqwt.plot import PlotManager [as 别名]
# 或者: from guiqwt.plot.PlotManager import get_default_tool [as 别名]
class RealtimeDemo(QWidget):
def __init__(self):
super(RealtimeDemo, self).__init__()
self.setWindowTitle(u"Realtime Demo")
self.data = {u"t": array("d")}
for name in sum(PLOT_DEFINE, []):
self.data[name] = array("d")
self.curves = {}
self.t = 0
vbox = QVBoxLayout()
vbox.addWidget(self.setup_toolbar())
self.manager = PlotManager(self)
self.plots = []
for i, define in enumerate(PLOT_DEFINE):
plot = CurvePlot()
plot.axisScaleDraw(CurvePlot.Y_LEFT).setMinimumExtent(60)
self.manager.add_plot(plot)
self.plots.append(plot)
plot.plot_id = id(plot)
for j, curve_name in enumerate(define):
curve = self.curves[curve_name] = make.curve([0], [0], color=COLORS[j], title=curve_name)
plot.add_item(curve)
plot.add_item(make.legend("BL"))
vbox.addWidget(plot)
self.manager.register_standard_tools()
self.manager.get_default_tool().activate()
self.manager.synchronize_axis(CurvePlot.X_BOTTOM, self.manager.plots.keys())
self.setLayout(vbox)
self.startTimer(100)
def setup_toolbar(self):
toolbar = QToolBar()
self.auto_yrange_checkbox = QCheckBox(u"Y轴自动调节")
self.auto_xrange_checkbox = QCheckBox(u"X轴自动调节")
self.xrange_box = QSpinBox()
self.xrange_box.setMinimum(5)
self.xrange_box.setMaximum(50)
self.xrange_box.setValue(10)
self.auto_xrange_checkbox.setChecked(True)
self.auto_yrange_checkbox.setChecked(True)
toolbar.addWidget(self.auto_yrange_checkbox)
toolbar.addWidget(self.auto_xrange_checkbox)
toolbar.addWidget(self.xrange_box)
return toolbar
def timerEvent(self, event):
for i in xrange(100):
t = self.t
self.data[u"t"].append(t)
self.data[u"sin1f"].append(sin(t))
self.data[u"cos1f"].append(cos(t))
self.data[u"sin3f"].append(sin(3*t)/6)
self.data[u"cos3f"].append(cos(3*t)/6)
self.data[u"sin合成"].append(sin(t)+sin(3*t)/6)
self.data[u"cos合成"].append(cos(t)+cos(3*t)/6)
self.t += DT
if self.auto_xrange_checkbox.isChecked():
xmax = self.data["t"][-1]
xmin = max(xmax - self.xrange_box.value(), 0)
else:
xmin, xmax = self.plots[0].get_axis_limits('bottom')
for key, curve in self.curves.iteritems():
xdata = self.data["t"]
ydata = self.data[key]
x, y = get_peak_data(xdata, ydata, xmin, xmax, 600, 1/DT)
curve.set_data(x, y)
for plot in self.plots:
if self.auto_yrange_checkbox.isChecked() and self.auto_xrange_checkbox.isChecked():
plot.do_autoscale()
elif self.auto_xrange_checkbox.isChecked():
plot.set_axis_limits("bottom", xmin, xmax)
plot.replot()
else:
plot.replot()
示例4: PlottingHelper
# 需要导入模块: from guiqwt.plot import PlotManager [as 别名]
# 或者: from guiqwt.plot.PlotManager import get_default_tool [as 别名]
class PlottingHelper(object):
'''This is the class implementing the plotting work.'''
def __init__(self, parent, signal_names, sample_rate):
'''Do the initialization work.
A PlottingHelper object helps plotting a group of signals all of which
has the same number of points to plot at one time.
signal_names:
a dictionary {'list_name':['list of signal names']}
sample_rate:
the sample_rate of the signals
'''
self.sample_rate = sample_rate
self.signal_names = signal_names
self.curve_items = {}
self.curve_plots = {}
self.plot_manager = PlotManager(parent)
for list_name, sig_name_list in self.signal_names.items():
# One CurvePlot object for every sig_name_list
curve_plot = CurvePlot()
curve_plot.axisScaleDraw(CurvePlot.Y_LEFT).setMinimumExtent(10)
self.curve_plots[list_name] = curve_plot
curve_plot.plot_id = id(curve_plot)
for i, sig_name in enumerate(sig_name_list):
# One CurveItem object for every signal_name
print sig_name, colors[i]
self.curve_items[sig_name] = make.curve([0], [0], \
color=colors[i], title=sig_name)
curve_plot.add_item(self.curve_items[sig_name])
# add the curve_plot object to plot_manager
self.plot_manager.add_plot(curve_plot)
# register and activate the tools
self.plot_manager.register_standard_tools()
self.plot_manager.get_default_tool().activate()
self.plot_manager.synchronize_axis(CurvePlot.X_BOTTOM, \
self.plot_manager.plots.keys())
def update_curves(self, time, signals, interval_in_second):
'''update the curves everytime the signals change
time:
the time sequence, which is also the x_axis data
signal:
a dictionary of signals to plot, the keys of which is recorded
in self.signal_names.
and in fact these are the y_axis data
'''
xmax = time[-1]
xmin = max(xmax - interval_in_second, 0)
xdata = time
for list_name, sig_name_list in self.signal_names.items():
#
for i, sig_name in enumerate(sig_name_list):
#
ydata = signals[sig_name]
idxmn = int(xmin*self.sample_rate)
idxmx = int(xmax*self.sample_rate)
self.curve_items[sig_name].set_data(xdata[idxmn:idxmx], \
ydata[idxmn:idxmx])
self.curve_plots[list_name].do_autoscale()
示例5: SyncXAxis
# 需要导入模块: from guiqwt.plot import PlotManager [as 别名]
# 或者: from guiqwt.plot.PlotManager import get_default_tool [as 别名]
class SyncXAxis(QtGui.QWidget):
def __init__(self):
super(SyncXAxis, self).__init__()
self.data = {u"t":array("d")}
for name in sum(PLOT_DEFINE, []):
self.data[name] = array("d")
self.i = 0
self.x = []
self.curves = {}
self.t = 0
self.sint = []
self.get_Roll = []
self.get_Pitch = []
self.get_Yaw = []
self.get_Angle1 = []
self.get_Angle2 =[]
self.get_Angle3 = []
vbox = QtGui.QGridLayout()
#工具栏
vbox.addLayout(self.setup_toolbar(),0,0)
self.manager = PlotManager(self)
self.plots = []
#生成竖直排列图形窗口
for i, define in enumerate(PLOT_DEFINE):
plot = CurvePlot()
plot.axisScaleDraw(CurvePlot.Y_LEFT).setMinimumExtent(60)
self.manager.add_plot(plot)
self.plots.append(plot)
plot.plot_id = id(plot)
for j, curve_name in enumerate(define):
curve = self.curves[curve_name] = make.curve([0], [0], color=COLORS[j], title=curve_name)
plot.add_item(curve)
plot.add_item(make.legend("BL"))
#vbox.addWidget(plot)
vbox.addWidget(self.plots[0],1,0)
vbox.addWidget(self.plots[1],1,1)
vbox.addWidget(self.plots[2],2,0)
vbox.addWidget(self.plots[3],2,1)
self.manager.register_standard_tools()
self.manager.get_default_tool().activate()
self.manager.synchronize_axis(CurvePlot.X_BOTTOM, self.manager.plots.keys())
self.setLayout(vbox)
self.startTimer(20)
def setup_toolbar(self):
toolbar = QtGui.QGridLayout()
self.auto_xrange_checkbox = QtGui.QCheckBox(u"X轴自动调节")
self.xrange_box = QtGui.QSpinBox()
self.xrange_box.setMinimum(5)
self.xrange_box.setMaximum(100)
self.xrange_box.setValue(50)
self.auto_xrange_checkbox.setChecked(True)
self.Roll_label = QtGui.QLabel("PID KP:")
self.lineEdit1 = QtGui.QLineEdit()
self.lineEdit1.setText("1")
self.lineEdit1.returnPressed.connect(self.PID_Roll)
self.Roll_label.setBuddy(self.lineEdit1)
self.Pitch_label = QtGui.QLabel("PID KI:")
self.lineEdit2 = QtGui.QLineEdit()
self.Pitch_label.setBuddy(self.lineEdit2)
self.lineEdit2.setText("1")
self.lineEdit2.returnPressed.connect(self.PID_Pitch)
self.Yaw_label = QtGui.QLabel("PID KD:")
self.lineEdit3 = QtGui.QLineEdit()
self.Yaw_label.setBuddy(self.lineEdit3)
self.lineEdit3.setText("1")
self.lineEdit3.returnPressed.connect(self.PID_Yaw)
toolbar.addWidget(self.auto_xrange_checkbox,0,0)
toolbar.addWidget(self.xrange_box,0,1)
toolbar.addWidget(self.Roll_label,1,0)
toolbar.addWidget(self.lineEdit1,1,1)
toolbar.addWidget(self.Pitch_label,2,0)
toolbar.addWidget(self.lineEdit2,2,1)
toolbar.addWidget(self.Yaw_label,3,0)
toolbar.addWidget(self.lineEdit3,3,1)
return toolbar
def PID_Roll(self):
global RPY_Array
try:
#print str(int(self.lineEdit1.text()))
RPY_Array[0] = int(self.lineEdit1.text())
except:
pass
def PID_Pitch(self):
global RPY_Array
try:
#print str(self.lineEdit1.text())
RPY_Array[1] = int(self.lineEdit2.text())
#.........这里部分代码省略.........