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): ...@@ -176,12 +176,14 @@ class ImageView(QtWidgets.QLabel):
else: else:
self.drag = "add" self.drag = "add"
p0 = event.pos() p0 = event.pos()
if self.drag=="add": self.appendSeedPoints(p0)
self.seedpoints.append([p0.x(),p0.y(),self.seedradius]) # print(p0)
elif self.drag=="delete": # if self.drag =="add":
self.seeddeletepoints.append([p0.x(),p0.y(),self.seedradius]) # self.seedpoints.append([p0.x(), p0.y(), self.seedradius])
else: # elif self.drag =="delete":
self.removeSeeds([p0.x(),p0.y()]) # self.seeddeletepoints.append([p0.x(), p0.y(), self.seedradius])
# elif self.drag == "remove":
# self.removeSeeds([p0.x(), p0.y()])
self.update() self.update()
super().mousePressEvent(event) super().mousePressEvent(event)
...@@ -189,12 +191,13 @@ class ImageView(QtWidgets.QLabel): ...@@ -189,12 +191,13 @@ class ImageView(QtWidgets.QLabel):
def mouseMoveEvent(self, event): def mouseMoveEvent(self, event):
if self.drag: if self.drag:
p0 = event.pos() p0 = event.pos()
if self.drag=="add": self.appendSeedPoints(p0)
self.seedpoints.append([p0.x(),p0.y(),self.seedradius]) # if self.drag == "add":
elif self.drag=="delete": # self.seedpoints.append([p0.x(),p0.y(),self.seedradius])
self.seeddeletepoints.append([p0.x(),p0.y(),self.seedradius]) # elif self.drag == "delete":
else: # self.seeddeletepoints.append([p0.x(),p0.y(),self.seedradius])
self.removeSeeds([p0.x(),p0.y()]) # else:
# self.removeSeeds([p0.x(),p0.y()])
self.update() self.update()
super().mouseMoveEvent(event) super().mouseMoveEvent(event)
...@@ -203,6 +206,16 @@ class ImageView(QtWidgets.QLabel): ...@@ -203,6 +206,16 @@ class ImageView(QtWidgets.QLabel):
self.seedChanged.emit() self.seedChanged.emit()
self.drag = False self.drag = False
super().mouseReleaseEvent(event) 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): def clearData(self):
self.contours = [] self.contours = []
...@@ -301,6 +314,7 @@ class ParticleDetectionView(QtWidgets.QWidget): ...@@ -301,6 +314,7 @@ class ParticleDetectionView(QtWidgets.QWidget):
self.showseedpoints.stateChanged.connect(self.imglabel.changeSeedDisplay) self.showseedpoints.stateChanged.connect(self.imglabel.changeSeedDisplay)
self.showseedpoints.setChecked(True) self.showseedpoints.setChecked(True)
self.setImageCenter() self.setImageCenter()
group = QtWidgets.QGroupBox("Detection settings", self) group = QtWidgets.QGroupBox("Detection settings", self)
grid = QtWidgets.QGridLayout() grid = QtWidgets.QGridLayout()
self.parameters = [] self.parameters = []
...@@ -316,6 +330,7 @@ class ParticleDetectionView(QtWidgets.QWidget): ...@@ -316,6 +330,7 @@ class ParticleDetectionView(QtWidgets.QWidget):
colstretch = 2 colstretch = 2
if p.dtype == np.bool: if p.dtype == np.bool:
paramui = QtWidgets.QCheckBox(p.helptext, self) paramui = QtWidgets.QCheckBox(p.helptext, self)
paramui.stateChanged.connect(self.autoUpdateIfDesired)
paramui.setChecked(p.value) paramui.setChecked(p.value)
valuefunc = makeValueLambda(paramui.isChecked) valuefunc = makeValueLambda(paramui.isChecked)
colstretch = 2 colstretch = 2
...@@ -335,6 +350,7 @@ class ParticleDetectionView(QtWidgets.QWidget): ...@@ -335,6 +350,7 @@ class ParticleDetectionView(QtWidgets.QWidget):
paramui.setSingleStep(p.stepsize) paramui.setSingleStep(p.stepsize)
paramui.setValue(p.value) paramui.setValue(p.value)
paramui.setMinimumWidth(70) paramui.setMinimumWidth(70)
paramui.valueChanged.connect(self.autoUpdateIfDesired)
valuefunc = makeValueLambda(paramui.value) valuefunc = makeValueLambda(paramui.value)
elif p.dtype is None: elif p.dtype is None:
label = QtWidgets.QLabel(p.helptext, self) label = QtWidgets.QLabel(p.helptext, self)
...@@ -358,10 +374,7 @@ class ParticleDetectionView(QtWidgets.QWidget): ...@@ -358,10 +374,7 @@ class ParticleDetectionView(QtWidgets.QWidget):
if paramui is not None: if paramui is not None:
self.parameters[-1][3] = pshow self.parameters[-1][3] = pshow
#link checkboxes to other parameters: #link checkboxes to other parameters:
def makeEnableLambda(checkbox, parameter): def makeEnableLambda(checkbox, parameter):
return lambda: parameter.setEnabled(checkbox.isChecked()) return lambda: parameter.setEnabled(checkbox.isChecked())
...@@ -401,6 +414,12 @@ class ParticleDetectionView(QtWidgets.QWidget): ...@@ -401,6 +414,12 @@ class ParticleDetectionView(QtWidgets.QWidget):
self.slider.setOrientation(QtCore.Qt.Horizontal) self.slider.setOrientation(QtCore.Qt.Horizontal)
self.slider.sliderMoved.connect(self.imglabel.resetAlpha) self.slider.sliderMoved.connect(self.imglabel.resetAlpha)
vbox.addWidget(self.slider) 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() hbox2 = QtWidgets.QHBoxLayout()
self.pdetectsub = QtWidgets.QPushButton("Detect", self) self.pdetectsub = QtWidgets.QPushButton("Detect", self)
self.pdetectall = QtWidgets.QPushButton("Detect all", self) self.pdetectall = QtWidgets.QPushButton("Detect all", self)
...@@ -490,11 +509,11 @@ class ParticleDetectionView(QtWidgets.QWidget): ...@@ -490,11 +509,11 @@ class ParticleDetectionView(QtWidgets.QWidget):
arr1 = self.dataset.seedpoints arr1 = self.dataset.seedpoints
# what seeds are actually in image view? # 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]): 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]]) seedpoints.append([point[0] - p0[0][0], point[1] - p0[0][1], point[2]])
arr2 = self.dataset.seeddeletepoints 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]): 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]]) seeddeletepoints.append([point[0] - p0[0][0], point[1] - p0[0][1], point[2]])
...@@ -524,8 +543,15 @@ class ParticleDetectionView(QtWidgets.QWidget): ...@@ -524,8 +543,15 @@ class ParticleDetectionView(QtWidgets.QWidget):
if self.drag: if self.drag:
self.lastcenter = self.lastmove self.lastcenter = self.lastmove
self.drag = False 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): def setDataSet(self, ds):
self.dataset = ds self.dataset = ds
self.updateImageSeeds() 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