예제 #1
0
파일: filtertest1.py 프로젝트: HaMF/guiqwt
 def setup_widget(self, title):
     #---Create the plot widget:
     curvewidget = CurveWidget(self)
     curvewidget.register_all_curve_tools()
     self.curve_item = make.curve([], [], color='b')
     curvewidget.plot.add_item(self.curve_item)
     curvewidget.plot.set_antialiasing(True)
     #---
     
     button = QPushButton("Test filter: %s" % title)
     self.connect(button, SIGNAL('clicked()'), self.process_data)
     vlayout = QVBoxLayout()
     vlayout.addWidget(curvewidget)
     vlayout.addWidget(button)
     self.setLayout(vlayout)
     
     self.update_curve()
예제 #2
0
    def setup_widget(self, title):
        # ---Create the plot widget:
        curvewidget = CurveWidget(self)
        curvewidget.register_all_curve_tools()
        self.curve_item = make.curve([], [], color="b")
        curvewidget.plot.add_item(self.curve_item)
        curvewidget.plot.set_antialiasing(True)
        # ---

        button = QPushButton("Test filter: %s" % title)
        button.clicked.connect(self.process_data)
        vlayout = QVBoxLayout()
        vlayout.addWidget(curvewidget)
        vlayout.addWidget(button)
        self.setLayout(vlayout)

        self.update_curve()
예제 #3
0
class CentralWidget(QSplitter):
    def __init__(self, parent, toolbar):
        QSplitter.__init__(self, parent)
        # QTabWidget.__init__(self, parent)
        self.setContentsMargins(10, 10, 10, 10)
        self.setOrientation(Qt.Vertical)

        linelistwithproperties = LineListWithProperties(self)
        # self.addWidget(linelistwithproperties)
        self.lineList = linelistwithproperties.lineList
        self.connect(self.lineList, SIGNAL("currentRowChanged(int)"),
                     self.current_item_changed)
        self.connect(self.lineList, SIGNAL("itemSelectionChanged()"),
                     self.selection_changed)
        self.curveProperties = linelistwithproperties.properties
        self.connect(self.curveProperties, SIGNAL("apply_button_clicked()"),
                     self.curve_properties_changed)
        
        self.curvewidget = CurveWidget(self)
        self.curvewidget.register_all_curve_tools()
        self.curve_item = make.curve([], [], color='b')
        self.peak_item = make.curve([],[], markerfacecolor = 'r', marker = 'o', curvestyle="NoCurve")#, alpha = 0.75)
        self.curvewidget.plot.add_item(self.curve_item)
        self.curvewidget.plot.add_item(self.peak_item)
        self.curvewidget.plot.set_antialiasing(True)
        self.addWidget(self.curvewidget)
        
        self.lines = [] # List of ImageParam instances
        self.peaks = []

        
        vSplitter = QSplitter()
        vSplitter.setOrientation(Qt.Vertical)
        daqParamProperties = DAQParamsProperties(self)
        self.daqProperties = daqParamProperties.properties
        self.connect(self.daqProperties, SIGNAL("apply_button_clicked()"), self.daq_properties_changed)
        # daqButton = QPushButton("Upload DAQ Params")
        vSplitter.addWidget(daqParamProperties)
        # vSplitter.addWidget(daqButton)
        tabWidget = QTabWidget()
        tab1 = tabWidget.addTab(linelistwithproperties, "Curve Params")
        tab2 = tabWidget.addTab(vSplitter, "DAQ Params")
        
        self.addWidget(tabWidget)

        self.setStretchFactor(0, 0)
        self.setStretchFactor(1, 1)
        self.setHandleWidth(10)
        self.setSizes([1, 2])

    def refresh_list(self):
        self.lineList.clear()
        for line in self.lines:
            self.lineList.addItem(line.title)
        
    def selection_changed(self):
        """Image list: selection changed"""
        row = self.lineList.currentRow()
        self.curveProperties.setDisabled(row == -1)
        
    def current_item_changed(self, row):
        """Line list: current line changed"""
        line = self.lines[row]
        peaks = self.peaks[row]
        self.show_peaks(peaks)
        self.show_data(line)
        update_dataset(self.curveProperties.dataset, line)
        self.curveProperties.get()
        # print "Current Item Changed."
        
    def show_data(self, line):
        plot = self.curvewidget.plot
        # plot.add_item(self.curve_item)
        self.curve_item.setData(line.xydata[0], line.xydata[1])
        self.autoScale()

    def show_peaks(self, curPeak):
        print "Set Peaks"
        self.peak_item.setData(curPeak[0], curPeak[1])
    
    def autoScale(self):
        # print "AutoScale"
        plot = self.curvewidget.plot
        for ax in plot.get_active_axes():
            plot.setAxisAutoScale(ax)
        plot.replot()

    def curve_properties_changed(self):
        """The properties 'Apply' button was clicked: updating line plot"""
        row = self.lineList.currentRow()
        line = self.lines[row]
        update_dataset(line, self.curveProperties.dataset)
        self.refresh_list()
        self.show_data(line)

    def daq_properties_changed(self):
        """The properties 'Apply' button was clicked: updating DAQ Properties"""
        print self.daqProperties.dataset

    def add_curve(self, lineName, x, y, pickPeaks = True):
        line = SignalParam()
        line.title = lineName
        line.xydata = np.vstack((x,y))#array([x,y]))
        self.lines.append(line)
        self.refresh_list()
        # print line.xydata[0:10], lineName, np.array([x,y])[0:10]

        if pickPeaks:
            self.addPeaks(line)
        self.show_data(line)
        # self.curve_item.setData(x, y)
        # self.curvewidget.plot.do_autoscale()
        # for ax in self.curvewidget.plot.get_active_axes():
        #             self.curvewidget.plot.setAxisAutoScale(ax)
        # self.curvewidget.plot.replot()

    def addPeaks(self, line):
        '''
        Need to create the points
        Consider: https://pythonhosted.org/guiqwt/examples.html
        '''
        x = line.xydata[0]
        y = line.xydata[1]
        _max, _min = pd.peakdetect(y, x, 5)
        xm = [p[0] for p in _max]
        ym = [p[1] for p in _max]
        xn = [p[0] for p in _min]
        yn = [p[1] for p in _min]

        curPeak = np.vstack((xm,ym))
        self.peaks.append(curPeak)
        self.show_peaks(curPeak)
    
    def add_image_from_file(self, filename):
        image = SignalParam()
        image.title = to_text_string(filename)
        image.data = io.imread(filename, to_grayscale=True)
        image.height, image.width = image.data.shape
        self.add_image(image)
