Skip to content

Commit

Permalink
Merge pull request #55 from medusabci/developers
Browse files Browse the repository at this point in the history
Bug fixes
  • Loading branch information
esantamariavazquez authored Sep 18, 2023
2 parents 4cb2a36 + 9cb0aa8 commit 52e2255
Show file tree
Hide file tree
Showing 10 changed files with 395 additions and 143 deletions.
2 changes: 1 addition & 1 deletion src/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ class MedusaException(Exception):
"""

IMPORTANCES = ['critical', 'important', 'mild', 'unknown']
SCOPES = ['app', 'plots', 'log', 'acquisition', 'general']
SCOPES = ['app', 'plots', 'log', 'studies', 'acquisition', 'general']

def __init__(self, exception, uid=None, importance='unknown', msg=None,
scope=None, origin=None):
Expand Down
3 changes: 3 additions & 0 deletions src/gui/apps_panel/apps_panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ def reset_tool_bar_app_buttons(self):
config_icon = gu.get_icon("settings.svg", self.theme_colors)
search_icon = gu.get_icon("search.svg", self.theme_colors)
install_icon = gu.get_icon("add.svg", self.theme_colors)
undock_icon = gu.get_icon("open_in_new.svg", self.theme_colors)

# Set icons in buttons
self.toolButton_app_power.setIcon(power_icon)
Expand All @@ -163,6 +164,8 @@ def reset_tool_bar_app_buttons(self):
self.toolButton_app_config.setToolTip('Configure selected app')
self.toolButton_app_install.setToolTip('Install a new app')

self.toolButton_app_undock.setIcon(undock_icon)
self.toolButton_app_undock.setToolTip('Undock')
# Set button states
self.toolButton_app_power.setDisabled(False)
self.toolButton_app_play.setDisabled(True)
Expand Down
4 changes: 2 additions & 2 deletions src/gui/log_panel/log_panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,14 @@ def reset_tool_bar_log_buttons(self):
try:
# Creates QIcons for the app tool bar
log_save_icon = gu.get_icon("save_as.svg", self.theme_colors)
log_config_clean = gu.get_icon("delete_sweep.svg", self.theme_colors)
log_clean_icon = gu.get_icon("delete_sweep.svg", self.theme_colors)
log_config_icon = gu.get_icon("settings.svg", self.theme_colors)
log_undock_icon = gu.get_icon("open_in_new.svg", self.theme_colors)

# Set icons in buttons
self.toolButton_log_save.setIcon(log_save_icon)
self.toolButton_log_save.setToolTip('Save to file')
self.toolButton_log_clean.setIcon(log_config_clean)
self.toolButton_log_clean.setIcon(log_clean_icon)
self.toolButton_log_clean.setToolTip('Clear log')
self.toolButton_log_config.setIcon(log_config_icon)
self.toolButton_log_config.setToolTip('Log settings')
Expand Down
266 changes: 194 additions & 72 deletions src/gui/main_window.py

Large diffs are not rendered by default.

16 changes: 8 additions & 8 deletions src/gui/plots_panel/real_time_plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -879,14 +879,14 @@ def __init__(self, plot_handler):

def select_channel(self):
cha_label = self.sender().text()
for i in range(self.plot_handler.lsl_stream.n_cha):
if self.plot_handler.lsl_stream.l_cha[i] == cha_label:
for i in range(self.plot_handler.lsl_stream_info.n_cha):
if self.plot_handler.lsl_stream_info.l_cha[i] == cha_label:
self.plot_handler.select_channel(i)

def set_channel_list(self):
for i in range(self.plot_handler.lsl_stream.n_cha):
for i in range(self.plot_handler.lsl_stream_info.n_cha):
channel_action = QAction(
self.plot_handler.lsl_stream.l_cha[i], self)
self.plot_handler.lsl_stream_info.l_cha[i], self)
channel_action.triggered.connect(self.select_channel)
self.addAction(channel_action)

Expand Down Expand Up @@ -1470,14 +1470,14 @@ def __init__(self, psd_plot_handler):

def select_channel(self):
cha_label = self.sender().text()
for i in range(self.psd_plot_handler.lsl_stream.n_cha):
if self.psd_plot_handler.lsl_stream.l_cha[i] == cha_label:
for i in range(self.psd_plot_handler.lsl_stream_info.n_cha):
if self.psd_plot_handler.lsl_stream_info.l_cha[i] == cha_label:
self.psd_plot_handler.select_channel(i)

def set_channel_list(self):
for i in range(self.psd_plot_handler.lsl_stream.n_cha):
for i in range(self.psd_plot_handler.lsl_stream_info.n_cha):
channel_action = QAction(
self.psd_plot_handler.lsl_stream.l_cha[i], self)
self.psd_plot_handler.lsl_stream_info.l_cha[i], self)
channel_action.triggered.connect(self.select_channel)
self.addAction(channel_action)

Expand Down
Empty file.
99 changes: 99 additions & 0 deletions src/gui/studies_panel/studies_panel.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
# PYTHON MODULES
import sys
import json
import importlib
import multiprocessing as mp
# EXTERNAL MODULES
from PyQt5 import uic
from PyQt5.QtWidgets import *
from PyQt5.QtCore import *
from PyQt5.QtGui import *
# MEDUSA MODULES
from gui import gui_utils as gu
import constants, exceptions


ui_plots_panel_widget = \
uic.loadUiType('gui/ui_files/studies_panel_widget.ui')[0]


class StudiesPanelWidget(QWidget, ui_plots_panel_widget):

def __init__(self, medusa_interface, theme_colors):
super().__init__()
self.setupUi(self)
# Attributes
self.medusa_interface = medusa_interface
self.theme_colors = theme_colors
self.studies_settings = None
self.undocked = False
# Set up tool bar
self.set_up_tool_bar_studies()

def handle_exception(self, ex):
# Treat exception
if not isinstance(ex, exceptions.MedusaException):
ex = exceptions.MedusaException(
ex, importance='unknown',
scope='studies',
origin='studies_panel/studies_panel/handle_exception')
# Notify exception to gui main
self.medusa_interface.error(ex)

def set_undocked(self, undocked):
self.undocked = undocked
self.reset_tool_bar_studies_buttons()

def reset_tool_bar_studies_buttons(self):
try:
# Creates QIcons for the app tool bar
studies_config_icon = gu.get_icon("settings.svg", self.theme_colors)
studies_undock_icon = gu.get_icon("open_in_new.svg", self.theme_colors)

# Set icons in buttons
self.toolButton_studies_config.setIcon(studies_config_icon)
self.toolButton_studies_config.setToolTip('Studies settings')
self.toolButton_studies_undock.setIcon(studies_undock_icon)
self.toolButton_studies_undock.setToolTip('Undock')
except Exception as e:
self.handle_exception(e)

def set_up_tool_bar_studies(self):
"""This method creates the QAction buttons displayed in the toolbar
"""
try:
# Creates QIcons for the app tool bar
self.reset_tool_bar_studies_buttons()
# Connect signals to functions
self.toolButton_studies_config.clicked.connect(self.studies_config)
except Exception as e:
self.handle_exception(e)

def studies_config(self):
try:
raise Exception('Not implemented')
except Exception as e:
self.handle_exception(e)


class StudiesPanelWindow(QMainWindow):

close_signal = pyqtSignal()

def __init__(self, studies_panel_widget, theme_colors,
width=400, height=650):
super().__init__()
# self.plots_panel_widget = plots_panel_widget
self.theme_colors = theme_colors
self.setCentralWidget(studies_panel_widget)
gu.set_css_and_theme(self, self.theme_colors)
# Resize plots window
self.resize(width, height)
self.show()

def closeEvent(self, event):
self.close_signal.emit()
event.accept()

def get_plots_panel_widget(self):
return self.centralWidget()
7 changes: 7 additions & 0 deletions src/gui/ui_files/apps_panel_widget.ui
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,13 @@
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="toolButton_app_undock">
<property name="text">
<string>...</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
Expand Down
68 changes: 8 additions & 60 deletions src/gui/ui_files/main_window.ui
Original file line number Diff line number Diff line change
Expand Up @@ -14,65 +14,7 @@
<string>MainWindow</string>
</property>
<widget class="QWidget" name="centralwidget">
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QSplitter" name="splitter">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<widget class="QWidget" name="widget_left_side" native="true">
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QSplitter" name="splitter_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<widget class="QGroupBox" name="box_apps_panel">
<property name="font">
<font>
<pointsize>9</pointsize>
</font>
</property>
<property name="title">
<string>APPLICATIONS</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2"/>
</widget>
<widget class="QGroupBox" name="box_log_panel">
<property name="font">
<font>
<pointsize>9</pointsize>
</font>
</property>
<property name="title">
<string>LOG </string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_8"/>
</widget>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="widget_right_side" native="true">
<layout class="QVBoxLayout" name="verticalLayout_5">
<item>
<widget class="QGroupBox" name="box_plots_panel">
<property name="font">
<font>
<pointsize>9</pointsize>
</font>
</property>
<property name="title">
<string>REAL TIME PLOTS</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_9"/>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
<layout class="QVBoxLayout" name="verticalLayout_3"/>
</widget>
<widget class="QStatusBar" name="statusbar"/>
<widget class="QToolBar" name="toolBar">
Expand Down Expand Up @@ -101,7 +43,7 @@
<x>0</x>
<y>0</y>
<width>1037</width>
<height>22</height>
<height>21</height>
</rect>
</property>
<widget class="QMenu" name="menuInfo_2">
Expand Down Expand Up @@ -131,6 +73,7 @@
</widget>
<addaction name="menu_view"/>
<addaction name="menu_color_theme"/>
<addaction name="menuAction_study_mode"/>
</widget>
<widget class="QMenu" name="menuAbout">
<property name="title">
Expand Down Expand Up @@ -298,6 +241,11 @@
<string>Activate weak search</string>
</property>
</action>
<action name="menuAction_study_mode">
<property name="text">
<string>Activate study mode</string>
</property>
</action>
</widget>
<resources/>
<connections/>
Expand Down
73 changes: 73 additions & 0 deletions src/gui/ui_files/studies_panel_widget.ui
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Form</class>
<widget class="QWidget" name="Form">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QHBoxLayout" name="log_toolbar">
<item>
<widget class="QToolButton" name="toolButton_studies_config">
<property name="toolTip">
<string extracomment="Log settings"/>
</property>
<property name="text">
<string>...</string>
</property>
<property name="iconSize">
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QToolButton" name="toolButton_studies_undock">
<property name="toolTip">
<string extracomment="Undock"/>
</property>
<property name="text">
<string>...</string>
</property>
<property name="iconSize">
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QTreeView" name="treeView_studies"/>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

0 comments on commit 52e2255

Please sign in to comment.