Пример #1
0
class Qt4_AdvancedBrick(BlissWidget):
    def __init__(self, *args):
        BlissWidget.__init__(self, *args)

        # Hardware objects ----------------------------------------------------
        self.session_hwobj = None

        # Internal values -----------------------------------------------------

        # Properties ----------------------------------------------------------
        self.addProperty("session", "string", "/session")
        self.addProperty("beamline_setup", "string", "/Qt4_beamline-setup")

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

        # Slots ---------------------------------------------------------------
        self.defineSlot("populate_advanced_widget", ({}))

        # Graphic elements ----------------------------------------------------
        self.stacked_widget = QtGui.QStackedWidget(self)
        self.parameters_widget = AdvancedParametersWidget(self)
        self.results_widget = AdvancedResultsWidget(self)
        self.toggle_page_button = QtGui.QPushButton('View Results', self)
        self.toggle_page_button.setFixedWidth(120)
        self.stacked_widget.addWidget(self.parameters_widget)
        self.stacked_widget.addWidget(self.results_widget)

        # Layout --------------------------------------------------------------
        _main_vlayout = QtGui.QVBoxLayout(self)
        _main_vlayout.addWidget(self.stacked_widget)
        _main_vlayout.addStretch(0)
        _main_vlayout.addWidget(self.toggle_page_button)

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

        # Qt signal/slot connections ------------------------------------------
        self.toggle_page_button.clicked.connect(self.toggle_page)

        # Other ---------------------------------------------------------------
        self.stacked_widget.setCurrentWidget(self.parameters_widget)

        self.toggle_page_button.setEnabled(True)

    def populate_advanced_widget(self, item):
        self.parameters_widget._data_path_widget._base_image_dir = \
            self.session_hwobj.get_base_image_directory()
        self.parameters_widget._data_path_widget._base_process_dir = \
            self.session_hwobj.get_base_process_directory()

        self.parameters_widget.populate_widget(item)
        self.results_widget.populate_widget(item)

        data_collection = item.get_model()
        executed = data_collection.is_executed()

        if executed:
            self.stacked_widget.setCurrentWidget(self.results_widget)
            self.toggle_page_button.setText("View parameters")

    def propertyChanged(self, property_name, old_value, new_value):
        """
        Overriding BaseComponents.BlissWidget (propertyChanged object) 
        run method.
        """
        if property_name == 'session':
            self.session_hwobj = self.getHardwareObject(new_value)
        elif property_name == 'beamline_setup':
            bl_setup = self.getHardwareObject(new_value)
            self.parameters_widget.set_beamline_setup(bl_setup)
            self.results_widget.set_beamline_setup(bl_setup)

    def toggle_page(self):
        if self.stacked_widget.currentWidget() is self.parameters_widget:
            self.stacked_widget.setCurrentWidget(self.results_widget)
            self.toggle_page_button.setText("View parameters")
        else:
            self.stacked_widget.setCurrentWidget(self.parameters_widget)
            self.toggle_page_button.setText("View Results")