예제 #4
0
 def createPlotCurve(self):
     curvewidget = CurveWidget(self)
     curvewidget.register_all_curve_tools()
     curvewidget.plot.set_antialiasing(True)
     self.curvewidget = curvewidget
예제 #5
0
class ErrorTraceDialog(QtGui.QDialog):
    
    def __init__(self, text, freqs, trace, max_freq, ul=None, ll=None, ignore_button=False, parent=None):
        super(ErrorTraceDialog, self).__init__(parent)

        # Plot
        self.curveWidget = CurveWidget(self, xlabel='freq [Hz]')
        self.curveWidget.plot.set_axis_scale('bottom', 'log')

        self.curveWidget.plot.set_axis_limits('bottom', 1, max_freq)
        self.curveWidget.register_all_curve_tools()

        # Resultaat trace
        resultTrace = make.curve([], [], color='b')
        self.curveWidget.plot.add_item(resultTrace)
        resultTrace.set_data(freqs, trace)

        if ul is not None:
            # Upper limit
            ulTrace = make.curve([], [], color='r')
            self.curveWidget.plot.add_item(ulTrace)
            ulTrace.set_data(freqs, ul)

        if ll is not None:
            # Lower limit
            llTrace = make.curve([], [], color='r')
            self.curveWidget.plot.add_item(llTrace)
            llTrace.set_data(freqs, ll)

        # Error icon
        style = QtGui.QApplication.style()
        icon = style.standardIcon(QtGui.QStyle.SP_MessageBoxCritical)
        errorLabel = QtGui.QLabel()
        errorLabel.setPixmap(icon.pixmap(32))
        errorLabel.setMinimumWidth(40)
        errorLabel.setStyleSheet('border-bottom-style:none;')

        # Label
        label = QtGui.QLabel('%s! <p>Klik op Ok, controleer montage/aansluitingen en begin opnieuw.' % text)
        label.setStyleSheet('border-bottom-style:none;')        
        
        # Buttons
        buttonLayout = QtGui.QHBoxLayout()
        cancelButton = QtGui.QPushButton('Ok')
        ignoreButton = QtGui.QPushButton('Negeer')
        traceButton = QtGui.QPushButton('Trace...')
        traceButton.setCheckable(True)
        buttonLayout.addSpacing(10)
        buttonLayout.addWidget(traceButton)
        buttonLayout.addStretch()
        buttonLayout.addWidget(ignoreButton)
        buttonLayout.addWidget(cancelButton)
        buttonLayout.addSpacing(10)

        if not ignore_button:
            ignoreButton.setHidden(True)

        cancelButton.clicked.connect(self.reject)
        ignoreButton.clicked.connect(self.accept)

        # Frame voor de trace
        traceFrame = QtGui.QFrame()
        traceFrame.setFrameStyle(QtGui.QFrame.NoFrame)
        frameLayout = QtGui.QHBoxLayout()
        frameLayout.addWidget(self.curveWidget)
        traceFrame.setLayout(frameLayout)
        traceFrame.hide()

        # Frame voor de boodschap
        messageFrame = QtGui.QFrame()
        messageFrame.setStyleSheet('background-color: white;border-bottom-style:solid;border-bottom-width:1px;border-bottom-color: rgb(190, 190, 190);')
        messageFrameLayout = QtGui.QHBoxLayout()
        messageFrameLayout.addWidget(errorLabel)
        messageFrameLayout.addWidget(label)
        messageFrame.setLayout(messageFrameLayout)

        # Layout
        layout = QtGui.QHBoxLayout()
        layout.setContentsMargins(0, 0, 0, 10)
        layout1 = QtGui.QVBoxLayout()
        messageFrameLayout.addStretch()
        layout1.addWidget(messageFrame)
        layout1.addSpacing(10)
        layout1.addLayout(buttonLayout)
        layout1.addWidget(traceFrame)

        layout.addLayout(layout1)
        self.setLayout(layout)
        self.setWindowTitle('Shake It')

        layout.setSizeConstraint(QtGui.QLayout.SetFixedSize)

        cancelButton.setFocus()

        traceButton.toggled.connect(traceFrame.setVisible)
