Exemplo n.º 1
0
    def __init__(self, parent=None, name="gphl_setup_widget"):
        QtImport.QWidget.__init__(self, parent)
        if name is not None:
            self.setObjectName(name)

        # Properties ----------------------------------------------------------

        # Signals ------------------------------------------------------------

        # Slots ---------------------------------------------------------------
        dispatcher.connect(self._refresh_interface, "model_update",
                           dispatcher.Any)

        # Hardware objects ----------------------------------------------------

        # Internal variables -------------------------------------------------
        self._widget_data = OrderedDict()
        self._data_object = GphlAcquisitionData()
        self._pulldowns = {}
        self._pulldown_defaults = {}
        self._parameter_mib = DataModelInputBinder(self._data_object)

        # Graphic elements ----------------------------------------------------
        _parameters_widget = self._parameters_widget = QtImport.QWidget(self)
        QtImport.QGridLayout(_parameters_widget)
        _parameters_widget.layout().setColumnStretch(2, 1)

        # Layout --------------------------------------------------------------
        # This seems to be necessary to make widget visible
        _main_vlayout = QtImport.QVBoxLayout(self)
        _main_vlayout.addWidget(_parameters_widget)
        _main_vlayout.setSpacing(0)
        _main_vlayout.setContentsMargins(0, 0, 0, 0)
Exemplo n.º 2
0
    def populate_widget(self, item):
        data_collection = item.get_model()
        self._tree_view_item = item
        self._data_collection = data_collection
        self._acquisition_mib = DataModelInputBinder(
            self._data_collection.acquisitions[0].acquisition_parameters)

        # The acq_widget sends a signal to the path_widget, and it relies
        # on that both models upto date, we need to refactor this part
        # so that both models are set before taking ceratin actions.
        # This workaround, works for the time beeing.
        self._data_path_widget._data_model = data_collection.acquisitions[
            0].path_template

        self._acq_widget.set_energies(
            data_collection.crystal.energy_scan_result)
        self._acq_widget.update_data_model(
            data_collection.acquisitions[0].acquisition_parameters,
            data_collection.acquisitions[0].path_template,
        )
        self._data_path_widget.update_data_model(
            data_collection.acquisitions[0].path_template)
        self._processing_widget.update_data_model(
            data_collection.processing_parameters)

        invalid = self._acquisition_mib.validate_all()
        if invalid:
            msg = (
                "This data collection has one or more incorrect parameters," +
                " correct the fields marked in red to solve the problem.")

            logging.getLogger("GUI").warning(msg)
Exemplo n.º 3
0
    def populate_widget(self, tree_view_item, data_collection):
        self._tree_view_item = tree_view_item
        self._data_collection = data_collection

        # if isinstance(tree_view_item, queue_item.XrayCenteringQueueItem):
        #    self._data_collection = tree_view_item.get_model().reference_image_collection
        # else:
        #    self._data_collection = tree_view_item.get_model()
        executed = self._data_collection.is_executed()

        self._acq_widget.setEnabled(not executed)
        self._data_path_widget.setEnabled(not executed)

        self._acquisition_mib = DataModelInputBinder(
            self._data_collection.acquisitions[0].acquisition_parameters)

        # The acq_widget sends a signal to the path_widget, and it relies
        # on that both models upto date, we need to refactor this part
        # so that both models are set before taking ceratin actions.
        # This workaround, works for the time beeing.
        self._data_path_widget.update_data_model(
            self._data_collection.acquisitions[0].path_template)

        self._acq_widget.update_data_model(
            self._data_collection.acquisitions[0].acquisition_parameters,
            self._data_collection.acquisitions[0].path_template,
        )
        # self._acq_widget.use_osc_start(False)

        self._acq_widget.acq_widget_layout.num_images_ledit.setDisabled(
            data_collection.is_mesh())
        invalid = self._acquisition_mib.validate_all()
        if invalid:
            msg = (
                "This data collection has one or more incorrect parameters," +
                " correct the fields marked in red to solve the problem.")
            logging.getLogger("GUI").warning(msg)
Exemplo n.º 4
0
    def __init__(self, *args):

        BaseWidget.__init__(self, *args)

        # Internal variables ------------------------------------------------
        self.sample = queue_model_objects.Sample()
        self.crystal = self.sample.crystals[0]
        self.sample_mib = DataModelInputBinder(self.sample)
        self.crystal_mib = DataModelInputBinder(self.crystal)

        # Signals ------------------------------------------------------------

        # Slots --------------------------------------------------------------
        self.define_slot("populate_sample_details", ({}))

        # Graphic elements ----------------------------------------------------
        _info_widget = QtImport.QWidget(self)
        self.crystal_widget = QtImport.load_ui_file("crystal_widget_layout.ui")
        self.sample_info_widget = QtImport.load_ui_file(
            "sample_info_widget_layout.ui")
        # self.ispyb_sample_info_widget = ISPyBSampleInfoWidget(self)

        # Layout --------------------------------------------------------------
        _info_widget_hlayout = QtImport.QHBoxLayout(_info_widget)
        _info_widget_hlayout.addWidget(self.sample_info_widget)
        _info_widget_hlayout.addWidget(self.crystal_widget)
        _info_widget_hlayout.addStretch(0)
        _info_widget_hlayout.setSpacing(0)
        _info_widget_hlayout.setContentsMargins(2, 2, 2, 2)

        _main_hlayout = QtImport.QVBoxLayout(self)
        _main_hlayout.addWidget(_info_widget)
        # _main_hlayout.addWidget(self.ispyb_sample_info_widget)
        _main_hlayout.addStretch(0)
        _main_hlayout.setSpacing(0)
        _main_hlayout.setContentsMargins(2, 2, 2, 2)

        # SizePolicies --------------------------------------------------------

        # Qt signal/slot connections ------------------------------------------

        # Other ---------------------------------------------------------------
        self.crystal_mib.bind_value_update(
            "space_group", self.crystal_widget.space_group_value_label, str,
            None)

        self.crystal_mib.bind_value_update(
            "protein_acronym",
            self.crystal_widget.protein_acronym_value_label,
            str,
            None,
        )

        self.crystal_mib.bind_value_update("cell_a",
                                           self.crystal_widget.a_value_label,
                                           str, None)

        self.crystal_mib.bind_value_update(
            "cell_alpha", self.crystal_widget.alpha_value_label, str, None)

        self.crystal_mib.bind_value_update("cell_b",
                                           self.crystal_widget.b_value_label,
                                           str, None)

        self.crystal_mib.bind_value_update(
            "cell_beta", self.crystal_widget.beta_value_label, str, None)

        self.crystal_mib.bind_value_update("cell_c",
                                           self.crystal_widget.c_value_label,
                                           str, None)

        self.crystal_mib.bind_value_update(
            "cell_gamma", self.crystal_widget.gamma_value_label, str, None)

        self.sample_mib.bind_value_update(
            "name", self.sample_info_widget.name_value_label, str, None)

        self.sample_mib.bind_value_update(
            "code", self.sample_info_widget.data_matrix_value_label, str, None)

        self.sample_mib.bind_value_update(
            "holder_length",
            self.sample_info_widget.holder_length_value_label,
            str,
            None,
        )

        self.sample_mib.bind_value_update(
            "lims_sample_location",
            self.sample_info_widget.sample_location_value_label,
            str,
            None,
        )

        self.sample_mib.bind_value_update(
            "lims_container_location",
            self.sample_info_widget.basket_location_value_label,
            str,
            None,
        )