Пример #2
0
class Qt4_DCParametersBrick(BlissWidget):
    """
    Descript. :
    """
    def __init__(self, *args):
        """
        Descript. :
        """
        BlissWidget.__init__(self, *args)

        # Hardware objects ----------------------------------------------------
        self.beamline_setup_hwobj = None
        self.queue_model_hwobj = None
        self.session_hwobj = None

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

        # Properties ----------------------------------------------------------
        self.addProperty("queue-model", "string", "/queue-model")
        self.addProperty("beamline_setup", "string", "/beamline-setup")
        self.addProperty("useImageTracking", "boolean", True)

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

        # Slots ---------------------------------------------------------------
        self.defineSlot("populate_dc_parameter_widget", ({}))

        # Graphic elements ----------------------------------------------------
        self.tool_box = QtGui.QToolBox(self)
        self.parameters_widget = DCParametersWidget(self, "parameters_widget")
        self.results_static_view = QtGui.QTextBrowser(self.tool_box)
        self.image_tracking_widget = ImageTrackingWidget(self.tool_box)
        self.advance_results_widget = AdvancedResultsWidget(self.tool_box)
        self.snapshot_widget = SnapshotWidget(self)

        self.tool_box.addItem(self.parameters_widget, "Parameters")
        self.tool_box.addItem(self.image_tracking_widget,
                              "Results - ADXV control")
        self.tool_box.addItem(self.results_static_view, "Results")
        self.tool_box.addItem(self.advance_results_widget,
                              "Results - Heat map")

        # Layout --------------------------------------------------------------
        _main_vlayout = QtGui.QHBoxLayout(self)
        _main_vlayout.addWidget(self.tool_box)
        _main_vlayout.addWidget(self.snapshot_widget)

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

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

        # Other ---------------------------------------------------------------

    def populate_dc_parameter_widget(self, item):
        """
        Descript. :
        """
        self.parameters_widget._data_path_widget._base_image_dir = \
            self.session_hwobj.get_base_image_directory()
        self.parameters_widget._data_path_widget._base_process_dir = \
            self.session_hwobj.get_base_process_directory()

        data_collection = item.get_model()

        if data_collection.is_helical():
            self.advance_results_widget.show()
        else:
            self.advance_results_widget.hide()


        self.snapshot_widget.display_snapshot(data_collection.\
             acquisitions[0].acquisition_parameters.\
             centred_position.snapshot_image,
             width=800)

        if data_collection.is_collected():
            self.parameters_widget.setEnabled(False)
            self.results_static_view.reload()
            self.image_tracking_widget.set_data_collection(data_collection)
            self.image_tracking_widget.refresh()
        else:
            self.parameters_widget.setEnabled(True)
        self.parameters_widget.populate_widget(item)
        #TODO
        #self.advance_results_widget.populate_widget(item)
        self.advance_results_widget.heat_map_widget.clean_result()
        self.advance_results_widget.heat_map_widget.\
             set_associated_data_collection(data_collection)
        self.advance_results_widget.heat_map_widget._summary_gbox.hide()

    def populate_results(self, data_collection):
        """
        Descript. :
        """
        if data_collection.html_report[-4:] == 'html':
            if self.results_static_view.mimeSourceFactory().\
                   data(data_collection.html_report) == None:
                self.results_static_view.setText(\
                     html_template.html_report(data_collection))
            else:
                self.results_static_view.setSource(data_collection.html_report)
        else:
            self.results_static_view.setText(\
                 html_template.html_report(data_collection))

    def propertyChanged(self, property_name, old_value, new_value):
        """
        Descript. :
        """
        if property_name == 'beamline_setup':
            self.beamline_setup_hwobj = self.getHardwareObject(new_value)
            self.session_hwobj = self.beamline_setup_hwobj.session_hwobj
            self.parameters_widget.set_beamline_setup(
                self.beamline_setup_hwobj)
            self.advance_results_widget.set_beamline_setup(
                self.beamline_setup_hwobj)
            if hasattr(self.beamline_setup_hwobj, "image_tracking_hwobj"):
                self.image_tracking_widget.set_image_tracking_hwobj(\
                     self.beamline_setup_hwobj.image_tracking_hwobj)
        elif property_name == 'queue-model':
            self.parameters_widget.queue_model_hwobj = \
                 self.getHardwareObject(new_value)
        elif property_name == 'useImageTracking':
            if new_value:
                self.tool_box.removeItem(self.tool_box.indexOf(\
                     self.results_static_view))
                self.results_static_view.hide()
            else:
                self.tool_box.removeItem(self.tool_box.indexOf(\
                     self.image_tracking_widget))
                self.image_tracking_widget.hide()