예제 #6
0
파일: main.py 프로젝트: MIZiper/rdsp
    def initUI(self):
        layout = QtGui.QVBoxLayout(self)

        curve_plot = CurveWidget()
        curve_plot.register_all_curve_tools()
        curve_rotor = make.curve([], [])
        curve_stator = make.curve([], [])
        curve_eccent = make.circle(0, 0, 0, 0)
        plot = curve_plot.plot
        # plot.setAxisScale(0,-self.range,self.range)
        # plot.setAxisScale(2,-self.range,self.range)
        plot.add_item(curve_rotor)
        plot.add_item(curve_stator)
        plot.add_item(curve_eccent)
        self.curve_rotor = curve_rotor
        self.curve_stator = curve_stator
        self.curve_plot = curve_plot
        self.curve_eccent = curve_eccent

        info_layout = QtGui.QVBoxLayout()
        eccent_grp = QtGui.QGroupBox("Eccentricity")
        eccent_layout = QtGui.QVBoxLayout(eccent_grp)
        eccent_x_lbl = QtGui.QLabel("X")
        eccent_x = QtGui.QLabel('0')
        eccent_y_lbl = QtGui.QLabel('Y')
        eccent_y = QtGui.QLabel('0')
        eccent_l_lbl = QtGui.QLabel('(X^2+Y^2)^0.5')
        eccent_l = QtGui.QLabel('0')
        eccent_layout.addWidget(eccent_x_lbl)
        eccent_layout.addWidget(eccent_x)
        eccent_layout.addWidget(eccent_y_lbl)
        eccent_layout.addWidget(eccent_y)
        eccent_layout.addWidget(eccent_l_lbl)
        eccent_layout.addWidget(eccent_l)
        self.eccent_x = eccent_x
        self.eccent_y = eccent_y
        self.eccent_l = eccent_l

        statRef_lbl = QtGui.QLabel("Stator Ref.")
        statRef_cmb = QtGui.QComboBox()
        statRef_cmb.addItems([str(i) for i in np.arange(self.numOfPole) + 1])
        statRef_cmb.currentIndexChanged.connect(self.pole_changed)
        rotRef_lbl = QtGui.QLabel("Rotor Ref.")
        rotRef_cmb = QtGui.QComboBox()
        rotRef_cmb.addItems(
            [self.result[i]['name'] for i in range(self.numOfSensor)])
        rotRef_cmb.currentIndexChanged.connect(self.sensor_changed)
        info_layout.addWidget(eccent_grp)
        info_layout.addStretch(1)
        info_layout.addWidget(statRef_lbl)
        info_layout.addWidget(statRef_cmb)
        info_layout.addWidget(rotRef_lbl)
        info_layout.addWidget(rotRef_cmb)

        speed_slider = QtGui.QSlider(Qt.Horizontal)
        speed_slider.setTickPosition(QtGui.QSlider.TicksAbove)
        speed_slider.setMaximum(self.numOfSpeed - 1)
        speed_slider.valueChanged.connect(self.speed_changed)
        speed_label = QtGui.QLabel("Speed")
        self.speed_label = speed_label
        spd_layout = QtGui.QHBoxLayout()
        spd_layout.addWidget(speed_slider)
        spd_layout.addWidget(speed_label)

        up_layout = QtGui.QHBoxLayout()
        up_layout.addWidget(curve_plot, stretch=1)
        up_layout.addLayout(info_layout)
        layout.addLayout(up_layout)
        layout.addLayout(spd_layout)