wip
This commit is contained in:
107
swissmx.py
107
swissmx.py
@@ -86,7 +86,7 @@ import qtawesome
|
||||
import qutilities
|
||||
from PyQt5 import QtCore, QtGui
|
||||
from PyQt5.QtCore import Qt, pyqtSlot, QSize, QRegExp, pyqtSignal, QObject, QThread
|
||||
from PyQt5.QtGui import QKeySequence, QPixmap, QRegExpValidator
|
||||
from PyQt5.QtGui import QKeySequence, QPixmap, QRegExpValidator, QFont
|
||||
from PyQt5.QtWidgets import (
|
||||
QAction, QApplication, QDoubleSpinBox, QFileDialog, QFormLayout, QGridLayout, QGroupBox, QHBoxLayout, QLabel, QLineEdit,
|
||||
QMessageBox, QPlainTextEdit, QProgressBar, QProgressDialog, QPushButton, QShortcut, QSizePolicy, QSpinBox,
|
||||
@@ -302,9 +302,10 @@ class WndSwissMx(QMainWindow, Ui_MainWindow):
|
||||
self._message_critical_fault = QLabel(None)
|
||||
self._message_critical_fault.setAccessibleName("device_fault")
|
||||
self.statusbar.insertWidget(0, self._message_critical_fault)
|
||||
self._lb_coords = QLabel(None)
|
||||
self._lb_coords.setText("coords")
|
||||
self.statusbar.addPermanentWidget(self._lb_coords)
|
||||
self._lb_coords=lbl=QLabel(None)
|
||||
#f=QFont('monospace', 10)
|
||||
#lbl.setFont(f)
|
||||
self.statusbar.addPermanentWidget(lbl)
|
||||
|
||||
self._fel_status = QLabel(None)
|
||||
self._fel_status.setAccessibleName("fel_status_statusbar")
|
||||
@@ -645,7 +646,25 @@ class WndSwissMx(QMainWindow, Ui_MainWindow):
|
||||
self.cb_new_frame_sim()
|
||||
except AttributeError:
|
||||
self.sigNewCamImg.connect(self.cb_update_img)
|
||||
app._camera.run(self.cb_new_frame_pv)
|
||||
cam=app._camera
|
||||
cfg=app._cfg
|
||||
param=cam.get_param()
|
||||
try:
|
||||
paramSv=cfg.value(AppCfg.GEO_CAM_PARAM)
|
||||
except AttributeError as e:
|
||||
cfg.setValue(AppCfg.GEO_CAM_PARAM, param)
|
||||
else:
|
||||
for k,v in param.items():
|
||||
if v!=paramSv[k]:
|
||||
if type(v)==tuple:
|
||||
if v==tuple(paramSv[k]):
|
||||
continue
|
||||
#cam.set_param(paramSv)
|
||||
#cfg.setValue(AppCfg.GEO_CAM_PARAM, param)
|
||||
#break
|
||||
_log.debug(f'diff:{k},{v} != {paramSv[k]}')
|
||||
|
||||
cam.run(self.cb_new_frame_pv)
|
||||
|
||||
def cb_new_frame_pv(self, **kwargs):
|
||||
#thrd=threading.current_thread()
|
||||
@@ -932,47 +951,40 @@ class WndSwissMx(QMainWindow, Ui_MainWindow):
|
||||
|
||||
def cb_mouse_move(self, pos):
|
||||
app = QApplication.instance()
|
||||
self._mouse_pos = pos
|
||||
geo = app._geometry
|
||||
#pos = pixel position on the widget
|
||||
task = self.active_task()
|
||||
xy = self._goImg.mapFromScene(pos)
|
||||
z = app._zoom.get_val()
|
||||
#_log.debug('mouse_pos:{} scene_pos:{} zoom:{}'.format(pos,xy,z))
|
||||
#TODO: implement mouse handling
|
||||
# if self._ppm_toolbox._force_ppm > 0:
|
||||
# ppm = self._ppm_toolbox._force_ppm
|
||||
# else:
|
||||
try:
|
||||
ppm = self.ppm_fitter(z)
|
||||
except:
|
||||
ppm = 1E3
|
||||
x, y = xy.x(), xy.y()
|
||||
try:
|
||||
bx, by = self.get_beam_mark_on_camera_xy()
|
||||
except:
|
||||
bx, by = 500, 500
|
||||
dx = (x - bx) / ppm
|
||||
dy = -(y - by) / ppm
|
||||
try:
|
||||
fx = self.tweakers["fast_x"].motor.get_position()
|
||||
fy = self.tweakers["fast_y"].motor.get_position()
|
||||
fx += dx
|
||||
fy += dy
|
||||
except:
|
||||
fx=fy=0
|
||||
|
||||
self._lb_coords.setText(
|
||||
"\u23FA{:>}:{:>6.0f} {:<.0f}"
|
||||
"\u23FA{:>}:{:>6.0f} {:<.0f}"
|
||||
"\u23FA{:>}:{:<.0f}"
|
||||
"\u23FA{:>}:{:>6.1f} {:<.1f} \u00B5"
|
||||
"\u23FA{:>}:{:>7.3f} {:<.3f} mm".format(
|
||||
"Beam at", bx, by,
|
||||
"Pixel coord ", x, y,
|
||||
"PPM", ppm,
|
||||
"Distance to beam", 1000 * dx, 1000 * dy,
|
||||
"Stage", fx, fy,
|
||||
)
|
||||
)
|
||||
#bm=self._goBeamMarker
|
||||
#pos=event.scenePos()
|
||||
pImg=pg.Point(self._goImg.mapFromScene(pos))
|
||||
pTrk=pg.Point(self._goTracked.mapFromScene(pos))
|
||||
fx=self.tweakers["fast_x"].get_val()
|
||||
fy=self.tweakers["fast_y"].get_val()
|
||||
pTrk=pTrk-(fx,fy)
|
||||
#s=f'pImg{pImg} pTrk{pTrk} bm._pos_eu{bm._pos_eu}'
|
||||
|
||||
|
||||
s=\
|
||||
f'img pix ({pImg[0]:>0.1f} {pImg[1]:>0.1f})px \u23A2 ' \
|
||||
f'dist to beam ({pTrk[0]:>0.6g} {pTrk[1]:>0.6g}mm) '
|
||||
|
||||
_log.debug(s)
|
||||
self._lb_coords.setText(s)
|
||||
#self._lb_coords.setText(
|
||||
# "\u23FA{:>}:{:>6.0f} {:<.0f}"
|
||||
# "\u23FA{:>}:{:>6.0f} {:<.0f}"
|
||||
# "\u23FA{:>}:{:<.0f}"
|
||||
# "\u23FA{:>}:{:>6.1f} {:<.1f} \u00B5"
|
||||
# "\u23FA{:>}:{:>7.3f} {:<.3f} mm".format(
|
||||
# "Beam at", bx, by,
|
||||
# "Pixel coord ", x, y,
|
||||
# "PPM", ppm,
|
||||
# "Distance to beam", 1000 * dx, 1000 * dy,
|
||||
# "Stage", fx, fy,
|
||||
# )
|
||||
#)
|
||||
|
||||
def cb_mouse_click(self, event):
|
||||
#_log.debug("{}".format(event))
|
||||
@@ -983,7 +995,8 @@ class WndSwissMx(QMainWindow, Ui_MainWindow):
|
||||
#_log.debug(f"vb pos {self.vb.mapFromScene(p)}") #pixel position on the scene (including black frame)
|
||||
#for o in self.vb.childGroup.childItems():
|
||||
# _log.debug(f"{type(o)} pos {o.mapFromScene(p)}") #pixel position on the scene (including black frame)
|
||||
_log.debug(f"currentItem:{event.currentItem}")
|
||||
|
||||
#_log.debug(f"currentItem:{event.currentItem}")
|
||||
task = self.active_task()
|
||||
if task==TASK_SETUP_GEOMETRY_CALIB:
|
||||
self.mouse_click_event_geometry_calib(event)
|
||||
@@ -1270,7 +1283,11 @@ class WndSwissMx(QMainWindow, Ui_MainWindow):
|
||||
import PIL.Image
|
||||
#img=PIL.Image.fromarray(cam.pic.astype(np.uint8))
|
||||
try:
|
||||
pic=cam.pic
|
||||
pic=cam._pic
|
||||
mx=pic.max()
|
||||
if pic.max()>255:
|
||||
scl=2**int(round(np.log2(mx)-8))
|
||||
pic=np.array(pic/scl,dtype=np.uint8)
|
||||
except AttributeError:
|
||||
sim=app._camera._sim
|
||||
pic=cam._sim['imgSeq'][sim['imgIdx']]
|
||||
|
||||
Reference in New Issue
Block a user