more cleanup
This commit is contained in:
583
gui/ContainerWidgets.py
Normal file
583
gui/ContainerWidgets.py
Normal file
@ -0,0 +1,583 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
from ui import ConductivityGroupBox, PeakGroupBox, StaticGroupBox, PowerLawGroupBox, YAFFparameters, YAFFConfig
|
||||
|
||||
__author__ = 'markusro'
|
||||
|
||||
from PyQt4.QtGui import *
|
||||
from PyQt4.QtCore import QRegExp, pyqtSignal,pyqtSlot
|
||||
|
||||
|
||||
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()
|
||||
|
||||
|
||||
|
||||
class LogFSpinBox(QDoubleSpinBox):
|
||||
scientificNotationValidator = QRegExpValidator(QRegExp("[+-]?(?:0|[1-9]\\d*)(?:\\.\\d*)?(?:[eE][+-]?\\d+)?"))
|
||||
def __init__(self, parent = None):
|
||||
super(LogFSpinBox, self).__init__(parent)
|
||||
self.setRange(0.0,1e18)
|
||||
self.setMinimum(0)
|
||||
self.setDecimals(17)
|
||||
self.setValue(1.0)
|
||||
|
||||
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)
|
||||
|
||||
|
||||
|
||||
class BaseWidget(QGroupBox):
|
||||
changedTable = pyqtSignal()
|
||||
removeMe = pyqtSignal()
|
||||
subtract = pyqtSignal()
|
||||
|
||||
def __init__(self, parent=None):
|
||||
super(BaseWidget, self).__init__(parent)
|
||||
self.fixedCheckBoxes = []
|
||||
self.inputs = []
|
||||
self.errors = []
|
||||
self.names = []
|
||||
self.selector_mask = None # TODO: clean up
|
||||
self.func_type="None"
|
||||
|
||||
def remove(self):
|
||||
self.removeMe.emit()
|
||||
|
||||
def subtract(self):
|
||||
self.subtract.emit()
|
||||
|
||||
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]
|
||||
#print "getTable:", tmp
|
||||
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=""
|
||||
|
||||
if isinstance(self.inputs[i], LogFSpinBox) and sd_beta is not None:
|
||||
#if i in (0,) and sd_beta is not None:
|
||||
sd = "+/- %.3e"%(sd_beta[i])
|
||||
elif isinstance(self.inputs[i], QDoubleSpinBox) and sd_beta is not None:
|
||||
#elif i in (1,) 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)
|
||||
#self.update()
|
||||
|
||||
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)
|
||||
|
||||
|
||||
|
||||
class PeakWidget(BaseWidget,QGroupBox):
|
||||
def __init__(self, parent=None):
|
||||
QGroupBox.__init__(self)
|
||||
BaseWidget.__init__(self)
|
||||
super(PeakWidget, self).__init__(parent)
|
||||
self.ui = PeakGroupBox.Ui_PeakGroupBox()
|
||||
self.ui.setupUi(self)
|
||||
# replace eps and tau with LogFSpinBox
|
||||
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)
|
||||
|
||||
self.ui.removeButton.clicked.connect(self.remove)
|
||||
|
||||
self.names = [
|
||||
"Deps",
|
||||
"tau",
|
||||
"alpha",
|
||||
"beta"
|
||||
]
|
||||
|
||||
self.func_type="HN"
|
||||
|
||||
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)
|
||||
|
||||
|
||||
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)
|
||||
self.ui.checkBox_4.setDisabled(False)
|
||||
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)
|
||||
if dist == 3: # Cole-Davidson
|
||||
self._distrib_debye(1)
|
||||
|
||||
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)
|
||||
self.func_type = "CD"
|
||||
else:
|
||||
self.ui.doubleSpinBox_3.setDisabled(False)
|
||||
self.func_type = "HN"
|
||||
|
||||
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)
|
||||
self.func_type = "Debye"
|
||||
|
||||
else:
|
||||
self.ui.doubleSpinBox_3.setDisabled(False)
|
||||
self.ui.doubleSpinBox_4.setDisabled(False)
|
||||
self.func_type = "HN"
|
||||
|
||||
|
||||
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)
|
||||
self.func_type = "CC"
|
||||
|
||||
else:
|
||||
self.ui.doubleSpinBox_4.setDisabled(False)
|
||||
self.func_type = "HN"
|
||||
|
||||
|
||||
|
||||
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)
|
||||
|
||||
|
||||
#
|
||||
# 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)
|
||||
|
||||
|
||||
class StaticWidget(BaseWidget, QGroupBox):
|
||||
|
||||
def __init__(self, parent=None):
|
||||
QGroupBox.__init__(self)
|
||||
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)
|
||||
|
||||
self.names = ["e_infty"]
|
||||
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)
|
||||
self.func_type=r"$\epsilon_\infty$"
|
||||
|
||||
|
||||
|
||||
class ConductivityWidget(BaseWidget, QGroupBox):
|
||||
|
||||
def __init__(self, parent=None):
|
||||
QGroupBox.__init__(self)
|
||||
BaseWidget.__init__(self)
|
||||
|
||||
super(ConductivityWidget, self).__init__(parent)
|
||||
self.ui = ConductivityGroupBox.Ui_ConductivityGroupBox()
|
||||
self.ui.setupUi(self)
|
||||
|
||||
self.ui.iSigma.setParent(None)
|
||||
self.ui.iSigma = LogFSpinBox(self)
|
||||
self.ui.gridLayout.addWidget(self.ui.iSigma,1,1)
|
||||
|
||||
self.ui.rSigma.setParent(None)
|
||||
self.ui.rSigma = LogFSpinBox(self)
|
||||
self.ui.gridLayout.addWidget(self.ui.rSigma,2,1)
|
||||
|
||||
self.ui.removeButton.clicked.connect(self.remove)
|
||||
#self.ui.subtractConductivityButton.connect(self.subtract)
|
||||
self.func_type="Cond."
|
||||
|
||||
self.names = [
|
||||
"iSig",
|
||||
"rSig",
|
||||
"pwrSig",
|
||||
]
|
||||
self.errors = [self.ui.iSigma_sd,
|
||||
self.ui.rSigma_sd,
|
||||
self.ui.pwrSigma_sd]
|
||||
|
||||
self.inputs = [self.ui.iSigma,
|
||||
self.ui.rSigma,
|
||||
self.ui.pwrSigma]
|
||||
|
||||
self.fixedCheckBoxes = [self.ui.checkBox_1,
|
||||
self.ui.checkBox_2,
|
||||
self.ui.checkBox_3]
|
||||
for dsb in self.inputs:
|
||||
dsb.valueChanged.connect(self.changeValues)
|
||||
|
||||
|
||||
|
||||
class PowerLawWidget(BaseWidget):
|
||||
|
||||
def __init__(self, parent=None):
|
||||
#QGroupBox.__init__(self)
|
||||
BaseWidget.__init__(self)
|
||||
|
||||
super(PowerLawWidget, self).__init__(parent)
|
||||
self.ui = PowerLawGroupBox.Ui_PowerLawGroupBox()
|
||||
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)
|
||||
self.ui.removeButton.clicked.connect(self.remove)
|
||||
self.func_type="Power Law"
|
||||
|
||||
self.names = ["Amp", "pwrAmp"]
|
||||
self.errors = [self.ui.label_5,
|
||||
self.ui.label_6]
|
||||
|
||||
self.inputs = [self.ui.doubleSpinBox_2,
|
||||
self.ui.doubleSpinBox_3]
|
||||
|
||||
self.fixedCheckBoxes = [ self.ui.checkBox_2,
|
||||
self.ui.checkBox_3]
|
||||
for dsb in self.inputs:
|
||||
dsb.valueChanged.connect(self.changeValues)
|
||||
|
||||
|
||||
class YaffWidget(BaseWidget):
|
||||
on_model_changed = pyqtSignal()
|
||||
configuration_changed = pyqtSignal(list,list)
|
||||
|
||||
def __init__(self, parent=None):
|
||||
#QGroupBox.__init__(self)
|
||||
BaseWidget.__init__(self)
|
||||
super(YaffWidget, self).__init__(parent)
|
||||
|
||||
self.func_type="YAFF" # Todo wie bei peak für gg gb gge etc.
|
||||
|
||||
self.ui = YAFFparameters.Ui_Form()
|
||||
self.ui.setupUi(self)
|
||||
self.ui.doubleSpinBox_1.setParent(None)
|
||||
self.ui.doubleSpinBox_1 = LogFSpinBox(self)
|
||||
self.ui.gridLayout.addWidget(self.ui.doubleSpinBox_1, 2, 1)
|
||||
self.ui.doubleSpinBox_2.setParent(None)
|
||||
self.ui.doubleSpinBox_2 = LogFSpinBox(self)
|
||||
self.ui.gridLayout.addWidget(self.ui.doubleSpinBox_2, 3, 1)
|
||||
self.ui.doubleSpinBox_6.setParent(None)
|
||||
self.ui.doubleSpinBox_6 = LogFSpinBox(self)
|
||||
self.ui.gridLayout.addWidget(self.ui.doubleSpinBox_6, 9, 1)
|
||||
self.ui.doubleSpinBox_9.setParent(None)
|
||||
self.ui.doubleSpinBox_9 = LogFSpinBox(self)
|
||||
self.ui.gridLayout.addWidget(self.ui.doubleSpinBox_9, 12, 1)
|
||||
|
||||
self.ui.removeButton.clicked.connect(self.remove)
|
||||
self.ui.configButton.clicked.connect(self.configure)
|
||||
|
||||
self.ui.comboBox.currentIndexChanged.connect(self.change_model)
|
||||
self._names = [
|
||||
"Deps",
|
||||
"tau_a",
|
||||
"alpha",
|
||||
"beta",
|
||||
"lambda",
|
||||
"tau_b",
|
||||
"a",
|
||||
"b",
|
||||
"scale",
|
||||
"g"
|
||||
]
|
||||
|
||||
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
|
||||
]
|
||||
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)
|
||||
self.change_model(0)
|
||||
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)
|
||||
|
||||
def getYaffType(self):
|
||||
return self.ui.comboBox.currentIndex()
|
||||
|
||||
@pyqtSlot(int)
|
||||
def change_model(self,ndx):
|
||||
#ndx = self.ui.comboBox.currentIndex()
|
||||
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
|
||||
]
|
||||
self.names = []
|
||||
|
||||
for i,inp in enumerate(self.inputs):
|
||||
self.inputs[i].setDisabled(mask[ndx][i])
|
||||
self.inputs[i].setHidden(mask[ndx][i])
|
||||
|
||||
self.errors[i].setDisabled(mask[ndx][i])
|
||||
self.errors[i].setHidden(mask[ndx][i])
|
||||
self.errors[i].setText("(---)")
|
||||
|
||||
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] ]
|
||||
self.on_model_changed.emit()
|
||||
|
||||
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)
|
||||
|
||||
|
||||
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)
|
||||
|
||||
|
||||
|
||||
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)
|
||||
|
31
gui/ExtraDifferentialWidget.py
Normal file
31
gui/ExtraDifferentialWidget.py
Normal file
@ -0,0 +1,31 @@
|
||||
# -*- encoding: utf-8 -*-
|
||||
from ui import ExtraDifferential
|
||||
|
||||
__author__ = 'markusro'
|
||||
|
||||
from PyQt4.QtGui import QColor
|
||||
import pyqtgraph as pg
|
||||
import numpy as np
|
||||
|
||||
class DifferentialWidget(ExtraDifferential.PlotWidget):
|
||||
def __init__(self, parent=None):
|
||||
super(DifferentialWidget, self).__init__(parent)
|
||||
self.setLogMode(x=True, y=False)
|
||||
self.showGrid(x=True, y=True)
|
||||
self.addLegend()
|
||||
self.disableAutoRange()
|
||||
self.setLabel("bottom", "Frequency", units="Hz")
|
||||
|
||||
self.setLabel("left", u"Dielectric loss ε<sub>der</sub>''= ∂ε'/∂log10(v)" , units="Debye")
|
||||
self.curve_imag = pg.PlotDataItem(x=[np.nan], y=[np.nan],pen=QColor(0,0,0,0), symbol='o',
|
||||
symbolBrush=(255,127,0,127), name=u"Imaginary ε")
|
||||
self.curve_real = pg.PlotDataItem(x=[np.nan], y=[np.nan],pen=QColor(0,0,0,0), symbol='s',
|
||||
symbolBrush=(119,202,92,127), name=u"Real ε")
|
||||
self.addItem(self.curve_imag)
|
||||
self.addItem(self.curve_real)
|
||||
|
||||
def plot(self, x,real_y,imag_y):
|
||||
self.enableAutoRange()
|
||||
self.curve_real.setData(x, real_y)
|
||||
self.curve_imag.setData(x, imag_y)
|
||||
|
0
gui/__init__.py
Normal file
0
gui/__init__.py
Normal file
Reference in New Issue
Block a user