fix in trace and app config

This commit is contained in:
2022-09-09 18:14:59 +02:00
parent 31c5df6cb5
commit e215f3abea
2 changed files with 44 additions and 29 deletions

View File

@@ -410,10 +410,6 @@ class WndSwissMx(QMainWindow, Ui_MainWindow):
#bm.setTransform(tr) # assign transform
grp.addItem(obj)
#--- camera tracong images ---
self._goTrace=grp=pg.ItemGroup() # the transformation is the same as for tracked objects
grp.setZValue(-20) #lower than other objects
self.vb.addItem(grp)
@@ -1079,16 +1075,7 @@ class WndSwissMx(QMainWindow, Ui_MainWindow):
#create trace
img=pg.ImageItem(self._goImg.image)
img.setZValue(100)
trImg=self._goImgGrp.transform()
trTrk=self._goTracked.transform()
tr=trImg*trTrk.inverted()[0] #TODO: check if oder correct !!!
#tr.scale(.5,.5)
img.setTransform(tr)
self._goTrace.addItem(img)
self.add_camera_trace()
_log.debug(f'dist to beam ({pFix[0]:>0.6g} {pFix[1]:>0.6g}mm)')
fx_motor=self.tweakers["fast_x"]
@@ -1096,9 +1083,6 @@ class WndSwissMx(QMainWindow, Ui_MainWindow):
fx_motor.move_rel(pFix[0])
fy_motor.move_rel(pFix[1])
self._goTrace.setTransform(self._goTracked.transform())
#fx_motor.move_abs(fx_motor.get_val()+pFix[0])
#fy_motor.move_abs(fy_motor.get_val()+pFix[1])
@@ -1280,6 +1264,7 @@ class WndSwissMx(QMainWindow, Ui_MainWindow):
fy=twk_fy.get_val()
try:
grp=self._goTracked
grpTrc=self._goTrace
zoom_old,fx_old,fy_old=grp._state
except AttributeError: # at initialization
self._goTracked=grp=pg.ItemGroup()
@@ -1287,12 +1272,17 @@ class WndSwissMx(QMainWindow, Ui_MainWindow):
self.vb.addItem(grp)
grp._state=(zoom,fx,fy)
zoom_old=fx_old=fy_old=None
#--- camera tracing images ---
self._goTrace=grpTrc=pg.ItemGroup() # the transformation is the same as for tracked objects
grpTrc.setZValue(-20) #lower than other objects
self.vb.addItem(grpTrc)
_log.debug(f"zoom:{zoom_old}->{zoom} fx:{fx_old}->{fx} fy:{fy_old}->{fy}")
if zoom_old!=zoom:
geo.interp_zoom(zoom)
bm=self._goBeamMarker
grp=self._goTracked
opt_ctr=geo._opt_ctr
A=np.asarray(geo._pix2pos.I)
# trf=cfg.value(AppCfg.GEO_CAM_TRF)
@@ -1304,6 +1294,21 @@ class WndSwissMx(QMainWindow, Ui_MainWindow):
A[1, 0], A[1, 1], 0,
p[0], p[1], 1) # translate dx,dy
grp.setTransform(tr)
grpTrc.setTransform(tr)
def add_camera_trace(self):
# add up to tracelen image when moveing motors to new positions
tracelen=4
img=pg.ImageItem(self._goImg.image)
trImg=self._goImgGrp.transform()
trTrk=self._goTracked.transform()
tr=trImg*trTrk.inverted()[0] # TODO: check if oder correct !!!
img.setTransform(tr)
self._goTrace.addItem(img)
cld=self._goTrace.childItems()
if len(cld) > tracelen:
self.vb.removeItem(cld[0])
def cb_modify_app_param(self):
wnd=WndParameter(self)