CMS 3D CMS Logo

List of all members | Public Member Functions | Public Attributes | Static Public Attributes
svgfig.Poly Class Reference

Public Member Functions

def __init__ (self, d=[], mode="L", loop=False, attr)
 
def __repr__ (self)
 
def Path (self, trans=None, local=False)
 
def SVG (self, trans=None)
 

Public Attributes

 attr
 
 d
 
 loop
 
 mode
 

Static Public Attributes

dictionary defaults = {}
 

Detailed Description

Draws a curve specified by a sequence of points. The curve may be
piecewise linear, like a polygon, or a Bezier curve.

Poly(d, mode, loop, attribute=value)

d                       required        list of tuples representing points
                                        and possibly control points
mode                    default="L"   "lines", "bezier", "velocity",
                                        "foreback", "smooth", or an abbreviation
loop                    default=False   if True, connect the first and last
                                        point, closing the loop
attribute=value pairs   keyword list    SVG attributes

The format of the tuples in d depends on the mode.

"lines"/"L"         d=[(x,y), (x,y), ...]
                                        piecewise-linear segments joining the (x,y) points
"bezier"/"B"        d=[(x, y, c1x, c1y, c2x, c2y), ...]
                                        Bezier curve with two control points (control points
                                        preceed (x,y), as in SVG paths). If (c1x,c1y) and
                                        (c2x,c2y) both equal (x,y), you get a linear
                                        interpolation ("lines")
"velocity"/"V"      d=[(x, y, vx, vy), ...]
                                        curve that passes through (x,y) with velocity (vx,vy)
                                        (one unit of arclength per unit time); in other words,
                                        (vx,vy) is the tangent vector at (x,y). If (vx,vy) is
                                        (0,0), you get a linear interpolation ("lines").
"foreback"/"F"      d=[(x, y, bx, by, fx, fy), ...]
                                        like "velocity" except that there is a left derivative
                                        (bx,by) and a right derivative (fx,fy). If (bx,by)
                                        equals (fx,fy) (with no minus sign), you get a
                                        "velocity" curve
"smooth"/"S"        d=[(x,y), (x,y), ...]
                                        a "velocity" interpolation with (vx,vy)[i] equal to
                                        ((x,y)[i+1] - (x,y)[i-1])/2: the minimal derivative

Definition at line 1679 of file svgfig.py.

Constructor & Destructor Documentation

def svgfig.Poly.__init__ (   self,
  d = [],
  mode = "L",
  loop = False,
  attr 
)

Definition at line 1721 of file svgfig.py.

