Commit 2efa7d08 authored by JosefBrandt's avatar JosefBrandt

Fix: No preview detection, while full detection is running

This messes up the progress bar....
Also: more complete blockUI and unblockUI
parent eeaa9d71
...@@ -291,6 +291,7 @@ class ParticleDetectionView(QtWidgets.QWidget): ...@@ -291,6 +291,7 @@ class ParticleDetectionView(QtWidgets.QWidget):
self.seg = Segmentation(self.dataset, self) self.seg = Segmentation(self.dataset, self)
self.seg.detectionState.connect(self.updateDetectionState) self.seg.detectionState.connect(self.updateDetectionState)
self.thread = None self.thread = None
self.threadrunning = False
self.view = parent self.view = parent
vbox = QtWidgets.QVBoxLayout() vbox = QtWidgets.QVBoxLayout()
...@@ -315,7 +316,7 @@ class ParticleDetectionView(QtWidgets.QWidget): ...@@ -315,7 +316,7 @@ class ParticleDetectionView(QtWidgets.QWidget):
self.showseedpoints.setChecked(True) self.showseedpoints.setChecked(True)
self.setImageCenter() self.setImageCenter()
group = QtWidgets.QGroupBox("Detection settings", self) self.detectParamsGroup = QtWidgets.QGroupBox("Detection settings", self)
grid = QtWidgets.QGridLayout() grid = QtWidgets.QGridLayout()
self.parameters = [] self.parameters = []
checkBoxesToLink = {} checkBoxesToLink = {}
...@@ -397,8 +398,8 @@ class ParticleDetectionView(QtWidgets.QWidget): ...@@ -397,8 +398,8 @@ class ParticleDetectionView(QtWidgets.QWidget):
grid.addWidget(self.showseedpoints, i+2, 0, 1, 2, QtCore.Qt.AlignLeft) grid.addWidget(self.showseedpoints, i+2, 0, 1, 2, QtCore.Qt.AlignLeft)
grid.addWidget(QtWidgets.QLabel("Click mouse to add seeds, Click+Shift to add deletepoints"), i+3, 0, 1, 2, QtCore.Qt.AlignLeft) grid.addWidget(QtWidgets.QLabel("Click mouse to add seeds, Click+Shift to add deletepoints"), i+3, 0, 1, 2, QtCore.Qt.AlignLeft)
grid.addWidget(QtWidgets.QLabel("Click+Alt removes seeds near cursor"), i+4, 0, 1, 2, QtCore.Qt.AlignLeft) grid.addWidget(QtWidgets.QLabel("Click+Alt removes seeds near cursor"), i+4, 0, 1, 2, QtCore.Qt.AlignLeft)
group.setLayout(grid) self.detectParamsGroup.setLayout(grid)
vbox.addWidget(group) vbox.addWidget(self.detectParamsGroup)
self.updateSeedsInSampleViewBtn = QtWidgets.QPushButton("Update Seedpoints in fullimage view", self) self.updateSeedsInSampleViewBtn = QtWidgets.QPushButton("Update Seedpoints in fullimage view", self)
self.updateSeedsInSampleViewBtn.released.connect(self.updateSeedsInSampleview) self.updateSeedsInSampleViewBtn.released.connect(self.updateSeedsInSampleview)
...@@ -600,21 +601,22 @@ class ParticleDetectionView(QtWidgets.QWidget): ...@@ -600,21 +601,22 @@ class ParticleDetectionView(QtWidgets.QWidget):
self.updateImageSeeds() self.updateImageSeeds()
def detectShow(self, showname): def detectShow(self, showname):
self.saveDetectParams(self.dataset) if not self.threadrunning:
img = self.subimg.copy() self.saveDetectParams(self.dataset)
kwargs = {} img = self.subimg.copy()
for ui, name, valuefunc, showbtn in self.parameters: kwargs = {}
kwargs[name] = valuefunc() for ui, name, valuefunc, showbtn in self.parameters:
self.seg.setParameters(**kwargs) kwargs[name] = valuefunc()
seedradius = self.seedradiusedit.value() self.seg.setParameters(**kwargs)
if showname is not None: seedradius = self.seedradiusedit.value()
stepImg, imgtype = self.seg.apply2Image(img, self.imglabel.seedpoints, self.imglabel.seeddeletepoints, if showname is not None:
seedradius, self.dataset, return_step=showname) stepImg, imgtype = self.seg.apply2Image(img, self.imglabel.seedpoints, self.imglabel.seeddeletepoints,
self.imglabel.showStep(stepImg, imgtype) seedradius, self.dataset, return_step=showname)
else: self.imglabel.showStep(stepImg, imgtype)
measurementpoints, contours = self.seg.apply2Image(img, self.imglabel.seedpoints, self.imglabel.seeddeletepoints, else:
seedradius, self.dataset) measurementpoints, contours = self.seg.apply2Image(img, self.imglabel.seedpoints, self.imglabel.seeddeletepoints,
self.imglabel.updateDetectionResults(contours, measurementpoints) seedradius, self.dataset)
self.imglabel.updateDetectionResults(contours, measurementpoints)
@QtCore.pyqtSlot() @QtCore.pyqtSlot()
def clearDetection(self): def clearDetection(self):
...@@ -637,10 +639,16 @@ class ParticleDetectionView(QtWidgets.QWidget): ...@@ -637,10 +639,16 @@ class ParticleDetectionView(QtWidgets.QWidget):
def blockUI(self): def blockUI(self):
self.pdetectsub.setEnabled(False) self.pdetectsub.setEnabled(False)
self.pclear.setEnabled(False) self.pclear.setEnabled(False)
self.detectParamsGroup.setEnabled(False)
self.updateSeedsInSampleViewBtn.setEnabled(False)
self.hideSeedsInSampleViewBtn.setEnabled(False)
def unBlockUI(self): def unBlockUI(self):
self.pdetectsub.setEnabled(True) self.pdetectsub.setEnabled(True)
self.pclear.setEnabled(True) self.pclear.setEnabled(True)
self.detectParamsGroup.setEnabled(True)
self.updateSeedsInSampleViewBtn.setEnabled(True)
self.hideSeedsInSampleViewBtn.setEnabled(True)
def raiseWarning(self, warning): def raiseWarning(self, warning):
QtWidgets.QMessageBox.critical(self, "Warning", warning) QtWidgets.QMessageBox.critical(self, "Warning", warning)
......
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