Exemplo n.º 5
0
    def __init__(self, parent=None, name=None, fl=0, xray_imaging_params=None):

        QtImport.QWidget.__init__(self, parent, QtImport.Qt.WindowFlags(fl))

        if name is not None:
            self.setObjectName(name)

        # Internal variables --------------------------------------------------

        # Properties ----------------------------------------------------------

        # Signals -------------------------------------------------------------

        # Slots ---------------------------------------------------------------

        # Graphic elements ----------------------------------------------------
        self._xray_imaging_parameters = xray_imaging_params
        self._xray_imaging_mib = DataModelInputBinder(
            self._xray_imaging_parameters)

        self._parameters_widget = QtImport.load_ui_file(
            "xray_imaging_parameters_widget_layout.ui")
        # Layout --------------------------------------------------------------
        __main_vlayout = QtImport.QVBoxLayout(self)
        __main_vlayout.addWidget(self._parameters_widget)
        __main_vlayout.setSpacing(0)
        __main_vlayout.setContentsMargins(0, 0, 0, 0)

        # SizePolicies --------------------------------------------------------

        # Qt signal/slot connections ------------------------------------------
        self._parameters_widget.ff_pre_cbox.toggled.connect(
            self.ff_pre_toggled)
        self._parameters_widget.ff_post_cbox.toggled.connect(
            self.ff_post_toggled)
        self._parameters_widget.add_button.pressed.connect(
            self.add_distance_pressed)
        self._parameters_widget.remove_button.pressed.connect(
            self.remove_distance_pressed)

        # Other ---------------------------------------------------------------
        # self.detector_distance_validator = QtImport.QIntValidator(
        #     0, 99999, self._parameters_widget.detector_distance_ledit
        # )
        self.detector_distance_validator = QtImport.QDoubleValidator(
            0, 99999, 2, self._parameters_widget.detector_distance_ledit)

        self._xray_imaging_mib.bind_value_update(
            "camera_write_data", self._parameters_widget.store_data_cbox, bool,
            None)

        self._xray_imaging_mib.bind_value_update(
            "ff_pre", self._parameters_widget.ff_pre_cbox, bool, None)

        self._xray_imaging_mib.bind_value_update(
            "ff_post", self._parameters_widget.ff_post_cbox, bool, None)

        self._xray_imaging_mib.bind_value_update(
            "ff_apply", self._parameters_widget.ff_apply_cbox, bool, None)

        self._xray_imaging_mib.bind_value_update(
            "ff_ssim_enabled", self._parameters_widget.ff_ssim_cbox, bool,
            None)

        self._xray_imaging_mib.bind_value_update(
            "ff_num_images", self._parameters_widget.ff_num_images_ledit, int,
            None)

        self._xray_imaging_mib.bind_value_update(
            "sample_offset_a",
            self._parameters_widget.ff_offset_a_ledit,
            float,
            None,
        )

        self._xray_imaging_mib.bind_value_update(
            "sample_offset_b",
            self._parameters_widget.ff_offset_b_ledit,
            float,
            None,
        )

        self._xray_imaging_mib.bind_value_update(
            "sample_offset_c",
            self._parameters_widget.ff_offset_c_ledit,
            float,
            None,
        )

        self._xray_imaging_mib.bind_value_update(
            "detector_distance",
            self._parameters_widget.detector_distance_ledit,
            float,
            self.detector_distance_validator,
        )
