[update] style_settings

This commit is contained in:
Marcel Paffrath 2017-09-07 16:07:43 +02:00
parent bab34a23c4
commit 9c63621ba4
7 changed files with 264 additions and 397 deletions

View File

@ -74,7 +74,8 @@ from pylot.core.util.connection import checkurl
from pylot.core.util.dataprocessing import read_metadata, restitute_data from pylot.core.util.dataprocessing import read_metadata, restitute_data
from pylot.core.util.utils import fnConstructor, getLogin, \ from pylot.core.util.utils import fnConstructor, getLogin, \
full_range, readFilterInformation, trim_station_components, check4gaps, make_pen, pick_color_plt, \ full_range, readFilterInformation, trim_station_components, check4gaps, make_pen, pick_color_plt, \
pick_linestyle_plt, remove_underscores, check4doubled, identifyPhaseID, excludeQualityClasses, has_spe, check4rotated pick_linestyle_plt, remove_underscores, check4doubled, identifyPhaseID, excludeQualityClasses, has_spe, \
check4rotated, transform_colors_mpl, transform_colors_mpl_str
from pylot.core.util.event import Event from pylot.core.util.event import Event
from pylot.core.io.location import create_creation_info, create_event from pylot.core.io.location import create_creation_info, create_event
from pylot.core.util.widgets import FilterOptionsDialog, NewEventDlg, \ from pylot.core.util.widgets import FilterOptionsDialog, NewEventDlg, \
@ -86,6 +87,8 @@ from pylot.core.util.structure import DATASTRUCTURE
from pylot.core.util.thread import Thread, Worker from pylot.core.util.thread import Thread, Worker
from pylot.core.util.version import get_git_version as _getVersionString from pylot.core.util.version import get_git_version as _getVersionString
from pylot.styles import style_settings
if sys.version_info.major == 3: if sys.version_info.major == 3:
import icons_rc_3 as icons_rc import icons_rc_3 as icons_rc
elif sys.version_info.major == 2: elif sys.version_info.major == 2:
@ -140,12 +143,6 @@ class MainWindow(QMainWindow):
# default factor for dataplot e.g. enabling/disabling scrollarea # default factor for dataplot e.g. enabling/disabling scrollarea
self.height_factor = 12 self.height_factor = 12
# default colors for ref/test event
self._colors = {
'ref': QtGui.QColor(200, 210, 230, 255),
'test': QtGui.QColor(200, 230, 200, 255)
}
# UI has to be set up before(!) children widgets are about to show up # UI has to be set up before(!) children widgets are about to show up
self.createAction = createAction self.createAction = createAction
# read settings # read settings
@ -553,6 +550,11 @@ class MainWindow(QMainWindow):
self.addActions(toolbars["autoPyLoT"], pickActions) self.addActions(toolbars["autoPyLoT"], pickActions)
self.addActions(toolbars["LocationTools"], locationToolActions) self.addActions(toolbars["LocationTools"], locationToolActions)
# init pyqtgraph
self.pg = pg
# init style
self.set_style('dark')
# add event combo box and ref/test buttons # add event combo box and ref/test buttons
self.eventBox = self.createEventBox() self.eventBox = self.createEventBox()
@ -577,8 +579,6 @@ class MainWindow(QMainWindow):
self.wf_scroll_area = QtGui.QScrollArea(self) self.wf_scroll_area = QtGui.QScrollArea(self)
# create central matplotlib figure canvas widget # create central matplotlib figure canvas widget
self.pg = pg
#self.set_style('dark')
self.init_wfWidget() self.init_wfWidget()
# init main widgets for main tabs # init main widgets for main tabs
@ -647,8 +647,8 @@ class MainWindow(QMainWindow):
'event as test picks for autopicker testing.') 'event as test picks for autopicker testing.')
self.ref_event_button.setCheckable(True) self.ref_event_button.setCheckable(True)
self.test_event_button.setCheckable(True) self.test_event_button.setCheckable(True)
self.set_button_color(self.ref_event_button, self._colors['ref']) self.set_button_border_color(self.ref_event_button, self._style['ref']['rgba'])
self.set_button_color(self.test_event_button, self._colors['test']) self.set_button_border_color(self.test_event_button, self._style['test']['rgba'])
self.ref_event_button.clicked.connect(self.toggleRef) self.ref_event_button.clicked.connect(self.toggleRef)
self.test_event_button.clicked.connect(self.toggleTest) self.test_event_button.clicked.connect(self.toggleTest)
self.ref_event_button.setEnabled(False) self.ref_event_button.setEnabled(False)
@ -669,43 +669,74 @@ class MainWindow(QMainWindow):
def init_styles(self): def init_styles(self):
self._styles = {} self._styles = {}
styles = ['default', 'dark'] styles = ['default', 'dark']
stylecolors = style_settings.stylecolors
for style in styles: for style in styles:
self._styles[style] = {} if style in stylecolors.keys():
self._styles[style] = stylecolors[style]
self._styles['default']['background'] = 'w' self._phasecolors = style_settings.phasecolors
self._styles['default']['foreground'] = 'k'
self._styles['default']['stylesheet'] = self.styleSheet()
self._styles['dark']['background'] = QtGui.QColor(50, 50, 65, 255) for style, stylecolors in self._styles.items():
self._styles['dark']['foreground'] = 'w' stylesheet = stylecolors['stylesheet']['filename']
# TODO: improve this if stylesheet:
infile = open('./styles/dark.qss', 'r') stylesheet_file = open(stylesheet, 'r')
stylesheet = infile.read() stylesheet = stylesheet_file.read()
infile.close() stylesheet_file.close()
self._styles['dark']['stylesheet'] = stylesheet else:
stylesheet = self.styleSheet()
def set_style(self, stylename): bg_color = stylecolors['background']['rgba']
line_color = stylecolors['linecolor']['rgba']
multcursor_color = stylecolors['multicursor']['rgba']
# transform to 0-1 values for mpl and update dict
stylecolors['background']['rgba_mpl'] = transform_colors_mpl(bg_color)
stylecolors['linecolor']['rgba_mpl'] = transform_colors_mpl(line_color)
multcursor_color = stylecolors['multicursor']['rgba_mpl'] = transform_colors_mpl(multcursor_color)
stylecolors['stylesheet'] = stylesheet
def set_style(self, stylename='default'):
if not stylename in self._styles: if not stylename in self._styles:
qmb = QMessageBox.warning(self, 'Could not find style', qmb = QMessageBox.warning(self, 'Could not find style',
'Could not find style with name {}.'.format(stylename)) 'Could not find style with name {}. Using default.'.format(stylename))
self.set_style()
return return
self._style = stylename
style = self._styles[stylename] style = self._styles[stylename]
self._style = style
self.setStyleSheet(style['stylesheet']) self.setStyleSheet(style['stylesheet'])
bg_colors = [60, 60, 70] # colors for ref/test event
bg_colors = [color/255. for color in bg_colors] self._ref_test_colors = {
'ref': QtGui.QColor(*style['ref']['rgba']),
'test': QtGui.QColor(*style['test']['rgba']),
}
cycler = matplotlib.cycler(color='wbgrcmy') # plot colors
matplotlib.rcParams['axes.prop_cycle'] = cycler bg_color = style['background']['rgba']
matplotlib.rcParams['axes.facecolor'] = '({}, {}, {})'.format(*bg_colors) bg_color_mpl_na = transform_colors_mpl_str(bg_color, no_alpha=True)
matplotlib.rcParams['figure.facecolor'] = '({}, {}, {})'.format(*bg_colors) line_color = style['linecolor']['rgba']
line_color_mpl_na = transform_colors_mpl_str(line_color, no_alpha=True)
for param in matplotlib.rcParams:
if 'color' in param and matplotlib.rcParams[param] in ['k', 'black']:
matplotlib.rcParams[param] = line_color_mpl_na
matplotlib.rc('axes',
edgecolor=line_color_mpl_na,
facecolor=bg_color_mpl_na,
labelcolor=line_color_mpl_na)
matplotlib.rc('xtick',
color=line_color_mpl_na)
matplotlib.rc('ytick',
color=line_color_mpl_na)
matplotlib.rc('figure',
facecolor=bg_color_mpl_na)
if self.pg: if self.pg:
pg.setConfigOption('background', style['background']) pg.setConfigOption('background', bg_color)
pg.setConfigOption('foreground', style['foreground']) pg.setConfigOption('foreground', line_color)
pg.setConfigOptions(antialias=True)
@property @property
def metadata(self): def metadata(self):
@ -846,20 +877,27 @@ class MainWindow(QMainWindow):
def add_recentfile(self, event): def add_recentfile(self, event):
self.recentfiles.insert(0, event) self.recentfiles.insert(0, event)
def set_button_color(self, button, color=None): def set_button_border_color(self, button, color=None):
''' '''
Set background color of a button. Set background color of a button.
button: type = QtGui.QAbstractButton button: type = QtGui.QAbstractButton
color: type = QtGui.QColor or type = str (RGBA) color: type = QtGui.QColor or type = str (RGBA)
''' '''
if type(color) == QtGui.QColor: if type(color) == QtGui.QColor:
button.setStyleSheet({'QPushButton{background-color:transparent}'})
palette = button.palette() palette = button.palette()
role = button.backgroundRole() role = button.backgroundRole()
palette.setColor(role, color) palette.setColor(role, color)
button.setPalette(palette) button.setPalette(palette)
button.setAutoFillBackground(True) button.setAutoFillBackground(True)
elif type(color) == str or not color: elif type(color) == str:
button.setStyleSheet("background-color: {}".format(color)) button.setStyleSheet('QPushButton{border-color: %s}'
'QPushButton:checked{background-color: rgba%s}'% (color, color))
elif type(color) == tuple:
button.setStyleSheet('QPushButton{border-color: rgba%s}'
'QPushButton:checked{background-color: rgba%s}' % (str(color), str(color)))
elif not color:
button.setStyleSheet(self.orig_parent._style['stylesheet'])
def getWFFnames(self): def getWFFnames(self):
try: try:
@ -1135,9 +1173,9 @@ class MainWindow(QMainWindow):
item_ref = QtGui.QStandardItem() # str(event_ref)) item_ref = QtGui.QStandardItem() # str(event_ref))
item_test = QtGui.QStandardItem() # str(event_test)) item_test = QtGui.QStandardItem() # str(event_test))
if event_ref: if event_ref:
item_ref.setBackground(self._colors['ref']) item_ref.setBackground(self._ref_test_colors['ref'])
if event_test: if event_test:
item_test.setBackground(self._colors['test']) item_test.setBackground(self._ref_test_colors['test'])
item_notes = QtGui.QStandardItem(event.notes) item_notes = QtGui.QStandardItem(event.notes)
openIcon = self.style().standardIcon(QStyle.SP_DirOpenIcon) openIcon = self.style().standardIcon(QStyle.SP_DirOpenIcon)
@ -1959,7 +1997,7 @@ class MainWindow(QMainWindow):
def init_canvas_dict(self): def init_canvas_dict(self):
self.canvas_dict = {} self.canvas_dict = {}
for key in self.fig_keys: for key in self.fig_keys:
self.canvas_dict[key] = PylotCanvas(self.fig_dict[key]) self.canvas_dict[key] = PylotCanvas(self.fig_dict[key], parent=self)
def init_fig_dict_wadatijack(self, eventIDs): def init_fig_dict_wadatijack(self, eventIDs):
self.fig_dict_wadatijack = {} self.fig_dict_wadatijack = {}
@ -1978,7 +2016,8 @@ class MainWindow(QMainWindow):
for eventID in self.fig_dict_wadatijack.keys(): for eventID in self.fig_dict_wadatijack.keys():
self.canvas_dict_wadatijack[eventID] = {} self.canvas_dict_wadatijack[eventID] = {}
for key in self.fig_keys_wadatijack: for key in self.fig_keys_wadatijack:
self.canvas_dict_wadatijack[eventID][key] = PylotCanvas(self.fig_dict_wadatijack[eventID][key]) self.canvas_dict_wadatijack[eventID][key] = PylotCanvas(self.fig_dict_wadatijack[eventID][key],
parent=self)
def tune_autopicker(self): def tune_autopicker(self):
''' '''
@ -2597,8 +2636,8 @@ class MainWindow(QMainWindow):
item_notes = QtGui.QTableWidgetItem() item_notes = QtGui.QTableWidgetItem()
# manipulate items # manipulate items
item_ref.setBackground(self._colors['ref']) item_ref.setBackground(self._ref_test_colors['ref'])
item_test.setBackground(self._colors['test']) item_test.setBackground(self._ref_test_colors['test'])
item_path.setText(event.path) item_path.setText(event.path)
if hasattr(event, 'origins'): if hasattr(event, 'origins'):
if event.origins: if event.origins:
@ -2909,7 +2948,7 @@ class MainWindow(QMainWindow):
def setParameter(self, show=True): def setParameter(self, show=True):
if not self.paraBox: if not self.paraBox:
self.paraBox = PylotParaBox(self._inputs) self.paraBox = PylotParaBox(self._inputs, parent=self, windowflag=1)
self.paraBox.accepted.connect(self._setDirty) self.paraBox.accepted.connect(self._setDirty)
self.paraBox.accepted.connect(self.filterOptionsFromParameter) self.paraBox.accepted.connect(self.filterOptionsFromParameter)
if show: if show:

