def __init__(self, parent=None, stack=False, actions=True):
        qt.QWidget.__init__(self, parent)
        if stack in [None, False]:
            file_browser = False
        else:
            file_browser = True
        self.mainLayout = qt.QVBoxLayout(self)
        self.mainLayout.setMargin(2)
        self.mainLayout.setSpacing(2)

        self.parametersWidget = SimpleFitBatchParameters(self)
        self.getParameters = self.parametersWidget.getParameters
        self.mainLayout.addWidget(self.parametersWidget)
        if actions:
            self.actionsBox = qt.QWidget(self)
            self.actionsBox.mainLayout = qt.QHBoxLayout(self.actionsBox)
            self.actionsBox.mainLayout.setMargin(2)
            self.actionsBox.mainLayout.setSpacing(2)
            self.closeButton = qt.QPushButton(self.actionsBox)
            self.closeButton.setText("Close")
            self.startButton = qt.QPushButton(self.actionsBox)
            self.startButton.setText("Start")
            self.actionsBox.mainLayout.addWidget(
                qt.HorizontalSpacer(self.actionsBox))
            self.actionsBox.mainLayout.addWidget(self.closeButton)
            self.actionsBox.mainLayout.addWidget(
                qt.HorizontalSpacer(self.actionsBox))
            self.actionsBox.mainLayout.addWidget(self.startButton)
            self.actionsBox.mainLayout.addWidget(
                qt.HorizontalSpacer(self.actionsBox))
            self.mainLayout.addWidget(self.actionsBox)
            self.connect(self.closeButton, qt.SIGNAL('clicked()'), self.close)
Exemple #2
0
 def __buildActions(self):
     box = qt.QWidget(self)
     boxLayout = qt.QHBoxLayout(box)
     boxLayout.addWidget(qt.HorizontalSpacer(box))
     self.__dismissButton = qt.QPushButton(box)
     boxLayout.addWidget(self.__dismissButton)
     boxLayout.addWidget(qt.HorizontalSpacer(box))
     self.__dismissButton.setText("Close")
     self.__startButton = qt.QPushButton(box)
     boxLayout.addWidget(self.__startButton)
     boxLayout.addWidget(qt.HorizontalSpacer(box))
     self.__startButton.setText("Start")
     self.mainLayout.addWidget(box)
     self.connect(self.__dismissButton, qt.SIGNAL("clicked()"), self.close)
     self.connect(self.__startButton, qt.SIGNAL("clicked()"), self.start)
Exemple #3
0
 def addButtons(self):
     self.actions = 1
     self.buttonsBox = qt.QWidget(self)
     l = qt.QHBoxLayout(self.buttonsBox)
     l.addWidget(qt.HorizontalSpacer(self.buttonsBox))
     self.pauseButton = qt.QPushButton(self.buttonsBox)
     l.addWidget(self.pauseButton)
     l.addWidget(qt.HorizontalSpacer(self.buttonsBox))
     self.pauseButton.setText("Pause")
     self.abortButton = qt.QPushButton(self.buttonsBox)
     l.addWidget(self.abortButton)
     l.addWidget(qt.HorizontalSpacer(self.buttonsBox))
     self.abortButton.setText("Abort")
     self.l.addWidget(self.buttonsBox)
     self.update()
 def __init__(self, parent=None):
     qt.QDialog.__init__(self, parent)
     self.setWindowTitle("Strip and SNIP Configuration Window")
     self.mainLayout = qt.QVBoxLayout(self)
     self.mainLayout.setMargin(0)
     self.mainLayout.setSpacing(2)
     self.parametersWidget = StripBackgroundWidget(self)
     self.setData = self.parametersWidget.setData
     self.getParameters = self.parametersWidget.getParameters
     self.setParameters = self.parametersWidget.setParameters
     self.mainLayout.addWidget(self.parametersWidget)
     hbox = qt.QWidget(self)
     hboxLayout = qt.QHBoxLayout(hbox)
     hboxLayout.setMargin(0)
     hboxLayout.setSpacing(2)
     self.okButton = qt.QPushButton(hbox)
     self.okButton.setText("OK")
     self.okButton.setAutoDefault(False)
     self.dismissButton = qt.QPushButton(hbox)
     self.dismissButton.setText("Cancel")
     self.dismissButton.setAutoDefault(False)
     hboxLayout.addWidget(qt.HorizontalSpacer(hbox))
     hboxLayout.addWidget(self.okButton)
     hboxLayout.addWidget(self.dismissButton)
     self.mainLayout.addWidget(hbox)
     self.connect(self.dismissButton, qt.SIGNAL("clicked()"), self.reject)
     self.connect(self.okButton, qt.SIGNAL("clicked()"), self.accept)
 def __init__(self, parent, data, energy=None):
     qt.QDialog.__init__(self, parent)
     self.setWindowTitle("XAS Normalization Dialog")
     self.mainLayout = qt.QVBoxLayout(self)
     self.mainLayout.setMargin(10)
     self.mainLayout.setSpacing(2)
     self.__image = False
     if len(data.shape) == 2:
         spectrum = data.ravel()
     else:
         spectrum = data
     self.parametersWidget = XASNormalizationWindow(self,
                                                    spectrum,
                                                    energy=energy)
     self.graph = self.parametersWidget.graph
     self.setData = self.parametersWidget.setData
     self.mainLayout.addWidget(self.parametersWidget)
     hbox = qt.QWidget(self)
     hboxLayout = qt.QHBoxLayout(hbox)
     hboxLayout.setMargin(0)
     hboxLayout.setSpacing(0)
     self.okButton = qt.QPushButton(hbox)
     self.okButton.setText("OK")
     self.okButton.setAutoDefault(False)
     self.dismissButton = qt.QPushButton(hbox)
     self.dismissButton.setText("Cancel")
     self.dismissButton.setAutoDefault(False)
     hboxLayout.addWidget(self.okButton)
     hboxLayout.addWidget(qt.HorizontalSpacer(hbox))
     hboxLayout.addWidget(self.dismissButton)
     self.mainLayout.addWidget(hbox)
     self.connect(self.dismissButton, qt.SIGNAL("clicked()"), self.reject)
     self.connect(self.okButton, qt.SIGNAL("clicked()"), self.accept)
Exemple #6
0
    def __init__(self, parent=None):
        qt.QWidget.__init__(self, parent)
        self.mainLayout = qt.QGridLayout(self)
        self.mainLayout.setMargin(2)
        self.mainLayout.setSpacing(2)
        font = qt.QFont(self.font())
        font.setBold(True)

        #Function handling
        self.functionLabel = qt.QLabel(self)
        self.functionLabel.setFont(font)
        self.functionLabel.setText("Function:")
        self.addFunctionButton = qt.QPushButton(self)
        self.addFunctionButton.setText("ADD")

        #fit function
        self.fitFunctionLabel = qt.QLabel(self)
        self.fitFunctionLabel.setFont(font)
        self.fitFunctionLabel.setText("Fit:")
        self.fitFunctionCombo = qt.QComboBox(self)
        self.fitFunctionCombo.addItem(qt.safe_str("None"))
        self.fitFunctionCombo.setSizeAdjustPolicy(
            qt.QComboBox.AdjustToContents)
        self.fitFunctionCombo.setMinimumWidth(100)

        #background function
        self.backgroundLabel = qt.QLabel(self)
        self.backgroundLabel.setFont(font)
        self.backgroundLabel.setText("Background:")
        self.backgroundCombo = qt.QComboBox(self)
        self.backgroundCombo.addItem(qt.safe_str("None"))
        self.backgroundCombo.setSizeAdjustPolicy(qt.QComboBox.AdjustToContents)
        self.backgroundCombo.setMinimumWidth(100)

        #arrange everything
        self.mainLayout.addWidget(self.functionLabel, 0, 0)
        self.mainLayout.addWidget(self.addFunctionButton, 0, 1)
        self.mainLayout.addWidget(qt.HorizontalSpacer(self), 0, 2)
        self.mainLayout.addWidget(self.fitFunctionLabel, 0, 3)
        self.mainLayout.addWidget(self.fitFunctionCombo, 0, 4)
        self.mainLayout.addWidget(qt.HorizontalSpacer(self), 0, 5)
        self.mainLayout.addWidget(self.backgroundLabel, 0, 6)
        self.mainLayout.addWidget(self.backgroundCombo, 0, 7)

        self.configureButton = qt.QPushButton(self)
        self.configureButton.setText("CONFIGURE")
        self.mainLayout.addWidget(self.configureButton, 0, 8)
    def __init__(self, parent=None, n=1):
        qt.QWidget.__init__(self, parent)
        self.mainLayout = qt.QHBoxLayout(self)
        self.mainLayout.setMargin(0)
        self.mainLayout.setSpacing(0)
        self.firstButton = qt.QPushButton(self)
        self.firstButton.setIcon(qt.QIcon(qt.QPixmap(icon_first)))
        self.previousButton = qt.QPushButton(self)
        self.previousButton.setIcon(qt.QIcon(qt.QPixmap(icon_previous)))
        self.lineEdit = qt.QLineEdit(self)
        self.lineEdit.setFixedWidth(self.lineEdit.fontMetrics().width('%05d' %
                                                                      n))
        validator = qt.QIntValidator(1, n, self.lineEdit)
        self.lineEdit.setText("1")
        self._oldIndex = 0
        self.lineEdit.setValidator(validator)
        self.label = qt.QLabel(self)
        self.label.setText("of %d" % n)
        self.nextButton = qt.QPushButton(self)
        self.nextButton.setIcon(qt.QIcon(qt.QPixmap(icon_next)))
        self.lastButton = qt.QPushButton(self)
        self.lastButton.setIcon(qt.QIcon(qt.QPixmap(icon_last)))

        self.mainLayout.addWidget(qt.HorizontalSpacer(self))
        self.mainLayout.addWidget(self.firstButton)
        self.mainLayout.addWidget(self.previousButton)
        self.mainLayout.addWidget(self.lineEdit)
        self.mainLayout.addWidget(self.label)
        self.mainLayout.addWidget(self.nextButton)
        self.mainLayout.addWidget(self.lastButton)
        self.mainLayout.addWidget(qt.HorizontalSpacer(self))

        self.connect(self.firstButton, qt.SIGNAL("clicked()"),
                     self._firstClicked)

        self.connect(self.previousButton, qt.SIGNAL("clicked()"),
                     self._previousClicked)

        self.connect(self.nextButton, qt.SIGNAL("clicked()"),
                     self._nextClicked)

        self.connect(self.lastButton, qt.SIGNAL("clicked()"),
                     self._lastClicked)

        self.connect(self.lineEdit, qt.SIGNAL("editingFinished()"),
                     self._textChangedSlot)
Exemple #8
0
 def __init__(self, parent = None, current="", curves = []):
     qt.QDialog.__init__(self, parent)
     self.setWindowTitle("Rename Curve %s" % current)
     self.curves = curves
     layout = qt.QVBoxLayout(self)
     self.lineEdit = qt.QLineEdit(self)
     self.lineEdit.setText(current)
     self.hbox = qt.QWidget(self)
     self.hboxLayout = qt.QHBoxLayout(self.hbox)
     self.hboxLayout.addWidget(qt.HorizontalSpacer(self.hbox))
     self.okButton    = qt.QPushButton(self.hbox)
     self.okButton.setText('OK')
     self.hboxLayout.addWidget(self.okButton)
     self.cancelButton = qt.QPushButton(self.hbox)
     self.cancelButton.setText('Dismiss')
     self.hboxLayout.addWidget(self.cancelButton)
     self.hboxLayout.addWidget(qt.HorizontalSpacer(self.hbox))
     layout.addWidget(self.lineEdit)
     layout.addWidget(self.hbox)
     self.connect(self.okButton, qt.SIGNAL('clicked()'), self.preAccept)
     self.connect(self.cancelButton, qt.SIGNAL('clicked()'), self.reject)
    def __init__(self, origin=None, name='', selection=[], parent=None):
        qt.QWidget.__init__(self, parent)
        self.setWindowTitle('Scan Window' + ' ' + name)
        self.plotWindow = origin
        self.scanWindow = ScanWindow.ScanWindow()
        self.title = name

        self.scanWindow.scanWindowInfoWidget.hide()

        buttonAdd = qt.QPushButton('Add', self)
        buttonReplace = qt.QPushButton('Replace', self)
        buttonAddAll = qt.QPushButton('Add all', self)
        buttonReplaceAll = qt.QPushButton('Replace all', self)

        buttonLayout = qt.QHBoxLayout(None)
        buttonLayout.setContentsMargins(0, 0, 0, 0)
        buttonLayout.setSpacing(5)
        buttonLayout.addWidget(qt.HorizontalSpacer(self))
        buttonLayout.addWidget(buttonAdd)
        buttonLayout.addWidget(buttonAddAll)
        buttonLayout.addWidget(buttonReplace)
        buttonLayout.addWidget(buttonReplaceAll)

        mainLayout = qt.QVBoxLayout(None)
        mainLayout.setContentsMargins(1, 1, 1, 1)
        mainLayout.setSpacing(0)
        mainLayout.addWidget(self.scanWindow)
        mainLayout.addLayout(buttonLayout)
        self.setLayout(mainLayout)

        buttonAdd.clicked.connect(self.add)
        buttonReplace.clicked.connect(self.replace)
        buttonAddAll.clicked.connect(self.addAll)
        buttonReplaceAll.clicked.connect(self.replaceAll)

        if self.plotWindow:
            activeCurve = self.plotWindow.graph.getActiveCurve(justlegend=True)
        else:
            activeCurve = None
        for legend in selection:
            self.plotWindow.setActiveCurve(legend)
            (xVal,  yVal,  leg,  info) = \
                            self.plotWindow.getActiveCurve()
            if 'selectionlegend' in info:
                newLegend = info['selectionlegend']
            elif 'operation' in info:
                newLegend = (str(operation) + ' ' + self.title)
            else:
                newLegend = leg
            self.scanWindow.addCurve(xVal, yVal, newLegend, info)
        if activeCurve:
            self.plotWindow.setActiveCurve(activeCurve)
Exemple #10
0
 def __init__(self, parent, data, x=None, smooth=False):
     qt.QDialog.__init__(self, parent)
     self.setWindowTitle("SNIP Configuration Dialog")
     self.mainLayout = qt.QVBoxLayout(self)
     self.mainLayout.setMargin(10)
     self.mainLayout.setSpacing(2)
     self.__image = False
     self.__smooth = smooth
     if len(data.shape) == 2:
         if 1 not in data.shape:
             image = data
             self.__image = True
         else:
             spectrum = data.ravel()
     else:
         spectrum = data
     if self.__image:
         self.parametersWidget = SNIPWindow(self, image, image=True, x=x)
     else:
         self.parametersWidget = SNIPWindow(self,
                                            spectrum,
                                            image=False,
                                            x=x,
                                            smooth=smooth)
     self.graph = self.parametersWidget.graph
     self.mainLayout.addWidget(self.parametersWidget)
     hbox = qt.QWidget(self)
     hboxLayout = qt.QHBoxLayout(hbox)
     hboxLayout.setMargin(0)
     hboxLayout.setSpacing(0)
     self.okButton = qt.QPushButton(hbox)
     self.okButton.setText("OK")
     self.okButton.setAutoDefault(False)
     self.dismissButton = qt.QPushButton(hbox)
     self.dismissButton.setText("Cancel")
     self.dismissButton.setAutoDefault(False)
     hboxLayout.addWidget(self.okButton)
     hboxLayout.addWidget(qt.HorizontalSpacer(hbox))
     hboxLayout.addWidget(self.dismissButton)
     self.mainLayout.addWidget(hbox)
     self.connect(self.dismissButton, qt.SIGNAL("clicked()"), self.reject)
     self.connect(self.okButton, qt.SIGNAL("clicked()"), self.accept)
