Exemplo n.º 1
0
    def _create_task(self, sample, shape):
        data_collections = []

        if self.count_time is not None:
            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 = copy.deepcopy(shape.get_centred_positions()[0])
                    cpos.snapshot_image = snapshot

            path_template = self._create_path_template(sample,
                                                       self._path_template)
            xrf_scan = queue_model_objects.XRFScan(sample, path_template, cpos)
            xrf_scan.set_name(path_template.get_prefix())
            xrf_scan.set_number(path_template.run_number)
            xrf_scan.count_time = self.count_time
            data_collections.append(xrf_scan)

            self._path_template.run_number += 1
        else:
            logging.getLogger("user_level_log").\
                info("Incorrect count time value")

        return data_collections
Exemplo n.º 2
0
    def _create_task(self, sample, shape):
        data_collections = []

        if self.count_time is not None:
            if not shape:
                cpos = queue_model_objects.CentredPosition()
                cpos.snapshot_image = self._graphics_manager_hwobj.get_snapshot(
                )
            else:
                # Shapes selected and sample is mounted, get the
                # centred positions for the shapes
                if isinstance(shape, Qt4_GraphicsManager.GraphicsItemPoint):
                    snapshot = self._graphics_manager_hwobj.get_snapshot(shape)

                    cpos = copy.deepcopy(shape.get_centred_positions()[0])
                    cpos.snapshot_image = snapshot

            path_template = self._create_path_template(sample,
                                                       self._path_template)

            xrf_scan = queue_model_objects.XRFScan(sample, path_template, cpos)
            xrf_scan.set_name(path_template.get_prefix())
            xrf_scan.set_number(path_template.run_number)
            xrf_scan.count_time = self.count_time

            data_collections.append(xrf_scan)
        else:
            logging.getLogger("user_level_log").\
                info("No count time specified.")

        return data_collections
Exemplo n.º 3
0
    def __init__(self, parent=None, name=None, fl=0):
        CreateTaskBase.__init__(self, parent, name, fl, 'XRF-scan')

        self.count_time = None

        # Data attributes
        self.init_models()
        xrfscan_model = queue_model_objects.XRFScan()
        self.xrfscan_mib = DataModelInputBinder(xrfscan_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.xrfscan_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)
Exemplo n.º 4
0
 def init_models(self):
     CreateTaskBase.init_models(self)
     self.enery_scan = queue_model_objects.XRFScan()
     self._path_template.start_num = 1
     self._path_template.num_files = 1
     self._path_template.suffix = 'raw'
Exemplo n.º 5
0
    def __init__(self, parent=None, name="xrf_scan_tab_widget"):
        qt.QWidget.__init__(self, parent, name)

        # Data Attributes
        self.xrf_scan_hwobj = None
        self.xrf_scan = queue_model_objects.XRFScan()
        self._tree_view_item = None

        self.data_path_widget = DataPathWidget(self)
        #self.data_path_widget.setSizePolicy(qt.QSizePolicy.Expanding,qt.QSizePolicy.Fixed)
        self.other_parameters_gbox = qt.QHGroupBox("Other parameters", self)
        #self.other_parameters_gbox.setSizePolicy(qt.QSizePolicy.Expanding,qt.QSizePolicy.Fixed)
        self.count_time_label = qt.QLabel("Count time:",
                                          self.other_parameters_gbox)
        self.count_time_ledit = qt.QLineEdit(self.other_parameters_gbox,
                                             "count_time_ledit")
        self.count_time_ledit.setFixedWidth(50)

        spacer = qt.QWidget(self.other_parameters_gbox)
        spacer.setSizePolicy(qt.QSizePolicy.Expanding, qt.QSizePolicy.Fixed)

        widget_ui = os.path.join(os.path.dirname(__file__),
                                 'ui_files/snapshot_widget_layout.ui')
        widget = qtui.QWidgetFactory.create(widget_ui)
        widget.reparent(self, qt.QPoint(0, 0))
        self.position_widget = widget
        self.position_widget.setFixedSize(457, 350)
        #self.position_widget.setSizePolicy(qt.QSizePolicy.Fixed, qt.QSizePolicy.Fixed)

        self.mca_spectrum = McaSpectrumBrick(self)
        self.mca_spectrum.setSizePolicy(qt.QSizePolicy.Expanding,
                                        qt.QSizePolicy.Expanding)
        self.mca_spectrum.setMinimumHeight(700)

        v_layout = qt.QVBoxLayout(self)
        rone_hlayout = qt.QHBoxLayout(v_layout)
        rone_vlayout = qt.QVBoxLayout(rone_hlayout)
        rone_sv_layout = qt.QVBoxLayout(rone_hlayout)

        rone_vlayout.addWidget(self.data_path_widget)
        rone_vlayout.addWidget(self.other_parameters_gbox)
        rone_vlayout.addStretch()

        rone_sv_layout.addWidget(self.position_widget)
        rone_sv_layout.addStretch()

        v_layout.addWidget(self.mca_spectrum)
        v_layout.addStretch()

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

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

        qt.QObject.connect(self.count_time_ledit,
                           qt.SIGNAL("textChanged(const QString &)"),
                           self._count_time_ledit_change)

        qt.QObject.connect(qt.qApp, qt.PYSIGNAL('tab_changed'),
                           self.tab_changed)
