kopia lustrzana https://github.com/evil-mad/EggBot
Correct possible problem with pause and resume for polyline, polygon, circle and ellipse. Before, self.pathcount would be incremented before deciding if the element was (as per SVG spec) to be ignored (e.g., a circle with a radius of zero, a polyline with no points). That could lead to pathcount being out of sync with svgLastPath. Now, the decision is first made whether or not the element is to be ignored and then pathcount is incremented if the element is NOT to be ignored.
git-svn-id: https://eggbotcode.googlecode.com/svn/trunk@74 72233254-1b6c-9e9c-5072-401df62706fbpull/47/head
rodzic
c4aad3fc1d
commit
52d09367aa
|
@ -100,7 +100,7 @@ selected number, which can be up to 100.
|
|||
<_param name="instructions_general" type="description" xml:space="preserve">
|
||||
EggBot Inkscape extension
|
||||
http://www.egg-bot.com/
|
||||
(Preview version 8/10/2010-A)
|
||||
(Preview version 8/10/2010-B)
|
||||
|
||||
*Motor wiring should be (L-R):
|
||||
Grey-Green-Yellow-Pink, for both motors
|
||||
|
|
|
@ -577,75 +577,88 @@ class EggBot(inkex.Effect):
|
|||
|
||||
elif node.tag == inkex.addNS('polyline','svg') or node.tag == 'polyline':
|
||||
|
||||
self.pathcount += 1
|
||||
#if we're in resume mode AND self.pathcount < self.svgLastPath, then skip over this path.
|
||||
#if we're in resume mode and self.pathcount = self.svgLastPath, then start here, and set
|
||||
# self.nodeCount equal to self.svgLastPathNC
|
||||
|
||||
if self.resumeMode and (self.pathcount == self.svgLastPath):
|
||||
self.nodeCount = self.svgLastPathNC
|
||||
# Ignore polylines with no 'points' attribute
|
||||
pl = node.get('points', '')
|
||||
if pl == '':
|
||||
pass
|
||||
|
||||
if self.resumeMode and (self.pathcount < self.svgLastPath):
|
||||
pass
|
||||
else:
|
||||
pl = node.get('points')
|
||||
if pl:
|
||||
pa = pl.split()
|
||||
d = "".join(["M " + pa[i] if i == 0 else " L " + pa[i] for i in range(0,len(pa))])
|
||||
newpath = inkex.etree.Element(inkex.addNS('path','svg'))
|
||||
newpath.set('d', d);
|
||||
s = node.get('style')
|
||||
if s:
|
||||
newpath.set('style',s)
|
||||
t = node.get('transform')
|
||||
if t:
|
||||
newpath.set('transform', t)
|
||||
self.plotPath(newpath, matNew)
|
||||
if (self.bStopped == False): #an "index" for resuming plots quickly-- record last complete path
|
||||
self.svgLastPath += 1
|
||||
self.svgLastPathNC = self.nodeCount
|
||||
else:
|
||||
pass
|
||||
self.pathcount += 1
|
||||
#if we're in resume mode AND self.pathcount < self.svgLastPath, then skip over this path.
|
||||
#if we're in resume mode and self.pathcount = self.svgLastPath, then start here, and set
|
||||
# self.nodeCount equal to self.svgLastPathNC
|
||||
|
||||
if self.resumeMode and (self.pathcount == self.svgLastPath):
|
||||
self.nodeCount = self.svgLastPathNC
|
||||
|
||||
if self.resumeMode and (self.pathcount < self.svgLastPath):
|
||||
pass
|
||||
|
||||
else:
|
||||
pa = pl.split()
|
||||
d = "".join(["M " + pa[i] if i == 0 else " L " + pa[i] for i in range(0,len(pa))])
|
||||
newpath = inkex.etree.Element(inkex.addNS('path','svg'))
|
||||
newpath.set('d', d);
|
||||
s = node.get('style')
|
||||
if s:
|
||||
newpath.set('style',s)
|
||||
t = node.get('transform')
|
||||
if t:
|
||||
newpath.set('transform', t)
|
||||
self.plotPath(newpath, matNew)
|
||||
if (self.bStopped == False): #an "index" for resuming plots quickly-- record last complete path
|
||||
self.svgLastPath += 1
|
||||
self.svgLastPathNC = self.nodeCount
|
||||
|
||||
elif node.tag == inkex.addNS('polygon','svg') or node.tag == 'polygon':
|
||||
|
||||
self.pathcount += 1
|
||||
#if we're in resume mode AND self.pathcount < self.svgLastPath, then skip over this path.
|
||||
#if we're in resume mode and self.pathcount = self.svgLastPath, then start here, and set
|
||||
# self.nodeCount equal to self.svgLastPathNC
|
||||
|
||||
if self.resumeMode and (self.pathcount == self.svgLastPath):
|
||||
self.nodeCount = self.svgLastPathNC
|
||||
# Ignore polygons which have no 'points' attributes
|
||||
pl = node.get('points', '')
|
||||
if pl == '':
|
||||
pass
|
||||
|
||||
if self.resumeMode and (self.pathcount < self.svgLastPath):
|
||||
pass
|
||||
self.pathcount += 1
|
||||
#if we're in resume mode AND self.pathcount < self.svgLastPath, then skip over this path.
|
||||
#if we're in resume mode and self.pathcount = self.svgLastPath, then start here, and set
|
||||
# self.nodeCount equal to self.svgLastPathNC
|
||||
|
||||
if self.resumeMode and (self.pathcount == self.svgLastPath):
|
||||
self.nodeCount = self.svgLastPathNC
|
||||
|
||||
if self.resumeMode and (self.pathcount < self.svgLastPath):
|
||||
pass
|
||||
|
||||
else:
|
||||
pl = node.get('points')
|
||||
if pl:
|
||||
pa = pl.split()
|
||||
d = "".join(["M " + pa[i] if i == 0 else " L " + pa[i] for i in range(0,len(pa))])
|
||||
d += " Z"
|
||||
newpath = inkex.etree.Element(inkex.addNS('path','svg'))
|
||||
newpath.set('d', d);
|
||||
s = node.get('style')
|
||||
if s:
|
||||
newpath.set('style',s)
|
||||
t = node.get('transform')
|
||||
if t:
|
||||
newpath.set('transform', t)
|
||||
self.plotPath(newpath, matNew)
|
||||
if (self.bStopped == False): #an "index" for resuming plots quickly-- record last complete path
|
||||
self.svgLastPath += 1
|
||||
self.svgLastPathNC = self.nodeCount
|
||||
else:
|
||||
pass
|
||||
pa = pl.split()
|
||||
d = "".join(["M " + pa[i] if i == 0 else " L " + pa[i] for i in range(0,len(pa))])
|
||||
d += " Z"
|
||||
newpath = inkex.etree.Element(inkex.addNS('path','svg'))
|
||||
newpath.set('d', d);
|
||||
s = node.get('style')
|
||||
if s:
|
||||
newpath.set('style',s)
|
||||
t = node.get('transform')
|
||||
if t:
|
||||
newpath.set('transform', t)
|
||||
self.plotPath(newpath, matNew)
|
||||
if (self.bStopped == False): #an "index" for resuming plots quickly-- record last complete path
|
||||
self.svgLastPath += 1
|
||||
self.svgLastPathNC = self.nodeCount
|
||||
|
||||
elif node.tag == inkex.addNS('ellipse','svg') or \
|
||||
node.tag == 'ellipse' or \
|
||||
node.tag == inkex.addNS('circle','svg') or \
|
||||
node.tag == 'circle':
|
||||
|
||||
# Ellipses or circles with a radius attribute of value 0 are ignored
|
||||
if node.tag == inkex.addNS('ellipse', 'svg') or node.tag == 'ellipse':
|
||||
rx = float(node.get('rx', '0'))
|
||||
ry = float(node.get('ry', '0'))
|
||||
else:
|
||||
rx = float(node.get('r', '0'))
|
||||
ry = rx
|
||||
if rx == 0 or ry == 0:
|
||||
pass
|
||||
|
||||
self.pathcount += 1
|
||||
#if we're in resume mode AND self.pathcount < self.svgLastPath, then skip over this path.
|
||||
#if we're in resume mode and self.pathcount = self.svgLastPath, then start here, and set
|
||||
|
@ -658,14 +671,6 @@ class EggBot(inkex.Effect):
|
|||
pass
|
||||
|
||||
else:
|
||||
if node.tag == inkex.addNS('ellipse', 'svg') or node.tag == 'ellipse':
|
||||
rx = float(node.get('rx', '0'))
|
||||
ry = float(node.get('ry', '0'))
|
||||
else:
|
||||
rx = float(node.get('r', '0'))
|
||||
ry = rx
|
||||
if rx == 0 or ry == 0:
|
||||
pass
|
||||
cx = float(node.get('cx', '0'))
|
||||
cy = float(node.get('cy', '0'))
|
||||
x1 = cx - rx
|
||||
|
|
Ładowanie…
Reference in New Issue