Exemplo n.º 6
0
    def __init__(
        self,
        parent=None,
        name=None,
        fl=0,
        acq_params=None,
        path_template=None,
        layout=None,
    ):

        QtImport.QWidget.__init__(self, parent, QtImport.Qt.WindowFlags(fl))
        if name is not None:
            self.setObjectName(name)

        # Internal variables --------------------------------------------------
        self.value_changed_list = []

        # Properties ----------------------------------------------------------

        # Signals -------------------------------------------------------------

        # Slots ---------------------------------------------------------------

        # Graphic elements ----------------------------------------------------
        if acq_params is None:
            self._acquisition_parameters = queue_model_objects.AcquisitionParameters(
            )
        else:
            self._acquisition_parameters = acq_params
        if path_template is None:
            self._path_template = queue_model_objects.PathTemplate()
        else:
            self._path_template = path_template

        self._acquisition_mib = DataModelInputBinder(
            self._acquisition_parameters)
        self.acq_widget_layout = QtImport.load_ui_file(
            "acquisition_widget_vertical_simple_layout.ui")

        # Layout --------------------------------------------------------------
        main_layout = QtImport.QVBoxLayout(self)
        main_layout.addWidget(self.acq_widget_layout)
        main_layout.setSpacing(0)
        main_layout.setContentsMargins(0, 0, 0, 0)

        # SizePolicies --------------------------------------------------------

        # Qt signal/slot connections ------------------------------------------
        self.acq_widget_layout.osc_start_cbox.stateChanged.connect(
            self.use_osc_start)
        self.acq_widget_layout.num_images_cbox.activated.connect(
            self.update_num_images)
        self.acq_widget_layout.detector_roi_mode_combo.activated.connect(
            self.detector_roi_mode_changed)

        # Other ---------------------------------------------------------------
        self.osc_start_validator = QtImport.QDoubleValidator(
            -10000, 10000, 4, self.acq_widget_layout.osc_start_ledit)
        self.osc_range_validator = QtImport.QDoubleValidator(
            -10000, 10000, 4, self.acq_widget_layout.osc_range_ledit)
        self.kappa_validator = QtImport.QDoubleValidator(
            0, 360, 4, self.acq_widget_layout.kappa_ledit)
        self.kappa_phi_validator = QtImport.QDoubleValidator(
            0, 360, 4, self.acq_widget_layout.kappa_phi_ledit)
        self.energy_validator = QtImport.QDoubleValidator(
            0, 25, 5, self.acq_widget_layout.energy_ledit)
        self.resolution_validator = QtImport.QDoubleValidator(
            0, 15, 3, self.acq_widget_layout.resolution_ledit)
        self.transmission_validator = QtImport.QDoubleValidator(
            0, 100, 3, self.acq_widget_layout.transmission_ledit)
        self.exp_time_validator = QtImport.QDoubleValidator(
            0, 10000, 6, self.acq_widget_layout.exp_time_ledit)
        self.acq_widget_layout.num_images_cbox.setCurrentIndex(1)

        self.acq_widget_layout.detector_roi_mode_label.setEnabled(False)
        self.acq_widget_layout.detector_roi_mode_combo.setEnabled(False)

        self.set_tunable_energy(HWR.beamline.tunable_wavelength)

        if HWR.beamline.diffractometer.in_plate_mode():
            self.acq_widget_layout.num_images_cbox.clear()
            self.acq_widget_layout.num_images_cbox.addItem("1")
            self.acq_widget_layout.num_images_cbox.setCurrentIndex(0)

        self.init_detector_roi_modes()
        self.init_limits()
