gpt4 book ai didi

python - 如何在pyqtgraph中设置绘制距离?

转载 作者:行者123 更新时间:2023-12-01 09:31:46 25 4
gpt4 key购买 nike

我的 GLViewWidget 中有许多 GLMeshItem,这使得我在平移或缩放时绘图速度非常慢。

有没有办法限制pyqtgraph中的绘制距离?

最佳答案

我自己发现了,在GLViewWidget.projectionMatrix()中有一个局部变量farClip:

def projectionMatrix(self, region=None):
if region is None:
region = (0, 0, self.width(), self.height())

x0, y0, w, h = self.getViewport()
dist = self.opts['distance']
fov = self.opts['fov']
nearClip = dist * 0.001
farClip = dist * 1000.

r = nearClip * np.tan(fov * 0.5 * np.pi / 180.)
t = r * h / w

left = r * ((region[0]-x0) * (2.0/w) - 1)
right = r * ((region[0]+region[2]-x0) * (2.0/w) - 1)
bottom = t * ((region[1]-y0) * (2.0/h) - 1)
top = t * ((region[1]+region[3]-y0) * (2.0/h) - 1)

tr = QtGui.QMatrix4x4()
tr.frustum(left, right, bottom, top, nearClip, farClip)
return tr

所以答案是继承GLViewWidget并更改farClip:

class MyView(GLViewWidget):
def __init__(self):
super().__init__()

def projectionMatrix(self, region=None):
...
farClip = 42.
...

关于python - 如何在pyqtgraph中设置绘制距离?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49901555/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com