加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
interactbackup.py 3.84 KB
一键复制 编辑 原始数据 按行查看 历史
lbllyl 提交于 2021-09-24 15:35 . lyl
import pyqtgraph as pg
from pyqtgraph import functions as fn
from pyqtgraph.Qt import QtCore, QtGui
from pyqtgraph.graphicsItems.ROI import MouseDragHandler
import pyqtgraph.opengl as gl
import numpy as np
import pynput
import time
from datetime import datetime
import pyqtgraph.console
from mpl_toolkits.mplot3d import axes3d
import matplotlib as plt
from OpenGL.GL import *
from pyqtgraph.opengl.GLGraphicsItem import GLGraphicsItem
from pyqtgraph import QtGui
app = pg.mkQApp("GLScatterPlotItem Example")
w = gl.GLViewWidget()
w.opts['distance'] = 20
w.show()
w.setWindowTitle('pyqtgraph example: GLScatterPlotItem')
g = gl.GLGridItem()
w.addItem(g)
'''
for i in range label:
if label==num[i]:
def update(x,y,z):
## update surface positions and colors
global velocity, sp3, distance
velocity -= 0.1
#track equation
x = -np.cos(distance*3+velocity)
y = -np.sin(distance*4+velocity)
z = -np.cos(distance*2+velocity)
#z = d3*2+velocity
#z = d3*2+velocity
#z = d3*2+velocity
#z = d3*2+velocity
#z = d3*2+velocity
#z = d3*3+velocity
pos[:,0] = x
pos[:,1] = y
pos[:,2] = z
sp3.setData(pos=pos), #color=color)
t = QtCore.QTimer()
t.timeout.connect(update)
t.start(50)
else:
def update():
## update surface positions and colors
global velocity, sp3, distance
velocity -= 0.1
#track equation
x = -np.cos(distance*3+velocity)
y = -np.sin(distance*4+velocity)
z = -np.cos(distance*2+velocity)
#z = d3*2+velocity
#z = d3*2+velocity
#z = d3*2+velocity
#z = d3*2+velocity
#z = d3*2+velocity
#z = d3*3+velocity
pos[:,0] = x
pos[:,1] = y
pos[:,2] = z
sp3.setData(pos=pos), #color=color)
t = QtCore.QTimer()
t.timeout.connect(update)
t.start(50)
'''
velocity = 0.
pos = np.empty((53, 3))
size = np.empty((53))
pos[0] = [1, 0, 0]; size[0] = 0.25;
pos[1] = [0, 1, 0]; size[1] = 0.25;
pos[2] = [0, 0, 1]; size[2] = 0.25;
pos[3] = [1, 1, 0]; size[3] = 0.25;
pos[4] = [1, 0, 1]; size[4] = 0.25;
pos[5] = [0, 1, 1]; size[5] = 0.25;
pos[6] = [1, 1, 1]; size[6] = 0.25;
pos[7] = [0, 0, 0]; size[7] = 0.25;
distance = (pos**2).sum(axis=1)**0.5
''''''
sp3 = gl.GLScatterPlotItem(pos=pos, color=(1,1,1,.3), size=0.1, pxMode=False)
w.addItem(sp3)
#raise brightness
w.addItem(sp3)
def update():
## update surface positions and colors
global velocity, sp3, distance
velocity -= 0.1
#track equation
x = -np.cos(distance*3+velocity)
y = -np.sin(distance*4+velocity)
z = -np.cos(distance*2+velocity)
#z = d3*2+velocity
#z = d3*2+velocity
#z = d3*2+velocity
#z = d3*2+velocity
#z = d3*2+velocity
#z = d3*3+velocity
pos[:,0] = x
pos[:,1] = y
pos[:,2] = z
'''
color = np.empty((len(d3),4), dtype=np.float32)
color[:,3] = 0.3
color[:,0] = np.clip(z * 3.0, 0, 1)
color[:,1] = np.clip(z * 1.0, 0, 1)
color[:,2] = np.clip(z ** 3, 0, 1)
'''
sp3.setData(pos=pos), #color=color)
t = QtCore.QTimer()
t.timeout.connect(update)
t.start(50)
#with pynput.mouse.Events() as event:
# for i in event:
# if isinstance(i,pynput.mouse.Events.Click):
# print()
#console
'''
app = pg.mkQApp()
namespace = {'pg': pg, 'np': np}
text = """An interactive python console has successfully runned. Please input your order."""
c = pyqtgraph.console.ConsoleWidget(namespace=namespace, text=text)
c.show()
c.setWindowTitle('pyqtgraph example: ConsoleWidget')
'''
if __name__ == '__main__':
pg.exec()
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化