Exemple #11
0
 def __init__(self, parent, legends, motorValues):
     """
     legends            List contains Plotnames
     motorValues     List contains names and values of the motors
     """
     qt.QWidget.__init__(self, parent)
     self.setWindowTitle("Motor Info Plugin")
     if len(legends) <> len(motorValues):
         print(
             'Consistency error: legends and motorValues do not have same length!'
         )
     self.numCurves = len(legends)
     # Buttons
     self.buttonAddColumn = qt.QPushButton("Add", self)
     self.buttonDeleteColumn = qt.QPushButton("Del", self)
     self.buttonClose = qt.QPushButton("Close", self)
     self.buttonUpdate = qt.QPushButton("Update", self)
     # Table
     self.table = MotorInfoTable(self, self.numCurves + 1, 5, legends,
                                 motorValues)
     # Layout
     self.mainLayout = qt.QGridLayout(self)
     self.mainLayout.setContentsMargins(1, 1, 1, 1)
     self.mainLayout.setSpacing(2)
     self.buttonLayout = qt.QHBoxLayout(None)
     self.buttonLayout.setSpacing(1)
     # Add widgets to layour
     self.mainLayout.addWidget(self.table, 0, 0)
     self.mainLayout.addLayout(self.buttonLayout, 1, 0)
     self.buttonLayout.addWidget(self.buttonUpdate)
     self.buttonLayout.addWidget(self.buttonAddColumn)
     self.buttonLayout.addWidget(self.buttonDeleteColumn)
     self.buttonLayout.addWidget(qt.HorizontalSpacer(self))
     self.buttonLayout.addWidget(self.buttonClose)
     self.resize(700, 500)
     # Make connections
     self.buttonClose.clicked.connect(self.close)
     self.buttonAddColumn.clicked.connect(self.table.addColumn)
     self.buttonDeleteColumn.clicked.connect(self.table.delColumn)
    def __init__(self, parent=None, name=None, fl=0):
        if QTVERSION < '4.0.0':
            qt.QWidget.__init__(self, parent, name,fl)
            if name is not None:self.setCaption(name)
        else:
            qt.QWidget.__init__(self, parent)
            if name is not None:self.setWindowTitle(name)
        layout = qt.QVBoxLayout(self)
        ##############
        self.headerlabel = qt.QLabel(self)
        self.headerlabel.setAlignment(qt.Qt.AlignHCenter)       
        self.setheader('<b>Channel ROIs of XXXXXXXXXX<\b>')
        layout.addWidget(self.headerlabel)
        ##############
        self.mcaROITable     = McaROITable(self)
        if QTVERSION < '4.0.0':
            self.mcaROITable.setMinimumHeight(4*self.mcaROITable.sizeHint().height())
            self.mcaROITable.setMaximumHeight(4*self.mcaROITable.sizeHint().height())
        else:
            rheight = self.mcaROITable.horizontalHeader().sizeHint().height()
            self.mcaROITable.setMinimumHeight(4*rheight)
            #self.mcaROITable.setMaximumHeight(4*rheight)
        self.fillfromroidict = self.mcaROITable.fillfromroidict
        self.addroi          = self.mcaROITable.addroi
        self.getroilistanddict=self.mcaROITable.getroilistanddict
        layout.addWidget(self.mcaROITable)
        self.roiDir = None
        #################


        
        hbox = qt.QWidget(self)
        hboxlayout = qt.QHBoxLayout(hbox)
        hboxlayout.setMargin(0)
        hboxlayout.setSpacing(0)

        hboxlayout.addWidget(qt.HorizontalSpacer(hbox))
        
        self.addbutton = qt.QPushButton(hbox)
        self.addbutton.setText("Add ROI")
        self.delbutton = qt.QPushButton(hbox)
        self.delbutton.setText("Delete ROI")        
        self.resetbutton = qt.QPushButton(hbox)
        self.resetbutton.setText("Reset")

        hboxlayout.addWidget(self.addbutton)
        hboxlayout.addWidget(self.delbutton)
        hboxlayout.addWidget(self.resetbutton)
        hboxlayout.addWidget(qt.HorizontalSpacer(hbox))

        if QTVERSION > '4.0.0':
            self.loadButton = qt.QPushButton(hbox)
            self.loadButton.setText("Load")
            self.saveButton = qt.QPushButton(hbox)
            self.saveButton.setText("Save")
            hboxlayout.addWidget(self.loadButton)
            hboxlayout.addWidget(self.saveButton)
            layout.setStretchFactor(self.headerlabel, 0)
            layout.setStretchFactor(self.mcaROITable, 1)
            layout.setStretchFactor(hbox, 0)

        layout.addWidget(hbox)

        self.connect(self.addbutton,  qt.SIGNAL("clicked()"), self.__add)
        self.connect(self.delbutton,  qt.SIGNAL("clicked()"), self.__del)
        self.connect(self.resetbutton,qt.SIGNAL("clicked()"), self.__reset)

        if QTVERSION < '4.0.0':
            self.connect(self.mcaROITable,  qt.PYSIGNAL('McaROITableSignal') ,self.__forward)
        else:
            self.connect(self.loadButton,qt.SIGNAL("clicked()"), self._load)
            self.connect(self.saveButton,qt.SIGNAL("clicked()"), self._save)
            self.connect(self.mcaROITable,  qt.SIGNAL('McaROITableSignal') ,self.__forward)
    def __init__(self, parent=None, name=None, fl=0):
        if QTVERSION < '4.0.0':
            qt.QWidget.__init__(self, parent, name, fl)

            if name == None:
                self.setName("FitParamForm")
            self.setCaption(str("FIT Parameters"))
        else:
            qt.QWidget.__init__(self, parent)

        if QTVERSION < '4.0.0':
            FitParamFormLayout = qt.QVBoxLayout(self, 11, 6,
                                                "FitParamFormLayout")
            self.mainTab = qt.QTabWidget(self, "mainTab")
            self.tabFit = qt.QWidget(self.mainTab, "tabFit")
            tabFitLayout = qt.QVBoxLayout(self.tabFit, 11, 6, "tabFitLayout")

            layout5 = qt.QGridLayout(None, 1, 1, 12, 6, "layout5")
        else:
            FitParamFormLayout = qt.QVBoxLayout(self)
            FitParamFormLayout.setMargin(11)
            FitParamFormLayout.setSpacing(6)
            self.mainTab = qt.QTabWidget(self)
            self.tabFit = qt.QWidget()
            tabFitLayout = qt.QVBoxLayout(self.tabFit)
            tabFitLayout.setMargin(11)
            tabFitLayout.setSpacing(6)
            layout5 = Q3GridLayout(None)
            #,1,1,
            layout5.setMargin(11)
            layout5.setSpacing(6)

        if QTVERSION < '4.0.0':
            self.functionCombo = qt.QComboBox(0, self.tabFit)
        else:
            self.functionCombo = qt.QComboBox(self.tabFit)
            self.functionCombo.insertItem = self.functionCombo.addItem

        self.functionLabel = qt.QLabel(self.tabFit)
        self.functionLabel.setText("Fit Function")
        self.functionCombo.insertItem(str("Mca Hypermet"))
        self.functionCombo.insertItem(str("Mca Pseudo-Voigt"))

        self.snipWidthLabel = qt.QLabel(self.tabFit)
        self.snipWidthLabel.setText(str("SNIP Background Width"))

        self.stripWidthLabel = qt.QLabel(self.tabFit)
        self.stripWidthLabel.setText(str("Strip Background Width"))
        self.stripIterValue = qt.QLineEdit(self.tabFit)

        self.chi2Label = qt.QLabel(self.tabFit)
        self.chi2Label.setText(str("Minimum chi^2 difference (%)"))

        self.chi2Value = qt.QLineEdit(self.tabFit)

        self.linearFitFlagCheck = qt.QCheckBox(self.tabFit)
        self.linearFitFlagCheck.setText(
            str("Perform a Linear Fit Fixing non-linear Parameters to Initial Values"
                ))

        self.mainTab.addTab(self.tabFit, str("FIT"))

        self.lastLabel = qt.QLabel(self.tabFit)
        lastLabel_font = qt.QFont(self.lastLabel.font())
        lastLabel_font.setItalic(1)
        self.lastLabel.setFont(lastLabel_font)
        self.lastLabel.setText(str("Last channel :"))
        self.lastLabel.setAlignment(QLabelAlignVCenter | QLabelAlignRight)

        self.regionCheck = qt.QCheckBox(self.tabFit)
        self.regionCheck.setText(str("Limit fitting region to :"))

        self.topLine = qt.QFrame(self.tabFit)
        self.topLine.setFrameShape(qt.QFrame.HLine)
        self.topLine.setFrameShadow(qt.QFrame.Sunken)
        self.topLine.setFrameShape(qt.QFrame.HLine)

        ##########
        self.weightLabel = qt.QLabel(self.tabFit)
        self.weightLabel.setText("Statistical weighting of data")
        if QTVERSION < '4.0.0':
            self.weightCombo = qt.QComboBox(0, self.tabFit)
        else:
            self.weightCombo = qt.QComboBox(self.tabFit)
            self.weightCombo.insertItem = self.weightCombo.addItem

        self.weightCombo.insertItem(str("NO Weight"))
        self.weightCombo.insertItem(str("Poisson (1/Y)"))
        #self.weightCombo.insertItem(str("Poisson (1/Y2)"))

        ##########
        self.iterLabel = qt.QLabel(self.tabFit)
        self.iterLabel.setText(str("Number of fit iterations"))

        if QTVERSION < '4.0.0':
            self.contCombo = qt.QComboBox(0, self.tabFit)
        else:
            self.contCombo = qt.QComboBox(self.tabFit)
            self.contCombo.insertItem = self.contCombo.addItem

        self.contCombo.insertItem(str("NO Continuum"))
        self.contCombo.insertItem(str("Constant"))
        self.contCombo.insertItem(str("Linear"))
        self.contCombo.insertItem(str("Parabolic"))
        self.contCombo.insertItem(str("Linear Polynomial"))
        self.contCombo.insertItem(str("Exp. Polynomial"))

        if QTVERSION < '4.0.0':
            self.stripCombo = qt.QComboBox(0, self.tabFit)
        else:
            self.stripCombo = qt.QComboBox(self.tabFit)
            self.stripCombo.insertItem = self.stripCombo.addItem

        self.stripComboLabel = qt.QLabel(self.tabFit)
        self.stripComboLabel.setText(
            "Non-analytical (or estimation) background algorithm")
        self.stripCombo.insertItem(str("Strip"))
        self.stripCombo.insertItem(str("SNIP"))
        self.connect(self.stripCombo, qt.SIGNAL("activated(int)"),
                     self._stripComboActivated)

        self.snipWidthSpin = Q3SpinBox(self.tabFit)
        self.snipWidthSpin.setMaxValue(300)
        self.snipWidthSpin.setMinValue(0)

        self.stripWidthSpin = Q3SpinBox(self.tabFit)
        self.stripWidthSpin.setMaxValue(100)
        self.stripWidthSpin.setMinValue(1)

        self.orderSpin = Q3SpinBox(self.tabFit)
        self.orderSpin.setMaxValue(10)
        self.orderSpin.setMinValue(1)

        maxnchannel = 16384 * 4

        self.maxSpin = Q3SpinBox(self.tabFit)
        self.maxSpin.setMaxValue(maxnchannel)
        self.maxSpin.setLineStep(128)

        self.minSpin = Q3SpinBox(self.tabFit)
        self.minSpin.setMaxValue(maxnchannel)
        self.minSpin.setLineStep(128)

        self.stripIterLabel = qt.QLabel(self.tabFit)
        self.stripIterLabel.setText(str("Strip Background Iterations"))

        self.iterSpin = Q3SpinBox(self.tabFit)
        self.iterSpin.setMinValue(1)

        self.stripFilterLabel = qt.QLabel(self.tabFit)
        self.stripFilterLabel.setText(
            str("Strip Background Smoothing Width (Savitsky-Golay)"))

        self.stripFilterSpin = Q3SpinBox(self.tabFit)
        self.stripFilterSpin.setMinValue(1)
        self.stripFilterSpin.setMaxValue(40)
        self.stripFilterSpin.setLineStep(2)

        ########
        self.anchorsContainer = qt.QWidget(self.tabFit)
        anchorsContainerLayout = qt.QHBoxLayout(self.anchorsContainer)
        anchorsContainerLayout.setMargin(0)
        anchorsContainerLayout.setSpacing(2)
        self.stripAnchorsFlagCheck = qt.QCheckBox(self.anchorsContainer)
        self.stripAnchorsFlagCheck.setText(str("Strip Background use Anchors"))
        anchorsContainerLayout.addWidget(self.stripAnchorsFlagCheck)

        self.stripAnchorsList = []
        for i in range(4):
            anchorSpin = Q3SpinBox(self.anchorsContainer)
            anchorSpin.setMinValue(0)
            anchorSpin.setMaxValue(maxnchannel)
            anchorsContainerLayout.addWidget(anchorSpin)
            self.stripAnchorsList.append(anchorSpin)
        #######

        self.firstLabel = qt.QLabel(self.tabFit)
        firstLabel_font = qt.QFont(self.firstLabel.font())
        firstLabel_font.setItalic(1)
        self.firstLabel.setFont(firstLabel_font)
        self.firstLabel.setText(str("First channel :"))
        if QTVERSION < '4.0.0':
            self.firstLabel.setAlignment(QLabelAlignVCenter | QLabelAlignRight)
        else:
            self.firstLabel.setAlignment(qt.Qt.AlignVCenter | qt.Qt.AlignRight)

        self.typeLabel = qt.QLabel(self.tabFit)
        self.typeLabel.setText(str("Continuum type"))

        self.orderLabel = qt.QLabel(self.tabFit)
        self.orderLabel.setText(str("Polynomial order"))

        self.bottomLine = qt.QFrame(self.tabFit)
        self.bottomLine.setFrameShape(qt.QFrame.HLine)
        self.bottomLine.setFrameShadow(qt.QFrame.Sunken)
        self.bottomLine.setFrameShape(qt.QFrame.HLine)

        layout5.addMultiCellWidget(self.functionLabel, 0, 0, 0, 1)
        layout5.addMultiCellWidget(self.functionCombo, 0, 0, 3, 4)

        layout5.addMultiCellWidget(self.typeLabel, 1, 1, 0, 1)
        layout5.addMultiCellWidget(self.contCombo, 1, 1, 3, 4)

        layout5.addMultiCellWidget(self.orderLabel, 2, 2, 0, 1)
        layout5.addMultiCellWidget(self.orderSpin, 2, 2, 3, 4)

        layout5.addMultiCellWidget(self.stripComboLabel, 3, 3, 0, 1)
        if QTVERSION > '4.0.0':
            self.stripSetupButton = qt.QPushButton(self.tabFit)
            self.stripSetupButton.setText('SETUP')
            self.stripSetupButton.setAutoDefault(False)
            layout5.addWidget(self.stripCombo, 3, 3)
            layout5.addWidget(self.stripSetupButton, 3, 4)
        else:
            layout5.addMultiCellWidget(self.stripCombo, 3, 3, 3, 4)

        layout5.addMultiCellWidget(self.snipWidthLabel, 4, 4, 0, 1)
        layout5.addMultiCellWidget(self.snipWidthSpin, 4, 4, 3, 4)

        layout5.addMultiCellWidget(self.stripWidthLabel, 5, 5, 0, 1)
        layout5.addMultiCellWidget(self.stripWidthSpin, 5, 5, 3, 4)

        layout5.addMultiCellWidget(self.stripIterLabel, 6, 6, 0, 1)
        layout5.addMultiCellWidget(self.stripIterValue, 6, 6, 3, 4)

        layout5.addMultiCellWidget(self.stripFilterLabel, 7, 7, 0, 1)
        layout5.addMultiCellWidget(self.stripFilterSpin, 7, 7, 3, 4)

        layout5.addMultiCellWidget(self.anchorsContainer, 8, 8, 0, 4)

        layout5.addWidget(self.weightLabel, 9, 0)
        layout5.addMultiCellWidget(self.weightCombo, 9, 9, 3, 4)

        layout5.addWidget(self.iterLabel, 10, 0)
        if QTVERSION < '4.0.0':
            spacer = qt.QSpacerItem(185, 16,\
                                    qt.QSizePolicy.Expanding,
                                    qt.QSizePolicy.Minimum)
            layout5.addMultiCell(spacer, 10, 10, 1, 2)
        else:
            layout5.addWidget(qt.HorizontalSpacer(self.tabFit), 10, 1)
        layout5.addMultiCellWidget(self.iterSpin, 10, 10, 3, 4)

        layout5.addWidget(self.chi2Label, 11, 0)
        layout5.addMultiCellWidget(self.chi2Value, 11, 11, 3, 4)

        layout5.addMultiCellWidget(self.linearFitFlagCheck, 12, 12, 0, 4)

        layout5.addMultiCellWidget(self.topLine, 13, 14, 0, 4)

        layout5.addMultiCellWidget(self.minSpin, 14, 15, 4, 4)

        layout5.addWidget(self.regionCheck, 15, 0)
        layout5.addMultiCellWidget(self.firstLabel, 15, 15, 2, 3)

        layout5.addMultiCellWidget(self.lastLabel, 16, 16, 2, 3)
        layout5.addWidget(self.maxSpin, 16, 4)
        layout5.addMultiCellWidget(self.bottomLine, 17, 17, 0, 4)

        tabFitLayout.addLayout(layout5)

        includeWidget = qt.QWidget(self.tabFit)

        if QTVERSION < '4.0.0':
            includeLayout = qt.QGridLayout(includeWidget, 1, 1, 0, 3,
                                           "includeLayout")
        else:
            includeLayout = Q3GridLayout(includeWidget)
            includeLayout.setMargin(0)
            includeLayout.setSpacing(3)

        self.stepCheck = qt.QCheckBox(includeWidget)
        self.stepCheck.setText(str("Step tail"))

        includeLayout.addWidget(self.stepCheck, 2, 2)

        self.escapeCheck = qt.QCheckBox(includeWidget)
        self.escapeCheck.setText(str("Escape peaks"))

        includeLayout.addWidget(self.escapeCheck, 1, 1)

        self.includeLabel = qt.QLabel(includeWidget)
        includeLabel_font = qt.QFont(self.includeLabel.font())
        includeLabel_font.setBold(1)
        self.includeLabel.setFont(includeLabel_font)
        self.includeLabel.setText(str("Include:"))

        includeLayout.addWidget(self.includeLabel, 0, 0)

        self.sumCheck = qt.QCheckBox(includeWidget)
        self.sumCheck.setText(str("Pile-up peaks"))

        includeLayout.addWidget(self.sumCheck, 1, 2)

        self.scatterCheck = qt.QCheckBox(includeWidget)
        self.scatterCheck.setText(str("Scattering peaks"))

        includeLayout.addWidget(self.scatterCheck, 1, 3)

        self.stripCheck = qt.QCheckBox(includeWidget)
        self.stripCheck.setText(str("Stripping"))

        includeLayout.addWidget(self.stripCheck, 1, 0)

        self.longCheck = qt.QCheckBox(includeWidget)
        self.longCheck.setText(str("Long tail"))

        includeLayout.addWidget(self.longCheck, 2, 1)

        self.shortCheck = qt.QCheckBox(includeWidget)
        self.shortCheck.setText(str("Short tail"))

        includeLayout.addWidget(self.shortCheck, 2, 0)
        #tabFitLayout.addLayout(includeLayout)
        layout5.addMultiCellWidget(includeWidget, 18, 19, 0, 4)

        spacer_2 = qt.QSpacerItem(20, 40,\
                                  qt.QSizePolicy.Minimum,\
                                  qt.QSizePolicy.Expanding)
        tabFitLayout.addItem(spacer_2)

        if QTVERSION < '4.0.0':
            #self.mainTab.insertTab(self.tabFit,str("FIT"))
            self.tabDetector = qt.QWidget(self.mainTab, "tabDetector")
            tabDetectorLayout = qt.QVBoxLayout(self.tabDetector, 11, 6,
                                               "tabDetectorLayout")

            detLayout = qt.QGridLayout(None, 1, 1, 0, 2, "detLayout")
            self.elementCombo = qt.QComboBox(0, self.tabDetector,
                                             "elementCombo")
        else:
            #self.mainTab.addTab(self.tabFit,str("FIT"))
            self.tabDetector = qt.QWidget()
            tabDetectorLayout = qt.QVBoxLayout(self.tabDetector)
            tabDetectorLayout.setMargin(11)
            tabDetectorLayout.setSpacing(6)

            detLayout = Q3GridLayout(None)
            detLayout.setMargin(0)
            detLayout.setSpacing(2)
            self.elementCombo = qt.QComboBox(self.tabDetector)

        if QTVERSION < '4.0.0':
            self.elementCombo.insertItem(str("Si"))
            self.elementCombo.insertItem(str("Ge"))
            self.elementCombo.insertItem(str("Cd1Te1"))
            self.elementCombo.insertItem(str("Hg1I2"))
            self.elementCombo.insertItem(str("Ga1As1"))
        else:
            self.elementCombo.insertItem(0, str("Si"))
            self.elementCombo.insertItem(1, str("Ge"))
            self.elementCombo.insertItem(2, str("Cd1Te1"))
            self.elementCombo.insertItem(3, str("Hg1I2"))
            self.elementCombo.insertItem(4, str("Ga1As1"))
        self.elementCombo.setEnabled(1)
        self.elementCombo.setDuplicatesEnabled(0)

        detLayout.addWidget(self.elementCombo, 0, 3)

        self.elementLabel = qt.QLabel(self.tabDetector)
        self.elementLabel.setText(str("Detector Composition"))

        detLayout.addWidget(self.elementLabel, 0, 0)
        self.escapeLabel = qt.QLabel(self.tabDetector)
        self.escapeLabel.setText(str("Maximum Number of Escape energies"))
        detLayout.addMultiCellWidget(self.escapeLabel, 3, 4, 0, 0)

        #self.intensityValue0 = QLineEdit(self.tabDetector,"intensityValue0")
        #self.intensityValue0.setText(str("1.0"))
        #self.intensityValue0.setReadOnly(1)
        self.nEscapeThreshold = Q3SpinBox(self.tabDetector)
        self.nEscapeThreshold.setMaxValue(20)
        self.nEscapeThreshold.setMinValue(1)
        self.nEscapeThreshold.setValue(4)
        #detLayout.addWidget(self.intensityValue0,3,3)
        detLayout.addWidget(self.nEscapeThreshold, 3, 3)
        spacer_4 = qt.QSpacerItem(89, 20,\
                                  qt.QSizePolicy.Expanding,
                                  qt.QSizePolicy.Minimum)
        detLayout.addItem(spacer_4, 3, 1)
        tabDetectorLayout.addLayout(detLayout)

        self.calibLine = qt.QFrame(self.tabDetector)
        self.calibLine.setFrameShape(qt.QFrame.HLine)
        self.calibLine.setFrameShadow(qt.QFrame.Sunken)
        self.calibLine.setFrameShape(qt.QFrame.HLine)
        tabDetectorLayout.addWidget(self.calibLine)

        if QTVERSION < '4.0.0':
            layout5_2 = qt.QGridLayout(None, 1, 1, 11, 2, "layout5_2")
        else:
            layout5_2 = Q3GridLayout(None)
            layout5_2.setMargin(11)
            layout5_2.setSpacing(2)

        self.zeroError = qt.QLineEdit(self.tabDetector)

        layout5_2.addWidget(self.zeroError, 1, 5)

        self.sumfacSepLabel = qt.QLabel(self.tabDetector)
        sumfacSepLabel_font = qt.QFont(self.sumfacSepLabel.font())
        sumfacSepLabel_font.setBold(1)
        self.sumfacSepLabel.setFont(sumfacSepLabel_font)
        self.sumfacSepLabel.setText(str("+/-"))

        layout5_2.addWidget(self.sumfacSepLabel, 5, 4)

        self.noiseLabel = qt.QLabel(self.tabDetector)
        self.noiseLabel.setText(str("Detector noise (keV)"))

        layout5_2.addWidget(self.noiseLabel, 3, 0)

        self.gainCheck = qt.QCheckBox(self.tabDetector)
        self.gainCheck.setText(str(""))

        layout5_2.addWidget(self.gainCheck, 2, 2)

        self.gainLabel = qt.QLabel(self.tabDetector)
        self.gainLabel.setText(str("Spectrometer gain (keV/ch)"))

        layout5_2.addWidget(self.gainLabel, 2, 0)

        self.sumfacLabel = qt.QLabel(self.tabDetector)
        self.sumfacLabel.setText(str("Pile-up Factor"))

        layout5_2.addWidget(self.sumfacLabel, 5, 0)

        self.noiseError = qt.QLineEdit(self.tabDetector)

        layout5_2.addWidget(self.noiseError, 3, 5)

        self.zeroValue = qt.QLineEdit(self.tabDetector)

        layout5_2.addWidget(self.zeroValue, 1, 3)

        self.fanoSepLabel = qt.QLabel(self.tabDetector)
        fanoSepLabel_font = qt.QFont(self.fanoSepLabel.font())
        fanoSepLabel_font.setBold(1)
        self.fanoSepLabel.setFont(fanoSepLabel_font)
        self.fanoSepLabel.setText(str("+/-"))

        layout5_2.addWidget(self.fanoSepLabel, 4, 4)

        self.fanoError = qt.QLineEdit(self.tabDetector)

        layout5_2.addWidget(self.fanoError, 4, 5)

        self.zeroSepLabel = qt.QLabel(self.tabDetector)
        zeroSepLabel_font = qt.QFont(self.zeroSepLabel.font())
        zeroSepLabel_font.setBold(1)
        self.zeroSepLabel.setFont(zeroSepLabel_font)
        self.zeroSepLabel.setText(str("+/-"))

        layout5_2.addWidget(self.zeroSepLabel, 1, 4)

        self.valueLabel = qt.QLabel(self.tabDetector)
        valueLabel_font = qt.QFont(self.valueLabel.font())
        valueLabel_font.setItalic(1)
        self.valueLabel.setFont(valueLabel_font)
        self.valueLabel.setText(str("Value"))
        if QTVERSION < '4.0.0':
            self.valueLabel.setAlignment(QLabelAlignCenter)
        else:
            self.valueLabel.setAlignment(qt.Qt.AlignCenter)

        layout5_2.addWidget(self.valueLabel, 0, 3)
        if QTVERSION < '4.0.0':
            spacer_5 = qt.QSpacerItem(44, 20,\
                                      qt.QSizePolicy.Expanding,\
                                      qt.QSizePolicy.Minimum)
            layout5_2.addItem(spacer_5, 1, 1)
        else:
            layout5_2.addWidget(qt.HorizontalSpacer(self.tabDetector), 1, 1)

        self.noiseValue = qt.QLineEdit(self.tabDetector)

        layout5_2.addWidget(self.noiseValue, 3, 3)

        self.fanoValue = qt.QLineEdit(self.tabDetector)

        layout5_2.addWidget(self.fanoValue, 4, 3)

        self.zeroLabel = qt.QLabel(self.tabDetector)
        self.zeroLabel.setText(str("Spectrometer zero (keV)"))

        layout5_2.addWidget(self.zeroLabel, 1, 0)

        self.sumfacError = qt.QLineEdit(self.tabDetector)

        layout5_2.addWidget(self.sumfacError, 5, 5)

        self.noiseSepLabel = qt.QLabel(self.tabDetector)
        noiseSepLabel_font = qt.QFont(self.noiseSepLabel.font())
        noiseSepLabel_font.setBold(1)
        self.noiseSepLabel.setFont(noiseSepLabel_font)
        self.noiseSepLabel.setText(str("+/-"))

        layout5_2.addWidget(self.noiseSepLabel, 3, 4)

        self.sumfacCheck = qt.QCheckBox(self.tabDetector)
        self.sumfacCheck.setText(str(""))

        layout5_2.addWidget(self.sumfacCheck, 5, 2)

        self.noiseCheck = qt.QCheckBox(self.tabDetector)
        self.noiseCheck.setText(str(""))

        layout5_2.addWidget(self.noiseCheck, 3, 2)

        self.errorLabel = qt.QLabel(self.tabDetector)
        errorLabel_font = qt.QFont(self.errorLabel.font())
        errorLabel_font.setItalic(1)
        self.errorLabel.setFont(errorLabel_font)
        self.errorLabel.setText(str("Delta "))
        self.errorLabel.setAlignment(QLabelAlignCenter)

        layout5_2.addWidget(self.errorLabel, 0, 5)

        self.fixedLabel = qt.QLabel(self.tabDetector)
        fixedLabel_font = qt.QFont(self.fixedLabel.font())
        fixedLabel_font.setItalic(1)
        self.fixedLabel.setFont(fixedLabel_font)
        self.fixedLabel.setText(str("Fixed "))
        if QTVERSION < '4.0.0':
            self.fixedLabel.setAlignment(QLabelAlignVCenter)
        else:
            self.fixedLabel.setAlignment(qt.Qt.AlignVCenter)

        layout5_2.addWidget(self.fixedLabel, 0, 2)

        self.zeroCheck = qt.QCheckBox(self.tabDetector)
        self.zeroCheck.setText(str(""))

        layout5_2.addWidget(self.zeroCheck, 1, 2)

        self.sumfacValue = qt.QLineEdit(self.tabDetector, )

        layout5_2.addWidget(self.sumfacValue, 5, 3)

        self.fanoLabel = qt.QLabel(self.tabDetector)
        self.fanoLabel.setText(str("Fano factor (Si ~ 0.12, Ge ~ 0.1)"))

        layout5_2.addWidget(self.fanoLabel, 4, 0)

        self.gainValue = qt.QLineEdit(self.tabDetector)

        layout5_2.addWidget(self.gainValue, 2, 3)

        self.gainSepLabel = qt.QLabel(self.tabDetector)
        gainSepLabel_font = qt.QFont(self.gainSepLabel.font())
        gainSepLabel_font.setBold(1)
        self.gainSepLabel.setFont(gainSepLabel_font)
        self.gainSepLabel.setText(str("+/-"))

        layout5_2.addWidget(self.gainSepLabel, 2, 4)

        self.fanoCheck = qt.QCheckBox(self.tabDetector)
        self.fanoCheck.setText(str(""))

        layout5_2.addWidget(self.fanoCheck, 4, 2)

        self.gainError = qt.QLineEdit(self.tabDetector)

        layout5_2.addWidget(self.gainError, 2, 5)
        tabDetectorLayout.addLayout(layout5_2)
        spacer_6 = qt.QSpacerItem(20, 2,\
                                  qt.QSizePolicy.Minimum,\
                                  qt.QSizePolicy.Expanding)
        tabDetectorLayout.addItem(spacer_6)
        if QTVERSION < '4.0.0':
            self.mainTab.insertTab(self.tabDetector, str("DETECTOR"))
            self.TabBeam = qt.QWidget(self.mainTab, "TabBeam")
            self.mainTab.insertTab(self.TabBeam, str("BEAM"))

            self.TabPeaks = qt.QWidget(self.mainTab, "TabPeaks")
            self.mainTab.insertTab(self.TabPeaks, str("PEAKS"))
        else:
            self.mainTab.addTab(self.tabDetector, str("DETECTOR"))
            self.TabBeam = qt.QWidget()
            self.mainTab.addTab(self.TabBeam, str("BEAM"))

            self.TabPeaks = qt.QWidget()
            self.mainTab.addTab(self.TabPeaks, str("PEAKS"))

        if QTVERSION < '4.0.0':
            self.tabPeakShape = qt.QWidget(self.mainTab)
            tabPeakShapeLayout = qt.QGridLayout(self.tabPeakShape, 1, 1, 11, 2,
                                                "tabPeakShapeLayout")
        else:
            self.tabPeakShape = qt.QWidget()
            tabPeakShapeLayout = Q3GridLayout(self.tabPeakShape)
            tabPeakShapeLayout.setMargin(11)
            tabPeakShapeLayout.setSpacing(2)

        spacer_7 = qt.QSpacerItem(20, 90,\
                                  qt.QSizePolicy.Minimum,\
                                  qt.QSizePolicy.Expanding)
        tabPeakShapeLayout.addItem(spacer_7, 8, 0)

        self.staLabel = qt.QLabel(self.tabPeakShape)
        self.staLabel.setText(str("Short Tail Area"))

        tabPeakShapeLayout.addWidget(self.staLabel, 2, 0)
        spacer_8 = qt.QSpacerItem(59, 20,\
                                  qt.QSizePolicy.Expanding,\
                                  qt.QSizePolicy.Minimum)
        tabPeakShapeLayout.addItem(spacer_8, 1, 1)

        self.fixedLabel_2 = qt.QLabel(self.tabPeakShape)
        fixedLabel_2_font = qt.QFont(self.fixedLabel_2.font())
        fixedLabel_2_font.setItalic(1)
        self.fixedLabel_2.setFont(fixedLabel_2_font)
        self.fixedLabel_2.setText(str("Fixed"))
        self.fixedLabel_2.setAlignment(QLabelAlignVCenter)

        tabPeakShapeLayout.addWidget(self.fixedLabel_2, 1, 2)

        self.staCheck = qt.QCheckBox(self.tabPeakShape)
        self.staCheck.setText(str(""))

        tabPeakShapeLayout.addWidget(self.staCheck, 2, 2)

        self.valueLabel_2 = qt.QLabel(self.tabPeakShape)
        valueLabel_2_font = qt.QFont(self.valueLabel_2.font())
        valueLabel_2_font.setItalic(1)
        self.valueLabel_2.setFont(valueLabel_2_font)
        self.valueLabel_2.setText(str("Value"))
        self.valueLabel_2.setAlignment(QLabelAlignCenter)

        tabPeakShapeLayout.addWidget(self.valueLabel_2, 1, 3)

        self.staValue = qt.QLineEdit(self.tabPeakShape)

        tabPeakShapeLayout.addWidget(self.staValue, 2, 3)

        self.staSep = qt.QLabel(self.tabPeakShape)
        staSep_font = qt.QFont(self.staSep.font())
        staSep_font.setBold(1)
        self.staSep.setFont(staSep_font)
        self.staSep.setText(str("+/-"))

        tabPeakShapeLayout.addWidget(self.staSep, 2, 4)

        self.errorLabel_2 = qt.QLabel(self.tabPeakShape)
        errorLabel_2_font = qt.QFont(self.errorLabel_2.font())
        errorLabel_2_font.setItalic(1)
        self.errorLabel_2.setFont(errorLabel_2_font)
        self.errorLabel_2.setText(str("Error"))
        self.errorLabel_2.setAlignment(QLabelAlignCenter)

        tabPeakShapeLayout.addWidget(self.errorLabel_2, 1, 5)

        self.staError = qt.QLineEdit(self.tabPeakShape)

        tabPeakShapeLayout.addWidget(self.staError, 2, 5)

        self.stsError = qt.QLineEdit(self.tabPeakShape)

        tabPeakShapeLayout.addWidget(self.stsError, 3, 5)

        self.stsSep = qt.QLabel(self.tabPeakShape)
        stsSep_font = qt.QFont(self.stsSep.font())
        stsSep_font.setBold(1)
        self.stsSep.setFont(stsSep_font)
        self.stsSep.setText(str("+/-"))

        tabPeakShapeLayout.addWidget(self.stsSep, 3, 4)

        self.stsValue = qt.QLineEdit(self.tabPeakShape)

        tabPeakShapeLayout.addWidget(self.stsValue, 3, 3)

        self.stsCheck = qt.QCheckBox(self.tabPeakShape)
        self.stsCheck.setText(str(""))

        tabPeakShapeLayout.addWidget(self.stsCheck, 3, 2)

        self.stsLabel = qt.QLabel(self.tabPeakShape)
        self.stsLabel.setText(str("Short Tail Slope"))

        tabPeakShapeLayout.addWidget(self.stsLabel, 3, 0)

        self.ltaLabel = qt.QLabel(self.tabPeakShape)
        self.ltaLabel.setText(str("Long Tail Area"))

        tabPeakShapeLayout.addWidget(self.ltaLabel, 4, 0)

        self.ltaCheck = qt.QCheckBox(self.tabPeakShape)
        self.ltaCheck.setText(str(""))

        tabPeakShapeLayout.addWidget(self.ltaCheck, 4, 2)

        self.ltaValue = qt.QLineEdit(self.tabPeakShape)

        tabPeakShapeLayout.addWidget(self.ltaValue, 4, 3)

        self.ltaSep = qt.QLabel(self.tabPeakShape)
        ltaSep_font = qt.QFont(self.ltaSep.font())
        ltaSep_font.setBold(1)
        self.ltaSep.setFont(ltaSep_font)
        self.ltaSep.setText(str("+/-"))

        tabPeakShapeLayout.addWidget(self.ltaSep, 4, 4)

        self.ltaError = qt.QLineEdit(self.tabPeakShape)

        tabPeakShapeLayout.addWidget(self.ltaError, 4, 5)

        self.ltsError = qt.QLineEdit(self.tabPeakShape)

        tabPeakShapeLayout.addWidget(self.ltsError, 5, 5)

        self.ltsSep = qt.QLabel(self.tabPeakShape)
        ltsSep_font = qt.QFont(self.ltsSep.font())
        ltsSep_font.setBold(1)
        self.ltsSep.setFont(ltsSep_font)
        self.ltsSep.setText(str("+/-"))

        tabPeakShapeLayout.addWidget(self.ltsSep, 5, 4)

        self.ltsValue = qt.QLineEdit(self.tabPeakShape)

        tabPeakShapeLayout.addWidget(self.ltsValue, 5, 3)

        self.ltsCheck = qt.QCheckBox(self.tabPeakShape)
        self.ltsCheck.setText(str(""))

        tabPeakShapeLayout.addWidget(self.ltsCheck, 5, 2)

        self.ltsLabel = qt.QLabel(self.tabPeakShape)
        self.ltsLabel.setText(str("Long Tail Slope"))

        tabPeakShapeLayout.addWidget(self.ltsLabel, 5, 0)

        # Step Height
        self.shLabel = qt.QLabel(self.tabPeakShape)
        self.shLabel.setText(str("Step Height"))

        tabPeakShapeLayout.addWidget(self.shLabel, 6, 0)

        self.shCheck = qt.QCheckBox(self.tabPeakShape)
        self.shCheck.setText(str(""))

        tabPeakShapeLayout.addWidget(self.shCheck, 6, 2)

        self.shValue = qt.QLineEdit(self.tabPeakShape)

        tabPeakShapeLayout.addWidget(self.shValue, 6, 3)

        self.shSep = qt.QLabel(self.tabPeakShape)
        shSep_font = qt.QFont(self.shSep.font())
        shSep_font.setBold(1)
        self.shSep.setFont(shSep_font)
        self.shSep.setText(str("+/-"))

        tabPeakShapeLayout.addWidget(self.shSep, 6, 4)

        self.shError = qt.QLineEdit(self.tabPeakShape)

        tabPeakShapeLayout.addWidget(self.shError, 6, 5)

        # Pseudo-Voigt Eta Factor
        self.etaLabel = qt.QLabel(self.tabPeakShape)
        self.etaLabel.setText(str("Pseudo-Voigt Eta"))

        tabPeakShapeLayout.addWidget(self.etaLabel, 7, 0)

        self.etaCheck = qt.QCheckBox(self.tabPeakShape)
        self.etaCheck.setText(str(""))

        tabPeakShapeLayout.addWidget(self.etaCheck, 7, 2)

        self.etaValue = qt.QLineEdit(self.tabPeakShape)

        tabPeakShapeLayout.addWidget(self.etaValue, 7, 3)

        self.etaSep = qt.QLabel(self.tabPeakShape)
        etaSep_font = qt.QFont(self.etaSep.font())
        etaSep_font.setBold(1)
        self.etaSep.setFont(etaSep_font)
        self.etaSep.setText(str("+/-"))

        tabPeakShapeLayout.addWidget(self.etaSep, 7, 4)

        self.etaError = qt.QLineEdit(self.tabPeakShape)

        tabPeakShapeLayout.addWidget(self.etaError, 7, 5)

        if QTVERSION < '4.0.0':
            self.mainTab.insertTab(self.tabPeakShape, str("PEAK SHAPE"))
        else:
            self.mainTab.addTab(self.tabPeakShape, str("PEAK SHAPE"))

        FitParamFormLayout.addWidget(self.mainTab)

        self.setTabOrder(self.mainTab, self.elementCombo)
        self.setTabOrder(self.zeroCheck, self.zeroValue)
        self.setTabOrder(self.zeroValue, self.zeroError)
        self.setTabOrder(self.zeroError, self.gainCheck)
        self.setTabOrder(self.gainCheck, self.gainValue)
        self.setTabOrder(self.gainValue, self.gainError)
        self.setTabOrder(self.gainError, self.noiseCheck)
        self.setTabOrder(self.noiseCheck, self.noiseValue)
        self.setTabOrder(self.noiseValue, self.noiseError)
        self.setTabOrder(self.noiseError, self.fanoCheck)
        self.setTabOrder(self.fanoCheck, self.fanoValue)
        self.setTabOrder(self.fanoValue, self.fanoError)
        self.setTabOrder(self.fanoError, self.staCheck)
        self.setTabOrder(self.staCheck, self.staValue)
        self.setTabOrder(self.staValue, self.staError)
        self.setTabOrder(self.staError, self.stsCheck)
        self.setTabOrder(self.stsCheck, self.stsValue)
        self.setTabOrder(self.stsValue, self.stsError)
        self.setTabOrder(self.stsError, self.ltaCheck)
        self.setTabOrder(self.ltaCheck, self.ltaValue)
        self.setTabOrder(self.ltaValue, self.ltaError)
        self.setTabOrder(self.ltaError, self.ltsCheck)
        self.setTabOrder(self.ltsCheck, self.ltsValue)
        self.setTabOrder(self.ltsValue, self.ltsError)
        self.setTabOrder(self.ltsError, self.shCheck)
        self.setTabOrder(self.shCheck, self.shValue)
        self.setTabOrder(self.shValue, self.shError)
        self.setTabOrder(self.shError, self.contCombo)
        self.setTabOrder(self.contCombo, self.stripCombo)
        self.setTabOrder(self.stripCombo, self.iterSpin)
        self.setTabOrder(self.iterSpin, self.chi2Value)
        self.setTabOrder(self.chi2Value, self.regionCheck)
        self.setTabOrder(self.regionCheck, self.minSpin)
        self.setTabOrder(self.minSpin, self.maxSpin)
        self.setTabOrder(self.maxSpin, self.stripCheck)
        self.setTabOrder(self.stripCheck, self.escapeCheck)
        self.setTabOrder(self.escapeCheck, self.sumCheck)
        self.setTabOrder(self.sumCheck, self.scatterCheck)
        self.setTabOrder(self.scatterCheck, self.shortCheck)
        self.setTabOrder(self.shortCheck, self.longCheck)
        self.setTabOrder(self.longCheck, self.stepCheck)
        self._stripComboActivated(0)
    def __init__(self, parent, ddict, llist, plugin):
        qt.QDialog.__init__(self, parent)
        self.setWindowTitle('Alignment Window')
        
        nCols = 2
        nRows = len(ddict)
        self.plugin = plugin
        
        # Buttons
        buttonSave = qt.QPushButton('Save')
        buttonSave.setToolTip('Save shifts to file')
        buttonLoad = qt.QPushButton('Load')
        buttonLoad.setToolTip('Load shifts from file')
        buttonStore = qt.QPushButton('Store')
        buttonStore.setToolTip('Store shifts in memory.\n')
        buttonApply = qt.QPushButton('Apply')
        buttonApply.setToolTip('Apply shift to curves present'
                              +' in the plot window')
        buttonCancel = qt.QPushButton('Cancel')
        buttonCalc = qt.QPushButton('Calculate')

        # Table
        self.shiftTab = qt.QTableWidget(nRows, nCols)
        self.shiftTab.verticalHeader().hide()
        self.shiftTab.horizontalHeader().setStretchLastSection(True)
        self.shiftTab.setHorizontalHeaderLabels(['Legend','Shift'])
        
        # Shift Method selector
        self.shiftMethodComboBox = qt.QComboBox()
        self.shiftMethodComboBox.addItems(
            ['Shift x-range',
            'Inverse FFT shift'])
        shiftMethodToolTip =\
            ('Select the method that shifts the spectra\n\n'
            +'Shift x-range:\n'
            +'     Directly applies the shift to the data\'s\n'
            +'     x-range\n'
            +'Inverse FFT shift:\n'
            +'     Shifts the spectra by multiplying a\n'
            +'     phase factor to their Fourier transform. The result is\n'
            +'     transformed back to real space. Recommended for data with\n'
            +'     resp. regions with constant background.')
        self.shiftMethodComboBox.setToolTip(shiftMethodToolTip)
             
        # Alignment Method selector
        self.alignmentMethodComboBox = qt.QComboBox()
        self.alignmentMethodComboBox.addItems(
            ['FFT',
             'MAX',
             'FIT',
             'FIT DRV'])
        alignmentMethodToolTip =\
            ('Select the method used to calculate the shift is calculated.\n\n'
            +'FFT:\n'
            +'     Calculates the correlation between two curves using its\n'
            +'     Fourier transform. The shift is proportional to the distance of\n'
            +'     the correlation function\'s maxima.\n'
            +'MAX:\n'
            +'     Determines the shift as the distance between the maxima of\n'
            +'     two peaks\n'
            +'FIT:\n'
            +'     Guesses the most prominent feature in a spectrum and tries\n'
            +'     to fit it with a Gaussian peak. Before the fit is perform, the\n'
            +'     background is substracted. The shift is given by the difference\n'
            +'     of the center of mass between two peaks.\n'
            +'FIT DRV:\n'
            +'     Like FIT, but the fit is performed on the derivate of the\n'
            +'     spectrum. Recommended procedure for XAFS data.')
        self.alignmentMethodComboBox.setToolTip(alignmentMethodToolTip)
        
        # Fill table with data
        self.setDict(llist, ddict)
        self.shiftTab.resizeColumnToContents(self._colLegend)
        self.shiftTab.resizeColumnToContents(self._colShiftLegend)
        
        #Layouts
        topLayout = qt.QHBoxLayout()
        topLayout.addWidget(buttonCalc)
        topLayout.addWidget(qt.HorizontalSpacer())
        topLayout.addWidget(qt.QLabel('Alignment method:'))
        topLayout.addWidget(self.alignmentMethodComboBox)
        topLayout.addWidget(qt.QLabel('Shift method:'))
        topLayout.addWidget(self.shiftMethodComboBox)
        
        buttonLayout = qt.QHBoxLayout()
        buttonLayout.addWidget(buttonSave)
        buttonLayout.addWidget(buttonLoad)
        buttonLayout.addWidget(qt.HorizontalSpacer())
        buttonLayout.addWidget(buttonApply)
        buttonLayout.addWidget(buttonStore)
        buttonLayout.addWidget(buttonCancel)
        
        mainLayout = qt.QVBoxLayout()
        mainLayout.addLayout(topLayout)
        mainLayout.addWidget(self.shiftTab)
        mainLayout.addLayout(buttonLayout)
        mainLayout.setContentsMargins(1,1,1,1)
        self.setLayout(mainLayout)
        
        # Connects
        self.shiftTab.cellChanged.connect(self.validateInput)
        buttonApply.clicked.connect(self.accept)
        buttonCancel.clicked.connect(self.reject)
        buttonStore.clicked.connect(self.store)
        buttonSave.clicked.connect(self.saveDict)
        buttonLoad.clicked.connect(self.loadDict)

        # ..to Plugin instance
        buttonCalc.clicked[()].connect(self.triggerCalculateShift)
        self.alignmentMethodComboBox.activated['QString'].\
                            connect(self.triggerCalculateShift)
