Exemplo n.º 1
0
    def fill_existing_entries(self, component_to_edit: Component):
        """
        Populate the pixel fields based on what is already stored in the NeXus file.
        """
        self.reset_pixel_mapping_table()

        try:
            component_to_edit.get_field_value(X_PIXEL_OFFSET)
            self.single_pixel_radio_button.setChecked(True)
            self.update_pixel_layout_visibility(True, False)
            self._fill_single_pixel_fields(component_to_edit)
            return
        except AttributeError:
            pass

        try:
            component_to_edit.get_field_value(DETECTOR_NUMBER)
            self.entire_shape_radio_button.setChecked(True)
            self.update_pixel_layout_visibility(False, True)
            self._fill_entire_shape_fields(component_to_edit)
            return
        except AttributeError:
            pass

        self.no_pixels_button.setChecked(True)
        self.pixel_options_stack.setVisible(False)
Exemplo n.º 2
0
    def _fill_single_pixel_fields(self, component_to_edit: Component):
        """
        Fill the "single pixel" fields of a component that's being edited and contains pixel information.
        :param component_to_edit: The component that's being edited.
        """
        # Retrieve the pixel offsets and detector number from the component
        x_pixel_offset = component_to_edit.get_field_value(X_PIXEL_OFFSET)
        y_pixel_offset = component_to_edit.get_field_value(Y_PIXEL_OFFSET)
        detector_numbers = component_to_edit.get_field_value(
            DETECTOR_NUMBER).tolist()

        # Check that x offset is more than one value
        if data_is_an_array_with_more_than_one_element(x_pixel_offset):

            # Set the number of rows and the row height
            n_rows, row_height = self._get_row_information(y_pixel_offset)
            self.row_count_spin_box.setValue(n_rows)
            self.row_height_spin_box.setValue(row_height)

            # Set the number of columns and the column width
            n_cols, col_width = self._get_column_information(x_pixel_offset)
            self.column_count_spin_box.setValue(n_cols)
            self.column_width_spin_box.setValue(col_width)

            # Set the first ID, start counting option, and the count direction option
            (
                first_id,
                start_counting_text,
                count_along_text,
            ) = self._get_detector_number_information(detector_numbers)
            self.first_id_spin_box.setValue(first_id)
            self.start_counting_combo_box.setCurrentText(start_counting_text)
            self.count_first_combo_box.setCurrentText(count_along_text)

        else:
            # If the pixel offset information represents a single pixel
            pass