Когда я обновляю вершины gl.GLMeshItem (), используя его метод .setMeshData (), я теряю память каждый раз, когда он обновляется.Вы можете уменьшить n_tri
ниже для менее серьезного примера;)
(Python 3.5, Qt 5.6.2, pyqtgraph 0.10.0)
Любые идеи, которые вызывают это, и если естьОбходной путь или исправление?
Рабочий пример:
# -*- coding: utf-8 -*-
from pyqtgraph.Qt import QtGui, QtCore
import numpy as np
import pyqtgraph as pg
import pyqtgraph.opengl as gl
app = QtGui.QApplication([])
mw = QtGui.QMainWindow()
mw.setWindowTitle('pyqtgraph example: PlotWidget')
mw.resize(800,800)
cw = QtGui.QWidget()
mw.setCentralWidget(cw)
l = QtGui.QGridLayout()
#l.setRowMinimumHeight(0, 400)
cw.setLayout(l)
w = gl.GLViewWidget()
w.setBackgroundColor(0.9)
w.setCameraPosition(distance=3)
l.addWidget(w, 0, 0, 1, 1)
sp = w.sizePolicy()
w.setSizePolicy(QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding))
mw.show()
n_tri = 100000
vertices = np.random.uniform(size=(n_tri, 3, 3)).reshape((-1, 3))
indices = np.arange(vertices.shape[0]).reshape((-1, 3))
colors = np.random.uniform(size=(vertices.shape[0], 3))
m1 = gl.GLMeshItem(vertexes=vertices, faces=indices, vertexColors=colors, smooth=False,
drawEdges=False, drawFaces=True, edgeColor=(0, 1, 0, 1))
w.addItem(m1)
def update():
vertices = np.random.uniform(size=(n_tri, 3, 3)).reshape((-1, 3))
m1.setMeshData(vertexes=vertices, faces=indices, vertexColors=colors, smooth=False,
drawEdges=False, drawFaces=True, edgeColor=(0, 1, 0, 1))
t2 = QtCore.QTimer()
t2.timeout.connect(update)
t2.start(250)
if __name__ == '__main__':
import sys
if (sys.flags.interactive != 1) or not hasattr(QtCore, 'PYQT_VERSION'):
QtGui.QApplication.instance().exec_()