Esempio n. 1
0
 def open_file_dialog(self):
     start_path = os.path.dirname(ConvertUtils.text_type(self.filepath.text()))
     if not os.path.exists(start_path):
         start_path = ""
     path = qt_import.QFileDialog(self).getOpenFileName(directory=start_path)
     if not path.isNull():
         self.filepath.setText(path)
Esempio n. 2
0
 def populateColumn(self, colNum, values, colours=None):
     """Fill values into column, extending if necessary"""
     if len(values) > self.rowCount():
         self.setRowCount(len(values))
     for rowNum, text in enumerate(values):
         wdg = qt_import.QLineEdit(self)
         wdg.setFont(qt_import.QFont("Courier"))
         wdg.setReadOnly(True)
         wdg.setText(ConvertUtils.text_type(text))
         if colours:
             colour = colours[rowNum]
             if colour:
                 colors.set_widget_color(wdg, getattr(colors, colour),
                                         qt_import.QPalette.Base)
                 # wdg.setBackground(getattr(qt_import.QColor, colour))
         self.setCellWidget(rowNum, colNum, wdg)
Esempio n. 3
0
    def workflow_selected(self):
        # necessary as this comes in as a QString object
        name = ConvertUtils.text_type(self._workflow_cbox.currentText())
        # if reset or name != self._previous_workflow:
        xx0 = self._workflow_cbox
        xx0.setCurrentIndex(xx0.findText(name))
        self.init_models()
        self._data_path_widget.update_data_model(self._path_template)

        parameters = HWR.beamline.gphl_workflow.get_available_workflows()[name]
        strategy_type = parameters.get("strategy_type")
        if strategy_type == "transcal":
            # NB Once we do not have to set unique prefixes, this should be readOnly
            self._data_path_widget.data_path_layout.prefix_ledit.setReadOnly(
                False)
            self._gphl_acq_widget.hide()
        elif strategy_type == "diffractcal":
            # TODO update this
            self._data_path_widget.data_path_layout.prefix_ledit.setReadOnly(
                True)
            self._gphl_diffractcal_widget.populate_widget()
            self._gphl_acq_widget.show()
            self._gphl_diffractcal_widget.show()
            self._gphl_acq_param_widget.hide()
        else:
            # acquisition type strategy
            self._data_path_widget.data_path_layout.prefix_ledit.setReadOnly(
                True)
            self._gphl_acq_param_widget.populate_widget()
            self._gphl_acq_widget.show()
            self._gphl_diffractcal_widget.hide()
            self._gphl_acq_param_widget.show()

        prefix = parameters.get("prefix")
        if prefix is not None:
            self.current_prefix = prefix
Esempio n. 4
0
    def _create_task(self, sample, shape):
        tasks = []

        path_template = self._create_path_template(sample, self._path_template)
        path_template.num_files = 0
        path_template.compression = False

        workflow_hwobj = HWR.beamline.gphl_workflow
        if workflow_hwobj.get_state() == workflow_hwobj.STATES.OFF:
            # We will be setting up the connection now - time to connect to quit
            qt_import.QApplication.instance().aboutToQuit.connect(
                workflow_hwobj.shutdown)

            tree_brick = self._tree_brick
            if tree_brick:
                tree_brick.dc_tree_widget.confirm_dialog.continueClickedSignal.connect(
                    self.continue_button_click)

        wf = queue_model_objects.GphlWorkflow(workflow_hwobj)
        wf_type = ConvertUtils.text_type(self._workflow_cbox.currentText())
        wf.set_type(wf_type)

        if self.current_prefix:
            path_template.base_prefix = self.current_prefix
        wf.path_template = path_template
        wf.set_name(wf.path_template.get_prefix())
        wf.set_number(wf.path_template.run_number)

        wf_parameters = workflow_hwobj.get_available_workflows()[wf_type]
        strategy_type = wf_parameters.get("strategy_type")
        wf.set_interleave_order(wf_parameters.get("interleaveOrder", ""))
        if strategy_type.startswith("transcal"):
            pass

        elif strategy_type.startswith("diffractcal"):
            ss0 = self._gphl_diffractcal_widget.get_parameter_value(
                "test_crystal")
            crystal_data = self._gphl_diffractcal_widget.test_crystals.get(ss0)
            wf.set_space_group(crystal_data.space_group)
            wf.set_cell_parameters(
                tuple(
                    getattr(crystal_data, tag)
                    for tag in ("a", "b", "c", "alpha", "beta", "gamma")))
            tag = self._gphl_acq_param_widget.get_parameter_value(
                "dose_budget")
            wf.set_dose_budget(
                HWR.beamline.gphl_workflow.dose_budgets.get(tag))
            # The entire strategy runs as a 'characterisation'
            wf.set_characterisation_budget_fraction(1.0)
        else:
            # Coulds be native_... phasing_... etc.

            wf.set_space_group(
                self._gphl_acq_param_widget.get_parameter_value("space_group"))
            wf.set_characterisation_strategy(
                self._gphl_acq_param_widget.get_parameter_value(
                    "characterisation_strategy"))
            tag = self._gphl_acq_param_widget.get_parameter_value(
                "crystal_system")
            crystal_system, point_group = None, None
            if tag:
                data = self._gphl_acq_param_widget._CRYSTAL_SYSTEM_DATA[tag]
                crystal_system = data.crystal_system
                point_groups = data.point_groups
                if len(point_groups) == 1 or point_groups[0] == "32":
                    # '32' is a special case; '312' and '321' are also returned as '32'
                    point_group = point_groups[0]
            wf.set_point_group(point_group)
            wf.set_crystal_system(crystal_system)
            wf.set_beam_energies(wf_parameters["beam_energies"])
            tag = self._gphl_acq_param_widget.get_parameter_value(
                "dose_budget")
            wf.set_dose_budget(
                HWR.beamline.gphl_workflow.dose_budgets.get(tag))
            val = self._gphl_acq_param_widget.get_parameter_value(
                "relative_rad_sensitivity")
            wf.set_relative_rad_sensitivity(val)
            wf.set_characterisation_budget_fraction(
                HWR.beamline.gphl_workflow.get_property(
                    "characterisation_budget_percent", 5.0) / 100.0)

        tasks.append(wf)

        return tasks
Esempio n. 5
0
 def get_value(self):
     return ConvertUtils.text_type(self.text())
Esempio n. 6
0
 def get_value(self):
     val = int(self.value())
     return ConvertUtils.text_type(val)