Beispiel #1
0
    def __init__(self):
        # Check syntax
        super(PmtXYPlot, self).__init__()
        
        # Counter
        self.ctr = expt.getNICounter(gateTime=100)

        self.setCanvasBackground(QtGui.QColor("white"))
        #self.alignScales()


        self.x = arange(0.0, 100.1, 1.)
        self.y = zeros(len(self.x), Float)

        self.setTitle("PMT Counts")
        self.curve = Qwt.QwtPlotCurve("Counts")
        self.curve.attach(self)

        self.curve.setSymbol(Qwt.QwtSymbol(
            Qwt.QwtSymbol.Ellipse,
            QtGui.QBrush(QtGui.QColor("black")),
            QtGui.QPen(QtGui.QColor("black")),
            QtCore.QSize(5, 5),
        ))

        self.setAxisTitle(Qwt.QwtPlot.xBottom, "Time (units)")
        self.setAxisTitle(Qwt.QwtPlot.yLeft, "Counts/bin")
        
        self.startTimer(10)
Beispiel #2
0
    def __init__(self, QwtPlot, chartHistoryLen, **kwargs):
        curveColor = kwargs.get('curveColor', Qt.Qt.green)
        curveTitle = kwargs.get('curveTitle', '')
        self.curveMovement = kwargs.get('curveMovement', 0)

        self.curve = Qwt.QwtPlotCurve(curveTitle)
        self.x = arange(0, chartHistoryLen, 1)
        self.y = zeros(len(self.x), Float)
        self.curve.attach(QwtPlot)
        self.curve.setPen(Qt.QPen(curveColor))
        self.curve.setSymbol(
            Qwt.QwtSymbol(
                Qwt.QwtSymbol.Ellipse,
                Qt.QBrush(curveColor),
                Qt.QPen(curveColor),
                Qt.QSize(5, 5),
            ))
Beispiel #3
0
 def plot_data(self, plot, samples):
     self.x = list(range(0, len(samples), 1))
     self.y = samples
     # clear the previous points from the plot
     plot.clear()
     # draw curve with new points and plot
     curve = Qwt.QwtPlotCurve()
     curve.setPen(Qt.QPen(Qt.Qt.blue, 2))
     curve.attach(plot)
     curve.setData(self.x, self.y)
     plot.replot()
Beispiel #4
0
    def __init__(self, *args, **kwargs):
        #super(AutoUpdatePlot, self).__init__()
        #self.app = Qt.QApplication(sys.argv)

        canvasBackground = kwargs.get('canvasBackground', Qt.Qt.white)
        self.chartHistoryLen = kwargs.get('chartHistoryLen', 10)
        chartTitle = kwargs.get('chartTitle', '')
        chartXAxisTitle = kwargs.get('chartXAxisTitle', 'X Values')
        chartYAxisTitle = kwargs.get('chartYAxisTitle', 'Y Values')
        winHorSize = kwargs.get('winHorSize', 500)
        winVertSize = kwargs.get('winVertSize', 300)
        winTitle = kwargs.get('winTitle', '')
        self.curves = {}

        self.dlg = Qt.QDialog(None)

        #Create a Qwt Plot
        self.plot = Qwt.QwtPlot(*args)
        self.plot.setCanvasBackground(canvasBackground)
        #self._alignScales()
        self.plot.setTitle(chartTitle)
        self.plot.insertLegend(Qwt.QwtLegend(), Qwt.QwtPlot.RightLegend)

        mY = Qwt.QwtPlotMarker()
        mY.setLabelAlignment(Qt.Qt.AlignRight | Qt.Qt.AlignTop)
        mY.setLineStyle(Qwt.QwtPlotMarker.HLine)
        mY.setYValue(0.0)
        mY.attach(self.plot)

        self.plot.setAxisTitle(Qwt.QwtPlot.xBottom, chartXAxisTitle)
        self.plot.setAxisTitle(Qwt.QwtPlot.yLeft, chartYAxisTitle)
        layout = Qt.QVBoxLayout()
        layout.addWidget(self.plot)
        self.dlg.setLayout(layout)
        self.dlg.resize(winHorSize, winVertSize)
        self.dlg.setWindowTitle(winTitle)
        self.dlg.timerEvent = self.timerEvent
        self.dlg.show()
