Ejemplo n.º 1
0
 def save_geometries(self):
     """Saves the geometries of all saveable widgets that this tab
     has.
     """
     if not gutils.get_potku_setting(BaseTab.SAVE_WINDOW_GEOM_KEY, True):
         return
     for key, widget in self.get_saveable_widgets().items():
         if widget is not None:
             gutils.set_potku_setting(key, widget.subwindow.saveGeometry())
Ejemplo n.º 2
0
    def __add_efficiency(self):
        """Opens a dialog that allows the user to add efficiency files to
        the Efficiency_files folder of the detector.
        """
        eff_folder = gutils.get_potku_setting(
            DetectorSettingsWidget.EFF_FILE_FOLDER_KEY,
            self.request.default_folder)

        new_eff_files = fdialogs.open_files_dialog(
            self, eff_folder, "Select efficiency files",
            "Efficiency File (*.eff)")
        if not new_eff_files:
            return

        used_eff_files = {
            Detector.get_used_efficiency_file_name(f)
            for f in self.efficiency_files
        }

        for eff_file in new_eff_files:
            new_eff_file = Path(eff_file)
            used_eff_file = Detector.get_used_efficiency_file_name(new_eff_file)

            if used_eff_file not in used_eff_files:
                try:
                    self.obj.add_efficiency_file(new_eff_file)
                    used_eff_files.add(used_eff_file)
                except OSError as e:
                    QtWidgets.QMessageBox.critical(
                        self, "Error",
                        f"Failed to add the efficiency file: {e}\n",
                        QtWidgets.QMessageBox.Ok, QtWidgets.QMessageBox.Ok)
            else:
                QtWidgets.QMessageBox.critical(
                    self, "Error",
                    f"There already is an efficiency file for element "
                    f"{used_eff_file.stem}.\n",
                    QtWidgets.QMessageBox.Ok, QtWidgets.QMessageBox.Ok)

        self.efficiency_files = self.obj.get_efficiency_files()
        # Store the folder where we previously fetched an eff-file
        gutils.set_potku_setting(
            DetectorSettingsWidget.EFF_FILE_FOLDER_KEY,
            str(new_eff_file.parent))
Ejemplo n.º 3
0
    def __accept_changes(self):
        """Accept changed settings and save.
        """
        for button in self.groupBox_3.findChildren(QtWidgets.QPushButton):
            self.settings.set_element_color(button.text(), button.color)
        for key, coinc_timing in self.__added_timings.items():
            self.settings.set_import_timing(
                key, coinc_timing.low.value(), coinc_timing.high.value())
        self.settings.set_import_coinc_count(self.coinc_count)

        self.settings.set_cross_sections(self.cross_section)

        # ToF-E graph settings
        self.settings.set_tofe_invert_x(self.tofe_invert_x)
        self.settings.set_tofe_invert_y(self.tofe_invert_y)
        self.settings.set_tofe_transposed(self.tofe_transposed)
        self.settings.set_tofe_color(self.color_scheme)
        if self.radio_tofe_bin_auto.isChecked():
            self.settings.set_tofe_bin_range_mode(0)
        elif self.radio_tofe_bin_manual.isChecked():
            self.settings.set_tofe_bin_range_mode(1)

        self.settings.set_tofe_bin_range_x(*self.tofe_bin_x)
        self.settings.set_tofe_bin_range_y(*self.tofe_bin_y)
        self.settings.set_tofe_compression_x(self.comp_x)
        self.settings.set_tofe_compression_y(self.comp_y)
        self.settings.set_num_iterations(self.depth_iters)
        self.settings.set_min_presim_ions(self.presim_ions)
        self.settings.set_min_simulation_ions(self.sim_ions)
        self.settings.set_ion_division(self.ion_division)
        self.settings.set_minimum_concentration(self.min_concentration)

        gutils.set_potku_setting(
            BaseTab.SAVE_WINDOW_GEOM_KEY, self.save_window_geometries)

        # Save config and close
        self.settings.save_config()
        self.settings_updated.emit(self.settings)
        self.close()