Esempio n. 1
0
 def mkline(self, xdata, ydata, style=('black', '-'), title=''):
     line = QwtPlotCurve(title)
     if title is '':
         # don't display it in the legend
         # kind of ugly, that the title variable is doing double duty
         line.setItemAttribute(QwtPlotItem.Legend, False)
     pen = self.getPen(*style)
     line.setPen(pen)
     line.setRenderHint(QwtPlotItem.RenderAntialiased)
     line.setData(xdata, ydata)
     return line
Esempio n. 2
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)
Esempio n. 3
0
    def initQwtPlot(self):
        self.PlotBuff = ''
        self.PlotData = [0] * 1000

        self.qwtPlot = QwtPlot(self)
        self.vLayout0.insertWidget(0, self.qwtPlot)

        self.PlotCurve = QwtPlotCurve()
        self.PlotCurve.attach(self.qwtPlot)
        self.PlotCurve.setData(range(1, len(self.PlotData) + 1), self.PlotData)

        self.on_cmbMode_currentIndexChanged(u'文本')
Esempio n. 4
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
Esempio n. 5
0
 def __init__(self, parent=None):
     super(IVSweepWidget, self).__init__(parent)
     self.setupUi(self)
     self.restoreSettings()
     self.msmThread = None
     self.startPb.clicked.connect(self.startPbClicked)
     self.adrTemp = TemperatureSubscriber(self)
     self.adrTemp.adrTemperature.connect(self.temperatureSb.setValue)
     self.adrTemp.start()
     self.plot.setAxisTitle(QwtPlot.yLeft, 'Vmeas')
     self.plot.setAxisTitle(QwtPlot.xBottom, 'Vdrive')
     self.curve = QwtPlotCurve('')
     self.curve.attach(self.plot)
     self.clearData()
     self.clearPb.clicked.connect(self.clearData)
Esempio n. 6
0
    def attachCurves(self, wdg, profiles):
        for i in range(0, len(profiles)):
            tmp_name = ("%s") % (profiles[i]["layer"].name())

            # As QwtPlotCurve doesn't support nodata, split the data into
            # single lines
            # with breaks wherever data is None.
            # Prepare two lists of coordinates (xx and yy). Make x=None
            # whenever y is None.
            xx = profiles[i]["l"]
            yy = profiles[i]["z"]
            for j in range(len(yy)):
                if yy[j] is None:
                    xx[j] = None

            # Split xx and yy into single lines at None values
            xx = [
                list(g) for k, g in itertools.groupby(xx, lambda x: x is None)
                if not k
            ]
            yy = [
                list(g) for k, g in itertools.groupby(yy, lambda x: x is None)
                if not k
            ]

            Cstyle = profiles[i]["style"]
            # Create & attach one QwtPlotCurve per one single line
            for j in range(len(xx)):
                curve = QwtPlotCurve(tmp_name)
                curve.setData(xx[j], yy[j])
                curve.setPen(Cstyle)
                curve.attach(wdg)

            # scaling this
            try:
                wdg.setAxisScale(2, 0, max(profiles[len(profiles) - 1]["l"]),
                                 0)
                self.resetScale(wdg, profiles)
            except:
                pass
                # self.iface.mainWindow().statusBar().showMessage(
                # "Problem with setting scale of plotting")
        # self.resetScale(wdg, profiles)
        wdg.replot()
Esempio n. 7
0
def plot_curve(title=None,
               pen=None,
               brush=None,
               style=QwtPlotCurve.Lines,
               symbol=QwtSymbol.Ellipse,
               legend=True,
               antialias=True,
               auto_scale=True,
               xaxis=QwtPlot.xBottom,
               yaxis=QwtPlot.yLeft):
    curve = QwtPlotCurve(title or "")
    return configure_curve(curve,
                           pen=pen,
                           brush=brush,
                           style=style,
                           symbol=symbol,
                           legend=legend,
                           antialias=antialias,
                           auto_scale=auto_scale,
                           xaxis=xaxis,
                           yaxis=yaxis)
