Commit 83cdeb70 authored by JosefBrandt's avatar JosefBrandt

Before refactoring analysis navigation....

parent 47db59a2
This diff is collapsed.
......@@ -254,9 +254,6 @@ class ParticleContainer(object):
for index in sorted(indexList, reverse=True):
particle = self.getParticleOfIndex(index) #just for asserting to have the correct particle!
del self.particles[index]
# particle = self.getParticleOfIndex(index)
# print('removing particle of index', index)
# self.particles.remove(particle)
def resetParticleIndices(self):
for newIndex, particle in enumerate(self.particles):
......
......@@ -161,6 +161,7 @@ class ParticlePainter(QtWidgets.QGraphicsItem):
for poly in self.polygons:
painter.setBrush(QtGui.QColor(200, 200, 255, 128))
painter.drawPolygon(poly)
\ No newline at end of file
......@@ -105,7 +105,7 @@ class ParticleContextMenu(QtWidgets.QMenu):
class ParticleEditor(QtCore.QObject):
particleContoursChanged = QtCore.pyqtSignal()
# particleContoursChanged = QtCore.pyqtSignal()
particleAssignmentChanged = QtCore.pyqtSignal()
def __init__(self, viewparent, particleContainer):
super(ParticleEditor, self).__init__()
......@@ -146,6 +146,7 @@ class ParticleEditor(QtCore.QObject):
self.viewparent.resetContourIndices()
self.viewparent.addParticleContour(newContour, len(self.viewparent.contourItems))
self.particleAssignmentChanged.emit()
#TODO: INCLUDE SANITY CHECK!!!!!!!!!
@QtCore.pyqtSlot(list, str)
......@@ -177,6 +178,7 @@ class ParticleEditor(QtCore.QObject):
for ind in self.storedIndices:
self.viewparent.removeParticleContour(ind)
self.particleAssignmentChanged.emit()
self.viewparent.resetContourIndices()
self.viewparent.addParticleContour(newContour, len(self.viewparent.contourItems))
......
......@@ -270,14 +270,14 @@ class SampleView(QtWidgets.QGraphicsView):
if self.particleEditor is None:
self.particleEditor = ParticleEditor(self, self.dataset.particleContainer)
#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)
self.particleEditor.particleContoursChanged.connect(self.resetParticleContours)
# self.particleEditor.particleContoursChanged.connect(self.resetParticleContours)
if self.analysiswidget is not None:
self.particleEditor.particleContoursChanged.connect(self.analysiswidget.updateDisplays)
self.particleEditor.particleAssignmentChanged.connect(self.analysiswidget.updateDisplays)
# self.particleEditor.particleContoursChanged.connect(self.analysiswidget.updateHistogramsAndContours)
self.particleEditor.particleAssignmentChanged.connect(self.analysiswidget.updateHistogramsAndContours)
def setMicroscopeMode(self):
if self.ramanSwitchNeeded:
......@@ -320,7 +320,7 @@ class SampleView(QtWidgets.QGraphicsView):
if event.button()==QtCore.Qt.MiddleButton:
self.drag = event.pos()
elif self.particlePainter is None:
if self.particlePainter is None:
if event.button()==QtCore.Qt.LeftButton:
self.checkForContourSelection(event)
......@@ -336,7 +336,7 @@ class SampleView(QtWidgets.QGraphicsView):
p0 = self.mapToScene(event.pos())
super(SampleView, self).mousePressEvent(event)
elif self.particlePainter is not None:
else:
self.particlePainter.mousePressEvent(event)
def mouseMoveEvent(self, event):
......@@ -412,14 +412,13 @@ class SampleView(QtWidgets.QGraphicsView):
for index, cnt in enumerate(self.contourItems):
if cnt.polygon.containsPoint(p, QtCore.Qt.OddEvenFill): #clicked on particle
if not event.modifiers()==QtCore.Qt.ShiftModifier:
addContourToSelection(cnt)
self.analysiswidget.selectParticleOfIndex(cnt.particleIndex, centerOn=False)
self.analysiswidget.selectParticleOfIndex(cnt.particleIndex)
else:
if cnt.particleIndex not in self.selectedParticleIndices:
addContourToSelection(cnt)
self.analysiswidget.selectParticleOfIndex(cnt.particleIndex, centerOn=False)
self.analysiswidget.selectParticleOfIndex(cnt.particleIndex)
elif cnt.particleIndex in self.selectedParticleIndices:
removeContourFromSelection(cnt)
......@@ -587,13 +586,6 @@ class SampleView(QtWidgets.QGraphicsView):
if self.dataset is not None:
for particleIndex, contour in enumerate(self.dataset.particleContainer.getParticleContours()):
self.addParticleContour(contour, particleIndex)
# newCnt = SegmentationContour(self, contour)
# newCnt.setIndex(particleIndex)
# assignment = self.dataset.particleContainer.getParticleAssignmentByIndex(particleIndex)
# color = getColorFromNameWithSeed(assignment, self.dataset.colorSeed)
# newCnt.setColor(QtGui.QColor(color[0], color[1], color[2], 255))
# self.contourItems.append(newCnt)
# self.scene().addItem(newCnt)
self.update()
print('resetted contours: {} ms'.format(round((time.time()-t0)*1000)))
......@@ -624,6 +616,12 @@ class SampleView(QtWidgets.QGraphicsView):
item.setHighLight(False)
self.ramanscanitems[index].setHighLight(True)
def highLightContour(self, index):
for contour in self.contourItems:
contour.isSelected = False
self.contourItems[index].isSelected = True
def centerOnRamanIndex(self, index, centerOn=True, highlightContour=True):
if centerOn:
self.centerOn(self.ramanscanitems[index])
......
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