View File

@ -14,6 +14,7 @@ from obspy.signal.rotate import rotate2zne
from obspy.io.xseed.utils import SEEDParserException from obspy.io.xseed.utils import SEEDParserException
from pylot.core.io.inputs import PylotParameter from pylot.core.io.inputs import PylotParameter
from pylot.styles import style_settings
from scipy.interpolate import splrep, splev from scipy.interpolate import splrep, splev
from PySide import QtCore, QtGui from PySide import QtCore, QtGui
@ -577,36 +578,22 @@ def modify_rgba(rgba, modifier, intensity):
def base_phase_colors(picktype, phase): def base_phase_colors(picktype, phase):
phases = { phasecolors = style_settings.phasecolors
'manual': return phasecolors[picktype][phase]
{
'P':
{
'rgba': (0, 0, 255, 255),
'modifier': 'g'
},
'S':
{
'rgba': (255, 0, 0, 255),
'modifier': 'b'
}
},
'auto':
{
'P':
{
'rgba': (140, 0, 255, 255),
'modifier': 'g'
},
'S':
{
'rgba': (255, 140, 0, 255),
'modifier': 'b'
}
}
}
return phases[picktype][phase]
def transform_colors_mpl_str(colors, no_alpha=False):
colors = list(colors)
colors_mpl = tuple([color / 255. for color in colors])
if no_alpha:
colors_mpl = '({}, {}, {})'.format(*colors_mpl)
else:
colors_mpl = '({}, {}, {}, {})'.format(*colors_mpl)
return colors_mpl
def transform_colors_mpl(colors):
colors = list(colors)
colors_mpl = tuple([color / 255. for color in colors])
return colors_mpl
def remove_underscores(data): def remove_underscores(data):
""" """

