Exemple #1
0
    def __init__(self, dev, win):
        QtGui.QWidget.__init__(self)
        self.win = win
        self.dev = dev
        self.dev.sigObjectiveChanged.connect(self.objectiveChanged)
        #self.dev.sigPositionChanged.connect(self.positionChanged)
        self.ui = Ui_Form()
        self.ui.setupUi(self)
        self.objList = self.dev._allObjectives()
        self.switchN = len(self.objList)
        self.objWidgets = {}
        self.blockSpinChange = False
        row = 1
        for i in self.objList:
            ## For each objective, create a set of widgets for selecting and updating.
            c = QtGui.QComboBox()
            r = QtGui.QRadioButton(i)
            #first = self.objList[i].keys()[0]
            #first = self.objList[i][first]
            xs = pg.SpinBox(step=1e-6, suffix='m', siPrefix=True)
            ys = pg.SpinBox(step=1e-6, suffix='m', siPrefix=True)
            zs = pg.SpinBox(step=1e-6, suffix='m', siPrefix=True)
            ss = pg.SpinBox(step=1e-7, bounds=(1e-10, None))

            xs.index = ys.index = zs.index = ss.index = i  ## used to determine which row has changed
            widgets = (r, c, xs, ys, zs, ss)
            for col, w in enumerate(widgets):
                self.ui.objectiveLayout.addWidget(w, row, col)
            self.objWidgets[i] = widgets

            for o in self.objList[i].values():
                c.addItem(o.name(), o)
                o.sigTransformChanged.connect(self.updateSpins)

            ## objectives are accessed like:
            ##   index = changedWidget.index
            ##   combo = self.objWidgets[index][1]
            ##   obj = combo.currentData()

            r.clicked.connect(self.objRadioClicked)
            c.currentIndexChanged.connect(self.objComboChanged)
            xs.sigValueChanged.connect(self.offsetSpinChanged)
            ys.sigValueChanged.connect(self.offsetSpinChanged)
            zs.sigValueChanged.connect(self.offsetSpinChanged)
            ss.sigValueChanged.connect(self.scaleSpinChanged)
            row += 1
        self.updateSpins()
Exemple #2
0
 def __init__(self, dev, win):
     QtGui.QWidget.__init__(self)
     self.win = win
     self.dev = dev
     self.dev.sigObjectiveChanged.connect(self.objectiveChanged)
     #self.dev.sigPositionChanged.connect(self.positionChanged)
     self.ui = Ui_Form()
     self.ui.setupUi(self)
     self.objList = self.dev._allObjectives()
     self.switchN = len(self.objList)
     self.objWidgets = {}
     self.blockSpinChange = False
     row = 1
     for i in self.objList:
         ## For each objective, create a set of widgets for selecting and updating.
         c = QtGui.QComboBox()
         r = QtGui.QRadioButton(i)
         #first = self.objList[i].keys()[0]
         #first = self.objList[i][first]
         xs = pg.SpinBox(step=1e-6, suffix='m', siPrefix=True)
         ys = pg.SpinBox(step=1e-6, suffix='m', siPrefix=True)
         ss = pg.SpinBox(step=1e-7, bounds=(1e-10, None))
         
         xs.index = ys.index = ss.index = i  ## used to determine which row has changed
         widgets = (r, c, xs, ys, ss)
         for col in range(5):
             self.ui.objectiveLayout.addWidget(widgets[col], row, col)
         self.objWidgets[i] = widgets
         
         for o in self.objList[i].values():
             c.addItem(o.name(), o)
             o.sigTransformChanged.connect(self.updateSpins)
         
         ## objectives are accessed like:
         ##   index = changedWidget.index
         ##   combo = self.objWidgets[index][1]
         ##   obj = combo.currentData()
             
         r.clicked.connect(self.objRadioClicked)
         c.currentIndexChanged.connect(self.objComboChanged)
         xs.sigValueChanged.connect(self.offsetSpinChanged)
         ys.sigValueChanged.connect(self.offsetSpinChanged)
         ss.sigValueChanged.connect(self.scaleSpinChanged)
         row += 1
     self.updateSpins()
