"""
.. module:: VisBase
    :platform: Unix, Windows
    :synopsis: Abstract classes for NURBS-Python visualization components

.. moduleauthor:: Onur Rauf Bingol <orbingol@gmail.com>

"""

import abc


class VisAbstract(object):
    """ Visualization abstract class

    Uses Python's *Abstract Base Class* implementation to define a base for all common visualization options
    in NURBS-Python package.

    :param plot_ctrlpts: enables/disables display of control points plot on the final figure
    :type plot_ctrlpts: bool
    """
    __metaclass__ = abc.ABCMeta

    def __init__(self, plot_ctrlpts=True, display_legend=True):
        self._plots = []
        self._plot_ctrlpts = plot_ctrlpts
        self._plot_legend = display_legend
        self._figure_size = [10.67, 8]
        self._figure_dpi = 96

    def clear(self):
        """ Clears the points, colors and names lists. """
        self._plots[:] = []

    def add(self, ptsarr=(), name=None, color=None, plot_type=0):
        """ Adds points sets to the visualization instance for plotting.

        :param ptsarr: control, curve or surface points
        :type ptsarr: list, tuple
        :param name: name of the point on the legend
        :type name: str
        :param color: color of the point on the legend
        :type color: str
        :param plot_type: type of the plot, control points (type = 1) or evaluated points (type = 0)
        :type plot_type: int
        """
        if not ptsarr or not color or not name:
            return
        # Add points, plot color and name on the legend
        elem = {'ptsarr': ptsarr, 'name': name, 'color': color, 'type': plot_type}
        self._plots.append(elem)

    def figure_size(self, size=None):
        """ Sets the figure/window size.

        :param size: size of the figure/window as (x, y) values
        :type size: list, tuple
        """
        if not size or not isinstance(size, (tuple, list)):
            return
        if not len(size) == 2:
            return
        self._figure_size = size

    def figure_dpi(self, dpi=None):
        """ Sets the resolution of the figure.

        :param dpi: resolution value; 96 by default
        :type dpi: int
        """
        if not dpi or not isinstance(dpi, int):
            return
        self._figure_dpi = dpi

    @abc.abstractmethod
    def render(self):
        """ Abstract method for rendering plots of the point sets.

        This method must be implemented in all subclasses of ``VisAbstract`` class.
        """
        pass


class VisAbstractSurf(VisAbstract):
    """ Visualization abstract class for surfaces

    Implements ``VisABstract`` class and also uses Python's *Abstract Base Class* implementation to define a base
    for **surface** visualization options in NURBS-Python package.

    :param plot_ctrlpts: enables/disables display of control points plot on the final figure
    :type plot_ctrlpts: bool
    """
    __metaclass__ = abc.ABCMeta

    def __init__(self, plot_ctrlpts=True, display_legend=True):
        super(VisAbstractSurf, self).__init__(plot_ctrlpts, display_legend)
        self._ctrlpts_offset = 0.0

    def add(self, ptsarr=(), size=0, name=None, color=None, plot_type=0):
        """ Adds points sets to the visualization instance for plotting.

        :param ptsarr: control, curve or surface points
        :type ptsarr: list, tuple
        :param size: size in all directions, e.g. in U- or V-direction
        :type size: int, tuple, list
        :param name: name of the point on the legend
        :type name: str
        :param color: color of the point on the legend
        :type color: str
        :param plot_type: type of the plot, control points (type = 1) or evaluated points (type = 0)
        :type plot_type: int
        """
        if not ptsarr or not color or not name:
            return
        # Add points, size, plot color and name on the legend
        elem = {'ptsarr': ptsarr, 'size': size, 'name': name, 'color': color, 'type': plot_type}
        self._plots.append(elem)

    def set_ctrlpts_offset(self, offset_value):
        """ Sets an offset for the control points grid plot.

        :param offset_value: offset value
        :type offset_value: float
        """
        self._ctrlpts_offset = float(offset_value)

    @abc.abstractmethod
    def render(self):
        """ Abstract method for rendering plots of the point sets.

        This method must be implemented in all subclasses of ``VisAbstractSurf`` class.
        """
        pass

@@ -944,16 +944,24 @@
 sarr=(),
+ size=0,
  name=No
@@ -982,32 +982,32 @@
 , plot_type=0):%0A
-
         %22%22%22 Adds
@@ -1146,32 +1146,141 @@
 rr: list, tuple%0A
+        :param size: size in all directions, e.g. in U- and V-direction%0A        :type size: int, tuple, list%0A
         :param n
@@ -1650,16 +1650,22 @@
  points,
+ size,
  plot co
@@ -1724,16 +1724,30 @@
  ptsarr,
+ 'size': size,
  'name':
@@ -3240,16 +3240,16 @@
 legend)%0A
+
         
@@ -3280,913 +3280,8 @@
 .0%0A%0A
-    def add(self, ptsarr=(), size=0, name=None, color=None, plot_type=0):%0A        %22%22%22 Adds points sets to the visualization instance for plotting.%0A%0A        :param ptsarr: control, curve or surface points%0A        :type ptsarr: list, tuple%0A        :param size: size in all directions, e.g. in U- or V-direction%0A        :type size: int, tuple, list%0A        :param name: name of the point on the legend%0A        :type name: str%0A        :param color: color of the point on the legend%0A        :type color: str%0A        :param plot_type: type of the plot, control points (type = 1) or evaluated points (type = 0)%0A        :type plot_type: int%0A        %22%22%22%0A        if not ptsarr or not color or not name:%0A            return%0A        # Add points, size, plot color and name on the legend%0A        elem = %7B'ptsarr': ptsarr, 'size': size, 'name': name, 'color': color, 'type': plot_type%7D%0A        self._plots.append(elem)%0A%0A
     

Fix "argument number difference" warning