# Path: rtlsdr_scanner/events.py
# def post_event(destination, status):
#     if isinstance(destination, Queue.Queue):
#         destination.put(status)
#     elif isinstance(destination, wx.EvtHandler):
#         wx.PostEvent(destination, status)
# 
# class EventThread(wx.PyEvent):
#     def __init__(self, status, arg1=None, arg2=None):
#         wx.PyEvent.__init__(self)
#         self.SetEventType(EVENT_THREAD)
#         self.data = Status(status, arg1, arg2)
# 
# class Event(object):
#     STARTING, STEPS, INFO, DATA, STOPPED, ERROR, FINISHED, PROCESSED, \
#         CAL, LEVEL, UPDATED, DRAW, \
#         DELAY_COUNT, DELAY_START, \
#         LOC, LOC_RAW, LOC_WARN, LOC_ERR, LOC_SAT = range(19)
# 
# Path: rtlsdr_scanner/misc.py
# def format_time(timeStamp, withDate=False):
#     if timeStamp <= 1:
#         return 'Unknown'
# 
#     if withDate:
#         return time.strftime('%c', time.localtime(timeStamp))
# 
#     return time.strftime('%H:%M:%S', time.localtime(timeStamp))
# 
# def format_precision(settings, freq=None, level=None,
#                      units=True, fancyUnits=False):
#     textFreq = None
#     textLevel = None
# 
#     if freq is not None:
#         prec = settings.precisionFreq
#         width = 4 + prec
#         textFreq = '{:{width}.{prec}f}'.format(freq, width=width, prec=prec)
#         if units or fancyUnits:
#             textFreq += " MHz"
#     if level is not None:
#         prec = settings.precisionLevel
#         width = 4 + prec
#         textLevel = '{:{width}.{prec}f}'.format(level, width=width, prec=prec)
#         if fancyUnits:
#             textLevel += r" dB/Hz"
#         elif units:
#             textLevel += " dB/Hz"
# 
#     if textFreq and textLevel:
#         return (textFreq, textLevel)
#     if textFreq:
#         return textFreq
#     if textLevel:
#         return textLevel
# 
#     return None


import threading
from matplotlib.font_manager import FontProperties
from matplotlib.table import Table
from rtlsdr_scanner.events import post_event, EventThread, Event
from rtlsdr_scanner.misc import format_time, format_precision
from rtlsdr_scanner.utils_mpl import find_artists, set_table_colour
        self.figure = None


class ThreadPlot(threading.Thread):
    def __init__(self, parent, settings, axes, data, extent):
        threading.Thread.__init__(self)
        self.name = "Plot"
        self.parent = parent
        self.settings = settings
        self.axes = axes
        self.data = data
        self.extent = extent

    def run(self):
        self.parent.clear_plots()
        if self.data is None:
            length, tMin, tMax, fMin, fMax, lMin, lMax, peakF, peakL, peakT = ('-',) * 10
        else:
            length = len(self.data)
            tMin = format_time(self.extent.tMin, True)
            tMax = format_time(self.extent.tMax, True)
            fMin = format_precision(self.settings, freq=self.extent.fMin,
                                    fancyUnits=True)
            fMax = format_precision(self.settings, freq=self.extent.fMax,
                                    fancyUnits=True)
            lMin = format_precision(self.settings, level=self.extent.lMin,
                                    fancyUnits=True)
            lMax = format_precision(self.settings, level=self.extent.lMax,
                                    fancyUnits=True)
            peak = self.extent.get_peak_flt()

# Path: rtlsdr_scanner/events.py
# def post_event(destination, status):
#     if isinstance(destination, Queue.Queue):
#         destination.put(status)
#     elif isinstance(destination, wx.EvtHandler):
#         wx.PostEvent(destination, status)
# 
# class EventThread(wx.PyEvent):
#     def __init__(self, status, arg1=None, arg2=None):
#         wx.PyEvent.__init__(self)
#         self.SetEventType(EVENT_THREAD)
#         self.data = Status(status, arg1, arg2)
# 
# class Event(object):
#     STARTING, STEPS, INFO, DATA, STOPPED, ERROR, FINISHED, PROCESSED, \
#         CAL, LEVEL, UPDATED, DRAW, \
#         DELAY_COUNT, DELAY_START, \
#         LOC, LOC_RAW, LOC_WARN, LOC_ERR, LOC_SAT = range(19)
# 
# Path: rtlsdr_scanner/misc.py
# def format_time(timeStamp, withDate=False):
#     if timeStamp <= 1:
#         return 'Unknown'
# 
#     if withDate:
#         return time.strftime('%c', time.localtime(timeStamp))
# 
#     return time.strftime('%H:%M:%S', time.localtime(timeStamp))
# 
# def format_precision(settings, freq=None, level=None,
#                      units=True, fancyUnits=False):
#     textFreq = None
#     textLevel = None
# 
#     if freq is not None:
#         prec = settings.precisionFreq
#         width = 4 + prec
#         textFreq = '{:{width}.{prec}f}'.format(freq, width=width, prec=prec)
#         if units or fancyUnits:
#             textFreq += " MHz"
#     if level is not None:
#         prec = settings.precisionLevel
#         width = 4 + prec
#         textLevel = '{:{width}.{prec}f}'.format(level, width=width, prec=prec)
#         if fancyUnits:
#             textLevel += r" dB/Hz"
#         elif units:
#             textLevel += " dB/Hz"
# 
#     if textFreq and textLevel:
#         return (textFreq, textLevel)
#     if textFreq:
#         return textFreq
#     if textLevel:
#         return textLevel
# 
#     return None


# Path: rtlsdr_scanner/plot_status.py
import threading
from matplotlib.font_manager import FontProperties
from matplotlib.table import Table
from rtlsdr_scanner.events import post_event, EventThread, Event
from rtlsdr_scanner.misc import format_time, format_precision
from rtlsdr_scanner.utils_mpl import find_artists, set_table_colour

        self.figure = None


class ThreadPlot(threading.Thread):
    def __init__(self, parent, settings, axes, data, extent):
        threading.Thread.__init__(self)
        self.name = "Plot"
        self.parent = parent
        self.settings = settings
        self.axes = axes
        self.data = data
        self.extent = extent

    def run(self):
        self.parent.clear_plots()
        if self.data is None:
            length, tMin, tMax, fMin, fMax, lMin, lMax, peakF, peakL, peakT = ('-',) * 10
        else:
            length = len(self.data)
            tMin = format_time(self.extent.tMin, True)
            tMax = format_time(self.extent.tMax, True)
            fMin = format_precision(self.settings, freq=self.extent.fMin,
                                    fancyUnits=True)
            fMax = format_precision(self.settings, freq=self.extent.fMax,
                                    fancyUnits=True)
            lMin = format_precision(self.settings, level=self.extent.lMin,
                                    fancyUnits=True)
            lMax = format_precision(self.settings, level=self.extent.lMax,
                                    fancyUnits=True)
            peak = self.extent.get_peak_flt()

            peakF = format_precision(self.settings, freq=peak[0],