Exemplo n.º 7
0
    def __init__(self, parent=None, name="char_parameter_widget"):

        QtImport.QWidget.__init__(self, parent)

        if name is not None:
            self.setObjectName(name)

        # Hardware objects ----------------------------------------------------

        # Internal variables --------------------------------------------------
        self._char = None
        self._char_params = queue_model_objects.CharacterisationParameters()
        self._char_params_mib = DataModelInputBinder(self._char_params)
        self._tree_view_item = None
        self.previous_energy = None

        self.add_dc_cb = None

        # Graphic elements ----------------------------------------------------
        main_widget = QtImport.QWidget(self)
        rone_widget = QtImport.QWidget(main_widget)
        self.reference_img_widget = ReferenceImageWidget(rone_widget)
        self.acq_widget = self.reference_img_widget.acq_widget
        self.path_widget = self.reference_img_widget.path_widget
        self.position_widget = QtImport.load_ui_file(
            "snapshot_widget_layout.ui")
        self.position_widget.setMinimumSize(450, 340)

        rtwo_widget = QtImport.QWidget(main_widget)
        self.char_type_widget = CharTypeWidget(rtwo_widget)
        self.routine_dc_widget = self.char_type_widget.routine_dc_page
        self.sad_widget = self.char_type_widget.sad_page
        self.rad_dmg_char_widget = self.char_type_widget.rad_damage_page
        self.opt_parameters_widget = OptimisationParametersWidgetLayout(self)

        rtree_widget = QtImport.QWidget(main_widget)
        self.rad_dmg_widget = QtImport.load_ui_file(
            "radiation_damage_model_widget_layout.ui")
        self.vertical_dimension_widget = QtImport.load_ui_file(
            "vertical_crystal_dimension_widget_layout.ui")

        # Layout --------------------------------------------------------------
        rone_widget_layout = QtImport.QHBoxLayout(rone_widget)
        rone_widget_layout.addWidget(self.reference_img_widget)
        rone_widget_layout.addWidget(self.position_widget)
        # rone_widget_layout.addStretch(0)
        rone_widget_layout.setSpacing(2)
        rone_widget_layout.setContentsMargins(0, 0, 0, 0)

        rtwo_widget_layout = QtImport.QHBoxLayout(rtwo_widget)
        rtwo_widget_layout.addWidget(self.char_type_widget)
        rtwo_widget_layout.addWidget(self.opt_parameters_widget)
        rtwo_widget_layout.addStretch(0)
        rtwo_widget_layout.setSpacing(2)
        rtwo_widget_layout.setContentsMargins(0, 0, 0, 0)

        rtree_widget_layout = QtImport.QHBoxLayout(rtree_widget)
        rtree_widget_layout.addWidget(self.rad_dmg_widget)
        rtree_widget_layout.addWidget(self.vertical_dimension_widget)
        rtree_widget_layout.addStretch(10)
        rtree_widget_layout.setSpacing(2)
        rtree_widget_layout.setContentsMargins(0, 0, 0, 0)

        _main_widget_vlayout = QtImport.QVBoxLayout(main_widget)
        _main_widget_vlayout.addWidget(rone_widget)
        _main_widget_vlayout.addWidget(rtwo_widget)
        _main_widget_vlayout.addWidget(rtree_widget)
        _main_widget_vlayout.addStretch(10)
        _main_widget_vlayout.setSpacing(2)
        _main_widget_vlayout.setContentsMargins(0, 0, 0, 0)

        _main_hlayout = QtImport.QHBoxLayout(self)
        _main_hlayout.addWidget(main_widget)
        _main_hlayout.setSpacing(0)
        _main_hlayout.addStretch(0)
        _main_hlayout.setContentsMargins(0, 0, 0, 0)

        # SizePolicies -------------------------------------------------------

        # Qt signal/slot connections ------------------------------------------
        self.toggle_permitted_range(
            self.opt_parameters_widget.opt_param_widget.permitted_range_cbx.
            isChecked())

        self.opt_parameters_widget.opt_param_widget.permitted_range_cbx.toggled.connect(
            self.toggle_permitted_range)

        # Other ---------------------------------------------------------------
        self._char_params_mib.bind_value_update(
            "min_dose",
            self.routine_dc_widget.dose_ledit,
            float,
            QtImport.QDoubleValidator(0.0, 1000, 2, self),
        )

        self._char_params_mib.bind_value_update(
            "min_time",
            self.routine_dc_widget.time_ledit,
            float,
            QtImport.QDoubleValidator(0.0, 1000, 2, self),
        )

        self._char_params_mib.bind_value_update(
            "use_min_dose", self.routine_dc_widget.min_dose_radio, bool, None)

        self._char_params_mib.bind_value_update(
            "use_min_time", self.routine_dc_widget.min_time_radio, bool, None)

        self._char_params_mib.bind_value_update(
            "account_rad_damage",
            self.routine_dc_widget.radiation_damage_cbx,
            bool,
            None,
        )

        self._char_params_mib.bind_value_update(
            "auto_res", self.sad_widget.automatic_resolution_radio, bool, None)

        self._char_params_mib.bind_value_update(
            "sad_res",
            self.sad_widget.sad_resolution_ledit,
            float,
            QtImport.QDoubleValidator(0.5, 20, 3, self),
        )

        self._char_params_mib.bind_value_update(
            "opt_sad", self.sad_widget.optimised_sad_cbx, bool, None)

        self._char_params_mib.bind_value_update(
            "determine_rad_params", self.rad_dmg_char_widget.rad_damage_cbx,
            bool, None)

        self._char_params_mib.bind_value_update(
            "burn_osc_start",
            self.rad_dmg_char_widget.burn_osc_start_ledit,
            float,
            QtImport.QDoubleValidator(0.0, 1000, 2, self),
        )

        self._char_params_mib.bind_value_update(
            "burn_osc_interval",
            self.rad_dmg_char_widget.burn_osc_interval_ledit,
            float,
            QtImport.QDoubleValidator(0.0, 1000, 2, self),
        )

        self._char_params_mib.bind_value_update(
            "use_aimed_resolution",
            self.opt_parameters_widget.opt_param_widget.maximum_res_cbx,
            bool,
            None,
        )

        self._char_params_mib.bind_value_update(
            "use_aimed_multiplicity",
            self.opt_parameters_widget.opt_param_widget.aimed_mult_cbx,
            bool,
            None,
        )

        self._char_params_mib.bind_value_update(
            "aimed_resolution",
            self.opt_parameters_widget.opt_param_widget.maximum_res_ledit,
            float,
            QtImport.QDoubleValidator(0.01, 1000, 2, self),
        )

        self._char_params_mib.bind_value_update(
            "aimed_multiplicity",
            self.opt_parameters_widget.opt_param_widget.aimed_mult_ledit,
            float,
            QtImport.QDoubleValidator(0.01, 1000, 2, self),
        )

        self._char_params_mib.bind_value_update(
            "aimed_i_sigma",
            self.opt_parameters_widget.opt_param_widget.i_over_sigma_ledit,
            float,
            QtImport.QDoubleValidator(0.01, 1000, 2, self),
        )

        self._char_params_mib.bind_value_update(
            "aimed_completness",
            self.opt_parameters_widget.opt_param_widget.aimed_comp_ledit,
            float,
            QtImport.QDoubleValidator(0.01, 1000, 2, self),
        )

        self._char_params_mib.bind_value_update(
            "strategy_complexity",
            self.opt_parameters_widget.opt_param_widget.start_comp_cbox,
            int,
            None,
        )

        self._char_params_mib.bind_value_update(
            "use_permitted_rotation",
            self.opt_parameters_widget.opt_param_widget.permitted_range_cbx,
            bool,
            None,
        )

        self._char_params_mib.bind_value_update(
            "permitted_phi_start",
            self.opt_parameters_widget.opt_param_widget.phi_start_ledit,
            float,
            QtImport.QDoubleValidator(0.0, 1000, 2, self),
        )

        self._char_params_mib.bind_value_update(
            "permitted_phi_end",
            self.opt_parameters_widget.opt_param_widget.phi_end_ledit,
            float,
            QtImport.QDoubleValidator(0.0, 1000, 2, self),
        )

        self._char_params_mib.bind_value_update(
            "low_res_pass_strat",
            self.opt_parameters_widget.opt_param_widget.low_res_pass_cbx,
            bool,
            None,
        )

        self._char_params_mib.bind_value_update(
            "rad_suscept",
            self.rad_dmg_widget.sensetivity_ledit,
            float,
            QtImport.QDoubleValidator(0.0, 1000, 2, self),
        )

        self._char_params_mib.bind_value_update(
            "beta",
            self.rad_dmg_widget.beta_over_gray_ledit,
            float,
            QtImport.QDoubleValidator(0.0, 1000, 2, self),
        )

        self._char_params_mib.bind_value_update(
            "gamma",
            self.rad_dmg_widget.gamma_over_gray_ledit,
            float,
            QtImport.QDoubleValidator(0.0, 1000, 2, self),
        )

        self._char_params_mib.bind_value_update(
            "max_crystal_vdim",
            self.vertical_dimension_widget.max_vdim_ledit,
            float,
            QtImport.QDoubleValidator(0.0, 1000, 2, self),
        )

        self._char_params_mib.bind_value_update(
            "min_crystal_vdim",
            self.vertical_dimension_widget.min_vdim_ledit,
            float,
            QtImport.QDoubleValidator(0.0, 1000, 2, self),
        )

        self._char_params_mib.bind_value_update(
            "min_crystal_vphi",
            self.vertical_dimension_widget.min_vphi_ledit,
            float,
            QtImport.QDoubleValidator(0.0, 1000, 2, self),
        )

        self._char_params_mib.bind_value_update(
            "max_crystal_vphi",
            self.vertical_dimension_widget.max_vphi_ledit,
            float,
            QtImport.QDoubleValidator(0.0, 1000, 2, self),
        )

        # self._char_params_mib.bind_value_update('space_group',
        #                                        self.vertical_dimension_widget.space_group_ledit,
        #                                        str,
        #                                        None)

        self.vertical_dimension_widget.space_group_ledit.addItems(
            queue_model_enumerables.XTAL_SPACEGROUPS)

        self.char_type_widget.charact_type_tbox.currentChanged.connect(
            self.update_char_type)
        self.rad_dmg_char_widget.rad_damage_cbx.toggled.connect(
            self.enable_opt_parameters_widget)
        self.opt_parameters_widget.opt_param_widget.maximum_res_cbx.toggled.connect(
            self.enable_maximum_res_ledit)
        self.opt_parameters_widget.opt_param_widget.aimed_mult_cbx.toggled.connect(
            self.enable_aimed_mult_ledit)
        self.path_widget.data_path_layout.prefix_ledit.textChanged.connect(
            self._prefix_ledit_change)
        self.path_widget.data_path_layout.run_number_ledit.textChanged.connect(
            self._run_number_ledit_change)
        self.vertical_dimension_widget.space_group_ledit.activated.connect(
            self._space_group_change)
