wip
This commit is contained in:
@@ -301,8 +301,11 @@ class Path(UsrROI):
|
||||
a circle is plot at the path positions
|
||||
a cross is plot at the fiducial positions
|
||||
'''
|
||||
def __init__( self, pos=(0,0), path=np.array(((6,4),(16,24),(-5,7),(3,12))), fiducial=None, ficucialScale=5, **kwargs):
|
||||
def __init__( self, pos=(0,0), size=(30,20), path=np.array(((6,4),(16,24),(-5,7),(3,12))), fiducial=None, ficucialScale=5, **kwargs):
|
||||
self.code_gen=kwargs.pop('code_gen',0)
|
||||
trf=kwargs.pop('trf',None)
|
||||
pg.ROI.__init__(self, pos, size, **kwargs)
|
||||
self.szOrig=size
|
||||
if type(path)==list:
|
||||
path=np.array(path)
|
||||
if fiducial is None:
|
||||
@@ -310,12 +313,7 @@ class Path(UsrROI):
|
||||
else:
|
||||
if type(fiducial)==list:
|
||||
fiducial=np.array(fiducial)
|
||||
all=np.vstack((fiducial,path))
|
||||
mn=all.min(0)
|
||||
mx=all.max(0)
|
||||
size=self.szOrig=mx-mn
|
||||
|
||||
pg.ROI.__init__(self, pos, size, **kwargs)
|
||||
if trf is not None:
|
||||
t=self.transform()
|
||||
t.setMatrix(trf[0][0], trf[0][1], 0,
|
||||
@@ -326,7 +324,7 @@ class Path(UsrROI):
|
||||
self._fiducial=fiducial
|
||||
self._path=path
|
||||
self._fidScl=ficucialScale
|
||||
self._rect=r=QtCore.QRectF(mn[0]-5*ficucialScale, mn[1]-5*ficucialScale, size[0]+10*ficucialScale, size[1]+10*ficucialScale)
|
||||
self._rect=r=QtCore.QRectF(0, 0, size[0], size[1])
|
||||
self._qpath=qPth=QPolygonF()
|
||||
for pt in path:
|
||||
qPth.append(QPointF(*pt))
|
||||
@@ -375,20 +373,37 @@ class Path(UsrROI):
|
||||
jsn= {
|
||||
'__class__':self.__class__.__name__,
|
||||
'pos':tuple(self.pos()),
|
||||
'size':tuple(self.szOrig),
|
||||
'code_gen':self.code_gen,
|
||||
'fiducial': self._fiducial.tolist(),
|
||||
'path': self._path.tolist(),
|
||||
'ficucialScale':self._fidScl
|
||||
'ficucialScale':self._fidScl,
|
||||
'path':self._path.tolist(),
|
||||
}
|
||||
so=pg.Point(self.szOrig)
|
||||
sn=self.size()
|
||||
trf=self.transform()
|
||||
if not trf.isIdentity() or so!=sn:
|
||||
scl=sn/so
|
||||
if not trf.isIdentity():
|
||||
#obj_info(trf)
|
||||
trf=((trf.m11()*scl[0],trf.m12()*scl[0]),(trf.m21()*scl[1],trf.m22()*scl[1]))
|
||||
trf=((trf.m11(),trf.m12()),(trf.m21(),trf.m22()))
|
||||
jsn['trf']=trf
|
||||
return jsn
|
||||
|
||||
def get_scan_param(self,mode=0x2):
|
||||
'returns scan parameters for scanning with deltatau. the format is as used for shapepath'
|
||||
#mode=pvt
|
||||
#param={'points':pts, 'mode':mode}
|
||||
param={'points':self._path, 'code_gen': self.code_gen}
|
||||
|
||||
t=self.transform()
|
||||
p=np.array(self.pos())
|
||||
s=self.size()/self.szOrig
|
||||
trf=np.array(((t.m11(),t.m12()),(t.m21(),t.m22()),(0,0)))
|
||||
trf[2,:]=p # shift origin
|
||||
#trf[:2, 0]*=s[0];trf[:2, 1]*=s[1] #scaling (before rotation shear)
|
||||
trf[:2,:]=(trf[:2,:].T*s).T # same as np.asmatrix(np.diag(s))*trf[:2,:], trf[:2,:]*=s not working, scale before rot / shear
|
||||
|
||||
# trf*'gridpos in um' -> motor pos in mm
|
||||
param['trf']=trf
|
||||
return param
|
||||
|
||||
class FixTargetFrame(UsrROI):
|
||||
'''fixed target frame'''
|
||||
tpl={
|
||||
@@ -433,6 +448,7 @@ class FixTargetFrame(UsrROI):
|
||||
}
|
||||
|
||||
def __init__( self, pos=(0,0), size=(100,100), tpl='test', dscr=None, **kwargs):
|
||||
self.code_gen=kwargs.pop('code_gen',0)
|
||||
trf=kwargs.pop('trf',None)
|
||||
pg.ROI.__init__(self, pos, size, **kwargs)
|
||||
if trf is not None:
|
||||
@@ -524,6 +540,7 @@ class FixTargetFrame(UsrROI):
|
||||
'__class__':self.__class__.__name__,
|
||||
'pos':tuple(self.pos()),
|
||||
'size':tuple(self.size()),
|
||||
'code_gen':self.code_gen,
|
||||
'dscr': self._dscr
|
||||
}
|
||||
trf=self.transform()
|
||||
@@ -533,8 +550,9 @@ class FixTargetFrame(UsrROI):
|
||||
jsn['trf']=trf
|
||||
return jsn
|
||||
|
||||
def get_scan_param(self,mode=0x2):
|
||||
def get_scan_param(self):
|
||||
'returns scan parameters for scanning with deltatau. the format is as used for shapepath'
|
||||
mode=0x2 #default fast y axis
|
||||
grid=self._dscr['grid']
|
||||
self._dscr['size']
|
||||
#pos=np.array(self.pos())
|
||||
@@ -553,7 +571,8 @@ class FixTargetFrame(UsrROI):
|
||||
|
||||
pts=np.array([xx.reshape(-1), yy.reshape(-1)], dtype=np.float).transpose() #*pitch
|
||||
|
||||
param={'grid':grid, 'points':pts, 'mode':mode}
|
||||
param={'grid':grid, 'points':pts, 'code_gen': self.code_gen}
|
||||
|
||||
t=self.transform()
|
||||
p=np.array(self.pos())
|
||||
s=self.size()/self._dscr['size']
|
||||
|
||||
Reference in New Issue
Block a user