Skip to content

Commit

Permalink
add configuration of inital plan search path, move AE Title, self AE …
Browse files Browse the repository at this point in the history
…Title (for future C-STORE), export staging directory (for RTBDI and UPS)
  • Loading branch information
sjswerdloff committed Jun 17, 2024
1 parent 00b0e89 commit 2a86785
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 5 deletions.
9 changes: 9 additions & 0 deletions rtbdi.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Default configuration file for scheduling tool

## Application settings
[DEFAULT]
qr_ae_title = "OST"
# Our AE Title
ae_title = "TMS"
export_staging_directory = "~/BDIFolder"
plan_path = "~/SamplePlanFolder"
8 changes: 8 additions & 0 deletions tdwii_plus_examples/rtbdi_creator/form.ui
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@
<height>600</height>
</rect>
</property>
<property name="font">
<font>
<family>.AppleSystemUIFont</family>
</font>
</property>
<property name="windowTitle">
<string>RT Beams Delivery Instruction and UPS Creator</string>
</property>
Expand Down Expand Up @@ -37,6 +42,9 @@
<property name="decimals">
<number>0</number>
</property>
<property name="value">
<double>1.000000000000000</double>
</property>
</widget>
</item>
<item row="0" column="0">
Expand Down
36 changes: 32 additions & 4 deletions tdwii_plus_examples/rtbdi_creator/mainbdiwidget.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
#!/usr/bin/env python
# This Python file uses the following encoding: utf-8
import logging
import sys
from datetime import datetime
from pathlib import Path
from typing import List

import tomli
from PySide6.QtCore import QDateTime, Qt, Slot # pylint: disable=no-name-in-module
from PySide6.QtWidgets import ( # pylint: disable=no-name-in-module
QApplication,
Expand Down Expand Up @@ -52,19 +54,45 @@ def __init__(self, parent=None):
self.ui.push_button_bdi_dir_finder.clicked.connect(self._bdidir_button_clicked)
self.ui.push_button_export_bdi.clicked.connect(self._bdi_export_button_clicked)
self.ui.push_button_export_ups.clicked.connect(self._export_ups_button_clicked)

self.plan = None
self.plan_path = Path("~/").expanduser()
self.rtbdi = None
self.export_path = Path("~/") # home for a default isn't the worst choice
self.export_path = Path("~/").expanduser() # home for a default isn't the worst choice
self.fraction_number = 1
self.retrieve_ae_title = ""
self.scheduled_datetime = datetime.now
self.ae_title = "TMS"
config_file = "rtbdi.toml"
# TODO: command line argument specifying a different config file
try:
with open(config_file, "rb") as f:
toml_dict = tomli.load(f)
if "DEFAULT" in toml_dict:
default_dict = toml_dict["DEFAULT"]
if "export_staging_directory" in default_dict:
export_staging_directory = Path(default_dict["export_staging_directory"]).expanduser()
self.ui.lineedit_bdidir_selector.setText(str(export_staging_directory))
if "qr_ae_title" in default_dict:
self.ui.line_edit_move_scp_ae_title.setText(toml_dict["DEFAULT"]["qr_ae_title"])
if "ae_title" in default_dict:
self.ae_title = default_dict["ae_title"]
if "plan_path" in default_dict:
self.plan_path = str(Path(default_dict["plan_path"]).expanduser())
else:
logging.warning("No [DEFAULT] section in toml config file")

except OSError as config_file_error:
logging.exception("Problem parsing config file: " + config_file)

@Slot()
def _plan_button_clicked(self):
file_name, ok = QFileDialog.getOpenFileName(self, "Open Plan", "~/", "Image Files (*.dcm)")
previous_path = self.plan_path
file_name, ok = QFileDialog.getOpenFileName(self, "Open Plan", str(previous_path), "Image Files (*.dcm)")
if file_name:
path = Path(file_name)
self.ui.lineedit_plan_selector.insert(str(path))
self.ui.lineedit_plan_selector.setText(str(path))
self.plan_path = path.parent
# print("Plan Button Clicked")

@Slot()
Expand All @@ -78,7 +106,7 @@ def _bdidir_button_clicked(self):
file_name = dialog.selectedFiles()[0]
if file_name:
path = Path(file_name)
self.ui.lineedit_bdidir_selector.insert(str(path))
self.ui.lineedit_bdidir_selector.setText(str(path))

# fraction_number = round(self.ui.double_spin_box_fraction_number.value())

Expand Down
6 changes: 5 additions & 1 deletion tdwii_plus_examples/rtbdi_creator/ui_form.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
################################################################################
## Form generated from reading UI file 'form.ui'
##
## Created by: Qt User Interface Compiler version 6.6.2
## Created by: Qt User Interface Compiler version 6.7.1
##
## WARNING! All changes made in this file will be lost when recompiling UI file!
################################################################################
Expand Down Expand Up @@ -61,6 +61,9 @@ def setupUi(self, MainBDIWidget):
if not MainBDIWidget.objectName():
MainBDIWidget.setObjectName("MainBDIWidget")
MainBDIWidget.resize(800, 600)
font = QFont()
font.setFamilies([".AppleSystemUIFont"])
MainBDIWidget.setFont(font)
self.group_box_bdi_variables = QGroupBox(MainBDIWidget)
self.group_box_bdi_variables.setObjectName("group_box_bdi_variables")
self.group_box_bdi_variables.setGeometry(QRect(40, 110, 491, 121))
Expand All @@ -70,6 +73,7 @@ def setupUi(self, MainBDIWidget):
self.double_spin_box_fraction_number.setObjectName("double_spin_box_fraction_number")
self.double_spin_box_fraction_number.setAlignment(Qt.AlignRight | Qt.AlignTrailing | Qt.AlignVCenter)
self.double_spin_box_fraction_number.setDecimals(0)
self.double_spin_box_fraction_number.setValue(1.000000000000000)

self.gridLayout_3.addWidget(self.double_spin_box_fraction_number, 0, 1, 1, 1)

Expand Down

0 comments on commit 2a86785

Please sign in to comment.