Exemplo n.º 8
0
    def __init__(
        self,
        parent=None,
        name=None,
        fl=0,
        acq_params=None,
        path_template=None,
        layout="vertical",
    ):
        """
        Loads ui file that defines the gui layout.
        Initiates QLineEdits by adding limits, precision
        Connects to qt signals to update acquisition parameters
        :param parent:
        :param name:
        :param fl:
        :param acq_params:
        :param path_template:
        :param layout:
        """

        QtImport.QWidget.__init__(self, parent, QtImport.Qt.WindowFlags(fl))

        if name is not None:
            self.setObjectName(name)

        # Internal variables --------------------------------------------------
        self.value_changed_list = []

        # Properties ----------------------------------------------------------

        # Signals -------------------------------------------------------------

        # Slots ---------------------------------------------------------------

        # Graphic elements ----------------------------------------------------
        if acq_params is None:
            self._acquisition_parameters = queue_model_objects.AcquisitionParameters(
            )
        else:
            self._acquisition_parameters = acq_params

        if path_template is None:
            self._path_template = queue_model_objects.PathTemplate()
        else:
            self._path_template = path_template

        self._acquisition_mib = DataModelInputBinder(
            self._acquisition_parameters)

        self.acq_widget_layout = QtImport.load_ui_file(
            "acquisition_widget_vertical_still_layout.ui")
        # Layout --------------------------------------------------------------
        __main_vlayout = QtImport.QVBoxLayout(self)
        __main_vlayout.addWidget(self.acq_widget_layout)
        __main_vlayout.setSpacing(0)
        __main_vlayout.setContentsMargins(0, 0, 0, 0)

        # SizePolicies --------------------------------------------------------

        # Qt signal/slot connections ------------------------------------------
        self.acq_widget_layout.num_triggers_ledit.textChanged.connect(
            self.num_triggers_ledit_changed)
        self.acq_widget_layout.num_images_per_trigger_ledit.textChanged.connect(
            self.num_images_per_trigger_ledit_changed)

        self.acq_widget_layout.exp_time_ledit.textChanged.connect(
            self.exposure_time_ledit_changed)
        self.acq_widget_layout.detector_roi_mode_combo.activated.connect(
            self.detector_roi_mode_changed)
        self.acq_widget_layout.energy_ledit.textEdited.connect(
            self.energy_ledit_changed)
        self.acq_widget_layout.transmission_ledit.textEdited.connect(
            self.transmission_ledit_changed)
        self.acq_widget_layout.resolution_ledit.textEdited.connect(
            self.resolution_ledit_changed)

        # Other ---------------------------------------------------------------
        self.energy_validator = QtImport.QDoubleValidator(
            4, 25, 4, self.acq_widget_layout.energy_ledit)
        self.resolution_validator = QtImport.QDoubleValidator(
            0, 15, 3, self.acq_widget_layout.resolution_ledit)
        self.transmission_validator = QtImport.QDoubleValidator(
            0, 100, 3, self.acq_widget_layout.transmission_ledit)
        self.exp_time_validator = QtImport.QDoubleValidator(
            0.0001, 10000, 7, self.acq_widget_layout.exp_time_ledit)
        self.num_triggers_validator = QtImport.QIntValidator(
            1, 9999999, self.acq_widget_layout.num_triggers_ledit)
        self.num_images_per_trigger_validator = QtImport.QIntValidator(
            1, 9999999, self.acq_widget_layout.num_images_per_trigger_ledit)
        self.num_img_validator = QtImport.QIntValidator(
            1, 9999999, self.acq_widget_layout.num_images_ledit)
        self.hare_num_validator = QtImport.QIntValidator(
            1, 9999999, self.acq_widget_layout.hare_num_ledit)

        limits_dict = HWR.beamline.acquisition_limit_values

        tpl = limits_dict.get("exposure_time")
        if tpl:
            self.exp_time_validator.setRange(tpl[0], tpl[1], 6)

        self._acquisition_mib.bind_value_update(
            "exp_time",
            self.acq_widget_layout.exp_time_ledit,
            float,
            self.exp_time_validator,
        )

        self._acquisition_mib.bind_value_update(
            "num_triggers",
            self.acq_widget_layout.num_triggers_ledit,
            int,
            self.num_triggers_validator,
        )

        self._acquisition_mib.bind_value_update(
            "num_images_per_trigger",
            self.acq_widget_layout.num_images_per_trigger_ledit,
            int,
            self.num_images_per_trigger_validator,
        )

        self._acquisition_mib.bind_value_update(
            "hare_num",
            self.acq_widget_layout.hare_num_ledit,
            int,
            self.hare_num_validator,
        )

        tpl = limits_dict.get("number_of_images")
        if tpl:
            self.num_img_validator.setRange(tpl[0], tpl[1])

        self._acquisition_mib.bind_value_update(
            "num_images",
            self.acq_widget_layout.num_images_ledit,
            int,
            self.num_img_validator,
        )

        self._acquisition_mib.bind_value_update(
            "energy", self.acq_widget_layout.energy_ledit, float,
            self.energy_validator)
        self.update_energy_limits(
            (self.energy_validator.bottom(), self.energy_validator.top()))

        self._acquisition_mib.bind_value_update(
            "transmission",
            self.acq_widget_layout.transmission_ledit,
            float,
            self.transmission_validator,
        )
        self.update_transmission_limits((self.transmission_validator.bottom(),
                                         self.transmission_validator.top()))

        self._acquisition_mib.bind_value_update(
            "resolution",
            self.acq_widget_layout.resolution_ledit,
            float,
            self.resolution_validator,
        )

        self.init_detector_roi_modes()
        self.acq_widget_layout.detector_roi_mode_label.setEnabled(False)
        self.acq_widget_layout.detector_roi_mode_combo.setEnabled(False)
        self.update_exp_time_limits()