View File

@ -442,12 +442,13 @@ class WaveformWidgetPG(QtGui.QWidget):
self.plotWidget.hideAxis('bottom') self.plotWidget.hideAxis('bottom')
self.plotWidget.hideAxis('left') self.plotWidget.hideAxis('left')
self.wfstart, self.wfend = 0, 0 self.wfstart, self.wfend = 0, 0
self.pen = self.pg.mkPen(self.parent()._style['multicursor']['rgba'])
self.reinitMoveProxy() self.reinitMoveProxy()
self._proxy = self.pg.SignalProxy(self.plotWidget.scene().sigMouseMoved, rateLimit=60, slot=self.mouseMoved) self._proxy = self.pg.SignalProxy(self.plotWidget.scene().sigMouseMoved, rateLimit=60, slot=self.mouseMoved)
def reinitMoveProxy(self): def reinitMoveProxy(self):
self.vLine = self.pg.InfiniteLine(angle=90, movable=False) self.vLine = self.pg.InfiniteLine(angle=90, movable=False, pen=self.pen)
self.hLine = self.pg.InfiniteLine(angle=0, movable=False) self.hLine = self.pg.InfiniteLine(angle=0, movable=False, pen=self.pen)
self.plotWidget.addItem(self.vLine, ignoreBounds=True) self.plotWidget.addItem(self.vLine, ignoreBounds=True)
self.plotWidget.addItem(self.hLine, ignoreBounds=True) self.plotWidget.addItem(self.hLine, ignoreBounds=True)
@ -594,7 +595,6 @@ class WaveformWidgetPG(QtGui.QWidget):
class PylotCanvas(FigureCanvas): class PylotCanvas(FigureCanvas):
def __init__(self, figure=None, parent=None, connect_events=True, multicursor=False, def __init__(self, figure=None, parent=None, connect_events=True, multicursor=False,
panZoomX=True, panZoomY=True): panZoomX=True, panZoomY=True):
self._parent = parent
if not figure: if not figure:
figure = Figure() figure = Figure()
# create axes # create axes
@ -602,17 +602,18 @@ class PylotCanvas(FigureCanvas):
self.axes = figure.axes self.axes = figure.axes
self.figure = figure self.figure = figure
self.figure.set_facecolor((1., 1., 1.)) self.figure.set_facecolor(parent._style['background']['rgba_mpl'])
# attribute plotdict is a dictionary connecting position and a name # attribute plotdict is a dictionary connecting position and a name
self.plotdict = dict() self.plotdict = dict()
# initialize super class # initialize super class
super(PylotCanvas, self).__init__(self.figure) super(PylotCanvas, self).__init__(self.figure)
self.setParent(parent)
if multicursor: if multicursor:
# add a cursor for station selection # add a cursor for station selection
self.multiCursor = MultiCursor(self.figure.canvas, self.axes, self.multiCursor = MultiCursor(self.figure.canvas, self.axes,
horizOn=True, useblit=True, horizOn=True, useblit=True,
color='m', lw=1) color=parent._style['multicursor']['rgba_mpl'], lw=1)
# initialize panning attributes # initialize panning attributes
self.press = None self.press = None
@ -868,12 +869,6 @@ class PylotCanvas(FigureCanvas):
def clearPlotDict(self): def clearPlotDict(self):
self.plotdict = dict() self.plotdict = dict()
def getParent(self):
return self._parent
def setParent(self, parent):
self._parent = parent
def plotWFData(self, wfdata, title=None, zoomx=None, zoomy=None, def plotWFData(self, wfdata, title=None, zoomx=None, zoomy=None,
noiselevel=None, scaleddata=False, mapping=True, noiselevel=None, scaleddata=False, mapping=True,
component='*', nth_sample=1, iniPick=None, verbosity=0): component='*', nth_sample=1, iniPick=None, verbosity=0):
@ -906,6 +901,9 @@ class PylotCanvas(FigureCanvas):
nsc.sort() nsc.sort()
nsc.reverse() nsc.reverse()
style = self.parent()._style
linecolor = style['linecolor']['rgba_mpl']
for n, (network, station, channel) in enumerate(nsc): for n, (network, station, channel) in enumerate(nsc):
st = st_select.select(network=network, station=station, channel=channel) st = st_select.select(network=network, station=station, channel=channel)
trace = st[0] trace = st[0]
@ -926,11 +924,13 @@ class PylotCanvas(FigureCanvas):
trace.normalize(np.max(np.abs(trace.data)) * 2) trace.normalize(np.max(np.abs(trace.data)) * 2)
times = [time for index, time in enumerate(time_ax) if not index % nth_sample] times = [time for index, time in enumerate(time_ax) if not index % nth_sample]
data = [datum + n for index, datum in enumerate(trace.data) if not index % nth_sample] data = [datum + n for index, datum in enumerate(trace.data) if not index % nth_sample]
ax.plot(times, data, linewidth=0.7) ax.plot(times, data, color=linecolor, linewidth=0.7)
if noiselevel is not None: if noiselevel is not None:
for level in noiselevel: for level in noiselevel:
ax.plot([time_ax[0], time_ax[-1]], ax.plot([time_ax[0], time_ax[-1]],
[level, level], '--k') [level, level],
color = linecolor,
linestyle = 'dashed')
self.setPlotDict(n, (station, channel, network)) self.setPlotDict(n, (station, channel, network))
if iniPick: if iniPick:
ax.vlines(iniPick, ax.get_ylim()[0], ax.get_ylim()[1], ax.vlines(iniPick, ax.get_ylim()[0], ax.get_ylim()[1],
@ -1093,7 +1093,8 @@ class PickDlg(QDialog):
def __init__(self, parent=None, data=None, station=None, network=None, picks=None, def __init__(self, parent=None, data=None, station=None, network=None, picks=None,
autopicks=None, rotate=False, parameter=None, embedded=False, metadata=None, autopicks=None, rotate=False, parameter=None, embedded=False, metadata=None,
event=None, filteroptions=None, model='iasp91'): event=None, filteroptions=None, model='iasp91'):
super(PickDlg, self).__init__(parent) super(PickDlg, self).__init__(parent, 1)
self.orig_parent = parent
# initialize attributes # initialize attributes
self.parameter = parameter self.parameter = parameter
@ -1113,6 +1114,7 @@ class PickDlg(QDialog):
pylot_user = getpass.getuser() pylot_user = getpass.getuser()
self._user = settings.value('user/Login', pylot_user) self._user = settings.value('user/Login', pylot_user)
self._dirty = False self._dirty = False
self._style = parent._style
if picks: if picks:
self.picks = copy.deepcopy(picks) self.picks = copy.deepcopy(picks)
self._init_picks = picks self._init_picks = picks
@ -1508,36 +1510,46 @@ class PickDlg(QDialog):
self.leave_picking_mode() self.leave_picking_mode()
def init_p_pick(self): def init_p_pick(self):
self.set_button_color(self.p_button, 'yellow') self.set_button_border_color(self.p_button, 'yellow')
self.activatePicking() self.activatePicking()
self.currentPhase = str(self.p_button.text()) self.currentPhase = str(self.p_button.text())
def init_s_pick(self): def init_s_pick(self):
self.set_button_color(self.s_button, 'yellow') self.set_button_border_color(self.s_button, 'yellow')
self.activatePicking() self.activatePicking()
self.currentPhase = str(self.s_button.text()) self.currentPhase = str(self.s_button.text())
def getPhaseID(self, phase): def getPhaseID(self, phase):
return identifyPhaseID(phase) return identifyPhaseID(phase)
def set_button_color(self, button, color=None): def set_button_border_color(self, button, color=None):
'''
Set background color of a button.
button: type = QtGui.QAbstractButton
color: type = QtGui.QColor or type = str (RGBA)
'''
if type(color) == QtGui.QColor: if type(color) == QtGui.QColor:
button.setStyleSheet({'QPushButton{background-color:transparent}'})
palette = button.palette() palette = button.palette()
role = button.backgroundRole() role = button.backgroundRole()
palette.setColor(role, color) palette.setColor(role, color)
button.setPalette(palette) button.setPalette(palette)
button.setAutoFillBackground(True) button.setAutoFillBackground(True)
elif type(color) == str or not color: elif type(color) == str:
button.setStyleSheet("background-color: {}".format(color)) button.setStyleSheet('QPushButton{border-color: %s}' % color)
elif type(color) == tuple:
button.setStyleSheet('QPushButton{border-color: rgba%s}' % str(color))
elif not color:
button.setStyleSheet(self.orig_parent._style['stylesheet'])
def reset_p_button(self): def reset_p_button(self):
self.set_button_color(self.p_button) self.set_button_border_color(self.p_button)
self.p_button.setEnabled(True) self.p_button.setEnabled(True)
self.p_button.setChecked(False) self.p_button.setChecked(False)
self.p_button.setText('P') self.p_button.setText('P')
def reset_s_button(self): def reset_s_button(self):
self.set_button_color(self.s_button) self.set_button_border_color(self.s_button)
self.s_button.setEnabled(True) self.s_button.setEnabled(True)
self.s_button.setChecked(False) self.s_button.setChecked(False)
self.s_button.setText('S') self.s_button.setText('S')
@ -1676,10 +1688,10 @@ class PickDlg(QDialog):
self.cidpress = self.multicompfig.connectPressEvent(self.setPick) self.cidpress = self.multicompfig.connectPressEvent(self.setPick)
if self.getPhaseID(self.currentPhase) == 'P': if self.getPhaseID(self.currentPhase) == 'P':
self.set_button_color(self.p_button, 'green') self.set_button_border_color(self.p_button, 'green')
self.setIniPickP(gui_event, wfdata, trace_number) self.setIniPickP(gui_event, wfdata, trace_number)
elif self.getPhaseID(self.currentPhase) == 'S': elif self.getPhaseID(self.currentPhase) == 'S':
self.set_button_color(self.s_button, 'green') self.set_button_border_color(self.s_button, 'green')
self.setIniPickS(gui_event, wfdata) self.setIniPickS(gui_event, wfdata)
self.zoomAction.setEnabled(False) self.zoomAction.setEnabled(False)
@ -2421,7 +2433,6 @@ class TuneAutopicker(QWidget):
def __init__(self, parent): def __init__(self, parent):
QtGui.QWidget.__init__(self, parent, 1) QtGui.QWidget.__init__(self, parent, 1)
self.parent = parent
self.setParent(parent) self.setParent(parent)
self.setWindowTitle('PyLoT - Tune Autopicker') self.setWindowTitle('PyLoT - Tune Autopicker')
self.parameter = parent._inputs self.parameter = parent._inputs
@ -2439,7 +2450,7 @@ class TuneAutopicker(QWidget):
self.set_stretch() self.set_stretch()
self.resize(1280, 720) self.resize(1280, 720)
if hasattr(parent, 'metadata'): if hasattr(parent, 'metadata'):
self.metadata = self.parent.metadata self.metadata = self.parent().metadata
else: else:
self.metadata = None self.metadata = None
# self.setWindowModality(QtCore.Qt.WindowModality.ApplicationModal) # self.setWindowModality(QtCore.Qt.WindowModality.ApplicationModal)
@ -2456,7 +2467,7 @@ class TuneAutopicker(QWidget):
self.setLayout(self.main_layout) self.setLayout(self.main_layout)
def init_eventlist(self): def init_eventlist(self):
self.eventBox = self.parent.createEventBox() self.eventBox = self.parent().createEventBox()
self.eventBox.setMaxVisibleItems(20) self.eventBox.setMaxVisibleItems(20)
self.fill_eventbox() self.fill_eventbox()
self.trace_layout.addWidget(self.eventBox) self.trace_layout.addWidget(self.eventBox)
@ -2474,13 +2485,13 @@ class TuneAutopicker(QWidget):
self.stationBox.activated.connect(self.fill_tabs) self.stationBox.activated.connect(self.fill_tabs)
def fill_stationbox(self): def fill_stationbox(self):
fnames = self.parent.getWFFnames_from_eventbox(eventbox=self.eventBox) fnames = self.parent().getWFFnames_from_eventbox(eventbox=self.eventBox)
self.data.setWFData(fnames) self.data.setWFData(fnames)
wfdat = self.data.getWFData() # all available streams wfdat = self.data.getWFData() # all available streams
# trim station components to same start value # trim station components to same start value
trim_station_components(wfdat, trim_start=True, trim_end=False) trim_station_components(wfdat, trim_start=True, trim_end=False)
# rotate misaligned stations to ZNE # rotate misaligned stations to ZNE
wfdat = check4rotated(wfdat, self.parent.metadata) wfdat = check4rotated(wfdat, self.parent().metadata)
self.stationBox.clear() self.stationBox.clear()
stations = [] stations = []
for trace in self.data.getWFData(): for trace in self.data.getWFData():
@ -2494,7 +2505,7 @@ class TuneAutopicker(QWidget):
for network, station in stations: for network, station in stations:
item = QtGui.QStandardItem(network + '.' + station) item = QtGui.QStandardItem(network + '.' + station)
if station in self.get_current_event().pylot_picks: if station in self.get_current_event().pylot_picks:
item.setBackground(self.parent._colors['ref']) item.setBackground(self.parent()._colors['ref'])
model.appendRow(item) model.appendRow(item)
def init_figure_tabs(self): def init_figure_tabs(self):
@ -2509,7 +2520,7 @@ class TuneAutopicker(QWidget):
self.stb_names = ['aicARHfig', 'refSpick', 'el_S1pick', 'el_S2pick'] self.stb_names = ['aicARHfig', 'refSpick', 'el_S1pick', 'el_S2pick']
def add_parameters(self): def add_parameters(self):
self.paraBox = PylotParaBox(self.parameter) self.paraBox = PylotParaBox(self.parameter, parent=self, windowflag=0)
self.paraBox.set_tune_mode(True) self.paraBox.set_tune_mode(True)
self.update_eventID() self.update_eventID()
self.parameter_layout.addWidget(self.paraBox) self.parameter_layout.addWidget(self.paraBox)
@ -2535,7 +2546,7 @@ class TuneAutopicker(QWidget):
def get_current_event(self): def get_current_event(self):
path = self.eventBox.currentText() path = self.eventBox.currentText()
return self.parent.project.getEventFromPath(path) return self.parent().project.getEventFromPath(path)
def get_current_event_name(self): def get_current_event_name(self):
return self.eventBox.currentText().split('/')[-1] return self.eventBox.currentText().split('/')[-1]
@ -2570,10 +2581,10 @@ class TuneAutopicker(QWidget):
return return
station = self.get_current_station() station = self.get_current_station()
data = self.data.getWFData() data = self.data.getWFData()
metadata = self.parent.metadata metadata = self.parent().metadata
event = self.get_current_event() event = self.get_current_event()
filteroptions = self.parent.filteroptions filteroptions = self.parent().filteroptions
pickDlg = PickDlg(self, data=data.select(station=station), pickDlg = PickDlg(self.parent(), data=data.select(station=station),
station=station, parameter=self.parameter, station=station, parameter=self.parameter,
picks=self.get_current_event_picks(station), picks=self.get_current_event_picks(station),
autopicks=self.get_current_event_autopicks(station), autopicks=self.get_current_event_autopicks(station),
@ -2582,8 +2593,8 @@ class TuneAutopicker(QWidget):
pickDlg.update_picks.connect(self.picks_from_pickdlg) pickDlg.update_picks.connect(self.picks_from_pickdlg)
pickDlg.update_picks.connect(self.fill_eventbox) pickDlg.update_picks.connect(self.fill_eventbox)
pickDlg.update_picks.connect(self.fill_stationbox) pickDlg.update_picks.connect(self.fill_stationbox)
pickDlg.update_picks.connect(lambda: self.parent.setDirty(True)) pickDlg.update_picks.connect(lambda: self.parent().setDirty(True))
pickDlg.update_picks.connect(self.parent.enableSaveEventAction) pickDlg.update_picks.connect(self.parent().enableSaveEventAction)
self.pickDlg = QtGui.QWidget() self.pickDlg = QtGui.QWidget()
hl = QtGui.QHBoxLayout() hl = QtGui.QHBoxLayout()
self.pickDlg.setLayout(hl) self.pickDlg.setLayout(hl)
@ -2591,15 +2602,15 @@ class TuneAutopicker(QWidget):
def picks_from_pickdlg(self, picks=None): def picks_from_pickdlg(self, picks=None):
station = self.get_current_station() station = self.get_current_station()
replot = self.parent.addPicks(station, picks) replot = self.parent().addPicks(station, picks)
self.get_current_event().setPick(station, picks) self.get_current_event().setPick(station, picks)
if self.get_current_event() == self.parent.get_current_event(): if self.get_current_event() == self.parent().get_current_event():
if replot: if replot:
self.parent.plotWaveformDataThread() self.parent().plotWaveformDataThread()
self.parent.drawPicks() self.parent().drawPicks()
else: else:
self.parent.drawPicks(station) self.parent().drawPicks(station)
self.parent.draw() self.parent().draw()
def plot_manual_picks_to_figs(self): def plot_manual_picks_to_figs(self):
picks = self.get_current_event_picks(self.get_current_station()) picks = self.get_current_event_picks(self.get_current_station())
@ -2624,13 +2635,13 @@ class TuneAutopicker(QWidget):
('el_S1pick', 0), ('el_S1pick', 0),
('el_S2pick', 0)] ('el_S2pick', 0)]
for p_ax in p_axes: for p_ax in p_axes:
axes = self.parent.fig_dict[p_ax[0]].axes axes = self.parent().fig_dict[p_ax[0]].axes
if not axes: if not axes:
continue continue
ax = axes[p_ax[1]] ax = axes[p_ax[1]]
self.plot_manual_Ppick_to_ax(ax, (picks['P']['mpp'] - starttime)) self.plot_manual_Ppick_to_ax(ax, (picks['P']['mpp'] - starttime))
for s_ax in s_axes: for s_ax in s_axes:
axes = self.parent.fig_dict[s_ax[0]].axes axes = self.parent().fig_dict[s_ax[0]].axes
if not axes: if not axes:
continue continue
ax = axes[s_ax[1]] ax = axes[s_ax[1]]
@ -2660,7 +2671,7 @@ class TuneAutopicker(QWidget):
def fill_tabs(self, event=None, picked=False): def fill_tabs(self, event=None, picked=False):
self.clear_all() self.clear_all()
canvas_dict = self.parent.canvas_dict canvas_dict = self.parent().canvas_dict
self.gen_pick_dlg() self.gen_pick_dlg()
self.overview = self.gen_tab_widget('Overview', canvas_dict['mainFig']) self.overview = self.gen_tab_widget('Overview', canvas_dict['mainFig'])
id0 = self.figure_tabs.insertTab(0, self.pickDlg, 'Traces Plot') id0 = self.figure_tabs.insertTab(0, self.pickDlg, 'Traces Plot')
@ -2706,12 +2717,12 @@ class TuneAutopicker(QWidget):
self.init_tab_names() self.init_tab_names()
def fill_eventbox(self): def fill_eventbox(self):
project = self.parent.project project = self.parent().project
if not project: if not project:
return return
# update own list # update own list
self.parent.fill_eventbox(eventBox=self.eventBox, select_events='ref') self.parent().fill_eventbox(eventBox=self.eventBox, select_events='ref')
index_start = self.parent.eventBox.currentIndex() index_start = self.parent().eventBox.currentIndex()
index = index_start index = index_start
if index == -1: if index == -1:
index += 1 index += 1
@ -2730,7 +2741,7 @@ class TuneAutopicker(QWidget):
if not index == index_start: if not index == index_start:
self.eventBox.activated.emit(index) self.eventBox.activated.emit(index)
# update parent # update parent
self.parent.fill_eventbox() self.parent().fill_eventbox()
def update_eventID(self): def update_eventID(self):
self.paraBox.boxes['eventID'].setText( self.paraBox.boxes['eventID'].setText(
@ -2793,8 +2804,8 @@ class TuneAutopicker(QWidget):
def params_from_gui(self): def params_from_gui(self):
parameters = self.paraBox.params_from_gui() parameters = self.paraBox.params_from_gui()
if self.parent: if self.parent():
self.parent._inputs = parameters self.parent()._inputs = parameters
return parameters return parameters
def set_stretch(self): def set_stretch(self):
@ -2834,7 +2845,7 @@ class PylotParaBox(QtGui.QWidget):
accepted = QtCore.Signal(str) accepted = QtCore.Signal(str)
rejected = QtCore.Signal(str) rejected = QtCore.Signal(str)
def __init__(self, parameter, parent=None): def __init__(self, parameter, parent=None, windowflag=1):
''' '''
Generate Widget containing parameters for PyLoT. Generate Widget containing parameters for PyLoT.
@ -2842,7 +2853,7 @@ class PylotParaBox(QtGui.QWidget):
:type: PylotParameter (object) :type: PylotParameter (object)
''' '''
QtGui.QWidget.__init__(self, parent) QtGui.QWidget.__init__(self, parent, windowflag)
self.parameter = parameter self.parameter = parameter
self.tabs = QtGui.QTabWidget() self.tabs = QtGui.QTabWidget()
self.layout = QtGui.QVBoxLayout() self.layout = QtGui.QVBoxLayout()

View File

@ -8,9 +8,22 @@ background-color: qlineargradient(spread:reflect, x1:0, y1:0, x2:0, y2:0.5, stop
color: rgba(255, 255, 255, 255); color: rgba(255, 255, 255, 255);
} }
QWidget:checked{
background-color: transparent;
border-color: rgba(100, 100, 120, 255);
border-width: 2px;
border-style:inset;
}
FigureCanvasQtAgg{
background-color: rgba(50, 50, 60, 255);
color: rgba(255, 255, 255, 255);
}
QComboBox{ QComboBox{
background-color: rgba(80, 80, 90, 255); background-color: rgba(80, 80, 90, 255);
color: rgba(255, 255, 255, 255); color: rgba(255, 255, 255, 255);
min-height: 1.5em;
} }
QComboBox *{ QComboBox *{
@ -35,9 +48,9 @@ color: rgba(255, 255, 255, 255);
padding:0; padding:0;
} }
QMenu::item:selected{ *::item:selected{
color: rgba(255, 255, 255, 255); color: rgba(255, 255, 255, 255);
background-color: rgba(200, 210, 230, 255); background-color: rgba(0, 150, 190, 255);
} }
QToolBar{ QToolBar{
@ -51,15 +64,6 @@ QToolBar *{
background-color: qlineargradient(spread:reflect, x1:0, y1:0, x2:0, y2:0.5, stop:0 rgba(70, 70, 80, 255), stop:1 rgba(60, 60, 70, 255)); background-color: qlineargradient(spread:reflect, x1:0, y1:0, x2:0, y2:0.5, stop:0 rgba(70, 70, 80, 255), stop:1 rgba(60, 60, 70, 255));
} }
QFileDialog QLabel{
color: rgba(0, 0, 0, 255);
}
QFileDialog QPushButton{
background-color: rgba(210, 210, 210, 255);
color: rgba(0, 0, 0, 255);
}
QMessageBox{ QMessageBox{
background-color: rgba(60, 60, 70, 255); background-color: rgba(60, 60, 70, 255);
color: rgba(255, 255, 255, 255); color: rgba(255, 255, 255, 255);
@ -103,16 +107,26 @@ color:rgba(255, 255, 255, 255);
} }
QPushButton{ QPushButton{
background-color:rgba(70, 70, 80, 255); background-color:qlineargradient(spread:reflect, x1:0, y1:0, x2:0, y2:0.5, stop:0 rgba(70, 70, 80, 255), stop:1 rgba(60, 60, 70, 255));
color:rgba(255, 255, 255, 255); color:rgba(255, 255, 255, 255);
border-color: (60, 60, 70, 255);
border-style: outset;
border-width: 2px;
border-color: rgba(50, 50, 60, 255);
min-width: 6em;
padding: 5px;
} }
QPushButton:pressed{ QPushButton:pressed{
background-color: rgba(70, 70, 80, 255); background-color: rgba(70, 70, 80, 255);
} }
*:disabled{
color:rgba(100, 100, 120, 255);
}
QTabBar{ QTabBar{
background-color:transparent background-color:transparent;
} }
QTabBar::tab{ QTabBar::tab{
@ -197,13 +211,12 @@ border-radius:0;
text-align:center; text-align:center;
color:rgba(255, 255, 255, 255); color:rgba(255, 255, 255, 255);
background-color:rgba(60,60,80,255); background-color:rgba(60,60,80,255);
border: 2px solid #e3a21a; border: 2px solid;
border-radius:7px; border-color:rgba(0, 150, 190, 255);
font: 75 12pt "Open Sans"; border-radius:5px;
} }
QProgressBar::chunk{ QProgressBar::chunk{
background-color:rgba(60, 60, 70, 255); background-color:rgba(0, 150, 190, 255);
width:10px; width:10px;
} }

View File

@ -1,44 +0,0 @@
# -*- coding: utf-8 -*-
# Set base phase colors for manual and automatic picks
# together with a modifier (r, g, or b) used to alternate
# the base color
phasecolors = {
'manual': {
'P':{
'rgba': (0, 0, 255, 255),
'modifier': 'g'},
'S':{
'rgba': (255, 0, 0, 255),
'modifier': 'b'}
},
'auto':{
'P':{
'rgba': (140, 0, 255, 255),
'modifier': 'g'},
'S':{
'rgba': (255, 140, 0, 255),
'modifier': 'b'}
}
}
# Set plot colors and stylesheet for each style
stylecolors = {
'default':{
'wf':{
'rgba': (0, 0, 0, 255)},
'background': {
'rgba': (255, 255, 255, 255)},
'stylesheet': {
'filename': None}
},
'dark':{
'wf':{
'rgba': (255, 255, 255, 255)},
'background':{
'rgba': (50, 50, 60, 255)},
'stylesheet': {
'filename': 'styles/dark.qss'}
}
}

View File

@ -0,0 +1,70 @@
# -*- coding: utf-8 -*-
# Set base phase colors for manual and automatic picks
# together with a modifier (r, g, or b) used to alternate
# the base color
phasecolors = {
'manual': {
'P':{
'rgba': (0, 0, 255, 255),
'modifier': 'g'},
'S':{
'rgba': (255, 0, 0, 255),
'modifier': 'b'}
},
'auto':{
'P':{
'rgba': (140, 0, 255, 255),
'modifier': 'g'},
'S':{
'rgba': (255, 140, 0, 255),
'modifier': 'b'}
}
}
# Set plot colors and stylesheet for each style
stylecolors = {
'default':{
'linecolor':{
'rgba': (0, 0, 0, 255)},
'background': {
'rgba': (255, 255, 255, 255)},
'multicursor': {
'rgba': (255, 190, 0, 255)},
'ref': {
'rgba': (200, 210, 230, 255)},
'test': {
'rgba': (200, 230, 200, 255)},
'stylesheet': {
'filename': None}
},
'dark': {
'linecolor': {
'rgba': (255, 255, 255, 255)},
'background': {
'rgba': (50, 50, 60, 255)},
'multicursor': {
'rgba': (0, 150, 190, 255)},
'ref': {
'rgba': (80, 110, 170, 255)},
'test': {
'rgba': (130, 190, 100, 255)},
'stylesheet': {
'filename': 'pylot/styles/dark.qss'}
},
'bright': {
'linecolor': {
'rgba': (0, 0, 0, 255)},
'background': {
'rgba': (255, 255, 255, 255)},
'multicursor': {
'rgba': (100, 100, 190, 255)},
'ref': {
'rgba': (200, 210, 230, 255)},
'test': {
'rgba': (200, 230, 200, 255)},
'stylesheet': {
'filename': 'pylot/styles/bright.qss'}
}
}

View File

@ -1,209 +0,0 @@
QMainWindow{
background-color: qlineargradient(spread:reflect, x1:0, y1:0, x2:0, y2:0.5, stop:0 rgba(70, 70, 80, 255), stop:1 rgba(60, 60, 70, 255));
color: rgba(255, 255, 255, 255);
}
QWidget{
background-color: qlineargradient(spread:reflect, x1:0, y1:0, x2:0, y2:0.5, stop:0 rgba(70, 70, 80, 255), stop:1 rgba(60, 60, 70, 255));
color: rgba(255, 255, 255, 255);
}
QComboBox{
background-color: rgba(80, 80, 90, 255);
color: rgba(255, 255, 255, 255);
}
QComboBox *{
background-color: rgba(80, 80, 90, 255);
color: rgba(255, 255, 255, 255);
}
QMenuBar{
background-color: qlineargradient(spread:pad, x1:0, y1:0, x2:0, y2:1, stop:0 rgba(70, 70, 80, 255), stop:1 rgba(60, 60, 70, 255));
padding:1px;
}
QMenuBar::item{
background-color: qlineargradient(spread:pad, x1:0, y1:0, x2:0, y2:1, stop:0 rgba(70, 70, 80, 255), stop:1 rgba(60, 60, 70, 255));
color: rgba(255, 255, 255, 255);
padding:3px;
}
QMenu{
background-color: qlineargradient(spread:pad, x1:0, y1:0, x2:0, y2:1, stop:0 rgba(70, 70, 80, 255), stop:1 rgba(60, 60, 70, 255));
color: rgba(255, 255, 255, 255);
padding:0;
}
QMenu::item:selected{
color: rgba(255, 255, 255, 255);
background-color: rgba(200, 210, 230, 255);
}
QToolBar{
background-color: qlineargradient(spread:reflect, x1:0, y1:0, x2:0, y2:0.5, stop:0 rgba(70, 70, 80, 255), stop:1 rgba(60, 60, 70, 255));
border-style:solid;
border-color:rgba(70, 70, 80, 255);
border-width:1px;
}
QToolBar *{
background-color: qlineargradient(spread:reflect, x1:0, y1:0, x2:0, y2:0.5, stop:0 rgba(70, 70, 80, 255), stop:1 rgba(60, 60, 70, 255));
}
QFileDialog QLabel{
color: rgba(0, 0, 0, 255);
}
QFileDialog QPushButton{
background-color: rgba(210, 210, 210, 255);
color: rgba(0, 0, 0, 255);
}
QMessageBox{
background-color: rgba(60, 60, 70, 255);
color: rgba(255, 255, 255, 255);
}
QTableWidget{
background-color: rgba(70, 70, 80, 255);
color:rgba(255, 255, 255, 255);
border-color:rgba(255, 255, 255, 255);
selection-background-color: rgba(200, 210, 230, 255);
}
QHeaderView::section{
background-color:qlineargradient(spread:pad, x1:0, y1:0, x2:1, y2:0, stop:0 rgba(60, 60, 70, 255), stop:1 rgba(70, 70, 80, 255));
border:none;
border-top-style:solid;
border-width:1px;
border-top-color:qlineargradient(spread:pad, x1:0, y1:0, x2:1, y2:0, stop:0 rgba(60, 60, 70, 255), stop:1 rgba(70, 70, 80, 255));
color:rgba(255, 255, 255, 255);
padding:5px;
}
QHeaderView{
background-color:qlineargradient(spread:pad, x1:0, y1:0, x2:1, y2:0, stop:0 rgba(60, 60, 70, 255), stop:1 rgba(70, 70, 80, 255));
border:none;
border-top-style:solid;
border-width:1px;
border-top-color:rgba(70, 70, 80, 255);
color:rgba(255, 255, 255, 255);
}
QListWidget{
background-color:rgba(200, 200, 200, 255);
color:rgba(255, 255, 255, 255);
}
QStatusBar{
background-color:rgba(60, 60, 70, 255);
color:rgba(255, 255, 255, 255);
}
QPushButton{
background-color:rgba(70, 70, 80, 255);
color:rgba(255, 255, 255, 255);
}
QPushButton:pressed{
background-color: rgba(70, 70, 80, 255);
}
QTabBar{
background-color:transparent
}
QTabBar::tab{
background-color:qlineargradient(spread:pad, x1:0, y1:0, x2:0, y2:1, stop:0 rgba(70, 70, 80, 255), stop:1 rgba(60, 60, 70, 255));
color: rgba(255, 255, 255, 255);
border-style:solid;
border-color:rgba(60, 60, 70, 255);
border-bottom-color: transparent;
border-width:1px;
padding:5px;
}
QTabBar::tab:selected{
background-color:rgba(80, 80, 90, 255);
color: rgba(255, 255, 255, 255);
border-style:solid;
border-color:rgba(80, 80, 90, 255);
border-bottom-color: transparent;
border-width:1px;
padding:5px;
}
QTabWidget{
background-color:transparent;
}
QTabWidget::pane{
background-color:rgba(255, 255, 255, 255);
border-style:solid;
border-color:rgba(80, 80, 90, 255);
border-width:1px;
}
QTabWidget::tab{
background-color:rgba(60, 60, 70, 255);
}
QTabWidget > QWidget{
background-color: rgba(60, 60, 70, 255);
color: rgba(255, 255, 255, 255);
}
QScrollArea{
background: transparent;
}
QScrollArea>QWidget>QWidget{
background: transparent;
}
QLabel{
color: rgba(255, 255, 255, 255);
background-color: transparent;
}
QTextEdit{
color: rgba(255, 255, 255, 255);
background-color: rgba(80, 80, 90, 255);
}
QSpinBox{
color: rgba(255, 255, 255, 255);
background-color: rgba(80, 80, 90, 255);
}
QDoubleSpinBox{
color: rgba(255, 255, 255, 255);
background-color: rgba(80, 80, 90, 255);
}
QLineEdit{
background-color: rgba(80, 80, 90, 255);
border-radius:0;
}
QListWidget{
background-color:rgba(60, 60, 70, 255)
}
QProgressBar{
border-radius:0;
text-align:center;
color:rgba(255, 255, 255, 255);
background-color:rgba(60,60,80,255);
border: 2px solid #e3a21a;
border-radius:7px;
font: 75 12pt "Open Sans";
}
QProgressBar::chunk{
background-color:rgba(60, 60, 70, 255);
width:10px;
}