Ejemplo n.º 1
0
    def __init__(self, parent):
        QMainWindow.__init__(self, parent)
        DlgUtils.__init__(self, 'Live data')
        self.panel = parent
        layout1 = QVBoxLayout()
        self.plot = QwtPlot(self)
        layout1.addWidget(self.plot)
        self.curve = QwtPlotCurve()
        self.curve.setRenderHint(QwtPlotCurve.RenderAntialiased)
        self.curve.attach(self.plot)
        self.marker = QwtPlotMarker()
        self.marker.attach(self.plot)
        self.markerpen = QPen(Qt.red)
        self.marker.setSymbol(
            QwtSymbol(QwtSymbol.Ellipse, QBrush(), self.markerpen, QSize(7,
                                                                         7)))
        self.zoomer = QwtPlotZoomer(self.plot.canvas())
        self.zoomer.setMousePattern(QwtPlotZoomer.MouseSelect3, Qt.NoButton)
        self.picker = QwtPlotPicker(self.plot.canvas())
        self.picker.setSelectionFlags(QwtPlotPicker.PointSelection
                                      | QwtPlotPicker.ClickSelection)
        self.picker.setMousePattern(QwtPlotPicker.MouseSelect1, Qt.MidButton)
        self.picker.selected.connect(self.pickerSelected)
        layout2 = QHBoxLayout()
        layout2.addWidget(QLabel('Scale:', self))
        self.scale = QComboBox(self)
        self.scale.addItems([
            'Single detectors, sorted by angle',
            'Scattering angle 2theta (deg)', 'Q value (A-1)'
        ])
        self.scale.currentIndexChanged[int].connect(self.scaleChanged)
        layout2.addWidget(self.scale)
        layout2.addStretch()
        self.scaleframe = QFrame(self)
        self.scaleframe.setLayout(layout2)
        self.scaleframe.setVisible(False)
        layout1.addWidget(self.scaleframe)
        mainframe = QFrame(self)
        mainframe.setLayout(layout1)
        self.setCentralWidget(mainframe)
        self.setContentsMargins(6, 6, 6, 6)
        plotfont = scaledFont(self.font(), 0.7)
        self.plot.setAxisFont(QwtPlot.xBottom, plotfont)
        self.plot.setAxisFont(QwtPlot.yLeft, plotfont)
        self.plot.setCanvasBackground(Qt.white)
        self.resize(800, 200)

        self._detinfo = None
        self._anglemap = None
        self._infowindow = None
        self._infolabel = None
        self._xs = self._ys = None
        self._type = None
 def handle_y(self, evt):
     if evt.attr_value is not None:
         if evt.attr_value.value != self.y:
             self.y = evt.attr_value.value / 1e9
             self.mark = QwtPlotMarker()
             self.mark.setSymbol(self.sym)
             self.mark.attach(self.l_plot)
             self.mark.setValue(self.x, self.y)
             if len(self.list_mark) > 10:
                 self.list_mark[0].setVisible(False)
                 l_mark = self.list_mark[0]
                 self.list_mark.pop(0)
             for mark in self.list_mark:
                 mark.setSymbol(self.sym_old)
             self.list_mark.append(self.mark)
             self.trigger.emit()
Ejemplo n.º 3
0
    def __init__(self, parent=None):
        super(TestPlot, self).__init__(parent)
        self.setWindowTitle("PyQwt" if USE_PYQWT5 else "PythonQwt")
        self.enableAxis(self.xTop, True)
        self.enableAxis(self.yRight, True)
        y = np.linspace(0, 10, 500)
        curve1 = QwtPlotCurve('Test Curve 1')
        curve1.setData(np.sin(y), y)
        curve2 = QwtPlotCurve('Test Curve 2')
        curve2.setData(y**3, y)
        if USE_PYQWT5:
            curve2.setAxis(self.xTop, self.yRight)
        else:
            # PythonQwt
            curve2.setAxes(self.xTop, self.yRight)

        for item, col, xa, ya in ((curve1, Qt.green, self.xBottom, self.yLeft),
                                  (curve2, Qt.red, self.xTop, self.yRight)):
            if not USE_PYQWT5:
                # PythonQwt
                item.setOrientation(Qt.Vertical)
            item.attach(self)
            item.setPen(QPen(col))
            for axis_id in xa, ya:
                palette = self.axisWidget(axis_id).palette()
                palette.setColor(QPalette.WindowText, QColor(col))
                palette.setColor(QPalette.Text, QColor(col))
                self.axisWidget(axis_id).setPalette(palette)
                ticks_font = self.axisFont(axis_id)
                self.setAxisFont(axis_id, ticks_font)

        self.canvas().setFrameStyle(0)  #QFrame.Panel|QFrame.Sunken)
        self.plotLayout().setCanvasMargin(0)
        self.axisWidget(QwtPlot.yLeft).setMargin(0)
        self.axisWidget(QwtPlot.xTop).setMargin(0)
        self.axisWidget(QwtPlot.yRight).setMargin(0)
        self.axisWidget(QwtPlot.xBottom).setMargin(0)

        self.marker = QwtPlotMarker()
        self.marker.setValue(0, 5)
        self.marker.attach(self)