Exemplo n.º 9
0
    def __init__(
        self,
        parent=None,
        name=None,
        fl=0,
        acq_params=None,
        path_template=None,
        layout="horizontal",
    ):

        QtImport.QWidget.__init__(self, parent, QtImport.Qt.WindowFlags(fl))

        if name is not None:
            self.setObjectName(name)

        # Hardware objects ----------------------------------------------------

        # Internal variables --------------------------------------------------
        self.previous_energy = 0

        # If the acq. widget is used with grids then total osc range is not
        # equal to num_images * osc_range, but num_images_per_line * osc_range
        # For grids the osc total range is updated when a grid is selected

        self.grid_mode = False

        # Properties ----------------------------------------------------------

        # Signals -------------------------------------------------------------

        # Slots ---------------------------------------------------------------

        # Graphic elements ----------------------------------------------------
        if acq_params is None:
            self._acquisition_parameters = queue_model_objects.AcquisitionParameters()
        else:
            self._acquisition_parameters = acq_params

        if path_template is None:
            self._path_template = queue_model_objects.PathTemplate()
        else:
            self._path_template = path_template

        self._acquisition_mib = DataModelInputBinder(self._acquisition_parameters)

        if layout == "horizontal":
            self.acq_widget_layout = QtImport.load_ui_file(
                "acquisition_widget_horizontal_layout.ui"
            )
            self.use_osc_start(False)
        else:
            self.acq_widget_layout = QtImport.load_ui_file(
                "acquisition_widget_vertical_layout.ui"
            )

        # Layout --------------------------------------------------------------
        __main_vlayout = QtImport.QVBoxLayout(self)
        __main_vlayout.addWidget(self.acq_widget_layout)
        __main_vlayout.setSpacing(0)
        __main_vlayout.setContentsMargins(0, 0, 0, 0)

        # SizePolicies --------------------------------------------------------

        # Qt signal/slot connections ------------------------------------------
        self.acq_widget_layout.osc_start_cbox.stateChanged.connect(self.fix_osc_start)
        self.acq_widget_layout.exp_time_ledit.textChanged.connect(
            self.exposure_time_ledit_changed
        )
        self.acq_widget_layout.exp_time_total_ledit.textEdited.connect(
            self.exp_time_total_ledit_changed
        )
        self.acq_widget_layout.first_image_ledit.textChanged.connect(
            self.first_image_ledit_change
        )
        self.acq_widget_layout.num_images_ledit.textChanged.connect(
            self.num_images_ledit_change
        )
        self.acq_widget_layout.detector_roi_mode_combo.activated.connect(
            self.detector_roi_mode_changed
        )
        self.acq_widget_layout.energies_combo.activated.connect(self.energy_selected)
        self.acq_widget_layout.mad_cbox.toggled.connect(self.use_mad)
        self.acq_widget_layout.osc_start_ledit.textEdited.connect(
            self.osc_start_ledit_changed
        )
        self.acq_widget_layout.osc_range_ledit.textEdited.connect(
            self.osc_range_per_frame_ledit_changed
        )
        self.acq_widget_layout.osc_total_range_ledit.textEdited.connect(
            self.osc_total_range_ledit_changed
        )
        self.acq_widget_layout.energy_ledit.textEdited.connect(
            self.energy_ledit_changed
        )
        self.acq_widget_layout.transmission_ledit.textEdited.connect(
            self.transmission_ledit_changed
        )
        self.acq_widget_layout.resolution_ledit.textEdited.connect(
            self.resolution_ledit_changed
        )
        self.acq_widget_layout.kappa_ledit.textEdited.connect(self.kappa_ledit_changed)
        self.acq_widget_layout.kappa_phi_ledit.textEdited.connect(
            self.kappa_phi_ledit_changed
        )

        if self.acq_widget_layout.findChild(QtImport.QLineEdit, "overlap_ledit"):
            self.acq_widget_layout.overlap_ledit.textChanged.connect(
                self.overlap_changed
            )
        if self.acq_widget_layout.findChild(QtImport.QCheckBox, "max_osc_range_cbx"):
            self.acq_widget_layout.max_osc_range_cbx.toggled.connect(
                self.max_osc_range_toggled
            )

        # Other ---------------------------------------------------------------
        self.value_changed_list = []

        self.acq_widget_layout.energies_combo.setDisabled(True)
        self.acq_widget_layout.energies_combo.addItems(
            ["ip: -", "pk: -", "rm1: -", "rm2: -"]
        )

        self.osc_start_validator = QtImport.QDoubleValidator(
            -10000, 10000, 4, self.acq_widget_layout.osc_start_ledit
        )
        self.osc_range_per_frame_validator = QtImport.QDoubleValidator(
            0, 10000, 4, self.acq_widget_layout.osc_range_ledit
        )
        self.osc_total_range_validator = QtImport.QDoubleValidator(
            0, 10000, 4, self.acq_widget_layout.osc_total_range_ledit
        )
        self.kappa_validator = QtImport.QDoubleValidator(
            -0.01, 360, 4, self.acq_widget_layout.kappa_ledit
        )
        self.kappa_phi_validator = QtImport.QDoubleValidator(
            -360, 360, 4, self.acq_widget_layout.kappa_phi_ledit
        )
        self.energy_validator = QtImport.QDoubleValidator(
            4, 25, 5, self.acq_widget_layout.energy_ledit
        )
        self.resolution_validator = QtImport.QDoubleValidator(
            0, 15, 3, self.acq_widget_layout.resolution_ledit
        )
        self.transmission_validator = QtImport.QDoubleValidator(
            0, 100, 3, self.acq_widget_layout.transmission_ledit
        )
        self.exp_time_validator = QtImport.QDoubleValidator(
            0.0001, 10000, 7, self.acq_widget_layout.exp_time_ledit
        )
        self.first_img_validator = QtImport.QIntValidator(
            0, 99999, self.acq_widget_layout.first_image_ledit
        )
        self.num_img_validator = QtImport.QIntValidator(
            1, 9999999, self.acq_widget_layout.num_images_ledit
        )
        self.acq_widget_layout.detector_roi_mode_label.setEnabled(False)
        self.acq_widget_layout.detector_roi_mode_combo.setEnabled(False)

        self.init_limits()