Exemple #15
0
    def build(self):
        layout = qt.QVBoxLayout(self)
        layout.setMargin(0)
        layout.setSpacing(0)
        if QTVERSION < '4.0.0':
            buttonGroup = qt.QVButtonGroup("Estimate concentrations", self)
            buttonGroup.setExclusive(True)
        else:
            buttonGroup = qt.QGroupBox(self)
            buttonGroup.layout = qt.QVBoxLayout(buttonGroup)
            buttonGroup.layout.setMargin(0)
            buttonGroup.layout.setSpacing(0)
        layout.addWidget(buttonGroup)
        self.fluxCheckBox = qt.QCheckBox(buttonGroup)
        self.fluxCheckBox.setText("From fundamental parameters")
        wf = qt.QWidget(buttonGroup)
        wf.layout = qt.QHBoxLayout(wf)
        wf.layout.setMargin(0)
        wf.layout.setSpacing(0)
        wf.layout.addWidget(qt.HorizontalSpacer(wf))
        self.fundamentalWidget = FundamentalWidget(wf)
        wf.layout.addWidget(self.fundamentalWidget)
        wf.layout.addWidget(qt.HorizontalSpacer(wf))
        self.matrixCheckBox = qt.QCheckBox(buttonGroup)
        self.matrixCheckBox.setText("From matrix composition")
        self.fluxCheckBox.setChecked(True)

        wm = qt.QWidget(buttonGroup)
        wm.layout = qt.QHBoxLayout(wm)
        wm.layout.setMargin(0)
        wm.layout.setSpacing(0)
        wm.layout.addWidget(qt.HorizontalSpacer(wm))
        referenceLabel = qt.QLabel(wm)
        wm.layout.addWidget(referenceLabel)
        referenceLabel.setText("Matrix Reference Element:")
        #self.referenceCombo=MyQComboBox(wm)
        #self.referenceCombo=qt.QComboBox(wm)
        #self.referenceCombo.setEditable(True)
        #self.referenceCombo.insertItem('Auto')
        self.referenceLine = MyQLineEdit(wm)
        wm.layout.addWidget(self.referenceLine)
        self.referenceLine.setFixedWidth(
            self.referenceLine.fontMetrics().width('#######'))

        wm.layout.addWidget(qt.HorizontalSpacer(wm))
        if QTVERSION < '4.0.0':
            self.connect(self.referenceLine,
                         qt.PYSIGNAL("MyQLineEditSignal"),
                         self._referenceLineSlot)

            self.connect(self.referenceLine,
                         qt.PYSIGNAL("MyQLineEditSignal"),
                         self._referenceLineSlot)
        else:
            self.connect(self.referenceLine,
                         qt.SIGNAL("MyQLineEditSignal"),
                         self._referenceLineSlot)

            self.connect(self.referenceLine,
                         qt.SIGNAL("MyQLineEditSignal"),
                         self._referenceLineSlot)
            buttonGroup.layout.addWidget(self.fluxCheckBox)
            buttonGroup.layout.addWidget(wf)
            buttonGroup.layout.addWidget(self.matrixCheckBox)
            buttonGroup.layout.addWidget(wm)

        #self.fundamentalWidget.setEnabled(False)
        self.attenuatorsCheckBox = qt.QCheckBox(self)
        self.attenuatorsCheckBox.setText("Consider attenuators in calculations")
        self.attenuatorsCheckBox.setDisabled(True)
        #Multilayer secondary excitation
        self.secondaryCheckBox = qt.QCheckBox(self)
        self.secondaryCheckBox.setText("Consider secondary excitation from deeper matrix layers (non intralayer nor above layers)")
        layout.addWidget(self.attenuatorsCheckBox)
        layout.addWidget( self.secondaryCheckBox)
        #XRFMC secondary excitation
        if XRFMC_FLAG:
            self.xrfmcCheckBox = qt.QCheckBox(self)
            self.xrfmcCheckBox.setText("use Monte Carlo code to correct higher order excitations")
            layout.addWidget( self.xrfmcCheckBox)

        #mM checkbox
        self.mMolarCheckBox = qt.QCheckBox(self)
        self.mMolarCheckBox.setText("Elemental mM concentrations (assuming 1 l of solution is 1000 * matrix_density grams)")
        layout.addWidget(self.mMolarCheckBox)

        layout.addWidget(qt.VerticalSpacer(self))
        buttonGroup.show()
        if QTVERSION < '4.0.0':
            self.connect(self.fluxCheckBox, qt.SIGNAL("clicked()"),
                         self.checkBoxSlot)
            self.connect(self.matrixCheckBox, qt.SIGNAL("clicked()"),
                         self.checkBoxSlot)
        else:
            self.connect(self.fluxCheckBox, qt.SIGNAL("clicked()"),
                         self._fluxCheckBoxSlot)
            self.connect(self.matrixCheckBox, qt.SIGNAL("clicked()"),
                         self.checkBoxSlot)
        self.connect(self.attenuatorsCheckBox, qt.SIGNAL("clicked()"),
                     self.checkBoxSlot)
        if XRFMC_FLAG:
            self.connect(self.secondaryCheckBox, qt.SIGNAL("clicked()"),
                         self._secondaryCheckBoxSlot)
            self.connect(self.xrfmcCheckBox, qt.SIGNAL("clicked()"),
                         self._xrfmcCheckBoxSlot)
        else:
            self.connect(self.secondaryCheckBox, qt.SIGNAL("clicked()"),
                         self.checkBoxSlot)
            
        self.connect(self.mMolarCheckBox, qt.SIGNAL("clicked()"),
                     self.checkBoxSlot)

        if QTVERSION < '4.0.0':
            self.connect(self.fundamentalWidget.flux,
                         qt.PYSIGNAL('MyQLineEditSignal'), self._mySignal)
            self.connect(self.fundamentalWidget.area,
                         qt.PYSIGNAL('MyQLineEditSignal'), self._mySignal)
            self.connect(self.fundamentalWidget.time,
                         qt.PYSIGNAL('MyQLineEditSignal'), self._mySignal)
            self.connect(self.fundamentalWidget.distance,
                         qt.PYSIGNAL('MyQLineEditSignal'), self._mySignal)
        else:
            self.connect(self.fundamentalWidget.flux,
                         qt.SIGNAL('MyQLineEditSignal'), self._mySignal)
            self.connect(self.fundamentalWidget.area,
                         qt.SIGNAL('MyQLineEditSignal'), self._mySignal)
            self.connect(self.fundamentalWidget.time,
                         qt.SIGNAL('MyQLineEditSignal'), self._mySignal)
            self.connect(self.fundamentalWidget.distance,
                         qt.SIGNAL('MyQLineEditSignal'), self._mySignal)
