optimize view iteractions
This commit is contained in:
24
swissmx.py
24
swissmx.py
@@ -85,7 +85,7 @@ ts.log('Import part 3/8:')
|
||||
import qtawesome
|
||||
import qutilities
|
||||
from PyQt5 import QtCore, QtGui
|
||||
from PyQt5.QtCore import Qt, pyqtSlot, QSize, QRegExp, pyqtSignal, QObject, QThread
|
||||
from PyQt5.QtCore import Qt, pyqtSlot, QSize, QRegExp, pyqtSignal, QObject, QThread, QRectF
|
||||
from PyQt5.QtGui import QKeySequence, QPixmap, QRegExpValidator, QFont
|
||||
from PyQt5.QtWidgets import (
|
||||
QAction, QApplication, QDoubleSpinBox, QFileDialog, QFormLayout, QGridLayout, QGroupBox, QHBoxLayout, QLabel, QLineEdit,
|
||||
@@ -388,8 +388,12 @@ class WndSwissMx(QMainWindow, Ui_MainWindow):
|
||||
self.glw.scene().sigMouseClicked.connect(self.cb_mouse_click)
|
||||
|
||||
#--- viewbox ---
|
||||
#self.vb=vb=self.glw.addViewBox(invertY=False,border='r',enableMenu=False)
|
||||
self.vb=vb=self.glw.addViewBox(invertY=False,border='r',enableMenu=False)
|
||||
self.vb=vb=self.glw.addViewBox(invertY=False,border='r',enableMenu=True)
|
||||
#TODO: vb.enableAutoRange(enable=True), vb.autoRange() does not work for ItemGroups
|
||||
#therefore set the vieweRange manually
|
||||
pad=10
|
||||
vb.setRange(QRectF(-1200-pad,-1000-pad,1200+2*pad,1000+2*pad))
|
||||
|
||||
vb.setAspectLocked(True)
|
||||
vb.setBackgroundColor((120, 90, 90))
|
||||
|
||||
@@ -728,6 +732,7 @@ class WndSwissMx(QMainWindow, Ui_MainWindow):
|
||||
app=QApplication.instance()
|
||||
cam=app._camera
|
||||
self._goImg.setImage(cam._pic)
|
||||
#vb.setRange(QRectF(-1300,-1100,1400,1200))
|
||||
|
||||
def cb_new_frame_sim(self, **kwargs):
|
||||
app=QApplication.instance()
|
||||
@@ -1122,6 +1127,14 @@ class WndSwissMx(QMainWindow, Ui_MainWindow):
|
||||
fy_motor.move_rel(pFix[1])
|
||||
#fx_motor.move_abs(fx_motor.get_val()+pFix[0])
|
||||
#fy_motor.move_abs(fy_motor.get_val()+pFix[1])
|
||||
|
||||
#if none of the image is visible, recenter it
|
||||
r1=self.vb.viewRect()
|
||||
#r2=self.vb.itemBoundingRect(self._goImg)
|
||||
r2=self.vb.itemBoundingRect(self._goBeamMarker)
|
||||
if not r1.intersects(r2):
|
||||
self.vb.autoRange(items=(self._goImg,))
|
||||
|
||||
try:
|
||||
pln=geo._fitPlane
|
||||
except AttributeError: pass
|
||||
@@ -1540,6 +1553,8 @@ class WndSwissMx(QMainWindow, Ui_MainWindow):
|
||||
self._testCode=tc={'idx':0}
|
||||
step=tc['idx']
|
||||
vb=self.vb
|
||||
vb.autoRange(items=(self._goImg,))
|
||||
return
|
||||
|
||||
if step==0:
|
||||
grp=pg.ItemGroup()
|
||||
@@ -1551,6 +1566,7 @@ class WndSwissMx(QMainWindow, Ui_MainWindow):
|
||||
obj=UsrGO.Marker((200, 100), (100, 100), mode=1)
|
||||
grp.addItem(obj)
|
||||
tc['grp']=grp
|
||||
vb.autoRange(items=(obj,))
|
||||
elif step==1:
|
||||
grp=tc['grp']
|
||||
tr=grp.transform()
|
||||
@@ -1901,7 +1917,7 @@ class WndSwissMx(QMainWindow, Ui_MainWindow):
|
||||
grp=self._goTracked
|
||||
for go in grp.childItems():
|
||||
vb.removeItem(go)
|
||||
#grp.clear()
|
||||
grp.setFlag(grp.ItemHasNoContents)
|
||||
mft._tree.setData(None)
|
||||
|
||||
def module_fix_target_fit_fiducial(self):
|
||||
|
||||
Reference in New Issue
Block a user