Exemplo n.º 10
0
    def __init__(self, parent=None, name=None, fl=0, data_model=None):

        QtImport.QWidget.__init__(self, parent, QtImport.Qt.WindowFlags(fl))
        if name is not None:
            self.setObjectName(name)

        if data_model is None:
            self._model = queue_model_objects.ProcessingParameters()
        else:
            self._model = data_model

        self._model_mib = DataModelInputBinder(self._model)

        self.processing_widget = QtImport.load_ui_file(
            "processing_widget_vertical_layout.ui")

        self.main_layout = QtImport.QVBoxLayout(self)
        self.main_layout.addWidget(self.processing_widget)
        self.main_layout.setSpacing(0)
        self.main_layout.setContentsMargins(0, 0, 0, 0)

        self.processing_widget.space_group_combo.addItems(
            queue_model_enumerables.XTAL_SPACEGROUPS)

        self._model_mib.bind_value_update("cell_a",
                                          self.processing_widget.a_ledit,
                                          float, None)

        self._model_mib.bind_value_update("cell_alpha",
                                          self.processing_widget.alpha_ledit,
                                          float, None)

        self._model_mib.bind_value_update("cell_b",
                                          self.processing_widget.b_ledit,
                                          float, None)

        self._model_mib.bind_value_update("cell_beta",
                                          self.processing_widget.beta_ledit,
                                          float, None)

        self._model_mib.bind_value_update("cell_c",
                                          self.processing_widget.c_ledit,
                                          float, None)

        self._model_mib.bind_value_update("cell_gamma",
                                          self.processing_widget.gamma_ledit,
                                          float, None)

        self._model_mib.bind_value_update(
            "num_residues", self.processing_widget.num_residues_ledit, float,
            None)

        self._model_mib.bind_value_update(
            "resolution_cutoff",
            self.processing_widget.resolution_cutoff_ledit, float, None)

        self._model_mib.bind_value_update(
            "pdb_file", self.processing_widget.pdb_file_ledit, str, None)

        self.processing_widget.space_group_combo.activated.connect(
            self._space_group_change)
        self.processing_widget.run_processing_after_cbox.stateChanged.connect(
            self._run_processing_after_toggled)
        self.processing_widget.run_processing_parallel_cbox.stateChanged.connect(
            self._run_processing_parallel_toggled)
        self.processing_widget.pdb_file_browse_button.clicked.connect(
            self._browse_clicked)

        self.processing_widget.resolution_cutoff_label.setHidden(True)
        self.processing_widget.resolution_cutoff_ledit.setHidden(True)
        self.processing_widget.pdb_file_label.setHidden(True)
        self.processing_widget.pdb_file_ledit.setHidden(True)
        self.processing_widget.pdb_file_browse_button.setHidden(True)
