Example #1
0
    def __init__(self, parent=None, name="parameter_widget"):
        qt.QWidget.__init__(self, parent, name)

        #
        # Private members
        #
        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

        self.char_type_widget = CharTypeWidget(self)
        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.reference_img_widget = ReferenceImageWidget(self)
        self.acq_widget = self.reference_img_widget.acq_widget
        self.path_widget = self.reference_img_widget.path_widget
        self.opt_parameters_widget = OptimisationParametersWidgetLayout(self)
        self.rad_dmg_widget = RadiationDamageModelWidgetLayout(self)
        self.position_widget = SnapshotWidgetLayout(self)
        self.vertical_dimension_widget = VerticalCrystalDimensionWidgetLayout(
            self)

        # Fix the widths of the widgets to make the layout look nicer,
        # and beacuse the qt layout engine is so tremendosly good.
        self.opt_parameters_widget.setFixedWidth(600)
        self.reference_img_widget.setFixedWidth(772)

        #
        # Layout
        #
        v_layout = qt.QVBoxLayout(self, 11, 15, "main_layout")
        rone_hlayout = qt.QHBoxLayout(v_layout, 15, "rone")
        rone_cone_vlayout = qt.QVBoxLayout(rone_hlayout, 15, "rone_cone")
        rtwo_hlayout = qt.QHBoxLayout(v_layout, 15, "rtwo")
        rthree_hlayout = qt.QHBoxLayout(v_layout, 15, "rtwo")

        rone_hlayout.addWidget(self.position_widget)
        rone_cone_vlayout.addWidget(self.reference_img_widget)
        rone_hlayout.addStretch()

        rtwo_hlayout.addWidget(self.char_type_widget)
        rtwo_hlayout.addWidget(self.opt_parameters_widget)
        rtwo_hlayout.addStretch(10)
        v_layout.addStretch(10)

        rthree_hlayout.addWidget(self.rad_dmg_widget)
        rthree_hlayout.addWidget(self.vertical_dimension_widget)
        rthree_hlayout.addStretch(10)
        v_layout.addStretch(10)

        #
        # Widget logic
        #
        self.toggle_permitted_range(self.\
            opt_parameters_widget.permitted_range_cbx.isOn())
        qt.QObject.connect(self.opt_parameters_widget.permitted_range_cbx,
                           qt.SIGNAL("toggled(bool)"),
                           self.toggle_permitted_range)

        self._char_params_mib.bind_value_update(
            'min_dose', self.routine_dc_widget.dose_ledit, float,
            qt.QDoubleValidator(0.0, 1000, 2, self))

        self._char_params_mib.bind_value_update(
            'min_time', self.routine_dc_widget.time_ledit, float,
            qt.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(
            'opt_sad', self.sad_widget.optimal_sad_radio, 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, qt.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,
            qt.QDoubleValidator(0.0, 1000, 2, self))

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

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

        self._char_params_mib.bind_value_update(
            'aimed_resolution', self.opt_parameters_widget.maximum_res_ledit,
            float, qt.QDoubleValidator(0.01, 1000, 2, self))

        self._char_params_mib.bind_value_update(
            'aimed_multiplicity', self.opt_parameters_widget.aimed_mult_ledit,
            float, qt.QDoubleValidator(0.01, 1000, 2, self))

        self._char_params_mib.bind_value_update(
            'aimed_i_sigma', self.opt_parameters_widget.i_over_sigma_ledit,
            float, qt.QDoubleValidator(0.01, 1000, 2, self))

        self._char_params_mib.bind_value_update(
            'aimed_completness', self.opt_parameters_widget.aimed_comp_ledit,
            float, qt.QDoubleValidator(0.01, 1000, 2, self))

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

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

        self._char_params_mib.bind_value_update(
            'permitted_phi_start', self.opt_parameters_widget.phi_start_ledit,
            float, qt.QDoubleValidator(0.0, 1000, 2, self))

        self._char_params_mib.bind_value_update(
            'permitted_phi_end', self.opt_parameters_widget.phi_end_ledit,
            float, qt.QDoubleValidator(0.0, 1000, 2, self))

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

        self._char_params_mib.bind_value_update(
            'rad_suscept', self.rad_dmg_widget.sensetivity_ledit, float,
            qt.QDoubleValidator(0.0, 1000, 2, self))

        self._char_params_mib.bind_value_update(
            'beta', self.rad_dmg_widget.beta_over_gray_ledit, float,
            qt.QDoubleValidator(0.0, 1000, 2, self))

        self._char_params_mib.bind_value_update(
            'gamma', self.rad_dmg_widget.gamma_over_gray_ledit, float,
            qt.QDoubleValidator(0.0, 1000, 2, self))

        self._char_params_mib.bind_value_update(
            'max_crystal_vdim', self.vertical_dimension_widget.max_vdim_ledit,
            float, qt.QDoubleValidator(0.0, 1000, 2, self))

        self._char_params_mib.bind_value_update(
            'min_crystal_vdim', self.vertical_dimension_widget.min_vdim_ledit,
            float, qt.QDoubleValidator(0.0, 1000, 2, self))

        self._char_params_mib.bind_value_update(
            'min_crystal_vphi', self.vertical_dimension_widget.min_vphi_ledit,
            float, qt.QDoubleValidator(0.0, 1000, 2, self))

        self._char_params_mib.bind_value_update(
            'max_crystal_vphi', self.vertical_dimension_widget.max_vphi_ledit,
            float, qt.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.\
            insertStrList(queue_model_enumerables.XTAL_SPACEGROUPS)

        qt.QObject.connect(self.char_type_widget.charact_type_tbox,
                           qt.SIGNAL("currentChanged(int)"),
                           self.update_char_type)

        qt.QObject.connect(self.rad_dmg_char_widget.rad_damage_cbx,
                           qt.SIGNAL("toggled(bool)"),
                           self.enable_opt_parameters_widget)

        qt.QObject.connect(self.opt_parameters_widget.maximum_res_cbx,
                           qt.SIGNAL("toggled(bool)"),
                           self.enable_maximum_res_ledit)

        qt.QObject.connect(self.opt_parameters_widget.aimed_mult_cbx,
                           qt.SIGNAL("toggled(bool)"),
                           self.enable_aimed_mult_ledit)

        qt.QObject.connect(
            self.path_widget.data_path_widget_layout.child('prefix_ledit'),
            qt.SIGNAL("textChanged(const QString &)"),
            self._prefix_ledit_change)

        qt.QObject.connect(
            self.path_widget.data_path_widget_layout.child('run_number_ledit'),
            qt.SIGNAL("textChanged(const QString &)"),
            self._run_number_ledit_change)

        qt.QObject.connect(self.vertical_dimension_widget.space_group_ledit,
                           qt.SIGNAL("activated(int)"),
                           self._space_group_change)

        qt.QObject.connect(qt.qApp, qt.PYSIGNAL('tab_changed'),
                           self.tab_changed)