Beispiel #5
0
    def __init__(self, window_name, options, parent=None):
        QtGui.QMainWindow.__init__(self, parent)

        # give Ctrl+C back to system
        signal.signal(signal.SIGINT, signal.SIG_DFL)

        self.gui = uic.loadUi(
            os.path.join(os.path.dirname(__file__), 'main_window.ui'), self)

        self.update_timer = Qt.QTimer()

        # socket addresses
        rpc_adr_server = "tcp://" + options.servername + ":6666"
        rpc_adr_client = "tcp://" + options.clientname + ":6667"
        probe_adr_server = "tcp://" + options.servername + ":5556"
        probe_adr_client = "tcp://" + options.clientname + ":5557"

        # ZeroMQ
        self.probe_manager = zeromq.probe_manager()
        self.probe_manager.add_socket(probe_adr_server, 'float32',
                                      self.plot_data_server)
        self.probe_manager.add_socket(probe_adr_client, 'float32',
                                      self.plot_data_client)

        self.rpc_mgr_server = zeromq.rpc_manager()
        self.rpc_mgr_server.set_request_socket(rpc_adr_server)
        self.rpc_mgr_client = zeromq.rpc_manager()
        self.rpc_mgr_client.set_request_socket(rpc_adr_client)

        self.gui.setWindowTitle(window_name)
        self.gui.qwtPlotServer.setTitle("Signal Scope")
        self.gui.qwtPlotServer.setAxisTitle(Qwt.QwtPlot.xBottom, "Samples")
        self.gui.qwtPlotServer.setAxisTitle(Qwt.QwtPlot.yLeft, "Amplitude")
        self.gui.qwtPlotServer.setAxisScale(Qwt.QwtPlot.xBottom, 0, 100)
        self.gui.qwtPlotServer.setAxisScale(Qwt.QwtPlot.yLeft, -2, 2)
        self.gui.qwtPlotClient.setTitle("Signal Scope")
        self.gui.qwtPlotClient.setAxisTitle(Qwt.QwtPlot.xBottom, "Samples")
        self.gui.qwtPlotClient.setAxisTitle(Qwt.QwtPlot.yLeft, "Amplitude")
        self.gui.qwtPlotClient.setAxisScale(Qwt.QwtPlot.xBottom, 0, 100)
        self.gui.qwtPlotClient.setAxisScale(Qwt.QwtPlot.yLeft, -2, 2)

        # Grid
        pen = Qt.QPen(Qt.Qt.DotLine)
        pen.setColor(Qt.Qt.black)
        pen.setWidth(0)
        grid_server = Qwt.QwtPlotGrid()
        grid_client = Qwt.QwtPlotGrid()
        grid_server.setPen(pen)
        grid_client.setPen(pen)
        grid_server.attach(self.gui.qwtPlotServer)
        grid_client.attach(self.gui.qwtPlotClient)

        #Signals
        self.connect(self.update_timer, QtCore.SIGNAL("timeout()"),
                     self.probe_manager.watcher)
        self.connect(self.gui.pushButtonRunServer, QtCore.SIGNAL("clicked()"),
                     self.start_fg_server)
        self.connect(self.gui.pushButtonStopServer, QtCore.SIGNAL("clicked()"),
                     self.stop_fg_server)
        self.connect(self.gui.pushButtonRunClient, QtCore.SIGNAL("clicked()"),
                     self.start_fg_client)
        self.connect(self.gui.pushButtonStopClient, QtCore.SIGNAL("clicked()"),
                     self.stop_fg_client)
        self.connect(self.gui.comboBox,
                     QtCore.SIGNAL("currentIndexChanged(QString)"),
                     self.set_waveform)
        self.connect(self.gui.spinBox, QtCore.SIGNAL("valueChanged(int)"),
                     self.set_gain)
        self.shortcut_start = QtGui.QShortcut(Qt.QKeySequence("Ctrl+S"),
                                              self.gui)
        self.shortcut_stop = QtGui.QShortcut(Qt.QKeySequence("Ctrl+C"),
                                             self.gui)
        self.shortcut_exit = QtGui.QShortcut(Qt.QKeySequence("Ctrl+D"),
                                             self.gui)
        self.connect(self.shortcut_exit, QtCore.SIGNAL("activated()"),
                     self.gui.close)

        # start update timer
        self.update_timer.start(30)

def plotSomething():
    global ys
    ys = numpy.roll(ys, -1)
    c.setData(xs, ys)
    uiplot.qwtPlot.replot()


if __name__ == "__main__":
    app = QtGui.QApplication(sys.argv)
    win_plot = ui_plot.QtGui.QMainWindow()
    uiplot = ui_plot.Ui_win_plot()
    uiplot.setupUi(win_plot)

    # tell buttons what to do when clicked
    uiplot.btnA.clicked.connect(plotSomething)
    uiplot.btnB.clicked.connect(lambda: uiplot.timer.setInterval(100.0))
    uiplot.btnC.clicked.connect(lambda: uiplot.timer.setInterval(10.0))
    uiplot.btnD.clicked.connect(lambda: uiplot.timer.setInterval(1.0))

    # set up the QwtPlot (pay attention!)
    c = Qwt.QwtPlotCurve()  #make a curve
    c.attach(uiplot.qwtPlot)  #attach it to the qwtPlot object
    uiplot.timer = QtCore.QTimer()  #start a timer (to call replot events)
    uiplot.timer.start(100.0)  #set the interval (in ms)
    win_plot.connect(uiplot.timer, QtCore.SIGNAL('timeout()'), plotSomething)

    # show the main window
    win_plot.show()
    sys.exit(app.exec_())
