本文整理汇总了Python中pyqtgraph.opengl.GLLinePlotItem方法的典型用法代码示例。如果您正苦于以下问题:Python opengl.GLLinePlotItem方法的具体用法?Python opengl.GLLinePlotItem怎么用?Python opengl.GLLinePlotItem使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyqtgraph.opengl
的用法示例。
在下文中一共展示了opengl.GLLinePlotItem方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from pyqtgraph import opengl [as 别名]
# 或者: from pyqtgraph.opengl import GLLinePlotItem [as 别名]
def __init__(self, input_video):
self.traces = dict()
self.app = QtGui.QApplication(sys.argv)
self.w = gl.GLViewWidget()
self.w.opts['distance'] = 45.0 ## distance of camera from center
self.w.opts['fov'] = 60 ## horizontal field of view in degrees
self.w.opts['elevation'] = 10 ## camera's angle of elevation in degrees 仰俯角
self.w.opts['azimuth'] = 90 ## camera's azimuthal angle in degrees 方位角
self.w.setWindowTitle('pyqtgraph example: GLLinePlotItem')
self.w.setGeometry(450, 700, 980, 700) # 原点在左上角
self.w.show()
# create the background grids
gx = gl.GLGridItem()
gx.rotate(90, 0, 1, 0)
gx.translate(-10, 0, 0)
self.w.addItem(gx)
gy = gl.GLGridItem()
gy.rotate(90, 1, 0, 0)
gy.translate(0, -10, 0)
self.w.addItem(gy)
gz = gl.GLGridItem()
gz.translate(0, 0, -10)
self.w.addItem(gz)
# special setting
self.cap = cv2.VideoCapture(input_video)
self.video_name = input_video.split('/')[-1].split('.')[0]
self.kpt2Ds = []
pos = pos_init
for j, j_parent in enumerate(common.skeleton_parents):
if j_parent == -1:
continue
x = np.array([pos[j, 0], pos[j_parent, 0]]) * 10
y = np.array([pos[j, 1], pos[j_parent, 1]]) * 10
z = np.array([pos[j, 2], pos[j_parent, 2]]) * 10 - 10
pos_total = np.vstack([x, y, z]).transpose()
self.traces[j] = gl.GLLinePlotItem(pos=pos_total, color=pg.glColor((j, 10)), width=6, antialias=True)
self.w.addItem(self.traces[j])
示例2: lines
# 需要导入模块: from pyqtgraph import opengl [as 别名]
# 或者: from pyqtgraph.opengl import GLLinePlotItem [as 别名]
def lines(self, name, lines, colors, alphas=1.0, width=1.0,
antialias=True):
if lines is None:
return
colors = _extend_color_if_necessary(colors, lines.shape[0], alphas)
if name not in self._named_items:
w_gl_item = gl.GLLinePlotItem(
pos=lines,
color=colors,
width=width,
antialias=antialias,
mode='lines')
self._named_items[name] = w_gl_item
self.addItem(w_gl_item)
else:
self._named_items[name].setData(
pos=lines,
color=colors,
width=width,
antialias=antialias,
mode='lines')
示例3: draw_3d_bboxlines_in_pyqt_v1
# 需要导入模块: from pyqtgraph import opengl [as 别名]
# 或者: from pyqtgraph.opengl import GLLinePlotItem [as 别名]
def draw_3d_bboxlines_in_pyqt_v1(widget,
bboxes,
colors=(0.0, 1.0, 0.0, 1.0),
width=1.0,
labels=None,
label_color='r'):
if not isinstance(colors, list):
colors = [colors for i in range(len(bboxes))]
if not isinstance(labels, list):
labels = [labels for i in range(len(bboxes))]
for box, facecolor, label in zip(bboxes, colors, labels):
lines = np.array([
box[0], box[1], box[1], box[2], box[2], box[3], box[3], box[0],
box[1], box[5], box[5], box[4], box[4], box[0], box[2], box[6],
box[6], box[7], box[7], box[3], box[5], box[6], box[4], box[7]
])
color = np.array([list(facecolor) for i in range(len(lines))])
plt = gl.GLLinePlotItem(
pos=lines, color=color, width=width, antialias=True, mode='lines')
widget.addItem(plt)
if label is not None:
label_color_qt = _pltcolor_to_qtcolor(label_color)
t = GLTextItem(
X=box[0, 0],
Y=box[0, 1],
Z=box[0, 2],
text=label,
color=label_color_qt)
t.setGLViewWidget(widget)
widget.addItem(t)
return widget
示例4: __init__
# 需要导入模块: from pyqtgraph import opengl [as 别名]
# 或者: from pyqtgraph.opengl import GLLinePlotItem [as 别名]
def __init__(self, skeletons_3d):
self.traces = dict()
self.app = QtGui.QApplication(sys.argv)
self.w = gl.GLViewWidget()
self.w.opts['distance'] = 45.0 ## distance of camera from center
self.w.opts['fov'] = 60 ## horizontal field of view in degrees
self.w.opts['elevation'] = 10 ## camera's angle of elevation in degrees 仰俯角
self.w.opts['azimuth'] = 90 ## camera's azimuthal angle in degrees 方位角
self.w.setWindowTitle('pyqtgraph example: GLLinePlotItem')
self.w.setGeometry(450, 700, 980, 700) # 原点在左上角
self.w.show()
# create the background grids
gx = gl.GLGridItem()
gx.rotate(90, 0, 1, 0)
gx.translate(-10, 0, 0)
self.w.addItem(gx)
gy = gl.GLGridItem()
gy.rotate(90, 1, 0, 0)
gy.translate(0, -10, 0)
self.w.addItem(gy)
gz = gl.GLGridItem()
gz.translate(0, 0, -10)
self.w.addItem(gz)
# special setting
pos = pos_init
self.skeleton_parents = common.skeleton_parents
self.skeletons_3d = skeletons_3d
for j, j_parent in enumerate(self.skeleton_parents):
if j_parent == -1:
continue
x = np.array([pos[j, 0], pos[j_parent, 0]]) * 10
y = np.array([pos[j, 1], pos[j_parent, 1]]) * 10
z = np.array([pos[j, 2], pos[j_parent, 2]]) * 10 - 10
pos_total = np.vstack([x, y, z]).transpose()
self.traces[j] = gl.GLLinePlotItem(pos=pos_total, color=pg.glColor((j, 10)), width=6, antialias=True)
self.w.addItem(self.traces[j])
示例5: _refresh_plot
# 需要导入模块: from pyqtgraph import opengl [as 别名]
# 或者: from pyqtgraph.opengl import GLLinePlotItem [as 别名]
def _refresh_plot(self):
import numpy as np
#import pyqtgraph as pg
from pyqtgraph import opengl as gl
self._create_grid()
pts = np.vstack([self.declaration.x,self.declaration.y,self.declaration.z]).transpose()
plt = gl.GLLinePlotItem(pos=pts)#, color=pg.glColor((i,n*1.3)), width=(i+1)/10., antialias=True)
self.widget.addItem(plt)
示例6: add_line
# 需要导入模块: from pyqtgraph import opengl [as 别名]
# 或者: from pyqtgraph.opengl import GLLinePlotItem [as 别名]
def add_line(self, p1, p2):
lines = np.array([[p1[0], p1[1], p1[2]], [p2[0], p2[1], p2[2]]])
lines_item = gl.GLLinePlotItem(
pos=lines, mode="lines", color=(1, 0, 0, 1), width=3, antialias=True
)
self.view.addItem(lines_item)
示例7: __drawSegment
# 需要导入模块: from pyqtgraph import opengl [as 别名]
# 或者: from pyqtgraph.opengl import GLLinePlotItem [as 别名]
def __drawSegment(self, segment):
# Update properties according to state
isVisible = True
if segment.isRemoved.atGivenStepAgo(Global.selStep) or (segment.type == SegmentType.proximal and self.menuShowProximalSegmentsNone.isChecked()) or (segment.type == SegmentType.distal and self.menuShowDistalSegmentsNone.isChecked()):
isVisible = False
else:
if segment.isFalselyPredicted.atGivenStepAgo(Global.selStep):
if segment.type == SegmentType.proximal and self.menuShowProximalSegmentsFalselyPredicted.isChecked():
color = self.colorSegmentFalselyPredicted
else:
isVisible = False
elif segment.isPredicted.atGivenStepAgo(Global.selStep):
if segment.type == SegmentType.proximal and self.menuShowProximalSegmentsPredicted.isChecked():
color = self.colorSegmentPredicted
else:
isVisible = False
elif segment.isActive.atGivenStepAgo(Global.selStep):
if (segment.type == SegmentType.proximal and self.menuShowProximalSegmentsActive.isChecked()) or (segment.type == SegmentType.distal and self.menuShowDistalSegmentsActive.isChecked()):
color = self.colorSegmentActive
else:
isVisible = False
else:
if segment.type == SegmentType.proximal:
color = self.colorInactive
else:
isVisible = False
if isVisible:
# Draw the segment
if not segment.tree3d_initialized:
pts = numpy.array([[segment.tree3d_x1, segment.tree3d_y1, segment.tree3d_z1], [segment.tree3d_x2, segment.tree3d_y2, segment.tree3d_z2]])
segment.tree3d_item = gl.GLLinePlotItem(pos=pts, width=1, antialias=False)
segment.tree3d_initialized = True
self.simulationViewer.addItem(segment.tree3d_item)
# Update the color
if segment.tree3d_selected:
color = self.colorSelected
segment.tree3d_item.color = pg.glColor(color)
else:
segment.tree3d_initialized = False
if segment.tree3d_item in self.simulationViewer.items:
self.simulationViewer.removeItem(segment.tree3d_item)
# Draw/update all synapses of this segment
for synapse in segment.synapses:
self.__drawSynapse(segment, synapse, isVisible)
示例8: __drawSynapse
# 需要导入模块: from pyqtgraph import opengl [as 别名]
# 或者: from pyqtgraph.opengl import GLLinePlotItem [as 别名]
def __drawSynapse(self, segment, synapse, segmentIsVisible):
# Update properties according to state
isVisible = True
if synapse.isRemoved.atGivenStepAgo(Global.selStep) or (not segment.isActive.atGivenStepAgo(Global.selStep) and not segment.isPredicted.atGivenStepAgo(Global.selStep) and not segment.isFalselyPredicted.atGivenStepAgo(Global.selStep)) or (segment.type == SegmentType.proximal and self.menuShowProximalSynapsesNone.isChecked()) or (segment.type == SegmentType.distal and self.menuShowDistalSynapsesNone.isChecked()):
isVisible = False
else:
if synapse.isFalselyPredicted.atGivenStepAgo(Global.selStep):
if (segment.type == SegmentType.proximal and self.menuShowProximalSynapsesFalselyPredicted.isChecked()):
color = self.colorSynapseFalselyPredicted
else:
isVisible = False
elif synapse.isPredicted.atGivenStepAgo(Global.selStep):
if (segment.type == SegmentType.proximal and self.menuShowProximalSynapsesPredicted.isChecked()):
color = self.colorSynapsePredicted
else:
isVisible = False
elif synapse.isConnected.atGivenStepAgo(Global.selStep):
if (segment.type == SegmentType.proximal and self.menuShowProximalSynapsesConnected.isChecked()) or (segment.type == SegmentType.distal and self.menuShowDistalSynapsesConnected.isChecked()):
color = self.colorSynapseConnected
else:
isVisible = False
else:
if (segment.type == SegmentType.proximal and self.menuShowProximalSynapsesActive.isChecked()) or (segment.type == SegmentType.distal and self.menuShowDistalSynapsesActive.isChecked()):
color = self.colorInactive
else:
isVisible = False
if isVisible and segmentIsVisible:
# Draw the synapse
if not synapse.tree3d_initialized:
pts = numpy.array([[segment.tree3d_x2, segment.tree3d_y2, segment.tree3d_z2], [synapse.inputElem.tree3d_x, synapse.inputElem.tree3d_y, synapse.inputElem.tree3d_z]])
synapse.tree3d_item = gl.GLLinePlotItem(pos=pts, width=1, antialias=False)
synapse.tree3d_initialized = True
self.simulationViewer.addItem(synapse.tree3d_item)
# Update the color
if synapse.tree3d_selected:
color = self.colorSelected
synapse.tree3d_item.color = pg.glColor(color)
else:
synapse.tree3d_initialized = False
if synapse.tree3d_item in self.simulationViewer.items:
self.simulationViewer.removeItem(synapse.tree3d_item)
示例9: draw_bboxlines_in_pyqt
# 需要导入模块: from pyqtgraph import opengl [as 别名]
# 或者: from pyqtgraph.opengl import GLLinePlotItem [as 别名]
def draw_bboxlines_in_pyqt(widget,
bboxes,
colors=GLColor.Green,
width=1.0,
labels=None,
alpha=1.0,
label_color='r',
line_item=None,
label_item=None):
if bboxes.shape[0] == 0:
return
if not isinstance(colors, list):
if isinstance(colors, GLColor):
colors = gl_color(colors, alpha)
colors = [colors for i in range(len(bboxes))]
if not isinstance(labels, list):
labels = [labels for i in range(len(bboxes))]
total_lines = []
total_colors = []
for box, facecolor in zip(bboxes, colors):
lines = np.array(
[box[0], box[1], box[1], box[2], box[2], box[3], box[3], box[0]])
total_lines.append(lines)
color = np.array([list(facecolor) for i in range(len(lines))])
total_colors.append(color)
total_lines = np.concatenate(total_lines, axis=0)
total_colors = np.concatenate(total_colors, axis=0)
if line_item is None:
line_item = gl.GLLinePlotItem(
pos=total_lines,
color=total_colors,
width=width,
antialias=True,
mode='lines')
widget.addItem(line_item)
else:
line_item.setData(
pos=total_lines,
color=total_colors,
width=width,
antialias=True,
mode='lines')
label_color_qt = _pltcolor_to_qtcolor(label_color)
if labels is not None:
if label_item is None:
label_item = GLLabelItem(bboxes[:, 0, :], labels, label_color_qt)
label_item.setGLViewWidget(widget)
widget.addItem(label_item)
else:
label_item.setData(
pos=bboxes[:, 0, :], text=labels, color=label_color_qt)
return line_item, label_item
示例10: _qtg_plot_graph
# 需要导入模块: from pyqtgraph import opengl [as 别名]
# 或者: from pyqtgraph.opengl import GLLinePlotItem [as 别名]
def _qtg_plot_graph(G, edges, vertex_size, title):
qtg, gl, QtGui = _import_qtg()
if G.coords.shape[1] == 2:
window = qtg.GraphicsWindow()
window.setWindowTitle(title)
view = window.addViewBox()
view.setAspectLocked()
if edges:
pen = tuple(np.array(G.plotting['edge_color']) * 255)
else:
pen = None
adj = _get_coords(G, edge_list=True)
g = qtg.GraphItem(pos=G.coords, adj=adj, pen=pen,
size=vertex_size/10)
view.addItem(g)
global _qtg_windows
_qtg_windows.append(window)
elif G.coords.shape[1] == 3:
if not QtGui.QApplication.instance():
QtGui.QApplication([]) # We want only one application.
widget = gl.GLViewWidget()
widget.opts['distance'] = 10
widget.show()
widget.setWindowTitle(title)
if edges:
x, y, z = _get_coords(G)
pos = np.stack((x, y, z), axis=1)
g = gl.GLLinePlotItem(pos=pos, mode='lines',
color=G.plotting['edge_color'])
widget.addItem(g)
gp = gl.GLScatterPlotItem(pos=G.coords, size=vertex_size/3,
color=G.plotting['vertex_color'])
widget.addItem(gp)
global _qtg_widgets
_qtg_widgets.append(widget)
示例11: _qtg_plot_signal
# 需要导入模块: from pyqtgraph import opengl [as 别名]
# 或者: from pyqtgraph.opengl import GLLinePlotItem [as 别名]
def _qtg_plot_signal(G, signal, edges, vertex_size, limits, title):
qtg, gl, QtGui = _import_qtg()
if G.coords.shape[1] == 2:
window = qtg.GraphicsWindow(title)
view = window.addViewBox()
elif G.coords.shape[1] == 3:
if not QtGui.QApplication.instance():
QtGui.QApplication([]) # We want only one application.
widget = gl.GLViewWidget()
widget.opts['distance'] = 10
widget.show()
widget.setWindowTitle(title)
if edges:
if G.coords.shape[1] == 2:
adj = _get_coords(G, edge_list=True)
pen = tuple(np.array(G.plotting['edge_color']) * 255)
g = qtg.GraphItem(pos=G.coords, adj=adj, symbolBrush=None,
symbolPen=None, pen=pen)
view.addItem(g)
elif G.coords.shape[1] == 3:
x, y, z = _get_coords(G)
pos = np.stack((x, y, z), axis=1)
g = gl.GLLinePlotItem(pos=pos, mode='lines',
color=G.plotting['edge_color'])
widget.addItem(g)
pos = [1, 8, 24, 40, 56, 64]
color = np.array([[0, 0, 143, 255], [0, 0, 255, 255], [0, 255, 255, 255],
[255, 255, 0, 255], [255, 0, 0, 255], [128, 0, 0, 255]])
cmap = qtg.ColorMap(pos, color)
signal = 1 + 63 * (signal - limits[0]) / limits[1] - limits[0]
if G.coords.shape[1] == 2:
gp = qtg.ScatterPlotItem(G.coords[:, 0],
G.coords[:, 1],
size=vertex_size/10,
brush=cmap.map(signal, 'qcolor'))
view.addItem(gp)
if G.coords.shape[1] == 3:
gp = gl.GLScatterPlotItem(pos=G.coords,
size=vertex_size/3,
color=cmap.map(signal, 'float'))
widget.addItem(gp)
if G.coords.shape[1] == 2:
global _qtg_windows
_qtg_windows.append(window)
elif G.coords.shape[1] == 3:
global _qtg_widgets
_qtg_widgets.append(widget)