rework graphic opbect and coordinate transformation

This commit is contained in:
2022-09-06 10:07:11 +02:00
parent d263c09028
commit cbae02c597
4 changed files with 121 additions and 77 deletions

View File

@@ -394,14 +394,29 @@ class WndSwissMx(QMainWindow, Ui_MainWindow):
tr=QtGui.QTransform() # prepare ImageItem transformation:
opt_ctr=app._geometry._opt_ctr
#--- image group ---
# uses image transformation
# contains image and opticalcenter
self._goImgGrp=grp=pg.ItemGroup()
self.vb.addItem(grp)
trf=cfg.value(AppCfg.GEO_CAM_TRF)
# be aware: setTransform is transposed!
# Qt uses: p'=(p.T*A.T).T , but I am used: p'=A*p, with p=[x,y,1].T
tr.setMatrix(trf[0,0],trf[1,0],trf[2,0], #(-1, 0, 0,
trf[0,1],trf[1,1],trf[2,1], # 0,-1, 0,
trf[0,2],trf[1,2],trf[2,2]) # 0, 0, 1)
grp.setTransform(tr) # assign transform
#--- image ---
self._goImg=img=pg.ImageItem()
tr.setMatrix(-1, 0, 0,
0,-1, 0,
0, 0, 1)
# opt_ctr[0], opt_ctr[1], 1)
img.setTransform(tr) # assign transform
vb.addItem(img)
grp.addItem(img)
#--- opctical center ----
oc_sz=np.array((50,50))
#self._goOptCtr=obj=UsrGO.Marker(-opt_ctr+oc_sz/2, oc_sz,mode=1)
self._goOptCtr=obj=UsrGO.Marker(opt_ctr-oc_sz/2, oc_sz,mode=1)
obj.sigRegionChangeFinished.connect(self.cb_marker_moved)
grp.addItem(obj)
#--- grid ---
try:
@@ -412,16 +427,10 @@ class WndSwissMx(QMainWindow, Ui_MainWindow):
self._goGrid=grid=pg.GridItem() # green grid and labels
grid.opts['pen']=QPen(QColor(0, 255, 0))
grid.opts['textPen']=QPen(QColor(0, 255, 0))
tr.reset()
#tr.reset()
#grid.setTransform(tr) # assign transform
vb.addItem(grid)
#--- opctical center ----
oc_sz=np.array((50,50))
self._goOptCtr=obj=UsrGO.Marker(-opt_ctr-oc_sz/2, oc_sz,mode=1)
obj.sigRegionChangeFinished.connect(self.cb_marker_moved)
#obj.setTransform(tr) # assign transform
vb.addItem(obj)
#--- beam marker ---
bm_sz=np.array((50, 40)) # it is immidiatly repositioned in cb_zoom_changed
@@ -658,9 +667,9 @@ class WndSwissMx(QMainWindow, Ui_MainWindow):
cam=app._camera
cfg=app._cfg
param=cam.get_param()
try:
paramSv=cfg.value(AppCfg.GEO_CAM_PARAM)
except AttributeError as e:
paramSv=cfg.value(AppCfg.GEO_CAM_PARAM)
if paramSv is None:
cfg.setValue(AppCfg.GEO_CAM_PARAM, param)
else:
for k,v in param.items():