Exemple #16
0
    def __init__(self, parent=None, options=[1, 2, 3, 4, 5, 10]):
        qt.QDialog.__init__(self, parent)
        if QTVERSION < '4.0.0':
            self.setCaption("NNMA Configuration Dialog")
        else:
            self.setWindowTitle("NNMA Configuration Dialog")
        self.mainLayout = qt.QVBoxLayout(self)
        self.mainLayout.setMargin(11)
        self.mainLayout.setSpacing(0)

        self.infoButton = qt.QPushButton(self)
        self.infoButton.setAutoDefault(False)
        self.infoButton.setText('About NNMA')
        self.mainLayout.addWidget(self.infoButton)
        self.connect(self.infoButton, qt.SIGNAL('clicked()'), self._showInfo)

        #
        self.methodOptions = qt.QGroupBox(self)
        self.methodOptions.setTitle('NNMA Method to use')
        self.methods = [
            'RRI', 'NNSC', 'NMF', 'SNMF', 'NMFKL', 'FNMAI', 'ALS', 'FastHALS',
            'GDCLS'
        ]
        self.methodOptions.mainLayout = qt.QGridLayout(self.methodOptions)
        self.methodOptions.mainLayout.setMargin(0)
        self.methodOptions.mainLayout.setSpacing(2)
        self.buttonGroup = qt.QButtonGroup(self.methodOptions)
        i = 0
        for item in self.methods:
            rButton = qt.QRadioButton(self.methodOptions)
            self.methodOptions.mainLayout.addWidget(rButton, 0, i)
            #self.l.setAlignment(rButton, qt.Qt.AlignHCenter)
            if i == 1:
                rButton.setChecked(True)
            rButton.setText(item)
            self.buttonGroup.addButton(rButton)
            self.buttonGroup.setId(rButton, i)
            i += 1
        self.connect(self.buttonGroup,
                     qt.SIGNAL('buttonPressed(QAbstractButton *)'), self._slot)

        self.mainLayout.addWidget(self.methodOptions)

        # NNMA configuration parameters
        self.nnmaConfiguration = qt.QGroupBox(self)
        self.nnmaConfiguration.setTitle('NNMA Configuration')
        self.nnmaConfiguration.mainLayout = qt.QGridLayout(
            self.nnmaConfiguration)
        self.nnmaConfiguration.mainLayout.setMargin(0)
        self.nnmaConfiguration.mainLayout.setSpacing(2)
        label = qt.QLabel(self.nnmaConfiguration)
        label.setText('Tolerance (0<eps<1000:')
        self._tolerance = qt.QLineEdit(self.nnmaConfiguration)
        validator = qt.QDoubleValidator(self._tolerance)
        self._tolerance.setValidator(validator)
        self._tolerance._validator = validator
        self._tolerance.setText("0.001")
        self.nnmaConfiguration.mainLayout.addWidget(label, 0, 0)
        self.nnmaConfiguration.mainLayout.addWidget(self._tolerance, 0, 1)
        label = qt.QLabel(self.nnmaConfiguration)
        label.setText('Maximum iterations:')
        self._maxIterations = qt.QSpinBox(self.nnmaConfiguration)
        self._maxIterations.setMinimum(1)
        self._maxIterations.setMaximum(1000)
        self._maxIterations.setValue(100)
        self.nnmaConfiguration.mainLayout.addWidget(label, 1, 0)
        self.nnmaConfiguration.mainLayout.addWidget(self._maxIterations, 1, 1)
        self.mainLayout.addWidget(self.nnmaConfiguration)

        #built in speed options
        self.speedOptions = qt.QGroupBox(self)
        self.speedOptions.setTitle("Speed Options")
        self.speedOptions.mainLayout = qt.QGridLayout(self.speedOptions)
        self.speedOptions.mainLayout.setMargin(0)
        self.speedOptions.mainLayout.setSpacing(2)
        labelPC = qt.QLabel(self)
        labelPC.setText("Number of PC:")
        self.nPC = qt.QSpinBox(self.speedOptions)
        self.nPC.setMinimum(0)
        self.nPC.setValue(10)
        self.nPC.setMaximum(40)

        self.binningLabel = qt.QLabel(self.speedOptions)
        self.binningLabel.setText("Spectral Binning:")
        self.binningCombo = qt.QComboBox(self.speedOptions)
        for option in options:
            self.binningCombo.addItem("%d" % option)
        self.speedOptions.mainLayout.addWidget(labelPC, 0, 0)
        self.speedOptions.mainLayout.addWidget(self.nPC, 0, 1)
        #self.speedOptions.mainLayout.addWidget(qt.HorizontalSpacer(self), 0, 2)
        self.speedOptions.mainLayout.addWidget(self.binningLabel, 1, 0)
        self.speedOptions.mainLayout.addWidget(self.binningCombo, 1, 1)
        self.binningCombo.setEnabled(True)

        #the OK button
        hbox = qt.QWidget(self)
        hboxLayout = qt.QHBoxLayout(hbox)
        hboxLayout.setMargin(0)
        hboxLayout.setSpacing(0)
        self.okButton = qt.QPushButton(hbox)
        self.okButton.setAutoDefault(False)
        self.okButton.setText("Accept")
        hboxLayout.addWidget(qt.HorizontalSpacer(hbox))
        hboxLayout.addWidget(self.okButton)
        self.dismissButton = qt.QPushButton(hbox)
        self.dismissButton.setAutoDefault(False)
        self.dismissButton.setText("Dismiss")
        hboxLayout.addWidget(qt.HorizontalSpacer(hbox))
        hboxLayout.addWidget(self.dismissButton)
        hboxLayout.addWidget(qt.HorizontalSpacer(hbox))
        self.mainLayout.addWidget(self.speedOptions)
        self.mainLayout.addWidget(hbox)
        self.connect(self.okButton, qt.SIGNAL("clicked()"), self.accept)
        self.connect(self.dismissButton, qt.SIGNAL("clicked()"), self.reject)

        self._infoDocument = qt.QTextEdit()
        self._infoDocument.setReadOnly(True)
        self._infoDocument.setText(NNMAModule.__doc__)
        self._infoDocument.hide()
        self.mainLayout.addWidget(self._infoDocument)
    def __init__(self, parent=None, name="Compound Tab",
                    layerindex=None, compoundlist=None):
        if layerindex is None:
            layerindex = 0
        if compoundlist is None:
            compoundlist = []
            for i in range(10):
                compoundlist.append("Compound%d%d" % (layerindex, i))
        qt.QWidget.__init__(self, parent)
        layout = qt.QVBoxLayout(self)

        grid = qt.QWidget(self)
        if QTVERSION < '4.0.0':
            gl = qt.QGridLayout(grid, 1, 1, 11, 2, "gridlayout")
        else:
            gl = Q3GridLayout(grid)
            gl.setMargin(11)
            gl.setSpacing(2)

        # Layer name
        nameLabel = qt.QLabel(grid)
        nameLabel.setText("Name")

        self.nameLine = qt.QLineEdit(grid)
        self.nameLine.setText("Compound fitting layer %d" % layerindex)

        gl.addWidget(nameLabel, 0, 0)
        gl.addMultiCellWidget(self.nameLine, 0, 0, 1, 5)

        Line = qt.QFrame(grid)
        Line.setFrameShape(qt.QFrame.HLine)
        Line.setFrameShadow(qt.QFrame.Sunken)
        Line.setFrameShape(qt.QFrame.HLine)
        gl.addMultiCellWidget(Line, 1, 1, 0, 5)

        #labels
        fixedLabel = qt.QLabel(grid)
        fixedLabel_font = qt.QFont(fixedLabel.font())
        fixedLabel_font.setItalic(1)
        fixedLabel.setFont(fixedLabel_font)
        fixedLabel.setText(str("Fixed"))
        if QTVERSION < '4.0.0':
            fixedLabel.setAlignment(qt.QLabel.AlignVCenter)
            fixedLabel.setAlignment(qt.QLabel.AlignHCenter)
        else:
            fixedLabel.setAlignment(qt.Qt.AlignVCenter)

        valueLabel = qt.QLabel(grid)
        valueLabel_font = qt.QFont(valueLabel.font())
        valueLabel_font.setItalic(1)
        valueLabel.setFont(valueLabel_font)
        valueLabel.setText(str("Value"))
        valueLabel.setAlignment(qt.QLabel.AlignCenter)


        errorLabel = qt.QLabel(grid)
        errorLabel_font = qt.QFont(errorLabel.font())
        errorLabel_font.setItalic(1)
        errorLabel.setFont(errorLabel_font)
        errorLabel.setText(str("Error"))
        errorLabel.setAlignment(qt.QLabel.AlignCenter)

        gl.addWidget(fixedLabel, 2, 2)
        gl.addWidget(valueLabel, 2, 3)
        gl.addWidget(errorLabel, 2, 5)
        
        #density
        densityLabel = qt.QLabel(grid)
        densityLabel.setText("Density")
        
        self.densityCheck = qt.QCheckBox(grid)
        self.densityCheck.setText(str(""))

        self.densityValue = qt.QLineEdit(grid)
        densitySepLabel = qt.QLabel(grid)
        densitySepLabel_font = qt.QFont(densitySepLabel.font())
        densitySepLabel_font.setBold(1)
        densitySepLabel.setFont(densitySepLabel_font)
        densitySepLabel.setText(str("+/-"))

        self.densityError = qt.QLineEdit(grid)

        gl.addWidget(densityLabel, 3, 0)
        gl.addWidget(qt.HorizontalSpacer(grid), 3, 1)
        gl.addWidget(self.densityCheck, 3, 2)
        gl.addWidget(self.densityValue, 3, 3)
        gl.addWidget(densitySepLabel, 3, 4)
        gl.addWidget(self.densityError, 3, 5)
        
        #thickness
        thicknessLabel = qt.QLabel(grid)
        thicknessLabel.setText("Thickness")
        
        self.thicknessCheck = qt.QCheckBox(grid)
        self.thicknessCheck.setText(str(""))

        self.thicknessValue = qt.QLineEdit(grid)
        thicknessSepLabel = qt.QLabel(grid)
        thicknessSepLabel_font = qt.QFont(thicknessSepLabel.font())
        thicknessSepLabel_font.setBold(1)
        thicknessSepLabel.setFont(thicknessSepLabel_font)
        thicknessSepLabel.setText(str("+/-"))

        self.thicknessError = qt.QLineEdit(grid)

        gl.addWidget(thicknessLabel, 4, 0)
        gl.addWidget(self.thicknessCheck, 4, 2)
        gl.addWidget(self.thicknessValue, 4, 3)
        gl.addWidget(thicknessSepLabel, 4, 4)
        gl.addWidget(self.thicknessError, 4, 5)
        
        Line = qt.QFrame(grid)
        Line.setFrameShape(qt.QFrame.HLine)
        Line.setFrameShadow(qt.QFrame.Sunken)
        Line.setFrameShape(qt.QFrame.HLine)
        gl.addMultiCellWidget(Line, 5, 5, 0, 5)
        
        layout.addWidget(grid)
        """
        self.matrixGeometry = MatrixEditor.MatrixEditor(self,"tabMatrix",
                                   table=False, orientation="horizontal",
                                   density=False, thickness=False,
                                   size="image2")
        layout.addWidget(self.matrixGeometry)
        
        text  ="This matrix definition will only be "
        text +="considered if Matrix is selected and material is set to "
        text +="MULTILAYER in the ATTENUATORS tab.\n  "
        self.matrixInfo  = qt.QLabel(self)
        layout.addWidget(self.matrixInfo)
        self.matrixInfo.setText(text)
        """ 
        self.matrixTable = AttenuatorsTableWidget(self, name,
                                                  attenuators=compoundlist,
                                                  matrixmode=False,
                                                  compoundmode=True,
                                                  layerindex=layerindex)
        layout.addWidget(self.matrixTable)
    def __init__(self,
                 parent,
                 legends,
                 motorValues,
                 plotWindow=None,
                 actions=[],
                 nSelectors=2):
        """
        legends            List contains Plotnames
        motorValues     List contains names and values of the motors
        """
        CloseEventNotifyingWidget.CloseEventNotifyingWidget.__init__(
            self, parent)
        self.setWindowTitle("Sort Plots Window")

        self.legendList = legends
        self.motorsList = motorValues
        self.motorNamesList = [''] + self.getAllMotorNames()
        self.motorNamesList.sort()
        self.numCurves = len(legends)
        self.actionList = actions
        self.cBoxList = []
        self.ScanWindowA = None
        self.ScanWindowB = None
        self.closeWidget = CloseEventNotifyingWidget.CloseEventNotifyingWidget(
        )
        self.plotWindow = plotWindow if plotWindow else None

        buttonPerfom = qt.QPushButton("Perform action", self)
        buttonProcessA = qt.QPushButton("Process as A", self)
        buttonProcessB = qt.QPushButton("Process as B", self)
        updatePixmap = qt.QPixmap(IconDict["reload"])
        buttonUpdate = qt.QPushButton(qt.QIcon(updatePixmap), '', self)

        cBoxLabel = qt.QLabel(qt.QString('Select motor:'), self)
        for i in range(nSelectors):
            cBox = qt.QComboBox(self)
            cBox.addItems(self.motorNamesList)
            cBox.activated['QString'].connect(self.updateTree)
            self.cBoxList += [cBox]
        self.actionCBox = qt.QComboBox(self)

        self.list = SortPlotsTreeWidget(self)
        labels = ['Legend'] + nSelectors * ['']
        ncols = len(labels)
        self.list.setColumnCount(ncols)
        self.list.setHeaderLabels(labels)
        self.list.setSortingEnabled(True)
        self.list.setSelectionMode(qt.QAbstractItemView.ExtendedSelection)

        mainLayout = qt.QGridLayout(self)
        cBoxLayout = qt.QHBoxLayout(None)
        buttonLayout = qt.QHBoxLayout(None)
        mainLayout.setContentsMargins(1, 1, 1, 1)
        mainLayout.setSpacing(2)
        mainLayout.addLayout(cBoxLayout, 0, 0)
        mainLayout.addLayout(buttonLayout, 2, 0)
        self.setLayout(mainLayout)

        cBoxLayout.addWidget(cBoxLabel)
        for cBox in self.cBoxList:
            cBoxLayout.addWidget(cBox)
        cBoxLayout.addWidget(qt.HorizontalSpacer(self))
        cBoxLayout.addWidget(buttonUpdate)
        mainLayout.addWidget(self.list, 1, 0)
        buttonLayout.addWidget(buttonProcessA)
        buttonLayout.addWidget(buttonProcessB)
        buttonLayout.addWidget(qt.HorizontalSpacer(self))
        buttonLayout.addWidget(self.actionCBox)
        buttonLayout.addWidget(buttonPerfom)
        self.resize(500, 300)

        buttonPerfom.clicked.connect(self.performAction)
        buttonProcessA.clicked.connect(self.processAsA)
        buttonProcessB.clicked.connect(self.processAsB)
        buttonUpdate.clicked.connect(self.updatePlots)

        self.updateTree()
        self.updateActionList([('Invert selection', self.list.invertSelection),
                               ('Process as A', self.processAsA),
                               ('Process as B', self.processAsB),
                               ('Remove curve(s)', self.removeCurve_)])
    def build(self, comments="True", height=3):
        layout = qt.QVBoxLayout(self)
        layout.setMargin(0)
        layout.setSpacing(0)
        self.__comments = comments
        commentsHBox = qt.QWidget(self)
        layout.addWidget(commentsHBox)
        commentsHBoxLayout = qt.QHBoxLayout(commentsHBox)
        commentsHBoxLayout.setMargin(0)
        commentsHBoxLayout.setSpacing(0)

        tableContainer = qt.QWidget(commentsHBox)
        commentsHBoxLayout.addWidget(tableContainer)
        tableContainerLayout = qt.QVBoxLayout(tableContainer)
        tableContainerLayout.setMargin(0)
        tableContainerLayout.setSpacing(0)
        self.__hboxTableContainer = qt.QWidget(tableContainer)
        hbox = self.__hboxTableContainer
        tableContainerLayout.addWidget(hbox)
        hboxLayout = qt.QHBoxLayout(hbox)
        hboxLayout.setMargin(0)
        hboxLayout.setSpacing(0)
        numberLabel = qt.QLabel(hbox)
        hboxLayout.addWidget(numberLabel)
        numberLabel.setText("Number  of  Compounds:")
        if QTVERSION < '4.0.0':
            numberLabel.setAlignment(qt.QLabel.WordBreak
                                     | qt.QLabel.AlignVCenter)
        else:
            numberLabel.setAlignment(qt.Qt.AlignVCenter)
        self.__numberSpin = qt.QSpinBox(hbox)
        hboxLayout.addWidget(self.__numberSpin)
        if QTVERSION < '4.0.0':
            self.__numberSpin.setMinValue(1)
            self.__numberSpin.setMaxValue(100)
        else:
            self.__numberSpin.setMinimum(1)
            self.__numberSpin.setMaximum(100)
        self.__numberSpin.setValue(1)
        if QTVERSION < '4.0.0':
            self.__table = qttable.QTable(tableContainer)
            self.__table.setNumRows(1)
            self.__table.setNumCols(2)
        else:
            self.__table = qt.QTableWidget(tableContainer)
            self.__table.setRowCount(1)
            self.__table.setColumnCount(2)
        tableContainerLayout.addWidget(self.__table)
        self.__table.setMinimumHeight(
            (height) * self.__table.horizontalHeader().sizeHint().height())
        self.__table.setMaximumHeight(
            (height) * self.__table.horizontalHeader().sizeHint().height())
        self.__table.setMinimumWidth(1 * self.__table.sizeHint().width())
        self.__table.setMaximumWidth(1 * self.__table.sizeHint().width())
        #self.__table.setSizePolicy(qt.QSizePolicy(qt.QSizePolicy.Fixed,qt.QSizePolicy.Fixed))
        if QTVERSION < '4.0.0':
            self.__table.setVScrollBarMode(self.__table.AlwaysOn)
            self.__table.horizontalHeader().setClickEnabled(False)
            qt.QHeader.setLabel(self.__table.horizontalHeader(), 0, "Material")
            qt.QHeader.setLabel(self.__table.horizontalHeader(), 1,
                                "Mass Fraction")
            self.__table.verticalHeader().hide()
            self.__table.setLeftMargin(0)
        else:
            labels = ["Material", "Mass Fraction"]
            for i in range(len(labels)):
                item = self.__table.horizontalHeaderItem(i)
                if item is None:
                    item = qt.QTableWidgetItem(labels[i],
                                               qt.QTableWidgetItem.Type)
                self.__table.setHorizontalHeaderItem(i, item)
        if QTVERSION < '4.1.0':
            self.__table.setSelectionMode(qttable.QTable.NoSelection)
        else:
            self.__table.setSelectionMode(qt.QTableWidget.NoSelection)
        if self.__comments:
            vbox = qt.QWidget(commentsHBox)
            commentsHBoxLayout.addWidget(vbox)
            vboxLayout = qt.QVBoxLayout(vbox)

            #default thickness and density
            self.__gridVBox = qt.QWidget(vbox)
            grid = self.__gridVBox
            vboxLayout.addWidget(grid)
            if QTVERSION < '4.0.0':
                gridLayout = qt.QGridLayout(grid, 2, 2, 11, 4)
            else:
                gridLayout = qt.QGridLayout(grid)
                gridLayout.setMargin(11)
                gridLayout.setSpacing(4)

            densityLabel = qt.QLabel(grid)
            gridLayout.addWidget(densityLabel, 0, 0)
            densityLabel.setText("Default Density (g/cm3):")
            if QTVERSION < '4.0.0':
                densityLabel.setAlignment(qt.QLabel.WordBreak
                                          | qt.QLabel.AlignVCenter)
                self.__densityLine = MyQLineEdit(grid)
            else:
                densityLabel.setAlignment(qt.Qt.AlignVCenter)
                self.__densityLine = qt.QLineEdit(grid)
                validator = qt.QDoubleValidator(self.__densityLine)
                self.__densityLine.setValidator(validator)

            self.__densityLine.setReadOnly(False)
            gridLayout.addWidget(self.__densityLine, 0, 1)

            thicknessLabel = qt.QLabel(grid)
            gridLayout.addWidget(thicknessLabel, 1, 0)
            thicknessLabel.setText("Default  Thickness  (cm):")
            if QTVERSION < '4.0.0':
                thicknessLabel.setAlignment(qt.QLabel.WordBreak
                                            | qt.QLabel.AlignVCenter)
                self.__thicknessLine = MyQLineEdit(grid)
            else:
                thicknessLabel.setAlignment(qt.Qt.AlignVCenter)
                self.__thicknessLine = qt.QLineEdit(grid)
                validator = qt.QDoubleValidator(self.__thicknessLine)
                self.__thicknessLine.setValidator(validator)

            gridLayout.addWidget(self.__thicknessLine, 1, 1)
            self.__thicknessLine.setReadOnly(False)
            if QTVERSION < '4.0.0':
                self.connect(self.__densityLine, qt.SIGNAL('returnPressed()'),
                             self.__densitySlot)
                self.connect(self.__thicknessLine,
                             qt.SIGNAL('returnPressed()'),
                             self.__thicknessSlot)
            else:
                self.connect(self.__densityLine,
                             qt.SIGNAL('editingFinished()'),
                             self.__densitySlot)
                self.connect(self.__thicknessLine,
                             qt.SIGNAL('editingFinished()'),
                             self.__thicknessSlot)

            if QTVERSION > '4.0.0':
                self.__transmissionButton = qt.QPushButton(grid)
                self.__transmissionButton.setText('Material Transmission')
                gridLayout.addWidget(self.__transmissionButton, 2, 0)
                self.__massAttButton = qt.QPushButton(grid)
                self.__massAttButton.setText('Mass Att. Coefficients')
                gridLayout.addWidget(self.__massAttButton, 2, 1)
                self.__transmissionButton.setAutoDefault(False)
                self.__massAttButton.setAutoDefault(False)
                self.connect(self.__transmissionButton, qt.SIGNAL('clicked()'),
                             self.__transmissionSlot)
                self.connect(self.__massAttButton, qt.SIGNAL('clicked()'),
                             self.__massAttSlot)
            vboxLayout.addWidget(qt.VerticalSpacer(vbox))

        if self.__comments:
            #comment
            nameHBox = qt.QWidget(self)
            nameHBoxLayout = qt.QHBoxLayout(nameHBox)
            nameLabel = qt.QLabel(nameHBox)
            nameHBoxLayout.addWidget(nameLabel)
            nameLabel.setText("Material Name/Comment:")
            if QTVERSION < '4.0.0':
                nameLabel.setAlignment(qt.QLabel.WordBreak
                                       | qt.QLabel.AlignVCenter)
            else:
                nameLabel.setAlignment(qt.Qt.AlignVCenter)
            nameHBoxLayout.addWidget(qt.HorizontalSpacer(nameHBox))
            if QTVERSION < '4.0.0':
                self.__nameLine = MyQLineEdit(nameHBox)
                self.connect(self.__nameLine, qt.SIGNAL('returnPressed()'),
                             self.__nameLineSlot)
            else:
                self.__nameLine = qt.QLineEdit(nameHBox)
                self.connect(self.__nameLine, qt.SIGNAL('editingFinished()'),
                             self.__nameLineSlot)
            nameHBoxLayout.addWidget(self.__nameLine)
            self.__nameLine.setReadOnly(False)
            longtext = "En un lugar de La Mancha, de cuyo nombre no quiero acordarme ..."
            self.__nameLine.setFixedWidth(
                self.__nameLine.fontMetrics().width(longtext))
            layout.addWidget(nameHBox)

        self.connect(self.__numberSpin, qt.SIGNAL("valueChanged(int)"),
                     self.__numberSpinChanged)
        if QTVERSION < '4.0.0':
            self.connect(self.__table, qt.SIGNAL("valueChanged(int,int)"),
                         self.__tableSlot)
            self.connect(self.__table, qt.SIGNAL("currentChanged(int,int)"),
                         self.__tableSlot2)
        else:
            self.connect(self.__table, qt.SIGNAL("cellChanged(int,int)"),
                         self.__tableSlot)
            self.connect(self.__table, qt.SIGNAL("cellEntered(int,int)"),
                         self.__tableSlot2)
