'''
Created on 20-Jan-2022

@author: bthakur
'''

import random
import inspect
import traceback

import matplotlib.pyplot as plt

from sympy.core.expr import UnevaluatedExpr
            
from sympy import ( latex, solve, simplify, 
                    pi, Rational,
                    exp, sin, cos, tan,
                    asin, acos, atan,
                    sinh, cosh, tanh,
                    log, exp, sqrt,
                    Eq
                    )

import numpy as np

from xv.util import list_to_str
from xv.util import run_with_timeout
from xv.km.ui import SvgHelper

from xv.km.util import latex_fraction, latex_exponent, wrap_bracket


# _plotting_helper
class PlottingHelper():
    
    def __init__(self, **kwargs):
        self.verbose = kwargs.get('verbose', False)
        pass


    def plot_quadrants(self, point,
                           figsize = (10,6),
                           title = None,
                           use_cache = True
                           ):
        plt.ioff()
        fig = plt.figure(figsize = figsize)
        ax = plt.gca()
        
        ax.axhline(0, color = "red")
        ax.axvline(0, color = "red")
        

        ax.plot(*point, marker = "o")
        ax.text(point[0] + 0.5, point[1] + 0.5, f"({point[0]}, {point[1]})")
            
        ax.text(7, 7, "Quadrant 1")
        ax.text(-7, 7, "Quadrant 2")
        ax.text(-7, -7, "Quadrant 3")
        ax.text(7, -7, "Quadrant 4")

        ax.set_xlim(-10, 10)       
        ax.set_ylim(-10, 10)   
            
        svgHelper = SvgHelper()
        svg_str = svgHelper.plt_to_svg()
    
        if not svg_str:
            if self.verbose:
                print(f"Error: svg_str could not be initialized")
            return None
            
        plt.clf()
        plt.close()
        
        return svg_str
        pass
    
    pass
#class PlottingHelper:
