enhance context menu, draw object center, recenter if image out of view
This commit is contained in:
@@ -224,15 +224,14 @@ class WndFixTarget(QWidget):
|
||||
|
||||
tree.setContextMenuPolicy(Qt.ActionsContextMenu)
|
||||
|
||||
act = QAction("delete", self)
|
||||
act.triggered.connect(self.tree_ctx_delete)
|
||||
tree.addAction(act)
|
||||
|
||||
act = QAction("center in view", self)
|
||||
act.triggered.connect(self.tree_ctx_center)
|
||||
tree.addAction(act)
|
||||
|
||||
#contextMenuEvent
|
||||
act = QAction("delete", self)
|
||||
act.triggered.connect(self.tree_ctx_delete)
|
||||
tree.addAction(act)
|
||||
|
||||
def tree_get_path(self):
|
||||
path=[]
|
||||
it=self._tree.currentItem()
|
||||
@@ -277,10 +276,13 @@ class WndFixTarget(QWidget):
|
||||
vb=wnd.vb
|
||||
grp=wnd._goTracked
|
||||
go=grp.childItems()[path[0]]
|
||||
vb.autoRange(items=(go,))
|
||||
#r1=vb.viewRect()
|
||||
#r2=vb.itemBoundingRect(go)
|
||||
#if not r1.intersects(r2):
|
||||
#vb.autoRange(items=(go,))
|
||||
r1=vb.viewRect()
|
||||
r2=vb.itemBoundingRect(go)
|
||||
#r=vb.viewRect()
|
||||
vb.setRange(rect=r2)
|
||||
r1.translate(r2.center()-r1.center())
|
||||
vb.setRange(r1)
|
||||
|
||||
def load_file(self, filename=None):
|
||||
app = QApplication.instance()
|
||||
|
||||
@@ -461,6 +461,15 @@ class FixTargetFrame(pg.ROI):
|
||||
lh=QLineF(x-rx, y, x+rx, y)
|
||||
lv=QLineF(x, y-ry, x, y+ry)
|
||||
p.drawLines(lh, lv)
|
||||
|
||||
#plot center of all feducials
|
||||
ctr=np.array(f['pos']).mean(axis=0)
|
||||
x, y=ctr # ;print(x,y)
|
||||
lh=QLineF(x-rx, y, x+rx, y)
|
||||
lv=QLineF(x, y-ry, x, y+ry)
|
||||
p.drawLines(lh, lv)
|
||||
p.drawEllipse(x-rx/2, y-ry/2, rx, ry)
|
||||
|
||||
else:
|
||||
assert('unknown feducial type')
|
||||
|
||||
@@ -741,6 +750,8 @@ if __name__=='__main__':
|
||||
#viRoi.addTranslateHandle([.7, .5], axes=None, item=None, name=None, index=None) #quadrat
|
||||
vb.addItem(viRoi)
|
||||
|
||||
#autorange not working, as all rois are in ItemGroup
|
||||
vb.setRange(QtCore.QRectF(-300, -400, 900+300, 500+400))
|
||||
|
||||
childTree(vb)
|
||||
|
||||
|
||||
@@ -1081,10 +1081,10 @@ class WndSwissMx(QMainWindow, Ui_MainWindow):
|
||||
|
||||
#if none of the image is visible, recenter it
|
||||
r1=self.vb.viewRect()
|
||||
#r2=self.vb.itemBoundingRect(self._goImg)
|
||||
r2=self.vb.itemBoundingRect(self._goBeamMarker)
|
||||
r2=self.vb.itemBoundingRect(self._goImg)
|
||||
if not r1.intersects(r2):
|
||||
self.vb.autoRange(items=(self._goImg,))
|
||||
r1.translate(r2.center()-r1.center())
|
||||
self.vb.setRange(r1)
|
||||
|
||||
try:
|
||||
pln=geo._fitPlane
|
||||
|
||||
Reference in New Issue
Block a user