* cleanup of the code
* fixed the table view of the PeakWidget
This commit is contained in:
parent
805a726346
commit
5f49684e01
@ -2,7 +2,7 @@
|
||||
|
||||
# Form implementation generated from reading ui file 'ConductivityGroupBox.ui'
|
||||
#
|
||||
# Created: Wed Jul 10 18:32:01 2013
|
||||
# Created: Wed Jul 10 18:57:09 2013
|
||||
# by: PyQt4 UI code generator 4.10.2
|
||||
#
|
||||
# WARNING! All changes made in this file will be lost!
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
# Form implementation generated from reading ui file 'PeakGroupBox.ui'
|
||||
#
|
||||
# Created: Wed Jul 10 18:32:01 2013
|
||||
# Created: Wed Jul 10 18:57:09 2013
|
||||
# by: PyQt4 UI code generator 4.10.2
|
||||
#
|
||||
# WARNING! All changes made in this file will be lost!
|
||||
|
38
QDS.py
38
QDS.py
@ -8,17 +8,19 @@ import signal
|
||||
from PyQt4.QtCore import *
|
||||
from PyQt4.QtGui import *
|
||||
|
||||
|
||||
import matplotlib
|
||||
import matplotlib.colors
|
||||
#from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg as FigureCanvas
|
||||
from matplotlib.backends.backend_qt4agg import NavigationToolbar2QTAgg as NavigationToolbar
|
||||
#import matplotlib.pyplot as plt
|
||||
import matplotlib.colors
|
||||
|
||||
matplotlib.rc_file("default.mplrc")
|
||||
|
||||
import numpy as N
|
||||
import scipy.odr as O
|
||||
import scipy.optimize as opt
|
||||
|
||||
import MatplotlibWidget
|
||||
import matplotlibWidget
|
||||
import QDSMain
|
||||
import PeakWidget
|
||||
from data import Data, Conductivity, conductivity
|
||||
@ -267,7 +269,6 @@ class AppWindow(QMainWindow):
|
||||
TODO: FIX RESIZEING keeping mainwindow maximised for now
|
||||
:param evt:
|
||||
"""
|
||||
|
||||
self.mplWidget.canvas.draw()
|
||||
self.mplWidget._bg_cache = self.mplWidget.canvas.copy_from_bbox(self.mplWidget.canvas.axes.bbox)
|
||||
for line in self.mplWidget.canvas.axes.get_lines():
|
||||
@ -422,6 +423,7 @@ class AppWindow(QMainWindow):
|
||||
|
||||
def openFile(self):
|
||||
ax = self.mplWidget.canvas.axes
|
||||
ax.clear()
|
||||
path = unicode(QFileDialog.getOpenFileName(self, "Open file"))
|
||||
# TODO anaylize file (LF,MF, HF) and act accordingly
|
||||
data = N.loadtxt(path, skiprows=4)
|
||||
@ -499,20 +501,28 @@ class AppWindow(QMainWindow):
|
||||
else:
|
||||
self.data.fitted_curve.set_xdata(nu[mask])
|
||||
self.data.fitted_curve.set_ydata(fit[mask])
|
||||
# handling of fit limit bars
|
||||
# if self.mplWidget._axvlims != []:
|
||||
# [axv.remove() for axv in self.mplWidget._axvlims]
|
||||
# self.mplWidget._axvlims = []
|
||||
# if self.mplWidget._axvname != []:
|
||||
# [axvname.remove() for axvname in self.mplWidget._axvname]
|
||||
# self.mplWidget._axvname = []
|
||||
#print self.mplWidget._axvlims
|
||||
if self.mplWidget._axvlims == []:
|
||||
for i,xlim in enumerate(self.data.fit_limits[:2]):
|
||||
|
||||
if self.mplWidget._axvlims != []:
|
||||
[axv.remove() for axv in self.mplWidget._axvlims]
|
||||
self.mplWidget._axvlims = []
|
||||
|
||||
if self.mplWidget._axvname != []:
|
||||
[axvname.remove() for axvname in self.mplWidget._axvname]
|
||||
self.mplWidget._axvname = []
|
||||
for xlim in self.data.fit_limits[:2]:
|
||||
self.mplWidget._axvlims.append(ax.axvline(xlim, color="k", ls="--", alpha=0.5, animated=True))
|
||||
self.mplWidget._axvname.append(ax.text(xlim, y_min*3. , "%.3g"%xlim,
|
||||
horizontalalignment='center',
|
||||
verticalalignment='center',
|
||||
animated=True) )
|
||||
else:
|
||||
for i,xlim in enumerate(self.data.fit_limits[:2]):
|
||||
self.mplWidget._axvlims[i].set_xdata(xlim)
|
||||
self.mplWidget._axvname[i].set_x(xlim)
|
||||
self.mplWidget._axvname[i].set_text("%.3g"%xlim)
|
||||
|
||||
self.mplWidget.canvas.restore_region(self.mplWidget._bg_cache)
|
||||
self.legend = ax.legend(title="T=%.2f" % (self.data.meta["T"]))
|
||||
self.legend.set_animated(True)
|
||||
@ -526,7 +536,7 @@ class PlotWidget(QWidget):
|
||||
def __init__(self, parent=None):
|
||||
QWidget.__init__(self)
|
||||
super(PlotWidget, self).__init__(parent)
|
||||
self.mplwidget = MatplotlibWidget.MatplotlibWidget(hold=True,
|
||||
self.mplwidget = matplotlibWidget.MatplotlibWidget(hold=True,
|
||||
xlim=(1e-2, 1e7),
|
||||
xscale='log',
|
||||
yscale='log')
|
||||
@ -628,7 +638,7 @@ class CustomToolbar(NavigationToolbar):
|
||||
self.iend = event.x
|
||||
if self.iend < self.istart:
|
||||
self.iend, self.istart = self.istart, self.iend
|
||||
print "released", self.xstart, self.xend
|
||||
#print "released", self.xstart, self.xend
|
||||
if self._pressed:
|
||||
if self.ignore(event):
|
||||
self.istart = 0
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
# Form implementation generated from reading ui file 'QDSMain.ui'
|
||||
#
|
||||
# Created: Wed Jul 10 18:32:01 2013
|
||||
# Created: Wed Jul 10 18:57:09 2013
|
||||
# by: PyQt4 UI code generator 4.10.2
|
||||
#
|
||||
# WARNING! All changes made in this file will be lost!
|
||||
@ -64,7 +64,7 @@ class Ui_MainWindow(object):
|
||||
self.scrollArea.setWidgetResizable(True)
|
||||
self.scrollArea.setObjectName(_fromUtf8("scrollArea"))
|
||||
self.scrollAreaWidgetContents = QtGui.QWidget()
|
||||
self.scrollAreaWidgetContents.setGeometry(QtCore.QRect(0, 0, 298, 585))
|
||||
self.scrollAreaWidgetContents.setGeometry(QtCore.QRect(0, 0, 298, 568))
|
||||
self.scrollAreaWidgetContents.setObjectName(_fromUtf8("scrollAreaWidgetContents"))
|
||||
self.verticalLayout_2 = QtGui.QVBoxLayout(self.scrollAreaWidgetContents)
|
||||
self.verticalLayout_2.setObjectName(_fromUtf8("verticalLayout_2"))
|
||||
@ -80,6 +80,7 @@ class Ui_MainWindow(object):
|
||||
self.statusbar.setObjectName(_fromUtf8("statusbar"))
|
||||
MainWindow.setStatusBar(self.statusbar)
|
||||
self.toolBar = QtGui.QToolBar(MainWindow)
|
||||
self.toolBar.setToolButtonStyle(QtCore.Qt.ToolButtonTextUnderIcon)
|
||||
self.toolBar.setObjectName(_fromUtf8("toolBar"))
|
||||
MainWindow.addToolBar(QtCore.Qt.TopToolBarArea, self.toolBar)
|
||||
self.actionAdd_Peak = QtGui.QAction(MainWindow)
|
||||
|
@ -77,7 +77,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>298</width>
|
||||
<height>585</height>
|
||||
<height>568</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2"/>
|
||||
@ -103,6 +103,9 @@
|
||||
<property name="windowTitle">
|
||||
<string>toolBar</string>
|
||||
</property>
|
||||
<property name="toolButtonStyle">
|
||||
<enum>Qt::ToolButtonTextUnderIcon</enum>
|
||||
</property>
|
||||
<attribute name="toolBarArea">
|
||||
<enum>TopToolBarArea</enum>
|
||||
</attribute>
|
||||
|
10
data.py
10
data.py
@ -1,6 +1,6 @@
|
||||
from PyQt4.QtCore import QObject, pyqtSignal
|
||||
import numpy as N
|
||||
import ConductivityWidget
|
||||
import conductivityWidget
|
||||
|
||||
|
||||
class Data:
|
||||
@ -14,8 +14,8 @@ class Data:
|
||||
self.fit_limits = (frequency.min(), frequency.max(), die_imag.min(), die_imag.max())
|
||||
|
||||
def __del__(self):
|
||||
self.remove_curves()
|
||||
|
||||
#self.remove_curves()
|
||||
pass
|
||||
#def set_fit_limits(self, limits=(None,None,None,None)):
|
||||
def get_data(self):
|
||||
"""
|
||||
@ -27,7 +27,9 @@ class Data:
|
||||
return self.frequency[mask], self.epsilon[mask]
|
||||
|
||||
def remove_curves(self):
|
||||
print "remove data_curve"
|
||||
if self.data_curve is not None: self.data_curve.remove()
|
||||
print "remove fitted_curve"
|
||||
if self.fitted_curve is not None: self.fitted_curve.remove()
|
||||
|
||||
|
||||
@ -37,7 +39,7 @@ class Conductivity(QObject):
|
||||
def __init__(self, mpl=None):
|
||||
QObject.__init__(self)
|
||||
super(Conductivity, self)
|
||||
self.widget = ConductivityWidget.ConductivityWidget()
|
||||
self.widget = conductivityWidget.ConductivityWidget()
|
||||
self.widget.changedTable.connect(self.updateData)
|
||||
self.mpl_line = None
|
||||
self.mpl_line_static = None
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
# Resource object code
|
||||
#
|
||||
# Created: Mi. Jul 10 18:32:00 2013
|
||||
# Created: Mi. Jul 10 18:57:09 2013
|
||||
# by: The Resource Compiler for PyQt (Qt v4.8.4)
|
||||
#
|
||||
# WARNING! All changes made in this file will be lost!
|
||||
|
Loading…
Reference in New Issue
Block a user