Exemplo n.º 11
0
    def __init__(self, parent=None, name=None, fl=0):

        CreateTaskBase.__init__(self, parent, name, fl, "Characterisation")
        self.setObjectName("create_char_widget")

        # Hardware objects ----------------------------------------------------

        # Internal variables --------------------------------------------------
        self._vertical_dimension_widget = None
        self._current_selected_item = None
        self._char = None
        self._char_params = None

        self.init_models()
        self._char_params_mib = DataModelInputBinder(self._char_params)

        # Graphic elements ----------------------------------------------------
        self._acq_widget = AcquisitionWidgetSimple(
            self,
            acq_params=self._acquisition_parameters,
            path_template=self._path_template,
        )

        self._data_path_widget = DataPathWidget(self,
                                                data_model=self._path_template,
                                                layout="vertical")

        self._vertical_dimension_widget = QtImport.load_ui_file(
            "vertical_crystal_dimension_widget_layout.ui")

        self._char_widget = QtImport.load_ui_file(
            "characterise_simple_widget_vertical_layout.ui")

        self._comments_widget = CommentsWidget(self)

        # Layout --------------------------------------------------------------
        _main_vlayout = QtImport.QVBoxLayout(self)
        _main_vlayout.addWidget(self._acq_widget)
        _main_vlayout.addWidget(self._data_path_widget)
        _main_vlayout.addWidget(self._char_widget)
        _main_vlayout.addWidget(self._vertical_dimension_widget)
        _main_vlayout.addWidget(self._comments_widget)
        _main_vlayout.setContentsMargins(2, 2, 2, 2)
        _main_vlayout.setSpacing(6)
        _main_vlayout.addStretch(0)

        # SizePolicies --------------------------------------------------------
        self._comments_widget.setFixedHeight(100)

        # Qt signal/slot connections ------------------------------------------
        self._data_path_widget.pathTemplateChangedSignal.connect(
            self.path_template_changed)
        self._acq_widget.acqParametersChangedSignal.connect(
            self.acq_parameters_changed)

        self._vertical_dimension_widget.space_group_ledit.activated.connect(
            self._space_group_change)

        self._char_widget.characterisation_gbox.toggled.connect(
            self.characterisation_gbox_toggled)
        self._char_widget.wait_result_cbx.toggled.connect(
            self.wait_results_cbx_toggled)
        self._char_widget.execute_plan_cbx.toggled.connect(
            self.run_diffraction_plan_cbx_toggled)

        # Other ---------------------------------------------------------------
        if False:
            self._char_params_mib.bind_value_update(
                "opt_sad", self._char_widget.optimised_sad_cbx, bool, None)

            self._char_params_mib.bind_value_update(
                "account_rad_damage", self._char_widget.account_rad_dmg_cbx,
                bool, None)

            self._char_params_mib.bind_value_update(
                "strategy_complexity", self._char_widget.start_comp_cbox, int,
                None)

            self._char_params_mib.bind_value_update(
                "max_crystal_vdim",
                self._vertical_dimension_widget.max_vdim_ledit,
                float,
                QtImport.QDoubleValidator(0.0, 1000, 2, self),
            )

            self._char_params_mib.bind_value_update(
                "min_crystal_vdim",
                self._vertical_dimension_widget.min_vdim_ledit,
                float,
                QtImport.QDoubleValidator(0.0, 1000, 2, self),
            )

            self._char_params_mib.bind_value_update(
                "min_crystal_vphi",
                self._vertical_dimension_widget.min_vphi_ledit,
                float,
                QtImport.QDoubleValidator(0.0, 1000, 2, self),
            )

            self._char_params_mib.bind_value_update(
                "max_crystal_vphi",
                self._vertical_dimension_widget.max_vphi_ledit,
                float,
                QtImport.QDoubleValidator(0.0, 1000, 2, self),
            )

        self._vertical_dimension_widget.space_group_ledit.addItems(
            XTAL_SPACEGROUPS)

        self._data_path_widget.data_path_layout.compression_cbox.setVisible(
            False)
Exemplo n.º 12
0
    def __init__(self,
                 parent=None,
                 name="",
                 fl=0,
                 data_model=None,
                 layout=None):

        QtImport.QWidget.__init__(self, parent, QtImport.Qt.WindowFlags(fl))

        if name is not None:
            self.setObjectName(name)
        self.parent = parent

        # Hardware objects ----------------------------------------------------

        # Internal variables --------------------------------------------------
        self._base_image_dir = ""
        self._base_process_dir = ""
        self.path_conflict_state = False
        self.enable_macros = False

        if data_model is None:
            self._data_model = queue_model_objects.PathTemplate()
        else:
            self._data_model = data_model

        self._data_model_pm = DataModelInputBinder(self._data_model)

        # Graphic elements ----------------------------------------------------
        if layout == "vertical":
            self.data_path_layout = QtImport.load_ui_file(
                "data_path_widget_vertical_layout.ui")
        else:
            self.data_path_layout = QtImport.load_ui_file(
                "data_path_widget_horizontal_layout.ui")

        # Layout --------------------------------------------------------------
        _main_vlayout = QtImport.QVBoxLayout(self)
        _main_vlayout.addWidget(self.data_path_layout)
        _main_vlayout.setSpacing(0)
        _main_vlayout.setContentsMargins(0, 0, 0, 0)

        # Qt signal/slot connections ------------------------------------------
        self.data_path_layout.prefix_ledit.textChanged.connect(
            self._prefix_ledit_change)
        self.data_path_layout.run_number_ledit.textChanged.connect(
            self._run_number_ledit_change)
        self.data_path_layout.browse_button.clicked.connect(
            self._browse_clicked)
        self.data_path_layout.folder_ledit.textChanged.connect(
            self._folder_ledit_change)
        self.data_path_layout.compression_cbox.clicked.connect(
            self._compression_toggled)

        # Other ---------------------------------------------------------------
        self._data_model_pm.bind_value_update(
            "base_prefix", self.data_path_layout.prefix_ledit, str, None)

        self._data_model_pm.bind_value_update(
            "run_number",
            self.data_path_layout.run_number_ledit,
            int,
            QtImport.QIntValidator(0, 1000, self),
        )

        self._data_model_pm.bind_value_update(
            "compression", self.data_path_layout.compression_cbox, bool, None)