Exemple #20
0
    def __init__(self, parent=None, **kw):
        qt.QDialog.__init__(self, parent)
        self.setWindowTitle("Matplotlib preview - Resize to your taste")
        self.mainLayout = qt.QGridLayout(self)
        self.mainLayout.setMargin(0)
        self.mainLayout.setSpacing(0)
        self._lastGoodSize = None

        self.axesLabelsWidget = qt.QWidget(self)
        layout = qt.QHBoxLayout(self.axesLabelsWidget)
        layout.setMargin(0)
        layout.setSpacing(2)
        xLabelLabel = qt.QLabel(self.axesLabelsWidget)
        xLabelLabel.setText("X Axis Label: ")
        self.xLabelLine = qt.QLineEdit(self.axesLabelsWidget)
        yLabelLabel = qt.QLabel(self.axesLabelsWidget)
        yLabelLabel.setText("Y Axis Label: ")
        self.yLabelLine = qt.QLineEdit(self.axesLabelsWidget)
        layout.addWidget(xLabelLabel)
        layout.addWidget(self.xLabelLine)
        layout.addWidget(yLabelLabel)
        layout.addWidget(self.yLabelLine)


        self.curveTable = MatplotlibCurveTable(self)
        self.plot = QPyMcaMatplotlibSave(self, **kw)
        self.plot.setCurveTable(self.curveTable)
        self.actionsWidget = qt.QWidget(self)
        layout = qt.QHBoxLayout(self.actionsWidget)
        layout.setMargin(0)
        layout.setSpacing(2)
        self.doNotShowAgain = qt.QCheckBox(self.actionsWidget)
        self.doNotShowAgain.setChecked(False)
        self.doNotShowAgain.setText("Don't show again this dialog")

        self.acceptButton = qt.QPushButton(self.actionsWidget)
        self.acceptButton.setText("Accept")
        self.acceptButton.setAutoDefault(False)
        self.dismissButton = qt.QPushButton(self.actionsWidget)
        self.dismissButton.setText("Dismiss")
        self.dismissButton.setAutoDefault(False)
        layout.addWidget(self.doNotShowAgain)
        layout.addWidget(qt.HorizontalSpacer(self.actionsWidget))
        layout.addWidget(self.acceptButton)
        layout.addWidget(self.dismissButton)
        horizontal = False
        if horizontal:
            self.mainLayout.addWidget(self.axesLabelsWidget, 0, 0)
            self.mainLayout.addWidget(self.plot, 1, 0)
            self.mainLayout.addWidget(self.curveTable, 1, 1)
            self.mainLayout.addWidget(self.actionsWidget, 2, 0, 1, 2)
            self.mainLayout.setColumnStretch(0, 1)
        else:
            self.mainLayout.addWidget(self.axesLabelsWidget, 0, 0)
            self.mainLayout.addWidget(self.curveTable, 1, 0)
            self.mainLayout.addWidget(self.plot, 2, 0)
            self.mainLayout.addWidget(self.actionsWidget, 3, 0)
            self.mainLayout.setRowStretch(1, 1)

        self.connect(self.xLabelLine,
                     qt.SIGNAL("editingFinished()"),
                     self._xLabelSlot)
        
        self.connect(self.yLabelLine,
                     qt.SIGNAL("editingFinished()"),
                     self._yLabelSlot)


        self.connect(self.acceptButton,
                     qt.SIGNAL("clicked()"),
                     self.accept)
        
        self.connect(self.dismissButton,
                     qt.SIGNAL("clicked()"),
                     self.reject)
