[update] increased flexibility of ArrayMap class

This commit is contained in:
Marcel Paffrath 2019-09-05 17:19:40 +02:00
parent 7382ca5d47
commit b39489b253
3 changed files with 17 additions and 11 deletions

View File

@ -3056,7 +3056,7 @@ class MainWindow(QMainWindow):
self.init_metadata() self.init_metadata()
if not self.metadata: if not self.metadata:
return return
self.array_map = Array_map(self) self.array_map = Array_map(self, self.metadata)
# self.array_map_thread() # self.array_map_thread()
self.array_layout.addWidget(self.array_map) self.array_layout.addWidget(self.array_map)
self.tabs.setCurrentIndex(index) self.tabs.setCurrentIndex(index)

View File

@ -17,7 +17,7 @@ plt.interactive(False)
class Array_map(QtGui.QWidget): class Array_map(QtGui.QWidget):
def __init__(self, parent, figure=None, pointsize=30.): def __init__(self, parent, metadata, figure=None, pointsize=30., width=5e6, height=2e6):
''' '''
Create a map of the array. Create a map of the array.
:param parent: PyLoT Mainwindow class :param parent: PyLoT Mainwindow class
@ -25,8 +25,10 @@ class Array_map(QtGui.QWidget):
''' '''
QtGui.QWidget.__init__(self) QtGui.QWidget.__init__(self)
self._parent = parent self._parent = parent
self.metadata = parent.metadata self.metadata = metadata
self.pointsize = pointsize self.pointsize = pointsize
self.width = width
self.height = height
self.picks = None self.picks = None
self.picks_dict = None self.picks_dict = None
self.autopicks_dict = None self.autopicks_dict = None
@ -39,7 +41,7 @@ class Array_map(QtGui.QWidget):
self.init_stations() self.init_stations()
self.init_basemap(resolution='l') self.init_basemap(resolution='l')
self.init_map() self.init_map()
self._style = parent._style self._style = None if not hasattr(parent, '_style') else parent._style
# self.show() # self.show()
@property @property
@ -213,6 +215,7 @@ class Array_map(QtGui.QWidget):
self.status_label = QtGui.QLabel() self.status_label = QtGui.QLabel()
self.main_ax = self.figure.add_subplot(111) self.main_ax = self.figure.add_subplot(111)
self.main_ax.set_facecolor('0.7')
self.canvas = PylotCanvas(self.figure, parent=self._parent, multicursor=True, self.canvas = PylotCanvas(self.figure, parent=self._parent, multicursor=True,
panZoomX=False, panZoomY=False) panZoomX=False, panZoomY=False)
@ -313,10 +316,8 @@ class Array_map(QtGui.QWidget):
def init_basemap(self, resolution='l'): def init_basemap(self, resolution='l'):
# basemap = Basemap(projection=projection, resolution = resolution, ax=self.main_ax) # basemap = Basemap(projection=projection, resolution = resolution, ax=self.main_ax)
width = 5e6
height = 2e6
basemap = Basemap(projection='lcc', resolution=resolution, ax=self.main_ax, basemap = Basemap(projection='lcc', resolution=resolution, ax=self.main_ax,
width=width, height=height, width=self.width, height=self.height,
lat_0=(self.latmin + self.latmax) / 2., lat_0=(self.latmin + self.latmax) / 2.,
lon_0=(self.lonmin + self.lonmax) / 2.) lon_0=(self.lonmin + self.lonmax) / 2.)

View File

@ -981,7 +981,12 @@ class PylotCanvas(FigureCanvas):
self.axes = figure.axes self.axes = figure.axes
self.figure = figure self.figure = figure
self.figure.set_facecolor(parent._style['background']['rgba_mpl']) if hasattr(parent, '_style'):
self.style = parent._style
else:
self.style = None
if self.style:
self.figure.set_facecolor(self.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
@ -990,10 +995,11 @@ class PylotCanvas(FigureCanvas):
self.orig_parent = parent self.orig_parent = parent
if multicursor: if multicursor:
color_cursor = (0., 0., 0., 1.) if not self.style else self.style['multicursor']['rgba_mpl']
# 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=parent._style['multicursor']['rgba_mpl'], lw=1) color=color_cursor, lw=1)
# initialize panning attributes # initialize panning attributes
self.press = None self.press = None
@ -1322,8 +1328,7 @@ class PylotCanvas(FigureCanvas):
nslc.sort() nslc.sort()
nslc.reverse() nslc.reverse()
style = self.orig_parent._style linecolor = (0., 0., 0., 1.) if not self.style else self.style['linecolor']['rgba_mpl']
linecolor = style['linecolor']['rgba_mpl']
for n, seed_id in enumerate(nslc): for n, seed_id in enumerate(nslc):
network, station, location, channel = seed_id.split('.') network, station, location, channel = seed_id.split('.')