Commit 1da28f10 authored by Robert Ohmacht's avatar Robert Ohmacht

Merge remote-tracking branch 'origin/SegmentationRefactoring' into Tiling2Develop

parents 5a37c671 d9b6effc
......@@ -176,12 +176,14 @@ class ImageView(QtWidgets.QLabel):
else:
self.drag = "add"
p0 = event.pos()
if self.drag=="add":
self.seedpoints.append([p0.x(),p0.y(),self.seedradius])
elif self.drag=="delete":
self.seeddeletepoints.append([p0.x(),p0.y(),self.seedradius])
else:
self.removeSeeds([p0.x(),p0.y()])
self.appendSeedPoints(p0)
# print(p0)
# if self.drag =="add":
# self.seedpoints.append([p0.x(), p0.y(), self.seedradius])
# elif self.drag =="delete":
# self.seeddeletepoints.append([p0.x(), p0.y(), self.seedradius])
# elif self.drag == "remove":
# self.removeSeeds([p0.x(), p0.y()])
self.update()
super().mousePressEvent(event)
......@@ -189,12 +191,13 @@ class ImageView(QtWidgets.QLabel):
def mouseMoveEvent(self, event):
if self.drag:
p0 = event.pos()
if self.drag=="add":
self.seedpoints.append([p0.x(),p0.y(),self.seedradius])
elif self.drag=="delete":
self.seeddeletepoints.append([p0.x(),p0.y(),self.seedradius])
else:
self.removeSeeds([p0.x(),p0.y()])
self.appendSeedPoints(p0)
# if self.drag == "add":
# self.seedpoints.append([p0.x(),p0.y(),self.seedradius])
# elif self.drag == "delete":
# self.seeddeletepoints.append([p0.x(),p0.y(),self.seedradius])
# else:
# self.removeSeeds([p0.x(),p0.y()])
self.update()
super().mouseMoveEvent(event)
......@@ -203,6 +206,16 @@ class ImageView(QtWidgets.QLabel):
self.seedChanged.emit()
self.drag = False
super().mouseReleaseEvent(event)
def appendSeedPoints(self, pos):
if 0 <= pos.x() < Nscreen and 0 <= pos.y() < Nscreen:
print(pos)
if self.drag == "add":
self.seedpoints.append([pos.x(), pos.y(), self.seedradius])
elif self.drag == "delete":
self.seeddeletepoints.append([pos.x(), pos.y(), self.seedradius])
elif self.drag == "remove":
self.removeSeeds([pos.x(), pos.y()])
def clearData(self):
self.contours = []
......@@ -301,6 +314,7 @@ class ParticleDetectionView(QtWidgets.QWidget):
self.showseedpoints.stateChanged.connect(self.imglabel.changeSeedDisplay)
self.showseedpoints.setChecked(True)
self.setImageCenter()
group = QtWidgets.QGroupBox("Detection settings", self)
grid = QtWidgets.QGridLayout()
self.parameters = []
......@@ -316,6 +330,7 @@ class ParticleDetectionView(QtWidgets.QWidget):
colstretch = 2
if p.dtype == np.bool:
paramui = QtWidgets.QCheckBox(p.helptext, self)
paramui.stateChanged.connect(self.autoUpdateIfDesired)
paramui.setChecked(p.value)
valuefunc = makeValueLambda(paramui.isChecked)
colstretch = 2
......@@ -335,6 +350,7 @@ class ParticleDetectionView(QtWidgets.QWidget):
paramui.setSingleStep(p.stepsize)
paramui.setValue(p.value)
paramui.setMinimumWidth(70)
paramui.valueChanged.connect(self.autoUpdateIfDesired)
valuefunc = makeValueLambda(paramui.value)
elif p.dtype is None:
label = QtWidgets.QLabel(p.helptext, self)
......@@ -358,10 +374,7 @@ class ParticleDetectionView(QtWidgets.QWidget):
if paramui is not None:
self.parameters[-1][3] = pshow
#link checkboxes to other parameters:
def makeEnableLambda(checkbox, parameter):
return lambda: parameter.setEnabled(checkbox.isChecked())
......@@ -401,6 +414,12 @@ class ParticleDetectionView(QtWidgets.QWidget):
self.slider.setOrientation(QtCore.Qt.Horizontal)
self.slider.sliderMoved.connect(self.imglabel.resetAlpha)
vbox.addWidget(self.slider)
self.autoUpdateCheckBox = QtWidgets.QCheckBox('Auto-update detection')
self.autoUpdateCheckBox.setMaximumWidth(200)
self.autoUpdateCheckBox.setChecked(True)
vbox.addWidget(self.autoUpdateCheckBox)
hbox2 = QtWidgets.QHBoxLayout()
self.pdetectsub = QtWidgets.QPushButton("Detect", self)
self.pdetectall = QtWidgets.QPushButton("Detect all", self)
......@@ -490,11 +509,11 @@ class ParticleDetectionView(QtWidgets.QWidget):
arr1 = self.dataset.seedpoints
# what seeds are actually in image view?
for point in arr1: #Josef says: I replaced the commented logic with the one right here below, as the old one somehow did not work.... The for-loop might become slow at some point??
for point in arr1:
if point[0] > (m1-point[2]) and point[0] <= (m2+point[2]) and point[1] > (n1-point[2]) and point[1] <= (n2+point[2]):
seedpoints.append([point[0] - p0[0][0], point[1] - p0[0][1], point[2]])
arr2 = self.dataset.seeddeletepoints
for point in arr2: #Josef says: I replaced the commented logic with the one right here below, as the old one somehow did not work.... The for-loop might become slow at some point??
for point in arr2:
if point[0] > (m1-point[2]) and point[0] <= (m2+point[2]) and point[1] > (n1-point[2]) and point[1] <= (n2+point[2]):
seeddeletepoints.append([point[0] - p0[0][0], point[1] - p0[0][1], point[2]])
......@@ -524,8 +543,15 @@ class ParticleDetectionView(QtWidgets.QWidget):
if self.drag:
self.lastcenter = self.lastmove
self.drag = False
self.detectShow(None)
self.autoUpdateIfDesired()
def autoUpdateIfDesired(self):
try:
if self.autoUpdateCheckBox.isChecked():
self.detectShow(None)
except: #the method is already called when automatically setting default parameters, which causes various errors because initialization is not yet finished...
pass
def setDataSet(self, ds):
self.dataset = ds
self.updateImageSeeds()
......
This diff is collapsed.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment