Commit 582761bd authored by JosefBrandt's avatar JosefBrandt

Modularization of analysisview, DocStrings

parent 07883df1
...@@ -10,3 +10,5 @@ analysis/database_config\.txt ...@@ -10,3 +10,5 @@ analysis/database_config\.txt
*.c *.c
external/build/ external/build/
.idea/
...@@ -135,7 +135,7 @@ class GEPARDMainWindow(QtWidgets.QMainWindow): ...@@ -135,7 +135,7 @@ class GEPARDMainWindow(QtWidgets.QMainWindow):
self.openAct.setShortcut("Ctrl+O") self.openAct.setShortcut("Ctrl+O")
self.openAct.triggered.connect(self.open) self.openAct.triggered.connect(self.open)
self.importAct = QtWidgets.QAction("&Import Project...", self) self.importAct = QtWidgets.QAction("&Import Zeiss Project...", self)
self.importAct.setShortcut("Ctrl+I") self.importAct.setShortcut("Ctrl+I")
self.importAct.triggered.connect(self.importProject) self.importAct.triggered.connect(self.importProject)
......
...@@ -23,9 +23,168 @@ from PyQt5 import QtWidgets, QtGui, QtCore ...@@ -23,9 +23,168 @@ from PyQt5 import QtWidgets, QtGui, QtCore
from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg as FigureCanvas from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg as FigureCanvas
from matplotlib.figure import Figure from matplotlib.figure import Figure
from matplotlib.backends.backend_qt5agg import NavigationToolbar2QT as NavigationToolbar from matplotlib.backends.backend_qt5agg import NavigationToolbar2QT as NavigationToolbar
import numpy as np
from .colorlegend import getColorFromNameWithSeed
class ParticleIndicator(QtWidgets.QPushButton): class SizeHistogramPlot(QtWidgets.QGroupBox):
def __init__(self, dataset):
super(SizeHistogramPlot, self).__init__()
self.dataset = dataset
self.minX = 3
self.maxX = 1E4
self.fontsize = 15
layout = QtWidgets.QHBoxLayout()
self.setLayout(layout)
self.sizeHistogramCanvas = FigureCanvas(Figure())
self.sizeHist_ax = self.sizeHistogramCanvas.figure.subplots()
self.sizeHist_ax.axis('off')
self.sizeHistogramCanvas.figure.subplots_adjust(left=0.1, top=0.93, bottom=0.15, right=0.995)
histNavigation = NavigationToolbar(self.sizeHistogramCanvas, self)
histNavigation.setOrientation(QtCore.Qt.Vertical)
histNavigation.setFixedWidth(50)
layout.addWidget(histNavigation)
layout.addWidget(self.sizeHistogramCanvas)
def drawHistograms(self, listOfHistograms):
if type(listOfHistograms) != list:
assert type(listOfHistograms) == SizeHistogramData
listOfHistograms = [listOfHistograms]
self.resetPlotFormat()
self.adjustPlotLimits(listOfHistograms)
for histData in listOfHistograms:
self.drawHistogram(histData)
self.drawLegend()
self.sizeHistogramCanvas.draw()
def resetPlotFormat(self):
self.sizeHist_ax.clear()
self.sizeHist_ax.axis('on')
self.sizeHist_ax.tick_params(axis='both', which='both', labelsize = self.fontsize)
self.sizeHist_ax.set_xlabel('Size (µm)', fontsize = self.fontsize)
self.sizeHist_ax.set_ylabel('Number', fontsize = self.fontsize)
self.sizeHist_ax.set_title('Size Distribution', fontsize=self.fontsize)
def adjustPlotLimits(self, listOfHistograms):
xmin, xmax = None, None
for histData in listOfHistograms:
if xmin is None:
xmin = np.clip(10**histData.minSizeExponent, self.minX, self.maxX)
xmax = np.clip(10**histData.maxSizeExponent, self.minX, self.maxX)
else:
currentXMin = np.clip(10**histData.minSizeExponent, self.minX, self.maxX)
currentXMax = np.clip(10**histData.maxSizeExponent, self.minX, self.maxX)
xmin = min(xmin, currentXMin)
xmax = max(xmax, currentXMax)
self.sizeHist_ax.set_xlim(xmin, xmax)
def drawHistogram(self, histData):
label = histData.label
x_values = histData.sizeHist_binCenters
y_values = histData.sizeHist_abundancies
color = getColorFromNameWithSeed(label, self.dataset.colorSeed, base255=False)
self.sizeHist_ax.semilogx(x_values, y_values, label=label, color=color)
def drawLegend(self):
self.sizeHist_ax.legend(prop = {'size': self.fontsize})
class SizeHistogramData(object):
def __init__(self, label, listOfSizes):
self.label = label
self.listOfSizes = listOfSizes
self.minSizeExponent = 0.1
self.maxSizeExponent = 3
self.numBins = 20
self.sizeHist_binCenters = None
self.sizeHist_abundancies = None
self.createSizeHistogramData()
def createSizeHistogramData(self):
assert self.listOfSizes is not None
bins = np.logspace(self.minSizeExponent, self.maxSizeExponent, self.numBins)
self.sizeHist_abundancies, binEdges = np.histogram(self.listOfSizes, bins)
self.sizeHist_binCenters = self.getBinCenters(binEdges)
def getBinCenters(self, binEdges):
binCenters = []
for i in range(self.numBins-1):
currentCenter = np.mean((binEdges[i], binEdges[i+1]))
binCenters.append(currentCenter)
return binCenters
class TypeHistogramPlot(QtWidgets.QScrollArea):
indexClicked = QtCore.pyqtSignal(int)
def __init__(self, dataset):
super(TypeHistogramPlot, self).__init__()
self.dataset = dataset
self.view = QtWidgets.QWidget(self)
self.view.setCursor(QtGui.QCursor(QtCore.Qt.WhatsThisCursor))
self.view.setMinimumWidth(250)
group = QtWidgets.QGroupBox('Polymer Type Distribution', self.view)
self.indicatorbox = QtWidgets.QVBoxLayout()
self.indicatorbox.setContentsMargins(5,5,5,5)
group.setLayout(self.indicatorbox)
hbox = QtWidgets.QHBoxLayout()
hbox.addWidget(group)
self.view.setLayout(hbox)
self.setWidgetResizable(True)
self.setWidget(self.view)
self.setAlignment(QtCore.Qt.AlignHCenter)
self.abundancyIndicators = []
def updateTypeHistogram(self, typeHistogram):
self.resetPlot()
colorList = []
abundancyList = []
labelList = []
for polymType in typeHistogram:
text = f'{typeHistogram[polymType]} x {polymType}'
labelList.append(text)
abundancyList.append(typeHistogram[polymType])
curColor = getColorFromNameWithSeed(polymType, self.dataset.colorSeed)
colorList.append(QtGui.QColor(*curColor))
types = list(zip(abundancyList, labelList, colorList))
numtotal= sum(abundancyList)
for index, entry in enumerate(types):
num, text, color = entry
indicator = AbundancyIndicator(num, numtotal, color, text)
self.indicatorbox.addWidget(indicator)
indicator.clicked.connect(self._getIndexFunction(index))
self.abundancyIndicators.append(indicator)
self.indicatorbox.addStretch()
self.view.update()
def resetPlot(self):
for indicator in self.abundancyIndicators:
self.indicatorbox.removeWidget(indicator)
indicator.setParent(None)
indicator.destroy()
self.indicatorbox.takeAt(0)
self.abundancyIndicators = []
def _getIndexFunction(self, index):
return lambda : self.indexClicked.emit(index)
class AbundancyIndicator(QtWidgets.QPushButton):
def __init__(self, number, numtotal, color, text, parent=None): def __init__(self, number, numtotal, color, text, parent=None):
super().__init__(parent) super().__init__(parent)
self.number = number self.number = number
...@@ -60,55 +219,13 @@ class ParticleIndicator(QtWidgets.QPushButton): ...@@ -60,55 +219,13 @@ class ParticleIndicator(QtWidgets.QPushButton):
self.text) self.text)
qp.end() qp.end()
class TypeHistogramView(QtWidgets.QScrollArea):
indexClicked = QtCore.pyqtSignal(int)
def __init__(self, parent=None):
super().__init__(parent)
self.view = QtWidgets.QWidget(self)
self.view.setCursor(QtGui.QCursor(QtCore.Qt.WhatsThisCursor))
self.view.setMinimumWidth(250)
group = QtWidgets.QGroupBox('Polymer Type Distribution', self.view)
self.indicatorbox = QtWidgets.QVBoxLayout()
self.indicatorbox.setContentsMargins(5,5,5,5)
group.setLayout(self.indicatorbox)
hbox = QtWidgets.QHBoxLayout()
hbox.addWidget(group)
self.view.setLayout(hbox)
self.setWidgetResizable(True)
self.setWidget(self.view)
self.setAlignment(QtCore.Qt.AlignHCenter)
self.widgets = []
def updateTypeHistogram(self, types):
for pi in self.widgets:
self.indicatorbox.removeWidget(pi)
pi.setParent(None)
pi.destroy()
self.indicatorbox.takeAt(0)
self.widgets = []
numtotal = sum([num for num, text, color in types])
def getIndexFunction(index):
return lambda : self.indexClicked.emit(index)
for index, entry in enumerate(types):
num, text, color = entry
pi = ParticleIndicator(num, numtotal, color, text)
self.indicatorbox.addWidget(pi)
pi.clicked.connect(getIndexFunction(index))
self.widgets.append(pi)
self.indicatorbox.addStretch()
self.view.update()
class SpectraPlot(QtWidgets.QGroupBox): class SpectraPlot(QtWidgets.QGroupBox):
def __init__(self, dataset): def __init__(self, dataset):
super(SpectraPlot, self).__init__() super(SpectraPlot, self).__init__()
self.dataset = dataset self.dataset = dataset
self.spectra = None self.spectra = None
self.fontsize = 15
layout = QtWidgets.QHBoxLayout() layout = QtWidgets.QHBoxLayout()
self.canvas = FigureCanvas(Figure()) self.canvas = FigureCanvas(Figure())
...@@ -131,14 +248,14 @@ class SpectraPlot(QtWidgets.QGroupBox): ...@@ -131,14 +248,14 @@ class SpectraPlot(QtWidgets.QGroupBox):
#draw Sample Spectrum #draw Sample Spectrum
self.spec_axis.axis("on") self.spec_axis.axis("on")
self.spec_axis.clear() self.spec_axis.clear()
self.spec_axis.tick_params(axis='both', which='both', labelsize=15) self.spec_axis.tick_params(axis='both', which='both', labelsize = self.fontsize)
self.spec_axis.set_xlabel('Wavenumber (cm-1)', fontsize = 15) self.spec_axis.set_xlabel('Wavenumber (cm-1)', fontsize = self.fontsize)
self.spec_axis.set_ylabel('Counts', fontsize = 15) self.spec_axis.set_ylabel('Counts', fontsize = self.fontsize)
if self.spectra is not None: if self.spectra is not None:
specInfo = f'ScanPoint Number {specIndex+1}, with assignment {assignment} (hqi = {hqi})' specInfo = f'ScanPoint Number {specIndex+1}, with assignment {assignment} (hqi = {hqi})'
self.spec_axis.plot(self.spectra[:, 0], self.spectra[:, specIndex+1]) self.spec_axis.plot(self.spectra[:, 0], self.spectra[:, specIndex+1])
self.spec_axis.set_title(specInfo, fontsize=13) self.spec_axis.set_title(specInfo, fontsize = self.fontsize)
self.spec_axis.set_xbound(100, (3400 if self.spectra[-1, 0] > 3400 else self.spectra[-1, 0])) self.spec_axis.set_xbound(100, (3400 if self.spectra[-1, 0] > 3400 else self.spectra[-1, 0]))
wavenumber_diff = list(self.spectra[:, 0]-100) wavenumber_diff = list(self.spectra[:, 0]-100)
...@@ -152,13 +269,10 @@ class SpectraPlot(QtWidgets.QGroupBox): ...@@ -152,13 +269,10 @@ class SpectraPlot(QtWidgets.QGroupBox):
def updateReferenceSpectrum(self, ref_wavenumber, ref_intensity): def updateReferenceSpectrum(self, ref_wavenumber, ref_intensity):
#draw Reference #draw Reference
self.reference_axis.clear() self.reference_axis.clear()
self.reference_axis.tick_params(axis='both', which='both', labelsize=15) self.reference_axis.tick_params(axis='both', which='both', labelsize = self.fontsize)
self.reference_axis.plot(ref_wavenumber, ref_intensity, color = 'r') self.reference_axis.plot(ref_wavenumber, ref_intensity, color = 'r')
self.reference_axis.set_ylabel('Ref. Intensity', fontsize = 15, color = 'r') self.reference_axis.set_ylabel('Ref. Intensity', fontsize = self.fontsize, color = 'r')
self.reference_axis.tick_params('y', colors = 'r') self.reference_axis.tick_params('y', colors = 'r')
self.reference_axis.set_xbound(100, (3400 if self.spectra[-1, 0] > 3400 else self.spectra[-1, 0])) self.reference_axis.set_xbound(100, (3400 if self.spectra[-1, 0] > 3400 else self.spectra[-1, 0]))
self.canvas.draw() self.canvas.draw()
\ No newline at end of file
\ No newline at end of file
...@@ -21,19 +21,14 @@ If not, see <https://www.gnu.org/licenses/>. ...@@ -21,19 +21,14 @@ If not, see <https://www.gnu.org/licenses/>.
""" """
from PyQt5 import QtCore, QtGui, QtWidgets from PyQt5 import QtCore, QtGui, QtWidgets
import numpy as np
import sys
import time
from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg as FigureCanvas
from matplotlib.figure import Figure
from matplotlib.backends.backend_qt5agg import NavigationToolbar2QT as NavigationToolbar
from .excelexport import ExpExcelDialog from .excelexport import ExpExcelDialog
from .analysisplots import TypeHistogramView, SpectraPlot from . import analysisplots
from . import analysiswidgets
from .loadresults import LoadTrueMatchResults from .loadresults import LoadTrueMatchResults
from .database import DataBaseWindow from .database import DataBaseWindow
from .colorlegend import getColorFromNameWithSeed from .colorlegend import getColorFromNameWithSeed
from .particleCharacterization import updateStatsOfParticlesIfNotManuallyEdited
try: try:
from .sqlexport import SQLExport from .sqlexport import SQLExport
...@@ -56,33 +51,18 @@ class ParticleAnalysis(QtWidgets.QMainWindow): ...@@ -56,33 +51,18 @@ class ParticleAnalysis(QtWidgets.QMainWindow):
self.particleContainer = dataset.particleContainer self.particleContainer = dataset.particleContainer
self.importWindow = None self.importWindow = None
self.findcoloredParticlesWindow = None
self.polymerCheckBoxes = []
self.lastSelectedCheckBoxNames = []
self.currentParticleIndex = 0 self.currentParticleIndex = 0
self.currentSpectrumIndex = 0 self.currentSpectrumIndex = 0
self.typeHistogramPlot = TypeHistogramView(self) self.typeHistogramPlot = analysisplots.TypeHistogramPlot(self.dataset)
self.sizeHistogramCanvas = FigureCanvas(Figure()) self.sizeHistogramPlot = analysisplots.SizeHistogramPlot(self.dataset)
self.specPlot = analysisplots.SpectraPlot(self.dataset)
sizeHistGroup = QtWidgets.QGroupBox()
sizeHistLayout = QtWidgets.QHBoxLayout()
self.sizeHist_ax = self.sizeHistogramCanvas.figure.subplots()
self.sizeHist_ax.axis('off')
self.sizeHistogramCanvas.figure.subplots_adjust(left=0.1, top=0.93, bottom=0.15, right=0.995)
histNavigation = NavigationToolbar(self.sizeHistogramCanvas, self)
histNavigation.setOrientation(QtCore.Qt.Vertical)
histNavigation.setFixedWidth(50)
sizeHistLayout.addWidget(histNavigation)
sizeHistLayout.addWidget(self.sizeHistogramCanvas)
sizeHistGroup.setLayout(sizeHistLayout)
self.specPlot = SpectraPlot(self.dataset)
splitter1 = QtWidgets.QSplitter(QtCore.Qt.Vertical) splitter1 = QtWidgets.QSplitter(QtCore.Qt.Vertical)
splitter1.addWidget(self.specPlot) splitter1.addWidget(self.specPlot)
splitter1.addWidget(sizeHistGroup) splitter1.addWidget(self.sizeHistogramPlot)
splitter2 = QtWidgets.QSplitter(QtCore.Qt.Horizontal) splitter2 = QtWidgets.QSplitter(QtCore.Qt.Horizontal)
splitter2.addWidget(splitter1) splitter2.addWidget(splitter1)
splitter2.addWidget(self.typeHistogramPlot) splitter2.addWidget(self.typeHistogramPlot)
...@@ -102,52 +82,14 @@ class ParticleAnalysis(QtWidgets.QMainWindow): ...@@ -102,52 +82,14 @@ class ParticleAnalysis(QtWidgets.QMainWindow):
referenceLayout.addWidget(self.refSelector) referenceLayout.addWidget(self.refSelector)
referenceLayout.addStretch() referenceLayout.addStretch()
referenceGroup.setLayout(referenceLayout) referenceGroup.setLayout(referenceLayout)
self.navigationGroup = QtWidgets.QGroupBox('Navigate through polymers') self.navigationToolbar = analysiswidgets.PolymerNavigationToolbar(self.particleContainer)
self.navigationGroup.setDisabled(True) self.navigationToolbar.WidgetsUpdated.connect(self.updateFromNavigationToolbar)
navigationLayout = QtWidgets.QHBoxLayout() self.navigationToolbar.JumpToIndicatedSpec.connect(self.jumpToIndicatedSpectrum)
self.specNumberSelector = QtWidgets.QSpinBox() self.viewparent.ParticleOfIndexSelected.connect(self.navigationToolbar.setWidgetsToNewParticleIndex)
self.specNumberSelector.setMinimumWidth(100)
self.specNumberSelector.setMinimum(1)
numSpectra = self.particleContainer.getNumberOfMeasurements()
self.specNumberSelector.setMaximum(numSpectra)
self.jumpToSpecBtn = QtWidgets.QPushButton('Jump To Spectrum of Number:')
self.jumpToSpecBtn.released.connect(self.jumpToIndicatedSpectrum)
self.typeSelectorCombo = QtWidgets.QComboBox()
self.typeSelectorCombo.setMinimumWidth(150)
self.typeSelectorCombo.currentIndexChanged.connect(self.setTypeSelector)
self.particleSelector = QtWidgets.QSpinBox()
self.particleSelector.valueChanged.connect(self.setParticleSelector)
self.particleNumberLabel = QtWidgets.QLabel('of xx particles; ')
self.spectrumSelector = QtWidgets.QSpinBox()
self.spectrumSelector.valueChanged.connect(self.setSpecSelector)
self.spectrumNumberLabel = QtWidgets.QLabel('of xx spectra')
for spinbox in [self.particleSelector, self.spectrumSelector]:
spinbox.setMinimum(1)
spinbox.setSingleStep(1)
spinbox.setValue(1)
navigationLayout.addWidget(self.jumpToSpecBtn)
navigationLayout.addWidget(self.specNumberSelector)
navigationLayout.addWidget(QtWidgets.QLabel('Select Polymer Type:'))
navigationLayout.addWidget(self.typeSelectorCombo)
navigationLayout.addStretch()
navigationLayout.addWidget(QtWidgets.QLabel('Select Particle'))
navigationLayout.addWidget(self.particleSelector)
navigationLayout.addWidget(self.particleNumberLabel)
navigationLayout.addStretch()
navigationLayout.addWidget(QtWidgets.QLabel('Select Spectrum'))
navigationLayout.addWidget(self.spectrumSelector)
navigationLayout.addWidget(self.spectrumNumberLabel)
self.navigationGroup.setLayout(navigationLayout)
topLayout = QtWidgets.QHBoxLayout() topLayout = QtWidgets.QHBoxLayout()
topLayout.addWidget(self.navigationGroup) topLayout.addWidget(self.navigationToolbar)
topLayout.addWidget(referenceGroup) topLayout.addWidget(referenceGroup)
viewLayout = QtWidgets.QVBoxLayout() viewLayout = QtWidgets.QVBoxLayout()
...@@ -175,29 +117,12 @@ class ParticleAnalysis(QtWidgets.QMainWindow): ...@@ -175,29 +117,12 @@ class ParticleAnalysis(QtWidgets.QMainWindow):
self.optionsGroup.setLayout(optionsLayout) self.optionsGroup.setLayout(optionsLayout)
self.optionsGroup.setMinimumWidth(175) self.optionsGroup.setMinimumWidth(175)
self.resultScrollarea = QtWidgets.QScrollArea(self) self.resultCheckBoxes = analysiswidgets.PolymerTypeCheckboxes()
self.resultScrollarea.setFixedWidth(250) self.resultCheckBoxes.PolymerCheckBoxToggled.connect(self.updatedPlotsAndContoursSelectively)
self.resultScrollarea.setWidgetResizable(True)
widget = QtWidgets.QWidget()
self.resultScrollarea.setWidget(widget)
self.layout_SArea = QtWidgets.QVBoxLayout(widget)
self.resultCheckBoxes = QtWidgets.QGroupBox('Display Polymer Types:')
self.resultCheckBoxesLayout = QtWidgets.QVBoxLayout()
self.showTotalSelector = QtWidgets.QCheckBox('Show Total Distribution')
self.showTotalSelector.setChecked(True)
self.showTotalSelector.setDisabled(True)
self.resultCheckBoxesLayout.addWidget(self.showTotalSelector)
self.resultCheckBoxesLayout.addStretch()
self.resultCheckBoxes.setLayout(self.resultCheckBoxesLayout)
self.layout_SArea.addWidget(self.resultCheckBoxes)
self.menuLayout = QtWidgets.QVBoxLayout() self.menuLayout = QtWidgets.QVBoxLayout()
self.menuLayout.addWidget(self.optionsGroup) self.menuLayout.addWidget(self.optionsGroup)
self.menuLayout.addWidget(self.resultScrollarea) self.menuLayout.addWidget(self.resultCheckBoxes)
self.layout.addLayout(self.menuLayout) self.layout.addLayout(self.menuLayout)
self.layout.addLayout(viewLayout) self.layout.addLayout(viewLayout)
...@@ -205,10 +130,8 @@ class ParticleAnalysis(QtWidgets.QMainWindow): ...@@ -205,10 +130,8 @@ class ParticleAnalysis(QtWidgets.QMainWindow):
self.createActions() self.createActions()
self.createMenus() self.createMenus()
self.applyHQIThresholdToResults() self.applyHQIThresholdToResults()
self.createHistogramData()
self.initializeSpecPlot() self.initializeSpecPlot()
self.setTypeSelector() self.navigationToolbar.updateWidgets()
self.updateHistogramsAndContours()
def createActions(self): def createActions(self):
self.loadTrueMatchAct = QtWidgets.QAction("Load &TrueMatch Results", self) self.loadTrueMatchAct = QtWidgets.QAction("Load &TrueMatch Results", self)
...@@ -217,9 +140,15 @@ class ParticleAnalysis(QtWidgets.QMainWindow): ...@@ -217,9 +140,15 @@ class ParticleAnalysis(QtWidgets.QMainWindow):
self.loadSpectraAct = QtWidgets.QAction("Load &Spectra", self) self.loadSpectraAct = QtWidgets.QAction("Load &Spectra", self)
self.loadSpectraAct.triggered.connect(self.initializeSpecPlot) self.loadSpectraAct.triggered.connect(self.initializeSpecPlot)
self.databaseAct = QtWidgets.QAction("&ManageDatabase", self) self.databaseAct = QtWidgets.QAction("&Manage reference spectra databases", self)
self.databaseAct.triggered.connect(self.launchDBManager) self.databaseAct.triggered.connect(self.launchDBManager)
self.findColorParticlesAct = QtWidgets.QAction("Navigate throuch &colored, not unknown particles", self)
self.findColorParticlesAct.triggered.connect(self.launchColoredParticleWindow)
self.recalculateParticleStatsAct = QtWidgets.QAction("&Recalculated particle stats", self)
self.recalculateParticleStatsAct.triggered.connect(self.recalculateParticleStats)
self.expExcelAct= QtWidgets.QAction("Export &Excel List", self) self.expExcelAct= QtWidgets.QAction("Export &Excel List", self)
self.expExcelAct.setDisabled(True) self.expExcelAct.setDisabled(True)
self.expExcelAct.triggered.connect(self.exportToExcel) self.expExcelAct.triggered.connect(self.exportToExcel)
...@@ -231,6 +160,10 @@ class ParticleAnalysis(QtWidgets.QMainWindow): ...@@ -231,6 +160,10 @@ class ParticleAnalysis(QtWidgets.QMainWindow):
self.getAndActivateActionsFromGepardMain() self.getAndActivateActionsFromGepardMain()
def getAndActivateActionsFromGepardMain(self): def getAndActivateActionsFromGepardMain(self):
"""
For user convenience, the actions from the Gepard main window are also added to the menubar of the analysis window.
:return:
"""
gepard = self.viewparent.imparent gepard = self.viewparent.imparent
self.noOverlayAct = gepard.noOverlayAct self.noOverlayAct = gepard.noOverlayAct
...@@ -241,7 +174,7 @@ class ParticleAnalysis(QtWidgets.QMainWindow): ...@@ -241,7 +174,7 @@ class ParticleAnalysis(QtWidgets.QMainWindow):
self.transpAct.triggered.connect(self.updateContourColors) self.transpAct.triggered.connect(self.updateContourColors)
self.hideLabelAct = gepard.hideLabelAct self.hideLabelAct = gepard.hideLabelAct
self.hideLabelAct.triggered.connect(self.show_hide_labels) self.hideLabelAct.triggered.connect(self.showOrHideSpecNumbers)
self.darkenAct = gepard.darkenAct self.darkenAct = gepard.darkenAct
self.darkenAct.triggered.connect(self.darkenBackground) self.darkenAct.triggered.connect(self.darkenBackground)
...@@ -264,7 +197,7 @@ class ParticleAnalysis(QtWidgets.QMainWindow): ...@@ -264,7 +197,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.updateHistogramsAndContours) self.overlayActGroup.triggered.connect(self.updatePlotsAndContours)
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)
...@@ -275,6 +208,8 @@ class ParticleAnalysis(QtWidgets.QMainWindow): ...@@ -275,6 +208,8 @@ class ParticleAnalysis(QtWidgets.QMainWindow):
self.toolMenu = QtWidgets.QMenu("&Tools") self.toolMenu = QtWidgets.QMenu("&Tools")
self.toolMenu.addAction(self.databaseAct) self.toolMenu.addAction(self.databaseAct)
self.toolMenu.addAction(self.findColorParticlesAct)
self.toolMenu.addAction(self.recalculateParticleStatsAct)
self.exportMenu = QtWidgets.QMenu("&Export", self) self.exportMenu = QtWidgets.QMenu("&Export", self)
self.exportMenu.addAction(self.expExcelAct) self.exportMenu.addAction(self.expExcelAct)
...@@ -285,16 +220,48 @@ class ParticleAnalysis(QtWidgets.QMainWindow): ...@@ -285,16 +220,48 @@ class ParticleAnalysis(QtWidgets.QMainWindow):
self.menuBar().addMenu(self.toolMenu)