CMS 3D CMS Logo

Public Member Functions | Public Attributes | Static Public Attributes

svgfig::LineGlobal Class Reference

List of all members.

Public Member Functions

def __init__
def __repr__
def SVG

Public Attributes

 arrow_end
 attr
 local2
 y2

Static Public Attributes

dictionary defaults = {}

Detailed Description

Draws a line between two points, one or both of which is in
global coordinates.

Line(x1, y1, x2, y2, lcoal1, local2, arrow_start, arrow_end, attribute=value)

x1, y1                  required        the starting point
x2, y2                  required        the ending point
local1                  default=False   if True, interpret first point as a
                                        local coordinate (apply transform)
local2                  default=False   if True, interpret second point as a
                                        local coordinate (apply transform)
arrow_start             default=None    if an identifier string/Unicode,
                                        draw a new arrow object at the
                                        beginning of the line; if a marker,
                                        draw that marker instead
arrow_end               default=None    same for the end of the line
attribute=value pairs   keyword list    SVG attributes

Definition at line 2048 of file svgfig.py.


Constructor & Destructor Documentation

def svgfig::LineGlobal::__init__ (   self,
  x1,
  y1,
  x2,
  y2,
  local1 = False,
  local2 = False,
  arrow_start = None,
  arrow_end = None,
  attr 
)

Definition at line 2076 of file svgfig.py.

02077                                                                                                           :
02078     self.x1, self.y1, self.x2, self.y2 = x1, y1, x2, y2
02079     self.local1, self.local2 = local1, local2
02080     self.arrow_start, self.arrow_end = arrow_start, arrow_end
02081 
02082     self.attr = dict(self.defaults)
02083     self.attr.update(attr)


Member Function Documentation

def svgfig::LineGlobal::__repr__ (   self)

Definition at line 2069 of file svgfig.py.

02070                     :
02071     local1, local2 = "", ""
02072     if self.local1: local1 = "L"
02073     if self.local2: local2 = "L"
02074 
02075     return "<LineGlobal %s(%s, %s) to %s(%s, %s) %s>" % (local1, str(self.x1), str(self.y1), local2, str(self.x2), str(self.y2), self.attr)

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

Definition at line 2084 of file svgfig.py.

02085                            :
02086     """Apply the transformation "trans" and return an SVG object."""
02087     if isinstance(trans, basestring): trans = totrans(trans)
02088 
02089     X1, Y1, X2, Y2 = self.x1, self.y1, self.x2, self.y2
02090 
02091     if self.local1: X1, Y1 = trans(X1, Y1)
02092     if self.local2: X2, Y2 = trans(X2, Y2)
02093 
02094     line = SVG("path", d="M%s %s L%s %s" % (X1, Y1, X2, Y2), **self.attr)
02095 
02096     if (self.arrow_start != False and self.arrow_start != None) or (self.arrow_end != False and self.arrow_end != None):
02097       defs = SVG("defs")
02098 
02099       if self.arrow_start != False and self.arrow_start != None:
02100         if isinstance(self.arrow_start, SVG):
02101           defs.append(self.arrow_start)
02102           line.attr["marker-start"] = "url(#%s)" % self.arrow_start["id"]
02103         elif isinstance(self.arrow_start, basestring):
02104           defs.append(make_marker(self.arrow_start, "arrow_start"))
02105           line.attr["marker-start"] = "url(#%s)" % self.arrow_start
02106         else:
02107           raise TypeError, "arrow_start must be False/None or an id string for the new marker"
02108 
02109       if self.arrow_end != False and self.arrow_end != None:
02110         if isinstance(self.arrow_end, SVG):
02111           defs.append(self.arrow_end)
02112           line.attr["marker-end"] = "url(#%s)" % self.arrow_end["id"]
02113         elif isinstance(self.arrow_end, basestring):
02114           defs.append(make_marker(self.arrow_end, "arrow_end"))
02115           line.attr["marker-end"] = "url(#%s)" % self.arrow_end
02116         else:
02117           raise TypeError, "arrow_end must be False/None or an id string for the new marker"
02118 
02119       return SVG("g", defs, line)
02120 
02121     return line


Member Data Documentation

Definition at line 2076 of file svgfig.py.

Definition at line 2076 of file svgfig.py.

dictionary svgfig::LineGlobal::defaults = {} [static]

Definition at line 2067 of file svgfig.py.

Definition at line 2076 of file svgfig.py.

Definition at line 2076 of file svgfig.py.