Skip to content

Commit 1fad16e

Browse files
committed
qt_vismach -improve panning when zoomed far away. change controls
make the controls align with qtvcp graphics widget Thanks to MarkoPolo from the forum for this patch!
1 parent 9bcf823 commit 1fad16e

1 file changed

Lines changed: 10 additions & 16 deletions

File tree

lib/python/qtvcp/lib/qt_vismach/qt_vismach.py

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ def __init__(self, parent=None):
9898

9999
self.plotdata = []
100100
self.plotColor = [1.0, 0.5, 0.5]
101-
self.plotlen = 16000
101+
self.plotlen = 64000
102102

103103
# Where we are centering.
104104
self.xcenter = 0.0
@@ -127,7 +127,7 @@ def __init__(self, parent=None):
127127
# add a 100ms timer to poll linuxcnc stats
128128
self.timer = QTimer()
129129
self.timer.timeout.connect(self.update)
130-
self.timer.start(100)
130+
self.timer.start(50)
131131

132132
def choosePlotColor(self, data):
133133
# by name
@@ -212,13 +212,13 @@ def setZoom(self, depth):
212212
self.update()
213213

214214
def zoomin(self):
215-
self.distance = self.distance / 1.1
215+
self.distance = self.distance / 1.2 - 20
216216
if self.distance < self.near:
217217
self.distance = self.near
218218
self.update()
219219

220220
def zoomout(self):
221-
self.distance = self.distance * 1.1
221+
self.distance = self.distance * 1.2 + 20
222222
if self.distance > self.far:
223223
self.distance = self.far
224224
self.update()
@@ -408,22 +408,15 @@ def mouseMoveEvent(self, event):
408408
dy = event.y() - self.lastPos.y()
409409

410410
if event.buttons() & Qt.LeftButton:
411-
self.setXRotation(self.xRot + 8 * dy)
412-
self.setYRotation(self.yRot - 8 * dx)
411+
scale = max(0.2, (self.distance ** 0.7) * 0.01)
412+
self.viewX -= dx * scale
413+
self.viewY += dy * scale
413414
elif event.buttons() & Qt.RightButton:
414415
self.setXRotation(self.xRot + 8 * dy)
415416
self.setZRotation(self.zRot + 8 * dx)
416417
else:
417-
# basic panning
418-
if dx > 0:
419-
self.viewX -=2
420-
elif dx < 0:
421-
self.viewX +=2
422-
if dy > 0:
423-
self.viewY +=2
424-
elif dy < 0:
425-
self.viewY -=2
426-
418+
self.setXRotation(self.xRot + 8 * dy)
419+
self.setYRotation(self.yRot - 8 * dx)
427420
self.lastPos = event.pos()
428421

429422
def mouseDoubleClickEvent(self, event):
@@ -476,3 +469,4 @@ def main(model, tool, work, size=10, hud=None, rotation_vectors=None, lat=0, lon
476469

477470
if __name__ == '__main__':
478471
print('This is a library file - it needs to be imported')
472+

0 commit comments

Comments
 (0)