Ejemplo n.º 4
0
    def setupUi(self, MainWindow):
        MainWindow.setObjectName(_fromUtf8("MainWindow"))
        MainWindow.resize(847, 480)
        self.centralwidget = QtGui.QWidget(MainWindow)
        self.centralwidget.setObjectName(_fromUtf8("centralwidget"))
        self.horizontalLayout_2 = QtGui.QHBoxLayout(self.centralwidget)
        self.horizontalLayout_2.setObjectName(_fromUtf8("horizontalLayout_2"))
        self.verticalLayout = QtGui.QVBoxLayout()
        self.verticalLayout.setObjectName(_fromUtf8("verticalLayout"))

        #Tworzenie zakładek
        self.tabs = QtGui.QTabWidget(self.centralwidget)

        #Główny wykre
        self.plot = QwtPlot(self.centralwidget)
        self.plot.setObjectName(_fromUtf8("plot"))
        self.plot.setAxisScale(self.plot.yLeft, -20, 80)
        self.plot.setAutoFillBackground(True)
        #self.plot.setPalette(Qt.Qt.black)
        self.plot.setCanvasBackground(Qt.Qt.black)

        self.grid = QwtPlotGrid()
        '''self.Yscale = QwtScaleDiv()
        self.Yscale.setInterval(10)
        self.Xscale = QwtScaleDiv()
        self.Xscale.setInterval(10)
        self.grid.setYDiv(self.YScale)
        self.grid.setXDiv(self.Xscale)'''
        self.grid.setMajPen(Qt.Qt.gray)
        self.grid.attach(self.plot)

        self.tabs.addTab(self.plot, "Spectrum")

        self.curve = QwtPlotCurve('')
        self.curve.setPen(Qt.Qt.yellow)
        self.curve.attach(self.plot)

        self.hold_curve = QwtPlotCurve('')
        self.hold_curve.setPen(Qt.Qt.red)

        self.peak_marker = QwtPlotMarker()
        self.symbol = QwtSymbol(QwtSymbol.DTriangle, QtGui.QBrush(Qt.Qt.red),
                                QtGui.QPen(Qt.Qt.red), QtCore.QSize(10, 10))
        self.peak_marker.setSymbol(self.symbol)
        self.peak_marker.setLabelAlignment(Qt.Qt.AlignTop)

        self.sybmol_2 = QwtSymbol(QwtSymbol.DTriangle, QtGui.QBrush(Qt.Qt.red),
                                  QtGui.QPen(Qt.Qt.white),
                                  QtCore.QSize(10, 10))
        self.marker_1 = QwtPlotMarker()
        self.marker_1.setSymbol(self.sybmol_2)
        self.marker_1.setLabelAlignment(Qt.Qt.AlignTop)
        self.marker_2 = QwtPlotMarker()
        self.marker_2.setSymbol(self.sybmol_2)
        self.marker_2.setLabelAlignment(Qt.Qt.AlignTop)
        self.marker_3 = QwtPlotMarker()
        self.marker_3.setSymbol(self.sybmol_2)
        self.marker_3.setLabelAlignment(Qt.Qt.AlignTop)
        self.marker_4 = QwtPlotMarker()
        self.marker_4.setSymbol(self.sybmol_2)
        self.marker_4.setLabelAlignment(Qt.Qt.AlignTop)
        self.delta_marker = QwtPlotMarker()
        self.delta_marker.setSymbol(self.sybmol_2)
        self.delta_marker.setLabelAlignment(Qt.Qt.AlignTop)

        self.markers = [
            self.marker_1, self.marker_2, self.marker_3, self.marker_4
        ]

        self.save_curve_1 = QwtPlotCurve('')
        self.save_curve_1.setPen(Qt.Qt.green)
        self.save_curve_2 = QwtPlotCurve('')
        self.save_curve_2.setPen(Qt.Qt.cyan)
        self.save_curve_3 = QwtPlotCurve('')
        self.save_curve_3.setPen(Qt.Qt.magenta)
        self.saved_curves = [
            self.save_curve_1, self.save_curve_2, self.save_curve_3
        ]

        #Wykres waterfall
        '''self.plot_2 = QwtPlot(self.centralwidget)
        self.plot_2.setObjectName(_fromUtf8("plot_2"))
        
        self.waterfall = QwtPlotSpectrogram()
        self.waterfall.attach(self.plot_2)
        
        self.colorMap = QwtLinearColorMap(Qt.Qt.darkCyan, Qt.Qt.red)
        self.scaleColors(80)
        self.waterfall.setColorMap(self.colorMap)
        #self.waterfallData = QwtRasterData()
        #self.tabs.addTab(self.plot_2, "Waterfall")'''

        self.verticalLayout.addWidget(self.tabs)

        self.picker = QwtPlotPicker(
            QwtPlot.xBottom, QwtPlot.yLeft,
            QwtPicker.PointSelection | QwtPicker.DragSelection,
            QwtPlotPicker.CrossRubberBand, QwtPicker.AlwaysOn,
            self.plot.canvas())
        self.picker.setTrackerPen(Qt.Qt.white)
        self.picker.setRubberBandPen(Qt.Qt.gray)

        self.freqBox = QtGui.QGroupBox(self.centralwidget)
        self.freqBox.setObjectName(_fromUtf8("freqBox"))
        self.verticalLayout_3 = QtGui.QVBoxLayout(self.freqBox)

        self.horizontalLayout = QtGui.QHBoxLayout()
        self.horizontalLayout.setObjectName(_fromUtf8("horizontalLayout"))

        self.formLayout_3 = QtGui.QFormLayout()
        self.formLayout_3.setObjectName(_fromUtf8("formLayout_3"))
        self.label = QtGui.QLabel(self.freqBox)
        self.label.setObjectName(_fromUtf8("label"))
        self.formLayout_3.setWidget(0, QtGui.QFormLayout.LabelRole, self.label)

        self.startEdit = QtGui.QDoubleSpinBox(self.freqBox)
        self.startEdit.setObjectName(_fromUtf8("startEdit"))
        self.startEdit.setDecimals(2)
        self.startEdit.setRange(1, 1280)
        self.startEdit.setKeyboardTracking(False)
        self.formLayout_3.setWidget(0, QtGui.QFormLayout.FieldRole,
                                    self.startEdit)
        self.horizontalLayout.addLayout(self.formLayout_3)

        self.formLayout_4 = QtGui.QFormLayout()
        self.formLayout_4.setObjectName(_fromUtf8("formLayout_4"))
        self.label_2 = QtGui.QLabel(self.freqBox)
        self.label_2.setObjectName(_fromUtf8("label_2"))
        self.formLayout_4.setWidget(0, QtGui.QFormLayout.LabelRole,
                                    self.label_2)

        self.stopEdit = QtGui.QDoubleSpinBox(self.freqBox)
        self.stopEdit.setObjectName(_fromUtf8("stopEdit"))
        self.stopEdit.setDecimals(2)
        self.stopEdit.setRange(1, 1280)
        self.stopEdit.setKeyboardTracking(False)

        self.formLayout_4.setWidget(0, QtGui.QFormLayout.FieldRole,
                                    self.stopEdit)
        self.horizontalLayout.addLayout(self.formLayout_4)
        self.formLayout_5 = QtGui.QFormLayout()
        self.formLayout_5.setObjectName(_fromUtf8("formLayout_5"))
        self.label_3 = QtGui.QLabel(self.freqBox)
        self.label_3.setObjectName(_fromUtf8("label_3"))
        self.formLayout_5.setWidget(0, QtGui.QFormLayout.LabelRole,
                                    self.label_3)

        self.rbwEdit = QtGui.QComboBox(self.freqBox)
        self.rbwEdit.setObjectName(_fromUtf8("rbwEdit"))
        self.rbwEdit.addItem('0,21 kHz', 16384)
        self.rbwEdit.addItem('0,42 kHz', 8192)
        self.rbwEdit.addItem('0,84 kHz', 4096)
        self.rbwEdit.addItem('1,69 kHz', 2048)
        self.rbwEdit.addItem('3,38 kHz', 1024)
        self.rbwEdit.addItem('6,75 kHz', 512)
        self.rbwEdit.addItem('13,5 kHz', 256)
        self.rbwEdit.addItem('27 kHz', 128)
        self.rbwEdit.addItem('54 kHz', 64)
        self.rbwEdit.addItem('108 kHz', 32)
        self.rbwEdit.addItem('216 kHz', 16)
        self.rbwEdit.addItem('432 kHz', 8)
        self.rbwEdit.setCurrentIndex(4)

        self.formLayout_5.setWidget(0, QtGui.QFormLayout.FieldRole,
                                    self.rbwEdit)
        self.horizontalLayout.addLayout(self.formLayout_5)
        spacerItem = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding,
                                       QtGui.QSizePolicy.Minimum)
        self.horizontalLayout.addItem(spacerItem)
        self.verticalLayout_3.addLayout(self.horizontalLayout)

        self.horizontalLayout_3 = QtGui.QHBoxLayout()
        self.horizontalLayout_3.setObjectName(_fromUtf8("horizontalLayout_3"))
        self.formLayout_7 = QtGui.QFormLayout()
        self.formLayout_7.setObjectName(_fromUtf8("formLayout_7"))
        self.centerLabel = QtGui.QLabel(self.freqBox)
        self.centerLabel.setObjectName(_fromUtf8("centerLabel"))
        self.formLayout_7.setWidget(0, QtGui.QFormLayout.LabelRole,
                                    self.centerLabel)

        self.centerEdit = QtGui.QDoubleSpinBox(self.freqBox)
        self.centerEdit.setObjectName(_fromUtf8("centerEdit"))
        self.centerEdit.setDecimals(2)
        self.centerEdit.setRange(1, 1280)
        self.centerEdit.setKeyboardTracking(False)
        self.formLayout_7.setWidget(0, QtGui.QFormLayout.FieldRole,
                                    self.centerEdit)
        self.horizontalLayout_3.addLayout(self.formLayout_7)

        self.formLayout_8 = QtGui.QFormLayout()
        self.formLayout_8.setObjectName(_fromUtf8("formLayout_8"))
        self.spanLabel = QtGui.QLabel(self.freqBox)
        self.spanLabel.setObjectName(_fromUtf8("spanLabel"))
        self.formLayout_8.setWidget(0, QtGui.QFormLayout.LabelRole,
                                    self.spanLabel)

        self.spanEdit = QtGui.QDoubleSpinBox(self.freqBox)
        self.spanEdit.setObjectName(_fromUtf8("spanEdit"))
        self.spanEdit.setDecimals(2)
        self.spanEdit.setRange(0.1, 1280)
        self.spanEdit.setKeyboardTracking(False)
        self.formLayout_8.setWidget(0, QtGui.QFormLayout.FieldRole,
                                    self.spanEdit)
        self.horizontalLayout_3.addLayout(self.formLayout_8)
        self.horizontalLayout_3.addItem(spacerItem)
        self.verticalLayout_3.addLayout(self.horizontalLayout_3)

        self.verticalLayout.addWidget(self.freqBox)
        self.horizontalLayout_2.addLayout(self.verticalLayout)

        self.settingsBox = QtGui.QGroupBox(self.centralwidget)
        self.settingsBox.setMaximumSize(QtCore.QSize(250, 16777215))
        self.settingsBox.setObjectName(_fromUtf8("settingsBox"))
        self.verticalLayout_2 = QtGui.QVBoxLayout(self.settingsBox)
        self.verticalLayout_2.setObjectName(_fromUtf8("verticalLayout_2"))

        self.formLayout = QtGui.QFormLayout()
        self.formLayout.setObjectName(_fromUtf8("formLayout"))
        self.gainLabel = QtGui.QLabel(self.settingsBox)
        self.gainLabel.setAlignment(QtCore.Qt.AlignRight
                                    | QtCore.Qt.AlignTrailing
                                    | QtCore.Qt.AlignVCenter)
        self.gainLabel.setObjectName(_fromUtf8("gainLabel"))
        self.formLayout.setWidget(0, QtGui.QFormLayout.LabelRole,
                                  self.gainLabel)
        self.gainSlider = QtGui.QSlider(self.settingsBox)
        self.gainSlider.setMaximum(49)
        self.gainSlider.setSingleStep(1)
        self.gainSlider.setProperty("value", 20)
        self.gainSlider.setOrientation(QtCore.Qt.Horizontal)
        self.gainSlider.setObjectName(_fromUtf8("gainSlider"))
        self.formLayout.setWidget(0, QtGui.QFormLayout.FieldRole,
                                  self.gainSlider)
        self.verticalLayout_2.addLayout(self.formLayout)

        self.gainDisp = QtGui.QLCDNumber(self.settingsBox)
        self.gainDisp.setSegmentStyle(QtGui.QLCDNumber.Flat)
        self.verticalLayout_2.addWidget(self.gainDisp)
        '''self.offsetButton = QtGui.QPushButton(self.settingsBox)
        self.offsetButton.setText("Remove DC offset")
        self.verticalLayout_2.addWidget(self.offsetButton)  '''

        self.formLayout_2 = QtGui.QFormLayout()
        self.formLayout_2.setObjectName(_fromUtf8("formLayout_2"))
        self.refLabel = QtGui.QLabel(self.settingsBox)
        self.refLabel.setAlignment(QtCore.Qt.AlignRight
                                   | QtCore.Qt.AlignTrailing
                                   | QtCore.Qt.AlignVCenter)
        self.refLabel.setObjectName(_fromUtf8("refLabel"))
        self.formLayout_2.setWidget(0, QtGui.QFormLayout.LabelRole,
                                    self.refLabel)
        self.refEdit = QtGui.QDoubleSpinBox(self.settingsBox)
        self.refEdit.setObjectName(_fromUtf8("refEdit"))
        self.refEdit.setDecimals(0)
        self.refEdit.setKeyboardTracking(False)
        self.formLayout_2.setWidget(0, QtGui.QFormLayout.FieldRole,
                                    self.refEdit)
        self.verticalLayout_2.addLayout(self.formLayout_2)

        spacerItem1 = QtGui.QSpacerItem(158, 304, QtGui.QSizePolicy.Minimum,
                                        QtGui.QSizePolicy.Expanding)
        self.verticalLayout_2.addItem(spacerItem1)

        #Settings tabs
        self.settings_tabs = QtGui.QTabWidget(self.settingsBox)
        self.verticalLayout_2.addWidget(self.settings_tabs)

        self.verticalLayout_4 = QtGui.QVBoxLayout()
        self.saveButton = QtGui.QPushButton(self.settingsBox)
        self.saveButton.setText("Save plot")
        self.verticalLayout_4.addWidget(self.saveButton)

        self.formLayout_9 = QtGui.QFormLayout()
        self.formLayout_9.setObjectName(_fromUtf8("formLayout_9"))
        self.avgLabel = QtGui.QLabel(self.settingsBox)
        self.avgLabel.setAlignment(QtCore.Qt.AlignRight
                                   | QtCore.Qt.AlignTrailing
                                   | QtCore.Qt.AlignVCenter)
        self.avgLabel.setObjectName(_fromUtf8("avgLabel"))
        self.formLayout_9.setWidget(0, QtGui.QFormLayout.LabelRole,
                                    self.avgLabel)
        self.avgCheck = QtGui.QCheckBox(self.settingsBox)
        self.formLayout_9.setWidget(0, QtGui.QFormLayout.FieldRole,
                                    self.avgCheck)
        self.verticalLayout_4.addLayout(self.formLayout_9)

        self.formLayout_10 = QtGui.QFormLayout()
        self.avgLabel_2 = QtGui.QLabel(self.settingsBox)
        self.avgLabel_2.setAlignment(QtCore.Qt.AlignRight
                                     | QtCore.Qt.AlignTrailing
                                     | QtCore.Qt.AlignVCenter)
        self.avgLabel_2.setObjectName(_fromUtf8("avgLabel_2"))
        self.formLayout_10.setWidget(0, QtGui.QFormLayout.LabelRole,
                                     self.avgLabel_2)
        self.avgEdit = QtGui.QDoubleSpinBox(self.settingsBox)
        self.avgEdit.setDecimals(0)
        self.avgEdit.setRange(1, 100)
        self.avgEdit.setKeyboardTracking(False)
        self.avgEdit.setValue(10)
        self.formLayout_10.setWidget(0, QtGui.QFormLayout.FieldRole,
                                     self.avgEdit)
        self.verticalLayout_4.addLayout(self.formLayout_10)

        self.formLayout_6 = QtGui.QFormLayout()
        self.formLayout_6.setObjectName(_fromUtf8("formLayout_6"))
        self.holdLabel = QtGui.QLabel(self.settingsBox)
        self.holdLabel.setAlignment(QtCore.Qt.AlignRight
                                    | QtCore.Qt.AlignTrailing
                                    | QtCore.Qt.AlignVCenter)
        self.holdLabel.setObjectName(_fromUtf8("holdLabel"))
        self.formLayout_6.setWidget(0, QtGui.QFormLayout.LabelRole,
                                    self.holdLabel)
        self.holdCheck = QtGui.QCheckBox(self.settingsBox)
        self.formLayout_6.setWidget(0, QtGui.QFormLayout.FieldRole,
                                    self.holdCheck)
        self.verticalLayout_4.addLayout(self.formLayout_6)

        self.formLayout_11 = QtGui.QFormLayout()
        self.formLayout_11.setObjectName(_fromUtf8("formLayout_11"))
        self.peakLabel = QtGui.QLabel(self.settingsBox)
        self.peakLabel.setAlignment(QtCore.Qt.AlignRight
                                    | QtCore.Qt.AlignTrailing
                                    | QtCore.Qt.AlignVCenter)
        self.peakLabel.setObjectName(_fromUtf8("peakLabel"))
        self.formLayout_11.setWidget(0, QtGui.QFormLayout.LabelRole,
                                     self.peakLabel)
        self.peakCheck = QtGui.QCheckBox(self.settingsBox)
        self.formLayout_11.setWidget(0, QtGui.QFormLayout.FieldRole,
                                     self.peakCheck)
        self.verticalLayout_4.addLayout(self.formLayout_11)

        self.peakStatus = QtGui.QLabel("Peak: ")

        self.correctButton = QtGui.QPushButton(self.settingsBox)
        self.correctButton.setText("Correction")
        self.verticalLayout_4.addWidget(self.correctButton)

        self.verticalLayout_5 = QtGui.QVBoxLayout()
        self.traceButton = QtGui.QPushButton(self.settingsBox)
        self.traceButton.setText("Save trace 1")
        self.verticalLayout_5.addWidget(self.traceButton)

        self.traceButton_2 = QtGui.QPushButton(self.settingsBox)
        self.traceButton_2.setText("Save trace 2")
        self.verticalLayout_5.addWidget(self.traceButton_2)

        self.traceButton_3 = QtGui.QPushButton(self.settingsBox)
        self.traceButton_3.setText("Save trace 3")
        self.verticalLayout_5.addWidget(self.traceButton_3)

        self.traces = [
            self.traceButton, self.traceButton_2, self.traceButton_3
        ]

        #MARKERS
        self.gridLayout = QtGui.QGridLayout()
        self.markerLabel = QtGui.QLabel(self.settingsBox)
        self.markerLabel.setAlignment(QtCore.Qt.AlignRight
                                      | QtCore.Qt.AlignTrailing
                                      | QtCore.Qt.AlignVCenter)
        self.gridLayout.addWidget(self.markerLabel, 0, 0)
        self.markerCheck = QtGui.QCheckBox(self.settingsBox)
        self.gridLayout.addWidget(self.markerCheck, 0, 1)
        self.markerEdit = QtGui.QDoubleSpinBox(self.settingsBox)
        self.markerEdit.setDecimals(2)
        self.markerEdit.setKeyboardTracking(False)
        self.markerEdit.setDisabled(True)
        self.markerEdit.setSingleStep(0.1)
        self.gridLayout.addWidget(self.markerEdit, 0, 2)

        self.markerLabel_2 = QtGui.QLabel(self.settingsBox)
        self.markerLabel_2.setAlignment(QtCore.Qt.AlignRight
                                        | QtCore.Qt.AlignTrailing
                                        | QtCore.Qt.AlignVCenter)
        self.gridLayout.addWidget(self.markerLabel_2, 2, 0)
        self.markerCheck_2 = QtGui.QCheckBox(self.settingsBox)
        self.gridLayout.addWidget(self.markerCheck_2, 2, 1)
        self.markerEdit_2 = QtGui.QDoubleSpinBox(self.settingsBox)
        self.markerEdit_2.setDecimals(2)
        self.markerEdit_2.setKeyboardTracking(False)
        self.markerEdit_2.setDisabled(True)
        self.markerEdit_2.setSingleStep(0.1)
        self.gridLayout.addWidget(self.markerEdit_2, 2, 2)

        self.markerLabel_3 = QtGui.QLabel(self.settingsBox)
        self.markerLabel_3.setAlignment(QtCore.Qt.AlignRight
                                        | QtCore.Qt.AlignTrailing
                                        | QtCore.Qt.AlignVCenter)
        self.gridLayout.addWidget(self.markerLabel_3, 3, 0)
        self.markerCheck_3 = QtGui.QCheckBox(self.settingsBox)
        self.gridLayout.addWidget(self.markerCheck_3, 3, 1)
        self.markerEdit_3 = QtGui.QDoubleSpinBox(self.settingsBox)
        self.markerEdit_3.setDecimals(2)
        self.markerEdit_3.setKeyboardTracking(False)
        self.markerEdit_3.setDisabled(True)
        self.markerEdit_3.setSingleStep(0.1)
        self.gridLayout.addWidget(self.markerEdit_3, 3, 2)

        self.markerLabel_4 = QtGui.QLabel(self.settingsBox)
        self.markerLabel_4.setAlignment(QtCore.Qt.AlignRight
                                        | QtCore.Qt.AlignTrailing
                                        | QtCore.Qt.AlignVCenter)
        self.gridLayout.addWidget(self.markerLabel_4, 4, 0)
        self.markerCheck_4 = QtGui.QCheckBox(self.settingsBox)
        self.gridLayout.addWidget(self.markerCheck_4, 4, 1)
        self.markerEdit_4 = QtGui.QDoubleSpinBox(self.settingsBox)
        self.markerEdit_4.setDecimals(2)
        self.markerEdit_4.setKeyboardTracking(False)
        self.markerEdit_4.setDisabled(True)
        self.markerEdit_4.setSingleStep(0.1)
        self.gridLayout.addWidget(self.markerEdit_4, 4, 2)

        self.deltaLabel = QtGui.QLabel(self.settingsBox)
        self.deltaLabel.setAlignment(QtCore.Qt.AlignRight
                                     | QtCore.Qt.AlignTrailing
                                     | QtCore.Qt.AlignVCenter)
        self.gridLayout.addWidget(self.deltaLabel, 1, 0)
        self.deltaCheck = QtGui.QCheckBox(self.settingsBox)
        self.gridLayout.addWidget(self.deltaCheck, 1, 1)
        self.deltaEdit = QtGui.QDoubleSpinBox(self.settingsBox)
        self.deltaEdit.setDecimals(2)
        self.deltaEdit.setSingleStep(0.1)
        self.deltaEdit.setKeyboardTracking(False)
        self.deltaEdit.setDisabled(True)
        self.gridLayout.addWidget(self.deltaEdit, 1, 2)
        self.deltaCheck.setDisabled(True)

        self.tab1 = QtGui.QWidget()
        self.settings_tabs.addTab(self.tab1, "Misc.")
        self.settings_tabs.widget(0).setLayout(self.verticalLayout_4)

        self.tab2 = QtGui.QWidget()
        self.settings_tabs.addTab(self.tab2, "Traces")
        self.settings_tabs.widget(1).setLayout(self.verticalLayout_5)

        self.tab3 = QtGui.QWidget()
        self.settings_tabs.addTab(self.tab3, "Markers")
        self.settings_tabs.widget(2).setLayout(self.gridLayout)

        self.horizontalLayout_2.addWidget(self.settingsBox)
        MainWindow.setCentralWidget(self.centralwidget)
        self.menubar = QtGui.QMenuBar(MainWindow)
        self.menubar.setGeometry(QtCore.QRect(0, 0, 847, 21))
        self.menubar.setObjectName(_fromUtf8("menubar"))
        MainWindow.setMenuBar(self.menubar)
        self.statusbar = QtGui.QStatusBar(MainWindow)
        self.statusbar.setObjectName(_fromUtf8("statusbar"))
        MainWindow.setStatusBar(self.statusbar)
        self.statusbar.addWidget(self.peakStatus)
        self.statusbar.setVisible(False)

        self.retranslateUi(MainWindow)
        QtCore.QMetaObject.connectSlotsByName(MainWindow)

        self.gainSlider.valueChanged.connect(self.gainDisp.display)
        self.saveButton.clicked.connect(self.savePlot)