Exemplo n.º 6
0
    def __init__(self, parent = None, name = "xrf_scan_tab_widget"):
        QtGui.QWidget.__init__(self, parent)

        if name is not None:
            self.setObjectName(name)

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

        # Internal variables --------------------------------------------------
        self.xrf_scan_model = queue_model_objects.XRFScan()
        self._tree_view_item = None

        # Graphic elements ----------------------------------------------------
        _top_widget = QtGui.QWidget(self)
        _parameters_widget = QtGui.QWidget(_top_widget)
        self.data_path_widget = DataPathWidget(_parameters_widget)
        self.other_parameters_gbox = QtGui.QGroupBox("Other parameters", _parameters_widget) 
        self.count_time_label = QtGui.QLabel("Count time:", 
                                             self.other_parameters_gbox)
	self.count_time_ledit = QtGui.QLineEdit(self.other_parameters_gbox)
	self.count_time_ledit.setFixedWidth(50)
        self.position_widget = uic.loadUi(os.path.join(os.path.dirname(__file__),
                                          'ui_files/Qt4_snapshot_widget_layout.ui'))
        self.mca_spectrum_widget = McaSpectrumWidget(self)
 
        # Layout -------------------------------------------------------------
        self.other_parameters_gbox_layout = QtGui.QHBoxLayout(self)
        self.other_parameters_gbox_layout.addWidget(self.count_time_label)  
        self.other_parameters_gbox_layout.addWidget(self.count_time_ledit)
        self.other_parameters_gbox_layout.addStretch(0)
        self.other_parameters_gbox_layout.setSpacing(2)
        self.other_parameters_gbox_layout.setContentsMargins(3, 3, 3, 3)
        self.other_parameters_gbox.setLayout(self.other_parameters_gbox_layout)

        _parameters_widget_layout = QtGui.QVBoxLayout()
        _parameters_widget_layout.addWidget(self.data_path_widget)
        _parameters_widget_layout.addWidget(self.other_parameters_gbox)
        _parameters_widget_layout.addStretch(0)
        _parameters_widget_layout.setSpacing(2)
        _parameters_widget_layout.setContentsMargins(0, 0, 0, 0)
        _parameters_widget.setLayout(_parameters_widget_layout)

        _top_widget_layout = QtGui.QHBoxLayout(_top_widget)
        _top_widget_layout.addWidget(_parameters_widget)
        _top_widget_layout.addWidget(self.position_widget)
        _top_widget_layout.setSpacing(2)
        _top_widget_layout.setContentsMargins(0, 0, 0, 0)
        
        _top_widget.setLayout(_top_widget_layout) 

        _main_vlayout = QtGui.QVBoxLayout(self)
        _main_vlayout.addWidget(_top_widget)
        _main_vlayout.addWidget(self.mca_spectrum_widget)
        _main_vlayout.setSpacing(2)
        _main_vlayout.setContentsMargins(0, 0, 0, 0)
        self.setLayout(_main_vlayout)
       
        # SizePolicies -------------------------------------------------------
        self.position_widget.setFixedSize(457, 350)
        self.mca_spectrum_widget.setSizePolicy(QtGui.QSizePolicy.Expanding,
                                               QtGui.QSizePolicy.Expanding)
        _top_widget.setSizePolicy(QtGui.QSizePolicy.Expanding,
                                  QtGui.QSizePolicy.Fixed)
        #self.mca_spectrum_widget.setMinimumHeight(800)
        #self.setSizePolicy(QtGui.QSizePolicy.Expanding,
        #                   QtGui.QSizePolicy.Fixed)

        # 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.count_time_ledit.textChanged.connect(self._count_time_ledit_change)
        
        #QtCore.QObject.connect(.qApp, qt.PYSIGNAL('tab_changed'),
        #                   self.tab_changed)

        # Other ---------------------------------------------------------------
        Qt4_widget_colors.set_widget_color(self.other_parameters_gbox,
                                           Qt4_widget_colors.GROUP_BOX_GRAY)
        Qt4_widget_colors.set_widget_color(self.data_path_widget,
                                           Qt4_widget_colors.GROUP_BOX_GRAY) 
        Qt4_widget_colors.set_widget_color(self.position_widget, 
                                           Qt4_widget_colors.GROUP_BOX_GRAY)