Пример #3
0
class Qt4_AdvancedBrick(BlissWidget):

    def __init__(self, *args):
        BlissWidget.__init__(self, *args)

        # Hardware objects ----------------------------------------------------
        self.session_hwobj = None

        # Internal values -----------------------------------------------------

        # Properties ----------------------------------------------------------
        self.addProperty("beamline_setup", "string", "/beamline-setup")

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

        # Slots ---------------------------------------------------------------
        self.defineSlot("populate_advanced_widget", ({}))

        # Graphic elements ----------------------------------------------------
        self.tool_box = QToolBox(self)
        self.parameters_widget = AdvancedParametersWidget(self) 
        self.results_widget = AdvancedResultsWidget(self)
        self.snapshot_widget = SnapshotWidget(self)

        self.tool_box.addItem(self.parameters_widget, "Parameters")
        self.tool_box.addItem(self.results_widget, "Results - Heat map")

        # Layout --------------------------------------------------------------
        _main_vlayout = QHBoxLayout(self)
        _main_vlayout.addWidget(self.tool_box)
        _main_vlayout.addWidget(self.snapshot_widget)

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

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

        # Other ---------------------------------------------------------------

    def populate_advanced_widget(self, item):
        self.parameters_widget._data_path_widget._base_image_dir = \
            self.session_hwobj.get_base_image_directory()
        self.parameters_widget._data_path_widget._base_process_dir = \
            self.session_hwobj.get_base_process_directory()

        self.parameters_widget.populate_widget(item)
        self.results_widget.populate_widget(item)

        if isinstance(item, Qt4_queue_item.XrayCenteringQueueItem):
            data_collection = item.get_model().reference_image_collection
        else:
            data_collection = item.get_model()

        self.snapshot_widget.display_snapshot(\
             data_collection.grid.get_snapshot())

        self.tool_box.setCurrentWidget(self.results_widget)

    def propertyChanged(self, property_name, old_value, new_value):
        """
        Overriding BaseComponents.BlissWidget (propertyChanged object) 
        run method.
        """
        if property_name == 'beamline_setup':
            bl_setup = self.getHardwareObject(new_value)
            self.session_hwobj = bl_setup.session_hwobj
            self.parameters_widget.set_beamline_setup(bl_setup)
            self.results_widget.set_beamline_setup(bl_setup)
Пример #4
0
class Qt4_AdvancedBrick(BlissWidget):

    def __init__(self, *args):
        BlissWidget.__init__(self, *args)

        # Hardware objects ----------------------------------------------------
        self.session_hwobj = None

        # Internal values -----------------------------------------------------

        # Properties ----------------------------------------------------------
        self.addProperty("beamline_setup", "string", "/beamline-setup")

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

        # Slots ---------------------------------------------------------------
        self.defineSlot("populate_advanced_widget", ({}))

        # Graphic elements ----------------------------------------------------
        self.tool_box = QToolBox(self)
        self.parameters_widget = AdvancedParametersWidget(self) 
        self.results_widget = AdvancedResultsWidget(self)

        self.line_parameters_widget = AdvancedParametersWidget(self)
        self.line_results_widget = AdvancedResultsWidget(self)
        self.snapshot_widget = SnapshotWidget(self)

        self.tool_box.addItem(self.parameters_widget, "2D Heat map: Parameters")
        self.tool_box.addItem(self.results_widget, "2D Heat map: Results")
        self.tool_box.addItem(self.line_parameters_widget, "Line scan: Parameters")
        self.tool_box.addItem(self.line_results_widget, "Line scan: Results")

        # Layout --------------------------------------------------------------
        _main_vlayout = QHBoxLayout(self)
        _main_vlayout.addWidget(self.tool_box)
        _main_vlayout.addWidget(self.snapshot_widget)

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

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

        # Other ---------------------------------------------------------------
        

    def populate_advanced_widget(self, item):
        self.parameters_widget._data_path_widget._base_image_dir = \
            self.session_hwobj.get_base_image_directory()
        self.parameters_widget._data_path_widget._base_process_dir = \
            self.session_hwobj.get_base_process_directory()

        self.line_parameters_widget._data_path_widget._base_image_dir = \
            self.session_hwobj.get_base_image_directory()
        self.line_parameters_widget._data_path_widget._base_process_dir = \
            self.session_hwobj.get_base_process_directory()

        #self.parameters_widget.populate_widget(item)
        #self.results_widget.populate_widget(item)

        if isinstance(item, Qt4_queue_item.XrayCenteringQueueItem):
            data_collection = item.get_model().reference_image_collection
            self.parameters_widget.populate_widget(item, data_collection)
            self.results_widget.populate_widget(item, data_collection)   

            self.line_parameters_widget.populate_widget(item, item.get_model().line_collection)
            self.line_results_widget.populate_widget(item, item.get_model().line_collection) 
        else:
            data_collection = item.get_model()
            self.parameters_widget.populate_widget(item, data_collection)
            self.results_widget.populate_widget(item, data_collection) 

        self.line_parameters_widget.setEnabled(isinstance(item, Qt4_queue_item.XrayCenteringQueueItem))
        self.line_results_widget.setEnabled(isinstance(item, Qt4_queue_item.XrayCenteringQueueItem))

        try:
            self.snapshot_widget.display_snapshot(\
                 data_collection.grid.get_snapshot())
        except:
            pass

        self.tool_box.setCurrentWidget(self.results_widget)

    def propertyChanged(self, property_name, old_value, new_value):
        """
        Overriding BaseComponents.BlissWidget (propertyChanged object) 
        run method.
        """
        if property_name == 'beamline_setup':
            bl_setup = self.getHardwareObject(new_value)
            self.session_hwobj = bl_setup.session_hwobj
            self.parameters_widget.set_beamline_setup(bl_setup)
            self.results_widget.set_beamline_setup(bl_setup)

            self.line_parameters_widget.set_beamline_setup(bl_setup)
            self.line_results_widget.set_beamline_setup(bl_setup)
