pathmodifier.py revision 5b2208f64b606f78f10d1136d933135a9d70a11a
'''
Copyright (C) 2006 Jean-Francois Barraud, barraud@math.univ-lille1.fr
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
barraud@math.univ-lille1.fr
'''
if transf=="":
return(mat)
#-- translate --
dy=0.0
else:
#-- scale --
else:
#-- rotate --
else:
#-- skewX --
#-- skewX --
#-- matrix --
else:
return matrix
def formatTransform(mat):
pt[0]=x
pt[1]=y
def fuseTransform(node):
if t == None:
return
m=parseTransform(t)
p=cubicsuperpath.parsePath(d)
for comp in p:
if b1 is None:
return b2
elif b2 is None:
return b1
else:
##################################
#-- Selectionlists manipulation --
##################################
bbox=None
p = cubicsuperpath.parsePath(d)
return bbox
clones={}
#!!!--> should it be given an id?
#seems to work without this!?!
return(clones)
return(id)
return(aList)
#Hum... not very efficient if there are many clones of groups...
if s:
if doReplace:
return aList
# Had not been rewritten for ElementTree
# def makeClonesReal(self,aList,doReplace=True,recursivelytransferTransform=True):
# for id in aList.keys():
# node=aList[id]
# if node.tagName == 'g':
# childs={}
# for child in node.childNodes:
# if child.nodeType==child.ELEMENT_NODE:
# childid=child.getAttributeNS(None,'id')
# del aList[childid]
# aList.update(self.makeClonesReal({childid:child},doReplace))
# elif node.tagName == 'use':
# refid=node.getAttributeNS(inkex.NSS[u'xlink'],'href')
# path = '//*[@id="%s"]' % refid[1:]
# refnode = xml.xpath.Evaluate(path,document)[0]
# clone=refnode.cloneNode(True)
# cloneid=self.uniqueId(clone.tagName)
# clone.setAttributeNS(None,'id', cloneid)
# style=simplestyle.parseStyle(node.getAttributeNS(None,u'style'))
# refstyle=simplestyle.parseStyle(refnode.getAttributeNS(None,u'style'))
# style.update(refstyle)
# clone.setAttributeNS(None,'style',simplestyle.formatStyle(style))
# applyTransformToNode(parseTransform(node.getAttributeNS(None,'transform')),clone)
# if doReplace:
# parent=node.parentNode
# parent.insertBefore(clone,node)
# parent.removeChild(node)
# del aList[id]
# aList.update(self.expandGroupsUnlinkClones({cloneid:clone}))
# return aList
################################
#-- Object conversion ----------
################################
#FIXME: no exception anymore and sometimes just one
try:
except:
rx=0
ry=0
d ='M %f,%f '%(x+rx,y)
d+='L %f,%f '%(x+w-rx,y)
d+='L %f,%f '%(x+w,y+h-ry)
d+='L %f,%f '%(x+rx,y+h)
d+='L %f,%f '%(x,y+ry)
if nnt:
if doReplace:
return newnode
#--TODO: support other object types!!!!
#--TODO: make sure cubicsuperpath supports A and Q commands...
for attName in attributes:
uri = None
#if attName not in ["d","id","style","transform"]:
return node
else:
return None
newSelection={}
################################
#-- Action ----------
################################
#-- overwrite this method in subclasses...
#self.duplicateNodes(self.selected)
p = cubicsuperpath.parsePath(d)
#do what ever you want with p!
class Diffeo(PathModifier):
'''
bpt is a base point and for v in vectors, v'=v-p is a tangent vector at bpt.
Defaults to identity!
'''
for v in vects:
#-- your transformations go here:
#x,y=bpt
#bpt[0]=f(x,y)
#bpt[1]=g(x,y)
#for v in vects:
# vx,vy=v
#
#-- !caution! y-axis is pointing downward!
for v in vects:
#self.duplicateNodes(self.selected)
p = cubicsuperpath.parsePath(d)
for sub in p:
#e = Diffeo()
#e.affect()