Exemple #21
0
    def __init__(self,
                 parent=None,
                 name="FitPeakSelect",
                 peakdict={},
                 fl=0,
                 energyTable=None):
        qt.QWidget.__init__(self, parent)

        if QTVERSION < '4.0.0':
            self.setSizePolicy(
                qt.QSizePolicy(qt.QSizePolicy.Minimum, qt.QSizePolicy.Minimum))

        layout = qt.QVBoxLayout(self)
        layout.setMargin(0)
        layout.setSpacing(10)
        hbox = qt.QWidget(self)
        hboxLayout = qt.QHBoxLayout(hbox)
        hboxLayout.setMargin(0)
        hboxLayout.setSpacing(20)
        hboxLayout.addWidget(qt.HorizontalSpacer(hbox))
        l1 = MyQLabel(hbox, bold=True, color=qt.QColor(0, 0, 0))
        hboxLayout.addWidget(l1)

        self.energyValue = None
        if energyTable is not None:
            text = '<b><nobr>Excitation Energy (keV)</nobr></b>'
            l1.setFixedWidth(l1.fontMetrics().width("##" + text + "####"))
            l1.setText(text)
            self.energyTable = energyTable
            add = 0
            self.energy = MyQLabel(hbox)
            hboxLayout.addWidget(self.energy)
            self.energy.setFixedWidth(
                self.energy.fontMetrics().width('########.###'))
            self.energy.setAlignment(qt.Qt.AlignLeft)
            #self.energy.setForegroundColor(qt.Qt.red)
        else:
            l1.setText('<b><nobr>Excitation Energy (keV)</nobr></b>')
            self.energyTable = EnergyTable.EnergyTable(self)
            add = 1
            self.energy = qt.QLineEdit(hbox)
            hboxLayout.addWidget(self.energy)
            self.energy.setFixedWidth(
                self.energy.fontMetrics().width('########.###'))
            self.energyButton = qt.QPushButton(hbox)
            hboxLayout.addWidget(self.energyButton)
            self.energyButton.setText("Update")
            self.connect(self.energyButton, qt.SIGNAL('clicked()'),
                         self._energyClicked)

        hboxLayout.addWidget(qt.HorizontalSpacer(hbox))
        layout.addSpacing(20)
        layout.addWidget(hbox)

        self.table = QPeriodicTable(self)
        line = qt.QFrame(self)
        line.setFrameShape(qt.QFrame.HLine)
        line.setFrameShadow(qt.QFrame.Sunken)

        self.peaks = PeakButtonList(self)
        self.peaks.setDisabled(['K', 'Ka', 'Kb', 'L', 'L1', 'L2', 'L3', 'M'])

        if QTVERSION < '4.0.0':
            self.connect(self.energyTable, qt.PYSIGNAL("EnergyTableSignal"),
                         self._energyTableAction)
            self.connect(self.table, qt.PYSIGNAL("elementClicked"),
                         self.elementClicked)
            self.connect(self.peaks, qt.PYSIGNAL("selectionChanged"),
                         self.peakSelectionChanged)
        else:
            self.connect(self.energyTable, qt.SIGNAL("EnergyTableSignal"),
                         self._energyTableAction)
            self.connect(self.table, qt.SIGNAL("elementClicked"),
                         self.elementClicked)
            self.connect(self.peaks, qt.SIGNAL("selectionChanged"),
                         self.peakSelectionChanged)
            #Reset All
            self.resetAllButton = qt.QPushButton(self.peaks)
            palette = qt.QPalette(self.resetAllButton.palette())
            role = self.resetAllButton.foregroundRole()
            palette.setColor(role, qt.Qt.red)
            self.resetAllButton.setPalette(palette)
            self.resetAllButton.setText("Reset All")
            self.peaks.layout().addWidget(self.resetAllButton)

            self.connect(self.resetAllButton, qt.SIGNAL("clicked()"),
                         self.__resetAll)

        layout.addWidget(self.table)
        layout.addWidget(line)
        layout.addWidget(self.peaks)
        if add: layout.addWidget(self.energyTable)
        layout.addStretch(1)

        self.current = None
        self.setSelection(peakdict)
Exemple #22
0
    def __init__(self, parent=None):
        qt.QGroupBox.__init__(self, parent)
        self.setTitle("Fit Control")
        self.mainLayout = qt.QGridLayout(self)
        self.mainLayout.setMargin(2)
        self.mainLayout.setSpacing(2)

        row = 0
        #linear fit
        self.fitAlgorithmLabel = qt.QLabel(self)
        self.fitAlgorithmLabel.setText("Fit algorithm")
        self.fitAlgorithmCombo = qt.QComboBox(self)
        self.fitAlgorithmCombo.addItem(str("Levenberg-Marquardt"))
        self.fitAlgorithmCombo.addItem(str("Linear Fit"))

        self.mainLayout.addWidget(self.fitAlgorithmLabel, row, 0)
        self.mainLayout.addWidget(qt.HorizontalSpacer(self), row, 1)
        self.mainLayout.addWidget(self.fitAlgorithmCombo, row, 3)
        row += 1

        #weighting
        self.weightLabel = qt.QLabel(self)
        self.weightLabel.setText("Statistical weighting of data")
        self.weightCombo = qt.QComboBox(self)
        self.weightCombo.addItem(str("NO Weight"))
        self.weightCombo.addItem(str("Poisson (1/Y)"))

        self.mainLayout.addWidget(self.weightLabel, row, 0)
        self.mainLayout.addWidget(qt.HorizontalSpacer(self), row, 1)
        self.mainLayout.addWidget(self.weightCombo, row, 3)
        row += 1

        #function estimation policy
        self.functionEstimationLabel = qt.QLabel(self)
        self.functionEstimationLabel.setText("Function estimation policy")
        self.functionEstimationCombo = qt.QComboBox(self)
        self.functionEstimationCombo.addItem(str("Use configuration"))
        self.functionEstimationCombo.addItem(str("Estimate once"))
        self.functionEstimationCombo.addItem(str("Estimate always"))
        self.functionEstimationCombo.setCurrentIndex(2)

        self.mainLayout.addWidget(self.functionEstimationLabel, row, 0)
        self.mainLayout.addWidget(self.functionEstimationCombo, row, 3)
        row += 1

        #background estimation policy
        self.backgroundEstimationLabel = qt.QLabel(self)
        text = "Background estimation policy"
        self.backgroundEstimationLabel.setText(text)
        self.backgroundEstimationCombo = qt.QComboBox(self)
        self.backgroundEstimationCombo.addItem(str("Use configuration"))
        self.backgroundEstimationCombo.addItem(str("Estimate once"))
        self.backgroundEstimationCombo.addItem(str("Estimate always"))
        self.backgroundEstimationCombo.setCurrentIndex(2)

        self.mainLayout.addWidget(self.backgroundEstimationLabel, row, 0)
        self.mainLayout.addWidget(self.backgroundEstimationCombo, row, 3)
        row += 1

        #number of iterations
        self.iterLabel = qt.QLabel(self)
        self.iterLabel.setText(str("Maximum number of fit iterations"))
        self.iterSpin = qt.QSpinBox(self)
        self.iterSpin.setMinimum(1)
        self.iterSpin.setMaximum(10000)
        self.iterSpin.setValue(10)
        self.mainLayout.addWidget(self.iterLabel, row, 0)
        self.mainLayout.addWidget(qt.HorizontalSpacer(self), row, 1)
        self.mainLayout.addWidget(self.iterSpin, row, 3)
        row += 1

        #chi square handling
        self.chi2Label = qt.QLabel(self)
        self.chi2Label.setText(str("Minimum chi^2 difference (%)"))
        if 0:
            self.chi2Value = qt.QLineEdit(self)
            self.chi2Value._v = qt.QDoubleValidator(self.chi2Value)
            self.chi2Value.setValidator(self.chi2Value._v)
            self.chi2Value.setText(str("0.001"))
        else:
            self.chi2Value = qt.QDoubleSpinBox(self)
            self.chi2Value.setDecimals(4)
            self.chi2Value.setMinimum(0.0001)
            self.chi2Value.setMaximum(100.)
            self.chi2Value.setSingleStep(0.0001)
            self.chi2Value.setValue(0.001)

        self.mainLayout.addWidget(self.chi2Label, row, 0)
        self.mainLayout.addWidget(qt.HorizontalSpacer(self), row, 1)
        self.mainLayout.addWidget(self.chi2Value, row, 3)
        row += 1

        #fitting region
        self.regionTopLine = qt.QFrame(self)
        self.regionTopLine.setFrameShape(qt.QFrame.HLine)
        self.regionTopLine.setFrameShadow(qt.QFrame.Sunken)
        self.regionTopLine.setFrameShape(qt.QFrame.HLine)

        self.regionCheckBox = qt.QCheckBox(self)
        self.regionCheckBox.setText(str("Limit fitting region to :"))

        self.firstLabel = qt.QLabel(self)
        firstLabel_font = qt.QFont(self.firstLabel.font())
        firstLabel_font.setItalic(1)
        self.firstLabel.setFont(firstLabel_font)
        self.firstLabel.setText(str("First X Value "))
        self.firstLabel.setAlignment(qt.Qt.AlignVCenter | qt.Qt.AlignRight)
        self.firstValue = qt.QLineEdit(self)
        self.firstValue._v = qt.QDoubleValidator(self.firstValue)
        self.firstValue.setValidator(self.firstValue._v)
        self.firstValue.setText(str("0."))

        self.lastLabel = qt.QLabel(self)
        lastLabel_font = qt.QFont(self.lastLabel.font())
        lastLabel_font.setItalic(1)
        self.lastLabel.setFont(lastLabel_font)
        self.lastLabel.setText(str("Last X Value "))
        self.lastLabel.setAlignment(qt.Qt.AlignVCenter | qt.Qt.AlignRight)
        self.lastValue = qt.QLineEdit(self)
        self.lastValue._v = qt.QDoubleValidator(self.lastValue)
        self.lastValue.setValidator(self.lastValue._v)
        self.lastValue.setText(str("1000."))

        self.regionBottomLine = qt.QFrame(self)
        self.regionBottomLine.setFrameShape(qt.QFrame.HLine)
        self.regionBottomLine.setFrameShadow(qt.QFrame.Sunken)
        self.regionBottomLine.setFrameShape(qt.QFrame.HLine)

        self.mainLayout.addWidget(self.regionTopLine, row, 0, 1, 4)
        row += 1
        self.mainLayout.addWidget(self.regionCheckBox, row, 0)
        self.mainLayout.addWidget(self.firstLabel, row, 1)
        self.mainLayout.addWidget(self.firstValue, row, 3)
        row += 1
        self.mainLayout.addWidget(self.lastLabel, row, 1)
        self.mainLayout.addWidget(self.lastValue, row, 3)
        row += 1
        self.mainLayout.addWidget(self.regionBottomLine, row, 0, 1, 4)
        row += 1
    def _buildToolBar(self):
        self.toolBar = qt.QWidget(self)
        self.toolBarLayout = qt.QHBoxLayout(self.toolBar)
        self.toolBarLayout.setMargin(0)
        self.toolBarLayout.setSpacing(2)
        self.layout().insertWidget(0, self.toolBar)
        #Autoscale
        self._addToolButton(self.zoomResetIcon, self._zoomReset,
                            'Auto-Scale the Graph')

        #y Autoscale
        self.yAutoScaleButton = self._addToolButton(
            self.yAutoIcon,
            self._yAutoScaleToggle,
            'Toggle Autoscale Y Axis (On/Off)',
            toggle=True)
        if QTVERSION < '4.0.0':
            self.yAutoScaleButton.setState(qt.QButton.On)
        else:
            self.yAutoScaleButton.setChecked(True)
            self.yAutoScaleButton.setDown(True)

        #x Autoscale
        self.xAutoScaleButton = self._addToolButton(
            self.xAutoIcon,
            self._xAutoScaleToggle,
            'Toggle Autoscale X Axis (On/Off)',
            toggle=True)
        if QTVERSION < '4.0.0':
            self.xAutoScaleButton.setState(qt.QButton.On)
        else:
            self.xAutoScaleButton.setChecked(True)
            self.xAutoScaleButton.setDown(True)

        #y Logarithmic
        self.yLogButton = self._addToolButton(
            self.logyIcon,
            self._toggleLogY,
            'Toggle Logarithmic Y Axis (On/Off)',
            toggle=True)
        if QTVERSION < '4.0.0':
            self.yLogButton.setState(qt.QButton.Off)
        else:
            self.yLogButton.setChecked(False)
            self.yLogButton.setDown(False)

        #toggle Points/Lines
        tb = self._addToolButton(self.togglePointsIcon,
                                 self._togglePointsSignal,
                                 'Toggle Points/Lines')

        #fit icon
        self.fitButton = self._addToolButton(self.fitIcon, self._fitIconSignal,
                                             'Simple Fit of Active Curve')

        self.newplotIcons = False
        if self.newplotIcons:
            tb = self._addToolButton(self.averageIcon, self._averageIconSignal,
                                     'Average Plotted Curves')

            tb = self._addToolButton(self.deriveIcon, self._deriveIconSignal,
                                     'Take Derivative of Active Curve')

            tb = self._addToolButton(self.smoothIcon, self._smoothIconSignal,
                                     'Smooth Active Curve')

            tb = self._addToolButton(self.swapSignIcon,
                                     self._swapSignIconSignal,
                                     'Multiply Active Curve by -1')

            tb = self._addToolButton(self.yMinToZeroIcon,
                                     self._yMinToZeroIconSignal,
                                     'Force Y Minimum to be Zero')

            tb = self._addToolButton(self.subtractIcon,
                                     self._subtractIconSignal,
                                     'Subtract Active Curve')
        #save
        infotext = 'Save Active Curve or Widget'
        tb = self._addToolButton(self.saveIcon, self._saveIconSignal, infotext)

        if QTVERSION > '4.0.0':
            infotext = "Call/Load 1D Plugins"
            tb = self._addToolButton(self.pluginIcon, self._pluginClicked,
                                     infotext)

        self.toolBarLayout.addWidget(qt.HorizontalSpacer(self.toolBar))

        # ---print
        tb = self._addToolButton(self.printIcon, self.printGraph,
                                 'Prints the Graph')
    def __init__(self,
                 parent=None,
                 energy=None,
                 threshold=None,
                 useviewer=None,
                 name="Peak Identifier",
                 fl=0):
        if QTVERSION < '4.0.0':
            qt.QWidget.__init__(self, parent, name, fl)
            self.setCaption(name)
            self.setIcon(qt.QPixmap(IconDict['gioconda16']))
        else:
            if fl == 0:
                qt.QWidget.__init__(self, parent)
            else:
                qt.QWidget.__init__(self, parent, fl)
            self.setWindowTitle(name)
            self.setWindowIcon(qt.QIcon(qt.QPixmap(IconDict['gioconda16'])))

        if energy is None: energy = 5.9
        if threshold is None: threshold = 0.030
        if useviewer is None: useviewer = 0
        self.__useviewer = useviewer

        layout = qt.QVBoxLayout(self)
        #heading
        self.__energyHBox = qt.QWidget(self)
        hbox = self.__energyHBox
        hbox.layout = qt.QHBoxLayout(hbox)
        hbox.layout.setMargin(0)
        hbox.layout.setSpacing(0)
        layout.addWidget(hbox)
        hbox.layout.addWidget(qt.HorizontalSpacer(hbox))

        l1 = qt.QLabel(hbox)
        l1.setText('<b><nobr>Energy (keV)</nobr></b>')
        hbox.layout.addWidget(l1)
        self.energy = MyQLineEdit(hbox)
        self.energy.setText("%.3f" % energy)
        if QTVERSION < '4.0.0':
            qt.QToolTip.add(self.energy, 'Press enter to validate your energy')
        else:
            self.energy._validator = qt.QDoubleValidator(self.energy)
            self.energy.setValidator(self.energy._validator)
            self.energy.setToolTip('Press enter to validate your energy')
        hbox.layout.addWidget(self.energy)
        hbox.layout.addWidget(qt.HorizontalSpacer(hbox))
        if QTVERSION < '4.0.0':
            self.connect(self.energy, qt.SIGNAL('returnPressed()'),
                         self._energySlot)
        else:
            self.connect(self.energy, qt.SIGNAL('editingFinished()'),
                         self._energySlot)
        #parameters
        self.__hbox2 = qt.QWidget(self)
        hbox2 = self.__hbox2

        layout.addWidget(hbox2)
        hbox2.layout = qt.QHBoxLayout(hbox2)
        hbox2.layout.setMargin(0)
        hbox2.layout.setSpacing(0)
        font = hbox2.font()
        font.setBold(1)
        hbox2.setFont(font)

        l2 = qt.QLabel(hbox2)
        l2.setText('Energy Threshold (eV)')
        self.threshold = qt.QSpinBox(hbox2)
        if QTVERSION < '4.0.0':
            self.threshold.setMinValue(0)
            self.threshold.setMaxValue(1000)
        else:
            self.threshold.setMinimum(0)
            self.threshold.setMaximum(1000)
        self.threshold.setValue(int(threshold * 1000))
        self.k = qt.QCheckBox(hbox2)
        self.k.setText('K')
        self.k.setChecked(1)
        self.l1 = qt.QCheckBox(hbox2)
        self.l1.setText('L1')
        self.l1.setChecked(1)
        self.l2 = qt.QCheckBox(hbox2)
        self.l2.setText('L2')
        self.l2.setChecked(1)
        self.l3 = qt.QCheckBox(hbox2)
        self.l3.setText('L3')
        self.l3.setChecked(1)
        self.m = qt.QCheckBox(hbox2)
        self.m.setText('M')
        self.m.setChecked(1)
        self.connect(self.threshold, qt.SIGNAL('valueChanged(int)'),
                     self.myslot)
        self.connect(self.k, qt.SIGNAL('clicked()'), self.myslot)
        self.connect(self.l1, qt.SIGNAL('clicked()'), self.myslot)
        self.connect(self.l2, qt.SIGNAL('clicked()'), self.myslot)
        self.connect(self.l3, qt.SIGNAL('clicked()'), self.myslot)
        self.connect(self.m, qt.SIGNAL('clicked()'), self.myslot)

        hbox2.layout.addWidget(l2)
        hbox2.layout.addWidget(self.threshold)
        hbox2.layout.addWidget(self.k)
        hbox2.layout.addWidget(self.l1)
        hbox2.layout.addWidget(self.l2)
        hbox2.layout.addWidget(self.l3)
        hbox2.layout.addWidget(self.m)

        if self.__useviewer:
            if QTVERSION < '4.0.0':
                self.__browsertext = qt.QTextView(self)
            else:
                self.__browsertext = qt.QTextEdit(self)
        layout.addWidget(self.__browsertext)
        self.setEnergy()
    def __init__(self, parent=None, name="McaSimpleFit", specfit=None, fl=0):
        if QTVERSION < '4.0.0':
            qt.QWidget.__init__(self, parent, name, fl)
            self.setCaption(name)
        else:
            qt.QWidget.__init__(self, parent)
            self.setWindowTitle(name)
        if specfit is None:
            self.specfit = Specfit.Specfit()
        else:
            self.specfit = specfit
        layout = qt.QVBoxLayout(self)
        ##############
        self.headerlabel = qt.QLabel(self)
        self.headerlabel.setAlignment(qt.Qt.AlignHCenter)
        self.setheader('<b>Fit of XXXXXXXXXX from Channel XXXXX to XXXX<\b>')
        ##############
        defaultFunctions = "SpecfitFunctions.py"
        if not os.path.exists(defaultFunctions):
            defaultFunctions = os.path.join(os.path.dirname(__file__),
                                            defaultFunctions)
        self.specfit.importfun(defaultFunctions)
        self.specfit.settheory('Area Gaussians')
        self.specfit.setbackground('Linear')

        fitconfig = {}
        fitconfig.update(self.specfit.fitconfig)
        fitconfig['WeightFlag'] = 1
        fitconfig['McaMode'] = 1
        self.specfit.configure(**fitconfig)
        self.specfitGUI = SpecfitGUI.SpecfitGUI(self,
                                                config=1,
                                                status=1,
                                                buttons=0,
                                                specfit=self.specfit,
                                                eh=self.specfit.eh)

        layout.addWidget(self.headerlabel)
        layout.addWidget(self.specfitGUI)

        hbox = qt.QWidget(self)
        hboxLayout = qt.QHBoxLayout(hbox)
        self.estimatebutton = qt.QPushButton(hbox)
        self.estimatebutton.setText("Estimate")
        hs1 = qt.HorizontalSpacer(hbox)
        self.fitbutton = qt.QPushButton(hbox)
        self.fitbutton.setText("Fit Again!")
        self.dismissbutton = qt.QPushButton(hbox)
        self.dismissbutton.setText("Dismiss")
        self.connect(self.estimatebutton, qt.SIGNAL("clicked()"),
                     self.estimate)
        self.connect(self.fitbutton, qt.SIGNAL("clicked()"), self.fit)
        self.connect(self.dismissbutton, qt.SIGNAL("clicked()"), self.dismiss)
        if QTVERSION < '4.0.0':
            self.connect(self.specfitGUI, qt.PYSIGNAL('SpecfitGUISignal'),
                         self.__anasignal)
        else:
            self.connect(self.specfitGUI, qt.SIGNAL('SpecfitGUISignal'),
                         self.__anasignal)
        hs2 = qt.HorizontalSpacer(hbox)
        hboxLayout.addWidget(hs1)
        hboxLayout.addWidget(self.estimatebutton)
        hboxLayout.addWidget(self.fitbutton)
        hboxLayout.addWidget(self.dismissbutton)
        hboxLayout.addWidget(hs2)
        layout.addWidget(hbox)
        self.estimatebutton.hide()
