Commit 83cdeb70 authored by JosefBrandt's avatar JosefBrandt

Before refactoring analysis navigation....

parent 47db59a2
...@@ -44,8 +44,8 @@ except: ...@@ -44,8 +44,8 @@ except:
class ParticleAnalysis(QtWidgets.QMainWindow): class ParticleAnalysis(QtWidgets.QMainWindow):
def __init__(self, dataset, parent=None): def __init__(self, dataset, viewparent=None):
super(ParticleAnalysis, self).__init__(parent) super(ParticleAnalysis, self).__init__(viewparent)
self.setGeometry(100, 100, 1680, 1050) self.setGeometry(100, 100, 1680, 1050)
self.setWindowTitle('Results of polymer analysis') self.setWindowTitle('Results of polymer analysis')
self.layout = QtWidgets.QHBoxLayout() self.layout = QtWidgets.QHBoxLayout()
...@@ -53,7 +53,7 @@ class ParticleAnalysis(QtWidgets.QMainWindow): ...@@ -53,7 +53,7 @@ class ParticleAnalysis(QtWidgets.QMainWindow):
self.widget.setLayout(self.layout) self.widget.setLayout(self.layout)
self.setCentralWidget(self.widget) self.setCentralWidget(self.widget)
self.parent = parent self.viewparent = viewparent
self.dataset = dataset self.dataset = dataset
self.particleContainer = dataset.particleContainer self.particleContainer = dataset.particleContainer
self.editor = ParticleEditor(self.particleContainer, self) self.editor = ParticleEditor(self.particleContainer, self)
...@@ -114,21 +114,18 @@ class ParticleAnalysis(QtWidgets.QMainWindow): ...@@ -114,21 +114,18 @@ class ParticleAnalysis(QtWidgets.QMainWindow):
self.navigationGroup.setDisabled(True) self.navigationGroup.setDisabled(True)
navigationLayout = QtWidgets.QHBoxLayout() navigationLayout = QtWidgets.QHBoxLayout()
self.specNumberSelector = QtWidgets.QSpinBox() self.specNumberSelector = QtWidgets.QSpinBox()
self.specNumberSelector.setMinimumWidth(150) self.specNumberSelector.setMinimumWidth(100)
self.specNumberSelector.setMinimum(1) self.specNumberSelector.setMinimum(1)
self.specNumberSelector.setMaximum(1E6) self.specNumberSelector.setMaximum(1E6)
self.jumpToSpecBtn = QtWidgets.QPushButton('Jump To Spectrum of Number:') self.jumpToSpecBtn = QtWidgets.QPushButton('Jump To Spectrum of Number:')
self.jumpToSpecBtn.released.connect(self.jumpToSpectrumOfNumber) self.jumpToSpecBtn.released.connect(self.jumpToIndicatedSpectrum)
self.typeSelectorCombo = QtWidgets.QComboBox() self.typeSelectorCombo = QtWidgets.QComboBox()
self.typeSelectorCombo.currentIndexChanged.connect(self.displayNewPolymerType)
self.typeSelectorCombo.setMinimumWidth(150) self.typeSelectorCombo.setMinimumWidth(150)
self.particleSelector = QtWidgets.QSpinBox() self.particleSelector = QtWidgets.QSpinBox()
self.particleSelector.valueChanged.connect(self.updateSpecPlotToSelectedParticle)
self.particleNumberLabel = QtWidgets.QLabel('of xx particles; ') self.particleNumberLabel = QtWidgets.QLabel('of xx particles; ')
self.spectrumSelector = QtWidgets.QSpinBox() self.spectrumSelector = QtWidgets.QSpinBox()
self.spectrumSelector.valueChanged.connect(self.selectSpectrum)
self.spectrumNumberLabel = QtWidgets.QLabel('of xx spectra') self.spectrumNumberLabel = QtWidgets.QLabel('of xx spectra')
for spinbox in [self.particleSelector, self.spectrumSelector]: for spinbox in [self.particleSelector, self.spectrumSelector]:
spinbox.setMinimum(1) spinbox.setMinimum(1)
...@@ -220,11 +217,10 @@ class ParticleAnalysis(QtWidgets.QMainWindow): ...@@ -220,11 +217,10 @@ class ParticleAnalysis(QtWidgets.QMainWindow):
self.createMenus() self.createMenus()
self.applyHQIThresholdToResults() self.applyHQIThresholdToResults()
self.createHistogramData() self.createHistogramData()
self.updateDisplays()
self.initializeSpecPlot() self.initializeSpecPlot()
self.displayNewPolymerType() self.displayNewPolymerType()
self.updateSpecPlotToSelectedParticle() self.updateSpecPlotToSelectedParticle()
# self.createPolymerOverlay() self.updateHistogramsAndContours()
def createActions(self): def createActions(self):
self.loadTrueMatchAct = QtWidgets.QAction("Load &TrueMatch Results", self) self.loadTrueMatchAct = QtWidgets.QAction("Load &TrueMatch Results", self)
...@@ -253,6 +249,9 @@ class ParticleAnalysis(QtWidgets.QMainWindow): ...@@ -253,6 +249,9 @@ class ParticleAnalysis(QtWidgets.QMainWindow):
self.seedAct = QtWidgets.QAction("&Set Color Seed", self) self.seedAct = QtWidgets.QAction("&Set Color Seed", self)
self.seedAct.triggered.connect(self.updateColorSeed) self.seedAct.triggered.connect(self.updateColorSeed)
self.removeTinyParticlesAct = QtWidgets.QAction("&Remove not unknown Particles < 1 µm")
self.removeTinyParticlesAct.triggered.connect(self.removeTinyParticles)
self.databaseAct = QtWidgets.QAction("&ManageDatabase", self) self.databaseAct = QtWidgets.QAction("&ManageDatabase", self)
self.databaseAct.triggered.connect(self.launchDBManager) self.databaseAct.triggered.connect(self.launchDBManager)
...@@ -272,7 +271,7 @@ class ParticleAnalysis(QtWidgets.QMainWindow): ...@@ -272,7 +271,7 @@ class ParticleAnalysis(QtWidgets.QMainWindow):
self.overlayActGroup = QtWidgets.QActionGroup(self.dispMenu) self.overlayActGroup = QtWidgets.QActionGroup(self.dispMenu)
self.overlayActGroup.setExclusive(True) self.overlayActGroup.setExclusive(True)
self.overlayActGroup.triggered.connect(self.updateContourColors) self.overlayActGroup.triggered.connect(self.updateContourColors)
self.overlayActGroup.triggered.connect(self.updateDisplays) self.overlayActGroup.triggered.connect(self.updateHistogramsAndContours)
for act in [self.noOverlayAct, self.selOverlayAct, self.fullOverlayAct]: for act in [self.noOverlayAct, self.selOverlayAct, self.fullOverlayAct]:
self.dispMenu.addAction(act) self.dispMenu.addAction(act)
...@@ -281,8 +280,9 @@ class ParticleAnalysis(QtWidgets.QMainWindow): ...@@ -281,8 +280,9 @@ class ParticleAnalysis(QtWidgets.QMainWindow):
self.dispMenu.addSeparator() self.dispMenu.addSeparator()
self.dispMenu.addActions([self.transpAct, self.hideLabelAct, self.darkenAct, self.seedAct]) self.dispMenu.addActions([self.transpAct, self.hideLabelAct, self.darkenAct, self.seedAct])
self.refMenu = QtWidgets.QMenu("&References") self.toolMenu = QtWidgets.QMenu("&Tools")
self.refMenu.addAction(self.databaseAct) self.toolMenu.addAction(self.removeTinyParticlesAct)
self.toolMenu.addAction(self.databaseAct)
self.exportMenu = QtWidgets.QMenu("&Export", self) self.exportMenu = QtWidgets.QMenu("&Export", self)
self.exportMenu.addAction(self.expExcelAct) self.exportMenu.addAction(self.expExcelAct)
...@@ -290,7 +290,7 @@ class ParticleAnalysis(QtWidgets.QMainWindow): ...@@ -290,7 +290,7 @@ class ParticleAnalysis(QtWidgets.QMainWindow):
self.menuBar().addMenu(self.importMenu) self.menuBar().addMenu(self.importMenu)
self.menuBar().addMenu(self.dispMenu) self.menuBar().addMenu(self.dispMenu)
self.menuBar().addMenu(self.refMenu) self.menuBar().addMenu(self.toolMenu)
self.menuBar().addMenu(self.exportMenu) self.menuBar().addMenu(self.exportMenu)
def launchDBManager(self): def launchDBManager(self):
...@@ -328,7 +328,7 @@ class ParticleAnalysis(QtWidgets.QMainWindow): ...@@ -328,7 +328,7 @@ class ParticleAnalysis(QtWidgets.QMainWindow):
self.dataset.resultParams['minHQI'] = hqi self.dataset.resultParams['minHQI'] = hqi
self.dataset.save() self.dataset.save()
self.createHistogramData() self.createHistogramData()
self.updateDisplays() self.updateHistogramsAndContours()
def createHistogramData(self): def createHistogramData(self):
###Handle Checkboxes for all polymers... ###Handle Checkboxes for all polymers...
...@@ -342,7 +342,7 @@ class ParticleAnalysis(QtWidgets.QMainWindow): ...@@ -342,7 +342,7 @@ class ParticleAnalysis(QtWidgets.QMainWindow):
del i del i
self.showTotalSelector.setParent(None) self.showTotalSelector.setParent(None)
self.showTotalSelector.setDisabled(False) self.showTotalSelector.setDisabled(False)
self.showTotalSelector.stateChanged.connect(self.updateDisplays) self.showTotalSelector.stateChanged.connect(self.updateHistogramsAndContours)
del self.resultCheckBoxes del self.resultCheckBoxes
del self.resultCheckBoxesLayout del self.resultCheckBoxesLayout
...@@ -369,7 +369,7 @@ class ParticleAnalysis(QtWidgets.QMainWindow): ...@@ -369,7 +369,7 @@ class ParticleAnalysis(QtWidgets.QMainWindow):
if polymer in self.lastSelectedCheckBoxNames: if polymer in self.lastSelectedCheckBoxNames:
self.polymerCheckBoxes[index].setChecked(True) self.polymerCheckBoxes[index].setChecked(True)
self.polymerCheckBoxes[index].stateChanged.connect(self.updateDisplays) self.polymerCheckBoxes[index].stateChanged.connect(self.updateHistogramsAndContours)
self.resultCheckBoxesLayout.addStretch() self.resultCheckBoxesLayout.addStretch()
self.resultCheckBoxes.setLayout(self.resultCheckBoxesLayout) self.resultCheckBoxes.setLayout(self.resultCheckBoxesLayout)
...@@ -381,10 +381,10 @@ class ParticleAnalysis(QtWidgets.QMainWindow): ...@@ -381,10 +381,10 @@ class ParticleAnalysis(QtWidgets.QMainWindow):
self.expSQLAct.setDisabled(False) self.expSQLAct.setDisabled(False)
self.navigationGroup.setEnabled(True) self.navigationGroup.setEnabled(True)
self.typeSelectorCombo.currentIndexChanged.disconnect() # self.typeSelectorCombo.currentIndexChanged.disconnect()
self.typeSelectorCombo.clear() self.typeSelectorCombo.clear()
self.typeSelectorCombo.addItems(uniquePolymers) self.typeSelectorCombo.addItems(uniquePolymers)
self.typeSelectorCombo.currentIndexChanged.connect(self.displayNewPolymerType) # self.typeSelectorCombo.currentIndexChanged.connect(self.displayNewPolymerType)
self.polymerIndex = self.typeSelectorCombo.currentIndex() self.polymerIndex = self.typeSelectorCombo.currentIndex()
# if self.lastSpectrumInFocus is not None: # if self.lastSpectrumInFocus is not None:
...@@ -395,7 +395,7 @@ class ParticleAnalysis(QtWidgets.QMainWindow): ...@@ -395,7 +395,7 @@ class ParticleAnalysis(QtWidgets.QMainWindow):
# print('displaying new type with resetting index') # print('displaying new type with resetting index')
# self.displayNewPolymerType() # self.displayNewPolymerType()
def updateDisplays(self): def updateHistogramsAndContours(self):
self.createHistogramData() self.createHistogramData()
t0 = time.time() t0 = time.time()
self.updateTypeHistogram() self.updateTypeHistogram()
...@@ -468,12 +468,10 @@ class ParticleAnalysis(QtWidgets.QMainWindow): ...@@ -468,12 +468,10 @@ class ParticleAnalysis(QtWidgets.QMainWindow):
self.lastSelectedCheckBoxNames = self.getSelectedPolymers() self.lastSelectedCheckBoxNames = self.getSelectedPolymers()
def updateSpecPlot(self, centerOn=True, highlightContour=True): def updateSpecPlot(self):
particleSize = self.particleContainer.getSizeOfParticleByIndex(self.currentParticleIndex) particleSize = self.particleContainer.getSizeOfParticleByIndex(self.currentParticleIndex)
hqi = self.particleContainer.getHQIOfSpectrumIndex(self.currentSpectrumIndex) hqi = self.particleContainer.getHQIOfSpectrumIndex(self.currentSpectrumIndex)
self.specPlot.updateParticleSpectrum(self.currentSpectrumIndex, particleSize, hqi) self.specPlot.updateParticleSpectrum(self.currentSpectrumIndex, particleSize, hqi)
self.parent.centerOnRamanIndex(self.currentSpectrumIndex, centerOn=centerOn, highlightContour=highlightContour) #TODO: is this reasonable to do in that way???
self.parent.highLightRamanIndex(self.currentSpectrumIndex)
# self.lastSpectrumInFocus = self.currentSpectrumIndex # self.lastSpectrumInFocus = self.currentSpectrumIndex
if self.refSelector.isEnabled() and self.refSelector.currentText() != '': if self.refSelector.isEnabled() and self.refSelector.currentText() != '':
...@@ -482,7 +480,7 @@ class ParticleAnalysis(QtWidgets.QMainWindow): ...@@ -482,7 +480,7 @@ class ParticleAnalysis(QtWidgets.QMainWindow):
self.specPlot.updateReferenceSpectrum(ref[:, 0], ref[:, 1]) self.specPlot.updateReferenceSpectrum(ref[:, 0], ref[:, 1])
def updateContourColors(self): def updateContourColors(self):
contours = self.parent.contourItems contours = self.viewparent.contourItems
alpha = (64 if self.transpAct.isChecked() else 255) alpha = (64 if self.transpAct.isChecked() else 255)
selectedPolymers = self.getSelectedPolymers() selectedPolymers = self.getSelectedPolymers()
...@@ -495,7 +493,7 @@ class ParticleAnalysis(QtWidgets.QMainWindow): ...@@ -495,7 +493,7 @@ class ParticleAnalysis(QtWidgets.QMainWindow):
contour.setHidden(hidden) contour.setHidden(hidden)
contour.setColor(color) contour.setColor(color)
contour.update() contour.update()
def updateLegend(self): def updateLegend(self):
if not self.noOverlayAct.isChecked(): if not self.noOverlayAct.isChecked():
legendItems = [] legendItems = []
...@@ -505,16 +503,31 @@ class ParticleAnalysis(QtWidgets.QMainWindow): ...@@ -505,16 +503,31 @@ class ParticleAnalysis(QtWidgets.QMainWindow):
color = getColorFromNameWithSeed(polymer, self.dataset.colorSeed) color = getColorFromNameWithSeed(polymer, self.dataset.colorSeed)
color = QtGui.QColor(color[0], color[1], color[2], 255) color = QtGui.QColor(color[0], color[1], color[2], 255)
legendItems.append((polymer, color)) legendItems.append((polymer, color))
self.parent.updateLegend(legendItems) self.viewparent.updateLegend(legendItems)
def getSelectedPolymers(self): def getSelectedPolymers(self):
return [checkbox.text() for checkbox in self.polymerCheckBoxes if checkbox.isChecked()] return [checkbox.text() for checkbox in self.polymerCheckBoxes if checkbox.isChecked()]
def jumpToSpectrumOfNumber(self): def getSpecIndexFromBoxesAndJumpThere(self):
self.currentSpectrumIndex = self.getSpectrumIndexFromSpectrumSelector()
self.specNumberSelector.setValue(self.currentSpectrumIndex+1)
self.jumpToIndicatedSpectrum()
def jumpToIndicatedSpectrum(self, centerOn=True):
print('jumping to spec index with centerOn', centerOn)
###disconnect Boxes
try:
self.typeSelectorCombo.currentIndexChanged.disconnect()
self.particleSelector.valueChanged.disconnect()
self.spectrumSelector.valueChanged.disconnect()
except TypeError:
pass #i.e., there was no connection
specIndex = self.specNumberSelector.value()-1 specIndex = self.specNumberSelector.value()-1
assert specIndex is not None print('specIndex', specIndex)
partIndex = self.particleContainer.getParticleIndexContainingSpecIndex(specIndex) partIndex = self.particleContainer.getParticleIndexContainingSpecIndex(specIndex)
print('partIndex', partIndex)
assignment = self.particleContainer.getParticleAssignmentByIndex(partIndex) assignment = self.particleContainer.getParticleAssignmentByIndex(partIndex)
self.typeSelectorCombo.setCurrentText(assignment) self.typeSelectorCombo.setCurrentText(assignment)
...@@ -523,19 +536,27 @@ class ParticleAnalysis(QtWidgets.QMainWindow): ...@@ -523,19 +536,27 @@ class ParticleAnalysis(QtWidgets.QMainWindow):
specIndices = self.particleContainer.getSpectraIndicesOfParticle(partIndex) specIndices = self.particleContainer.getSpectraIndicesOfParticle(partIndex)
self.spectrumSelector.setValue(specIndices.index(specIndex)+1) self.spectrumSelector.setValue(specIndices.index(specIndex)+1)
def selectParticleOfIndex(self, particleIndex, centerOn=True):
assignment = self.particleContainer.getParticleAssignmentByIndex(particleIndex)
self.typeSelectorCombo.setCurrentText(assignment)
self.typeSelectorCombo.currentIndexChanged.connect(self.displayNewPolymerType)
self.particleSelector.valueChanged.disconnect() if centerOn:
particleIndices = self.particleContainer.getIndicesOfParticleType(assignment) self.viewparent.centerOnRamanIndex(self.currentSpectrumIndex, centerOn=True, highlightContour=True)
self.particleSelector.setValue(particleIndices.index(particleIndex)+1) self.viewparent.highLightContour(self.getParticleIndexFromParticleSelector())
self.particleSelector.valueChanged.connect(self.updateSpecPlotToSelectedParticle)
###connect Boxes
self.typeSelectorCombo.currentIndexChanged.connect(self.displayNewPolymerType)
self.typeSelectorCombo.currentIndexChanged.connect(self.getSpecIndexFromBoxesAndJumpThere)
# self.particleSelector.valueChanged.connect(self.updateSpecPlotToSelectedParticle)
self.particleSelector.valueChanged.connect(self.getSpecIndexFromBoxesAndJumpThere)
# self.spectrumSelector.valueChanged.connect(self.selectSpectrum)
self.spectrumSelector.valueChanged.connect(self.getSpecIndexFromBoxesAndJumpThere)
self.displayNewPolymerType()
self.updateSpecPlotToSelectedParticle()
self.updateHistogramsAndContours()
self.updateSpecPlotToSelectedParticle(resetSpectrumCount=True, centerOn=centerOn)
def selectParticleOfIndex(self, particleIndex, centerOn=False):
specIndices = self.particleContainer.getSpectraIndicesOfParticle(particleIndex)
self.specNumberSelector.setValue(specIndices[0]+1)
self.jumpToIndicatedSpectrum(centerOn=centerOn)
def displayNewPolymerType(self, resetCurrentIndex=True): def displayNewPolymerType(self, resetCurrentIndex=True):
polymerName = self.typeSelectorCombo.currentText() polymerName = self.typeSelectorCombo.currentText()
...@@ -551,9 +572,9 @@ class ParticleAnalysis(QtWidgets.QMainWindow): ...@@ -551,9 +572,9 @@ class ParticleAnalysis(QtWidgets.QMainWindow):
self.spectrumSelector.setMaximum(numSpectra) self.spectrumSelector.setMaximum(numSpectra)
self.spectrumNumberLabel.setText(f'of {numSpectra} Spectra') self.spectrumNumberLabel.setText(f'of {numSpectra} Spectra')
self.currentSpectrumIndex = self.getSpectrumIndexFromSpectrumSelector() self.currentSpectrumIndex = self.getSpectrumIndexFromSpectrumSelector()
self.updateSpecPlot(centerOn=False) self.updateSpecPlot()
def updateSpecPlotToSelectedParticle(self, resetSpectrumCount=True, centerOn=True): def updateSpecPlotToSelectedParticle(self, resetSpectrumCount=True):
polymerName = self.typeSelectorCombo.currentText() polymerName = self.typeSelectorCombo.currentText()
if polymerName != '': if polymerName != '':
self.currentParticleIndex = self.getParticleIndexFromParticleSelector() self.currentParticleIndex = self.getParticleIndexFromParticleSelector()
...@@ -564,11 +585,11 @@ class ParticleAnalysis(QtWidgets.QMainWindow): ...@@ -564,11 +585,11 @@ class ParticleAnalysis(QtWidgets.QMainWindow):
self.spectrumSelector.setValue(1) self.spectrumSelector.setValue(1)
self.currentSpectrumIndex = self.getSpectrumIndexFromSpectrumSelector() self.currentSpectrumIndex = self.getSpectrumIndexFromSpectrumSelector()
self.updateSpecPlot(centerOn) self.updateSpecPlot()
def selectSpectrum(self): # def selectSpectrum(self):
self.currentSpectrumIndex = self.getSpectrumIndexFromSpectrumSelector() # self.currentSpectrumIndex = self.getSpectrumIndexFromSpectrumSelector()
self.updateSpecPlot() # self.updateSpecPlot()
def getSpectrumIndexFromSpectrumSelector(self): def getSpectrumIndexFromSpectrumSelector(self):
specIndicesOfParticle = self.particleContainer.getSpectraIndicesOfParticle(self.currentParticleIndex) specIndicesOfParticle = self.particleContainer.getSpectraIndicesOfParticle(self.currentParticleIndex)
...@@ -582,24 +603,53 @@ class ParticleAnalysis(QtWidgets.QMainWindow): ...@@ -582,24 +603,53 @@ class ParticleAnalysis(QtWidgets.QMainWindow):
return particleIndicesOfType[self.particleSelector.value()-1] return particleIndicesOfType[self.particleSelector.value()-1]
def darkenBackground(self): def darkenBackground(self):
self.parent.darkenPixmap = self.darkenAct.isChecked() self.viewparent.darkenPixmap = self.darkenAct.isChecked()
if self.darkenAct.isChecked(): if self.darkenAct.isChecked():
self.parent.scene().setBackgroundBrush(QtGui.QColor(5, 5, 5)) self.viewparent.scene().setBackgroundBrush(QtGui.QColor(5, 5, 5))
self.parent.item.setOpacity(0.2) self.viewparent.item.setOpacity(0.2)
else: else:
self.parent.scene().setBackgroundBrush(QtCore.Qt.darkGray) self.viewparent.scene().setBackgroundBrush(QtCore.Qt.darkGray)
self.parent.item.setOpacity(1) self.viewparent.item.setOpacity(1)
def updateColorSeed(self): def updateColorSeed(self):
text, ok = QtWidgets.QInputDialog.getText(self, 'Color Seed', 'Enter New Seed here', text=self.dataset.colorSeed) text, ok = QtWidgets.QInputDialog.getText(self, 'Color Seed', 'Enter New Seed here', text=self.dataset.colorSeed)
if ok: if ok:
self.dataset.colorSeed = text self.dataset.colorSeed = text
self.updateDisplays() self.updateHistogramsAndContours()
def removeTinyParticles(self):
indices = []
for particle in self.particleContainer.particles:
if particle.getParticleAssignment() != 'unknown' and particle.getParticleSize() < 1:
indices.append(particle.index)
indices = sorted(indices, reverse=True)
numIndices = len(indices)
for index, partIndex in enumerate(indices):
self.selectParticleOfIndex(partIndex, centerOn=True)
reply = QtWidgets.QMessageBox.question(self, f'Particle {index+1} of {numIndices}',
"Do you want to remove that particle?",
QtWidgets.QMessageBox.Yes |
QtWidgets.QMessageBox.No | QtWidgets.QMessageBox.Cancel, QtWidgets.QMessageBox.No)
if reply == QtWidgets.QMessageBox.Yes:
self.viewparent.removeParticleContour(partIndex)
self.particleContainer.removeParticles([partIndex])
elif reply == QtWidgets.QMessageBox.Cancel:
self.particleContainer.resetParticleIndices()
self.viewparent.resetContourIndices()
return
self.particleContainer.resetParticleIndices()
self.viewparent.resetContourIndices()
def show_hide_labels(self): def show_hide_labels(self):
hidden = self.hideLabelAct.isChecked() hidden = self.hideLabelAct.isChecked()
for scanIndicator in self.parent.ramanscanitems: for scanIndicator in self.viewparent.ramanscanitems:
scanIndicator.hidden = hidden scanIndicator.hidden = hidden
scanIndicator.update() scanIndicator.update()
...@@ -615,7 +665,7 @@ class ParticleAnalysis(QtWidgets.QMainWindow): ...@@ -615,7 +665,7 @@ class ParticleAnalysis(QtWidgets.QMainWindow):
for window in [self.importWindow, self.dbWin]: for window in [self.importWindow, self.dbWin]:
try: window.close() try: window.close()
except: pass except: pass
self.parent.imparent.particelAnalysisAct.setChecked(False) self.viewparent.imparent.particelAnalysisAct.setChecked(False)
event.accept() event.accept()
......
...@@ -254,9 +254,6 @@ class ParticleContainer(object): ...@@ -254,9 +254,6 @@ class ParticleContainer(object):
for index in sorted(indexList, reverse=True): for index in sorted(indexList, reverse=True):
particle = self.getParticleOfIndex(index) #just for asserting to have the correct particle! particle = self.getParticleOfIndex(index) #just for asserting to have the correct particle!
del self.particles[index] del self.particles[index]
# particle = self.getParticleOfIndex(index)
# print('removing particle of index', index)
# self.particles.remove(particle)
def resetParticleIndices(self): def resetParticleIndices(self):
for newIndex, particle in enumerate(self.particles): for newIndex, particle in enumerate(self.particles):
......
...@@ -161,6 +161,7 @@ class ParticlePainter(QtWidgets.QGraphicsItem): ...@@ -161,6 +161,7 @@ class ParticlePainter(QtWidgets.QGraphicsItem):
for poly in self.polygons: for poly in self.polygons:
painter.setBrush(QtGui.QColor(200, 200, 255, 128)) painter.setBrush(QtGui.QColor(200, 200, 255, 128))
painter.drawPolygon(poly) painter.drawPolygon(poly)
\ No newline at end of file
...@@ -105,7 +105,7 @@ class ParticleContextMenu(QtWidgets.QMenu): ...@@ -105,7 +105,7 @@ class ParticleContextMenu(QtWidgets.QMenu):
class ParticleEditor(QtCore.QObject): class ParticleEditor(QtCore.QObject):
particleContoursChanged = QtCore.pyqtSignal() # particleContoursChanged = QtCore.pyqtSignal()
particleAssignmentChanged = QtCore.pyqtSignal() particleAssignmentChanged = QtCore.pyqtSignal()
def __init__(self, viewparent, particleContainer): def __init__(self, viewparent, particleContainer):
super(ParticleEditor, self).__init__() super(ParticleEditor, self).__init__()
...@@ -146,6 +146,7 @@ class ParticleEditor(QtCore.QObject): ...@@ -146,6 +146,7 @@ class ParticleEditor(QtCore.QObject):
self.viewparent.resetContourIndices() self.viewparent.resetContourIndices()
self.viewparent.addParticleContour(newContour, len(self.viewparent.contourItems)) self.viewparent.addParticleContour(newContour, len(self.viewparent.contourItems))
self.particleAssignmentChanged.emit()
#TODO: INCLUDE SANITY CHECK!!!!!!!!! #TODO: INCLUDE SANITY CHECK!!!!!!!!!
@QtCore.pyqtSlot(list, str) @QtCore.pyqtSlot(list, str)
...@@ -177,6 +178,7 @@ class ParticleEditor(QtCore.QObject): ...@@ -177,6 +178,7 @@ class ParticleEditor(QtCore.QObject):
for ind in self.storedIndices: for ind in self.storedIndices:
self.viewparent.removeParticleContour(ind) self.viewparent.removeParticleContour(ind)
self.particleAssignmentChanged.emit()
self.viewparent.resetContourIndices() self.viewparent.resetContourIndices()
self.viewparent.addParticleContour(newContour, len(self.viewparent.contourItems)) self.viewparent.addParticleContour(newContour, len(self.viewparent.contourItems))
......
...@@ -270,14 +270,14 @@ class SampleView(QtWidgets.QGraphicsView): ...@@ -270,14 +270,14 @@ class SampleView(QtWidgets.QGraphicsView):
if self.particleEditor is None: if self.particleEditor is None:
self.particleEditor = ParticleEditor(self, self.dataset.particleContainer) self.particleEditor = ParticleEditor(self, self.dataset.particleContainer)
#try disconnecting the signals. If they are connected multiple times, the functions will run accordingly... #try disconnecting the signals. If they are connected multiple times, the functions will run accordingly...
tryDisconnectingSignal(self.particleEditor.particleContoursChanged) # tryDisconnectingSignal(self.particleEditor.particleContoursChanged)
tryDisconnectingSignal(self.particleEditor.particleAssignmentChanged) tryDisconnectingSignal(self.particleEditor.particleAssignmentChanged)
self.particleEditor.particleContoursChanged.connect(self.resetParticleContours) # self.particleEditor.particleContoursChanged.connect(self.resetParticleContours)
if self.analysiswidget is not None: if self.analysiswidget is not None:
self.particleEditor.particleContoursChanged.connect(self.analysiswidget.updateDisplays) # self.particleEditor.particleContoursChanged.connect(self.analysiswidget.updateHistogramsAndContours)
self.particleEditor.particleAssignmentChanged.connect(self.analysiswidget.updateDisplays) self.particleEditor.particleAssignmentChanged.connect(self.analysiswidget.updateHistogramsAndContours)
def setMicroscopeMode(self): def setMicroscopeMode(self):
if self.ramanSwitchNeeded: if self.ramanSwitchNeeded:
...@@ -320,7 +320,7 @@ class SampleView(QtWidgets.QGraphicsView): ...@@ -320,7 +320,7 @@ class SampleView(QtWidgets.QGraphicsView):
if event.button()==QtCore.Qt.MiddleButton: if event.button()==QtCore.Qt.MiddleButton:
self.drag = event.pos() self.drag = event.pos()
elif self.particlePainter is None: if self.particlePainter is None:
if event.button()==QtCore.Qt.LeftButton: if event.button()==QtCore.Qt.LeftButton:
self.checkForContourSelection(event) self.checkForContourSelection(event)
...@@ -336,7 +336,7 @@ class SampleView(QtWidgets.QGraphicsView): ...@@ -336,7 +336,7 @@ class SampleView(QtWidgets.QGraphicsView):
p0 = self.mapToScene(event.pos()) p0 = self.mapToScene(event.pos())
super(SampleView, self).mousePressEvent(event) super(SampleView, self).mousePressEvent(event)
elif self.particlePainter is not None: else:
self.particlePainter.mousePressEvent(event) self.particlePainter.mousePressEvent(event)
def mouseMoveEvent(self, event): def mouseMoveEvent(self, event):
...@@ -412,14 +412,13 @@ class SampleView(QtWidgets.QGraphicsView): ...@@ -412,14 +412,13 @@ class SampleView(QtWidgets.QGraphicsView):
for index, cnt in enumerate(self.contourItems): for index, cnt in enumerate(self.contourItems):