Ejemplo n.º 1
0
    def FinishedDiffusion(self, stepActiveNodes):
        if self.lastLine:

            self.lastLine.setPen(QtGui.QPen(QtGui.QColor("Blue")))
        #Utility.SystemWarning("Information diffusion is finished!")
        # self.textInfoWidget.setPlainText("")
        self.ShowAllNodes()
        self.pushButtonDiffusion.setEnabled(True)

        # show result (Figure)
        win = PlotWindow.PlotWindow("The number of active cities in each step")
        win.show()
        y = str(stepActiveNodes).split("_")
        yy = []
        for i in range(len(y)):
            yy.append(int(y[i]))
        win.y = yy
        win.DrawPlot3()

        win = PlotWindow.PlotWindow("Percentage of active cities")
        win.show()
        nodesCount = self.graph.GetNodes()
        totalActive = 0
        for i in range(len(yy)):
            totalActive += yy[i]
            yy[i] = totalActive * 100.0 / nodesCount
        win.y = yy
        win.DrawPlot4()
Ejemplo n.º 2
0
    def generatePlot(self, type, point=-1):
        """
        @param option:
        @param type:
        @param point:
        @return
        """
        self.plotter.dataset.setAverageDataset(bool(self.voltageAverage.get()))
        if type == PlotType.SPECTRA:
            self.dataset.setCurrentIndex(int(self.spectPlotNum.get()))
            self.plots["Spectra " + str(self.dataset)] = PlotWindow.PlotWindow(
                self.plotArea,
                self.plotter.createSpectra(
                    contour=1 if self.varShowContour.get() else 0,
                    index=int(self.spectPlotNum.get())), type)
            self.activePlot = "Spectra " + str(self.dataset.currentDataset)

        elif type == PlotType.VOLTAGE_LINE:

            value = point if point != -1 else int(self.spnrNumVoltage.get())
            self.activePlot = "Voltage - pt" + str(value)
            self.plots[self.activePlot] = PlotWindow.PlotWindow(
                self.plotArea, self.plotter.createYPointPlot(value), type)

        elif type == PlotType.CYCLE_LINE:
            value = point if point != -1 else int(self.spnrNumCycle.get())
            self.activePlot = "Cycle - pt" + str(value)
            self.plots[self.activePlot] = PlotWindow.PlotWindow(
                self.plotArea, self.plotter.createXPointPlot(value), type)

        else:
            raise Exception("Unknown Plot type")

        self.updateView()
Ejemplo n.º 3
0
 def _plotDataset(self):
     """
     PlotDataset plots all three graphs from the dataset.
     @return
     """
     self.spectra = PlotWindow.PlotWindow(self.plotWindow,
                                          self.plotter.createSpectra())
     self.lineHoriz = PlotWindow.PlotWindow(
         self.plotWindow,
         self.plotter.createYPointPlot(self.cyclePoint.get()))
     self.lineVert = PlotWindow.PlotWindow(
         self.plotWindow,
         self.plotter.createXPointPlot(self.voltagePoint.get()))
Ejemplo n.º 4
0
 def __init__(self, filename):
     try:
         self.ifs = IFS.loadIFSFromFile(filename)
     except:
         print("You have passed an invalid file.")
         print("Please try again with a valid file.")
         sys.exit(-1)
     self.window = PlotWindow.PlotWindow()
     self.signalHandler = SignalHandler.SignalHandler()
Ejemplo n.º 5
0
    def createSpectraWithXHighlight(self, point):
        """

        @param point:
        @return
        """
        self.plots["Spectra highlight " + str(point)] = \
            PlotWindow.PlotWindow(self.plotArea, self.plotter.createSpectra(
                xHighlight=point, contour=1 if self.varShowContour.get() else 0), PlotType.SPECTRA)
        self.activePlot = "Spectra highlight " + str(point)
        self.updateView()
Ejemplo n.º 6
0
    def updatePlots(self, event):
        """

        @param event:
        @return
        """
        if self.plotter == None:
            return
        if self.filterSetAppy.get():
            self.plotter.updateData(Filters.BackgroundSubtraction(
                self.dataset))
        else:
            self.plotter.updateData(self.dataset)
        self.spectra = PlotWindow.PlotWindow(self.plotWindow,
                                             self.plotter.createSpectra())
        self.lineHoriz = PlotWindow.PlotWindow(
            self.plotWindow,
            self.plotter.createYPointPlot(self.voltagePoint.get()))
        self.lineVert = PlotWindow.PlotWindow(
            self.plotWindow,
            self.plotter.createXPointPlot(self.cyclePoint.get()))
        self.plot = self._showPlot(self.lastSelectedPlot)
Ejemplo n.º 7
0
 def doneClicked(self):
   '''Stores the current time intervals and then runs all the commands in self.savedCommands
   If all commands return True, the currrent window is closed and PlotWindow is open and fed
   the savedPlotCommands. If a saved command fails it is noted in the status bar and the user
   is told to fix/delete it before continuing.
   '''
   self.storeTimeIntervals()
   self.executeSavedCommands()
   if self.failedCommands:
     message = 'Command number ['+', '.join(self.failedCommands)+'] has failed. Please fix or delete it.'
     self.ui.statusbar.showMessage(message)
     self.failedCommands = []
   elif self.fpgaScriptName and not self.fpgaOutputLocation:
     message = 'FPGA script selected but no output location provided'
     self.ui.statusbar.showMessage(message)
   elif self.ui.checkBoxLogData.isChecked() and not self.ui.labelLocationSelected.text():
     message = 'Log Data selected but no output location provided.'
     self.ui.statusbar.showMessage(message)
   else:
     self.close()
     self.plotWindowApp = PlotWindow((self, self.savedPlotCommands, self.fpgaOutputLocation,
       self.fpgaScriptName, self.logFile))
     self.plotWindowApp.show()
Ejemplo n.º 8
0
    def __init__(self,
                 basePath,
                 speaker,
                 session,
                 uttList,
                 recordingSetup,
                 parallelPath=None,
                 feedbackPath=None,
                 preproFeaturesPath=None):
        print("Openened recording window to record " + speaker + "_" +
              session + " to " + basePath + " from list " + uttList)
        super(RecordDataWindow, self).__init__()

        # Create recording manager
        self.dummyRecord = False
        if speaker.lower().startswith("dummy") or session.lower().startswith(
                "dummy"):
            self.dummyRecord = True
            self.recordingManager = RecordingManager.RecordingManager(
                basePath,
                speaker,
                session,
                uttList,
                recordingSetup,
                dummyRecord=True,
                parallelPath=parallelPath)
        else:
            self.recordingManager = RecordingManager.RecordingManager(
                basePath,
                speaker,
                session,
                uttList,
                recordingSetup,
                parallelPath=parallelPath)

        # Set up window properties
        self.title = "Silent-EMG Recorder - Speaker '" + speaker + "', Session '" + session + "'"
        self.setWindowTitle(self.title)
        self.resize(800, 200)
        self.setStyleSheet('font-size: 18pt;')

        # Create a plot window
        self.plotWindow = PlotWindow.PlotWindow()
        self.plotWindowRunning = PlotWindow.PlotWindow(
            roll_len=2048 * 4, roll_len_aud=16000 * 4,
            title="Live View")  # TODO do this right

        # Create and link up GUI components
        self.createMenuBar()
        self.createComponents()
        self.createLayout()
        self.connectEvents()

        self.lastUttEMGFile = None
        self.lastUttAudioFile = None

        self.grabKeyboard()

        self.plotTimer = QtCore.QTimer()
        self.plotTimer.timeout.connect(self.liveReplot)
        self.plotTimer.start(100)