Esempio n. 8
0
    def __init__(self, title, xdata, ydata, style, symbol=None, *args):
        super(BMPlot, self).__init__(*args)
        self.setMinimumSize(200, 200)
        self.setTitle(title)
        self.setAxisTitle(QwtPlot.xBottom, 'x')
        self.setAxisTitle(QwtPlot.yLeft, 'y')
        self.curve_nb = 0
        for idx in range(1, 11):
            self.curve_nb += 1
            curve = QwtPlotCurve()
            curve.setPen(QPen(get_curve_color()))
            curve.setStyle(style)
            curve.setRenderHint(QwtPlotCurve.RenderAntialiased)
            if symbol is not None:
                curve.setSymbol(symbol)
            curve.attach(self)
            curve.setData(xdata, ydata * idx, finite=False)


#        self.setAxisScale(self.yLeft, -1.5, 1.5)
#        self.setAxisScale(self.xBottom, 9.9, 10.)
        self.replot()
Esempio n. 9
0
if len(sys.argv) < 2:
    print 'You must specify the date as a parameter'
    sys.exit(-1)

from PyQt4 import QtCore, QtGui
from PyQt4.Qwt5 import QwtPlot, QwtPlotCurve
import pickle

data = sys.argv[1]

app = QtGui.QApplication(sys.argv)

p = QwtPlot()

curve = QwtPlotCurve("Segon i tal")

fn = resDir + '/' + data
f = file(fn)
v = pickle.load(f)

y = v
x = range(len(y))

curve.setData(x, y)

curve.attach(p)

p.replot()

p.show()
Esempio n. 10
0
    def setupUi_plot(self):
        # plot
        self.plotLibSelector.setVisible(False)
        self.enableStatistics.setVisible(False)
        # stats by default because estimated are fast
        self.enableStatistics.setChecked(True)

        plot_count = 0
        self.mplLine = None  # make sure to invalidate when layers change

        if self.hasqwt:  # Page 2 - qwt
            self.plotLibSelector.addItem('Qwt')
            plot_count += 1
            # Setup Qwt Plot Area in Widget
            self.qwtPlot = QwtPlot(self.stackedWidget)
            self.qwtPlot.setAutoFillBackground(False)
            self.qwtPlot.setObjectName("qwtPlot")
            self.curve = QwtPlotCurve()
            self.curve.setSymbol(
                QwtSymbol(QwtSymbol.Ellipse, QBrush(Qt.white), QPen(Qt.red, 2),
                          QSize(9, 9)))
            self.curve.attach(self.qwtPlot)

            # Size Policy ???
            sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding,
                                           QtGui.QSizePolicy.Expanding)
            sizePolicy.setHorizontalStretch(0)
            sizePolicy.setVerticalStretch(0)
            sizePolicy.setHeightForWidth(
                self.qwtPlot.sizePolicy().hasHeightForWidth())
            self.qwtPlot.setSizePolicy(sizePolicy)
            # Size Policy ???

            self.qwtPlot.updateGeometry()
            self.stackedWidget.addWidget(self.qwtPlot)
            self.qwt_widgetnumber = self.stackedWidget.indexOf(self.qwtPlot)

        if self.hasmpl:  # Page 3 -  setup matplotlib
            self.plotLibSelector.addItem('matplotlib')
            # If matplotlib is the only one
            self.toggleInterpolation.setEnabled(True)
            self.toggleInterpolation.setVisible(True)
            plot_count += 1
            self.mplBackground = None
            # http://www.scipy.org/Cookbook/Matplotlib/Animations
            self.mplFig = plt.Figure(facecolor='w',
                                     edgecolor='g',
                                     linewidth=0.0)

            self.mpl_subplot = self.mplFig.add_subplot(111)
            self.pltCanvas = FigureCanvasQTAgg(self.mplFig)
            self.pltCanvas.setParent(self.stackedWidget)
            self.pltCanvas.setAutoFillBackground(False)
            self.pltCanvas.setObjectName("mplPlot")
            self.mplPlot = self.pltCanvas
            self.mplPlot.updateGeometry()
            self.stackedWidget.addWidget(self.mplPlot)
            self.mpl_widgetnumber = self.stackedWidget.indexOf(self.mplPlot)

        if self.haspqg:  # Page 3 - setup PyQtGraph
            self.plotLibSelector.addItem('PyQtGraph')
            plot_count += 1
            # Setup PyQtGraph stuff
            pg.setConfigOption('background', 'w')
            pg.setConfigOption('foreground', 'k')
            self.pqg_axis = DateTimeAxis(orientation='bottom')
            self.pqg_plot_widget = pg.PlotWidget(
                parent=self.stackedWidget, axisItems={'bottom': self.pqg_axis})
            self.pqg_plot_item = self.pqg_plot_widget.getPlotItem()
            self.pqg_plot_widget.updateGeometry()
            self.stackedWidget.addWidget(self.pqg_plot_widget)
            self.pqg_widgetnumber = self.stackedWidget.indexOf(
                self.pqg_plot_widget)
            # on zoom change do:
            self.pqg_plot_item.sigXRangeChanged.connect(self.refresh_ticks)

        if plot_count > 1:
            self.plotLibSelector.setEnabled(True)
            self.plotLibSelector.setVisible(True)
            self.plotLibSelector.setCurrentIndex(0)
            if self.hasqwt:
                self.plotLibSelector.setCurrentIndex(self.qwt_widgetnumber)
            elif self.hasmpl:
                self.plotLibSelector.setCurrentIndex(self.mpl_widgetnumber)
            else:
                self.plotLibSelector.setCurrentIndex(self.pqg_widgetnumber)
            self.change_plot()
        elif plot_count == 1:
            self.plotLibSelector.setCurrentIndex(0)
            self.change_plot()
        else:  # can only be 0 if nothing else matched
            message_text = "Mutant cannot find any graphiclibrary for " \
                           "creating plots. Please install either Qwt >= 5.0 " \
                           ",matplotlib >= 1.0 or PyQtGraph >= 0.9.8!"
            self.plot_message = QtGui.QLabel(message_text)
            self.plot_message.setWordWrap(True)
            self.stackedWidget.addWidget(self.plot_message)
            self.pop_messagebar(message_text)
