Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • software_public/passoft/sohstationviewer
1 result
Show changes
Commits on Source (4)
......@@ -6,3 +6,8 @@ History
--------
* First release
2023.1.0.1
--------
* Fixed a problem with SOHViewer not fitting on smaller resolutions
package:
name: sohviewer
version: 2023.1.0.0
version: 2023.1.0.1
source:
path: ../
......
......@@ -51,6 +51,6 @@ setup(
name='sohstationviewer',
packages=find_packages(include=['sohstationviewer*']),
url='https://git.passcal.nmt.edu/software_public/passoft/sohstationviewer',
version='2023.1.0.0',
version='2023.1.0.1',
zip_safe=False,
)
from typing import Literal
# The current version of SOHStationViewer
SOFTWARE_VERSION = '2023.1.0.0'
SOFTWARE_VERSION = '2023.1.0.1'
# waveform pattern
WF_1ST = 'A-HLM-V'
......
......@@ -6,6 +6,7 @@ import traceback
from pathlib import Path
from PySide2 import QtWidgets
from PySide2.QtGui import QGuiApplication
from PySide2.QtWidgets import QMessageBox
from sohstationviewer.view.main_window import MainWindow
......@@ -14,7 +15,6 @@ from sohstationviewer.conf.config_processor import (
BadConfigError,
)
# Enable Layer-backing for MacOs version >= 11
# Only needed if using the pyside2 library with version>=5.15.
# Layer-backing is always enabled in pyside6.
......@@ -26,47 +26,91 @@ if os_name == 'macOS':
os.environ['QT_MAC_WANTS_LAYER'] = '1'
def main():
# Change the working directory so that relative paths work correctly.
def fix_relative_paths() -> None:
"""
Change the working directory so that the relative paths in the code work
correctly.
"""
current_file_path = os.path.abspath(__file__)
current_file_dir = Path(current_file_path).parent
os.chdir(current_file_dir)
def resize_windows(main_window: MainWindow):
"""
Resize the plotting windows in the program so that they fit well on all
screen resolutions.
"""
screen_size = QtWidgets.QApplication.primaryScreen().size().toTuple()
screen_width, screen_height = screen_size
main_window.resize(screen_width * 1, screen_height * 1)
main_window.waveform_dlg.resize(screen_width * (2 / 3),
screen_height * (2 / 3))
main_window.tps_dlg.resize(screen_width * (2 / 3), screen_height * (2 / 3))
main_right_x = (main_window.x() + main_window.frameSize().width())
# This offset is based on the hard-coded geometry previously assigned to
# the waveform and TPS dialogs
wf_tps_x_offset = 50
# We are moving the TPS dialog so that it is slightly offset from the right
# edge of the main window
tps_dlg_x = main_right_x - main_window.tps_dlg.width() - wf_tps_x_offset
wf_tps_y = 50
main_window.waveform_dlg.move(wf_tps_x_offset, wf_tps_y)
main_window.tps_dlg.move(tps_dlg_x, wf_tps_y)
gps_dlg_y = main_window.height() / 5
main_window.gps_dialog.move(main_window.gps_dialog.y(), gps_dlg_y)
def check_if_user_want_to_reset_config() -> bool:
"""
Show a dialog asking the user if they want to reset the config.
:return: whether the user wants to reset the config.
"""
bad_config_dialog = QMessageBox()
bad_config_dialog.setText('Something went wrong when reading the '
'config.')
bad_config_dialog.setDetailedText(traceback.format_exc())
bad_config_dialog.setInformativeText('Do you want to reset the config '
'file?')
bad_config_dialog.setStandardButtons(QMessageBox.Ok |
QMessageBox.Close)
bad_config_dialog.setDefaultButton(QMessageBox.Ok)
bad_config_dialog.setIcon(QMessageBox.Critical)
reset_choice = bad_config_dialog.exec_()
return reset_choice == QMessageBox.Ok
def main():
# Change the working directory so that relative paths work correctly.
fix_relative_paths()
app = QtWidgets.QApplication(sys.argv)
wnd = MainWindow()
config = ConfigProcessor()
config.load_config()
need_reset = False
do_reset = None
try:
config.validate_config()
config.apply_config(wnd)
except (BadConfigError, ValueError) as e:
bad_config_dialog = QMessageBox()
bad_config_dialog.setText('Something went wrong when reading the '
'config.')
bad_config_dialog.setDetailedText(traceback.format_exc())
bad_config_dialog.setInformativeText('Do you want to reset the config '
'file?')
bad_config_dialog.setStandardButtons(QMessageBox.Ok |
QMessageBox.Close)
bad_config_dialog.setDefaultButton(QMessageBox.Ok)
bad_config_dialog.setIcon(QMessageBox.Critical)
reset_choice = bad_config_dialog.exec_()
if reset_choice == QMessageBox.Ok:
need_reset = True
else:
sys.exit(1)
if need_reset:
do_reset = check_if_user_want_to_reset_config()
if do_reset:
try:
config.reset()
except OSError:
QMessageBox.critical(None, 'Cannot reset config',
'Config file cannot be reset. Please '
'ensure that it is not opened in another '
'program.',
'Config file cannot be reset. Please ensure '
'that it is not opened in another program.',
QMessageBox.Close)
sys.exit(1)
elif do_reset is not None:
sys.exit(1)
config.apply_config(wnd)
resize_windows(wnd)
wnd.show()
sys.exit(app.exec_())
......
......@@ -3,7 +3,7 @@ import sys
import os
import traceback
from pathlib import Path
from typing import List, Optional, Literal, Iterable
from typing import List, Optional, Literal, Iterable, Any
from PySide2 import QtWidgets, QtCore
from matplotlib.axes import Axes
......@@ -31,7 +31,7 @@ class GPSWidget(QtWidgets.QWidget):
# one point for each coordinate.
self.unique_gps_points: Optional[List[GPSPoint]] = None
self.fig = Figure(figsize=(6, 6), dpi=100)
self.fig = Figure(figsize=(6, 6), dpi=100, facecolor='#ECECEC')
self.canvas = Canvas(self.fig)
self.canvas.mpl_connect('pick_event', self.on_pick_event)
......@@ -156,7 +156,7 @@ class GPSWidget(QtWidgets.QWidget):
self.repaint()
self.tracking_box.clear()
def on_pick_event(self, event) -> None:
def on_pick_event(self, event) -> Any:
"""
On a GPS point being picked, display the data of that point on the
tracking box.
......@@ -172,13 +172,13 @@ class GPSWidget(QtWidgets.QWidget):
# and longitude follows correspondingly.
lat_dir = 'N' if picked_point.latitude > 0 else 'S'
long_dir = 'E' if picked_point.longitude > 0 else 'W'
meta_separator = ' ' * 22
loc_separator = ' ' * 10
meta_separator = ' ' * 7
loc_separator = ' ' * 5
msg = (
f'Mark: {picked_point.last_timemark}{meta_separator}'
f' Mark: {picked_point.last_timemark}{meta_separator}'
f'Fix: {picked_point.fix_type}{meta_separator}'
f'Sats: {picked_point.num_satellite_used}<br>'
f'Lat: {lat_dir}{abs(picked_point.latitude):.6f}{loc_separator}'
f' Lat: {lat_dir}{abs(picked_point.latitude):.6f}{loc_separator}'
f'Long: {long_dir}{abs(picked_point.longitude):.6f}{loc_separator}'
f'Elev: {picked_point.height}{picked_point.height_unit}'
)
......@@ -254,7 +254,7 @@ class GPSDialog(QtWidgets.QWidget):
bottom_layout = QtWidgets.QVBoxLayout()
bottom_layout.addLayout(button_layout)
self.info_text_browser.setFixedHeight(42)
self.info_text_browser.setFixedHeight(45)
bottom_layout.addWidget(self.info_text_browser)
main_layout.addLayout(bottom_layout)
......
......@@ -40,7 +40,6 @@ class TimePowerSquaredDialog(QtWidgets.QWidget):
"""
self.date_format: str = 'YYYY-MM-DD'
self.setGeometry(50, 50, 1200, 800)
self.setWindowTitle("TPS Plot")
main_layout = QtWidgets.QVBoxLayout()
......
......@@ -231,7 +231,7 @@ class TimePowerSquaredWidget(plotting_widget.PlottingWidget):
ax = self.create_axes(self.plotting_bot, plot_h)
ax.spines[['right', 'left', 'top', 'bottom']].set_visible(False)
ax.text(
-0.12, 1,
-0.15, 1,
f"{get_seismic_chan_label(chan_id)} {c_data['samplerate']}sps",
horizontalalignment='left',
verticalalignment='top',
......
......@@ -77,7 +77,6 @@ class WaveformDialog(QtWidgets.QWidget):
date_format: format for date
"""
self.date_format: str = 'YYYY-MM-DD'
self.setGeometry(50, 10, 1600, 700)
self.setWindowTitle("Raw Data Plot")
main_layout = QtWidgets.QVBoxLayout()
......
......@@ -7,6 +7,7 @@ from PySide2.QtWidgets import (
QMainWindow, QWidget, QTextBrowser, QPushButton, QLineEdit, QDateEdit,
QListWidget, QCheckBox, QRadioButton, QMenu, QLabel, QFrame,
QVBoxLayout, QHBoxLayout, QGridLayout, QAbstractItemView, QButtonGroup,
QSplitter,
)
from PySide2.QtWidgets import (
QAction, QActionGroup, QShortcut
......@@ -279,7 +280,6 @@ class UIMainWindow(object):
:param main_window: QMainWindow - main GUI for user to interact with
"""
self.main_window = main_window
main_window.resize(1798, 1110)
main_window.setWindowTitle("SOH Station Viewer")
self.central_widget = QWidget(main_window)
main_window.setCentralWidget(self.central_widget)
......@@ -294,8 +294,6 @@ class UIMainWindow(object):
self.set_first_row(main_layout)
self.set_second_row(main_layout)
self.tracking_info_text_browser.setFixedHeight(80)
main_layout.addWidget(self.tracking_info_text_browser)
self.create_menu_bar(main_window)
self.connect_signals(main_window)
self.create_shortcuts(main_window)
......@@ -352,7 +350,7 @@ class UIMainWindow(object):
left_widget = QWidget(self.central_widget)
h_layout.addWidget(left_widget)
left_widget.setFixedWidth(240)
left_widget.setMinimumHeight(650)
# left_widget.setMinimumHeight(650)
left_layout = QVBoxLayout()
left_layout.setContentsMargins(0, 0, 0, 0)
left_layout.setSpacing(0)
......@@ -360,12 +358,22 @@ class UIMainWindow(object):
self.set_control_column(left_layout)
plot_splitter = QSplitter(QtCore.Qt.Orientation.Vertical)
h_layout.addWidget(plot_splitter, 2)
self.plotting_widget = SOHWidget(self.main_window,
self.tracking_info_text_browser,
'SOH',
self.main_window)
plot_splitter.addWidget(self.plotting_widget)
h_layout.addWidget(self.plotting_widget, 2)
self.tracking_info_text_browser.setMinimumHeight(60)
self.tracking_info_text_browser.setMaximumHeight(80)
plot_splitter.addWidget(self.tracking_info_text_browser)
tracking_browser_idx = plot_splitter.indexOf(
self.tracking_info_text_browser
)
plot_splitter.setCollapsible(tracking_browser_idx, False)
def set_control_column(self, left_layout):
"""
......