Skip to content

Commit

Permalink
disabled toolbear features in testing + added timer timestamps to log
Browse files Browse the repository at this point in the history
  • Loading branch information
zemmyang committed Jul 24, 2022
1 parent 86c0b5d commit 168a9d5
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 66 deletions.
13 changes: 9 additions & 4 deletions MRICenterline/app/config/config_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,16 @@ def get_color(self, section, key):
as_list = [int(i) / 255 for i in rgb_str]
return tuple(as_list)

def get_testing_status(self, testing):
if self.config_file['testing'][testing]:
return self.config_file.getboolean('testing', testing)
else:
def get_testing_status(self, testing: str or None):
if (self.config_file['testing']['disable-all-testing-features']
and self.config_file.getboolean('testing', 'disable-all-testing-features')) \
or testing is None:
return False
else:
if self.config_file['testing'][testing]:
return self.config_file.getboolean('testing', testing)
else:
return False

def get_boolean(self, section, key):
return self.config_file.getboolean(section, key)
Expand Down
1 change: 1 addition & 0 deletions MRICenterline/app/database/openable_sessions.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ def get_all_sessions():


def get_latest_sessions():
# TODO: show only latest sessions on custom open dialog
# select * from 'sessions' group by case_id order by timestamp desc
pass

Expand Down
4 changes: 3 additions & 1 deletion MRICenterline/app/gui_data_handling/case_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,9 @@ def calculate(self, status: PointStatus):
self.centerline_model.calculate_length()

def timer_status(self, status):
logging.info(f"Timer set to {status}")
import time

logging.info(f"Timer set to {status} on {int(time.time())}")
self.timer.command(status)

def undo(self, undo_all: bool = False):
Expand Down
2 changes: 1 addition & 1 deletion MRICenterline/app/gui_data_handling/centerline_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def save(self):
print("save points")

def refresh_panel(self, angle_change=None, height_change=None):
if CFG.get_testing_status("test-mode"):
if CFG.get_testing_status("running-for-tests"):
self.calculate_centerline()
self.centerline_viewer.refresh_panel(angle_change, height_change)
else:
Expand Down
5 changes: 5 additions & 0 deletions MRICenterline/gui/display/toolbar.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from MRICenterline.app.points.status import PickerStatus, PointStatus
from MRICenterline.app.gui_data_handling.case_model import CaseModel
from MRICenterline.gui.display import toolbar_connect
from MRICenterline import CFG


class DisplayPanelToolbarButtons(QWidget):
Expand All @@ -25,6 +26,8 @@ def __init__(self,
export_button.setFlat(True)
layout.addWidget(export_button, 1, column, 1, 1)
export_button.clicked.connect(lambda: toolbar_connect.export(model, parent))
export_button.setEnabled(CFG.get_testing_status(testing=None)) # TODO: populate the export functions

# endregion

# region length
Expand Down Expand Up @@ -123,6 +126,8 @@ def show_hide_mpr_markers(s):
comment_button.setFlat(True)
layout.addWidget(comment_button, 1, column, 1, 1)
comment_button.clicked.connect(lambda: toolbar_connect.comment(model, parent))
comment_button.setEnabled(CFG.get_testing_status(testing=None)) # TODO: implement the comment dialog

# endregion

# region window/level + intermediate points
Expand Down
3 changes: 3 additions & 0 deletions MRICenterline/gui/window/Toolbar.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from PyQt5.QtWidgets import QToolBar, QPushButton

from MRICenterline.gui.window import toolbar_connect
from MRICenterline import CFG


class IUToolbar(QToolBar):
Expand All @@ -14,6 +15,7 @@ def __init__(self, parent=None):
new_case_button.setFlat(True)
self.addWidget(new_case_button)
new_case_button.clicked.connect(parent.open_new_case)
new_case_button.setEnabled(CFG.get_testing_status(testing=None)) # TODO: fix the new case bug

setting_button = QPushButton(qta.icon('fa.gear'), "Settings")
setting_button.setFlat(True)
Expand All @@ -24,3 +26,4 @@ def __init__(self, parent=None):
help_button.setFlat(True)
self.addWidget(help_button)
help_button.clicked.connect(lambda: toolbar_connect.open_help_dialog(self))
help_button.setEnabled(CFG.get_testing_status(testing=None)) # TODO: populate the help dialog
57 changes: 0 additions & 57 deletions config.ini.bak

This file was deleted.

5 changes: 2 additions & 3 deletions default_config.ini
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,11 @@ line-thickness = 10
line-style = line

[testing]
disable-all-testing-features = on
use-slice-location = off
draw-connecting-lines = off
ignore-uneven-slices = off
point-editing = off
show-memory-usage = on
show-fixer-button = on
show-sliders = off
point-shifter = on
test-mode = off
running-for-tests = off

0 comments on commit 168a9d5

Please sign in to comment.