Пример #5
0
class Qt4_DCParametersBrick(BlissWidget):
    """
    Descript. :
    """
    def __init__(self, *args):
        """
        Descript. :
        """
        BlissWidget.__init__(self, *args)

        # Hardware objects ----------------------------------------------------
        self.beamline_setup_hwobj = None
        self.queue_model_hwobj = None
        self.session_hwobj = None

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

        # Properties ----------------------------------------------------------
        self.addProperty("queue-model", "string", "/queue-model")
        self.addProperty("beamline_setup", "string", "/beamline-setup")
        self.addProperty("useImageTracking", "boolean", True)

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

        # Slots ---------------------------------------------------------------
        self.defineSlot("populate_dc_parameter_widget",({}))
       
        # Graphic elements ---------------------------------------------------- 
        self.tool_box = QtGui.QToolBox(self)
        self.parameters_widget = DCParametersWidget(self, "parameters_widget")
        self.results_static_view = QtGui.QTextBrowser(self.tool_box)
        self.image_tracking_widget = ImageTrackingWidget(self.tool_box) 
        self.advance_results_widget = AdvancedResultsWidget(self.tool_box)
        self.snapshot_widget = SnapshotWidget(self)

        self.tool_box.addItem(self.parameters_widget, "Parameters")
        self.tool_box.addItem(self.image_tracking_widget, "Results - ADXV control")
        self.tool_box.addItem(self.results_static_view, "Results")
        self.tool_box.addItem(self.advance_results_widget, "Results - Heat map")

        # Layout -------------------------------------------------------------- 
        _main_vlayout = QtGui.QHBoxLayout(self)
        _main_vlayout.addWidget(self.tool_box)
        _main_vlayout.addWidget(self.snapshot_widget)

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

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

        # Other --------------------------------------------------------------- 

    def populate_dc_parameter_widget(self, item):
        """
        Descript. :
        """
        self.parameters_widget._data_path_widget._base_image_dir = \
            self.session_hwobj.get_base_image_directory()
        self.parameters_widget._data_path_widget._base_process_dir = \
            self.session_hwobj.get_base_process_directory()

        data_collection = item.get_model()

        if data_collection.is_helical():
            self.advance_results_widget.show()
        else:
            self.advance_results_widget.hide()

              
        self.snapshot_widget.display_snapshot(data_collection.\
             acquisitions[0].acquisition_parameters.\
             centred_position.snapshot_image,
             width=800) 
        
        if data_collection.is_collected():
            self.parameters_widget.setEnabled(False)
            self.results_static_view.reload()
            self.image_tracking_widget.set_data_collection(data_collection)
            self.image_tracking_widget.refresh()
        else:
            self.parameters_widget.setEnabled(True)
        self.parameters_widget.populate_widget(item)
        #TODO 
        #self.advance_results_widget.populate_widget(item)
        self.advance_results_widget.heat_map_widget.clean_result()
        self.advance_results_widget.heat_map_widget.\
             set_associated_data_collection(data_collection) 
        self.advance_results_widget.heat_map_widget._summary_gbox.hide()

    def populate_results(self, data_collection):
        """
        Descript. :
        """
        if data_collection.html_report[-4:] == 'html':
            if self.results_static_view.mimeSourceFactory().\
                   data(data_collection.html_report) == None:
                self.results_static_view.setText(\
                     html_template.html_report(data_collection))
            else:
                self.results_static_view.setSource(data_collection.html_report)
        else:
            self.results_static_view.setText(\
                 html_template.html_report(data_collection))
        
    def propertyChanged(self, property_name, old_value, new_value):
        """
        Descript. :
        """
        if property_name == 'beamline_setup':            
            self.beamline_setup_hwobj = self.getHardwareObject(new_value)
            self.session_hwobj = self.beamline_setup_hwobj.session_hwobj
            self.parameters_widget.set_beamline_setup(self.beamline_setup_hwobj)
            self.advance_results_widget.set_beamline_setup(self.beamline_setup_hwobj)
            if hasattr(self.beamline_setup_hwobj, "image_tracking_hwobj"):
                self.image_tracking_widget.set_image_tracking_hwobj(\
                     self.beamline_setup_hwobj.image_tracking_hwobj)
        elif property_name == 'queue-model':            
            self.parameters_widget.queue_model_hwobj = \
                 self.getHardwareObject(new_value)
        elif property_name == 'useImageTracking':
            if new_value:
                self.tool_box.removeItem(self.tool_box.indexOf(\
                     self.results_static_view))
                self.results_static_view.hide()
            else:
                self.tool_box.removeItem(self.tool_box.indexOf(\
                     self.image_tracking_widget))
                self.image_tracking_widget.hide()
