CMS 3D CMS Logo

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

Public Member Functions

def __init__ (self, d, kwds)
 
def __repr__ (self)
 
def SVG (self, trans=None)
 

Public Attributes

 d
 
 trans
 

Detailed Description

Stores graphics primitive objects and applies a single coordinate
transformation to them. To compose coordinate systems, nest Fig
objects.

Fig(obj, obj, obj..., trans=function)

obj     optional list    a list of drawing primatives
trans   default=None     a coordinate transformation function

>>> fig = Fig(Line(0,0,1,1), Rect(0.2,0.2,0.8,0.8), trans="2*x, 2*y")
>>> print fig.SVG().xml()
<g>
    <path d='M0 0L2 2' />
    <path d='M0.4 0.4L1.6 0.4ZL1.6 1.6ZL0.4 1.6ZL0.4 0.4ZZ' />
</g>
>>> print Fig(fig, trans="x/2., y/2.").SVG().xml()
<g>
    <path d='M0 0L1 1' />
    <path d='M0.2 0.2L0.8 0.2ZL0.8 0.8ZL0.2 0.8ZL0.2 0.2ZZ' />
</g>

Definition at line 711 of file svgfig.py.

Constructor & Destructor Documentation

◆ __init__()

def svgfig.Fig.__init__ (   self,
  d,
  kwds 
)

Definition at line 742 of file svgfig.py.

742  def __init__(self, *d, **kwds):
743  self.d = list(d)
744  defaults = {"trans":None}
745  defaults.update(kwds)
746  kwds = defaults
747 
748  self.trans = kwds["trans"]; del kwds["trans"]
749  if len(kwds) != 0:
750  raise TypeError("Fig() got unexpected keyword arguments %s" % kwds.keys())
751 
def __init__(self, dataset, job_number, job_id, job_name, isDA, isMC, applyBOWS, applyEXTRACOND, extraconditions, runboundary, lumilist, intlumi, maxevents, gt, allFromGT, alignmentDB, alignmentTAG, apeDB, apeTAG, bowDB, bowTAG, vertextype, tracktype, refittertype, ttrhtype, applyruncontrol, ptcut, CMSSW_dir, the_dir)

Member Function Documentation

◆ __repr__()

def svgfig.Fig.__repr__ (   self)

Definition at line 734 of file svgfig.py.

Referenced by data_sources.json_file.__str__(), and datamodel.Object.__str__().

734  def __repr__(self):
735  if self.trans == None:
736  return "<Fig (%d items)>" % len(self.d)
737  elif isinstance(self.trans, str):
738  return "<Fig (%d items) x,y -> %s>" % (len(self.d), self.trans)
739  else:
740  return "<Fig (%d items) %s>" % (len(self.d), self.trans.__name__)
741 

◆ SVG()

def svgfig.Fig.SVG (   self,
  trans = None 
)
Apply the transformation "trans" and return an SVG object.

Coordinate transformations in nested Figs will be composed.

Definition at line 752 of file svgfig.py.

References svgfig.Fig.d, svgfig.totrans(), and svgfig.Fig.trans.

752  def SVG(self, trans=None):
753  """Apply the transformation "trans" and return an SVG object.
754 
755  Coordinate transformations in nested Figs will be composed.
756  """
757 
758  if trans == None: trans = self.trans
759  if isinstance(trans, str): trans = totrans(trans)
760 
761  output = SVG("g")
762  for s in self.d:
763  if isinstance(s, SVG):
764  output.append(s)
765 
766  elif isinstance(s, Fig):
767  strans = s.trans
768  if isinstance(strans, str): strans = totrans(strans)
769 
770  if trans == None: subtrans = strans
771  elif strans == None: subtrans = trans
772  else: subtrans = lambda x,y: trans(*strans(x, y))
773 
774  output.sub += s.SVG(subtrans).sub
775 
776  elif s == None: pass
777 
778  else:
779  output.append(s.SVG(trans))
780 
781  return output
782 
def totrans(expr, vars=("x", "y"), globals=None, locals=None)
Definition: svgfig.py:598

Member Data Documentation

◆ d

svgfig.Fig.d

◆ trans

svgfig.Fig.trans

Definition at line 735 of file svgfig.py.

Referenced by svgfig.Fig.SVG(), and svgfig.Plot.SVG().