path and codegen
This commit is contained in:
@@ -301,19 +301,32 @@ 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, **kargs):
|
||||
def __init__( self, pos=(0,0), path=np.array(((6,4),(16,24),(-5,7),(3,12))), fiducial=None, ficucialScale=5, **kwargs):
|
||||
trf=kwargs.pop('trf',None)
|
||||
if type(path)==list:
|
||||
path=np.array(path)
|
||||
if fiducial is None:
|
||||
all=path
|
||||
else:
|
||||
if type(fiducial)==list:
|
||||
fiducial=np.array(fiducial)
|
||||
all=np.vstack((fiducial,path))
|
||||
mn=all.min(0)
|
||||
mx=all.max(0)
|
||||
sz=mx-mn
|
||||
pg.ROI.__init__(self, pos, sz, **kargs)
|
||||
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,
|
||||
trf[1][0], trf[1][1], 0,
|
||||
0, 0, 1)
|
||||
self.setTransform(t)
|
||||
|
||||
self._fiducial=fiducial
|
||||
self._path=path
|
||||
self._fidScl=ficucialScale
|
||||
self._rect=r=QtCore.QRectF(mn[0], mn[1], sz[0], sz[1])
|
||||
self._rect=r=QtCore.QRectF(mn[0]-5*ficucialScale, mn[1]-5*ficucialScale, size[0]+10*ficucialScale, size[1]+10*ficucialScale)
|
||||
self._qpath=qPth=QPolygonF()
|
||||
for pt in path:
|
||||
qPth.append(QPointF(*pt))
|
||||
@@ -331,8 +344,8 @@ class Path(UsrROI):
|
||||
p.setRenderHint(QtGui.QPainter.Antialiasing)
|
||||
p.setPen(self.currentPen)
|
||||
#p.drawEllipse(0, 0, int(sz[0]), int(sz[1]))
|
||||
p.drawRect(0, 0, int(sz[0]), int(sz[1]))
|
||||
|
||||
#p.drawRect(0, 0, int(sz[0]), int(sz[1]))
|
||||
p.drawRect(QtCore.QRectF(0, 0, sz[0], sz[1]).normalized())
|
||||
#obj_info(p)
|
||||
p.scale(sz[0]/r.width(), sz[1]/r.height())
|
||||
p.translate(-r.left(), -r.top())
|
||||
@@ -362,10 +375,18 @@ class Path(UsrROI):
|
||||
jsn= {
|
||||
'__class__':self.__class__.__name__,
|
||||
'pos':tuple(self.pos()),
|
||||
'fiducial': repr(self._fiducial),
|
||||
'path': repr(self._path),
|
||||
'fiducial': self._fiducial.tolist(),
|
||||
'path': self._path.tolist(),
|
||||
'ficucialScale':self._fidScl
|
||||
}
|
||||
so=pg.Point(self.szOrig)
|
||||
sn=self.size()
|
||||
trf=self.transform()
|
||||
if not trf.isIdentity() or so!=sn:
|
||||
scl=sn/so
|
||||
#obj_info(trf)
|
||||
trf=((trf.m11()*scl[0],trf.m12()*scl[0]),(trf.m21()*scl[1],trf.m22()*scl[1]))
|
||||
jsn['trf']=trf
|
||||
return jsn
|
||||
|
||||
class FixTargetFrame(UsrROI):
|
||||
@@ -532,7 +553,7 @@ class FixTargetFrame(UsrROI):
|
||||
|
||||
pts=np.array([xx.reshape(-1), yy.reshape(-1)], dtype=np.float).transpose() #*pitch
|
||||
|
||||
param={'grid':grid, 'points':pts}
|
||||
param={'grid':grid, 'points':pts, 'mode':mode}
|
||||
t=self.transform()
|
||||
p=np.array(self.pos())
|
||||
s=self.size()/self._dscr['size']
|
||||
|
||||
Reference in New Issue
Block a user