2014-03-18 19:37:32 +00:00
|
|
|
#!/usr/bin/env python
|
|
|
|
# -*- coding: utf-8 -*-
|
2014-04-14 12:01:45 +00:00
|
|
|
__author__ = 'markusro'
|
|
|
|
|
2014-03-19 18:48:15 +00:00
|
|
|
from PyQt4.QtGui import QGroupBox, QPalette, QColor
|
|
|
|
import ConductivityGroupBox
|
|
|
|
import PeakGroupBox
|
2014-03-19 21:02:26 +00:00
|
|
|
import PowerLawGroupBox
|
2014-03-19 23:35:07 +00:00
|
|
|
import StaticGroupBox
|
2014-04-15 13:44:15 +00:00
|
|
|
import YAFFparameters, YAFFConfig
|
2014-03-18 19:37:32 +00:00
|
|
|
|
|
|
|
|
2014-03-18 18:48:39 +00:00
|
|
|
from PyQt4.QtGui import *
|
2014-04-11 15:30:48 +00:00
|
|
|
from PyQt4.QtCore import QRegExp, pyqtSignal,pyqtSlot
|
2014-04-14 12:01:45 +00:00
|
|
|
|
|
|
|
|
|
|
|
class ParameterWidget(QWidget):
|
|
|
|
def __init__(self, parent = None):
|
|
|
|
super(ParameterWidget, self).__init__(parent)
|
|
|
|
self.vlayout = QVBoxLayout(self)
|
|
|
|
self.vlayout.addSpacerItem(QSpacerItem(10,10,QSizePolicy.Minimum, QSizePolicy.Expanding) )
|
|
|
|
self.blockSignals(True)
|
|
|
|
|
|
|
|
def add(self, wdgt):
|
|
|
|
self.vlayout.insertWidget(self.vlayout.count()-1, wdgt)
|
|
|
|
self.vlayout.update()
|
|
|
|
|
2014-03-18 18:48:39 +00:00
|
|
|
|
|
|
|
|
|
|
|
class LogFSpinBox(QDoubleSpinBox):
|
|
|
|
scientificNotationValidator = QRegExpValidator(QRegExp("[+-]?(?:0|[1-9]\\d*)(?:\\.\\d*)?(?:[eE][+-]?\\d+)?"))
|
|
|
|
def __init__(self, parent = None):
|
|
|
|
super(LogFSpinBox, self).__init__(parent)
|
2014-04-03 18:56:50 +00:00
|
|
|
self.setRange(0.0,1e18)
|
|
|
|
self.setMinimum(0)
|
2014-03-18 18:48:39 +00:00
|
|
|
self.setDecimals(17)
|
|
|
|
self.setValue(1.0)
|
2014-03-19 23:35:07 +00:00
|
|
|
|
2014-03-18 18:48:39 +00:00
|
|
|
def stepBy(self, up_down):
|
|
|
|
if self.value() != 0.0:
|
|
|
|
self.setValue(self.value()*10**(up_down/9.0)) # 19 steps per decade
|
|
|
|
|
|
|
|
def textFromValue(self, value):
|
|
|
|
return "%.3e"%value
|
|
|
|
|
|
|
|
def valueFromText(self, str_value):
|
|
|
|
return str_value.toDouble()[0]
|
|
|
|
|
|
|
|
def validate(self, str_value, p_int):
|
|
|
|
return self.scientificNotationValidator.validate(str_value, p_int)
|
|
|
|
|
2014-03-19 18:48:15 +00:00
|
|
|
|
|
|
|
|
2014-03-19 23:35:07 +00:00
|
|
|
class BaseWidget(QGroupBox):
|
2014-03-19 18:48:15 +00:00
|
|
|
changedTable = pyqtSignal()
|
2014-03-19 21:02:26 +00:00
|
|
|
removeMe = pyqtSignal()
|
2014-04-03 18:56:50 +00:00
|
|
|
subtract = pyqtSignal()
|
2014-04-11 07:29:32 +00:00
|
|
|
|
2014-03-19 23:35:07 +00:00
|
|
|
def __init__(self, parent=None):
|
|
|
|
super(BaseWidget, self).__init__(parent)
|
|
|
|
self.fixedCheckBoxes = []
|
|
|
|
self.inputs = []
|
|
|
|
self.errors = []
|
2014-04-11 07:29:32 +00:00
|
|
|
self.names = []
|
2014-04-11 15:30:48 +00:00
|
|
|
self.selector_mask = None # TODO: clean up
|
2014-09-24 14:25:58 +00:00
|
|
|
self.func_type="None"
|
2014-03-19 23:35:07 +00:00
|
|
|
|
|
|
|
def remove(self):
|
|
|
|
self.removeMe.emit()
|
|
|
|
|
2014-04-03 18:56:50 +00:00
|
|
|
def subtract(self):
|
|
|
|
self.subtract.emit()
|
|
|
|
|
2014-03-19 23:35:07 +00:00
|
|
|
def changeValues(self, num):
|
|
|
|
self.changedTable.emit()
|
|
|
|
|
|
|
|
def fixedParameter(self):
|
|
|
|
return [0 if cb.isChecked() else 1 for cb in self.fixedCheckBoxes]
|
|
|
|
|
|
|
|
def setColor(self, color):
|
|
|
|
r, g, b = color
|
|
|
|
palette = self.palette()
|
|
|
|
palette.setColor(QPalette.Foreground, QColor(r, g, b))
|
|
|
|
self.setPalette(palette)
|
|
|
|
|
|
|
|
def getTable(self):
|
|
|
|
tmp = [i.value() # selects the number, ignores the status
|
|
|
|
for i in self.inputs]
|
2014-03-20 13:30:19 +00:00
|
|
|
#print "getTable:", tmp
|
2014-03-19 23:35:07 +00:00
|
|
|
return tmp
|
|
|
|
|
|
|
|
def update(self):
|
|
|
|
self.changedTable.emit()
|
|
|
|
|
|
|
|
def updateTable(self, beta, sd_beta=None):
|
|
|
|
for i, arg in enumerate(beta):
|
|
|
|
self.inputs[i].setValue(arg)
|
|
|
|
sd_style=""
|
2014-03-20 16:02:58 +00:00
|
|
|
|
|
|
|
if isinstance(self.inputs[i], LogFSpinBox) and sd_beta is not None:
|
|
|
|
#if i in (0,) and sd_beta is not None:
|
2014-03-19 23:35:07 +00:00
|
|
|
sd = "+/- %.3e"%(sd_beta[i])
|
2014-03-20 16:02:58 +00:00
|
|
|
elif isinstance(self.inputs[i], QDoubleSpinBox) and sd_beta is not None:
|
|
|
|
#elif i in (1,) and sd_beta is not None:
|
2014-03-19 23:35:07 +00:00
|
|
|
sd = "+/- %.2f"%(sd_beta[i])
|
|
|
|
if sd_beta is not None:
|
|
|
|
if 0.0 < sd_beta[i]/arg < 0.2:
|
|
|
|
sd_style="background-color: rgba(0, 255, 0, 64);"
|
|
|
|
if 0.2 < sd_beta[i]/arg < 1.0:
|
|
|
|
sd_style="background-color: rgba(255,255, 0, 64);"
|
|
|
|
elif sd_beta[i]/arg > 1.0:
|
|
|
|
sd_style="background-color: rgba(255, 0, 0, 64);"
|
|
|
|
|
|
|
|
else:
|
|
|
|
sd = "( --- )"
|
|
|
|
self.errors[i].setStyleSheet(sd_style)
|
|
|
|
self.errors[i].setText(sd)
|
2014-06-23 10:02:49 +00:00
|
|
|
#self.update()
|
2014-03-19 23:35:07 +00:00
|
|
|
|
2014-04-15 13:44:15 +00:00
|
|
|
def replaceDoubleSpinBox(self, layout, widget):
|
|
|
|
ndx = layout.indexOf(widget)
|
|
|
|
row, column, cols, rows = layout.getItemPosition(ndx)
|
|
|
|
widget.setParent(None)
|
|
|
|
widget = LogFSpinBox(self)
|
|
|
|
layout.addWidget(widget, row,column)
|
2014-03-19 23:35:07 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class PeakWidget(BaseWidget,QGroupBox):
|
2014-03-19 18:48:15 +00:00
|
|
|
def __init__(self, parent=None):
|
|
|
|
QGroupBox.__init__(self)
|
2014-03-19 23:35:07 +00:00
|
|
|
BaseWidget.__init__(self)
|
2014-03-19 18:48:15 +00:00
|
|
|
super(PeakWidget, self).__init__(parent)
|
|
|
|
self.ui = PeakGroupBox.Ui_PeakGroupBox()
|
|
|
|
self.ui.setupUi(self)
|
2014-03-20 13:30:19 +00:00
|
|
|
# replace eps and tau with LogFSpinBox
|
2014-03-19 18:48:15 +00:00
|
|
|
self.ui.doubleSpinBox_1.setParent(None)
|
|
|
|
self.ui.doubleSpinBox_1 = LogFSpinBox(self)
|
|
|
|
self.ui.gridLayout.addWidget(self.ui.doubleSpinBox_1,1,1)
|
|
|
|
self.ui.doubleSpinBox_2.setParent(None)
|
|
|
|
self.ui.doubleSpinBox_2 = LogFSpinBox(self)
|
|
|
|
self.ui.gridLayout.addWidget(self.ui.doubleSpinBox_2,2,1)
|
|
|
|
|
2014-03-20 13:30:19 +00:00
|
|
|
self.ui.removeButton.clicked.connect(self.remove)
|
|
|
|
|
2014-04-11 07:29:32 +00:00
|
|
|
self.names = [
|
|
|
|
"Deps",
|
|
|
|
"tau",
|
|
|
|
"alpha",
|
|
|
|
"beta"
|
|
|
|
]
|
|
|
|
|
2014-09-24 14:25:58 +00:00
|
|
|
self.func_type="HN"
|
|
|
|
|
2014-03-19 18:48:15 +00:00
|
|
|
self.inputs = [
|
|
|
|
self.ui.doubleSpinBox_1,
|
|
|
|
self.ui.doubleSpinBox_2,
|
|
|
|
self.ui.doubleSpinBox_3,
|
|
|
|
self.ui.doubleSpinBox_4
|
|
|
|
]
|
|
|
|
|
|
|
|
self.errors = [
|
|
|
|
self.ui.label_5,
|
|
|
|
self.ui.label_6,
|
|
|
|
self.ui.label_7,
|
|
|
|
self.ui.label_8,
|
|
|
|
]
|
|
|
|
|
|
|
|
for dsb in self.inputs:
|
|
|
|
dsb.valueChanged.connect(self.changeValues)
|
|
|
|
|
|
|
|
self.fixedCheckBoxes = [self.ui.checkBox_1,
|
|
|
|
self.ui.checkBox_2,
|
|
|
|
self.ui.checkBox_3,
|
|
|
|
self.ui.checkBox_4]
|
|
|
|
# self.ui.checkBox_3.stateChanged.connect(self._distrib_cc)
|
|
|
|
# self.ui.checkBox_4.stateChanged.connect(self._distrib_cd)
|
|
|
|
self.ui.comboBox.currentIndexChanged.connect(self._distrib_select)
|
|
|
|
|
2014-03-19 21:02:26 +00:00
|
|
|
|
2014-03-19 18:48:15 +00:00
|
|
|
def _distrib_select(self, dist):
|
|
|
|
if dist == 0: # hav-neg:
|
|
|
|
self.ui.checkBox_3.setChecked(False)
|
|
|
|
self.ui.checkBox_3.setDisabled(False)
|
|
|
|
self.ui.checkBox_4.setChecked(False)
|
2014-09-24 14:25:58 +00:00
|
|
|
self.ui.checkBox_4.setDisabled(False)
|
2014-03-19 18:48:15 +00:00
|
|
|
self.ui.doubleSpinBox_3.setDisabled(False)
|
|
|
|
self.ui.doubleSpinBox_4.setDisabled(False)
|
|
|
|
|
|
|
|
if dist == 1: # Cole-Cole:
|
|
|
|
self._distrib_cc(1)
|
|
|
|
if dist == 2: # Cole-Davidson
|
|
|
|
self._distrib_cd(1)
|
2014-03-19 23:47:19 +00:00
|
|
|
if dist == 3: # Cole-Davidson
|
|
|
|
self._distrib_debye(1)
|
2014-03-19 18:48:15 +00:00
|
|
|
|
|
|
|
def _distrib_cd(self, state):
|
|
|
|
if state:
|
|
|
|
self.ui.doubleSpinBox_3.setValue(1.0)
|
|
|
|
self.ui.doubleSpinBox_3.setDisabled(True)
|
|
|
|
self.ui.doubleSpinBox_4.setDisabled(False)
|
|
|
|
self.ui.checkBox_3.setChecked(True)
|
|
|
|
self.ui.checkBox_3.setDisabled(True)
|
|
|
|
self.ui.checkBox_4.setChecked(False)
|
2014-09-24 14:25:58 +00:00
|
|
|
self.func_type = "CD"
|
2014-03-19 18:48:15 +00:00
|
|
|
else:
|
|
|
|
self.ui.doubleSpinBox_3.setDisabled(False)
|
2014-09-24 14:25:58 +00:00
|
|
|
self.func_type = "HN"
|
2014-03-19 18:48:15 +00:00
|
|
|
|
2014-03-19 23:47:19 +00:00
|
|
|
def _distrib_debye(self, state):
|
|
|
|
if state:
|
|
|
|
self.ui.doubleSpinBox_3.setValue(1.0)
|
|
|
|
self.ui.doubleSpinBox_3.setDisabled(True)
|
|
|
|
self.ui.doubleSpinBox_4.setValue(1.0)
|
|
|
|
self.ui.doubleSpinBox_4.setDisabled(True)
|
|
|
|
self.ui.checkBox_3.setChecked(True)
|
|
|
|
self.ui.checkBox_3.setDisabled(True)
|
|
|
|
self.ui.checkBox_4.setChecked(True)
|
|
|
|
self.ui.checkBox_4.setDisabled(True)
|
2014-09-24 14:25:58 +00:00
|
|
|
self.func_type = "Debye"
|
2014-03-19 23:47:19 +00:00
|
|
|
|
|
|
|
else:
|
|
|
|
self.ui.doubleSpinBox_3.setDisabled(False)
|
|
|
|
self.ui.doubleSpinBox_4.setDisabled(False)
|
2014-09-24 14:25:58 +00:00
|
|
|
self.func_type = "HN"
|
2014-03-19 23:47:19 +00:00
|
|
|
|
|
|
|
|
2014-03-19 18:48:15 +00:00
|
|
|
def _distrib_cc(self, state):
|
|
|
|
if state:
|
|
|
|
self.ui.doubleSpinBox_4.setValue(1.0)
|
|
|
|
self.ui.doubleSpinBox_4.setDisabled(True)
|
|
|
|
self.ui.doubleSpinBox_3.setDisabled(False)
|
|
|
|
self.ui.checkBox_3.setChecked(False)
|
|
|
|
self.ui.checkBox_4.setChecked(True)
|
|
|
|
self.ui.checkBox_4.setDisabled(True)
|
2014-09-24 14:25:58 +00:00
|
|
|
self.func_type = "CC"
|
|
|
|
|
2014-03-19 18:48:15 +00:00
|
|
|
else:
|
|
|
|
self.ui.doubleSpinBox_4.setDisabled(False)
|
2014-09-24 14:25:58 +00:00
|
|
|
self.func_type = "HN"
|
|
|
|
|
2014-03-19 18:48:15 +00:00
|
|
|
|
|
|
|
|
|
|
|
def setId(self, id):
|
|
|
|
self.id = id
|
|
|
|
self.setTitle("Peak %i" % id)
|
|
|
|
|
|
|
|
def setColor(self, color):
|
|
|
|
palette = self.palette()
|
|
|
|
palette.setColor(QPalette.Foreground, color)
|
|
|
|
self.setPalette(palette)
|
|
|
|
|
|
|
|
|
2014-03-20 16:02:58 +00:00
|
|
|
#
|
|
|
|
# def updateTable(self, beta=None, sd_beta = None):
|
|
|
|
#
|
|
|
|
#
|
|
|
|
# for i, arg in enumerate(beta):
|
|
|
|
# self.inputs[i].setValue(arg)
|
|
|
|
# sd_style=""
|
|
|
|
# if i in (0,1) and sd_beta is not None:
|
|
|
|
# sd = "+/- %.3e"%(sd_beta[i])
|
|
|
|
# elif i in (2,3) and sd_beta is not None:
|
|
|
|
# sd = "+/- %.2f"%(sd_beta[i])
|
|
|
|
# if sd_beta is not None:
|
|
|
|
# if 0.0 < sd_beta[i]/arg < 0.2:
|
|
|
|
# sd_style="background-color: rgba(0, 255, 0, 64);"
|
|
|
|
# if 0.2 < sd_beta[i]/arg < 1.0:
|
|
|
|
# sd_style="background-color: rgba(255,255, 0, 64);"
|
|
|
|
# elif sd_beta[i]/arg > 1.0:
|
|
|
|
# sd_style="background-color: rgba(255, 0, 0, 64);"
|
|
|
|
#
|
|
|
|
# else:
|
|
|
|
# sd = "( --- )"
|
|
|
|
# self.errors[i].setStyleSheet(sd_style)
|
|
|
|
# self.errors[i].setText(sd)
|
2014-03-19 18:48:15 +00:00
|
|
|
|
|
|
|
|
2014-03-19 23:35:07 +00:00
|
|
|
class StaticWidget(BaseWidget, QGroupBox):
|
|
|
|
|
2014-03-19 21:02:26 +00:00
|
|
|
def __init__(self, parent=None):
|
|
|
|
QGroupBox.__init__(self)
|
2014-03-19 23:35:07 +00:00
|
|
|
BaseWidget.__init__(self)
|
|
|
|
|
|
|
|
super(StaticWidget, self).__init__(parent)
|
|
|
|
self.ui = StaticGroupBox.Ui_StaticGroupBox()
|
|
|
|
self.ui.setupUi(self)
|
|
|
|
|
|
|
|
#self.ui.doubleSpinBox_2.setParent(None)
|
|
|
|
#self.ui.doubleSpinBox_2 = LogFSpinBox(self)
|
|
|
|
#self.ui.gridLayout.addWidget(self.ui.doubleSpinBox_2,1,1)
|
|
|
|
|
2014-04-11 07:29:32 +00:00
|
|
|
self.names = ["e_infty"]
|
2014-03-19 23:35:07 +00:00
|
|
|
self.errors = [self.ui.label_4]
|
|
|
|
self.inputs = [self.ui.doubleSpinBox_1]
|
|
|
|
|
|
|
|
self.fixedCheckBoxes = [ self.ui.checkBox_1]
|
|
|
|
for dsb in self.inputs:
|
|
|
|
dsb.valueChanged.connect(self.changeValues)
|
|
|
|
|
|
|
|
self.ui.removeButton.clicked.connect(self.remove)
|
2014-09-24 14:25:58 +00:00
|
|
|
self.func_type=r"$\epsilon_\infty$"
|
2014-03-19 23:35:07 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
2014-03-20 13:30:19 +00:00
|
|
|
class ConductivityWidget(BaseWidget, QGroupBox):
|
2014-03-19 23:35:07 +00:00
|
|
|
|
|
|
|
def __init__(self, parent=None):
|
|
|
|
QGroupBox.__init__(self)
|
|
|
|
BaseWidget.__init__(self)
|
|
|
|
|
|
|
|
super(ConductivityWidget, self).__init__(parent)
|
|
|
|
self.ui = ConductivityGroupBox.Ui_ConductivityGroupBox()
|
2014-03-19 21:02:26 +00:00
|
|
|
self.ui.setupUi(self)
|
|
|
|
|
2014-04-11 07:29:32 +00:00
|
|
|
self.ui.iSigma.setParent(None)
|
|
|
|
self.ui.iSigma = LogFSpinBox(self)
|
|
|
|
self.ui.gridLayout.addWidget(self.ui.iSigma,1,1)
|
2014-04-03 18:56:50 +00:00
|
|
|
|
2014-04-11 07:29:32 +00:00
|
|
|
self.ui.rSigma.setParent(None)
|
|
|
|
self.ui.rSigma = LogFSpinBox(self)
|
|
|
|
self.ui.gridLayout.addWidget(self.ui.rSigma,2,1)
|
2014-03-19 21:02:26 +00:00
|
|
|
|
2014-04-03 18:56:50 +00:00
|
|
|
self.ui.removeButton.clicked.connect(self.remove)
|
|
|
|
#self.ui.subtractConductivityButton.connect(self.subtract)
|
2014-09-24 14:25:58 +00:00
|
|
|
self.func_type="Cond."
|
2014-03-19 21:02:26 +00:00
|
|
|
|
2014-04-11 07:29:32 +00:00
|
|
|
self.names = [
|
2014-09-24 14:25:58 +00:00
|
|
|
"iSig",
|
|
|
|
"rSig",
|
|
|
|
"pwrSig",
|
2014-04-11 07:29:32 +00:00
|
|
|
]
|
|
|
|
self.errors = [self.ui.iSigma_sd,
|
|
|
|
self.ui.rSigma_sd,
|
|
|
|
self.ui.pwrSigma_sd]
|
2014-03-19 21:02:26 +00:00
|
|
|
|
2014-04-11 07:29:32 +00:00
|
|
|
self.inputs = [self.ui.iSigma,
|
|
|
|
self.ui.rSigma,
|
|
|
|
self.ui.pwrSigma]
|
2014-03-19 21:02:26 +00:00
|
|
|
|
2014-04-03 18:56:50 +00:00
|
|
|
self.fixedCheckBoxes = [self.ui.checkBox_1,
|
|
|
|
self.ui.checkBox_2,
|
2014-03-19 21:02:26 +00:00
|
|
|
self.ui.checkBox_3]
|
|
|
|
for dsb in self.inputs:
|
|
|
|
dsb.valueChanged.connect(self.changeValues)
|
|
|
|
|
|
|
|
|
2014-04-11 07:29:32 +00:00
|
|
|
|
2014-04-15 13:44:15 +00:00
|
|
|
class PowerLawWidget(BaseWidget):
|
2014-03-19 21:02:26 +00:00
|
|
|
|
2014-03-19 23:35:07 +00:00
|
|
|
def __init__(self, parent=None):
|
2014-04-15 13:44:15 +00:00
|
|
|
#QGroupBox.__init__(self)
|
2014-03-19 23:35:07 +00:00
|
|
|
BaseWidget.__init__(self)
|
2014-03-19 21:02:26 +00:00
|
|
|
|
2014-03-19 23:35:07 +00:00
|
|
|
super(PowerLawWidget, self).__init__(parent)
|
|
|
|
self.ui = PowerLawGroupBox.Ui_PowerLawGroupBox()
|
|
|
|
self.ui.setupUi(self)
|
2014-03-19 21:02:26 +00:00
|
|
|
|
2014-03-19 23:35:07 +00:00
|
|
|
self.ui.doubleSpinBox_2.setParent(None)
|
|
|
|
self.ui.doubleSpinBox_2 = LogFSpinBox(self)
|
|
|
|
self.ui.gridLayout.addWidget(self.ui.doubleSpinBox_2,1,1)
|
2014-03-20 13:30:19 +00:00
|
|
|
self.ui.removeButton.clicked.connect(self.remove)
|
2014-09-24 14:25:58 +00:00
|
|
|
self.func_type="Power Law"
|
2014-03-19 21:02:26 +00:00
|
|
|
|
2014-04-11 07:29:32 +00:00
|
|
|
self.names = ["Amp", "pwrAmp"]
|
2014-03-19 23:35:07 +00:00
|
|
|
self.errors = [self.ui.label_5,
|
|
|
|
self.ui.label_6]
|
2014-03-19 21:02:26 +00:00
|
|
|
|
2014-03-19 23:35:07 +00:00
|
|
|
self.inputs = [self.ui.doubleSpinBox_2,
|
|
|
|
self.ui.doubleSpinBox_3]
|
2014-03-19 21:02:26 +00:00
|
|
|
|
2014-03-19 23:35:07 +00:00
|
|
|
self.fixedCheckBoxes = [ self.ui.checkBox_2,
|
|
|
|
self.ui.checkBox_3]
|
|
|
|
for dsb in self.inputs:
|
|
|
|
dsb.valueChanged.connect(self.changeValues)
|
2014-03-19 18:48:15 +00:00
|
|
|
|
2014-03-20 16:02:58 +00:00
|
|
|
|
2014-04-11 07:29:32 +00:00
|
|
|
class YaffWidget(BaseWidget):
|
|
|
|
on_model_changed = pyqtSignal()
|
2014-04-15 13:44:15 +00:00
|
|
|
configuration_changed = pyqtSignal(list,list)
|
2014-03-20 16:02:58 +00:00
|
|
|
|
|
|
|
def __init__(self, parent=None):
|
2014-04-11 07:29:32 +00:00
|
|
|
#QGroupBox.__init__(self)
|
2014-03-20 16:02:58 +00:00
|
|
|
BaseWidget.__init__(self)
|
|
|
|
super(YaffWidget, self).__init__(parent)
|
2014-09-24 14:25:58 +00:00
|
|
|
|
|
|
|
self.func_type="YAFF" # Todo wie bei peak für gg gb gge etc.
|
|
|
|
|
2014-03-20 16:02:58 +00:00
|
|
|
self.ui = YAFFparameters.Ui_Form()
|
|
|
|
self.ui.setupUi(self)
|
|
|
|
self.ui.doubleSpinBox_1.setParent(None)
|
|
|
|
self.ui.doubleSpinBox_1 = LogFSpinBox(self)
|
2014-04-03 18:56:50 +00:00
|
|
|
self.ui.gridLayout.addWidget(self.ui.doubleSpinBox_1, 2, 1)
|
2014-03-20 16:02:58 +00:00
|
|
|
self.ui.doubleSpinBox_2.setParent(None)
|
|
|
|
self.ui.doubleSpinBox_2 = LogFSpinBox(self)
|
2014-04-03 18:56:50 +00:00
|
|
|
self.ui.gridLayout.addWidget(self.ui.doubleSpinBox_2, 3, 1)
|
2014-03-20 16:02:58 +00:00
|
|
|
self.ui.doubleSpinBox_6.setParent(None)
|
|
|
|
self.ui.doubleSpinBox_6 = LogFSpinBox(self)
|
2014-04-03 18:56:50 +00:00
|
|
|
self.ui.gridLayout.addWidget(self.ui.doubleSpinBox_6, 9, 1)
|
2014-04-11 07:29:32 +00:00
|
|
|
self.ui.doubleSpinBox_9.setParent(None)
|
|
|
|
self.ui.doubleSpinBox_9 = LogFSpinBox(self)
|
|
|
|
self.ui.gridLayout.addWidget(self.ui.doubleSpinBox_9, 12, 1)
|
|
|
|
|
2014-03-20 16:02:58 +00:00
|
|
|
self.ui.removeButton.clicked.connect(self.remove)
|
2014-04-15 13:44:15 +00:00
|
|
|
self.ui.configButton.clicked.connect(self.configure)
|
2014-03-20 16:02:58 +00:00
|
|
|
|
2014-04-11 07:29:32 +00:00
|
|
|
self.ui.comboBox.currentIndexChanged.connect(self.change_model)
|
2014-04-11 15:30:48 +00:00
|
|
|
self._names = [
|
2014-04-11 07:29:32 +00:00
|
|
|
"Deps",
|
|
|
|
"tau_a",
|
|
|
|
"alpha",
|
|
|
|
"beta",
|
|
|
|
"lambda",
|
|
|
|
"tau_b",
|
|
|
|
"a",
|
|
|
|
"b",
|
2014-04-11 15:30:48 +00:00
|
|
|
"scale",
|
|
|
|
"g"
|
2014-04-11 07:29:32 +00:00
|
|
|
]
|
|
|
|
|
2014-04-11 15:30:48 +00:00
|
|
|
self.labels = [
|
|
|
|
self.ui.label_111,
|
|
|
|
self.ui.label_222,
|
|
|
|
self.ui.label_322,
|
|
|
|
self.ui.label_422,
|
|
|
|
self.ui.label_522,
|
|
|
|
self.ui.label_622,
|
|
|
|
self.ui.label_72,
|
|
|
|
self.ui.label_82,
|
|
|
|
self.ui.label_112,
|
|
|
|
self.ui.label_102
|
|
|
|
]
|
2014-03-20 16:02:58 +00:00
|
|
|
self.errors = [self.ui.label_1,
|
|
|
|
self.ui.label_2,
|
|
|
|
self.ui.label_3,
|
|
|
|
self.ui.label_4,
|
|
|
|
self.ui.label_5,
|
|
|
|
self.ui.label_6,
|
|
|
|
self.ui.label_7,
|
|
|
|
self.ui.label_8,
|
|
|
|
self.ui.label_9,
|
|
|
|
self.ui.label_10,
|
|
|
|
]
|
|
|
|
|
|
|
|
self.inputs = [self.ui.doubleSpinBox_1,
|
|
|
|
self.ui.doubleSpinBox_2,
|
|
|
|
self.ui.doubleSpinBox_3,
|
|
|
|
self.ui.doubleSpinBox_4,
|
|
|
|
self.ui.doubleSpinBox_5,
|
|
|
|
self.ui.doubleSpinBox_6,
|
|
|
|
self.ui.doubleSpinBox_7,
|
|
|
|
self.ui.doubleSpinBox_8,
|
|
|
|
self.ui.doubleSpinBox_9,
|
|
|
|
self.ui.doubleSpinBox_10,
|
|
|
|
]
|
|
|
|
|
|
|
|
self.fixedCheckBoxes = [ self.ui.checkBox_1,
|
|
|
|
self.ui.checkBox_2,
|
|
|
|
self.ui.checkBox_3,
|
|
|
|
self.ui.checkBox_4,
|
|
|
|
self.ui.checkBox_5,
|
|
|
|
self.ui.checkBox_6,
|
|
|
|
self.ui.checkBox_7,
|
|
|
|
self.ui.checkBox_8,
|
|
|
|
self.ui.checkBox_9,
|
|
|
|
self.ui.checkBox_10,
|
|
|
|
]
|
|
|
|
for dsb in self.inputs:
|
|
|
|
dsb.valueChanged.connect(self.changeValues)
|
2014-04-11 15:30:48 +00:00
|
|
|
self.change_model(0)
|
2014-04-15 13:44:15 +00:00
|
|
|
self._t_list, self._tau_list = None, None
|
|
|
|
|
|
|
|
def configure(self):
|
|
|
|
qd = YaffConfigWidget(t_list = self._t_list, tau_list = self._tau_list)
|
|
|
|
qd.configuration_changed.connect(self._store_config)
|
|
|
|
qd.exec_()
|
|
|
|
#qd.show()
|
|
|
|
def _store_config(self,t_list,tau_list):
|
|
|
|
self._t_list = t_list
|
|
|
|
self._tau_list = tau_list
|
|
|
|
self.configuration_changed.emit(t_list,tau_list)
|
2014-04-14 12:01:45 +00:00
|
|
|
|
2014-04-11 07:29:32 +00:00
|
|
|
def getYaffType(self):
|
|
|
|
return self.ui.comboBox.currentIndex()
|
|
|
|
|
2014-04-11 15:30:48 +00:00
|
|
|
@pyqtSlot(int)
|
|
|
|
def change_model(self,ndx):
|
|
|
|
#ndx = self.ui.comboBox.currentIndex()
|
2014-09-24 14:25:58 +00:00
|
|
|
mask = [ # 0 show, 1 hide
|
|
|
|
(0,0,0,0,1,1,1,1,1,1), # GG
|
|
|
|
(0,0,0,0,1,1,1,1,0,0), # GGe
|
|
|
|
(0,1,1,1,1,0,0,0,1,1), # Gb
|
|
|
|
|
|
|
|
(0,0,0,0,0,0,0,0,1,1), # GG + Gb
|
|
|
|
(0,0,0,0,0,0,0,0,0,0), # GGe + Gb
|
2014-04-11 07:29:32 +00:00
|
|
|
]
|
2014-04-11 15:30:48 +00:00
|
|
|
self.names = []
|
|
|
|
|
2014-04-11 07:29:32 +00:00
|
|
|
for i,inp in enumerate(self.inputs):
|
|
|
|
self.inputs[i].setDisabled(mask[ndx][i])
|
2014-04-11 15:30:48 +00:00
|
|
|
self.inputs[i].setHidden(mask[ndx][i])
|
|
|
|
|
2014-04-11 07:29:32 +00:00
|
|
|
self.errors[i].setDisabled(mask[ndx][i])
|
2014-04-11 15:30:48 +00:00
|
|
|
self.errors[i].setHidden(mask[ndx][i])
|
2014-04-11 07:29:32 +00:00
|
|
|
self.errors[i].setText("(---)")
|
2014-04-11 15:30:48 +00:00
|
|
|
|
|
|
|
self.fixedCheckBoxes[i].setChecked(mask[ndx][i])
|
|
|
|
self.fixedCheckBoxes[i].setDisabled(mask[ndx][i])
|
|
|
|
self.fixedCheckBoxes[i].setHidden(mask[ndx][i])
|
|
|
|
|
|
|
|
self.labels[i].setHidden(mask[ndx][i])
|
|
|
|
if mask[ndx][i]==0: self.names.append(self._names[i])
|
|
|
|
self.selector_mask = [not i for i in mask[ndx] ]
|
2014-04-11 07:29:32 +00:00
|
|
|
self.on_model_changed.emit()
|
2014-04-15 13:44:15 +00:00
|
|
|
|
|
|
|
class YaffConfigWidget(QDialog):
|
|
|
|
configuration_changed = pyqtSignal(list,list)
|
|
|
|
|
|
|
|
def __init__(self, parent=None, t_list=None, tau_list=None):
|
|
|
|
super(YaffConfigWidget,self).__init__(parent)
|
|
|
|
|
|
|
|
self.ui = YAFFConfig.Ui_Dialog()
|
|
|
|
self.ui.setupUi(self)
|
|
|
|
|
|
|
|
# not working; cannot set values
|
|
|
|
#self.replaceDoubleSpinBox(self.ui.gridLayout_time, self.ui.doubleSpinBox_tmin)
|
|
|
|
#self.replaceDoubleSpinBox(self.ui.gridLayout_time, self.ui.doubleSpinBox_tmax)
|
|
|
|
#self.replaceDoubleSpinBox(self.ui.gridLayout_tau, self.ui.doubleSpinBox_taumin)
|
|
|
|
#self.replaceDoubleSpinBox(self.ui.gridLayout_tau, self.ui.doubleSpinBox_taumax)
|
|
|
|
|
2014-06-23 10:02:49 +00:00
|
|
|
|
2014-04-15 13:44:15 +00:00
|
|
|
ndx = self.ui.gridLayout_time.indexOf(self.ui.doubleSpinBox_tmin)
|
|
|
|
row, column, cols, rows = self.ui.gridLayout_time.getItemPosition(ndx)
|
|
|
|
self.ui.doubleSpinBox_tmin.setParent(None)
|
|
|
|
self.ui.doubleSpinBox_tmin = LogFSpinBox(self)
|
2014-06-23 10:02:49 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
2014-04-15 13:44:15 +00:00
|
|
|
self.ui.gridLayout_time.addWidget(self.ui.doubleSpinBox_tmin, row,column)
|
|
|
|
|
|
|
|
ndx = self.ui.gridLayout_time.indexOf(self.ui.doubleSpinBox_tmax)
|
|
|
|
row, column, cols, rows = self.ui.gridLayout_time.getItemPosition(ndx)
|
|
|
|
self.ui.doubleSpinBox_tmax.setParent(None)
|
|
|
|
self.ui.doubleSpinBox_tmax = LogFSpinBox(self)
|
|
|
|
self.ui.gridLayout_time.addWidget(self.ui.doubleSpinBox_tmax, row,column)
|
|
|
|
|
|
|
|
ndx = self.ui.gridLayout_tau.indexOf(self.ui.doubleSpinBox_taumin)
|
|
|
|
row, column, cols, rows = self.ui.gridLayout_tau.getItemPosition(ndx)
|
|
|
|
self.ui.doubleSpinBox_taumin.setParent(None)
|
|
|
|
self.ui.doubleSpinBox_taumin = LogFSpinBox(self)
|
|
|
|
self.ui.gridLayout_tau.addWidget(self.ui.doubleSpinBox_taumin, row,column)
|
|
|
|
|
|
|
|
ndx = self.ui.gridLayout_tau.indexOf(self.ui.doubleSpinBox_taumax)
|
|
|
|
row, column, cols, rows = self.ui.gridLayout_tau.getItemPosition(ndx)
|
|
|
|
self.ui.doubleSpinBox_taumax.setParent(None)
|
|
|
|
self.ui.doubleSpinBox_taumax = LogFSpinBox(self)
|
|
|
|
self.ui.gridLayout_tau.addWidget(self.ui.doubleSpinBox_taumax, row,column)
|
|
|
|
|
|
|
|
if t_list is not None:
|
|
|
|
self.ui.doubleSpinBox_tmin.setValue(t_list[0])
|
|
|
|
self.ui.doubleSpinBox_tmax.setValue(t_list[1])
|
|
|
|
else:
|
|
|
|
self.ui.doubleSpinBox_tmin.setValue(1e-10)
|
|
|
|
self.ui.doubleSpinBox_tmax.setValue(1e5)
|
|
|
|
|
|
|
|
if tau_list is not None:
|
|
|
|
self.ui.doubleSpinBox_taumin.setValue(tau_list[0])
|
|
|
|
self.ui.doubleSpinBox_taumax.setValue(tau_list[1])
|
|
|
|
else:
|
|
|
|
self.ui.doubleSpinBox_taumin.setValue(1e-10)
|
|
|
|
self.ui.doubleSpinBox_taumax.setValue(1e5)
|
|
|
|
|
|
|
|
values = [self.ui.doubleSpinBox_tmin,
|
|
|
|
self.ui.doubleSpinBox_tmax,
|
|
|
|
self.ui.spinBox_tn,
|
|
|
|
self.ui.doubleSpinBox_taumin,
|
|
|
|
self.ui.doubleSpinBox_taumax,
|
|
|
|
self.ui.spinBox_taun]
|
|
|
|
for val in values: val.valueChanged.connect(self.changedConfiguration)
|
|
|
|
|
|
|
|
def changedConfiguration(self):
|
|
|
|
t_list = [self.ui.doubleSpinBox_tmin.value(),
|
|
|
|
self.ui.doubleSpinBox_tmax.value(),
|
|
|
|
self.ui.spinBox_tn.value()]
|
|
|
|
tau_list = [self.ui.doubleSpinBox_taumin.value(),
|
|
|
|
self.ui.doubleSpinBox_taumax.value(),
|
|
|
|
self.ui.spinBox_taun.value()]
|
|
|
|
self.configuration_changed.emit(t_list,tau_list)
|
|
|
|
|