Esempio n. 11
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)
Esempio n. 12
0
    def attachCurves(self, wdg, profiles, model1, library):
        if library == "Qwt5" and has_qwt:
            wdg.plotWdg.clear()
        for i in range(0, model1.rowCount()):
            profileName = model1.item(i, 4).data(Qt.EditRole)
            profileId = model1.item(i, 5).data(Qt.EditRole)
            isVisible = model1.item(i, 0).data(Qt.CheckStateRole)

            xx = profiles[i]["l"]
            yy = profiles[i][profileName]

            if library == "Qwt5" and has_qwt:
                # As QwtPlotCurve doesn't support nodata, split the data into single lines
                # with breaks wherever data is None.
                # Prepare two lists of coordinates (xx and yy). Make x=None whenever y==None.
                for j in range(len(yy)):
                    if yy[j] is None or isnan(yy[j]):
                        xx[j] = None
                        yy[j] = None

                # Split xx and yy into single lines at None values
                xx = [
                    list(g)
                    for k, g in itertools.groupby(xx, lambda x: x is None)
                    if not k
                ]
                yy = [
                    list(g)
                    for k, g in itertools.groupby(yy, lambda x: x is None)
                    if not k
                ]

                # Create & attach one QwtPlotCurve per one single line
                for j in range(len(xx)):
                    curve = QwtPlotCurve(profileId)
                    curve.setData(xx[j], yy[j])

                    curve.setPen(
                        QPen(model1.item(i, 1).data(Qt.BackgroundRole), 3))
                    curve.attach(wdg.plotWdg)
                    curve.setVisible(isVisible)

            elif library == "Matplotlib" and has_mpl:
                lines = wdg.plotWdg.figure.get_axes()[0].get_lines()
                lineIds = [line.get_gid() for line in lines]
                if profileId in lineIds:
                    # Update existing line
                    line = lines[lineIds.index(profileId)]
                    line.set_data([xx, yy])
                else:
                    # Create new line
                    line = wdg.plotWdg.figure.get_axes()[0].plot(
                        xx, yy, gid=profileId)[0]
                line.set_visible(isVisible)
                # X-axis have to be set before wdg is redrawn in changeColor, otherwise and
                # exception is sometimes thrown when time-based axis is used.
                minimumValueX = min(z for z in profiles[i]["l"])
                maximumValueX = max(z for z in profiles[i]["l"])
                wdg.plotWdg.figure.get_axes()[0].set_xlim(
                    [minimumValueX, maximumValueX])
                self.changeColor(wdg, "Matplotlib",
                                 model1.item(i, 1).data(Qt.BackgroundRole),
                                 profileId)
