Commit 16751ee9 authored by Hackmet's avatar Hackmet

Added database support,

several bugfixes
parent 86522ed2
This diff is collapsed.
This diff is collapsed.
......@@ -125,8 +125,8 @@ class ParticleEditor(object):
print('removing index from particles2spectra:', index)
del self.parent.parent.dataset.particles2spectra[index]
#save dataset
self.parent.parent.dataset.save()
#save data
self.parent.saveAnalysisResults()
#update contours in sampleview
self.parent.parent.contouritem.resetContours(self.parent.parent.dataset.particlecontours)
......@@ -144,6 +144,9 @@ class ParticleEditor(object):
self.parent.spectraResults[specIndex] = new_assignment
self.parent.hqis[specIndex] = 100
#save data
self.parent.saveAnalysisResults()
self.parent.loadParticleData()
......
......@@ -92,9 +92,12 @@ class MeasureParticleWindow(QtWidgets.QMainWindow):
fileName = QtWidgets.QFileDialog.getSaveFileName(self, "Create New Project",
defaultPath, "*.pkl")[0]
if fileName:
self.fname = str(fileName)
self.view.new(self.fname)
self.scalingChanged(1.)
if fileName.find(' ') < 0:
self.fname = str(fileName)
self.view.new(self.fname)
self.scalingChanged(1.)
else:
QtWidgets.QMessageBox.critical(self, "Error", "File path must not contain spaces.")
@QtCore.pyqtSlot()
def about(self):
......
# -*- coding: utf-8 -*-
"""
Created on Mon Feb 11 14:33:22 2019
@author: brandt
"""
from PyQt5 import QtWidgets, QtCore
import numpy as np
import sys
class GetOffset(QtWidgets.QWidget):
def __init__(self, parent, ramanctrl):
super(GetOffset, self).__init__()
self.setWindowTitle('Get Coordinate Offset')
self.ramanctrl = ramanctrl
self.parent = parent
layout = QtWidgets.QVBoxLayout()
self.setLayout(layout)
layout.addWidget(QtWidgets.QLabel('Position of points'))
numPoints = 5
self.pointBtns = []
self.coordLabels = []
self.old_coords = []
self.new_coords = []
coordGroup = QtWidgets.QGroupBox()
coordLayout = QtWidgets.QGridLayout()
for i in range(numPoints):
self.coordLabels.append(QtWidgets.QLabel())
self.coordLabels[-1].setFixedWidth(200)
coordLayout.addWidget(i, 0, QtCore.Qt.AlignLeft)
self.pointBtns.append(QtWidgets.QPushButton('Point'+str(i+1)))
coordLayout.addWidget(i, )
def connectButtonAndLabel(self, btn, lbl, index):
btn.released.connect(lambda: self.readPoint(lbl, index))
def readPoint(self, lbl):
x, y, z = self.ramanctrl.getPosition()
z = self.ramanctrl.getUserZ()
lbl.setText(f'x = {np.round(x)} µm, y = {np.round(y)} µm, z = {np.round(z)} µm')
if __name__ == '__main__':
app = QtWidgets.QApplication(sys.argv)
offset = GetOffset(None)
offset.show()
sys.exit(app.exec_())
\ No newline at end of file
......@@ -475,8 +475,9 @@ class OpticalScan(QtWidgets.QWidget):
else:
return
self.view.imparent.ramanSwitch.df_btn.setChecked(self.df_btn.isChecked())
self.view.imparent.ramanSwitch.df_btn.setChecked(self.df_btn.isChecked())
self.view.imparent.ramanSwitch.setDisabled(True)
self.view.setMicroscopeMode()
if self.df_btn.isChecked():
self.view.dataset.imagescanMode = 'df'
......
......@@ -170,6 +170,7 @@ class RamanScanUI(QtWidgets.QWidget):
QtWidgets.QMessageBox.Yes |
QtWidgets.QMessageBox.No, QtWidgets.QMessageBox.No)
if reply == QtWidgets.QMessageBox.Yes:
self.ramanctrl.finishMeasurement()
self.timer.stop()
self.processstopevent.set()
self.process.join()
......@@ -192,6 +193,8 @@ class RamanScanUI(QtWidgets.QWidget):
else:
return
self.view.imparent.ramanSwitch.hide()
self.view.setMicroscopeMode()
points = np.asarray(self.dataset.ramanpoints)
ramanSettings = {'filename': self.dataset.name,
'numPoints': len(points),
......
......@@ -215,8 +215,9 @@ class SampleView(QtWidgets.QGraphicsView):
self.dataset.save()
#close all widgets
for widget in [self.detectionwidget, self.ramanwidget, self.oscanwidget, self.analysiswidget]:
widget.close()
widget.destroy()
if widget is not None:
widget.close()
widget.destroy()
self.contouritem.resetContours()
self.dataset = loadData(fname)
......@@ -508,7 +509,7 @@ class SampleView(QtWidgets.QGraphicsView):
self.analysiswidget.spectrumSelector.valueChanged.connect(self.analysiswidget.selectSpectrum)
self.analysiswidget.polymerComboBox.currentIndexChanged.connect(self.analysiswidget.displayNewPolymerType)
self.analysiswidget.updatePolymerSpectrum(centerOn=centerOn)
self.analysiswidget.updateSpecPlot(centerOn=centerOn)
def prepareAnalysis(self):
......
......@@ -64,6 +64,10 @@ class SegmentationContours(QtWidgets.QGraphicsItem):
def paint(self, painter, option, widget):
painter.setPen(QtCore.Qt.green)
lenColorList = len(self.colorList)
if self.parent.analysiswidget is not None:
nonePaintMode = self.parent.analysiswidget.noOverlayAct.isChecked()
else:
nonePaintMode = False
for index, c in enumerate(self.contours):
if index not in self.selectedContours:
if lenColorList > 0:
......@@ -72,14 +76,16 @@ class SegmentationContours(QtWidgets.QGraphicsItem):
else:
color = QtCore.Qt.green
painter.setPen(color)
painter.setBrush(color)
if not nonePaintMode:
painter.setBrush(color)
painter.drawPolygon(c)
else:
if lenColorList > 0:
alpha = self.colorList[index].alpha()
else:
alpha = 255
painter.setBrush(QtGui.QColor(200, 200, 200, alpha))
if not nonePaintMode:
painter.setBrush(QtGui.QColor(200, 200, 200, alpha))
painter.setPen(QtCore.Qt.white)
painter.drawPolygon(c)
......@@ -92,7 +98,10 @@ class SegmentationContours(QtWidgets.QGraphicsItem):
if cnt.containsPoint(p, QtCore.Qt.OddEvenFill):
if event.modifiers()==QtCore.Qt.ShiftModifier:
self.selectedContours.append(index)
if index not in self.selectedContours:
self.selectedContours.append(index)
else:
self.selectedContours.remove(index)
else:
self.selectedContours = [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