Ejemplo n.º 5
0
    def __init__(self, image, parent, imgman, name=None, save=False):
        QFrame.__init__(self, parent)
        self.setFrameStyle(QFrame.StyledPanel | QFrame.Raised)
        # init state
        self.image = image
        self._imgman = imgman
        self._currier = PersistentCurrier()
        self._control_dialog = None
        # create widgets
        self._lo = lo = QHBoxLayout(self)
        lo.setContentsMargins(0, 0, 0, 0)
        lo.setSpacing(2)
        # raise button
        self._wraise = QToolButton(self)
        lo.addWidget(self._wraise)
        self._wraise.setIcon(pixmaps.raise_up.icon())
        self._wraise.setAutoRaise(True)
        self._can_raise = False
        QObject.connect(self._wraise, SIGNAL("clicked()"), self._raiseButtonPressed)
        self._wraise.setToolTip("""<P>Click here to raise this image above other images. Hold the button down briefly to
      show a menu of image operations.</P>""")
        # center label
        self._wcenter = QLabel(self)
        self._wcenter.setPixmap(pixmaps.center_image.pm())
        self._wcenter.setToolTip(
            "<P>The plot is currently centered on (the reference pixel %d,%d) of this image.</P>" % self.image.referencePixel())
        lo.addWidget(self._wcenter)
        # name/filename label
        self.name = image.name
        self._wlabel = QLabel(self.name, self)
        self._number = 0
        self.setName(self.name)
        self._wlabel.setToolTip("%s %s" % (image.filename, "\u00D7".join(map(str, image.data().shape))))
        lo.addWidget(self._wlabel, 1)
        # if 'save' is specified, create a "save" button
        if save:
            self._wsave = QToolButton(self)
            lo.addWidget(self._wsave)
            self._wsave.setText("save")
            self._wsave.setAutoRaise(True)
            self._save_dir = save if isinstance(save, str) else "."
            QObject.connect(self._wsave, SIGNAL("clicked()"), self._saveImage)
            self._wsave.setToolTip("""<P>Click here to write this image to a FITS file.</P>""")
        # render control
        dprint(2, "creating RenderControl")
        self._rc = RenderControl(image, self)
        dprint(2, "done")
        # selectors for extra axes
        self._wslicers = []
        curslice = self._rc.currentSlice();  # this may be loaded from config, so not necessarily 0
        for iextra, axisname, labels in self._rc.slicedAxes():
            if axisname.upper() not in ["STOKES", "COMPLEX"]:
                lbl = QLabel("%s:" % axisname, self)
                lo.addWidget(lbl)
            else:
                lbl = None
            slicer = QComboBox(self)
            self._wslicers.append(slicer)
            lo.addWidget(slicer)
            slicer.addItems(labels)
            slicer.setToolTip("""<P>Selects current slice along the %s axis.</P>""" % axisname)
            slicer.setCurrentIndex(curslice[iextra])
            QObject.connect(slicer, SIGNAL("activated(int)"), self._currier.curry(self._rc.changeSlice, iextra))
        # min/max display ranges
        lo.addSpacing(5)
        self._wrangelbl = QLabel(self)
        lo.addWidget(self._wrangelbl)
        self._minmaxvalidator = FloatValidator(self)
        self._wmin = QLineEdit(self)
        self._wmax = QLineEdit(self)
        width = self._wmin.fontMetrics().width("1.234567e-05")
        for w in self._wmin, self._wmax:
            lo.addWidget(w, 0)
            w.setValidator(self._minmaxvalidator)
            w.setMaximumWidth(width)
            w.setMinimumWidth(width)
            QObject.connect(w, SIGNAL("editingFinished()"), self._changeDisplayRange)
        # full-range button
        self._wfullrange = QToolButton(self)
        lo.addWidget(self._wfullrange, 0)
        self._wfullrange.setIcon(pixmaps.zoom_range.icon())
        self._wfullrange.setAutoRaise(True)
        QObject.connect(self._wfullrange, SIGNAL("clicked()"), self.renderControl().resetSubsetDisplayRange)
        rangemenu = QMenu(self)
        rangemenu.addAction(pixmaps.full_range.icon(), "Full subset", self.renderControl().resetSubsetDisplayRange)
        for percent in (99.99, 99.9, 99.5, 99, 98, 95):
            rangemenu.addAction("%g%%" % percent, self._currier.curry(self._changeDisplayRangeToPercent, percent))
        self._wfullrange.setPopupMode(QToolButton.DelayedPopup)
        self._wfullrange.setMenu(rangemenu)
        # update widgets from current display range
        self._updateDisplayRange(*self._rc.displayRange())
        # lock button
        self._wlock = QToolButton(self)
        self._wlock.setIcon(pixmaps.unlocked.icon())
        self._wlock.setAutoRaise(True)
        self._wlock.setToolTip("""<P>Click to lock or unlock the intensity range. When the intensity range is locked across multiple images, any changes in the intensity
          range of one are propagated to the others. Hold the button down briefly for additional options.</P>""")
        lo.addWidget(self._wlock)
        QObject.connect(self._wlock, SIGNAL("clicked()"), self._toggleDisplayRangeLock)
        QObject.connect(self.renderControl(), SIGNAL("displayRangeLocked"), self._setDisplayRangeLock)
        QObject.connect(self.renderControl(), SIGNAL("dataSubsetChanged"), self._dataSubsetChanged)
        lockmenu = QMenu(self)
        lockmenu.addAction(pixmaps.locked.icon(), "Lock all to this",
                           self._currier.curry(imgman.lockAllDisplayRanges, self.renderControl()))
        lockmenu.addAction(pixmaps.unlocked.icon(), "Unlock all", imgman.unlockAllDisplayRanges)
        self._wlock.setPopupMode(QToolButton.DelayedPopup)
        self._wlock.setMenu(lockmenu)
        self._setDisplayRangeLock(self.renderControl().isDisplayRangeLocked())
        # dialog button
        self._wshowdialog = QToolButton(self)
        lo.addWidget(self._wshowdialog)
        self._wshowdialog.setIcon(pixmaps.colours.icon())
        self._wshowdialog.setAutoRaise(True)
        self._wshowdialog.setToolTip("""<P>Click for colourmap and intensity policy options.</P>""")
        QObject.connect(self._wshowdialog, SIGNAL("clicked()"), self.showRenderControls)
        tooltip = """<P>You can change the currently displayed intensity range by entering low and high limits here.</P>
    <TABLE>
      <TR><TD><NOBR>Image min:</NOBR></TD><TD>%g</TD><TD>max:</TD><TD>%g</TD></TR>
      </TABLE>""" % self.image.imageMinMax()
        for w in self._wmin, self._wmax, self._wrangelbl:
            w.setToolTip(tooltip)

        # create image operations menu
        self._menu = QMenu(self.name, self)
        self._qa_raise = self._menu.addAction(pixmaps.raise_up.icon(), "Raise image",
                                              self._currier.curry(self.image.emit, SIGNAL("raise")))
        self._qa_center = self._menu.addAction(pixmaps.center_image.icon(), "Center plot on image",
                                               self._currier.curry(self.image.emit, SIGNAL("center")))
        self._qa_show_rc = self._menu.addAction(pixmaps.colours.icon(), "Colours && Intensities...",
                                                self.showRenderControls)
        if save:
            self._qa_save = self._menu.addAction("Save image...", self._saveImage)
        self._menu.addAction("Export image to PNG file...", self._exportImageToPNG)
        self._export_png_dialog = None
        self._menu.addAction("Unload image", self._currier.curry(self.image.emit, SIGNAL("unload")))
        self._wraise.setMenu(self._menu)
        self._wraise.setPopupMode(QToolButton.DelayedPopup)

        # connect updates from renderControl and image
        self.image.connect(SIGNAL("slice"), self._updateImageSlice)
        QObject.connect(self._rc, SIGNAL("displayRangeChanged"), self._updateDisplayRange)

        # default plot depth of image markers
        self._z_markers = None
        # and the markers themselves
        self._image_border = QwtPlotCurve()
        self._image_label = QwtPlotMarker()

        # subset markers
        self._subset_pen = QPen(QColor("Light Blue"))
        self._subset_border = QwtPlotCurve()
        self._subset_border.setPen(self._subset_pen)
        self._subset_border.setVisible(False)
        self._subset_label = QwtPlotMarker()
        text = QwtText("subset")
        text.setColor(self._subset_pen.color())
        self._subset_label.setLabel(text)
        self._subset_label.setLabelAlignment(Qt.AlignRight | Qt.AlignBottom)
        self._subset_label.setVisible(False)
        self._setting_lmrect = False

        self._all_markers = [self._image_border, self._image_label, self._subset_border, self._subset_label]