Esempio n. 13
0
    def setupUi_plot(self):

        # plot
        self.plotSelector.setVisible(False)
        self.cbxStats.setVisible(False)
        # stats by default because estimated are fast
        self.cbxStats.setChecked(True)
        self.plotSelector.addItem('Qwt')
        self.plotSelector.addItem('mpl')

        # Page 2 - qwt
        if self.hasqwt:
            self.qwtPlot = QwtPlot(self.stackedWidget)
            self.qwtPlot.setAutoFillBackground(False)
            self.qwtPlot.setObjectName("qwtPlot")
            self.curve = QwtPlotCurve()
            self.curve.setSymbol(
                QwtSymbol(QwtSymbol.Ellipse, QBrush(Qt.white), QPen(Qt.red, 2),
                          QSize(9, 9)))
            self.curve.attach(self.qwtPlot)
        else:
            self.qwtPlot = QtGui.QLabel(
                "Need Qwt >= 5.0 or matplotlib >= 1.0 !")

        sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding,
                                       QtGui.QSizePolicy.Expanding)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(
            self.qwtPlot.sizePolicy().hasHeightForWidth())
        self.qwtPlot.setSizePolicy(sizePolicy)
        self.qwtPlot.updateGeometry()
        self.stackedWidget.addWidget(self.qwtPlot)

        #Page 3 - matplotlib
        self.mplLine = None  #make sure to invalidate when layers change
        if self.hasmpl:
            # mpl stuff
            # should make figure light gray
            self.mplBackground = None  #http://www.scipy.org/Cookbook/Matplotlib/Animations
            self.mplFig = plt.Figure(facecolor='w', edgecolor='w')
            self.mplFig.subplots_adjust(left=0.1,
                                        right=0.975,
                                        bottom=0.13,
                                        top=0.95)
            self.mplPlt = self.mplFig.add_subplot(111)
            self.mplPlt.tick_params(axis='both', which='major', labelsize=12)
            self.mplPlt.tick_params(axis='both', which='minor', labelsize=10)
            # qt stuff
            self.pltCanvas = FigureCanvasQTAgg(self.mplFig)
            self.pltCanvas.setParent(self.stackedWidget)
            self.pltCanvas.setAutoFillBackground(False)
            self.pltCanvas.setObjectName("mplPlot")
            self.mplPlot = self.pltCanvas
        else:
            self.mplPlot = QtGui.QLabel(
                "Need Qwt >= 5.0 or matplotlib >= 1.0 !")

        sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding,
                                       QtGui.QSizePolicy.Expanding)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(
            self.mplPlot.sizePolicy().hasHeightForWidth())
        self.mplPlot.setSizePolicy(sizePolicy)
        self.mplPlot.updateGeometry()
        self.stackedWidget.addWidget(self.mplPlot)

        if (self.hasqwt and self.hasmpl):
            self.plotSelector.setEnabled(True)
            self.plotSelector.setVisible(True)
            self.plotSelector.setCurrentIndex(0)
        else:
            if self.hasqwt:
                self.plotSelector.setCurrentIndex(0)
            else:
                self.plotSelector.setCurrentIndex(1)
        self.changePlot()