Exemple #26
0
    def __init__(self, parent=None, name="ScanFit", specfit=None, fl=0):
        #fl=qt.Qt.WDestructiveClose):
        qt.QWidget.__init__(self, parent)
        if QTVERSION < '4.0.0':
            self.setCaption(name)
        else:
            self.setWindowTitle(name)

        if specfit is None:
            self.specfit = Specfit.Specfit()
        else:
            self.specfit = specfit
        self.info = None
        layout = qt.QVBoxLayout(self)
        layout.setMargin(0)
        layout.setSpacing(0)
        ##############
        self.headerlabel = qt.QLabel(self)
        self.headerlabel.setAlignment(qt.Qt.AlignHCenter)
        self.setHeader('<b>Fit of XXXXXXXXXX from X XXXXX to XXXX<\b>')
        ##############
        if not len(self.specfit.theorylist):
            funsFile = "SpecfitFunctions.py"
            if not os.path.exists(funsFile):
                funsFile = os.path.join(os.path.dirname(Specfit.__file__),
                                        funsFile)
            self.specfit.importfun(funsFile)
        if 'Area Gaussians' not in self.specfit.theorylist:
            funsFile = "SpecfitFunctions.py"
            if not os.path.exists(funsFile):
                funsFile = os.path.join(os.path.dirname(Specfit.__file__),
                                        funsFile)
            self.specfit.importfun(funsFile)
        self.specfit.settheory('Area Gaussians')
        self.specfit.setbackground('Linear')
        fitconfig = {}
        fitconfig.update(self.specfit.fitconfig)
        fitconfig['WeightFlag'] = 0
        fitconfig['ForcePeakPresence'] = 1
        fitconfig['McaMode'] = 0
        self.specfit.configure(**fitconfig)
        self.specfitGUI = SpecfitGUI.SpecfitGUI(self,
                                                config=1,
                                                status=1,
                                                buttons=0,
                                                specfit=self.specfit,
                                                eh=self.specfit.eh)
        #self.specfitGUI.updateGUI(configuration=fitconfig)
        #self.setdata = self.specfit.setdata

        self.specfitGUI.guiconfig.MCACheckBox.setEnabled(1)
        palette = self.specfitGUI.guiconfig.MCACheckBox.palette()
        if QTVERSION < '4.0.0':
            palette.setDisabled(palette.active())
        ##############
        hbox = qt.QWidget(self)
        hboxlayout = qt.QHBoxLayout(hbox)
        hboxlayout.setMargin(0)
        hboxlayout.setSpacing(0)
        self.estimatebutton = qt.QPushButton(hbox)
        self.estimatebutton.setText("Estimate")
        self.fitbutton = qt.QPushButton(hbox)
        self.fitbutton.setText("Fit")
        hboxlayout.addWidget(self.estimatebutton)
        hboxlayout.addWidget(qt.HorizontalSpacer(hbox))
        hboxlayout.addWidget(self.fitbutton)

        self.dismissbutton = qt.QPushButton(hbox)
        self.dismissbutton.setText("Dismiss")
        self.connect(self.estimatebutton, qt.SIGNAL("clicked()"),
                     self.estimate)
        self.connect(self.fitbutton, qt.SIGNAL("clicked()"), self.fit)
        self.connect(self.dismissbutton, qt.SIGNAL("clicked()"), self.dismiss)
        if QTVERSION < '4.0.0':
            self.connect(self.specfitGUI, qt.PYSIGNAL('SpecfitGUISignal'),
                         self._specfitGUISignal)
        else:
            self.connect(self.specfitGUI, qt.SIGNAL('SpecfitGUISignal'),
                         self._specfitGUISignal)
        hboxlayout.addWidget(qt.HorizontalSpacer(hbox))
        hboxlayout.addWidget(self.dismissbutton)
        layout.addWidget(self.headerlabel)
        layout.addWidget(self.specfitGUI)
        layout.addWidget(hbox)
Exemple #27
0
    def _buildToolBar(self,
                      selection=False,
                      colormap=False,
                      imageicons=False,
                      standalonesave=True,
                      standalonezoom=True,
                      profileselection=False):
        if QTVERSION < '4.0.0':
            if qt.qVersion() < '3.0':
                self.colormapIcon = qt.QIconSet(
                    qt.QPixmap(IconDict["colormap16"]))
            else:
                self.colormapIcon = qt.QIconSet(
                    qt.QPixmap(IconDict["colormap"]))
            self.selectionIcon = qt.QIconSet(qt.QPixmap(IconDict["normal"]))
            self.zoomResetIcon = qt.QIconSet(qt.QPixmap(IconDict["zoomreset"]))
            self.printIcon = qt.QIconSet(qt.QPixmap(IconDict["fileprint"]))
            self.saveIcon = qt.QIconSet(qt.QPixmap(IconDict["filesave"]))
            self.xAutoIcon = qt.QIconSet(qt.QPixmap(IconDict["xauto"]))
            self.yAutoIcon = qt.QIconSet(qt.QPixmap(IconDict["yauto"]))
            self.imageIcon = qt.QIconSet(qt.QPixmap(IconDict["image"]))
            self.eraseSelectionIcon = qt.QIconSet(
                qt.QPixmap(IconDict["eraseselect"]))
            self.rectSelectionIcon = qt.QIconSet(
                qt.QPixmap(IconDict["boxselect"]))
            self.brushSelectionIcon = qt.QIconSet(
                qt.QPixmap(IconDict["brushselect"]))
            self.brushIcon = qt.QIconSet(qt.QPixmap(IconDict["brush"]))
            self.hFlipIcon = qt.QIconSet(
                qt.QPixmap(IconDict["gioconda16mirror"]))
        else:
            self.colormapIcon = qt.QIcon(qt.QPixmap(IconDict["colormap"]))
            self.selectionIcon = qt.QIcon(qt.QPixmap(IconDict["normal"]))
            self.zoomResetIcon = qt.QIcon(qt.QPixmap(IconDict["zoomreset"]))
            self.printIcon = qt.QIcon(qt.QPixmap(IconDict["fileprint"]))
            self.saveIcon = qt.QIcon(qt.QPixmap(IconDict["filesave"]))
            self.xAutoIcon = qt.QIcon(qt.QPixmap(IconDict["xauto"]))
            self.yAutoIcon = qt.QIcon(qt.QPixmap(IconDict["yauto"]))
            self.hFlipIcon = qt.QIcon(qt.QPixmap(IconDict["gioconda16mirror"]))
            self.imageIcon = qt.QIcon(qt.QPixmap(IconDict["image"]))
            self.eraseSelectionIcon = qt.QIcon(
                qt.QPixmap(IconDict["eraseselect"]))
            self.rectSelectionIcon = qt.QIcon(qt.QPixmap(
                IconDict["boxselect"]))
            self.brushSelectionIcon = qt.QIcon(
                qt.QPixmap(IconDict["brushselect"]))
            self.brushIcon = qt.QIcon(qt.QPixmap(IconDict["brush"]))
            self.additionalIcon = qt.QIcon(
                qt.QPixmap(IconDict["additionalselect"]))
            self.hLineIcon = qt.QIcon(qt.QPixmap(IconDict["horizontal"]))
            self.vLineIcon = qt.QIcon(qt.QPixmap(IconDict["vertical"]))
            self.lineIcon = qt.QIcon(qt.QPixmap(IconDict["diagonal"]))

        self.toolBar = qt.QWidget(self)
        self.toolBarLayout = qt.QHBoxLayout(self.toolBar)
        self.toolBarLayout.setMargin(0)
        self.toolBarLayout.setSpacing(0)
        self.mainLayout.addWidget(self.toolBar)
        #Autoscale
        if standalonezoom:
            tb = self._addToolButton(self.zoomResetIcon, self._zoomReset,
                                     'Auto-Scale the Graph')
        else:
            tb = self._addToolButton(self.zoomResetIcon, None,
                                     'Auto-Scale the Graph')
        self.zoomResetToolButton = tb
        #y Autoscale
        tb = self._addToolButton(self.yAutoIcon,
                                 self._yAutoScaleToggle,
                                 'Toggle Autoscale Y Axis (On/Off)',
                                 toggle=True,
                                 state=True)
        if qt.qVersion() < '4.0.0':
            tb.setState(qt.QButton.On)
        else:
            tb.setDown(True)
        self.yAutoScaleToolButton = tb
        tb.setDown(True)

        #x Autoscale
        tb = self._addToolButton(self.xAutoIcon,
                                 self._xAutoScaleToggle,
                                 'Toggle Autoscale X Axis (On/Off)',
                                 toggle=True,
                                 state=True)
        self.xAutoScaleToolButton = tb
        tb.setDown(True)

        #colormap
        if colormap:
            tb = self._addToolButton(self.colormapIcon, None,
                                     'Change Colormap')
            self.colormapToolButton = tb

        #flip
        tb = self._addToolButton(self.hFlipIcon, None, 'Flip Horizontal')
        self.hFlipToolButton = tb

        #save
        if standalonesave:
            tb = self._addToolButton(self.saveIcon, self._saveIconSignal,
                                     'Save Graph')
        else:
            tb = self._addToolButton(self.saveIcon, None, 'Save')
        self.saveToolButton = tb

        #Selection
        if selection:
            tb = self._addToolButton(self.selectionIcon,
                                     None,
                                     'Toggle Selection Mode',
                                     toggle=True,
                                     state=False)
            if qt.qVersion() < '4.0.0':
                tb.setState(qt.QButton.Off)
            else:
                tb.setDown(False)
            self.selectionToolButton = tb
        #image selection icons
        if imageicons:
            tb = self._addToolButton(self.imageIcon, None, 'Reset')
            self.imageToolButton = tb

            tb = self._addToolButton(self.eraseSelectionIcon, None,
                                     'Erase Selection')
            self.eraseSelectionToolButton = tb

            tb = self._addToolButton(self.rectSelectionIcon, None,
                                     'Rectangular Selection')
            self.rectSelectionToolButton = tb

            tb = self._addToolButton(self.brushSelectionIcon, None,
                                     'Brush Selection')
            self.brushSelectionToolButton = tb

            tb = self._addToolButton(self.brushIcon, None, 'Select Brush')
            self.brushToolButton = tb
            if QTVERSION > '4.0.0':
                tb = self._addToolButton(self.additionalIcon, None,
                                         'Additional Selections Menu')
                self.additionalSelectionToolButton = tb
        else:
            self.imageToolButton = None

        #picker selection
        self._pickerSelectionButtons = []
        if profileselection:
            self._profileSelection = True
            self._polygonSelection = False
            self._pickerSelectionButtons = []
            if self._profileSelection:
                tb = self._addToolButton(self.hLineIcon,
                                         self._hLineProfileClicked,
                                         'Horizontal Profile Selection',
                                         toggle=True,
                                         state=False)
                self.hLineProfileButton = tb
                self._pickerSelectionButtons.append(tb)

                tb = self._addToolButton(self.vLineIcon,
                                         self._vLineProfileClicked,
                                         'Vertical Profile Selection',
                                         toggle=True,
                                         state=False)
                self.vLineProfileButton = tb
                self._pickerSelectionButtons.append(tb)

                tb = self._addToolButton(self.lineIcon,
                                         self._lineProfileClicked,
                                         'Line Profile Selection',
                                         toggle=True,
                                         state=False)
                self.lineProfileButton = tb
                self._pickerSelectionButtons.append(tb)

                self._pickerSelectionWidthLabel = qt.QLabel(self.toolBar)
                self._pickerSelectionWidthLabel.setText("W:")
                self.toolBar.layout().addWidget(
                    self._pickerSelectionWidthLabel)
                self._pickerSelectionWidthValue = qt.QSpinBox(self.toolBar)
                self._pickerSelectionWidthValue.setMinimum(1)
                self._pickerSelectionWidthValue.setMaximum(1000)
                self.toolBar.layout().addWidget(
                    self._pickerSelectionWidthValue)
                #tb = self._addToolButton(None,
                #                     self._lineProfileClicked,
                #                     'Line Profile Selection',
                #                     toggle=True,
                #                     state=False)
                #tb.setText = "W:"
                #self.lineWidthProfileButton = tb
                #self._pickerSelectionButtons.append(tb)
            if self._polygonSelection:
                print("Polygon selection not implemented yet")
        #hide profile selection buttons
        if imageicons:
            for button in self._pickerSelectionButtons:
                button.hide()

        self.infoWidget = qt.QWidget(self.toolBar)
        self.infoWidget.mainLayout = qt.QHBoxLayout(self.infoWidget)
        self.infoWidget.mainLayout.setMargin(0)
        self.infoWidget.mainLayout.setSpacing(0)
        self.infoWidget.label = qt.QLabel(self.infoWidget)
        self.infoWidget.label.setText("X = ???? Y = ???? Z = ????")
        self.infoWidget.mainLayout.addWidget(self.infoWidget.label)
        self.toolBarLayout.addWidget(self.infoWidget)
        self.infoWidget.hide()

        self.toolBarLayout.addWidget(qt.HorizontalSpacer(self.toolBar))

        # ---print
        tb = self._addToolButton(self.printIcon, self.printGraph,
                                 'Prints the Graph')
