# Path: pytripgui/canvas_vc/objects/vdx.py
# class Vdx:
#     """
#     This class holds data model for plotting Vdx stuff.
#     """
#     def __init__(self, ctx, projection_selector):
#         self.ctx = ctx
#         self.projection_selector = projection_selector
#         self.voi_list = []
# 
# Path: pytripgui/canvas_vc/plotter/managers/blit_manager.py
# class BlitManager:
#     def __init__(self, canvas, animated_artists=()):
#         """
#         Parameters
#         ----------
#         canvas : FigureCanvasAgg
#             The canvas to work with, this only works for sub-classes of the Agg
#             canvas which have the `~FigureCanvasAgg.copy_from_bbox` and
#             `~FigureCanvasAgg.restore_region` methods.
# 
#         animated_artists : Iterable[Artist]
#             List of the artists to manage
#         """
#         self.canvas = canvas
#         self._bg = None
#         self._artists = []
# 
#         for a in animated_artists:
#             self.add_artist(a)
#         # grab the background on every draw
#         self.cid = canvas.mpl_connect("draw_event", self.on_draw)
# 
#     def on_draw(self, event):
#         """Callback to register with 'draw_event'."""
#         cv = self.canvas
#         if event is not None and event.canvas != cv:
#             raise RuntimeError
#         self._bg = cv.copy_from_bbox(cv.figure.bbox)
#         self._draw_animated()
# 
#     def add_artist(self, art):
#         """
#         Add an artist to be managed.
# 
#         Parameters
#         ----------
#         art : Artist
# 
#             The artist to be added.  Will be set to 'animated' (just
#             to be safe).  *art* must be in the figure associated with
#             the canvas this class is managing.
# 
#         """
#         if art.figure != self.canvas.figure:
#             raise RuntimeError
#         art.set_animated(True)
#         self._artists.append(art)
# 
#     def remove_artist(self, art):
#         """
#         Remove an artist.
# 
#         Parameters
#         ----------
#         art : Artist
# 
#             The artist to be removed.
#             *art* must be in the figure associated with
#             the canvas this class is managing.
# 
#         """
#         if art.figure != self.canvas.figure:
#             raise RuntimeError
#         self._artists.remove(art)
# 
#     def _draw_animated(self):
#         """Draw all of the animated artists."""
#         fig = self.canvas.figure
#         for a in self._artists:
#             fig.draw_artist(a)
# 
#     def update(self):
#         """Update the screen with animated artists."""
#         cv = self.canvas
#         fig = cv.figure
#         # paranoia in case we missed the draw event,
#         if self._bg is None:
#             self.on_draw(None)
#         else:
#             # restore the background
#             cv.restore_region(self._bg)
#             # draw all of the animated artists
#             self._draw_animated()
#             # update the GUI state
#             cv.blit(fig.bbox)
#         # let the GUI event loop process anything it has to do
#         cv.flush_events()


import logging
import matplotlib.colors
import numpy as np
from typing import Optional, Dict, List
from matplotlib.axes import Axes
from matplotlib.lines import Line2D
from pytrip.vdx import Slice, Voi
from pytripgui.canvas_vc.objects.vdx import Vdx
from pytripgui.canvas_vc.plotter.managers import BlitManager




logger = logging.getLogger(__name__)

# set matplotlib logging level to ERROR, in order not to pollute our log space
logging.getLogger('matplotlib').setLevel(logging.ERROR)


class VoiManager:
    def __init__(self, axes: Axes, blit_manager: BlitManager):
        # axes where contours will be plotted
        self._axes: Axes = axes
        # blit manager is needed to add new contour to it, so it can blit them when the time comes

# Path: pytripgui/canvas_vc/objects/vdx.py
# class Vdx:
#     """
#     This class holds data model for plotting Vdx stuff.
#     """
#     def __init__(self, ctx, projection_selector):
#         self.ctx = ctx
#         self.projection_selector = projection_selector
#         self.voi_list = []
# 
# Path: pytripgui/canvas_vc/plotter/managers/blit_manager.py
# class BlitManager:
#     def __init__(self, canvas, animated_artists=()):
#         """
#         Parameters
#         ----------
#         canvas : FigureCanvasAgg
#             The canvas to work with, this only works for sub-classes of the Agg
#             canvas which have the `~FigureCanvasAgg.copy_from_bbox` and
#             `~FigureCanvasAgg.restore_region` methods.
# 
#         animated_artists : Iterable[Artist]
#             List of the artists to manage
#         """
#         self.canvas = canvas
#         self._bg = None
#         self._artists = []
# 
#         for a in animated_artists:
#             self.add_artist(a)
#         # grab the background on every draw
#         self.cid = canvas.mpl_connect("draw_event", self.on_draw)
# 
#     def on_draw(self, event):
#         """Callback to register with 'draw_event'."""
#         cv = self.canvas
#         if event is not None and event.canvas != cv:
#             raise RuntimeError
#         self._bg = cv.copy_from_bbox(cv.figure.bbox)
#         self._draw_animated()
# 
#     def add_artist(self, art):
#         """
#         Add an artist to be managed.
# 
#         Parameters
#         ----------
#         art : Artist
# 
#             The artist to be added.  Will be set to 'animated' (just
#             to be safe).  *art* must be in the figure associated with
#             the canvas this class is managing.
# 
#         """
#         if art.figure != self.canvas.figure:
#             raise RuntimeError
#         art.set_animated(True)
#         self._artists.append(art)
# 
#     def remove_artist(self, art):
#         """
#         Remove an artist.
# 
#         Parameters
#         ----------
#         art : Artist
# 
#             The artist to be removed.
#             *art* must be in the figure associated with
#             the canvas this class is managing.
# 
#         """
#         if art.figure != self.canvas.figure:
#             raise RuntimeError
#         self._artists.remove(art)
# 
#     def _draw_animated(self):
#         """Draw all of the animated artists."""
#         fig = self.canvas.figure
#         for a in self._artists:
#             fig.draw_artist(a)
# 
#     def update(self):
#         """Update the screen with animated artists."""
#         cv = self.canvas
#         fig = cv.figure
#         # paranoia in case we missed the draw event,
#         if self._bg is None:
#             self.on_draw(None)
#         else:
#             # restore the background
#             cv.restore_region(self._bg)
#             # draw all of the animated artists
#             self._draw_animated()
#             # update the GUI state
#             cv.blit(fig.bbox)
#         # let the GUI event loop process anything it has to do
#         cv.flush_events()


# Path: pytripgui/canvas_vc/plotter/managers/voi_manager.py
import logging
import matplotlib.colors
import numpy as np
from typing import Optional, Dict, List
from matplotlib.axes import Axes
from matplotlib.lines import Line2D
from pytrip.vdx import Slice, Voi
from pytripgui.canvas_vc.objects.vdx import Vdx
from pytripgui.canvas_vc.plotter.managers import BlitManager




logger = logging.getLogger(__name__)

# set matplotlib logging level to ERROR, in order not to pollute our log space
logging.getLogger('matplotlib').setLevel(logging.ERROR)


class VoiManager:
    def __init__(self, axes: Axes, blit_manager: BlitManager):
        # axes where contours will be plotted
        self._axes: Axes = axes
        # blit manager is needed to add new contour to it, so it can blit them when the time comes

        self._blit_manager: BlitManager = blit_manager