Beispiel #7
0
    def __init__(self, iface):
        '''costruttore'''
        QDialog.__init__(self, iface.mainWindow())
        self.setupUi(self)
        self.iface = iface
        self.activeLayer = self.iface.activeLayer()
        self.Xgraph = self.Ygraph = []
        self.fzyValuer = {}  #hold the valuer for fuzzify matrix
        for i in range(1, self.toolBox.count()):
            self.toolBox.setItemEnabled(i, False)
        QObject.connect(self.SetBtnQuit, SIGNAL("clicked()"), self,
                        SLOT("reject()"))
        self.SetBtnAbout.clicked.connect(self.about)
        self.SetBtnHelp.clicked.connect(self.open_help)
        #QObject.connect(self.EnvAddFieldBtn, SIGNAL( "clicked()" ), self.AddField)
        self.EnvCalculateBtn.clicked.connect(self.AnalyticHierarchyProcess)
        self.EnvGetWeightBtn.clicked.connect(self.Elaborate)
        self.RenderBtn.clicked.connect(self.RenderLayer)
        self.GraphBtn.clicked.connect(self.BuildOutput)
        QObject.connect(self.AnlsBtnBox, SIGNAL("rejected()"), self,
                        SLOT("reject()"))
        self.FzyFieldBtn.clicked.connect(self.getFzyGraph)
        self.FzfyListFieldsCBox.currentIndexChanged.connect(self.setqwtPlot)
        self.qwtPlot.setAutoReplot()
        self.qwtPlot.setAxisScale(0, 0, 1, 0.1)
        self.picker = Qwt.QwtPlotPicker(
            Qwt.QwtPlot.xBottom,
            Qwt.QwtPlot.yLeft,
            #Qwt.QwtPicker.PointSelection,
            Qwt.QwtPicker.PolygonSelection,
            #Qwt.QwtPlotPicker.CrossRubberBand,
            Qwt.QwtPlotPicker.PolygonRubberBand,
            Qwt.QwtPicker.AlwaysOn,
            self.qwtPlot.canvas())
        self.picker.setRubberBandPen(QPen(Qt.red))
        #self.picker.connect(self.picker,SIGNAL('selected(const QwtDoublePoint&)'), self.pickPoints)
        self.picker.connect(self.picker, SIGNAL('selected(const QwtPolygon&)'),
                            self.pickPoints)
        # curves
        self.curve = Qwt.QwtPlotCurve('Fuzzify')
        self.curve.setRenderHint(Qwt.QwtPlotItem.RenderAntialiased)
        self.curve.setPen(QPen(Qt.blue))
        self.curve.setYAxis(self.qwtPlot.yLeft)
        self.curve.attach(self.qwtPlot)

        sourceIn = str(self.iface.activeLayer().source())
        pathSource = os.path.dirname(sourceIn)
        outputFile = "geoFuzzy.shp"
        sourceOut = os.path.join(pathSource, outputFile)

        self.EnvMapNameLbl.setText(self.activeLayer.name())
        self.EnvlistFieldsCBox.addItems(self.GetFieldNames(self.activeLayer))
        self.FzfyListFieldsCBox.addItems(self.GetFieldNames(self.activeLayer))
        self.LabelListFieldsCBox.addItems(self.GetFieldNames(self.activeLayer))
        #################################################################################
        Envfields = self.GetFieldNames(self.activeLayer)  #field list
        self.EnvTableWidget.setColumnCount(len(Envfields))
        self.EnvTableWidget.setHorizontalHeaderLabels(Envfields)
        self.EnvTableWidget.setRowCount(len(Envfields))
        self.EnvTableWidget.setVerticalHeaderLabels(Envfields)

        EnvSetLabel = ["Hedges", "Min", "Max", "Set"]
        self.EnvParameterWidget.setColumnCount(len(Envfields))
        self.EnvParameterWidget.setHorizontalHeaderLabels(Envfields)
        self.EnvParameterWidget.setRowCount(len(EnvSetLabel))
        self.EnvParameterWidget.setVerticalHeaderLabels(EnvSetLabel)
        for r in range(len(Envfields)):
            self.EnvTableWidget.setItem(r, r, QTableWidgetItem("1.0"))
        self.EnvTableWidget.cellChanged[(int,
                                         int)].connect(self.CompleteMatrix)
        self.updateTable()
        ###############################ContextMenu########################################
        #		self.EnvTableWidget.setContextMenuPolicy(Qt.CustomContextMenu)
        #		self.EnvTableWidget.customContextMenuRequested.connect(self.removePopup)
        headers = self.EnvParameterWidget.horizontalHeader()
        headers.setContextMenuPolicy(Qt.CustomContextMenu)
        headers.customContextMenuRequested.connect(self.popMenu)
        #################################################################################
        setting = self.csv2setting()
        try:
            self.setting2table(setting)
        except:
            pass
        for i in range(1, self.toolBox.count()):
            self.toolBox.setItemEnabled(i, True)