Exemple #28
0
    def build(self, table, orientation, thickness, density, size=None):
        if size is None: size = "medium"
        layout = qt.QHBoxLayout(self)

        if table:
            #the material definition
            matBox = qt.QWidget(self)
            layout.addWidget(matBox)
            matBoxLayout = qt.QVBoxLayout(matBox)
            self.materialEditor = MaterialEditor.MaterialEditor(matBox,
                                                                comments=False,
                                                                height=7)
            matBoxLayout.addWidget(self.materialEditor)
            matBoxLayout.addWidget(qt.VerticalSpacer(matBox))
        else:
            self.materialEditor = None

        #the matrix definition
        sampleBox = qt.QWidget(self)
        layout.addWidget(sampleBox)
        if orientation == "vertical":
            sampleBoxLayout = qt.QVBoxLayout(sampleBox)
        else:
            sampleBoxLayout = qt.QHBoxLayout(sampleBox)

        #the image
        if orientation == "vertical":
            labelHBox = qt.QWidget(sampleBox)
            sampleBoxLayout.addWidget(labelHBox)
            labelHBoxLayout = qt.QHBoxLayout(labelHBox)
            labelHBoxLayout.addWidget(qt.HorizontalSpacer(labelHBox))
            label = MatrixImage.MatrixImage(labelHBox, size=size)
            labelHBoxLayout.addWidget(label)
            labelHBoxLayout.addWidget(qt.HorizontalSpacer(labelHBox))
        else:
            labelHBox = qt.QWidget(sampleBox)
            sampleBoxLayout.addWidget(labelHBox)
            labelHBoxLayout = qt.QVBoxLayout(labelHBox)
            labelHBoxLayout.setMargin(0)
            labelHBoxLayout.setSpacing(4)
            label = MatrixImage.MatrixImage(labelHBox, size=size)
            labelHBoxLayout.addWidget(label)
        if orientation != "vertical":
            labelHBoxLayout.addWidget(qt.VerticalSpacer(labelHBox))
        self.imageLabel = label
        #the input fields container
        self.__gridSampleBox = qt.QWidget(sampleBox)
        grid = self.__gridSampleBox
        sampleBoxLayout.addWidget(grid)
        if QTVERSION < '4.0.0':
            gridLayout = qt.QGridLayout(grid, 6, 2, 11, 4)
        else:
            gridLayout = qt.QGridLayout(grid)
            gridLayout.setMargin(11)
            gridLayout.setSpacing(4)

        #the angles
        angle1Label = qt.QLabel(grid)
        angle1Label.setText("Incoming Angle (deg.):")
        self.__angle1Line = MyQLineEdit(grid)
        self.__angle1Line.setReadOnly(False)

        angle2Label = qt.QLabel(grid)
        angle2Label.setText("Outgoing Angle (deg.):")
        self.__angle2Line = MyQLineEdit(grid)
        self.__angle2Line.setReadOnly(False)

        self.__angle3Label = qt.QCheckBox(grid)
        self.__angle3Label.setText("Scattering Angle (deg.):")
        self.__angle3Line = MyQLineEdit(grid)
        self.__angle3Line.setReadOnly(False)
        self.__angle3Line.setDisabled(True)
        if QTVERSION < '4.0.0':
            angle1Label.setAlignment(qt.QLabel.WordBreak | \
                                     qt.QLabel.AlignVCenter)
            angle2Label.setAlignment(qt.QLabel.WordBreak | \
                                     qt.QLabel.AlignVCenter)
        else:
            angle1Label.setAlignment(qt.Qt.AlignVCenter)
            angle2Label.setAlignment(qt.Qt.AlignVCenter)

        self.__angle3Label.setChecked(0)

        gridLayout.addWidget(angle1Label, 0, 0)
        gridLayout.addWidget(self.__angle1Line, 0, 1)
        gridLayout.addWidget(angle2Label, 1, 0)
        gridLayout.addWidget(self.__angle2Line, 1, 1)
        gridLayout.addWidget(self.__angle3Label, 2, 0)
        gridLayout.addWidget(self.__angle3Line, 2, 1)

        rowoffset = 3
        #thickness and density
        if density:
            densityLabel = qt.QLabel(grid)
            densityLabel.setText("Sample Density (g/cm3):")
            if QTVERSION < '4.0.0':
                densityLabel.setAlignment(qt.QLabel.WordBreak | \
                                          qt.QLabel.AlignVCenter)
            else:
                densityLabel.setAlignment(qt.Qt.AlignVCenter)
            self.__densityLine = MyQLineEdit(grid)
            self.__densityLine.setReadOnly(False)
            gridLayout.addWidget(densityLabel, rowoffset, 0)
            gridLayout.addWidget(self.__densityLine, rowoffset, 1)
            rowoffset = rowoffset + 1
        else:
            self.__densityLine = None

        if thickness:
            thicknessLabel = qt.QLabel(grid)
            thicknessLabel.setText("Sample Thickness   (cm):")
            if QTVERSION < '4.0.0':
                thicknessLabel.setAlignment(qt.QLabel.WordBreak | \
                                            qt.QLabel.AlignVCenter)
            else:
                thicknessLabel.setAlignment(qt.Qt.AlignVCenter)
            self.__thicknessLine = MyQLineEdit(grid)
            self.__thicknessLine.setReadOnly(False)
            gridLayout.addWidget(thicknessLabel, rowoffset, 0)
            gridLayout.addWidget(self.__thicknessLine, rowoffset, 1)
            rowoffset = rowoffset + 1
        else:
            self.__thicknessLine = None

        gridLayout.addWidget(qt.VerticalSpacer(grid), rowoffset, 0)
        gridLayout.addWidget(qt.VerticalSpacer(grid), rowoffset, 1)

        if QTVERSION < '4.0.0':
            self.connect(self.__angle1Line, qt.PYSIGNAL('MyQLineEditSignal'),
                         self.__angle1Slot)
            self.connect(self.__angle2Line, qt.PYSIGNAL('MyQLineEditSignal'),
                         self.__angle2Slot)
            self.connect(self.__angle3Line, qt.PYSIGNAL('MyQLineEditSignal'),
                         self.__angle3Slot)
            if self.__densityLine is not None:
                self.connect(self.__densityLine,
                             qt.PYSIGNAL('MyQLineEditSignal'),
                             self.__densitySlot)
            if self.__thicknessLine is not None:
                self.connect(self.__thicknessLine,
                             qt.PYSIGNAL('MyQLineEditSignal'),
                             self.__thicknessSlot)
        else:
            self.connect(self.__angle1Line, qt.SIGNAL('MyQLineEditSignal'),
                         self.__angle1Slot)
            self.connect(self.__angle2Line, qt.SIGNAL('MyQLineEditSignal'),
                         self.__angle2Slot)
            self.connect(self.__angle3Line, qt.SIGNAL('MyQLineEditSignal'),
                         self.__angle3Slot)
            if self.__densityLine is not None:
                self.connect(self.__densityLine,
                             qt.SIGNAL('MyQLineEditSignal'),
                             self.__densitySlot)
            if self.__thicknessLine is not None:
                self.connect(self.__thicknessLine,
                             qt.SIGNAL('MyQLineEditSignal'),
                             self.__thicknessSlot)
        self.connect(self.__angle3Label, qt.SIGNAL('clicked()'),
                     self.__angle3LabelSlot)

        if orientation == "vertical":
            sampleBoxLayout.addWidget(qt.VerticalSpacer(sampleBox))
Exemple #29
0
    def __init__(self, parent=None):
        qt.QGroupBox.__init__(self, parent)
        self.setTitle("Function Definition")
        self.mainLayout = qt.QGridLayout(self)
        self.mainLayout.setMargin(2)
        self.mainLayout.setSpacing(2)

        row = 0

        #actual fit function
        self.fitFunctionCheckBox = qt.QCheckBox(self)
        self.fitFunctionCheckBox.setText("Fit Function to be used")
        self.fitFunctionCombo = qt.QComboBox(self)
        self.fitFunctionCombo.addItem(str("None"))
        self.connect(self.fitFunctionCombo, qt.SIGNAL("activated(int)"),
                     self._fitFunctionComboActivated)
        self.fitFunctionSetupButton = qt.QPushButton(self)
        self.fitFunctionSetupButton.setText('SETUP')
        self.fitFunctionSetupButton.setAutoDefault(False)
        self.fitFunctionSetupButton.hide()

        self.mainLayout.addWidget(self.fitFunctionCheckBox, row, 0)
        self.mainLayout.addWidget(qt.HorizontalSpacer(self), row, 1)
        self.mainLayout.addWidget(self.fitFunctionSetupButton, row, 2)
        self.mainLayout.addWidget(self.fitFunctionCombo, row, 3)
        row += 1

        #background
        self.backgroundCheckBox = qt.QCheckBox(self)
        self.backgroundCheckBox.setText("Background function")
        self.backgroundCombo = qt.QComboBox(self)
        self.backgroundCombo.addItem(str("None"))
        self.connect(self.backgroundCombo, qt.SIGNAL("activated(int)"),
                     self._backgroundComboActivated)

        self.backgroundSetupButton = qt.QPushButton(self)
        self.backgroundSetupButton.setText('SETUP')
        self.backgroundSetupButton.setAutoDefault(False)
        self.backgroundSetupButton.hide()

        self.mainLayout.addWidget(self.backgroundCheckBox, row, 0)
        self.mainLayout.addWidget(qt.HorizontalSpacer(self), row, 1)
        self.mainLayout.addWidget(self.backgroundSetupButton, row, 2)
        self.mainLayout.addWidget(self.backgroundCombo, row, 3)
        row += 1

        #stripping
        self.stripCheckBox = qt.QCheckBox(self)
        self.stripCheckBox.setText(
            "Non-analytical (or estimation) background algorithm")
        self.stripCombo = qt.QComboBox(self)
        self.stripCombo.addItem(str("Strip"))
        self.stripCombo.addItem(str("SNIP"))
        self.stripSetupButton = qt.QPushButton(self)
        self.stripSetupButton.setText('SETUP')
        self.stripSetupButton.setAutoDefault(False)
        self.connect(self.stripCombo, qt.SIGNAL("activated(int)"),
                     self._stripComboActivated)

        self.mainLayout.addWidget(self.stripCheckBox, row, 0)
        self.mainLayout.addWidget(qt.HorizontalSpacer(self), row, 1)
        self.mainLayout.addWidget(self.stripSetupButton, row, 2)
        self.mainLayout.addWidget(self.stripCombo, row, 3)
        row += 1

        self.snipWidthLabel = qt.QLabel(self)
        self.snipWidthLabel.setText(str("SNIP Background Width"))
        self.snipWidthSpin = qt.QSpinBox(self)
        self.snipWidthSpin.setMinimum(1)
        self.snipWidthSpin.setMaximum(300)
        self.snipWidthSpin.setValue(10)
        self.mainLayout.addWidget(self.snipWidthLabel, row, 0)
        self.mainLayout.addWidget(self.snipWidthSpin, row, 3)
        row += 1

        self.stripWidthLabel = qt.QLabel(self)
        self.stripWidthLabel.setText(str("Strip Background Width"))
        self.stripWidthSpin = qt.QSpinBox(self)
        self.stripWidthSpin.setMinimum(1)
        self.stripWidthSpin.setMaximum(100)
        self.stripWidthSpin.setValue(4)
        self.mainLayout.addWidget(self.stripWidthLabel, row, 0)
        self.mainLayout.addWidget(self.stripWidthSpin, row, 3)
        row += 1

        self.stripIterLabel = qt.QLabel(self)
        self.stripIterLabel.setText(str("Strip Background Iterations"))
        self.stripIterSpin = qt.QSpinBox(self)
        self.stripIterSpin.setMinimum(0)
        self.stripIterSpin.setMaximum(100000)
        self.stripIterSpin.setValue(5000)
        self.mainLayout.addWidget(self.stripIterLabel, row, 0)
        self.mainLayout.addWidget(self.stripIterSpin, row, 3)
        row += 1

        self.stripFilterLabel = qt.QLabel(self)
        text = str("Strip Background Smoothing Width (Savitsky-Golay)")
        self.stripFilterLabel.setText(text)
        self.stripFilterSpin = qt.QSpinBox(self)
        self.stripFilterSpin.setMinimum(0)
        self.stripFilterSpin.setMaximum(40)
        self.stripFilterSpin.setSingleStep(2)
        self.mainLayout.addWidget(self.stripFilterLabel, row, 0)
        self.mainLayout.addWidget(self.stripFilterSpin, row, 3)
        row += 1

        #anchors
        self.anchorsContainer = qt.QWidget(self)
        anchorsContainerLayout = qt.QHBoxLayout(self.anchorsContainer)
        anchorsContainerLayout.setMargin(2)
        anchorsContainerLayout.setSpacing(2)
        self.stripAnchorsCheckBox = qt.QCheckBox(self.anchorsContainer)
        self.stripAnchorsCheckBox.setText(str("Strip Background use Anchors"))
        anchorsContainerLayout.addWidget(self.stripAnchorsCheckBox)
        self.stripAnchorsList = []
        for i in range(4):
            anchor = qt.QLineEdit(self.anchorsContainer)
            anchor._v = qt.QDoubleValidator(anchor)
            anchor.setValidator(anchor._v)
            anchor.setText("0.0")
            anchorsContainerLayout.addWidget(anchor)
            self.stripAnchorsList.append(anchor)
        self.mainLayout.addWidget(self.anchorsContainer, row, 0, 1, 4)
        row += 1

        #signals
        self.connect(self.fitFunctionSetupButton, qt.SIGNAL('clicked()'),
                     self.setupFitFunction)

        self.connect(self.backgroundSetupButton, qt.SIGNAL('clicked()'),
                     self.setupBackground)

        self.connect(self.stripSetupButton, qt.SIGNAL('clicked()'),
                     self.setupStrip)
    def configureFilter(self):
        msg = qt.QDialog()
        msgLayout = qt.QGridLayout()
        buttonLayout = qt.QHBoxLayout()

        inpThreshold = qt.QDoubleSpinBox()
        inpThreshold.setRange(0., 10.)
        inpThreshold.setSingleStep(.1)
        inpThreshold.setValue(2.0)
        inpThreshold.setToolTip('Increase width for broad spikes')

        inpWidth = qt.QSpinBox()
        inpWidth.setRange(1, 101)
        inpWidth.setSingleStep(2)
        inpWidth.setValue(self.width)
        inpWidth.setToolTip(
            'Set low threshold for multiple spikes of different markedness')

        labelWidth = qt.QLabel('Width (must be odd)')
        labelThreshold = qt.QLabel('Threshold (multiple of deviation)')
        buttonOK = qt.QPushButton('Ok')
        buttonOK.clicked.connect(msg.accept)
        buttonCancel = qt.QPushButton('Cancel')
        buttonCancel.clicked.connect(msg.reject)

        allActiveBG = qt.QButtonGroup()
        buttonAll = qt.QCheckBox('Apply to All')
        buttonActive = qt.QCheckBox('Apply to Active')
        allActiveBG.addButton(buttonAll, 0)
        allActiveBG.addButton(buttonActive, 1)

        buttonLayout.addWidget(qt.HorizontalSpacer())
        buttonLayout.addWidget(buttonOK)
        buttonLayout.addWidget(buttonCancel)

        msgLayout.addWidget(labelWidth, 0, 0)
        msgLayout.addWidget(inpWidth, 0, 1)
        msgLayout.addWidget(labelThreshold, 1, 0)
        msgLayout.addWidget(inpThreshold, 1, 1)
        msgLayout.addWidget(buttonActive, 2, 0)
        msgLayout.addWidget(buttonAll, 2, 1)
        msgLayout.addLayout(buttonLayout, 3, 0, 1, 2)
        msg.setLayout(msgLayout)
        if msg.exec_():
            try:
                self.threshold = float(inpThreshold.value()) / 100.
                self.threshold = float(inpThreshold.value())
                self.width = int(inpWidth.value())
            except:
                self.threshold = 0.66
                self.width = 9
            if not (self.width % 2):
                self.width += 1
            if buttonActive.isChecked():
                if DEBUG:
                    print('ActiveChecked')
                self.removeSpikesActive()
            if buttonAll.isChecked():
                if DEBUG:
                    print('AllChecked')
                self.removeSpikesAll()