1721  def __init__(self, d=[], mode="L", loop=False, **attr):
1722  self.d = list(d)
1723  self.mode = mode
1724  self.loop = loop
1725 
1726  self.attr = dict(self.defaults)
1727  self.attr.update(attr)
1728 
dictionary defaults
Definition: svgfig.py:1716
def __init__(self, d=[], mode="L", loop=False, attr)
Definition: svgfig.py:1721
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger list("!*","!HLTx*"if it matches 2 triggers or more) will accept the event if all the matching triggers are FAIL.It will reject the event if any of the triggers are PASS or EXCEPTION(this matches the behavior of"!*"before the partial wildcard feature was incorporated).Triggers which are in the READY state are completely ignored.(READY should never be returned since the trigger paths have been run

Member Function Documentation

def svgfig.Poly.__repr__ (   self)

Definition at line 1718 of file svgfig.py.

References svgfig.SVG.attr, svgfig.Path.attr, svgfig.Curve.attr, svgfig.Poly.attr, svgfig.Fig.d, svgfig.Plot.d, svgfig.Frame.d, svgfig.Path.d, svgfig.Poly.d, svgfig.Curve.loop, svgfig.Poly.loop, and svgfig.Poly.mode.

Referenced by data_sources.json_file.__str__().

1718  def __repr__(self):
1719  return "<Poly (%d nodes) mode=%s loop=%s %s>" % (len(self.d), self.mode, repr(self.loop), self.attr)
1720 
def __repr__(self)
Definition: svgfig.py:1718
def svgfig.Poly.Path (   self,
  trans = None,
  local = False 
)
Apply the transformation "trans" and return a Path object in
global coordinates.  If local=True, return a Path in local coordinates
(which must be transformed again).

Definition at line 1733 of file svgfig.py.

References svgfig.SVG.attr, svgfig.Path.attr, svgfig.Curve.attr, svgfig.Poly.attr, svgfig.Fig.d, svgfig.Plot.d, svgfig.Frame.d, svgfig.Path.d, svgfig.Poly.d, svgfig.Curve.loop, svgfig.Poly.loop, svgfig.Poly.mode, and svgfig.totrans().

Referenced by svgfig.Poly.SVG().

1733  def Path(self, trans=None, local=False):
1734  """Apply the transformation "trans" and return a Path object in
1735  global coordinates. If local=True, return a Path in local coordinates
1736  (which must be transformed again)."""
1737  if isinstance(trans, basestring): trans = totrans(trans)
1738 
1739  if self.mode[0] == "L" or self.mode[0] == "l": mode = "L"
1740  elif self.mode[0] == "B" or self.mode[0] == "b": mode = "B"
1741  elif self.mode[0] == "V" or self.mode[0] == "v": mode = "V"
1742  elif self.mode[0] == "F" or self.mode[0] == "f": mode = "F"
1743  elif self.mode[0] == "S" or self.mode[0] == "s":
1744  mode = "S"
1745 
1746  vx, vy = [0.]*len(self.d), [0.]*len(self.d)
1747  for i in xrange(len(self.d)):
1748  inext = (i+1) % len(self.d)
1749  iprev = (i-1) % len(self.d)
1750 
1751  vx[i] = (self.d[inext][0] - self.d[iprev][0])/2.
1752  vy[i] = (self.d[inext][1] - self.d[iprev][1])/2.
1753  if not self.loop and (i == 0 or i == len(self.d)-1):
1754  vx[i], vy[i] = 0., 0.
1755 
1756  else:
1757  raise ValueError("mode must be \"lines\", \"bezier\", \"velocity\", \"foreback\", \"smooth\", or an abbreviation")
1758 
1759  d = []
1760  indexes = range(len(self.d))
1761  if self.loop and len(self.d) > 0: indexes.append(0)
1762 
1763  for i in indexes:
1764  inext = (i+1) % len(self.d)
1765  iprev = (i-1) % len(self.d)
1766 
1767  x, y = self.d[i][0], self.d[i][1]
1768 
1769  if trans == None: X, Y = x, y
1770  else: X, Y = trans(x, y)
1771 
1772  if d == []:
1773  if local: d.append(("M", x, y, False))
1774  else: d.append(("M", X, Y, True))
1775 
1776  elif mode == "L":
1777  if local: d.append(("L", x, y, False))
1778  else: d.append(("L", X, Y, True))
1779 
1780  elif mode == "B":
1781  c1x, c1y = self.d[i][2], self.d[i][3]
1782  if trans == None: C1X, C1Y = c1x, c1y
1783  else: C1X, C1Y = trans(c1x, c1y)
1784 
1785  c2x, c2y = self.d[i][4], self.d[i][5]
1786  if trans == None: C2X, C2Y = c2x, c2y
1787  else: C2X, C2Y = trans(c2x, c2y)
1788 
1789  if local: d.append(("C", c1x, c1y, False, c2x, c2y, False, x, y, False))
1790  else: d.append(("C", C1X, C1Y, True, C2X, C2Y, True, X, Y, True))
1791 
1792  elif mode == "V":
1793  c1x, c1y = self.d[iprev][2]/3. + self.d[iprev][0], self.d[iprev][3]/3. + self.d[iprev][1]
1794  c2x, c2y = self.d[i][2]/-3. + x, self.d[i][3]/-3. + y
1795 
1796  if trans == None: C1X, C1Y = c1x, c1y
1797  else: C1X, C1Y = trans(c1x, c1y)
1798  if trans == None: C2X, C2Y = c2x, c2y
1799  else: C2X, C2Y = trans(c2x, c2y)
1800 
1801  if local: d.append(("C", c1x, c1y, False, c2x, c2y, False, x, y, False))
1802  else: d.append(("C", C1X, C1Y, True, C2X, C2Y, True, X, Y, True))
1803 
1804  elif mode == "F":
1805  c1x, c1y = self.d[iprev][4]/3. + self.d[iprev][0], self.d[iprev][5]/3. + self.d[iprev][1]
1806  c2x, c2y = self.d[i][2]/-3. + x, self.d[i][3]/-3. + y
1807 
1808  if trans == None: C1X, C1Y = c1x, c1y
1809  else: C1X, C1Y = trans(c1x, c1y)
1810  if trans == None: C2X, C2Y = c2x, c2y
1811  else: C2X, C2Y = trans(c2x, c2y)
1812 
1813  if local: d.append(("C", c1x, c1y, False, c2x, c2y, False, x, y, False))
1814  else: d.append(("C", C1X, C1Y, True, C2X, C2Y, True, X, Y, True))
1815 
1816  elif mode == "S":
1817  c1x, c1y = vx[iprev]/3. + self.d[iprev][0], vy[iprev]/3. + self.d[iprev][1]
1818  c2x, c2y = vx[i]/-3. + x, vy[i]/-3. + y
1819 
1820  if trans == None: C1X, C1Y = c1x, c1y
1821  else: C1X, C1Y = trans(c1x, c1y)
1822  if trans == None: C2X, C2Y = c2x, c2y
1823  else: C2X, C2Y = trans(c2x, c2y)
1824 
1825  if local: d.append(("C", c1x, c1y, False, c2x, c2y, False, x, y, False))
1826  else: d.append(("C", C1X, C1Y, True, C2X, C2Y, True, X, Y, True))
1827 
1828  if self.loop and len(self.d) > 0: d.append(("Z",))
1829 
1830  return Path(d, **self.attr)
1831 
def Path(self, trans=None, local=False)
Definition: svgfig.py:1733
def totrans(expr, vars=("x","y"), globals=None, locals=None)
Definition: svgfig.py:597
def svgfig.Poly.SVG (   self,
  trans = None 
)
Apply the transformation "trans" and return an SVG object.

Definition at line 1729 of file svgfig.py.

References SiStripHistoPlotter::PlotParameter.Path, Json::PathArgument.Path, svgfig.Curve.Path(), and svgfig.Poly.Path().

1729  def SVG(self, trans=None):
1730  """Apply the transformation "trans" and return an SVG object."""
1731  return self.Path(trans).SVG()
1732 
def Path(self, trans=None, local=False)
Definition: svgfig.py:1733
def SVG(self, trans=None)
Definition: svgfig.py:1729

Member Data Documentation

svgfig.Poly.attr
svgfig.Poly.d
dictionary svgfig.Poly.defaults = {}
static

Definition at line 1716 of file svgfig.py.

Referenced by tree.Tree.reset(), and tree.Tree.var().

svgfig.Poly.loop

Definition at line 1724 of file svgfig.py.

Referenced by svgfig.Poly.__repr__(), and svgfig.Poly.Path().

svgfig.Poly.mode