Exemple #3
0
class ScopeGUI(QtGui.QWidget):
    """Microscope GUI displayed in Manager window.
    Shows selection of objectives and allows scale/offset to be changed for each."""
    def __init__(self, dev, win):
        QtGui.QWidget.__init__(self)
        self.win = win
        self.dev = dev
        self.dev.sigObjectiveChanged.connect(self.objectiveChanged)
        #self.dev.sigPositionChanged.connect(self.positionChanged)
        self.ui = Ui_Form()
        self.ui.setupUi(self)
        self.objList = self.dev._allObjectives()
        self.switchN = len(self.objList)
        self.objWidgets = {}
        self.blockSpinChange = False
        row = 1
        for i in self.objList:
            ## For each objective, create a set of widgets for selecting and updating.
            c = QtGui.QComboBox()
            r = QtGui.QRadioButton(i)
            #first = self.objList[i].keys()[0]
            #first = self.objList[i][first]
            xs = pg.SpinBox(step=1e-6, suffix='m', siPrefix=True)
            ys = pg.SpinBox(step=1e-6, suffix='m', siPrefix=True)
            zs = pg.SpinBox(step=1e-6, suffix='m', siPrefix=True)
            ss = pg.SpinBox(step=1e-7, bounds=(1e-10, None))

            xs.index = ys.index = zs.index = ss.index = i  ## used to determine which row has changed
            widgets = (r, c, xs, ys, zs, ss)
            for col, w in enumerate(widgets):
                self.ui.objectiveLayout.addWidget(w, row, col)
            self.objWidgets[i] = widgets

            for o in self.objList[i].values():
                c.addItem(o.name(), o)
                o.sigTransformChanged.connect(self.updateSpins)

            ## objectives are accessed like:
            ##   index = changedWidget.index
            ##   combo = self.objWidgets[index][1]
            ##   obj = combo.currentData()

            r.clicked.connect(self.objRadioClicked)
            c.currentIndexChanged.connect(self.objComboChanged)
            xs.sigValueChanged.connect(self.offsetSpinChanged)
            ys.sigValueChanged.connect(self.offsetSpinChanged)
            zs.sigValueChanged.connect(self.offsetSpinChanged)
            ss.sigValueChanged.connect(self.scaleSpinChanged)
            row += 1
        self.updateSpins()

    def objectiveChanged(self, obj):
        ## Microscope says new objective has been selected; update selection radio
        (obj, old) = obj
        index = obj.key()[0]
        self.objWidgets[index][0].setChecked(True)

    def objRadioClicked(self):
        checked = None
        for r in self.objList:
            if self.objWidgets[r][0].isChecked():
                checked = r
                break
        self.dev.setObjectiveIndex(r)

    def objComboChanged(self):
        combo = self.sender()
        self.dev.selectObjective(combo.itemData(combo.currentIndex()))
        self.blockSpinChange = True
        try:
            self.updateSpins()
        finally:
            self.blockSpinChange = False

    def offsetSpinChanged(self, spin):
        if self.blockSpinChange:
            return
        index = spin.index
        (r, combo, xs, ys, zs, ss) = self.objWidgets[index]
        obj = combo.itemData(combo.currentIndex())
        obj.sigTransformChanged.disconnect(self.updateSpins)
        try:
            obj.setOffset((xs.value(), ys.value(), zs.value()))
        finally:
            obj.sigTransformChanged.connect(self.updateSpins)

    def scaleSpinChanged(self, spin):
        if self.blockSpinChange:
            return
        index = spin.index
        (r, combo, xs, ys, zs, ss) = self.objWidgets[index]
        obj = combo.itemData(combo.currentIndex())
        obj.sigTransformChanged.disconnect(self.updateSpins)
        try:
            obj.setScale(ss.value())
        finally:
            obj.sigTransformChanged.connect(self.updateSpins)

    def updateSpins(self):
        for k, w in self.objWidgets.iteritems():
            (r, combo, xs, ys, zs, ss) = w
            obj = combo.itemData(combo.currentIndex())
            offset = obj.offset()
            xs.setValue(offset.x())
            ys.setValue(offset.y())
            zs.setValue(offset.z())
            ss.setValue(obj.scale().x())
