refactoring and log of coorinate work
This commit is contained in:
@@ -145,9 +145,9 @@ class Marker(pg.ROI):
|
||||
# # p.drawText(-w, -h, '{:.0f}x{:.0f}'.format(*self._size))
|
||||
|
||||
class Fiducial(pg.ROI):
|
||||
def __init__(self, pos, size, xyz, **kargs):
|
||||
def __init__(self, pos, size, z:float, **kargs):
|
||||
pg.ROI.__init__(self, pos, size, **kargs)
|
||||
self._xyz=xyz
|
||||
self._z=z
|
||||
|
||||
def paint(self, p, *args):
|
||||
#pg.ROI.paint(self, p, *args)
|
||||
@@ -157,16 +157,30 @@ class Fiducial(pg.ROI):
|
||||
p.translate(r.left(), r.top())
|
||||
p.scale(.01*r.width(), .01*r.height()) # -> values x,y 0 to 100
|
||||
p.drawRect(0, 0, 100, 100)
|
||||
p.drawEllipse(45, 45, 10, 10)
|
||||
p.setPen(pg.mkPen(width=1, color=[255, 0, 0]))
|
||||
p.drawLine(pg.Point(50,10), pg.Point(50, 90))
|
||||
p.drawLine(pg.Point(10,50), pg.Point(90, 50))
|
||||
tr=p.transform()
|
||||
tr.setMatrix(tr.m11(), tr.m12(), tr.m13(), tr.m21(), -tr.m22(), tr.m23(), tr.m31(), tr.m32(), tr.m33())
|
||||
p.setTransform(tr)
|
||||
#tr=p.transform()
|
||||
#tr.setMatrix(tr.m11(), tr.m12(), tr.m13(), tr.m21(), -tr.m22(), tr.m23(), tr.m31(), tr.m32(), tr.m33())
|
||||
#p.setTransform(tr)
|
||||
f=p.font()
|
||||
f.setPixelSize(10)
|
||||
p.setFont(f)
|
||||
#p.drawText(24, 20, 'beam marker')
|
||||
ctr=tuple(self.pos()+self.size()/2)
|
||||
sz=tuple(self.size())
|
||||
print((*ctr,self._z))
|
||||
#p.drawText(5, 25, 'x{:.4g}\ny{:.4g}\nz{:.4g}'.format(*ctr,self._z))
|
||||
p.drawText(52, 10,40,40,Qt.TextWordWrap, 'x{:.5g}\ny{:.5g}\nz{:.5g}'.format(*ctr,self._z))
|
||||
|
||||
def ctr(self):
|
||||
ctr=tuple(self.pos()+self.size()/2)+(self._z,)
|
||||
return ctr
|
||||
|
||||
def __repr__(self):
|
||||
pos='('+', '.join(tuple(map(lambda x: f'{x:.6g}',self.pos())))+')'
|
||||
s=f'{self.__class__.__name__}:(pos:{itr2str(self.pos())}, size:{itr2str(self.size())}, xyz:{itr2str(self._xyz)}}}'
|
||||
ctr=self.ctr()
|
||||
s=f'{self.__class__.__name__}:(ctr:{itr2str(ctr)}, size:{itr2str(self.size())}}}'
|
||||
return s
|
||||
|
||||
def obj2json(self,encoder):
|
||||
@@ -174,7 +188,7 @@ class Fiducial(pg.ROI):
|
||||
'__class__':self.__class__.__name__,
|
||||
'pos':tuple(self.pos()),
|
||||
'size':tuple(self.size()),
|
||||
'xyz':tuple(self._xyz),
|
||||
'z':self._z,
|
||||
}
|
||||
return jsn
|
||||
|
||||
@@ -469,6 +483,7 @@ class FixTargetFrame(pg.ROI):
|
||||
def get_scan_param(self,mode=0x2):
|
||||
'returns scan parameters for scanning with deltatau. the format is as used for shapepath'
|
||||
grid=self._dscr['grid']
|
||||
self._dscr['size']
|
||||
#pos=np.array(self.pos())
|
||||
cnt =np.array(grid['count'],np.int32)
|
||||
#pos =np.array(grid['pos'],np.float)
|
||||
@@ -486,11 +501,14 @@ class FixTargetFrame(pg.ROI):
|
||||
pts=np.array([xx.reshape(-1), yy.reshape(-1)], dtype=np.float).transpose() #*pitch
|
||||
|
||||
param={'grid':grid, 'points':pts}
|
||||
trf=self.transform()
|
||||
if not trf.isIdentity():
|
||||
#obj_info(trf)
|
||||
trf=np.array(((trf.m11(),trf.m12()),(trf.m21(),trf.m22())))
|
||||
param['trf']=trf
|
||||
t=self.transform()
|
||||
p=np.array(self.pos())
|
||||
s=self.size()/self._dscr['size']
|
||||
trf=np.array(((t.m11(),t.m12(),0),(t.m21(),t.m22(),0)))
|
||||
trf[:,2]=p
|
||||
trf[:,:2]*=s
|
||||
# trf*'gridpos in um' -> motor pos in mm
|
||||
param['trf']=trf
|
||||
return param
|
||||
|
||||
class TxtROI(pg.ROI):
|
||||
@@ -661,7 +679,7 @@ if __name__=='__main__':
|
||||
vi=FixTargetFrame((400,-200),(400,400),tpl='12.5x12.5')
|
||||
vb.addItem(vi)
|
||||
|
||||
vi=Fiducial((0,200),(40,40),(1,2,3))
|
||||
vi=Fiducial((0,200),(40,40),3)
|
||||
vb.addItem(vi)
|
||||
|
||||
viRoi=pg.ROI([-200, -200], [100, 80],movable=True, rotatable=True, resizable=True)
|
||||
|
||||
Reference in New Issue
Block a user