# Path: apasvo/utils/plotting.py
# SPECGRAM_WINDOWS = ("boxcar", "hamming", "hann", "bartlett",
#                             'blackman', "blackmanharris")
# SPECGRAM_WINDOWS_NAMES = ("Rectangular", "Hamming", "Hann", "Bartlett",
#                           "Blackman", "Blackman-Harris")
# def plot_specgram(ax, data, fs, nfft=256, noverlap=128, window='hann',
#                   cmap='jet', interpolation='bilinear', rasterized=True):
# def reduce_data(x, y, width, xmin=0, xmax=None):
# def adjust_axes_height(ax, max_value=None, min_value=None, margin=0.1):
# 
# Path: apasvo/utils/clt.py
# def float_secs_2_string_date(x, starttime=datetime.datetime.utcfromtimestamp(0)):
# def print_msg(msg):
# def query_yes_no_all_quit(question, default="yes"):
# def query_custom_answers(question, answers, default=None):
#     def __init__(self, name, data, align=ALIGN.RIGHT, fmt='%.6g'):
#     def __init__(self, *columns):
#     def get_row(self, i=None):
#     def get_line(self):
#     def join_n_wrap(self, char, elements):
#     def get_rows(self):
#     def __str__(self):
#     def __init__(self, minValue=0, maxValue=100, totalWidth=12):
#     def updateAmount(self, newAmount=0):
#     def __str__(self):
# class ALIGN:
# class Column():
# class Table:
# class ProgressBar:
#     LEFT, RIGHT = '-', ''


from PySide import QtGui
from PySide import QtCore
from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg as FigureCanvas
from matplotlib.ticker import FuncFormatter
from mpl_toolkits.axes_grid.anchored_artists import AnchoredText
from apasvo.utils import plotting
from apasvo.utils import clt
import numpy as np
import matplotlib
import matplotlib.pyplot as plt
  You should have received a copy of the GNU General Public License
  along with this program.  If not, see <http://www.gnu.org/licenses/>.
'''


matplotlib.rcParams['backend'] = 'qt4agg'
matplotlib.rcParams['backend.qt4'] = 'PySide'
matplotlib.rcParams['patch.antialiased'] = False
matplotlib.rcParams['figure.dpi'] = 65
matplotlib.rcParams['agg.path.chunksize'] = 80000



class TracePlot(QtCore.QObject):

    def __init__(self, parent, trace, fig_nrows=1, fig_ncols=1, ax_pos=1):
        super(TracePlot, self).__init__()
        self.parent = parent
        self.fig = parent.fig
        self.ax = self.fig.add_subplot(fig_nrows, fig_ncols, ax_pos, visible=False)
        self.trace = trace
        # Get trace dataseries
        self.signal = trace.signal
        self.time = np.linspace(0, len(self.signal) / trace.fs, num=len(self.signal), endpoint=False)
        self.xmin, self.xmax = 0, self.time[-1]
        # Plot current data
        self._plot_data = self.ax.plot(self.time, self.signal, color='black', rasterized=True)[0]
        self.ax.callbacks.connect('xlim_changed', self.on_xlim_change)
        self.ax.set_xlim(self.xmin, self.xmax)
        # Format axes

# Path: apasvo/utils/plotting.py
# SPECGRAM_WINDOWS = ("boxcar", "hamming", "hann", "bartlett",
#                             'blackman', "blackmanharris")
# SPECGRAM_WINDOWS_NAMES = ("Rectangular", "Hamming", "Hann", "Bartlett",
#                           "Blackman", "Blackman-Harris")
# def plot_specgram(ax, data, fs, nfft=256, noverlap=128, window='hann',
#                   cmap='jet', interpolation='bilinear', rasterized=True):
# def reduce_data(x, y, width, xmin=0, xmax=None):
# def adjust_axes_height(ax, max_value=None, min_value=None, margin=0.1):
# 
# Path: apasvo/utils/clt.py
# def float_secs_2_string_date(x, starttime=datetime.datetime.utcfromtimestamp(0)):
# def print_msg(msg):
# def query_yes_no_all_quit(question, default="yes"):
# def query_custom_answers(question, answers, default=None):
#     def __init__(self, name, data, align=ALIGN.RIGHT, fmt='%.6g'):
#     def __init__(self, *columns):
#     def get_row(self, i=None):
#     def get_line(self):
#     def join_n_wrap(self, char, elements):
#     def get_rows(self):
#     def __str__(self):
#     def __init__(self, minValue=0, maxValue=100, totalWidth=12):
#     def updateAmount(self, newAmount=0):
#     def __str__(self):
# class ALIGN:
# class Column():
# class Table:
# class ProgressBar:
#     LEFT, RIGHT = '-', ''


# Path: apasvo/gui/views/tsvwidget.py
from PySide import QtGui
from PySide import QtCore
from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg as FigureCanvas
from matplotlib.ticker import FuncFormatter
from mpl_toolkits.axes_grid.anchored_artists import AnchoredText
from apasvo.utils import plotting
from apasvo.utils import clt
import numpy as np
import matplotlib
import matplotlib.pyplot as plt

  You should have received a copy of the GNU General Public License
  along with this program.  If not, see <http://www.gnu.org/licenses/>.
'''


matplotlib.rcParams['backend'] = 'qt4agg'
matplotlib.rcParams['backend.qt4'] = 'PySide'
matplotlib.rcParams['patch.antialiased'] = False
matplotlib.rcParams['figure.dpi'] = 65
matplotlib.rcParams['agg.path.chunksize'] = 80000



class TracePlot(QtCore.QObject):

    def __init__(self, parent, trace, fig_nrows=1, fig_ncols=1, ax_pos=1):
        super(TracePlot, self).__init__()
        self.parent = parent
        self.fig = parent.fig
        self.ax = self.fig.add_subplot(fig_nrows, fig_ncols, ax_pos, visible=False)
        self.trace = trace
        # Get trace dataseries
        self.signal = trace.signal
        self.time = np.linspace(0, len(self.signal) / trace.fs, num=len(self.signal), endpoint=False)
        self.xmin, self.xmax = 0, self.time[-1]
        # Plot current data
        self._plot_data = self.ax.plot(self.time, self.signal, color='black', rasterized=True)[0]
        self.ax.callbacks.connect('xlim_changed', self.on_xlim_change)
        self.ax.set_xlim(self.xmin, self.xmax)
        # Format axes

        axes_formatter = FuncFormatter(lambda x, pos: clt.float_secs_2_string_date(x, trace.starttime))