Exemple #4
0
class ScopeGUI(QtGui.QWidget):
    """Microscope GUI displayed in Manager window.
    Shows selection of objectives and allows scale/offset to be changed for each."""
    
    def __init__(self, dev, win):
        QtGui.QWidget.__init__(self)
        self.win = win
        self.dev = dev
        self.dev.sigObjectiveChanged.connect(self.objectiveChanged)
        #self.dev.sigPositionChanged.connect(self.positionChanged)
        self.ui = Ui_Form()
        self.ui.setupUi(self)
        self.objList = self.dev._allObjectives()
        self.switchN = len(self.objList)
        self.objWidgets = {}
        self.blockSpinChange = False
        row = 1
        for i in self.objList:
            ## For each objective, create a set of widgets for selecting and updating.
            c = QtGui.QComboBox()
            r = QtGui.QRadioButton(i)
            #first = self.objList[i].keys()[0]
            #first = self.objList[i][first]
            xs = pg.SpinBox(step=1e-6, suffix='m', siPrefix=True)
            ys = pg.SpinBox(step=1e-6, suffix='m', siPrefix=True)
            ss = pg.SpinBox(step=1e-7, bounds=(1e-10, None))
            
            xs.index = ys.index = ss.index = i  ## used to determine which row has changed
            widgets = (r, c, xs, ys, ss)
            for col in range(5):
                self.ui.objectiveLayout.addWidget(widgets[col], row, col)
            self.objWidgets[i] = widgets
            
            for o in self.objList[i].values():
                c.addItem(o.name(), o)
                o.sigTransformChanged.connect(self.updateSpins)
            
            ## objectives are accessed like:
            ##   index = changedWidget.index
            ##   combo = self.objWidgets[index][1]
            ##   obj = combo.currentData()
                
            r.clicked.connect(self.objRadioClicked)
            c.currentIndexChanged.connect(self.objComboChanged)
            xs.sigValueChanged.connect(self.offsetSpinChanged)
            ys.sigValueChanged.connect(self.offsetSpinChanged)
            ss.sigValueChanged.connect(self.scaleSpinChanged)
            row += 1
        self.updateSpins()
    
    def objectiveChanged(self, obj):
        ## Microscope says new objective has been selected; update selection radio
        (obj, old) = obj
        index = obj.key()[0]
        self.objWidgets[index][0].setChecked(True)
    
    def objRadioClicked(self):
        checked = None
        for r in self.objList:
            if self.objWidgets[r][0].isChecked():
                checked = r
                break
        self.dev.setObjectiveIndex(r)
    
    def objComboChanged(self):
        combo = self.sender()
        self.dev.selectObjective(combo.itemData(combo.currentIndex()))
        self.blockSpinChange = True
        try:
            self.updateSpins()
        finally:
            self.blockSpinChange = False
    
    def offsetSpinChanged(self, spin):
        if self.blockSpinChange:
            return
        index = spin.index
        (r, combo, xs, ys, ss) = self.objWidgets[index]
        obj = combo.itemData(combo.currentIndex())
        obj.sigTransformChanged.disconnect(self.updateSpins)
        try:
            obj.setOffset((xs.value(), ys.value()))
        finally:
            obj.sigTransformChanged.connect(self.updateSpins)
    
    def scaleSpinChanged(self, spin):
        if self.blockSpinChange:
            return
        index = spin.index
        (r, combo, xs, ys, ss) = self.objWidgets[index]
        obj = combo.itemData(combo.currentIndex())
        obj.sigTransformChanged.disconnect(self.updateSpins)
        try:
            obj.setScale(ss.value())
        finally:
            obj.sigTransformChanged.connect(self.updateSpins)
        
    def updateSpins(self):
        for k, w in self.objWidgets.iteritems():
            (r, combo, xs, ys, ss) = w
            obj = combo.itemData(combo.currentIndex())
            offset = obj.offset()
            xs.setValue(offset.x())
            ys.setValue(offset.y())
            ss.setValue(obj.scale().x())