Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Open sidebar
GEPARD
GEPARD
Commits
83cdeb70
Commit
83cdeb70
authored
Jul 16, 2019
by
JosefBrandt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Before refactoring analysis navigation....
parent
47db59a2
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
121 additions
and
73 deletions
+121
-73
analysis/analysisview.py
analysis/analysisview.py
+103
-53
analysis/particleInfo.py
analysis/particleInfo.py
+0
-3
analysis/particlePainter.py
analysis/particlePainter.py
+1
-0
analysis/particleeditor.py
analysis/particleeditor.py
+3
-1
sampleview.py
sampleview.py
+14
-16
No files found.
analysis/analysisview.py
View file @
83cdeb70
...
...
@@ -44,8 +44,8 @@ except:
class
ParticleAnalysis
(
QtWidgets
.
QMainWindow
):
def
__init__
(
self
,
dataset
,
parent
=
None
):
super
(
ParticleAnalysis
,
self
).
__init__
(
parent
)
def
__init__
(
self
,
dataset
,
view
parent
=
None
):
super
(
ParticleAnalysis
,
self
).
__init__
(
view
parent
)
self
.
setGeometry
(
100
,
100
,
1680
,
1050
)
self
.
setWindowTitle
(
'Results of polymer analysis'
)
self
.
layout
=
QtWidgets
.
QHBoxLayout
()
...
...
@@ -53,7 +53,7 @@ class ParticleAnalysis(QtWidgets.QMainWindow):
self
.
widget
.
setLayout
(
self
.
layout
)
self
.
setCentralWidget
(
self
.
widget
)
self
.
parent
=
parent
self
.
view
parent
=
view
parent
self
.
dataset
=
dataset
self
.
particleContainer
=
dataset
.
particleContainer
self
.
editor
=
ParticleEditor
(
self
.
particleContainer
,
self
)
...
...
@@ -114,21 +114,18 @@ class ParticleAnalysis(QtWidgets.QMainWindow):
self
.
navigationGroup
.
setDisabled
(
True
)
navigationLayout
=
QtWidgets
.
QHBoxLayout
()
self
.
specNumberSelector
=
QtWidgets
.
QSpinBox
()
self
.
specNumberSelector
.
setMinimumWidth
(
1
5
0
)
self
.
specNumberSelector
.
setMinimumWidth
(
1
0
0
)
self
.
specNumberSelector
.
setMinimum
(
1
)
self
.
specNumberSelector
.
setMaximum
(
1E6
)
self
.
jumpToSpecBtn
=
QtWidgets
.
QPushButton
(
'Jump To Spectrum of Number:'
)
self
.
jumpToSpecBtn
.
released
.
connect
(
self
.
jumpToSpectrum
OfNumber
)
self
.
jumpToSpecBtn
.
released
.
connect
(
self
.
jumpTo
Indicated
Spectrum
)
self
.
typeSelectorCombo
=
QtWidgets
.
QComboBox
()
self
.
typeSelectorCombo
.
currentIndexChanged
.
connect
(
self
.
displayNewPolymerType
)
self
.
typeSelectorCombo
.
setMinimumWidth
(
150
)
self
.
particleSelector
=
QtWidgets
.
QSpinBox
()
self
.
particleSelector
.
valueChanged
.
connect
(
self
.
updateSpecPlotToSelectedParticle
)
self
.
particleNumberLabel
=
QtWidgets
.
QLabel
(
'of xx particles; '
)
self
.
spectrumSelector
=
QtWidgets
.
QSpinBox
()
self
.
spectrumSelector
.
valueChanged
.
connect
(
self
.
selectSpectrum
)
self
.
spectrumNumberLabel
=
QtWidgets
.
QLabel
(
'of xx spectra'
)
for
spinbox
in
[
self
.
particleSelector
,
self
.
spectrumSelector
]:
spinbox
.
setMinimum
(
1
)
...
...
@@ -220,11 +217,10 @@ class ParticleAnalysis(QtWidgets.QMainWindow):
self
.
createMenus
()
self
.
applyHQIThresholdToResults
()
self
.
createHistogramData
()
self
.
updateDisplays
()
self
.
initializeSpecPlot
()
self
.
displayNewPolymerType
()
self
.
updateSpecPlotToSelectedParticle
()
#
self.
createPolymerOverlay
()
self
.
updateHistogramsAndContours
()
def
createActions
(
self
):
self
.
loadTrueMatchAct
=
QtWidgets
.
QAction
(
"Load &TrueMatch Results"
,
self
)
...
...
@@ -253,6 +249,9 @@ class ParticleAnalysis(QtWidgets.QMainWindow):
self
.
seedAct
=
QtWidgets
.
QAction
(
"&Set Color Seed"
,
self
)
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
.
triggered
.
connect
(
self
.
launchDBManager
)
...
...
@@ -272,7 +271,7 @@ class ParticleAnalysis(QtWidgets.QMainWindow):
self
.
overlayActGroup
=
QtWidgets
.
QActionGroup
(
self
.
dispMenu
)
self
.
overlayActGroup
.
setExclusive
(
True
)
self
.
overlayActGroup
.
triggered
.
connect
(
self
.
updateContourColors
)
self
.
overlayActGroup
.
triggered
.
connect
(
self
.
update
D
is
play
s
)
self
.
overlayActGroup
.
triggered
.
connect
(
self
.
update
H
is
togramsAndContour
s
)
for
act
in
[
self
.
noOverlayAct
,
self
.
selOverlayAct
,
self
.
fullOverlayAct
]:
self
.
dispMenu
.
addAction
(
act
)
...
...
@@ -281,8 +280,9 @@ class ParticleAnalysis(QtWidgets.QMainWindow):
self
.
dispMenu
.
addSeparator
()
self
.
dispMenu
.
addActions
([
self
.
transpAct
,
self
.
hideLabelAct
,
self
.
darkenAct
,
self
.
seedAct
])
self
.
refMenu
=
QtWidgets
.
QMenu
(
"&References"
)
self
.
refMenu
.
addAction
(
self
.
databaseAct
)
self
.
toolMenu
=
QtWidgets
.
QMenu
(
"&Tools"
)
self
.
toolMenu
.
addAction
(
self
.
removeTinyParticlesAct
)
self
.
toolMenu
.
addAction
(
self
.
databaseAct
)
self
.
exportMenu
=
QtWidgets
.
QMenu
(
"&Export"
,
self
)
self
.
exportMenu
.
addAction
(
self
.
expExcelAct
)
...
...
@@ -290,7 +290,7 @@ class ParticleAnalysis(QtWidgets.QMainWindow):
self
.
menuBar
().
addMenu
(
self
.
importMenu
)
self
.
menuBar
().
addMenu
(
self
.
dispMenu
)
self
.
menuBar
().
addMenu
(
self
.
ref
Menu
)
self
.
menuBar
().
addMenu
(
self
.
tool
Menu
)
self
.
menuBar
().
addMenu
(
self
.
exportMenu
)
def
launchDBManager
(
self
):
...
...
@@ -328,7 +328,7 @@ class ParticleAnalysis(QtWidgets.QMainWindow):
self
.
dataset
.
resultParams
[
'minHQI'
]
=
hqi
self
.
dataset
.
save
()
self
.
createHistogramData
()
self
.
update
D
is
play
s
()
self
.
update
H
is
togramsAndContour
s
()
def
createHistogramData
(
self
):
###Handle Checkboxes for all polymers...
...
...
@@ -342,7 +342,7 @@ class ParticleAnalysis(QtWidgets.QMainWindow):
del
i
self
.
showTotalSelector
.
setParent
(
None
)
self
.
showTotalSelector
.
setDisabled
(
False
)
self
.
showTotalSelector
.
stateChanged
.
connect
(
self
.
update
D
is
play
s
)
self
.
showTotalSelector
.
stateChanged
.
connect
(
self
.
update
H
is
togramsAndContour
s
)
del
self
.
resultCheckBoxes
del
self
.
resultCheckBoxesLayout
...
...
@@ -369,7 +369,7 @@ class ParticleAnalysis(QtWidgets.QMainWindow):
if
polymer
in
self
.
lastSelectedCheckBoxNames
:
self
.
polymerCheckBoxes
[
index
].
setChecked
(
True
)
self
.
polymerCheckBoxes
[
index
].
stateChanged
.
connect
(
self
.
update
D
is
play
s
)
self
.
polymerCheckBoxes
[
index
].
stateChanged
.
connect
(
self
.
update
H
is
togramsAndContour
s
)
self
.
resultCheckBoxesLayout
.
addStretch
()
self
.
resultCheckBoxes
.
setLayout
(
self
.
resultCheckBoxesLayout
)
...
...
@@ -381,10 +381,10 @@ class ParticleAnalysis(QtWidgets.QMainWindow):
self
.
expSQLAct
.
setDisabled
(
False
)
self
.
navigationGroup
.
setEnabled
(
True
)
self
.
typeSelectorCombo
.
currentIndexChanged
.
disconnect
()
#
self.typeSelectorCombo.currentIndexChanged.disconnect()
self
.
typeSelectorCombo
.
clear
()
self
.
typeSelectorCombo
.
addItems
(
uniquePolymers
)
self
.
typeSelectorCombo
.
currentIndexChanged
.
connect
(
self
.
displayNewPolymerType
)
#
self.typeSelectorCombo.currentIndexChanged.connect(self.displayNewPolymerType)
self
.
polymerIndex
=
self
.
typeSelectorCombo
.
currentIndex
()
# if self.lastSpectrumInFocus is not None:
...
...
@@ -395,7 +395,7 @@ class ParticleAnalysis(QtWidgets.QMainWindow):
# print('displaying new type with resetting index')
# self.displayNewPolymerType()
def
update
D
is
play
s
(
self
):
def
update
H
is
togramsAndContour
s
(
self
):
self
.
createHistogramData
()
t0
=
time
.
time
()
self
.
updateTypeHistogram
()
...
...
@@ -468,12 +468,10 @@ class ParticleAnalysis(QtWidgets.QMainWindow):
self
.
lastSelectedCheckBoxNames
=
self
.
getSelectedPolymers
()
def
updateSpecPlot
(
self
,
centerOn
=
True
,
highlightContour
=
True
):
def
updateSpecPlot
(
self
):
particleSize
=
self
.
particleContainer
.
getSizeOfParticleByIndex
(
self
.
currentParticleIndex
)
hqi
=
self
.
particleContainer
.
getHQIOfSpectrumIndex
(
self
.
currentSpectrumIndex
)
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
if
self
.
refSelector
.
isEnabled
()
and
self
.
refSelector
.
currentText
()
!=
''
:
...
...
@@ -482,7 +480,7 @@ class ParticleAnalysis(QtWidgets.QMainWindow):
self
.
specPlot
.
updateReferenceSpectrum
(
ref
[:,
0
],
ref
[:,
1
])
def
updateContourColors
(
self
):
contours
=
self
.
parent
.
contourItems
contours
=
self
.
view
parent
.
contourItems
alpha
=
(
64
if
self
.
transpAct
.
isChecked
()
else
255
)
selectedPolymers
=
self
.
getSelectedPolymers
()
...
...
@@ -505,16 +503,31 @@ class ParticleAnalysis(QtWidgets.QMainWindow):
color
=
getColorFromNameWithSeed
(
polymer
,
self
.
dataset
.
colorSeed
)
color
=
QtGui
.
QColor
(
color
[
0
],
color
[
1
],
color
[
2
],
255
)
legendItems
.
append
((
polymer
,
color
))
self
.
parent
.
updateLegend
(
legendItems
)
self
.
view
parent
.
updateLegend
(
legendItems
)
def
getSelectedPolymers
(
self
):
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
assert
specIndex
is
not
None
print
(
'
specIndex
'
,
specIndex
)
partIndex
=
self
.
particleContainer
.
getParticleIndexContainingSpecIndex
(
specIndex
)
print
(
'partIndex'
,
partIndex
)
assignment
=
self
.
particleContainer
.
getParticleAssignmentByIndex
(
partIndex
)
self
.
typeSelectorCombo
.
setCurrentText
(
assignment
)
...
...
@@ -524,18 +537,26 @@ class ParticleAnalysis(QtWidgets.QMainWindow):
specIndices
=
self
.
particleContainer
.
getSpectraIndicesOfParticle
(
partIndex
)
self
.
spectrumSelector
.
setValue
(
specIndices
.
index
(
specIndex
)
+
1
)
if
centerOn
:
self
.
viewparent
.
centerOnRamanIndex
(
self
.
currentSpectrumIndex
,
centerOn
=
True
,
highlightContour
=
True
)
self
.
viewparent
.
highLightContour
(
self
.
getParticleIndexFromParticleSelector
())
def
selectParticleOfIndex
(
self
,
particleIndex
,
centerOn
=
True
):
assignment
=
self
.
particleContainer
.
getParticleAssignmentByIndex
(
particleIndex
)
self
.
typeSelectorCombo
.
setCurrentText
(
assignment
)
###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
.
particleSelector
.
valueChanged
.
disconnect
()
particleIndices
=
self
.
particleContainer
.
getIndicesOfParticleType
(
assignment
)
self
.
particleSelector
.
setValue
(
particleIndices
.
index
(
particleIndex
)
+
1
)
self
.
particleSelector
.
valueChanged
.
connect
(
self
.
updateSpecPlotToSelectedParticle
)
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
):
polymerName
=
self
.
typeSelectorCombo
.
currentText
()
...
...
@@ -551,9 +572,9 @@ class ParticleAnalysis(QtWidgets.QMainWindow):
self
.
spectrumSelector
.
setMaximum
(
numSpectra
)
self
.
spectrumNumberLabel
.
setText
(
f
'of
{
numSpectra
}
Spectra'
)
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
()
if
polymerName
!=
''
:
self
.
currentParticleIndex
=
self
.
getParticleIndexFromParticleSelector
()
...
...
@@ -563,13 +584,13 @@ class ParticleAnalysis(QtWidgets.QMainWindow):
if
resetSpectrumCount
:
self
.
spectrumSelector
.
setValue
(
1
)
self
.
currentSpectrumIndex
=
self
.
getSpectrumIndexFromSpectrumSelector
()
self
.
updateSpecPlot
(
centerOn
)
def
selectSpectrum
(
self
):
self
.
currentSpectrumIndex
=
self
.
getSpectrumIndexFromSpectrumSelector
()
self
.
updateSpecPlot
()
# def selectSpectrum(self):
# self.currentSpectrumIndex = self.getSpectrumIndexFromSpectrumSelector()
# self.updateSpecPlot()
def
getSpectrumIndexFromSpectrumSelector
(
self
):
specIndicesOfParticle
=
self
.
particleContainer
.
getSpectraIndicesOfParticle
(
self
.
currentParticleIndex
)
try
:
...
...
@@ -582,24 +603,53 @@ class ParticleAnalysis(QtWidgets.QMainWindow):
return
particleIndicesOfType
[
self
.
particleSelector
.
value
()
-
1
]
def
darkenBackground
(
self
):
self
.
parent
.
darkenPixmap
=
self
.
darkenAct
.
isChecked
()
self
.
view
parent
.
darkenPixmap
=
self
.
darkenAct
.
isChecked
()
if
self
.
darkenAct
.
isChecked
():
self
.
parent
.
scene
().
setBackgroundBrush
(
QtGui
.
QColor
(
5
,
5
,
5
))
self
.
parent
.
item
.
setOpacity
(
0.2
)
self
.
view
parent
.
scene
().
setBackgroundBrush
(
QtGui
.
QColor
(
5
,
5
,
5
))
self
.
view
parent
.
item
.
setOpacity
(
0.2
)
else
:
self
.
parent
.
scene
().
setBackgroundBrush
(
QtCore
.
Qt
.
darkGray
)
self
.
parent
.
item
.
setOpacity
(
1
)
self
.
view
parent
.
scene
().
setBackgroundBrush
(
QtCore
.
Qt
.
darkGray
)
self
.
view
parent
.
item
.
setOpacity
(
1
)
def
updateColorSeed
(
self
):
text
,
ok
=
QtWidgets
.
QInputDialog
.
getText
(
self
,
'Color Seed'
,
'Enter New Seed here'
,
text
=
self
.
dataset
.
colorSeed
)
if
ok
:
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
):
hidden
=
self
.
hideLabelAct
.
isChecked
()
for
scanIndicator
in
self
.
parent
.
ramanscanitems
:
for
scanIndicator
in
self
.
view
parent
.
ramanscanitems
:
scanIndicator
.
hidden
=
hidden
scanIndicator
.
update
()
...
...
@@ -615,7 +665,7 @@ class ParticleAnalysis(QtWidgets.QMainWindow):
for
window
in
[
self
.
importWindow
,
self
.
dbWin
]:
try
:
window
.
close
()
except
:
pass
self
.
parent
.
imparent
.
particelAnalysisAct
.
setChecked
(
False
)
self
.
view
parent
.
imparent
.
particelAnalysisAct
.
setChecked
(
False
)
event
.
accept
()
...
...
analysis/particleInfo.py
View file @
83cdeb70
...
...
@@ -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
):
...
...
analysis/particlePainter.py
View file @
83cdeb70
...
...
@@ -164,3 +164,4 @@ class ParticlePainter(QtWidgets.QGraphicsItem):
\ No newline at end of file
analysis/particleeditor.py
View file @
83cdeb70
...
...
@@ -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
))
...
...
sampleview.py
View file @
83cdeb70
...
...
@@ -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
.
update
D
is
play
s
)
self
.
particleEditor
.
particleAssignmentChanged
.
connect
(
self
.
analysiswidget
.
update
D
is
play
s
)
#
self.particleEditor.particleContoursChanged.connect(self.analysiswidget.update
H
is
togramsAndContour
s)
self
.
particleEditor
.
particleAssignmentChanged
.
connect
(
self
.
analysiswidget
.
update
H
is
togramsAndContour
s
)
def
setMicroscopeMode
(
self
):
if
self
.
ramanSwitchNeeded
:
...
...
@@ -320,7 +320,7 @@ class SampleView(QtWidgets.QGraphicsView):
if
event
.
button
()
==
QtCore
.
Qt
.
MiddleButton
:
self
.
drag
=
event
.
pos
()
el
if
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
)
el
if
self
.
particlePainter
is
not
Non
e
:
el
s
e
:
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
])
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment