Exemplo n.º 1
0
class VOIWidget(QtWidgets.QFrame):
    def __init__(self, widget_file):
        super().__init__()
        widget_path = Path(Path(__file__).parent, "widgets",
                           widget_file).resolve()
        uic.loadUi(widget_path, self)

        self._name = LineEdit(self.name_lineEdit)
        self._center = [
            LineEdit(self.centerX_lineEdit),
            LineEdit(self.centerY_lineEdit),
            LineEdit(self.centerZ_lineEdit)
        ]

        validator = QRegularExpressionValidator(Regex.STRING.value)
        self._name.enable_validation(validator)

        validator = QRegularExpressionValidator(Regex.FLOAT.value)
        enable_validation_list(validator, self._center)

    @property
    def name(self):
        return self._name.text

    @property
    def center(self):
        return [float(field.text) for field in self._center]

    def validate(self) -> bool:
        return self._name.validate() and validate_list(self._center)

    def disable_fields(self) -> None:
        self._name.set_enabled(False)
        for field in self._center:
            field.set_enabled(False)
Exemplo n.º 2
0
    def __init__(self):
        super().__init__("spherical_voi.ui")

        self._radius = LineEdit(self.radius_lineEdit)

        validator = QRegularExpressionValidator(Regex.FLOAT_UNSIGNED.value)
        self._radius.enable_validation(validator)
Exemplo n.º 3
0
class CylindricalVOIWidget(VOIWidget):
    def __init__(self):
        super().__init__("cylindrical_voi.ui")

        self._radius = LineEdit(self.radius_lineEdit)
        self._depth = LineEdit(self.depth_lineEdit)

        validator = QRegularExpressionValidator(Regex.FLOAT_UNSIGNED.value)
        self._radius.enable_validation(validator)
        self._depth.enable_validation(validator)

    @property
    def radius(self):
        return float(self._radius.text)

    @property
    def depth(self):
        return float(self._depth.text)

    def validate(self) -> bool:
        return super().validate() and self._radius.validate(
        ) and self._depth.validate()

    def disable_fields(self) -> None:
        super().disable_fields()
        self._radius.set_enabled(False)
        self._depth.set_enabled(False)
Exemplo n.º 4
0
    def __init__(self):
        super().__init__("cuboidal_voi.ui")

        self._width = LineEdit(self.width_lineEdit)
        self._height = LineEdit(self.height_lineEdit)
        self._depth = LineEdit(self.depth_lineEdit)
        self._dims = [self._width, self._height, self._depth]

        validator = QRegularExpressionValidator(Regex.FLOAT_UNSIGNED.value)
        enable_validation_list(validator, self._dims)
Exemplo n.º 5
0
    def __init__(self, widget_file):
        super().__init__()
        widget_path = Path(Path(__file__).parent, "widgets",
                           widget_file).resolve()
        uic.loadUi(widget_path, self)

        self._name = LineEdit(self.name_lineEdit)
        self._center = [
            LineEdit(self.centerX_lineEdit),
            LineEdit(self.centerY_lineEdit),
            LineEdit(self.centerZ_lineEdit)
        ]

        validator = QRegularExpressionValidator(Regex.STRING.value)
        self._name.enable_validation(validator)

        validator = QRegularExpressionValidator(Regex.FLOAT.value)
        enable_validation_list(validator, self._center)
Exemplo n.º 6
0
    def __init__(self, parent=None):
        self._ui = EmptyPatientDialog(parent)
        self.name = LineEdit(self._ui.name_lineEdit)
        self.hu_value = LineEditMath(self._ui.hUValue_lineEdit)

        self.dimensions_tabs = TabWidget(self._ui.dimensions_tabWidget)
        self.dimensions_fields = [{
            "width":
            LineEditMath(self._ui.width_lineEdit_1),
            "height":
            LineEditMath(self._ui.height_lineEdit_1),
            "depth":
            LineEditMath(self._ui.depth_lineEdit_1),
            "slice_distance":
            LineEditMath(self._ui.sliceDistance_lineEdit_1),
            "pixel_size":
            LineEditMath(self._ui.pixelSize_lineEdit_1),
        }, {
            "width":
            LineEditMath(self._ui.width_lineEdit_2),
            "height":
            LineEditMath(self._ui.height_lineEdit_2),
            "depth":
            LineEditMath(self._ui.depth_lineEdit_2),
            "slice_number":
            LineEditMath(self._ui.sliceNumber_lineEdit_2),
            "pixel_number_x":
            LineEditMath(self._ui.pixelNumberX_lineEdit_2),
            "pixel_number_y":
            LineEditMath(self._ui.pixelNumberY_lineEdit_2),
        }, {
            "slice_number":
            LineEditMath(self._ui.sliceNumber_lineEdit_3),
            "slice_distance":
            LineEditMath(self._ui.sliceDistance_lineEdit_3),
            "pixel_number_x":
            LineEditMath(self._ui.pixelNumberX_lineEdit_3),
            "pixel_number_y":
            LineEditMath(self._ui.pixelNumberY_lineEdit_3),
            "pixel_size":
            LineEditMath(self._ui.pixelSize_lineEdit_3),
        }]

        self.xoffset = LineEditMath(self._ui.xOffset_lineEdit)
        self.yoffset = LineEditMath(self._ui.yOffset_lineEdit)
        self.slice_offset = LineEditMath(self._ui.sliceOffset_lineEdit)

        self.accept = self._ui.accept
        self.accept_buttons = self._ui.accept_buttonBox
Exemplo n.º 7
0
class ConfigQtView:
    stackedWidget_local_index = 0
    stackedWidget_remote_index = 1
    """
    """
    def __init__(self, parent=None):
        self._ui = UiTripConfig(parent)

        self.name = LineEdit(self._ui.configName_lineEdit)
        self.user_name = LineEdit(self._ui.username_lineEdit)
        self.pkey_path = LineEdit(self._ui.pkey_lineEdit)
        self.password = LineEdit(self._ui.password_lineEdit)
        self.host_name = LineEdit(self._ui.host_lineEdit)
        self.dedx_path = LineEdit(self._ui.dedx_lineEdit)
        self.hlut_path = LineEdit(self._ui.hlut_lineEdit)
        self.wdir_path = LineEdit(self._ui.wdirPath_lineEdit)
        self.trip_path = LineEdit(self._ui.tripPath_lineEdit)

        self.add_button = PushButton(self._ui.add_pushButton)
        self.remove_button = PushButton(self._ui.remove_pushButton)

        self.wdir_remote_path = LineEdit(self._ui.wdirRemote_lineEdit)

        self.configs = ComboBox(self._ui.configs_comboBox)

        self.info_box = UserInfoBox(self._ui)

        self._setup_internal_callbacks()
        self._ui.local_radioButton.clicked.emit()

        self.name.emit_on_text_change(self.configs.set_current_item_text)

    def test_ssh_clicked_callback_connect(self, callback):
        self._ui.testSsh_pushButton.clicked.connect(callback)

    def _setup_internal_callbacks(self):
        self._ui.wdirPath_pushButton.clicked.connect(self._browse_wdir)
        self._ui.tripPath_pushButton.clicked.connect(self._browse_trip_path)
        self._ui.hlut_pushButton.clicked.connect(self._browse_hlut_path)
        self._ui.dedx_pushButton.clicked.connect(self._browse_dedx_path)
        self._ui.pKey_pushButton.clicked.connect(self._browse_pkey_path)

        self._ui.local_radioButton.clicked.connect(
            self._on_local_radio_button_click)
        self._ui.remote_radioButton.clicked.connect(
            self._on_remote_radio_button_click)

    def _browse_wdir(self):
        selected_dir = QFileDialog.getExistingDirectory(
            self._ui, "Select working directory", self.wdir_path.text,
            QFileDialog.ShowDirsOnly | QFileDialog.DontResolveSymlinks)
        if selected_dir != "":
            self.wdir_path.text = selected_dir

    def _browse_trip_path(self):
        selected_dir = QFileDialog.getExistingDirectory(
            self._ui, "Select trip executable directory", self.trip_path.text,
            QFileDialog.ShowDirsOnly | QFileDialog.DontResolveSymlinks)
        if selected_dir != "":
            self.trip_path.text = selected_dir

    def _browse_hlut_path(self):
        selected_file = QFileDialog.getOpenFileName(
            self._ui, "Select HLUT", self.hlut_path.text,
            "Hounsfield lookup table (*.hlut)")
        if selected_file[0] != "":
            self.hlut_path.text = selected_file[0]

    def _browse_dedx_path(self):
        selected_file = QFileDialog.getOpenFileName(
            self._ui, "Select DEDX", self.dedx_path.text,
            "Stopping power table (*.dedx)")
        if selected_file[0] != "":
            print(selected_file)
            self.dedx_path.text = selected_file[0]

    def _browse_pkey_path(self):
        selected_file = QFileDialog.getOpenFileName(
            self._ui, "Select private key for SSH connection",
            self.pkey_path.text, "Private key (*)")
        if selected_file[0] != "":
            self.pkey_path.text = selected_file[0]

    def _on_local_radio_button_click(self):
        self._ui.local_radioButton.setChecked(True)
        self._ui.tripPath_pushButton.setVisible(True)
        self._ui.hlut_pushButton.setVisible(True)
        self._ui.dedx_pushButton.setVisible(True)
        self._ui.ssh_GroupBox.setEnabled(False)
        self._ui.remoteLocal_groupBox.setTitle("Local paths")

    def _on_remote_radio_button_click(self):
        self._ui.remote_radioButton.setChecked(True)
        self._ui.tripPath_pushButton.setVisible(False)
        self._ui.hlut_pushButton.setVisible(False)
        self._ui.dedx_pushButton.setVisible(False)
        self._ui.ssh_GroupBox.setEnabled(True)
        self._ui.remoteLocal_groupBox.setTitle("Remote paths")

    def show(self):
        self._ui.show()
        self._ui.exec_()

    def exit(self):
        self._ui.close()

    def set_ok_callback(self, fun):
        self._ui.accept_buttonBox.accepted.connect(fun)

    def set_cancel_callback(self, fun):
        self._ui.accept_buttonBox.rejected.connect(fun)

    @property
    def remote_execution(self):
        return self._ui.remote_radioButton.isChecked()

    @remote_execution.setter
    def remote_execution(self, remote_execution):
        if remote_execution:
            self._ui.remote_radioButton.clicked.emit()
        else:
            self._ui.local_radioButton.clicked.emit()
Exemplo n.º 8
0
    def __init__(self, parent=None):
        self._ui = UiTripConfig(parent)

        self.name = LineEdit(self._ui.configName_lineEdit)
        self.user_name = LineEdit(self._ui.username_lineEdit)
        self.pkey_path = LineEdit(self._ui.pkey_lineEdit)
        self.password = LineEdit(self._ui.password_lineEdit)
        self.host_name = LineEdit(self._ui.host_lineEdit)
        self.dedx_path = LineEdit(self._ui.dedx_lineEdit)
        self.hlut_path = LineEdit(self._ui.hlut_lineEdit)
        self.wdir_path = LineEdit(self._ui.wdirPath_lineEdit)
        self.trip_path = LineEdit(self._ui.tripPath_lineEdit)

        self.add_button = PushButton(self._ui.add_pushButton)
        self.remove_button = PushButton(self._ui.remove_pushButton)

        self.wdir_remote_path = LineEdit(self._ui.wdirRemote_lineEdit)

        self.configs = ComboBox(self._ui.configs_comboBox)

        self.info_box = UserInfoBox(self._ui)

        self._setup_internal_callbacks()
        self._ui.local_radioButton.clicked.emit()

        self.name.emit_on_text_change(self.configs.set_current_item_text)