def __init__(self, parent=None, name="parameter_widget"): QWidget.__init__(self, parent) if name is not None: self.setObjectName(name) # Properties ---------------------------------------------------------- # Signals ------------------------------------------------------------ # Slots --------------------------------------------------------------- # Hardware objects ---------------------------------------------------- self._beamline_setup_hwobj = None # Internal variables -------------------------------------------------- self._data_collection = None self.add_dc_cb = None self._tree_view_item = None # Graphic elements ---------------------------------------------------- _dc_parameters_widget = QWidget(self) self._data_path_widget = DataPathWidget(_dc_parameters_widget) self._acq_widget = AcquisitionWidget(_dc_parameters_widget, layout='horizontal') self._processing_widget = ProcessingWidget(_dc_parameters_widget) # Layout -------------------------------------------------------------- _dc_parameters_widget_layout = QVBoxLayout(_dc_parameters_widget) _dc_parameters_widget_layout.addWidget(self._data_path_widget) _dc_parameters_widget_layout.addWidget(self._acq_widget) _dc_parameters_widget_layout.addWidget(self._processing_widget) _dc_parameters_widget_layout.setContentsMargins(0, 0, 0, 0) _dc_parameters_widget_layout.setSpacing(2) _dc_parameters_widget_layout.addStretch(10) _main_hlayout = QHBoxLayout(self) _main_hlayout.addWidget(_dc_parameters_widget) _main_hlayout.setContentsMargins(0, 0, 0, 0) _main_hlayout.setSpacing(2) _main_hlayout.addStretch(0) # SizePolicies -------------------------------------------------------- # Qt signal/slot connections ------------------------------------------ self._data_path_widget.data_path_layout.prefix_ledit.textChanged.\ connect(self._prefix_ledit_change) self._data_path_widget.data_path_layout.run_number_ledit.textChanged.\ connect(self._run_number_ledit_change) self._acq_widget.madEnergySelectedSignal.\ connect(self.mad_energy_selected) self._acq_widget.acqParametersChangedSignal.\ connect(self.acq_parameters_changed)
def __init__(self, parent = None, name = "parameter_widget"): QtGui.QWidget.__init__(self, parent) if name is not None: self.setObjectName(name) # Properties ---------------------------------------------------------- # Signals ------------------------------------------------------------ # Slots --------------------------------------------------------------- # Hardware objects ---------------------------------------------------- self._beamline_setup_hwobj = None # Internal variables -------------------------------------------------- self._data_collection = None self.add_dc_cb = None self._tree_view_item = None # Graphic elements ---------------------------------------------------- _dc_parameters_widget = QtGui.QWidget(self) self._data_path_widget = DataPathWidget(_dc_parameters_widget) self._acq_widget = AcquisitionWidget(_dc_parameters_widget, layout = 'horizontal') self._processing_widget = ProcessingWidget(_dc_parameters_widget) # Layout -------------------------------------------------------------- _dc_parameters_widget_layout = QtGui.QVBoxLayout(_dc_parameters_widget) _dc_parameters_widget_layout.addWidget(self._data_path_widget) _dc_parameters_widget_layout.addWidget(self._acq_widget) _dc_parameters_widget_layout.addWidget(self._processing_widget) _dc_parameters_widget_layout.setContentsMargins(0, 0, 0, 0) _dc_parameters_widget_layout.setSpacing(2) _dc_parameters_widget_layout.addStretch(10) _main_hlayout = QtGui.QHBoxLayout(self) _main_hlayout.addWidget(_dc_parameters_widget) _main_hlayout.setContentsMargins(0, 0, 0, 0) _main_hlayout.setSpacing(2) _main_hlayout.addStretch(0) # SizePolicies -------------------------------------------------------- # Qt signal/slot connections ------------------------------------------ self._data_path_widget.data_path_layout.prefix_ledit.textChanged.\ connect(self._prefix_ledit_change) self._data_path_widget.data_path_layout.run_number_ledit.textChanged.\ connect(self._run_number_ledit_change) self._acq_widget.madEnergySelectedSignal.\ connect(self.mad_energy_selected) self._acq_widget.acqParametersChangedSignal.\ connect(self.acq_parameters_changed)
class DCParametersWidget(QtGui.QWidget): def __init__(self, parent = None, name = "parameter_widget"): QtGui.QWidget.__init__(self, parent) if name is not None: self.setObjectName(name) # Properties ---------------------------------------------------------- # Signals ------------------------------------------------------------ # Slots --------------------------------------------------------------- # Hardware objects ---------------------------------------------------- self._beamline_setup_hwobj = None # Internal variables -------------------------------------------------- self._data_collection = None self.add_dc_cb = None self._tree_view_item = None # Graphic elements ---------------------------------------------------- _dc_parameters_widget = QtGui.QWidget(self) self._data_path_widget = DataPathWidget(_dc_parameters_widget) self._acq_widget = AcquisitionWidget(_dc_parameters_widget, layout = 'horizontal') #self._acq_widget.setFixedHeight(170) self._processing_widget = ProcessingWidget(_dc_parameters_widget) _snapshot_widget = QtGui.QWidget(self) self.position_widget = uic.loadUi(os.path.join(os.path.dirname(__file__), 'ui_files/Qt4_snapshot_widget_layout.ui')) # Layout -------------------------------------------------------------- _dc_parameters_widget_layout = QtGui.QVBoxLayout(_dc_parameters_widget) _dc_parameters_widget_layout.addWidget(self._data_path_widget) _dc_parameters_widget_layout.addWidget(self._acq_widget) _dc_parameters_widget_layout.addWidget(self._processing_widget) _dc_parameters_widget_layout.setContentsMargins(0, 0, 0, 0) _dc_parameters_widget_layout.setSpacing(2) _dc_parameters_widget_layout.addStretch(0) _snapshots_vlayout = QtGui.QVBoxLayout(_snapshot_widget) _snapshots_vlayout.addWidget(self.position_widget) _snapshots_vlayout.setContentsMargins(0, 0, 0, 0) _snapshots_vlayout.setSpacing(2) _snapshots_vlayout.addStretch(10) _main_hlayout = QtGui.QHBoxLayout(self) _main_hlayout.addWidget(_dc_parameters_widget) _main_hlayout.addWidget(_snapshot_widget) _main_hlayout.setContentsMargins(0, 0, 0, 0) _main_hlayout.setSpacing(2) _main_hlayout.addStretch(0) # SizePolicies -------------------------------------------------------- # Qt signal/slot connections ------------------------------------------ self._data_path_widget.data_path_layout.prefix_ledit.textChanged.connect( self._prefix_ledit_change) self._data_path_widget.data_path_layout.run_number_ledit.textChanged.connect( self._run_number_ledit_change) self._acq_widget.madEnergySelectedSignal.connect(self.mad_energy_selected) self._acq_widget.acqParametersChangedSignal.connect(\ self.acq_parameters_changed) # Other --------------------------------------------------------------- def set_beamline_setup(self, bl_setup): self._acq_widget.set_beamline_setup(bl_setup) self._beamline_setup_hwobj = bl_setup def _prefix_ledit_change(self, new_value): prefix = self._data_collection.acquisitions[0].\ path_template.get_prefix() self._data_collection.set_name(prefix) self._tree_view_item.setText(0, self._data_collection.get_name()) def _run_number_ledit_change(self, new_value): if str(new_value).isdigit(): self._data_collection.set_number(int(new_value)) self._tree_view_item.setText(0, self._data_collection.get_name()) def acq_parameters_changed(self): if self._tree_view_item is None: #TODO fix this return dc_tree_widget = self._tree_view_item.listView().parent() dc_tree_widget.check_for_path_collisions() path_template = self._data_collection.acquisitions[0].path_template path_conflict = self.queue_model_hwobj.\ check_for_path_collisions(path_template) if new_value != '': if path_conflict: logging.getLogger("user_level_log").\ error('The current path settings will overwrite data' +\ ' from another task. Correct the problem before collecting') widget.setPaletteBackgroundColor(widget_colors.LIGHT_RED) else: widget.setPaletteBackgroundColor(widget_colors.WHITE) def __add_data_collection(self): return self.add_dc_cb(self._data_collection, self.collection_type) def mad_energy_selected(self, name, energy, state): path_template = self._data_collection.acquisitions[0].path_template if state: path_template.mad_prefix = name else: path_template.mad_prefix = '' run_number = self._beamline_setup_hwobj.queue_model_hwobj.\ get_next_run_number(path_template) self._data_path_widget.set_run_number(run_number) self._data_path_widget.set_prefix(path_template.base_prefix) model = self._tree_view_item.get_model() model.set_name(path_template.get_prefix()) self._tree_view_item.setText(0, model.get_name()) def tab_changed(self): if self._tree_view_item: self.populate_parameter_widget(self._tree_view_item) def set_enabled(self, state): self._acq_widget.setEnabled(state) self._data_path_widget.setEnabled(state) self._processing_widget.setEnabled(state) 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) if data_collection.acquisitions[0].acquisition_parameters.\ centred_position.snapshot_image: image = data_collection.acquisitions[0].\ acquisition_parameters.centred_position.snapshot_image ration = image.height() / float(image.width()) image = image.scaled(400, 400 * ration, QtCore.Qt.KeepAspectRatio) self.position_widget.svideo.setPixmap(QtGui.QPixmap(image)) 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("user_level_log").\ warning(msg)
def __init__(self, parent = None, name = "parameter_widget"): QtGui.QWidget.__init__(self, parent) if name is not None: self.setObjectName(name) # Properties ---------------------------------------------------------- # Signals ------------------------------------------------------------ # Slots --------------------------------------------------------------- # Hardware objects ---------------------------------------------------- self._beamline_setup_hwobj = None # Internal variables -------------------------------------------------- self._data_collection = None self.add_dc_cb = None self._tree_view_item = None # Graphic elements ---------------------------------------------------- _dc_parameters_widget = QtGui.QWidget(self) self.caution_pixmap = Qt4_Icons.load("Caution2.png") self.path_widget = DataPathWidget(_dc_parameters_widget) self.acq_widget = AcquisitionWidget(_dc_parameters_widget, layout = 'horizontal') #self.acq_widget.setFixedHeight(170) self.processing_widget = ProcessingWidget(_dc_parameters_widget) self.position_widget = uic.loadUi(os.path.join(os.path.dirname(__file__), 'ui_files/Qt4_snapshot_widget_layout.ui')) #self.position_widget.setMinimumSize(310, 210) # Layout -------------------------------------------------------------- _dc_parameters_widget_layout = QtGui.QVBoxLayout(self) _dc_parameters_widget_layout.addWidget(self.path_widget) _dc_parameters_widget_layout.addWidget(self.acq_widget) _dc_parameters_widget_layout.addWidget(self.processing_widget) _dc_parameters_widget_layout.setSpacing(2) _dc_parameters_widget_layout.addStretch(0) _dc_parameters_widget_layout.setContentsMargins(0, 0, 0, 0) _dc_parameters_widget.setLayout(_dc_parameters_widget_layout) _main_hlayout = QtGui.QHBoxLayout(self) _main_hlayout.addWidget(_dc_parameters_widget) _main_hlayout.addWidget(self.position_widget) _main_hlayout.setSpacing(2) _main_hlayout.setContentsMargins(0, 0, 0, 0) _main_hlayout.addStretch(0) self.setLayout(_main_hlayout) # SizePolicies -------------------------------------------------------- # Qt signal/slot connections ------------------------------------------ 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.connect(self.acq_widget, QtCore.SIGNAL('mad_energy_selected'), self.mad_energy_selected) self.connect(self.acq_widget, QtCore.SIGNAL("path_template_changed"), self.handle_path_conflict) #QtCore.QObject.connect(QtGui.QApplication, QtCore.SIGNAL('tab_changed'), # self.tab_changed) # Other --------------------------------------------------------------- Qt4_widget_colors.set_widget_color(self.path_widget, Qt4_widget_colors.GROUP_BOX_GRAY) Qt4_widget_colors.set_widget_color(self.acq_widget, Qt4_widget_colors.GROUP_BOX_GRAY) Qt4_widget_colors.set_widget_color(self.processing_widget, Qt4_widget_colors.GROUP_BOX_GRAY) Qt4_widget_colors.set_widget_color(self.position_widget, Qt4_widget_colors.GROUP_BOX_GRAY)
class DCParametersWidget(QWidget): def __init__(self, parent=None, name="parameter_widget"): QWidget.__init__(self, parent) if name is not None: self.setObjectName(name) # Properties ---------------------------------------------------------- # Signals ------------------------------------------------------------ # Slots --------------------------------------------------------------- # Hardware objects ---------------------------------------------------- self._beamline_setup_hwobj = None # Internal variables -------------------------------------------------- self._data_collection = None self.add_dc_cb = None self._tree_view_item = None # Graphic elements ---------------------------------------------------- _dc_parameters_widget = QWidget(self) self._data_path_widget = DataPathWidget(_dc_parameters_widget) self._acq_widget = AcquisitionWidget(_dc_parameters_widget, layout='horizontal') self._processing_widget = ProcessingWidget(_dc_parameters_widget) # Layout -------------------------------------------------------------- _dc_parameters_widget_layout = QVBoxLayout(_dc_parameters_widget) _dc_parameters_widget_layout.addWidget(self._data_path_widget) _dc_parameters_widget_layout.addWidget(self._acq_widget) _dc_parameters_widget_layout.addWidget(self._processing_widget) _dc_parameters_widget_layout.setContentsMargins(0, 0, 0, 0) _dc_parameters_widget_layout.setSpacing(2) _dc_parameters_widget_layout.addStretch(10) _main_hlayout = QHBoxLayout(self) _main_hlayout.addWidget(_dc_parameters_widget) _main_hlayout.setContentsMargins(0, 0, 0, 0) _main_hlayout.setSpacing(2) _main_hlayout.addStretch(0) # SizePolicies -------------------------------------------------------- # Qt signal/slot connections ------------------------------------------ self._data_path_widget.data_path_layout.prefix_ledit.textChanged.\ connect(self._prefix_ledit_change) self._data_path_widget.data_path_layout.run_number_ledit.textChanged.\ connect(self._run_number_ledit_change) self._acq_widget.madEnergySelectedSignal.\ connect(self.mad_energy_selected) self._acq_widget.acqParametersChangedSignal.\ connect(self.acq_parameters_changed) # Other --------------------------------------------------------------- def set_beamline_setup(self, bl_setup): self._acq_widget.set_beamline_setup(bl_setup) self._beamline_setup_hwobj = bl_setup def _prefix_ledit_change(self, new_value): prefix = self._data_collection.acquisitions[0].\ path_template.get_prefix() self._data_collection.set_name(prefix) self._tree_view_item.setText(0, self._data_collection.get_name()) def _run_number_ledit_change(self, new_value): if str(new_value).isdigit(): self._data_collection.set_number(int(new_value)) self._tree_view_item.setText(0, self._data_collection.get_name()) def acq_parameters_changed(self): if self._tree_view_item is None: #TODO fix this return #TODO get tree view in another way dc_tree_widget = self._tree_view_item.listView().parent().parent() dc_tree_widget.check_for_path_collisions() path_template = self._data_collection.acquisitions[0].path_template path_conflict = self.queue_model_hwobj.\ check_for_path_collisions(path_template) def __add_data_collection(self): return self.add_dc_cb(self._data_collection, self.collection_type) def mad_energy_selected(self, name, energy, state): path_template = self._data_collection.acquisitions[0].path_template if state: path_template.mad_prefix = str(name) else: path_template.mad_prefix = '' run_number = self._beamline_setup_hwobj.queue_model_hwobj.\ get_next_run_number(path_template) self._data_path_widget.set_run_number(run_number) self._data_path_widget.set_prefix(path_template.base_prefix) model = self._tree_view_item.get_model() model.set_name(path_template.get_prefix()) self._tree_view_item.setText(0, model.get_name()) def tab_changed(self): if self._tree_view_item: self.populate_parameter_widget(self._tree_view_item) def set_enabled(self, state): self._acq_widget.setEnabled(state) self._data_path_widget.setEnabled(state) self._processing_widget.setEnabled(state) 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)
def __init__(self, parent=None, name=None, fl=0): CreateTaskBase.__init__(self, parent, name, QtCore.Qt.WindowFlags(fl), 'GphlWorkflow') if not name: self.setObjectName("Qt4_create_gphl_workflow_widget") # Hardware objects ---------------------------------------------------- self._workflow_hwobj = None # Internal variables -------------------------------------------------- self.current_prefix = None self.init_models() # Graphic elements ---------------------------------------------------- self._workflow_type_widget = QtGui.QGroupBox('Workflow type', self) self._workflow_cbox = QtGui.QComboBox(self._workflow_type_widget) self._gphl_acq_widget = QtGui.QGroupBox('Acquisition', self) self._gphl_acq_param_widget = GphlAcquisitionWidget( self._gphl_acq_widget, "gphl_acquisition_parameter_widget") self._data_path_widget = DataPathWidget(self, 'create_dc_path_widget', layout='vertical') data_path_layout = self._data_path_widget.data_path_layout data_path_layout.file_name_label.hide() data_path_layout.file_name_value_label.hide() data_path_layout.run_number_label.hide() data_path_layout.run_number_ledit.hide() self._processing_widget = ProcessingWidget(self) processing_layout = self._processing_widget.processing_widget processing_layout.num_residues_label.hide() processing_layout.num_residues_ledit.hide() processing_layout.run_processing_after_cbox.hide() # Layout -------------------------------------------------------------- _workflow_type_vlayout = QtGui.QVBoxLayout(self._workflow_type_widget) _workflow_type_vlayout.addWidget(self._workflow_cbox) _gphl_acq_vlayout = QtGui.QVBoxLayout(self._gphl_acq_widget) _gphl_acq_vlayout.addWidget(self._gphl_acq_param_widget) _main_vlayout = QtGui.QVBoxLayout(self) _main_vlayout.addWidget(self._workflow_type_widget) _main_vlayout.addWidget(self._data_path_widget) _main_vlayout.addWidget(self._gphl_acq_widget) _main_vlayout.addWidget(self._processing_widget) _main_vlayout.addStretch(0) _main_vlayout.setSpacing(2) _main_vlayout.setContentsMargins(0, 0, 0, 0) # SizePolicies -------------------------------------------------------- # Qt signal/slot connections ------------------------------------------ # TODO check if this is needed # self._data_path_widget.data_path_layout.prefix_ledit.textChanged.connect( # self._prefix_ledit_change) # Removed in porting to master branch # self._data_path_widget.data_path_layout.run_number_ledit.textChanged.connect( # self._run_number_ledit_change) self._workflow_cbox.currentIndexChanged[str].connect( self.workflow_selected) # set up popup data dialog self.gphl_data_dialog = GphlDataDialog(self, 'GPhL Workflow Data') self.gphl_data_dialog.setModal(True) self.gphl_data_dialog.continueClickedSignal.connect(self.data_acquired)
class CreateGphlWorkflowWidget(CreateTaskBase): def __init__(self, parent=None, name=None, fl=0): CreateTaskBase.__init__(self, parent, name, QtCore.Qt.WindowFlags(fl), 'GphlWorkflow') if not name: self.setObjectName("Qt4_create_gphl_workflow_widget") # Hardware objects ---------------------------------------------------- self._workflow_hwobj = None # Internal variables -------------------------------------------------- self.current_prefix = None self.init_models() # Graphic elements ---------------------------------------------------- self._workflow_type_widget = QtGui.QGroupBox('Workflow type', self) self._workflow_cbox = QtGui.QComboBox(self._workflow_type_widget) self._gphl_acq_widget = QtGui.QGroupBox('Acquisition', self) self._gphl_acq_param_widget = GphlAcquisitionWidget( self._gphl_acq_widget, "gphl_acquisition_parameter_widget") self._data_path_widget = DataPathWidget(self, 'create_dc_path_widget', layout='vertical') data_path_layout = self._data_path_widget.data_path_layout data_path_layout.file_name_label.hide() data_path_layout.file_name_value_label.hide() data_path_layout.run_number_label.hide() data_path_layout.run_number_ledit.hide() self._processing_widget = ProcessingWidget(self) processing_layout = self._processing_widget.processing_widget processing_layout.num_residues_label.hide() processing_layout.num_residues_ledit.hide() processing_layout.run_processing_after_cbox.hide() # Layout -------------------------------------------------------------- _workflow_type_vlayout = QtGui.QVBoxLayout(self._workflow_type_widget) _workflow_type_vlayout.addWidget(self._workflow_cbox) _gphl_acq_vlayout = QtGui.QVBoxLayout(self._gphl_acq_widget) _gphl_acq_vlayout.addWidget(self._gphl_acq_param_widget) _main_vlayout = QtGui.QVBoxLayout(self) _main_vlayout.addWidget(self._workflow_type_widget) _main_vlayout.addWidget(self._data_path_widget) _main_vlayout.addWidget(self._gphl_acq_widget) _main_vlayout.addWidget(self._processing_widget) _main_vlayout.addStretch(0) _main_vlayout.setSpacing(2) _main_vlayout.setContentsMargins(0, 0, 0, 0) # SizePolicies -------------------------------------------------------- # Qt signal/slot connections ------------------------------------------ # TODO check if this is needed # self._data_path_widget.data_path_layout.prefix_ledit.textChanged.connect( # self._prefix_ledit_change) # Removed in porting to master branch # self._data_path_widget.data_path_layout.run_number_ledit.textChanged.connect( # self._run_number_ledit_change) self._workflow_cbox.currentIndexChanged[str].connect( self.workflow_selected) # set up popup data dialog self.gphl_data_dialog = GphlDataDialog(self, 'GPhL Workflow Data') self.gphl_data_dialog.setModal(True) self.gphl_data_dialog.continueClickedSignal.connect(self.data_acquired) # self.connect(self.gphl_data_dialog, qt.PYSIGNAL("continue_clicked"), # self.data_acquired) def initialise_workflows(self, workflow_hwobj): self._workflow_hwobj = workflow_hwobj self._workflow_cbox.clear() # self._gphl_parameters_widget.set_workflow(workflow_hwobj) if self._workflow_hwobj is not None: workflow_names = list(workflow_hwobj.get_available_workflows()) for workflow_name in workflow_names: self._workflow_cbox.addItem(workflow_name) self.workflow_selected(workflow_names[0]) workflow_hwobj.connect('gphlParametersNeeded', self.gphl_data_dialog.open_dialog) # # Set hardwired and default values # self._gphl_acquisition_widget.set_param_value('char_energy', # workflow_hwobj.getProperty('characterisation_energy') # ) # # Placeholder. Must be set to match hardwired detector distance # self._gphl_acquisition_widget.set_param_value('detector_resolution', -1) def workflow_selected(self, name): # necessary as this comes in as a QString object name = str(name) # if reset or name != self._previous_workflow: xx = self._workflow_cbox xx.setCurrentIndex(xx.findText(name)) # self._previous_workflow = name parameters = self._workflow_hwobj.get_available_workflows()[name] beam_energies = parameters.get('beam_energies', {}) strategy_type = parameters.get('strategy_type') if strategy_type == 'transcal': self._processing_widget.hide() self._gphl_acq_widget.hide() else: # diffractcal or acquisition type strategy self._processing_widget.show() self._gphl_acq_param_widget.populate_widget( beam_energies=beam_energies) self._gphl_acq_widget.show() prefix = parameters.get('prefix') if prefix is not None: self.current_prefix = prefix def data_acquired(self): """Data gathered from popup, continue execution""" pass # def set_beam_energies(self, beam_energy_dict): # parameter_dict = self._gphl_acquisition_widget.get_parameter_dict() # for tag, energy in beam_energy_dict.items(): # if tag in parameter_dict: # self._gphl_acquisition_widget.set_param_value(tag, energy) # else: # raise ValueError("GPhL: No active beam energy named %s" # % tag) def single_item_selection(self, tree_item): CreateTaskBase.single_item_selection(self, tree_item) wf_model = tree_item.get_model() if isinstance(tree_item, queue_item.SampleQueueItem): sample_model = tree_item.get_model() self._processing_parameters = sample_model.processing_parameters else: if isinstance(tree_item, queue_item.GphlWorkflowQueueItem): if tree_item.get_model().is_executed(): self.setDisabled(True) else: self.setDisabled(False) if wf_model.get_path_template(): self._path_template = wf_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.DataCollectionGroupQueueItem): self.setDisabled(True) self._processing_widget.update_data_model(self._processing_parameters) def init_models(self): CreateTaskBase.init_models(self) self._init_models() def _init_models(self): self._processing_parameters = queue_model_objects.ProcessingParameters( ) self._processing_parameters.num_residues = 0 self._processing_parameters.process_data = False # self.workflow_selected(self._workflow_cbox.currentText()) def continue_button_click(self, sample_items, checked_items): """Intercepts the datacollection continue_button click for parameter setting""" tree_brick = self._tree_brick if tree_brick: for item in checked_items: model = item.get_model() if isinstance(model, queue_model_objects.GphlWorkflow): dialog = tree_brick.dc_tree_widget.confirm_dialog ss = dialog.conf_dialog_layout.take_snapshots_combo.currentText( ) model.set_snapshot_count(int(ss) if ss else 0) # 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 = [] path_template = self._create_path_template(sample, self._path_template) path_template.num_files = 0 ho = self._workflow_hwobj if ho.get_state() == States.OFF: # We will be setting up the connection now - time to connect to quit QtGui.QApplication.instance().aboutToQuit.connect(ho.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(self._workflow_hwobj) wf_type = str(self._workflow_cbox.currentText()) wf.set_type(wf_type) interleave_order = ho.get_available_workflows()[wf_type].get( 'interleaveOrder', '') wf.set_interleave_order(interleave_order) if self.current_prefix: path_template.base_prefix = self.current_prefix wf.path_template = path_template wf.processing_parameters = self._processing_parameters wf.set_name(wf.path_template.get_prefix()) wf.set_number(wf.path_template.run_number) expected_resolution = self._gphl_acq_param_widget.get_parameter_value( 'expected_resolution') wf.set_expected_resolution(expected_resolution) dd = self._gphl_acq_param_widget.get_energy_dict() wf.set_beam_energies(dd) tasks.append(wf) return tasks
def __init__(self, parent=None, name="parameter_widget"): QtGui.QWidget.__init__(self, parent) if name is not None: self.setObjectName(name) # Properties ---------------------------------------------------------- # Signals ------------------------------------------------------------ # Slots --------------------------------------------------------------- # Hardware objects ---------------------------------------------------- self._beamline_setup_hwobj = None # Internal variables -------------------------------------------------- self._data_collection = None self.add_dc_cb = None self._tree_view_item = None # Graphic elements ---------------------------------------------------- _dc_parameters_widget = QtGui.QWidget(self) self.caution_pixmap = Qt4_Icons.load("Caution2.png") self.path_widget = DataPathWidget(_dc_parameters_widget) self.acq_widget = AcquisitionWidget(_dc_parameters_widget, layout='horizontal') #self.acq_widget.setFixedHeight(170) self.processing_widget = ProcessingWidget(_dc_parameters_widget) self.position_widget = uic.loadUi( os.path.join(os.path.dirname(__file__), 'ui_files/Qt4_snapshot_widget_layout.ui')) #self.position_widget.setMinimumSize(310, 210) # Layout -------------------------------------------------------------- _dc_parameters_widget_layout = QtGui.QVBoxLayout(self) _dc_parameters_widget_layout.addWidget(self.path_widget) _dc_parameters_widget_layout.addWidget(self.acq_widget) _dc_parameters_widget_layout.addWidget(self.processing_widget) _dc_parameters_widget_layout.setSpacing(2) _dc_parameters_widget_layout.addStretch(0) _dc_parameters_widget_layout.setContentsMargins(0, 0, 0, 0) _dc_parameters_widget.setLayout(_dc_parameters_widget_layout) _main_hlayout = QtGui.QHBoxLayout(self) _main_hlayout.addWidget(_dc_parameters_widget) _main_hlayout.addWidget(self.position_widget) _main_hlayout.setSpacing(2) _main_hlayout.setContentsMargins(0, 0, 0, 0) _main_hlayout.addStretch(0) self.setLayout(_main_hlayout) # SizePolicies -------------------------------------------------------- # Qt signal/slot connections ------------------------------------------ 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.connect(self.acq_widget, QtCore.SIGNAL('mad_energy_selected'), self.mad_energy_selected) self.connect(self.acq_widget, QtCore.SIGNAL("path_template_changed"), self.handle_path_conflict) #QtCore.QObject.connect(QtGui.QApplication, QtCore.SIGNAL('tab_changed'), # self.tab_changed) # Other --------------------------------------------------------------- Qt4_widget_colors.set_widget_color(self.path_widget, Qt4_widget_colors.GROUP_BOX_GRAY) Qt4_widget_colors.set_widget_color(self.acq_widget, Qt4_widget_colors.GROUP_BOX_GRAY) Qt4_widget_colors.set_widget_color(self.processing_widget, Qt4_widget_colors.GROUP_BOX_GRAY) Qt4_widget_colors.set_widget_color(self.position_widget, Qt4_widget_colors.GROUP_BOX_GRAY)
class DCParametersWidget(QtGui.QWidget): def __init__(self, parent=None, name="parameter_widget"): QtGui.QWidget.__init__(self, parent) if name is not None: self.setObjectName(name) # Properties ---------------------------------------------------------- # Signals ------------------------------------------------------------ # Slots --------------------------------------------------------------- # Hardware objects ---------------------------------------------------- self._beamline_setup_hwobj = None # Internal variables -------------------------------------------------- self._data_collection = None self.add_dc_cb = None self._tree_view_item = None # Graphic elements ---------------------------------------------------- _dc_parameters_widget = QtGui.QWidget(self) self.caution_pixmap = Qt4_Icons.load("Caution2.png") self.path_widget = DataPathWidget(_dc_parameters_widget) self.acq_widget = AcquisitionWidget(_dc_parameters_widget, layout='horizontal') #self.acq_widget.setFixedHeight(170) self.processing_widget = ProcessingWidget(_dc_parameters_widget) self.position_widget = uic.loadUi( os.path.join(os.path.dirname(__file__), 'ui_files/Qt4_snapshot_widget_layout.ui')) #self.position_widget.setMinimumSize(310, 210) # Layout -------------------------------------------------------------- _dc_parameters_widget_layout = QtGui.QVBoxLayout(self) _dc_parameters_widget_layout.addWidget(self.path_widget) _dc_parameters_widget_layout.addWidget(self.acq_widget) _dc_parameters_widget_layout.addWidget(self.processing_widget) _dc_parameters_widget_layout.setSpacing(2) _dc_parameters_widget_layout.addStretch(0) _dc_parameters_widget_layout.setContentsMargins(0, 0, 0, 0) _dc_parameters_widget.setLayout(_dc_parameters_widget_layout) _main_hlayout = QtGui.QHBoxLayout(self) _main_hlayout.addWidget(_dc_parameters_widget) _main_hlayout.addWidget(self.position_widget) _main_hlayout.setSpacing(2) _main_hlayout.setContentsMargins(0, 0, 0, 0) _main_hlayout.addStretch(0) self.setLayout(_main_hlayout) # SizePolicies -------------------------------------------------------- # Qt signal/slot connections ------------------------------------------ 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.connect(self.acq_widget, QtCore.SIGNAL('mad_energy_selected'), self.mad_energy_selected) self.connect(self.acq_widget, QtCore.SIGNAL("path_template_changed"), self.handle_path_conflict) #QtCore.QObject.connect(QtGui.QApplication, QtCore.SIGNAL('tab_changed'), # self.tab_changed) # Other --------------------------------------------------------------- Qt4_widget_colors.set_widget_color(self.path_widget, Qt4_widget_colors.GROUP_BOX_GRAY) Qt4_widget_colors.set_widget_color(self.acq_widget, Qt4_widget_colors.GROUP_BOX_GRAY) Qt4_widget_colors.set_widget_color(self.processing_widget, Qt4_widget_colors.GROUP_BOX_GRAY) Qt4_widget_colors.set_widget_color(self.position_widget, Qt4_widget_colors.GROUP_BOX_GRAY) def set_beamline_setup(self, bl_setup): self.acq_widget.set_beamline_setup(bl_setup) self._beamline_setup_hwobj = bl_setup def _prefix_ledit_change(self, new_value): prefix = self._data_collection.acquisitions[0].\ path_template.get_prefix() self._data_collection.set_name(prefix) self._tree_view_item.setText(0, self._data_collection.get_name()) def _run_number_ledit_change(self, new_value): if str(new_value).isdigit(): self._data_collection.set_number(int(new_value)) self._tree_view_item.setText(0, self._data_collection.get_name()) def handle_path_conflict(self, widget, new_value): if self._tree_view_item is None: #TODO fix this return dc_tree_widget = self._tree_view_item.listView().parent() dc_tree_widget.check_for_path_collisions() path_template = self._data_collection.acquisitions[0].path_template path_conflict = self.queue_model_hwobj.\ check_for_path_collisions(path_template) if new_value != '': if path_conflict: logging.getLogger("user_level_log").\ error('The current path settings will overwrite data' +\ ' from another task. Correct the problem before collecting') widget.setPaletteBackgroundColor(widget_colors.LIGHT_RED) else: widget.setPaletteBackgroundColor(widget_colors.WHITE) def __add_data_collection(self): return self.add_dc_cb(self._data_collection, self.collection_type) def mad_energy_selected(self, name, energy, state): path_template = self._data_collection.acquisitions[0].path_template if state: path_template.mad_prefix = name else: path_template.mad_prefix = '' run_number = self._beamline_setup_hwobj.queue_model_hwobj.\ get_next_run_number(path_template) self.path_widget.set_run_number(run_number) self.path_widget.set_prefix(path_template.base_prefix) model = self._tree_view_item.get_model() model.set_name(path_template.get_prefix()) self._tree_view_item.setText(0, model.get_name()) def tab_changed(self): if self._tree_view_item: self.populate_parameter_widget(self._tree_view_item) def set_enabled(self, state): self.acq_widget.setEnabled(state) self.path_widget.setEnabled(state) self.processing_widget.setEnabled(state) 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.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.acq_widget.use_osc_start(True) self.path_widget.update_data_model(data_collection.\ acquisitions[0].path_template) self.processing_widget.update_data_model(data_collection.\ processing_parameters) if data_collection.acquisitions[0].acquisition_parameters.\ centred_position.snapshot_image: image = data_collection.acquisitions[0].\ acquisition_parameters.centred_position.snapshot_image ration = image.height() / float(image.width()) image = image.scaled(400, 400 * ration, QtCore.Qt.KeepAspectRatio) self.position_widget.svideo.setPixmap(QtGui.QPixmap(image)) 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("user_level_log").\ warning(msg)
class DCParametersWidget(QtGui.QWidget): def __init__(self, parent = None, name = "parameter_widget"): QtGui.QWidget.__init__(self, parent) if name is not None: self.setObjectName(name) # Properties ---------------------------------------------------------- # Signals ------------------------------------------------------------ # Slots --------------------------------------------------------------- # Hardware objects ---------------------------------------------------- self._beamline_setup_hwobj = None # Internal variables -------------------------------------------------- self._data_collection = None self.add_dc_cb = None self._tree_view_item = None # Graphic elements ---------------------------------------------------- _dc_parameters_widget = QtGui.QWidget(self) self._data_path_widget = DataPathWidget(_dc_parameters_widget) self._acq_widget = AcquisitionWidget(_dc_parameters_widget, layout = 'horizontal') self._processing_widget = ProcessingWidget(_dc_parameters_widget) # Layout -------------------------------------------------------------- _dc_parameters_widget_layout = QtGui.QVBoxLayout(_dc_parameters_widget) _dc_parameters_widget_layout.addWidget(self._data_path_widget) _dc_parameters_widget_layout.addWidget(self._acq_widget) _dc_parameters_widget_layout.addWidget(self._processing_widget) _dc_parameters_widget_layout.setContentsMargins(0, 0, 0, 0) _dc_parameters_widget_layout.setSpacing(2) _dc_parameters_widget_layout.addStretch(10) _main_hlayout = QtGui.QHBoxLayout(self) _main_hlayout.addWidget(_dc_parameters_widget) _main_hlayout.setContentsMargins(0, 0, 0, 0) _main_hlayout.setSpacing(2) _main_hlayout.addStretch(0) # SizePolicies -------------------------------------------------------- # Qt signal/slot connections ------------------------------------------ self._data_path_widget.data_path_layout.prefix_ledit.textChanged.\ connect(self._prefix_ledit_change) self._data_path_widget.data_path_layout.run_number_ledit.textChanged.\ connect(self._run_number_ledit_change) self._acq_widget.madEnergySelectedSignal.\ connect(self.mad_energy_selected) self._acq_widget.acqParametersChangedSignal.\ connect(self.acq_parameters_changed) # Other --------------------------------------------------------------- def set_beamline_setup(self, bl_setup): self._acq_widget.set_beamline_setup(bl_setup) self._beamline_setup_hwobj = bl_setup def _prefix_ledit_change(self, new_value): prefix = self._data_collection.acquisitions[0].\ path_template.get_prefix() self._data_collection.set_name(prefix) self._tree_view_item.setText(0, self._data_collection.get_name()) def _run_number_ledit_change(self, new_value): if str(new_value).isdigit(): self._data_collection.set_number(int(new_value)) self._tree_view_item.setText(0, self._data_collection.get_name()) def acq_parameters_changed(self): if self._tree_view_item is None: #TODO fix this return dc_tree_widget = self._tree_view_item.listView().parent() dc_tree_widget.check_for_path_collisions() path_template = self._data_collection.acquisitions[0].path_template path_conflict = self.queue_model_hwobj.\ check_for_path_collisions(path_template) def __add_data_collection(self): return self.add_dc_cb(self._data_collection, self.collection_type) def mad_energy_selected(self, name, energy, state): path_template = self._data_collection.acquisitions[0].path_template if state: path_template.mad_prefix = name else: path_template.mad_prefix = '' run_number = self._beamline_setup_hwobj.queue_model_hwobj.\ get_next_run_number(path_template) self._data_path_widget.set_run_number(run_number) self._data_path_widget.set_prefix(path_template.base_prefix) model = self._tree_view_item.get_model() model.set_name(path_template.get_prefix()) self._tree_view_item.setText(0, model.get_name()) def tab_changed(self): if self._tree_view_item: self.populate_parameter_widget(self._tree_view_item) def set_enabled(self, state): self._acq_widget.setEnabled(state) self._data_path_widget.setEnabled(state) self._processing_widget.setEnabled(state) 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)
def __init__(self, parent = None, name = "parameter_widget"): QtGui.QWidget.__init__(self, parent) if name is not None: self.setObjectName(name) # Properties ---------------------------------------------------------- # Signals ------------------------------------------------------------- # Slots --------------------------------------------------------------- # Hardware objects ---------------------------------------------------- self._beamline_setup_hwobj = None # Internal variables -------------------------------------------------- self._data_collection = None self.add_dc_cb = None self._tree_view_item = None # Graphic elements ---------------------------------------------------- _dc_parameters_widget = QtGui.QWidget(self) self._data_path_widget = DataPathWidget(_dc_parameters_widget) self._acq_widget = AcquisitionWidget(_dc_parameters_widget, layout = 'horizontal') #self._acq_widget.setFixedHeight(170) self._processing_widget = ProcessingWidget(_dc_parameters_widget) _snapshot_widget = QtGui.QWidget(self) self.position_widget = uic.loadUi(os.path.join(os.path.dirname(__file__), 'ui_files/Qt4_snapshot_widget_layout.ui')) # LNLS self.position_widget.setFixedSize(450, 340) # Layout -------------------------------------------------------------- _dc_parameters_widget_layout = QtGui.QVBoxLayout(_dc_parameters_widget) _dc_parameters_widget_layout.addWidget(self._data_path_widget) _dc_parameters_widget_layout.addWidget(self._acq_widget) _dc_parameters_widget_layout.addWidget(self._processing_widget) _dc_parameters_widget_layout.setContentsMargins(0, 0, 0, 0) _dc_parameters_widget_layout.setSpacing(2) _dc_parameters_widget_layout.addStretch(0) _snapshots_vlayout = QtGui.QVBoxLayout(_snapshot_widget) _snapshots_vlayout.addWidget(self.position_widget) _snapshots_vlayout.setContentsMargins(0, 0, 0, 0) _snapshots_vlayout.setSpacing(2) # LNLS # _snapshots_vlayout.addStretch(10) _snapshots_vlayout.addStretch(0) _snapshot_widget.setLayout(_snapshots_vlayout) # ---- _main_hlayout = QtGui.QHBoxLayout(self) _main_hlayout.addWidget(_dc_parameters_widget) _main_hlayout.addWidget(_snapshot_widget) _main_hlayout.setContentsMargins(0, 0, 0, 0) _main_hlayout.setSpacing(2) _main_hlayout.addStretch(0) # SizePolicies -------------------------------------------------------- # Qt signal/slot connections ------------------------------------------ self._data_path_widget.data_path_layout.prefix_ledit.textChanged.connect( self._prefix_ledit_change) self._data_path_widget.data_path_layout.run_number_ledit.textChanged.connect( self._run_number_ledit_change) self._acq_widget.madEnergySelectedSignal.connect(self.mad_energy_selected) self._acq_widget.acqParametersChangedSignal.connect(\ self.acq_parameters_changed)
def __init__(self, parent=None, name="parameter_widget"): QtGui.QWidget.__init__(self, parent) if name is not None: self.setObjectName(name) # Properties ---------------------------------------------------------- # Signals ------------------------------------------------------------- # Slots --------------------------------------------------------------- # Hardware objects ---------------------------------------------------- self._beamline_setup_hwobj = None # Internal variables -------------------------------------------------- self._data_collection = None self.add_dc_cb = None self._tree_view_item = None # Graphic elements ---------------------------------------------------- _dc_parameters_widget = QtGui.QWidget(self) self._data_path_widget = DataPathWidget(_dc_parameters_widget) self._acq_widget = AcquisitionWidget(_dc_parameters_widget, layout='horizontal') #self._acq_widget.setFixedHeight(170) self._processing_widget = ProcessingWidget(_dc_parameters_widget) _snapshot_widget = QtGui.QWidget(self) self.position_widget = uic.loadUi( os.path.join(os.path.dirname(__file__), 'ui_files/Qt4_snapshot_widget_layout.ui')) # LNLS self.position_widget.setFixedSize(450, 340) # Layout -------------------------------------------------------------- _dc_parameters_widget_layout = QtGui.QVBoxLayout(_dc_parameters_widget) _dc_parameters_widget_layout.addWidget(self._data_path_widget) _dc_parameters_widget_layout.addWidget(self._acq_widget) _dc_parameters_widget_layout.addWidget(self._processing_widget) _dc_parameters_widget_layout.setContentsMargins(0, 0, 0, 0) _dc_parameters_widget_layout.setSpacing(2) _dc_parameters_widget_layout.addStretch(0) _snapshots_vlayout = QtGui.QVBoxLayout(_snapshot_widget) _snapshots_vlayout.addWidget(self.position_widget) _snapshots_vlayout.setContentsMargins(0, 0, 0, 0) _snapshots_vlayout.setSpacing(2) # LNLS # _snapshots_vlayout.addStretch(10) _snapshots_vlayout.addStretch(0) _snapshot_widget.setLayout(_snapshots_vlayout) # ---- _main_hlayout = QtGui.QHBoxLayout(self) _main_hlayout.addWidget(_dc_parameters_widget) _main_hlayout.addWidget(_snapshot_widget) _main_hlayout.setContentsMargins(0, 0, 0, 0) _main_hlayout.setSpacing(2) _main_hlayout.addStretch(0) # SizePolicies -------------------------------------------------------- # Qt signal/slot connections ------------------------------------------ self._data_path_widget.data_path_layout.prefix_ledit.textChanged.connect( self._prefix_ledit_change) self._data_path_widget.data_path_layout.run_number_ledit.textChanged.connect( self._run_number_ledit_change) self._acq_widget.madEnergySelectedSignal.connect( self.mad_energy_selected) self._acq_widget.acqParametersChangedSignal.connect(\ self.acq_parameters_changed)