[add] pyqtgraph now part of Settings object; if installed will be used by default but can be deactivated
This commit is contained in:
parent
b061c81b2c
commit
8e839df718
51
QtPyLoT.py
51
QtPyLoT.py
@ -45,6 +45,7 @@ from obspy import UTCDateTime
|
||||
try:
|
||||
import pyqtgraph as pg
|
||||
except:
|
||||
print('QtPyLoT: Could not import pyqtgraph.')
|
||||
pg = None
|
||||
|
||||
try:
|
||||
@ -144,9 +145,6 @@ class MainWindow(QMainWindow):
|
||||
|
||||
self.dirty = False
|
||||
|
||||
# setup UI
|
||||
self.setupUi()
|
||||
|
||||
if settings.value("user/FullName", None) is None:
|
||||
fulluser = QInputDialog.getText(self, "Enter Name:", "Full name")
|
||||
settings.setValue("user/FullName", fulluser)
|
||||
@ -170,6 +168,9 @@ class MainWindow(QMainWindow):
|
||||
settings.setValue('compclass', SetChannelComponents())
|
||||
settings.sync()
|
||||
|
||||
# setup UI
|
||||
self.setupUi()
|
||||
|
||||
self.filteroptions = {}
|
||||
self.pickDlgs = {}
|
||||
self.picks = {}
|
||||
@ -189,8 +190,6 @@ class MainWindow(QMainWindow):
|
||||
self.setWindowTitle("PyLoT - do seismic processing the python way")
|
||||
self.setWindowIcon(pylot_icon)
|
||||
|
||||
xlab = self.startTime.strftime('seconds since %Y/%m/%d %H:%M:%S (%Z)')
|
||||
|
||||
_widget = QWidget()
|
||||
self._main_layout = QVBoxLayout()
|
||||
|
||||
@ -213,21 +212,13 @@ class MainWindow(QMainWindow):
|
||||
self._main_layout.addWidget(self.tabs)
|
||||
self.tabs.currentChanged.connect(self.refreshTabs)
|
||||
|
||||
# create central matplotlib figure canvas widget
|
||||
plottitle = None#"Overview: {0} components ".format(self.getComponent())
|
||||
if pg:
|
||||
self.pg = True
|
||||
self.dataPlot = WaveformWidgetPG(parent=self, xlabel=xlab, ylabel=None,
|
||||
title=plottitle)
|
||||
else:
|
||||
self.pg = False
|
||||
self.dataPlot = WaveformWidget(parent=self, xlabel=xlab, ylabel=None,
|
||||
title=plottitle)
|
||||
self.dataPlot.setCursor(Qt.CrossCursor)
|
||||
|
||||
# add scroll area used in case number of traces gets too high
|
||||
self.wf_scroll_area = QtGui.QScrollArea()
|
||||
|
||||
# create central matplotlib figure canvas widget
|
||||
self.pg = pg
|
||||
self.init_wfWidget()
|
||||
|
||||
# init main widgets for main tabs
|
||||
wf_tab = QtGui.QWidget()
|
||||
array_tab = QtGui.QWidget()
|
||||
@ -247,7 +238,6 @@ class MainWindow(QMainWindow):
|
||||
self.tabs.addTab(events_tab, 'Eventlist')
|
||||
|
||||
self.wf_layout.addWidget(self.wf_scroll_area)
|
||||
self.wf_scroll_area.setWidget(self.dataPlot)
|
||||
self.wf_scroll_area.setWidgetResizable(True)
|
||||
self.init_array_tab()
|
||||
self.init_event_table()
|
||||
@ -521,6 +511,24 @@ class MainWindow(QMainWindow):
|
||||
|
||||
self.setCentralWidget(_widget)
|
||||
|
||||
def init_wfWidget(self):
|
||||
settings = QSettings()
|
||||
xlab = self.startTime.strftime('seconds since %Y/%m/%d %H:%M:%S (%Z)')
|
||||
plottitle = None#"Overview: {0} components ".format(self.getComponent())
|
||||
self.disconnectWFplotEvents()
|
||||
if str(settings.value('pyqtgraphic')) == 'false' or not pg:
|
||||
self.pg = False
|
||||
self.dataPlot = WaveformWidget(parent=self, xlabel=xlab, ylabel=None,
|
||||
title=plottitle)
|
||||
else:
|
||||
self.pg = True
|
||||
self.dataPlot = WaveformWidgetPG(parent=self, xlabel=xlab, ylabel=None,
|
||||
title=plottitle)
|
||||
self.dataPlot.setCursor(Qt.CrossCursor)
|
||||
self.wf_scroll_area.setWidget(self.dataPlot)
|
||||
if self.get_current_event():
|
||||
self.plotWaveformDataThread()
|
||||
|
||||
def init_ref_test_buttons(self):
|
||||
'''
|
||||
Initiate/create buttons for assigning events containing manual picks to reference or test set.
|
||||
@ -1662,12 +1670,12 @@ class MainWindow(QMainWindow):
|
||||
plotID = self.getStationID(station)
|
||||
if plotID is None:
|
||||
return
|
||||
if pg:
|
||||
if self.pg:
|
||||
pw = self.getPlotWidget().plotWidget
|
||||
else:
|
||||
ax = self.getPlotWidget().axes
|
||||
ylims = np.array([-.5, +.5]) + plotID
|
||||
if pg:
|
||||
if self.pg:
|
||||
dashed = QtCore.Qt.DashLine
|
||||
dotted = QtCore.Qt.DotLine
|
||||
phase_col = {
|
||||
@ -1699,7 +1707,7 @@ class MainWindow(QMainWindow):
|
||||
if not spe and epp and lpp:
|
||||
spe = symmetrize_error(mpp - epp, lpp - mpp)
|
||||
|
||||
if pg:
|
||||
if self.pg:
|
||||
if picktype == 'manual':
|
||||
if picks['epp'] and picks['lpp']:
|
||||
pw.plot([epp, epp], ylims,
|
||||
@ -2252,6 +2260,7 @@ class MainWindow(QMainWindow):
|
||||
self._props = PropertiesDlg(self, infile=self.infile)
|
||||
|
||||
if self._props.exec_():
|
||||
self.init_wfWidget()
|
||||
return
|
||||
|
||||
def helpHelp(self):
|
||||
|
@ -1 +1 @@
|
||||
d6dd-dirty
|
||||
b061-dirty
|
||||
|
@ -2373,6 +2373,7 @@ class PropTab(QWidget):
|
||||
|
||||
def resetValues(self, infile=None):
|
||||
return None
|
||||
|
||||
|
||||
class InputsTab(PropTab):
|
||||
def __init__(self, parent, infile=None):
|
||||
@ -2484,6 +2485,7 @@ class GraphicsTab(PropTab):
|
||||
def __init__(self, parent=None):
|
||||
super(GraphicsTab, self).__init__(parent)
|
||||
self.init_layout()
|
||||
self.add_pg_cb()
|
||||
self.add_nth_sample()
|
||||
self.setLayout(self.main_layout)
|
||||
|
||||
@ -2498,15 +2500,28 @@ class GraphicsTab(PropTab):
|
||||
|
||||
self.spinbox_nth_sample = QtGui.QSpinBox()
|
||||
label = QLabel('nth sample')
|
||||
label.setToolTip('Plot every nth sample (to speed up plotting)')
|
||||
self.spinbox_nth_sample.setMinimum(1)
|
||||
self.spinbox_nth_sample.setMaximum(10e3)
|
||||
self.spinbox_nth_sample.setValue(int(nth_sample))
|
||||
label.setToolTip('Plot every nth sample (to speed up plotting)')
|
||||
self.main_layout.addWidget(label, 0, 0)
|
||||
self.main_layout.addWidget(self.spinbox_nth_sample, 0, 1)
|
||||
self.main_layout.addWidget(label, 1, 0)
|
||||
self.main_layout.addWidget(self.spinbox_nth_sample, 1, 1)
|
||||
|
||||
def add_pg_cb(self):
|
||||
text = {True: 'Use pyqtgraphic library for plotting',
|
||||
False: 'Cannot use library: pyqtgraphic not found on system'}
|
||||
label = QLabel('PyQt graphic')
|
||||
label.setToolTip(text[bool(pg)])
|
||||
label.setEnabled(bool(pg))
|
||||
self.checkbox_pg = QtGui.QCheckBox()
|
||||
self.checkbox_pg.setEnabled(bool(pg))
|
||||
self.checkbox_pg.setChecked(bool(pg))
|
||||
self.main_layout.addWidget(label, 0, 0)
|
||||
self.main_layout.addWidget(self.checkbox_pg, 0, 1)
|
||||
|
||||
def getValues(self):
|
||||
values = {'nth_sample': self.spinbox_nth_sample.value()}
|
||||
values = {'nth_sample': self.spinbox_nth_sample.value(),
|
||||
'pyqtgraphic': self.checkbox_pg.isChecked()}
|
||||
return values
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user