Esempio n. 14
0
    def __init__(self):
        super(self.__class__, self).__init__()
        self.setupUi(self)
        self.label_current_state.installEventFilter(self)
        self.label_sensor.installEventFilter(self)
        self.label_sensor_1.installEventFilter(self)
        self.label_sensor_2.installEventFilter(self)
        self.label_sensor_3.installEventFilter(self)
        self.label_sensor_4.installEventFilter(self)

        self.label_humidity.installEventFilter(self)
        self.label_humidity_1.installEventFilter(self)
        self.label_humidity_2.installEventFilter(self)
        self.label_humidity_3.installEventFilter(self)
        self.label_humidity_4.installEventFilter(self)

        self.label_temperature.installEventFilter(self)
        self.label_temperature_1.installEventFilter(self)
        self.label_temperature_2.installEventFilter(self)
        self.label_temperature_3.installEventFilter(self)
        self.label_temperature_4.installEventFilter(self)
        """self.doubleSpinBox_humidity.installEventFilter(self)
        self.doubleSpinBox_humidity1.installEventFilter(self)
        self.doubleSpinBox_humidity2.installEventFilter(self)
        self.doubleSpinBox_humidity3.installEventFilter(self)
        self.doubleSpinBox_humidity4.installEventFilter(self)
        
        self.doubleSpinBox_temperature.installEventFilter(self)
        self.doubleSpinBox_temperature1.installEventFilter(self)
        self.doubleSpinBox_temperature2.installEventFilter(self)
        self.doubleSpinBox_temperature3.installEventFilter(self)
        self.doubleSpinBox_temperature4.installEventFilter(self)"""

        self.stateOfCurvers = [True, True, True, True, True]

        self.sensors = [
            "p11/raspberry/sht75.01", "p11/raspberry/sht75.02",
            "p11/raspberry/sht75.03", "p11/raspberry/sht75.04",
            "p11/raspberry/sht75.05"
        ]

        cwd = os.getcwd()
        self.filePath = cwd + "/data/"
        if not os.path.exists(self.filePath):
            os.makedirs(self.filePath)
        #print self.cwd
        self.filename = 'hum_data%s.csv' % time.strftime('%Y%m%d-%H%M%S')
        self.file = open(self.filePath + self.filename, 'wb')
        self.writer = csv.writer(self.file,
                                 delimiter=';',
                                 quotechar="",
                                 quoting=csv.QUOTE_NONE,
                                 escapechar=';')
        self.writer.writerow([
            '#Time',
            '#Temperature_1',
            'Humidity_1',
            'Temperature_2',
            'Humidity_2',
            'Temperature_3',
            'Humidity_3',
            'Temperature_4',
            'Humidity_4',
            'Temperature_5',
            'Humidity_5',
        ])

        self.label_sensor.setStyleSheet(
            "background-color: rgb(153,0,0); color: rgb(255,255,255);")
        self.label_sensor_1.setStyleSheet(
            "background-color: rgb(153,153,0); color: rgb(255,255,255);")
        self.label_sensor_2.setStyleSheet(
            "background-color: rgb(0,0,0); color: rgb(255,255,255);")
        self.label_sensor_3.setStyleSheet(
            "background-color: rgb(0,0,153); color: rgb(255,255,255);")
        self.label_sensor_4.setStyleSheet(
            "background-color: rgb(0,153,0); color: rgb(255,255,255);")

        #self.humidity = []
        #self.temperature = []
        self.humidity1 = "---"
        self.humidity2 = "---"
        self.humidity3 = "---"
        self.humidity4 = "---"
        self.humidity5 = "---"
        self.temperature1 = "---"
        self.temperature2 = "---"
        self.temperature3 = "---"
        self.temperature4 = "---"
        self.temperature5 = "---"

        self.doubleSpinBox_temperature.setValue(0.00)
        self.doubleSpinBox_humidity.setValue(0.00)
        self.doubleSpinBox_temperature1.setValue(0.00)
        self.doubleSpinBox_humidity1.setValue(0.00)
        self.doubleSpinBox_temperature2.setValue(0.00)
        self.doubleSpinBox_humidity2.setValue(0.00)
        self.doubleSpinBox_temperature3.setValue(0.00)
        self.doubleSpinBox_humidity3.setValue(0.00)
        self.doubleSpinBox_temperature4.setValue(0.00)
        self.doubleSpinBox_humidity4.setValue(0.00)

        self.containers = []
        for i in range(len(self.sensors)):
            #self.containers.append(deque(maxlen = 2250))
            self.containers.append(deque(maxlen=111))
        #self.times = deque(maxlen = 2250)
        self.times = deque(maxlen=111)

        self.qwtPlot.insertLegend(Qwt.QwtLegend(), Qwt.QwtPlot.BottomLegend)
        self.curve1 = QwtPlotCurve("Sensor1")
        #self.curve1.setPen(Qt.QPen(Qt.Qt.red, 3, Qt.Qt.SolidLine))
        self.curve1.setPen(Qt.QPen(QColor(153, 0, 0), 3, Qt.Qt.SolidLine))
        self.curve2 = QwtPlotCurve("Sensor2")
        #self.curve2.setPen(Qt.QPen(Qt.Qt.yellow, 3, Qt.Qt.SolidLine))
        self.curve2.setPen(Qt.QPen(QColor(153, 153, 0), 3, Qt.Qt.SolidLine))
        self.curve3 = QwtPlotCurve("Sensor3")
        #self.curve3.setPen(Qt.QPen(Qt.Qt.black, 3, Qt.Qt.SolidLine))
        self.curve3.setPen(Qt.QPen(QColor(0, 0, 0), 3, Qt.Qt.SolidLine))
        self.curve4 = QwtPlotCurve("Sensor4")
        #self.curve4.setPen(Qt.QPen(Qt.Qt.blue, 3, Qt.Qt.SolidLine))
        self.curve4.setPen(Qt.QPen(QColor(0, 0, 153), 3, Qt.Qt.SolidLine))
        #self.curve5 = QwtPlotCurve("Sensor5")
        #self.curve5.setPen(Qt.QPen(Qt.Qt.green, 3, Qt.Qt.SolidLine))
        #self.curve5.setPen(Qt.QPen(QColor(0,153,0), 3, Qt.Qt.SolidLine))
        self.curve1.attach(self.qwtPlot)
        self.curve2.attach(self.qwtPlot)
        self.curve3.attach(self.qwtPlot)
        self.curve4.attach(self.qwtPlot)
        #self.curve5.attach(self.qwtPlot)

        #print self.qwtPlot.axisAutoScale(0)
        #print self.qwtPlot.axisAutoScale(1)
        #print self.qwtPlot.axisAutoScale(2)
        #print self.qwtPlot.axisAutoScale(3)
        #self.qwtPlot.setAxisAutoScale(0)
        #self.qwtPlot.setAxisScale(2, 0, 0.3)

        self.data_thread1 = read_rasp_Thread(self.sensors[0])
        self.connect(self.data_thread1, SIGNAL("newData"), self.updateData1)
        self.connect(self.data_thread1, SIGNAL("connectionFailed()"),
                     self.connectionFailed1)
        self.data_thread2 = read_rasp_Thread(self.sensors[1])
        self.connect(self.data_thread2, SIGNAL("newData"), self.updateData2)
        self.connect(self.data_thread2, SIGNAL("connectionFailed()"),
                     self.connectionFailed2)
        self.data_thread3 = read_rasp_Thread(self.sensors[2])
        self.connect(self.data_thread3, SIGNAL("newData"), self.updateData3)
        self.connect(self.data_thread3, SIGNAL("connectionFailed()"),
                     self.connectionFailed3)
        self.data_thread4 = read_rasp_Thread(self.sensors[3])
        self.connect(self.data_thread4, SIGNAL("newData"), self.updateData4)
        self.connect(self.data_thread4, SIGNAL("connectionFailed()"),
                     self.connectionFailed4)
        self.data_thread5 = read_rasp_Thread(self.sensors[4])
        self.connect(self.data_thread5, SIGNAL("newData"), self.updateData5)
        self.connect(self.data_thread5, SIGNAL("connectionFailed()"),
                     self.connectionFailed5)
        self.data_thread1.start()
        self.data_thread2.start()
        self.data_thread3.start()
        self.data_thread4.start()
        self.data_thread5.start()

        self.connections = [True, True, True, True, True]
        self.signals = [False, False, False, False, False]

        self.start = time.time()
        self.TimeToWrite = time.time()
Esempio n. 15
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]