def off_component_with_no_pixel_data(
    nexus_wrapper, nx_off_geometry_group, off_geometry_file
):
    component = Component(nexus_wrapper, nx_off_geometry_group)
    component.set_off_shape(off_geometry_file)

    return component
def off_component_with_pixel_grid(
    pixel_grid, nexus_wrapper, nx_off_geometry_group, off_geometry_file
):
    component = Component(nexus_wrapper, nx_off_geometry_group)
    component.record_pixel_grid(pixel_grid)
    component.set_off_shape(off_geometry_file, pixel_data=pixel_grid)

    return component
def off_component_with_pixel_mapping(
    nexus_wrapper,
    nx_off_geometry_group,
    pixel_mapping_with_six_pixels,
    off_geometry_file,
):
    component = Component(nexus_wrapper, nx_off_geometry_group)
    component.record_pixel_mapping(pixel_mapping_with_six_pixels)
    component.set_off_shape(off_geometry_file, pixel_data=pixel_mapping_with_six_pixels)

    return component
def replace_pixel_grid_in_off_component(
    component: Component, pixel_grid: PixelGrid, off_geometry: OFFGeometryNexus
):
    """
    Change the pixel grid that is currently stored in a Component. Used to see if everything behaves correctly even
    for pixel data with 'special' properties.
    :param component: The component to have its pixel data replaced.
    :param pixel_grid: The PixelGrid object.
    :param off_geometry: The OffGeometry.
    """
    component.record_pixel_grid(pixel_grid)
    component.set_off_shape(off_geometry, pixel_data=pixel_grid)
    def generate_geometry_model(
        self, component: Component, pixel_data: PixelData = None
    ):
        """
        Generates a geometry model depending on the type of geometry selected and the current values
        of the line edits that apply to the particular geometry type.
        :return: The generated model.
        """
        if self.CylinderRadioButton.isChecked():

            component.set_cylinder_shape(
                QVector3D(
                    self.cylinderXLineEdit.value(),
                    self.cylinderYLineEdit.value(),
                    self.cylinderZLineEdit.value(),
                ),
                self.cylinderHeightLineEdit.value(),
                self.cylinderRadiusLineEdit.value(),
                self.unitsLineEdit.text(),
                pixel_data=pixel_data,
            )
        elif self.meshRadioButton.isChecked():
            mesh_geometry = OFFGeometryNoNexus()
            geometry_model = load_geometry(
                self.cad_file_name, self.unitsLineEdit.text(), mesh_geometry
            )

            # Units have already been used during loading the file, but we store them and file name
            # so we can repopulate their fields in the edit component window
            geometry_model.units = self.unitsLineEdit.text()
            geometry_model.file_path = self.cad_file_name

            component.set_off_shape(
                geometry_model,
                units=self.unitsLineEdit.text(),
                filename=self.fileLineEdit.text(),
                pixel_data=pixel_data,
            )