本文整理匯總了Python中widgets.widget_utils.DataModelInputBinder.set_model方法的典型用法代碼示例。如果您正苦於以下問題:Python DataModelInputBinder.set_model方法的具體用法?Python DataModelInputBinder.set_model怎麽用?Python DataModelInputBinder.set_model使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類widgets.widget_utils.DataModelInputBinder
的用法示例。
在下文中一共展示了DataModelInputBinder.set_model方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: AcquisitionWidget
# 需要導入模塊: from widgets.widget_utils import DataModelInputBinder [as 別名]
# 或者: from widgets.widget_utils.DataModelInputBinder import set_model [as 別名]
#.........這裏部分代碼省略.........
def set_energies(self, energy_scan_result):
self.acq_widget_layout.child("energies_combo").clear()
inflection = (
("ip: %.4f" % energy_scan_result.inflection)
if energy_scan_result.inflection
else "ip: -"
)
peak = (
("pk: %.4f" % energy_scan_result.peak)
if energy_scan_result.peak
else "pk: -"
)
first_remote = (
("rm1: %.4f" % energy_scan_result.first_remote)
if energy_scan_result.first_remote
else "rm1: -"
)
second_remote = (
("rm2: %.4f" % energy_scan_result.second_remote)
if energy_scan_result.second_remote
else "rm2: -"
)
self.acq_widget_layout.child("energies_combo").insertStrList(
[inflection, peak, first_remote, second_remote]
)
def energy_selected(self, index):
if self.acq_widget_layout.child("mad_cbox").isChecked():
(name, energy) = self.get_mad_energy()
if energy != 0:
self.set_energy(energy, 0)
self.emit(qt.PYSIGNAL("mad_energy_selected"), (name, energy, True))
def set_energy(self, energy, wav):
self._acquisition_parameters.energy = energy
self.acq_widget_layout.child("energy_ledit").setText("%.4f" % float(energy))
def update_transmission(self, transmission):
self.acq_widget_layout.child("transmission_ledit").setText(
"%.2f" % float(transmission)
)
# self._acquisition_parameters.transmission = float(transmission)
def update_resolution(self, resolution):
self.acq_widget_layout.child("resolution_ledit").setText(
"%.3f" % float(resolution)
)
# self._acquisition_parameters.resolution = float(resolution)
def update_data_model(self, acquisition_parameters, path_template):
self._acquisition_parameters = acquisition_parameters
self._path_template = path_template
self._acquisition_mib.set_model(acquisition_parameters)
# Update mad widgets
mad = True if self._path_template.mad_prefix != "" else False
if mad:
mad_prefix = self._path_template.mad_prefix
index = MAD_ENERGY_COMBO_NAMES[mad_prefix]
self.acq_widget_layout.child("energies_combo").setCurrentItem(index)
self.acq_widget_layout.child("mad_cbox").setChecked(True)
self.acq_widget_layout.child("energies_combo").setEnabled(True)
else:
self.acq_widget_layout.child("mad_cbox").setChecked(False)
self.acq_widget_layout.child("energies_combo").setEnabled(False)
self.acq_widget_layout.child("energies_combo").setCurrentItem(0)
def set_tunable_energy(self, state):
self.acq_widget_layout.child("energy_ledit").setEnabled(state)
self.acq_widget_layout.child("mad_cbox").setEnabled(state)
self.acq_widget_layout.child("energies_combo").setEnabled(state)
def disable_inverse_beam(self, state):
if state:
self.acq_widget_layout.child("inverse_beam_cbx").hide()
self.acq_widget_layout.child("subwedge_size_label").hide()
self.acq_widget_layout.child("subwedge_size_ledit").hide()
else:
self.acq_widget_layout.child("inverse_beam_cbx").show()
self.acq_widget_layout.child("subwedge_size_label").show()
self.acq_widget_layout.child("subwedge_size_ledit").show()
def hide_aperture(self, state):
pass
# if state:
# self.acq_widget_layout.child('aperture_ledit').show()
# self.acq_widget_layout.child('aperture_cbox').show()
# else:
# self.acq_widget_layout.child('aperture_ledit').hide()
# self.acq_widget_layout.child('aperture_cbox').hide()
def check_parameter_conflict(self):
return len(self._acquisition_mib.validate_all()) > 0
示例2: CreateCharWidget
# 需要導入模塊: from widgets.widget_utils import DataModelInputBinder [as 別名]
# 或者: from widgets.widget_utils.DataModelInputBinder import set_model [as 別名]
#.........這裏部分代碼省略.........
resolution = 0
try:
energy = self._beamline_setup_hwobj.energy_hwobj.getCurrentEnergy()
energy = round(float(energy), 4)
except AttributeError:
energy = 0
self._acquisition_parameters.resolution = resolution
self._acquisition_parameters.energy = energy
self._acquisition_parameters.transmission = transmission
else:
self._acquisition_parameters = queue_model_objects.AcquisitionParameters()
self._path_template.reference_image_prefix = "ref"
# The num images drop down default value is 1
# we would like it to be 2
self._acquisition_parameters.num_images = 2
self._char.characterisation_software = (
queue_model_enumerables.COLLECTION_ORIGIN.EDNA
)
self._path_template.num_files = 2
self._acquisition_parameters.shutterless = False
def single_item_selection(self, tree_item):
CreateTaskBase.single_item_selection(self, tree_item)
if isinstance(tree_item, queue_item.SampleQueueItem):
self._init_models()
self._set_space_group(self._char_params.space_group)
self._acq_widget.update_data_model(
self._acquisition_parameters, self._path_template
)
self._char_params_mib.set_model(self._char_params)
# self._char_params = copy.deepcopy(self._char_params)
# self._acquisition_parameters = copy.deepcopy(self._acquisition_parameters)
elif isinstance(tree_item, queue_item.BasketQueueItem):
self.setDisabled(False)
elif isinstance(tree_item, queue_item.CharacterisationQueueItem):
if tree_item.get_model().is_executed():
self.setDisabled(True)
else:
self.setDisabled(False)
self._char = tree_item.get_model()
if self._char.get_path_template():
self._path_template = self._char.get_path_template()
self._data_path_widget.update_data_model(self._path_template)
data_collection = self._char.reference_image_collection
self._char_params = self._char.characterisation_parameters
self._char_params_mib.set_model(self._char_params)
self._acquisition_parameters = data_collection.acquisitions[
0
].acquisition_parameters
self._acq_widget.update_data_model(
self._acquisition_parameters, self._path_template
)
self.get_acquisition_widget().use_osc_start(True)
if len(data_collection.acquisitions) == 1:
示例3: CharParametersWidget
# 需要導入模塊: from widgets.widget_utils import DataModelInputBinder [as 別名]
# 或者: from widgets.widget_utils.DataModelInputBinder import set_model [as 別名]
#.........這裏部分代碼省略.........
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.prefix_ledit,
qt.SIGNAL("textChanged(const QString &)"),
self._prefix_ledit_change)
qt.QObject.connect(self.path_widget.data_path_widget_layout.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)
def _space_group_change(self, index):
self._char_params.space_group = queue_model_enumerables.\
XTAL_SPACEGROUPS[index]
def _set_space_group(self, space_group):
index = 0
if space_group in queue_model_enumerables.XTAL_SPACEGROUPS:
index = queue_model_enumerables.XTAL_SPACEGROUPS.index(space_group)
self._space_group_change(index)
self.vertical_dimension_widget.space_group_ledit.setCurrentItem(index)
def _prefix_ledit_change(self, new_value):
prefix = self._data_collection.acquisitions[0].\
path_template.get_prefix()
self._char.set_name(prefix)
self._tree_view_item.setText(0, self._char.get_name())
def _run_number_ledit_change(self, new_value):
if str(new_value).isdigit():
self._char.set_number(int(new_value))
self._tree_view_item.setText(0, self._char.get_name())
def enable_aimed_mult_ledit(self, state):
self.opt_parameters_widget.aimed_mult_ledit.setEnabled(state)
def enable_maximum_res_ledit(self, state):
self.opt_parameters_widget.maximum_res_ledit.setEnabled(state)
def update_char_type(self, index):
self._char_params.experiment_type = index
def toggle_permitted_range(self, status):
self.opt_parameters_widget.phi_start_ledit.setEnabled(status)
self.opt_parameters_widget.phi_end_ledit.setEnabled(status)
def enable_opt_parameters_widget(self, state):
self.opt_parameters_widget.setEnabled(not state)
def tab_changed(self):
if self._tree_view_item:
self.populate_parameter_widget(self._tree_view_item)
def populate_parameter_widget(self, tree_view_item):
self._tree_view_item = tree_view_item
self._char = tree_view_item.get_model()
self._data_collection = self._char.reference_image_collection
self._char_params = self._char.characterisation_parameters
self._char_params_mib.set_model(self._char.characterisation_parameters)
self._set_space_group(self._char_params.space_group)
self.acq_widget.update_data_model(self._char.reference_image_collection.\
acquisitions[0].acquisition_parameters,
self._char.reference_image_collection.\
acquisitions[0].path_template)
self.path_widget.update_data_model(self._char.reference_image_collection.\
acquisitions[0].path_template)
if self._data_collection.acquisitions[0].acquisition_parameters.\
centred_position.snapshot_image:
image = self._data_collection.acquisitions[0].\
acquisition_parameters.centred_position.snapshot_image
image = image.scale(427, 320)
self.position_widget.svideo.setPixmap(qt.QPixmap(image))
self.toggle_permitted_range(self._char_params.use_permitted_rotation)
self.enable_opt_parameters_widget(self._char_params.determine_rad_params)
self.enable_maximum_res_ledit(self._char_params.use_aimed_resolution)
self.enable_aimed_mult_ledit(self._char_params.use_aimed_multiplicity)
item = self.char_type_widget.charact_type_tbox.\
item(self._char_params.experiment_type)
self.char_type_widget.charact_type_tbox.setCurrentItem(item)
self.char_type_widget.toggle_time_dose()
crystal = self._char.reference_image_collection.crystal
self.acq_widget.set_energies(crystal.energy_scan_result)
示例4: ProcessingWidget
# 需要導入模塊: from widgets.widget_utils import DataModelInputBinder [as 別名]
# 或者: from widgets.widget_utils.DataModelInputBinder import set_model [as 別名]
class ProcessingWidget(qt.QWidget):
def __init__(self, parent = None, name = None, fl = 0, data_model = None):
qt.QWidget.__init__(self, parent, name, fl)
if data_model is None:
self._model = queue_model_objects.ProcessingParameters()
else:
self._model = data_model
self._model_mib = DataModelInputBinder(self._model)
h_layout = qt.QHBoxLayout(self)
widget = self.acq_widget_layout = qtui.QWidgetFactory.\
create(os.path.join(os.path.dirname(__file__),
'ui_files/processing_widget_vertical_layout.ui'))
widget.reparent(self, qt.QPoint(0,0))
self.layout_widget = widget
h_layout.addWidget(self.layout_widget)
self.layout_widget.child('space_group_ledit').\
insertStrList(queue_model_enumerables.XTAL_SPACEGROUPS)
self._model_mib.bind_value_update('cell_a',
self.layout_widget.child('a_ledit'),
float,
None)
self._model_mib.bind_value_update('cell_alpha',
self.layout_widget.child('alpha_ledit'),
float,
None)
self._model_mib.bind_value_update('cell_b',
self.layout_widget.child('b_ledit'),
float,
None)
self._model_mib.bind_value_update('cell_beta',
self.layout_widget.child('beta_ledit'),
float,
None)
self._model_mib.bind_value_update('cell_c',
self.layout_widget.child('c_ledit'),
float,
None)
self._model_mib.bind_value_update('cell_gamma',
self.layout_widget.child('gamma_ledit'),
float,
None)
self._model_mib.bind_value_update('num_residues',
self.layout_widget.child('num_residues_ledit'),
float,
None)
self._model_mib.bind_value_update('process_data',
self.layout_widget.child('use_processing'),
bool,
None)
self._model_mib.bind_value_update('anomalous',
self.layout_widget.child('use_anomalous'),
bool,
None)
self.connect(self.layout_widget.child('space_group_ledit'),
qt.SIGNAL("activated(int)"),
self._space_group_change)
def _space_group_change(self, index):
self._model.space_group = queue_model_enumerables.\
XTAL_SPACEGROUPS[index]
def _set_space_group(self, space_group):
index = 0
if space_group in queue_model_enumerables.XTAL_SPACEGROUPS:
index = queue_model_enumerables.XTAL_SPACEGROUPS.index(space_group)
self._space_group_change(index)
self.layout_widget.child('space_group_ledit').setCurrentItem(index)
def update_data_model(self, model):
self._model = model
self._model_mib.set_model(model)
self._set_space_group(model.space_group)
示例5: SampleDetailsBrick
# 需要導入模塊: from widgets.widget_utils import DataModelInputBinder [as 別名]
# 或者: from widgets.widget_utils.DataModelInputBinder import set_model [as 別名]
class SampleDetailsBrick(BaseComponents.BlissWidget):
def __init__(self, *args):
BaseComponents.BlissWidget.__init__(self, *args)
#
# Data attributes
#
self.sample = queue_model_objects.Sample()
self.crystal = self.sample.crystals[0]
self.sample_mib = DataModelInputBinder(self.sample)
self.crystal_mib = DataModelInputBinder(self.crystal)
#
# Qt - Signals/Slots
#
self.defineSlot("populate_sample_details", ({}))
#
# Layout
#
main_layout = qt.QHBoxLayout(self, 11, 15, "main_layout")
self.crystal_widget = CrystalWidgetLayout(self)
self.sample_info_widget = SampleInfoWidgetLayout(self)
main_layout.addWidget(self.sample_info_widget)
main_layout.addWidget(self.crystal_widget)
main_layout.addStretch(10)
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,
)
def populate_sample_details(self, sample):
self.sample = sample
self.crystal = sample.crystals[0]
self.crystal_mib.set_model(self.crystal)
self.sample_mib.set_model(sample)
示例6: AcquisitionWidgetSimple
# 需要導入模塊: from widgets.widget_utils import DataModelInputBinder [as 別名]
# 或者: from widgets.widget_utils.DataModelInputBinder import set_model [as 別名]
#.........這裏部分代碼省略.........
def osc_start_cbox_click(self, state):
self.update_osc_start(self._beamline_setup._get_omega_axis_position())
self.acq_widget_layout.child('osc_start_ledit').setEnabled(state)
def update_osc_start(self, new_value):
if not self.acq_widget_layout.child('osc_start_cbox').isChecked():
osc_start_ledit = self.acq_widget_layout.child('osc_start_ledit')
osc_start_value = 0
try:
osc_start_value = round(float(new_value),2)
except TypeError:
pass
osc_start_ledit.setText("%.2f" % osc_start_value)
self._acquisition_parameters.osc_start = osc_start_value
def update_num_images(self, index = None, num_images = None):
if index is not None:
if index is 0:
self._acquisition_parameters.num_images = 1
self._path_template.num_files = 1
elif index is 1:
self._acquisition_parameters.num_images = 2
self._path_template.num_files = 2
elif index is 2:
self._acquisition_parameters.num_images = 4
self._path_template.num_files = 4
if num_images:
if self.acq_widget_layout.child('num_images_cbox').count() > 3:
self.acq_widget_layout.child('num_images_cbox').removeItem(4)
if num_images is 1:
self.acq_widget_layout.child('num_images_cbox').setCurrentItem(0)
elif num_images is 2:
self.acq_widget_layout.child('num_images_cbox').setCurrentItem(1)
elif num_images is 4:
self.acq_widget_layout.child('num_images_cbox').setCurrentItem(2)
else:
self.acq_widget_layout.child('num_images_cbox').insertItem(str(num_images))
self.acq_widget_layout.child('num_images_cbox').setCurrentItem(3)
self._path_template.num_files = num_images
def use_mad(self, state):
pass
def get_mad_energy(self):
pass
def set_energies(self, energy_scan_result):
pass
def energy_selected(self, index):
pass
def set_beamline_setup(self, beamline_setup):
self._beamline_setup = beamline_setup
te = beamline_setup.tunable_wavelength()
self.set_tunable_energy(te)
has_aperture = self._beamline_setup.has_aperture()
self.hide_aperture(has_aperture)
def set_energy(self, energy, wav):
self._acquisition_parameters.energy = energy
self.acq_widget_layout.child('energy_ledit').setText("%.4f" % float(energy))
def update_transmission(self, transmission):
self.acq_widget_layout.child('transmission_ledit').\
setText("%.2f" % float(transmission))
self._acquisition_parameters.transmission = float(transmission)
def update_resolution(self, resolution):
self.acq_widget_layout.child('resolution_ledit').\
setText("%.3f" % float(resolution))
self._acquisition_parameters.resolution = float(resolution)
def update_data_model(self, acquisition_parameters, path_template):
self._acquisition_parameters = acquisition_parameters
self._acquisition_mib.set_model(acquisition_parameters)
self._path_template = path_template
self.update_num_images(None, acquisition_parameters.num_images)
def set_tunable_energy(self, state):
self.acq_widget_layout.child('energy_ledit').setEnabled(state)
def hide_aperture(self, state):
if state:
self.acq_widget_layout.child('aperture_ledit').show()
self.acq_widget_layout.child('aperture_cbox').show()
else:
self.acq_widget_layout.child('aperture_ledit').hide()
self.acq_widget_layout.child('aperture_cbox').hide()
def use_osc_start(self, state):
self.acq_widget_layout.child('osc_start_cbox').setChecked(state)
self.acq_widget_layout.child('osc_start_cbox').setDisabled(state)
示例7: CreateXRFSpectrumWidget
# 需要導入模塊: from widgets.widget_utils import DataModelInputBinder [as 別名]
# 或者: from widgets.widget_utils.DataModelInputBinder import set_model [as 別名]
class CreateXRFSpectrumWidget(CreateTaskBase):
def __init__(self, parent=None, name=None, fl=0):
CreateTaskBase.__init__(self, parent, name, fl, "XRF-spectrum")
self.count_time = None
# Data attributes
self.init_models()
xrfspectrum_model = queue_model_objects.XRFSpectrum()
self.xrfspectrum_mib = DataModelInputBinder(xrfspectrum_model)
# Layout
v_layout = qt.QVBoxLayout(self, 2, 6, "main_v_layout")
self._data_path_gbox = qt.QVGroupBox("Data location", self, "data_path_gbox")
self._data_path_widget = DataPathWidget(
self._data_path_gbox, data_model=self._path_template, layout="vertical"
)
parameters_hor_gbox = qt.QHGroupBox("Parameters", self)
self.count_time_label = qt.QLabel("Count time", parameters_hor_gbox)
self.count_time_label.setFixedWidth(83)
self.count_time_ledit = qt.QLineEdit(
"1.0", parameters_hor_gbox, "count_time_ledit"
)
self.count_time_ledit.setFixedWidth(50)
self.xrfspectrum_mib.bind_value_update(
"count_time", self.count_time_ledit, float
) # ,
spacer = qt.QWidget(parameters_hor_gbox)
spacer.setSizePolicy(qt.QSizePolicy.Expanding, qt.QSizePolicy.Fixed)
v_layout.addWidget(self._data_path_gbox)
v_layout.addWidget(parameters_hor_gbox)
v_layout.addStretch()
self.connect(
self._data_path_widget.data_path_widget_layout.child("run_number_ledit"),
qt.SIGNAL("textChanged(const QString &)"),
self._run_number_ledit_change,
)
self.connect(
self._data_path_widget.data_path_widget_layout.child("prefix_ledit"),
qt.SIGNAL("textChanged(const QString &)"),
self._prefix_ledit_change,
)
self.connect(
self._data_path_widget,
qt.PYSIGNAL("path_template_changed"),
self.handle_path_conflict,
)
def init_models(self):
CreateTaskBase.init_models(self)
self._path_template.start_num = 1
self._path_template.num_files = 1
self._path_template.suffix = "raw"
def single_item_selection(self, tree_item):
CreateTaskBase.single_item_selection(self, tree_item)
if isinstance(tree_item, queue_item.XRFSpectrumQueueItem):
xrfspectrum_model = tree_item.get_model()
self.xrfspectrum_mib.set_model(xrfspectrum_model)
if xrfspectrum_model.is_executed():
self.setDisabled(True)
else:
self.setDisabled(False)
if xrfspectrum_model.get_path_template():
self._path_template = xrfspectrum_model.get_path_template()
self._data_path_widget.update_data_model(self._path_template)
elif isinstance(tree_item, queue_item.BasketQueueItem):
self.setDisabled(False)
elif not (
isinstance(tree_item, queue_item.SampleQueueItem)
or isinstance(tree_item, queue_item.DataCollectionGroupQueueItem)
):
self.setDisabled(True)
def approve_creation(self):
result = CreateTaskBase.approve_creation(self)
selected_shapes = self._shape_history.selected_shapes
for shape in selected_shapes:
if isinstance(shape, shape_history.Line) or isinstance(
shape, shape_history.CanvasGrid
):
result = False
self.count_time = None
try:
#.........這裏部分代碼省略.........
示例8: DataPathWidget
# 需要導入模塊: from widgets.widget_utils import DataModelInputBinder [as 別名]
# 或者: from widgets.widget_utils.DataModelInputBinder import set_model [as 別名]
#.........這裏部分代碼省略.........
given_dir = self._session_hwobj.get_base_image_directory()
d = str(get_dir.getExistingDirectory(given_dir, self, "",
"Select a directory",
True, False))
d = os.path.dirname(d)
if d is not None and len(d) > 0:
self.set_directory(d)
def _prefix_ledit_change(self, new_value):
self.set_prefix(new_value)
self.emit(qt.PYSIGNAL('path_template_changed'),
(self.data_path_widget_layout.prefix_ledit,
new_value))
def _run_number_ledit_change(self, new_value):
if str(new_value).isdigit():
self.set_run_number(new_value)
self.emit(qt.PYSIGNAL('path_template_changed'),
(self.data_path_widget_layout.run_number_ledit,
new_value))
def _folder_ledit_change(self, new_value):
base_image_dir = self._session_hwobj.get_base_image_directory()
base_proc_dir = self._session_hwobj.get_base_process_directory()
new_sub_dir = str(new_value)
if len(new_sub_dir) > 0:
if new_sub_dir[0] == '/':
new_sub_dir = new_sub_dir[1:]
new_image_directory = os.path.join(base_image_dir, str(new_sub_dir))
new_proc_dir = os.path.join(base_proc_dir, str(new_sub_dir))
else:
new_image_directory = base_image_dir
new_proc_dir = base_proc_dir
self._data_model.directory = new_image_directory
self._data_model.process_directory = new_proc_dir
self.data_path_widget_layout.folder_ledit.\
setPaletteBackgroundColor(widget_colors.WHITE)
self.emit(qt.PYSIGNAL('path_template_changed'),
(self.data_path_widget_layout.folder_ledit,
new_value))
def set_data_path(self, path):
(dir_name, file_name) = os.path.split(path)
self.set_directory(dir_name)
file_name = file_name.replace('%' + self._data_model.precision + 'd',
int(self._data_model.precision) * '#' )
self.data_path_widget_layout.file_name_value_label.setText(file_name)
def set_directory(self, directory):
base_image_dir = self._session_hwobj.get_base_image_directory()
dir_parts = directory.split(base_image_dir)
if len(dir_parts) > 1:
sub_dir = dir_parts[1]
self._data_model.directory = directory
self.data_path_widget_layout.folder_ledit.setText(sub_dir)
#self.data_path_widget_layout.folder_ledit.\
# setPaletteBackgroundColor(widget_colors.WHITE)
else:
self.data_path_widget_layout.folder_ledit.setText('')
#self.data_path_widget_layout.folder_ledit.\
# setPaletteBackgroundColor(widget_colors.LIGHT_RED)
self._data_model.directory = base_image_dir
#logging.getLogger('user_level_log').\
# info("The selected data location is invalid, please select" \
# " a directory within: " + base_image_dir)
self.data_path_widget_layout.base_path_label.setText(base_image_dir)
def set_run_number(self, run_number):
self._data_model.run_number = int(run_number)
self.data_path_widget_layout.run_number_ledit.\
setText(str(run_number))
def set_prefix(self, base_prefix):
self._data_model.base_prefix = str(base_prefix)
self.data_path_widget_layout.prefix_ledit.setText(str(base_prefix))
file_name = self._data_model.get_image_file_name()
file_name = file_name.replace('%' + self._data_model.precision + 'd',
int(self._data_model.precision) * '#' )
self.data_path_widget_layout.file_name_value_label.setText(file_name)
def update_data_model(self, data_model):
self._data_model = data_model
self.set_data_path(data_model.get_image_path())
self._data_model_pm.set_model(data_model)
示例9: AcquisitionWidget
# 需要導入模塊: from widgets.widget_utils import DataModelInputBinder [as 別名]
# 或者: from widgets.widget_utils.DataModelInputBinder import set_model [as 別名]
#.........這裏部分代碼省略.........
return int(self.acq_widget_layout.child('subwedge_size_ledit').text())
def subwedge_size_ledit_change(self, new_value):
widget = self.acq_widget_layout.child('subwedge_size_ledit')
if int(new_value) > self._acquisition_parameters.num_images:
widget.setPaletteBackgroundColor(widget_colors.LIGHT_RED)
else:
widget.setPaletteBackgroundColor(widget_colors.WHITE)
def get_mad_energy(self):
energy_str = str(self.acq_widget_layout.\
child('energies_combo').currentText())
(name, value) = energy_str.split(':')
name = name.strip()
value = value.strip()
value = 0 if (value == '-') else value
return (name, value)
def set_energies(self, energy_scan_result):
self.acq_widget_layout.child('energies_combo').clear()
inflection = ('ip: %.4f' % energy_scan_result.inflection) if \
energy_scan_result.inflection else 'ip: -'
peak = ('pk: %.4f' % energy_scan_result.peak) if \
energy_scan_result.peak else 'pk: -'
first_remote = ('rm1: %.4f' % energy_scan_result.first_remote) if \
energy_scan_result.first_remote else 'rm1: -'
second_remote = ('rm2: %.4f' % energy_scan_result.second_remote) if \
energy_scan_result.second_remote else 'rm2: -'
self.acq_widget_layout.child('energies_combo').\
insertStrList([inflection,
peak,
first_remote,
second_remote])
def energy_selected(self, index):
if self.acq_widget_layout.child('mad_cbox').isChecked():
(name, energy) = self.get_mad_energy()
if energy != 0:
self.set_energy(energy, 0)
self.emit(qt.PYSIGNAL('mad_energy_selected'), (name, energy, True))
def set_energy(self, energy, wav):
self._acquisition_parameters.energy = energy
self.acq_widget_layout.child('energy_ledit').setText("%.4f" % float(energy))
def update_transmission(self, transmission):
self.acq_widget_layout.child('transmission_ledit').\
setText("%.2f" % float(transmission))
self._acquisition_parameters.transmission = float(transmission)
def update_resolution(self, resolution):
self.acq_widget_layout.child('resolution_ledit').\
setText("%.3f" % float(resolution))
self._acquisition_parameters.resolution = float(resolution)
def update_data_model(self, acquisition_parameters, path_template):
self._acquisition_parameters = acquisition_parameters
self._path_template = path_template
self._acquisition_mib.set_model(acquisition_parameters)
#Update mad widgets
mad = True if self._path_template.mad_prefix != '' else False
if mad:
mad_prefix = self._path_template.mad_prefix
index = MAD_ENERGY_COMBO_NAMES[mad_prefix]
self.acq_widget_layout.child('energies_combo').setCurrentItem(index)
self.acq_widget_layout.child('mad_cbox').setChecked(True)
self.acq_widget_layout.child('energies_combo').setEnabled(True)
else:
self.acq_widget_layout.child('mad_cbox').setChecked(False)
self.acq_widget_layout.child('energies_combo').setEnabled(False)
self.acq_widget_layout.child('energies_combo').setCurrentItem(0)
def set_tunable_energy(self, state):
self.acq_widget_layout.child('energy_ledit').setEnabled(state)
self.acq_widget_layout.child('mad_cbox').setEnabled(state)
self.acq_widget_layout.child('energies_combo').setEnabled(state)
def disable_inverse_beam(self, state):
if state:
self.acq_widget_layout.child('inverse_beam_cbx').hide()
self.acq_widget_layout.child('subwedge_size_label').hide()
self.acq_widget_layout.child('subwedge_size_ledit').hide()
else:
self.acq_widget_layout.child('inverse_beam_cbx').show()
self.acq_widget_layout.child('subwedge_size_label').show()
self.acq_widget_layout.child('subwedge_size_ledit').show()
def hide_aperture(self, state):
pass
示例10: CreateCharWidget
# 需要導入模塊: from widgets.widget_utils import DataModelInputBinder [as 別名]
# 或者: from widgets.widget_utils.DataModelInputBinder import set_model [as 別名]
#.........這裏部分代碼省略.........
self._char_params = copy.deepcopy(self._char_params)
self._acquisition_parameters = copy.deepcopy(self._acquisition_parameters)
elif isinstance(tree_item, queue_item.CharacterisationQueueItem):
self.setDisabled(False)
self._char = tree_item.get_model()
if self._char.get_path_template():
self._path_template = self._char.get_path_template()
self._data_path_widget.update_data_model(self._path_template)
data_collection = self._char.reference_image_collection
self._char_params = self._char.characterisation_parameters
self._acquisition_parameters = data_collection.acquisitions[0].\
acquisition_parameters
if len(data_collection.acquisitions) == 1:
self.select_shape_with_cpos(self._acquisition_parameters.\
centred_position)
self._processing_parameters = data_collection.processing_parameters
else:
self.setDisabled(True)
if isinstance(tree_item, queue_item.SampleQueueItem) or \
isinstance(tree_item, queue_item.DataCollectionGroupQueueItem) or \
isinstance(tree_item, queue_item.CharacterisationQueueItem):
self._set_space_group(self._char_params.space_group)
self._acq_widget.update_data_model(self._acquisition_parameters,
self._path_template)
self._char_params_mib.set_model(self._char_params)
def update_processing_parameters(self, crystal):
self._processing_parameters.space_group = crystal.space_group
self._char_params.space_group = crystal.space_group
self._processing_parameters.cell_a = crystal.cell_a
self._processing_parameters.cell_alpha = crystal.cell_alpha
self._processing_parameters.cell_b = crystal.cell_b
self._processing_parameters.cell_beta = crystal.cell_beta
self._processing_parameters.cell_c = crystal.cell_c
self._processing_parameters.cell_gamma = crystal.cell_gamma
def approve_creation(self):
return CreateTaskBase.approve_creation(self)
# Called by the owning widget (task_toolbox_widget) to create
# a collection. when a data collection group is selected.
def _create_task(self, sample, shape):
tasks = []
if not shape:
cpos = queue_model_objects.CentredPosition()
cpos.snapshot_image = self._shape_history.get_snapshot([])
else:
# Shapes selected and sample is mounted, get the
# centred positions for the shapes
if isinstance(shape, shape_history.Point):
snapshot = self._shape_history.\
get_snapshot([shape.qub_point])
cpos = shape.get_centred_positions()[0]
cpos.snapshot_image = snapshot
示例11: DataPathWidget
# 需要導入模塊: from widgets.widget_utils import DataModelInputBinder [as 別名]
# 或者: from widgets.widget_utils.DataModelInputBinder import set_model [as 別名]
#.........這裏部分代碼省略.........
new_sub_dir = str(new_value).strip(" ")
if len(new_sub_dir) > 0:
if new_sub_dir[0] == os.path.sep:
new_sub_dir = new_sub_dir[1:]
new_image_directory = os.path.join(base_image_dir, str(new_sub_dir))
new_proc_dir = os.path.join(base_proc_dir, str(new_sub_dir))
else:
new_image_directory = base_image_dir
new_proc_dir = base_proc_dir
self._data_model.directory = new_image_directory
self._data_model.process_directory = new_proc_dir
self.data_path_widget_layout.child("folder_ledit").setPaletteBackgroundColor(
widget_colors.WHITE
)
self.emit(
qt.PYSIGNAL("path_template_changed"),
(self.data_path_widget_layout.child("folder_ledit"), new_value),
)
def set_data_path(self, path):
(dir_name, file_name) = os.path.split(path)
self.set_directory(dir_name)
file_name = file_name.replace(
"%" + self._data_model.precision + "d",
int(self._data_model.precision) * "#",
)
self.data_path_widget_layout.child("file_name_value_label").setText(file_name)
def set_directory(self, directory):
base_image_dir = self._base_image_dir
dir_parts = directory.split(base_image_dir)
if len(dir_parts) > 1:
sub_dir = dir_parts[1]
self._data_model.directory = directory
self.data_path_widget_layout.child("folder_ledit").setText(sub_dir)
else:
self.data_path_widget_layout.child("folder_ledit").setText("")
self._data_model.directory = base_image_dir
self.data_path_widget_layout.child("base_path_label").setText(base_image_dir)
def set_run_number(self, run_number):
self._data_model.run_number = int(run_number)
self.data_path_widget_layout.child("run_number_ledit").setText(str(run_number))
def set_prefix(self, base_prefix):
self._data_model.base_prefix = str(base_prefix)
self.data_path_widget_layout.child("prefix_ledit").setText(str(base_prefix))
file_name = self._data_model.get_image_file_name()
file_name = file_name.replace(
"%" + self._data_model.precision + "d",
int(self._data_model.precision) * "#",
)
self.data_path_widget_layout.child("file_name_value_label").setText(file_name)
def update_data_model(self, data_model):
self._data_model = data_model
self.set_data_path(data_model.get_image_path())
self._data_model_pm.set_model(data_model)
def indicate_path_conflict(self, conflict):
if conflict:
self.data_path_widget_layout.child(
"prefix_ledit"
).setPaletteBackgroundColor(widget_colors.LIGHT_RED)
self.data_path_widget_layout.child(
"run_number_ledit"
).setPaletteBackgroundColor(widget_colors.LIGHT_RED)
self.data_path_widget_layout.child(
"folder_ledit"
).setPaletteBackgroundColor(widget_colors.LIGHT_RED)
logging.getLogger("user_level_log").error(
"The current path settings will overwrite data"
+ " from another task. Correct the problem before adding to queue"
)
else:
# We had a conflict previous, but its corrected now !
if self.path_conflict_state:
logging.getLogger("user_level_log").info("Path valid")
self.data_path_widget_layout.child(
"prefix_ledit"
).setPaletteBackgroundColor(widget_colors.WHITE)
self.data_path_widget_layout.child(
"run_number_ledit"
).setPaletteBackgroundColor(widget_colors.WHITE)
self.data_path_widget_layout.child(
"folder_ledit"
).setPaletteBackgroundColor(widget_colors.WHITE)
self.path_conflict_state = conflict