Пример #6
0
class Qt4_ParallelProcessingPreviewBrick(BlissWidget):
    def __init__(self, *args):
        BlissWidget.__init__(self, *args)

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

        # Internal values -----------------------------------------------------

        # Properties ----------------------------------------------------------
        self.addProperty("beamline_setup", "string", "/beamline-setup")

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

        # Slots ---------------------------------------------------------------
        self.defineSlot("populate_widget", ({}))

        # Graphic elements ----------------------------------------------------
        self.mesh_results_widget = AdvancedResultsWidget(
            self, allow_adjust_size=False)
        self.line_results_widget = AdvancedResultsWidget(
            self, allow_adjust_size=False)

        # Layout --------------------------------------------------------------
        _main_vlayout = QHBoxLayout(self)
        _main_vlayout.addWidget(self.mesh_results_widget)
        _main_vlayout.addWidget(self.line_results_widget)
        _main_vlayout.setSpacing(0)
        _main_vlayout.setContentsMargins(0, 0, 0, 0)

        # SizePolicies --------------------------------------------------------
        self.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.MinimumExpanding)

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

        # Other ---------------------------------------------------------------
        self.line_results_widget.setHidden(True)
        self.mesh_results_widget.heat_map_widget._heat_map_tools_widget.setHidden(
            True)
        self.line_results_widget.heat_map_widget._heat_map_tools_widget.setHidden(
            True)
        self.mesh_results_widget.heat_map_widget._summary_gbox.setHidden(True)
        self.line_results_widget.heat_map_widget._summary_gbox.setHidden(True)

        self.mesh_results_widget.heat_map_widget.setFixedWidth(1450)
        self.line_results_widget.heat_map_widget.setFixedWidth(1450)

    def populate_widget(self, item):
        if isinstance(item, Qt4_queue_item.XrayCenteringQueueItem):
            data_collection = item.get_model().reference_image_collection
            self.parameters_widget.populate_widget(item, data_collection)
            self.results_widget.populate_widget(item, data_collection)

            self.line_parameters_widget.populate_widget(
                item,
                item.get_model().line_collection)
            self.line_results_widget.populate_widget(
                item,
                item.get_model().line_collection)
        else:
            data_collection = item.get_model()
            if data_collection.is_mesh():
                self.mesh_results_widget.setHidden(False)
                self.line_results_widget.setHidden(True)
                self.mesh_results_widget.populate_widget(item, data_collection)
            else:
                self.mesh_results_widget.setHidden(True)
                self.line_results_widget.setHidden(False)
                self.line_results_widget.populate_widget(item, data_collection)

    def propertyChanged(self, property_name, old_value, new_value):
        """
        Overriding BaseComponents.BlissWidget (propertyChanged object) 
        run method.
        """
        if property_name == 'beamline_setup':
            bl_setup = self.getHardwareObject(new_value)
            #self.session_hwobj = bl_setup.session_hwobj
            self.mesh_results_widget.set_beamline_setup(bl_setup)
            self.line_results_widget.set_beamline_setup(bl_setup)
