Exemplo n.º 1
0
    def __import_external_file(self):
        """
        Import an external file that matches the format of hist and simu files.
        """
        QtWidgets.QMessageBox.information(
            self, "Notice",
            "The external file needs to have the following format:\n\n"
            "energy count\nenergy count\nenergy count\n...\n\n"
            "to match the simulation and measurement energy spectra files.",
            QtWidgets.QMessageBox.Ok, QtWidgets.QMessageBox.Ok)
        file_path = fdialogs.open_file_dialog(
            self, self.element_simulation.request.directory,
            "Select a file to import", "")
        if file_path is None:
            return

        name = file_path.name

        new_file_name = \
            self.element_simulation.request.get_imported_files_folder() / name

        if new_file_name.exists():
            QtWidgets.QMessageBox.critical(
                self, "Error", "A file with that name already exists.",
                QtWidgets.QMessageBox.Ok, QtWidgets.QMessageBox.Ok)
            return

        shutil.copyfile(file_path, new_file_name)

        item = QtWidgets.QTreeWidgetItem()
        item.setText(0, new_file_name.name)
        item.setData(0, QtCore.Qt.UserRole, new_file_name)
        item.setCheckState(0, QtCore.Qt.Checked)
        self.external_tree_widget.addTopLevelItem(item)
Exemplo n.º 2
0
    def __load_file(self):
        """Load settings from file.
        """
        file = fdialogs.open_file_dialog(self, self.request.default_folder,
                                         "Select detector file",
                                         "Detector File (*.detector)")
        if file is None:
            return

        temp_detector = Detector.from_file(file, self.request, False)
        self.obj.set_settings(**temp_detector.get_settings())

        self.tmp_foil_info = []
        self.tof_foils = []
        self.detector_structure_widgets = []
        # Remove old widgets
        for i in range(self.detectorScrollAreaContents.layout().count()):
            layout_item = self.detectorScrollAreaContents.layout().itemAt(i)
            if layout_item == self.foils_layout:
                self.detectorScrollAreaContents.layout().removeItem(
                    layout_item)
                for j in reversed(range(layout_item.count())):
                    layout_item.itemAt(j).widget().deleteLater()

        # Add foil widgets and foil objects
        self.foils_layout = self._add_default_foils(temp_detector)
        self.detectorScrollAreaContents.layout().addLayout(self.foils_layout)

        self.show_settings()
Exemplo n.º 3
0
    def load_selections(self):
        """Show dialog to load selections.
        """
        filename = open_file_dialog(self, self.measurement.directory,
                                    "Load Element Selection",
                                    "Selection file (*.selections)")
        if filename:
            sbh = StatusBarHandler(self.statusbar)
            sbh.reporter.report(40)

            self.measurement.load_selection(
                filename,
                progress=sbh.reporter.get_sub_reporter(lambda x: 40 + 0.6 * x))
            self.on_draw()
            self.elementSelectionSelectButton.setEnabled(True)

            sbh.reporter.report(100)

        self.__emit_selections_changed()
Exemplo n.º 4
0
 def __browse_files(self):
     self.filename = fdialogs.open_file_dialog(
         self, self.directory, "Select a measurement to load",
         "Raw Measurement (*.asc)")
     self.pathLineEdit.setText(str(self.filename))