Пример #7
0
class Qt4_AdvancedBrick(BlissWidget):

    def __init__(self, *args):
        BlissWidget.__init__(self, *args)

        # Hardware objects ----------------------------------------------------
        self.session_hwobj = None

        # Internal values -----------------------------------------------------

        # Properties ----------------------------------------------------------
        self.addProperty("session", "string", "/session")
        self.addProperty("beamline_setup", "string", "/Qt4_beamline-setup")

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

        # Slots ---------------------------------------------------------------
        self.defineSlot("populate_advanced_widget", ({}))

        # Graphic elements ----------------------------------------------------
        self.stacked_widget = QtGui.QStackedWidget(self)
        self.parameters_widget = AdvancedParametersWidget(self) 
        self.results_widget = AdvancedResultsWidget(self)
        self.toggle_page_button = QtGui.QPushButton('View Results', self)
        self.toggle_page_button.setFixedWidth(120)
        self.stacked_widget.addWidget(self.parameters_widget)
        self.stacked_widget.addWidget(self.results_widget)

        # Layout --------------------------------------------------------------
        _main_vlayout = QtGui.QVBoxLayout(self)
        _main_vlayout.addWidget(self.stacked_widget)
        _main_vlayout.addStretch(0)
        _main_vlayout.addWidget(self.toggle_page_button)

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

        # Qt signal/slot connections ------------------------------------------
        self.toggle_page_button.clicked.connect(self.toggle_page)

        # Other ---------------------------------------------------------------
        self.stacked_widget.setCurrentWidget(self.parameters_widget)

        self.toggle_page_button.setEnabled(True)

    def populate_advanced_widget(self, item):
        self.parameters_widget._data_path_widget._base_image_dir = \
            self.session_hwobj.get_base_image_directory()
        self.parameters_widget._data_path_widget._base_process_dir = \
            self.session_hwobj.get_base_process_directory()

        self.parameters_widget.populate_widget(item)
        self.results_widget.populate_widget(item)

        data_collection = item.get_model()
        executed = data_collection.is_executed()

        if executed:
            self.stacked_widget.setCurrentWidget(self.results_widget)
            self.toggle_page_button.setText("View parameters")

    def propertyChanged(self, property_name, old_value, new_value):
        """
        Overriding BaseComponents.BlissWidget (propertyChanged object) 
        run method.
        """
        if property_name == 'session':
            self.session_hwobj = self.getHardwareObject(new_value)
        elif property_name == 'beamline_setup':
            bl_setup = self.getHardwareObject(new_value)
            self.parameters_widget.set_beamline_setup(bl_setup)
            self.results_widget.set_beamline_setup(bl_setup)

    def toggle_page(self):
        if self.stacked_widget.currentWidget() is self.parameters_widget:
            self.stacked_widget.setCurrentWidget(self.results_widget)
            self.toggle_page_button.setText("View parameters")
        else:
            self.stacked_widget.setCurrentWidget(self.parameters_widget)
            self.toggle_page_button.setText("View Results")