summaryrefslogtreecommitdiffstats
path: root/share/extensions
diff options
context:
space:
mode:
authorJabier Arraiza Cenoz <jabier.arraiza@marker.es>2015-07-24 19:44:32 +0000
committerJabiertxof <jtx@jtx.marker.es>2015-07-24 19:44:32 +0000
commitee640046c8e8d720c14496461eb956e0b68e0f66 (patch)
tree85cbbc8e6f62ddfcce07d34a68e9175bb988ec08 /share/extensions
parentfix a bug in refactor (diff)
parentFix a bug continuing a bezier path whith a LPE one like spiro or bspline on a... (diff)
downloadinkscape-ee640046c8e8d720c14496461eb956e0b68e0f66.tar.gz
inkscape-ee640046c8e8d720c14496461eb956e0b68e0f66.zip
update to trunk
(bzr r13973.1.15)
Diffstat (limited to 'share/extensions')
-rw-r--r--share/extensions/CMakeLists.txt49
-rw-r--r--share/extensions/Makefile.am3
-rw-r--r--share/extensions/hpgl_encoder.py77
-rw-r--r--share/extensions/hpgl_output.inx14
-rwxr-xr-xshare/extensions/hpgl_output.py4
-rw-r--r--share/extensions/image_attributes.inx82
-rwxr-xr-xshare/extensions/image_attributes.py169
-rwxr-xr-xshare/extensions/ink2canvas.py2
-rwxr-xr-xshare/extensions/inkex.py31
-rw-r--r--share/extensions/layout_nup.inx1
-rwxr-xr-xshare/extensions/layout_nup.py216
-rwxr-xr-xshare/extensions/layout_nup_pageframe.py230
-rwxr-xr-xshare/extensions/measure.py2
-rw-r--r--share/extensions/plotter.inx44
-rw-r--r--share/extensions/plotter.py106
-rw-r--r--share/extensions/scour.inx8
-rw-r--r--share/extensions/scour/Makefile.am13
-rw-r--r--[-rwxr-xr-x]share/extensions/scour/scour.inkscape.py (renamed from share/extensions/scour.inkscape.py)0
-rw-r--r--share/extensions/scour/scour.py (renamed from share/extensions/scour.py)0
-rw-r--r--[-rwxr-xr-x]share/extensions/scour/svg_regex.py (renamed from share/extensions/svg_regex.py)0
-rw-r--r--[-rwxr-xr-x]share/extensions/scour/svg_transform.py (renamed from share/extensions/svg_transform.py)0
-rw-r--r--[-rwxr-xr-x]share/extensions/scour/yocto_css.py (renamed from share/extensions/yocto_css.py)0
-rwxr-xr-xshare/extensions/svg2xaml.xsl27
-rwxr-xr-xshare/extensions/synfig_prepare.py2
-rwxr-xr-xshare/extensions/webslicer_export.py8
25 files changed, 733 insertions, 355 deletions
diff --git a/share/extensions/CMakeLists.txt b/share/extensions/CMakeLists.txt
new file mode 100644
index 000000000..280abd0a7
--- /dev/null
+++ b/share/extensions/CMakeLists.txt
@@ -0,0 +1,49 @@
+file(GLOB _FILES
+ "README"
+ "fontfix.conf"
+ "inkweb.js"
+ "jessyInk.js"
+ "jessyInk_core_mouseHandler_noclick.js"
+ "jessyInk_core_mouseHandler_zoomControl.js"
+ "aisvg.xslt"
+ "colors.xml"
+ "jessyInk_video.svg"
+ "seamless_pattern.svg"
+ "svg2fxg.xsl"
+ "svg2xaml.xsl"
+ "xaml2svg.xsl"
+ "inkscape.extension.rng"
+ "*.py"
+ "*.pl"
+ "*.sh"
+ "*.rb"
+ "*.inx"
+ )
+install(FILES ${_FILES} DESTINATION ${SHARE_INSTALL}/inkscape/extensions)
+
+file(GLOB _FILES "alphabet_soup/*.svg")
+install(FILES ${_FILES} DESTINATION ${SHARE_INSTALL}/inkscape/extensions/alphabet_soup)
+
+file(GLOB _FILES "Barcode/*.py")
+install(FILES ${_FILES} DESTINATION ${SHARE_INSTALL}/inkscape/extensions/Barcode)
+
+file(GLOB _FILES "Poly3DObjects/*.obj")
+install(FILES ${_FILES} DESTINATION ${SHARE_INSTALL}/inkscape/extensions/Poly3DObjects)
+
+# file(GLOB _FILES
+# "test/*.svg"
+# "test/*.sh"
+# "test/*.py"
+# "test/*.js"
+# "test/run-all-extension-tests"
+# )
+# install(FILES ${_FILES} DESTINATION ${SHARE_INSTALL}/inkscape/extensions/test)
+
+file(GLOB _FILES "ink2canvas/*.py")
+install(FILES ${_FILES} DESTINATION ${SHARE_INSTALL}/inkscape/extensions/ink2canvas)
+
+file(GLOB _FILES "scour/*.py")
+install(FILES ${_FILES} DESTINATION ${SHARE_INSTALL}/inkscape/extensions/scour)
+
+file(GLOB _FILES "xaml2svg/*.xsl")
+install(FILES ${_FILES} DESTINATION ${SHARE_INSTALL}/inkscape/extensions/xaml2svg)
diff --git a/share/extensions/Makefile.am b/share/extensions/Makefile.am
index 130ed6e40..765f18a02 100644
--- a/share/extensions/Makefile.am
+++ b/share/extensions/Makefile.am
@@ -2,9 +2,10 @@
SUBDIRS = \
alphabet_soup \
Barcode \
+ ink2canvas \
Poly3DObjects \
+ scour \
test \
- ink2canvas \
xaml2svg
extensiondir = $(datadir)/inkscape/extensions
diff --git a/share/extensions/hpgl_encoder.py b/share/extensions/hpgl_encoder.py
index a16561e97..83b1b7297 100644
--- a/share/extensions/hpgl_encoder.py
+++ b/share/extensions/hpgl_encoder.py
@@ -23,7 +23,6 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
import math
import re
import string
-#from StringIO import StringIO
# local libraries
import bezmisc
import cspsubdiv
@@ -66,6 +65,7 @@ class hpglEncoder:
self.sizeY = 'False'
self.dryRun = True
self.lastPoint = [0, 0, 0]
+ self.lastPen = -1
self.offsetX = 0
self.offsetY = 0
self.scaleX = self.options.resolutionX / effect.unittouu("1.0in") # dots per inch to dots per user unit
@@ -109,7 +109,7 @@ class hpglEncoder:
# dryRun to find edges
groupmat = [[self.mirrorX * self.scaleX * self.viewBoxTransformX, 0.0, 0.0], [0.0, self.mirrorY * self.scaleY * self.viewBoxTransformY, 0.0]]
groupmat = simpletransform.composeTransform(groupmat, simpletransform.parseTransform('rotate(' + self.options.orientation + ')'))
- self.vData = [['', -1.0, -1.0], ['', -1.0, -1.0], ['', -1.0, -1.0], ['', -1.0, -1.0]]
+ self.vData = [['', 'False', 0, 0], ['', 'False', 0, 0], ['', 'False', 0, 0], ['', 'False', 0, 0]]
self.processGroups(self.doc, groupmat)
if self.divergenceX == 'False' or self.divergenceY == 'False' or self.sizeX == 'False' or self.sizeY == 'False':
raise Exception('NO_PATHS')
@@ -156,11 +156,11 @@ class hpglEncoder:
groupmat = [[self.mirrorX * self.scaleX * self.viewBoxTransformX, 0.0, -self.divergenceX + self.offsetX],
[0.0, self.mirrorY * self.scaleY * self.viewBoxTransformY, -self.divergenceY + self.offsetY]]
groupmat = simpletransform.composeTransform(groupmat, simpletransform.parseTransform('rotate(' + self.options.orientation + ')'))
- self.vData = [['', -1.0, -1.0], ['', -1.0, -1.0], ['', -1.0, -1.0], ['', -1.0, -1.0]]
+ self.vData = [['', 'False', 0, 0], ['', 'False', 0, 0], ['', 'False', 0, 0], ['', 'False', 0, 0]]
# add move to zero point and precut
if self.toolOffset > 0.0 and self.options.precut:
if self.options.center:
- # position precut outside of drawing plus one times the tooloffset
+ # position precut outside of drawing plus one time the tooloffset
if self.offsetX >= 0.0:
precutX = self.offsetX + self.toolOffset
else:
@@ -169,17 +169,16 @@ class hpglEncoder:
precutY = self.offsetY + self.toolOffset
else:
precutY = self.offsetY - self.toolOffset
- self.processOffset('PU', precutX, precutY)
- self.processOffset('PD', precutX, precutY + self.toolOffset * 8)
+ self.processOffset('PU', precutX, precutY, self.options.pen)
+ self.processOffset('PD', precutX, precutY + self.toolOffset * 8, self.options.pen)
else:
- self.processOffset('PU', 0, 0)
- self.processOffset('PD', 0, self.toolOffset * 8)
- else:
- self.processOffset('PU', 0, 0)
+ self.processOffset('PU', 0, 0, self.options.pen)
+ self.processOffset('PD', 0, self.toolOffset * 8, self.options.pen)
# start conversion
self.processGroups(self.doc, groupmat)
# shift an empty node in in order to process last node in cache
- self.processOffset('PU', 0, 0)
+ if self.toolOffset > 0.0 and not self.dryRun:
+ self.processOffset('PU', 0, 0, 0)
if self.options.debug:
return self.hpgl, self
else:
@@ -190,7 +189,7 @@ class hpglEncoder:
paths = []
for node in doc:
if (node.tag == inkex.addNS('g', 'svg') and self.isGroupVisible(node)) or node.tag == inkex.addNS('path', 'svg'):
- paths.append([node.tag, node, self.mergeTransform(node, groupmat)])
+ paths.append([node.tag, node, self.mergeTransform(node, groupmat), self.getPenNumber(node)])
doc = ''
hasGroups = True
while hasGroups:
@@ -200,11 +199,19 @@ class hpglEncoder:
hasGroups = True
for path in paths[i][1]:
if (path.tag == inkex.addNS('g', 'svg') and self.isGroupVisible(path)) or path.tag == inkex.addNS('path', 'svg'):
- paths.append([path.tag, path, self.mergeTransform(path, paths[i][2])])
+ paths.insert(i + 1, [path.tag, path, self.mergeTransform(path, paths[i][2]), paths[i][3]])
paths[i][0] = ''
for node in paths:
if node[0] == inkex.addNS('path', 'svg'):
- self.processPath(node[1], node[2])
+ self.processPath(node[1], node[2], node[3])
+
+ def getPenNumber(self, doc):
+ penNum = str(doc.get('{' + inkex.NSS['inkscape'] + '}label')).lower().strip(' \t\n\r')
+ if re.search(r'( |\A)pen *\d+( |\Z)', penNum):
+ penNum = re.sub(r'(.* |\A)pen *(\d+)( .*|\Z)', r'\2', penNum, 1)
+ return int(penNum)
+ else:
+ return self.options.pen
def mergeTransform(self, doc, matrix):
# get and merge two matrixes into one
@@ -222,7 +229,7 @@ class hpglEncoder:
return False
return True
- def processPath(self, node, mat):
+ def processPath(self, node, mat, pen):
# process path
path = node.get('d')
if path:
@@ -239,7 +246,7 @@ class hpglEncoder:
posX, posY = singlePathPoint[1]
# check if point is repeating, if so, ignore
if int(round(posX)) != int(round(oldPosX)) or int(round(posY)) != int(round(oldPosY)):
- self.processOffset(cmd, posX, posY)
+ self.processOffset(cmd, posX, posY, pen)
cmd = 'PD'
oldPosX = posX
oldPosY = posY
@@ -255,10 +262,10 @@ class hpglEncoder:
overcutLength += self.getLength(oldPosX, oldPosY, posX, posY)
if overcutLength >= self.overcut:
newLength = self.changeLength(oldPosX, oldPosY, posX, posY, - (overcutLength - self.overcut))
- self.processOffset(cmd, newLength[0], newLength[1])
+ self.processOffset(cmd, newLength[0], newLength[1], pen)
break
else:
- self.processOffset(cmd, posX, posY)
+ self.processOffset(cmd, posX, posY, pen)
oldPosX = posX
oldPosY = posY
@@ -277,34 +284,34 @@ class hpglEncoder:
y = y2 + (y2 - y1) / self.getLength(x1, y1, x2, y2, False) * offset
return [x, y]
- def processOffset(self, cmd, posX, posY):
+ def processOffset(self, cmd, posX, posY, pen):
# calculate offset correction (or dont)
if self.toolOffset == 0.0 or self.dryRun:
- self.storePoint(cmd, posX, posY)
+ self.storePoint(cmd, posX, posY, pen)
else:
# insert data into cache
self.vData.pop(0)
- self.vData.insert(3, [cmd, posX, posY])
+ self.vData.insert(3, [cmd, posX, posY, pen])
# decide if enough data is availabe
- if self.vData[2][1] != -1.0:
- if self.vData[1][1] == -1.0:
- self.storePoint(self.vData[2][0], self.vData[2][1], self.vData[2][2])
+ if self.vData[2][1] != 'False':
+ if self.vData[1][1] == 'False':
+ self.storePoint(self.vData[2][0], self.vData[2][1], self.vData[2][2], self.vData[2][3])
else:
# perform tool offset correction (It's a *tad* complicated, if you want to understand it draw the data as lines on paper)
if self.vData[2][0] == 'PD': # If the 3rd entry in the cache is a pen down command make the line longer by the tool offset
pointThree = self.changeLength(self.vData[1][1], self.vData[1][2], self.vData[2][1], self.vData[2][2], self.toolOffset)
- self.storePoint('PD', pointThree[0], pointThree[1])
- elif self.vData[0][1] != -1.0:
+ self.storePoint('PD', pointThree[0], pointThree[1], self.vData[2][3])
+ elif self.vData[0][1] != 'False':
# Elif the 1st entry in the cache is filled with data and the 3rd entry is a pen up command shift
# the 3rd entry by the current tool offset position according to the 2nd command
pointThree = self.changeLength(self.vData[0][1], self.vData[0][2], self.vData[1][1], self.vData[1][2], self.toolOffset)
pointThree[0] = self.vData[2][1] - (self.vData[1][1] - pointThree[0])
pointThree[1] = self.vData[2][2] - (self.vData[1][2] - pointThree[1])
- self.storePoint('PU', pointThree[0], pointThree[1])
+ self.storePoint('PU', pointThree[0], pointThree[1], self.vData[2][3])
else:
# Else just write the 3rd entry
pointThree = [self.vData[2][1], self.vData[2][2]]
- self.storePoint('PU', pointThree[0], pointThree[1])
+ self.storePoint('PU', pointThree[0], pointThree[1], self.vData[2][3])
if self.vData[3][0] == 'PD':
# If the 4th entry in the cache is a pen down command guide tool to next line with a circle between the prolonged 3rd and 4th entry
if self.getLength(self.vData[2][1], self.vData[2][2], self.vData[3][1], self.vData[3][2]) >= self.toolOffset:
@@ -324,16 +331,16 @@ class hpglEncoder:
if angleVector >= 0:
angle = angleStart + self.toolOffsetFlat
while angle < angleStart + angleVector:
- self.storePoint('PD', self.vData[2][1] + math.cos(angle) * self.toolOffset, self.vData[2][2] + math.sin(angle) * self.toolOffset)
+ self.storePoint('PD', self.vData[2][1] + math.cos(angle) * self.toolOffset, self.vData[2][2] + math.sin(angle) * self.toolOffset, self.vData[2][3])
angle += self.toolOffsetFlat
else:
angle = angleStart - self.toolOffsetFlat
while angle > angleStart + angleVector:
- self.storePoint('PD', self.vData[2][1] + math.cos(angle) * self.toolOffset, self.vData[2][2] + math.sin(angle) * self.toolOffset)
+ self.storePoint('PD', self.vData[2][1] + math.cos(angle) * self.toolOffset, self.vData[2][2] + math.sin(angle) * self.toolOffset, self.vData[2][3])
angle -= self.toolOffsetFlat
- self.storePoint('PD', pointFour[0], pointFour[1])
+ self.storePoint('PD', pointFour[0], pointFour[1], self.vData[3][3])
- def storePoint(self, command, x, y):
+ def storePoint(self, command, x, y, pen):
x = int(round(x))
y = int(round(y))
# skip when no change in movement
@@ -357,11 +364,15 @@ class hpglEncoder:
x = 0
if y < 0:
y = 0
+ # select correct pen
+ if self.lastPen != pen:
+ self.hpgl += ';SP%d' % pen
# do not repeat command
- if command == 'PD' and self.lastPoint[0] == 'PD':
+ if command == 'PD' and self.lastPoint[0] == 'PD' and self.lastPen == pen:
self.hpgl += ',%d,%d' % (x, y)
else:
self.hpgl += ';%s%d,%d' % (command, x, y)
+ self.lastPen = pen
self.lastPoint = [command, x, y]
# vim: expandtab shiftwidth=4 tabstop=8 softtabstop=4 fileencoding=utf-8 textwidth=99 \ No newline at end of file
diff --git a/share/extensions/hpgl_output.inx b/share/extensions/hpgl_output.inx
index bfb3e3567..7fa900dc8 100644
--- a/share/extensions/hpgl_output.inx
+++ b/share/extensions/hpgl_output.inx
@@ -22,14 +22,16 @@
</param>
<param name="mirrorX" type="boolean" _gui-text="Mirror X axis" _gui-description="Check this to mirror the X axis (Default: Unchecked)">false</param>
<param name="mirrorY" type="boolean" _gui-text="Mirror Y axis" _gui-description="Check this to mirror the Y axis (Default: Unchecked)">false</param>
- <param name="center" type="boolean" _gui-text="Center zero point" _gui-description="Check this if your plotter uses a centered zero point (Default: Unchecked)">false</param>
+ <param name="center" type="boolean" _gui-text="Center zero point" _gui-description="Check this if your plotter uses a centered zero point (Default: Unchecked)">false</param>
+ <param name="space" type="description">&#xa0;</param>
+ <_param name="multiplePensHelp" type="description">If you want to use multiple pens on your pen plotter create one layer for each pen, name the layers "Pen 1", "Pen 2", etc., and put your drawings in the corresponding layers. This overrules the pen number option above.</_param>
</page>
<page name="overcutToolOffset" _gui-text="Plot Features ">
- <param name="overcut" type="float" min="0.0" max="100.0" precision="2" _gui-text="Overcut (mm):" _gui-description="The distance in mm that will be cut over the starting point of the path to prevent open paths, set to 0.0 to omit command (Default: 1.00)">1.00</param>
- <param name="toolOffset" type="float" min="0.0" max="20.0" precision="2" _gui-text="Tool offset (mm):" _gui-description="The offset from the tool tip to the tool axis in mm, set to 0.0 to omit command (Default: 0.25)">0.25</param>
- <param name="precut" type="boolean" _gui-text="Use precut" _gui-description="Check this to cut a small line before the real drawing starts to correctly align the tool orientation. (Default: Checked)">true</param>
- <param name="flat" type="float" min="0.1" max="10.0" precision="1" _gui-text="Curve flatness:" _gui-description="Curves are divided into lines, this number controls how fine the curves will be reproduced, the smaller the finer (Default: '1.2')">1.2</param>
- <param name="autoAlign" type="boolean" _gui-text="Auto align" _gui-description="Check this to auto align the drawing to the zero point (Plus the tool offset if used). If unchecked you have to make sure that all parts of your drawing are within the document border! (Default: Checked)">true</param>
+ <param name="overcut" type="float" min="0.0" max="100.0" precision="2" _gui-text="Overcut (mm):" _gui-description="The distance in mm that will be cut over the starting point of the path to prevent open paths, set to 0.0 to omit command (Default: 1.00)">1.00</param>
+ <param name="toolOffset" type="float" min="0.0" max="20.0" precision="2" _gui-text="Tool offset (mm):" _gui-description="The offset from the tool tip to the tool axis in mm, set to 0.0 to omit command (Default: 0.25)">0.25</param>
+ <param name="precut" type="boolean" _gui-text="Use precut" _gui-description="Check this to cut a small line before the real drawing starts to correctly align the tool orientation. (Default: Checked)">true</param>
+ <param name="flat" type="float" min="0.1" max="10.0" precision="1" _gui-text="Curve flatness:" _gui-description="Curves are divided into lines, this number controls how fine the curves will be reproduced, the smaller the finer (Default: '1.2')">1.2</param>
+ <param name="autoAlign" type="boolean" _gui-text="Auto align" _gui-description="Check this to auto align the drawing to the zero point (Plus the tool offset if used). If unchecked you have to make sure that all parts of your drawing are within the document border! (Default: Checked)">true</param>
</page>
</param>
<_param name="settingsHelp" type="description">All these settings depend on the plotter you use, for more information please consult the manual or homepage for your plotter.</_param>
diff --git a/share/extensions/hpgl_output.py b/share/extensions/hpgl_output.py
index c6713cb65..fc4f248af 100755
--- a/share/extensions/hpgl_output.py
+++ b/share/extensions/hpgl_output.py
@@ -62,12 +62,12 @@ class HpglOutput(inkex.Effect):
type, value, traceback = sys.exc_info()
raise ValueError, ("", type, value), traceback
# convert raw HPGL to HPGL
- hpglInit = 'IN;SP%d' % self.options.pen
+ hpglInit = 'IN'
if self.options.force > 0:
hpglInit += ';FS%d' % self.options.force
if self.options.speed > 0:
hpglInit += ';VS%d' % self.options.speed
- self.hpgl = hpglInit + self.hpgl + ';PU0,0;SP0;IN;'
+ self.hpgl = hpglInit + self.hpgl + ';SP0;PU0,0;IN; '
def output(self):
# print to file
diff --git a/share/extensions/image_attributes.inx b/share/extensions/image_attributes.inx
new file mode 100644
index 000000000..a353d17e5
--- /dev/null
+++ b/share/extensions/image_attributes.inx
@@ -0,0 +1,82 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension">
+
+ <_name>Set Image Attributes</_name>
+ <id>org.inkscape.effect.image_attributes</id>
+
+ <dependency type="executable" location="extensions">image_attributes.py</dependency>
+ <dependency type="executable" location="extensions">inkex.py</dependency>
+
+ <param name="tab_main" type="notebook">
+
+ <!-- render images like in 0.48 -->
+ <page name="tab_basic" _gui-text="Basic">
+ <_param name="basic_desc1" type="description">Render all bitmap images like in older Inskcape versions.
+
+Available options:</_param>
+ <param name="fix_scaling" type="boolean" _gui-text="Support non-unifom scaling">true</param>
+ <param name="fix_rendering" type="boolean" _gui-text="Render images blocky">false</param>
+ </page>
+
+ <!-- image aspect ratio -->
+ <page name="tab_aspectRatio" _gui-text="Image Aspect Ratio">
+ <param name="aspect_ratio" type="enum" _gui-text="preserveAspectRatio attribute:">
+ <item value="none">none</item>
+ <_item value="unset">Unset</_item>
+ <item value="xMinYMin">xMinYMin</item>
+ <item value="xMidYMin">xMidYMin</item>
+ <item value="xMaxYMin">xMaxYMin</item>
+ <item value="xMinYMid">xMinYMid</item>
+ <item value="xMidYMid">xMidYMid</item>
+ <item value="xMaxYMid">xMaxYMid</item>
+ <item value="xMinYMax">xMinYMax</item>
+ <item value="xMidYMax">xMidYMax</item>
+ <item value="xMaxYMax">xMaxYMax</item>
+ </param>
+ <param name="aspect_clip" type="enum" _gui-text="meetOrSlice:">
+ <item value="unset">-</item>
+ <item value="meet">meet</item>
+ <item value="slice">slice</item>
+ </param>
+ <param name="aspect_ratio_scope" type="enum" _gui-text="Scope:">
+ <_item value="selected_only">Change only selected image(s)</_item>
+ <_item value="in_selection">Change all images in selection</_item>
+ <_item value="in_document">Change all images in document</_item>
+ </param>
+ </page>
+
+ <!-- image-rendering -->
+ <page name="tab_image_rendering" _gui-text="Image Rendering Quality">
+ <param name="image_rendering" type="enum" _gui-text="Image rendering attribute:">
+ <_item value="unset">Unset</_item>
+ <item value="auto">auto</item>
+ <item value="optimizeQuality">optimizeQuality</item>
+ <item value="optimizeSpeed">optimizeSpeed</item>
+ <item value="inherit">inherit</item>
+ </param>
+ <param name="image_rendering_scope" type="enum" _gui-text="Scope:">
+ <_item value="selected_only">Change only selected image(s)</_item>
+ <_item value="in_selection">Change all images in selection</_item>
+ <_item value="in_document">Change all images in document</_item>
+ <_item value="on_parent_group">Apply attribute to parent group of selection</_item>
+ <_item value="on_root_only" >Apply attribute to SVG root</_item>
+ </param>
+ </page>
+
+ </param>
+
+ <effect needs-document="true" needs-live-preview="true">
+ <object-type>all</object-type>
+ <effects-menu>
+ <submenu _name="Images"/>
+ </effects-menu>
+ </effect>
+
+ <script>
+ <command reldir="extensions" interpreter="python">image_attributes.py</command>
+ </script>
+
+ <options silent="false"></options>
+
+</inkscape-extension>
+
diff --git a/share/extensions/image_attributes.py b/share/extensions/image_attributes.py
new file mode 100755
index 000000000..ddd5a8b87
--- /dev/null
+++ b/share/extensions/image_attributes.py
@@ -0,0 +1,169 @@
+#!/usr/bin/env python
+'''
+image_attributes.py - adjust image attributes which don't have global
+GUI options yet
+
+Tool for Inkscape 0.91 to adjust rendering of drawings with linked
+or embedded bitmap images created with older versions of Inkscape
+or third-party applications.
+
+Copyright (C) 2015, ~suv <suv-sf@users.sf.net>
+
+This program is free software; you can redistribute it and/or modify
+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
+'''
+
+# local library
+import inkex
+import simplestyle
+
+try:
+ inkex.localize()
+except:
+ import gettext
+ _ = gettext.gettext
+
+
+class SetAttrImage(inkex.Effect):
+ def __init__(self):
+ inkex.Effect.__init__(self)
+ # main options
+ self.OptionParser.add_option("--fix_scaling",
+ action="store", type="inkbool",
+ dest="fix_scaling", default=True,
+ help="")
+ self.OptionParser.add_option("--fix_rendering",
+ action="store", type="inkbool",
+ dest="fix_rendering", default=False,
+ help="")
+ self.OptionParser.add_option("--aspect_ratio",
+ action="store", type="string",
+ dest="aspect_ratio", default="none",
+ help="Value for attribute 'preserveAspectRatio'")
+ self.OptionParser.add_option("--aspect_clip",
+ action="store", type="string",
+ dest="aspect_clip", default="unset",
+ help="optional 'meetOrSlice' value")
+ self.OptionParser.add_option("--aspect_ratio_scope",
+ action="store", type="string",
+ dest="aspect_ratio_scope", default="selected_only",
+ help="scope within which to edit 'preserveAspectRatio' attribute")
+ self.OptionParser.add_option("--image_rendering",
+ action="store", type="string",
+ dest="image_rendering", default="unset",
+ help="Value for attribute 'image-rendering'")
+ self.OptionParser.add_option("--image_rendering_scope",
+ action="store", type="string",
+ dest="image_rendering_scope", default="selected_only",
+ help="scope within which to edit 'image-rendering' attribute")
+ # tabs
+ self.OptionParser.add_option("--tab_main",
+ action="store", type="string",
+ dest="tab_main")
+
+ # core method
+
+ def change_attribute(self, node, attribute):
+ for key, value in attribute.items():
+ if key == 'preserveAspectRatio':
+ # set presentation attribute
+ if value != "unset":
+ node.set(key, str(value))
+ else:
+ if node.get(key):
+ del node.attrib[key]
+ elif key == 'image-rendering':
+ node_style = simplestyle.parseStyle(node.get('style'))
+ if key not in node_style:
+ # set presentation attribute
+ if value != "unset":
+ node.set(key, str(value))
+ else:
+ if node.get(key):
+ del node.attrib[key]
+ else:
+ # set style property
+ if value != "unset":
+ node_style[key] = str(value)
+ else:
+ del node_style[key]
+ node.set('style', simplestyle.formatStyle(node_style))
+ else:
+ pass
+
+ def change_all_images(self, node, attribute):
+ path = 'descendant-or-self::svg:image'
+ for img in node.xpath(path, namespaces=inkex.NSS):
+ self.change_attribute(img, attribute)
+
+ # methods called via dispatcher
+
+ def change_selected_only(self, selected, attribute):
+ if selected:
+ for node_id, node in selected.iteritems():
+ if node.tag == inkex.addNS('image', 'svg'):
+ self.change_attribute(node, attribute)
+
+ def change_in_selection(self, selected, attribute):
+ if selected:
+ for node_id, node in selected.iteritems():
+ self.change_all_images(node, attribute)
+
+ def change_in_document(self, selected, attribute):
+ self.change_all_images(self.document.getroot(), attribute)
+
+ def change_on_parent_group(self, selected, attribute):
+ if selected:
+ for node_id, node in selected.iteritems():
+ self.change_attribute(node.getparent(), attribute)
+
+ def change_on_root_only(self, selected, attribute):
+ self.change_attribute(self.document.getroot(), attribute)
+
+ # main
+
+ def effect(self):
+ attr_val = []
+ attr_dict = {}
+ cmd_scope = None
+ if self.options.tab_main == '"tab_basic"':
+ cmd_scope = "in_document"
+ attr_dict['preserveAspectRatio'] = ("none" if self.options.fix_scaling else "unset")
+ attr_dict['image-rendering'] = ("optimizeSpeed" if self.options.fix_rendering else "unset")
+ elif self.options.tab_main == '"tab_aspectRatio"':
+ attr_val = [self.options.aspect_ratio]
+ if self.options.aspect_clip != "unset":
+ attr_val.append(self.options.aspect_clip)
+ attr_dict['preserveAspectRatio'] = ' '.join(attr_val)
+ cmd_scope = self.options.aspect_ratio_scope
+ elif self.options.tab_main == '"tab_image_rendering"':
+ attr_dict['image-rendering'] = self.options.image_rendering
+ cmd_scope = self.options.image_rendering_scope
+ else: # help tab
+ pass
+ # dispatcher
+ if cmd_scope is not None:
+ try:
+ change_cmd = getattr(self, 'change_{0}'.format(cmd_scope))
+ change_cmd(self.selected, attr_dict)
+ except AttributeError:
+ inkex.errormsg('Scope "{0}" not supported'.format(cmd_scope))
+
+
+if __name__ == '__main__':
+ e = SetAttrImage()
+ e.affect()
+
+
+# vim: expandtab shiftwidth=4 tabstop=8 softtabstop=4 fileencoding=utf-8 textwidth=99
diff --git a/share/extensions/ink2canvas.py b/share/extensions/ink2canvas.py
index d1e11a7c2..b5c0fbb7b 100755
--- a/share/extensions/ink2canvas.py
+++ b/share/extensions/ink2canvas.py
@@ -59,6 +59,8 @@ class Ink2Canvas(inkex.Effect):
def walk_tree(self, root):
for node in root:
+ if node.tag is inkex.etree.Comment:
+ continue
tag = self.get_tag_name(node)
class_name = tag.capitalize()
if not hasattr(svg, class_name):
diff --git a/share/extensions/inkex.py b/share/extensions/inkex.py
index 19e860b9a..6eb229885 100755
--- a/share/extensions/inkex.py
+++ b/share/extensions/inkex.py
@@ -207,7 +207,7 @@ class Effect:
x = self.unittouu( xattr[0] + 'px' )
y = self.unittouu( yattr[0] + 'px')
doc_height = self.unittouu(self.document.getroot().get('height'))
- if x and y:
+ if x and y and doc_height is not None:
self.view_center = (float(x), doc_height - float(y)) # FIXME: y-coordinate flip, eliminate it when it's gone in Inkscape
def getselected(self):
@@ -297,7 +297,7 @@ class Effect:
svgwidth = self.document.getroot().get('width')
viewboxstr = self.document.getroot().get('viewBox')
- if viewboxstr:
+ if viewboxstr and svgwidth is not None:
unitmatch = re.compile('(%s)$' % '|'.join(self.__uuconv.keys()))
param = re.compile(r'(([-+]?[0-9]+(\.[0-9]*)?|[-+]?\.[0-9]+)([eE][-+]?[0-9]+)?)')
@@ -340,19 +340,22 @@ class Effect:
unit = re.compile('(%s)$' % '|'.join(self.__uuconv.keys()))
param = re.compile(r'(([-+]?[0-9]+(\.[0-9]*)?|[-+]?\.[0-9]+)([eE][-+]?[0-9]+)?)')
- p = param.match(string)
- u = unit.search(string)
- if p:
- retval = float(p.string[p.start():p.end()])
+ if string is not None:
+ p = param.match(string)
+ u = unit.search(string)
+ if p:
+ retval = float(p.string[p.start():p.end()])
+ else:
+ retval = 0.0
+ if u:
+ try:
+ return retval * (self.__uuconv[u.string[u.start():u.end()]] / self.__uuconv[self.getDocumentUnit()])
+ except KeyError:
+ pass
+ else: # default assume 'px' unit
+ return retval / self.__uuconv[self.getDocumentUnit()]
else:
- retval = 0.0
- if u:
- try:
- return retval * (self.__uuconv[u.string[u.start():u.end()]] / self.__uuconv[self.getDocumentUnit()])
- except KeyError:
- pass
- else: # default assume 'px' unit
- return retval / self.__uuconv[self.getDocumentUnit()]
+ retval = None
return retval
diff --git a/share/extensions/layout_nup.inx b/share/extensions/layout_nup.inx
index 2b7734fc3..1d4d1ef0f 100644
--- a/share/extensions/layout_nup.inx
+++ b/share/extensions/layout_nup.inx
@@ -3,7 +3,6 @@
<_name>N-up layout</_name>
<id>org.greygreen.inkscape.effects.nup</id>
<dependency type="executable" location="extensions">layout_nup.py</dependency>
- <dependency type="executable" location="extensions">layout_nup_pageframe.py</dependency>
<dependency type="executable" location="extensions">inkex.py</dependency>
<param name="tab" type="notebook">
diff --git a/share/extensions/layout_nup.py b/share/extensions/layout_nup.py
index 5f8451c45..266a3950d 100755
--- a/share/extensions/layout_nup.py
+++ b/share/extensions/layout_nup.py
@@ -19,7 +19,19 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
import inkex
import sys
-import layout_nup_pageframe
+try:
+ import xml.etree.ElementTree as ElementTree
+except:
+ try:
+ from lxml import etree as ElementTree
+ except:
+ try:
+ from elementtree.ElementTree import ElementTree
+ except:
+ sys.stderr.write("""Requires ElementTree module, included
+in Python 2.5 or supplied by lxml or elementtree modules.
+
+""")
class Nup(inkex.Effect):
def __init__(self):
@@ -64,7 +76,7 @@ class Nup(inkex.Effect):
if getattr(self.options, i):
showList.append(i.lower().replace('show', ''))
o = self.options
- self.pf = layout_nup_pageframe.GenerateNup(
+ self.pf = self.GenerateNup(
unit=o.unit,
pgSize=(o.pgSizeX,o.pgSizeY),
pgMargin=(o.pgMarginTop,o.pgMarginRight,o.pgMarginBottom,o.pgMarginLeft),
@@ -84,7 +96,203 @@ class Nup(inkex.Effect):
def output(self):
sys.stdout.write(self.pf)
+ def expandTuple(self, unit, x, length = 4):
+ try:
+ iter(x)
+ except:
+ return None
+
+ if len(x) != length: x = x*2
+ if len(x) != length:
+ raise Exception("expandTuple: requires 2 or 4 item tuple")
+ try:
+ return tuple(map(lambda ev: (self.unittouu(str(eval(str(ev)))+unit)/self.unittouu('1px')), x))
+ except:
+ return None
+
+ def GenerateNup(self,
+ unit="px",
+ pgSize=("8.5*96","11*96"),
+ pgMargin=(0,0),
+ pgPadding=(0,0),
+ num=(2,2),
+ calculateSize=True,
+ size=None,
+ margin=(0,0),
+ padding=(20,20),
+ show=['default'],
+ container='svg',
+ returnTree = False,
+ ):
+ """Generate the SVG. Inputs are run through 'eval(str(x))' so you can use
+ '8.5*72' instead of 612. Margin / padding dimension tuples can be
+ (top & bottom, left & right) or (top, right, bottom, left).
+
+ Keyword arguments:
+ pgSize -- page size, width x height
+ pgMargin -- extra space around each page
+ pgPadding -- added to pgMargin
+ n -- rows x cols
+ size -- override calculated size, width x height
+ margin -- white space around each piece
+ padding -- inner padding for each piece
+ show -- list of keywords indicating what to show
+ - 'crosses' - cutting guides
+ - 'inner' - inner boundary
+ - 'outer' - outer boundary
+ container -- 'svg' or 'g'
+ returnTree -- whether to return the ElementTree or the string
+ """
+
+ if 'default' in show:
+ show = set(show).union(['inner', 'innerbox', 'holder', 'crosses'])
+
+ pgMargin = self.expandTuple(unit, pgMargin)
+ pgPadding = self.expandTuple(unit, pgPadding)
+ margin = self.expandTuple(unit, margin)
+ padding = self.expandTuple(unit, padding)
+
+ pgSize = self.expandTuple(unit, pgSize, length = 2)
+ # num = tuple(map(lambda ev: eval(str(ev)), num))
+
+ pgEdge = map(sum,zip(pgMargin, pgPadding))
+
+ top, right, bottom, left = 0,1,2,3
+ width, height = 0,1
+ rows, cols = 0,1
+ size = self.expandTuple(unit, size, length = 2)
+ if size == None or calculateSize == True or len(size) < 2 or size[0] == 0 or size[1] == 0:
+ size = ((pgSize[width]
+ - pgEdge[left] - pgEdge[right]
+ - num[cols]*(margin[left] + margin[right])) / num[cols],
+ (pgSize[height]
+ - pgEdge[top] - pgEdge[bottom]
+ - num[rows]*(margin[top] + margin[bottom])) / num[rows]
+ )
+ else:
+ size = self.expandTuple(unit, size, length = 2)
+
+ # sep is separation between same points on pieces
+ sep = (size[width]+margin[right]+margin[left],
+ size[height]+margin[top]+margin[bottom])
+
+ style = 'stroke:#000000;stroke-opacity:1;fill:none;fill-opacity:1;'
+
+ padbox = 'rect', {
+ 'x': str(pgEdge[left] + margin[left] + padding[left]),
+ 'y': str(pgEdge[top] + margin[top] + padding[top]),
+ 'width': str(size[width] - padding[left] - padding[right]),
+ 'height': str(size[height] - padding[top] - padding[bottom]),
+ 'style': style,
+ }
+ margbox = 'rect', {
+ 'x': str(pgEdge[left] + margin[left]),
+ 'y': str(pgEdge[top] + margin[top]),
+ 'width': str(size[width]),
+ 'height': str(size[height]),
+ 'style': style,
+ }
+
+ doc = ElementTree.ElementTree(ElementTree.Element(container,
+ {'xmlns:inkscape':"http://www.inkscape.org/namespaces/inkscape",
+ 'xmlns:xlink':"http://www.w3.org/1999/xlink",
+ 'width':str(pgSize[width]),
+ 'height':str(pgSize[height]),
+ }))
+
+ sub = ElementTree.SubElement
+
+ root = doc.getroot()
+
+ def makeClones(under, to):
+ for r in range(0,num[rows]):
+ for c in range(0,num[cols]):
+ if r == 0 and c == 0: continue
+ sub(under, 'use', {
+ 'xlink:href': '#' + to,
+ 'transform': 'translate(%f,%f)' %
+ (c*sep[width], r*sep[height])})
+
+ # guidelayer #####################################################
+ if set(['inner', 'outer']).intersection(show):
+ layer = sub(root, 'g', {'id':'guidelayer',
+ 'inkscape:groupmode':'layer'})
+ if 'inner' in show:
+ padbox[1]['id'] = 'innerguide'
+ padbox[1]['style'] = padbox[1]['style'].replace('stroke:#000000',
+ 'stroke:#8080ff')
+ sub(layer, *padbox)
+ del padbox[1]['id']
+ padbox[1]['style'] = padbox[1]['style'].replace('stroke:#8080ff',
+ 'stroke:#000000')
+ makeClones(layer, 'innerguide')
+ if 'outer' in show:
+ margbox[1]['id'] = 'outerguide'
+ margbox[1]['style'] = padbox[1]['style'].replace('stroke:#000000',
+ 'stroke:#8080ff')
+ sub(layer, *margbox)
+ del margbox[1]['id']
+ margbox[1]['style'] = padbox[1]['style'].replace('stroke:#8080ff',
+ 'stroke:#000000')
+ makeClones(layer, 'outerguide')
+
+ # crosslayer #####################################################
+ if set(['crosses']).intersection(show):
+ layer = sub(root, 'g', {'id':'cutlayer',
+ 'inkscape:groupmode':'layer'})
+
+ if 'crosses' in show:
+ crosslen = 12
+ group = sub(layer, 'g', id='cross')
+ x,y = 0,0
+ path = 'M%f %f' % (x+pgEdge[left] + margin[left],
+ y+pgEdge[top] + margin[top]-crosslen)
+ path += ' L%f %f' % (x+pgEdge[left] + margin[left],
+ y+pgEdge[top] + margin[top]+crosslen)
+ path += ' M%f %f' % (x+pgEdge[left] + margin[left]-crosslen,
+ y+pgEdge[top] + margin[top])
+ path += ' L%f %f' % (x+pgEdge[left] + margin[left]+crosslen,
+ y+pgEdge[top] + margin[top])
+ sub(group, 'path', style=style+'stroke-width:0.05',
+ d = path, id = 'crossmarker')
+ for r in 0, 1:
+ for c in 0, 1:
+ if r or c:
+ x,y = c*size[width], r*size[height]
+ sub(group, 'use', {
+ 'xlink:href': '#crossmarker',
+ 'transform': 'translate(%f,%f)' %
+ (x,y)})
+ makeClones(layer, 'cross')
+
+ # clonelayer #####################################################
+ layer = sub(root, 'g', {'id':'clonelayer', 'inkscape:groupmode':'layer'})
+ makeClones(layer, 'main')
+
+ # mainlayer ######################################################
+ layer = sub(root, 'g', {'id':'mainlayer', 'inkscape:groupmode':'layer'})
+ group = sub(layer, 'g', {'id':'main'})
+
+ if 'innerbox' in show:
+ sub(group, *padbox)
+ if 'outerbox' in show:
+ sub(group, *margbox)
+ if 'holder' in show:
+ x, y = (pgEdge[left] + margin[left] + padding[left],
+ pgEdge[top] + margin[top] + padding[top])
+ w, h = (size[width] - padding[left] - padding[right],
+ size[height] - padding[top] - padding[bottom])
+ path = 'M%f %f' % (x + w/2., y)
+ path += ' L%f %f' % (x + w, y + h/2.)
+ path += ' L%f %f' % (x + w/2., y + h)
+ path += ' L%f %f' % (x, y + h/2.)
+ path += ' Z'
+ sub(group, 'path', style=style, d = path)
+
+ if returnTree:
+ return doc
+ else:
+ return ElementTree.tostring(root)
+
e = Nup()
e.affect()
-
-
diff --git a/share/extensions/layout_nup_pageframe.py b/share/extensions/layout_nup_pageframe.py
deleted file mode 100755
index 471a75dd3..000000000
--- a/share/extensions/layout_nup_pageframe.py
+++ /dev/null
@@ -1,230 +0,0 @@
-#!/usr/bin/env python
-#@+leo-ver=4-thin
-#@+node:tbrown.20070622094435.1:@thin pageframe.py
-"""Create n-up SVG layouts"""
-
-#@+others
-#@+node:tbrown.20070622103716:imports
-import sys, inkex
-
-try:
- import xml.etree.ElementTree as ElementTree
-except:
- try:
- from lxml import etree as ElementTree
- except:
- try:
- from elementtree.ElementTree import ElementTree
- except:
- sys.stderr.write("""Requires ElementTree module, included
-in Python 2.5 or supplied by lxml or elementtree modules.
-
-""")
-#@-node:tbrown.20070622103716:imports
-#@+node:tbrown.20070622103716.1:expandTuple
-def expandTuple(unit, x, length = 4):
- try:
- iter(x)
- except:
- return None
-
- if len(x) != length: x = x*2
- if len(x) != length:
- raise Exception("expandTuple: requires 2 or 4 item tuple")
- try:
- return tuple(map(lambda ev: (self.unittouu(str(eval(str(ev)))+unit)), x))
- except:
- return None
-#@-node:tbrown.20070622103716.1:expandTuple
-#@+node:tbrown.20070622103716.2:GenerateNup
-def GenerateNup(unit="px",
- pgSize=("8.5*96","11*96"),
- pgMargin=(0,0),
- pgPadding=(0,0),
- num=(2,2),
- calculateSize=True,
- size=None,
- margin=(0,0),
- padding=(20,20),
- show=['default'],
- container='svg',
- returnTree = False,
- ):
- """Generate the SVG. Inputs are run through 'eval(str(x))' so you can use
-'8.5*72' instead of 612. Margin / padding dimension tuples can be
-(top & bottom, left & right) or (top, right, bottom, left).
-
-Keyword arguments:
-pgSize -- page size, width x height
-pgMargin -- extra space around each page
-pgPadding -- added to pgMargin
-n -- rows x cols
-size -- override calculated size, width x height
-margin -- white space around each piece
-padding -- inner padding for each piece
-show -- list of keywords indicating what to show
- - 'crosses' - cutting guides
- - 'inner' - inner boundary
- - 'outer' - outer boundary
-container -- 'svg' or 'g'
-returnTree -- whether to return the ElementTree or the string
-"""
-
- if 'default' in show:
- show = set(show).union(['inner', 'innerbox', 'holder', 'crosses'])
-
- pgMargin = expandTuple(unit, pgMargin)
- pgPadding = expandTuple(unit, pgPadding)
- margin = expandTuple(unit, margin)
- padding = expandTuple(unit, padding)
-
- pgSize = expandTuple(unit, pgSize, length = 2)
-# num = tuple(map(lambda ev: eval(str(ev)), num))
-
- pgEdge = map(sum,zip(pgMargin, pgPadding))
-
- top, right, bottom, left = 0,1,2,3
- width, height = 0,1
- rows, cols = 0,1
- size = expandTuple(unit, size, length = 2)
- if size == None or calculateSize == True or len(size) < 2 or size[0] == 0 or size[1] == 0:
- size = ((pgSize[width]
- - pgEdge[left] - pgEdge[right]
- - num[cols]*(margin[left] + margin[right])) / num[cols],
- (pgSize[height]
- - pgEdge[top] - pgEdge[bottom]
- - num[rows]*(margin[top] + margin[bottom])) / num[rows]
- )
- else:
- size = expandTuple(unit, size, length = 2)
-
- # sep is separation between same points on pieces
- sep = (size[width]+margin[right]+margin[left],
- size[height]+margin[top]+margin[bottom])
-
- style = 'stroke:#000000;stroke-opacity:1;fill:none;fill-opacity:1;'
-
- padbox = 'rect', {
- 'x': str(pgEdge[left] + margin[left] + padding[left]),
- 'y': str(pgEdge[top] + margin[top] + padding[top]),
- 'width': str(size[width] - padding[left] - padding[right]),
- 'height': str(size[height] - padding[top] - padding[bottom]),
- 'style': style,
- }
- margbox = 'rect', {
- 'x': str(pgEdge[left] + margin[left]),
- 'y': str(pgEdge[top] + margin[top]),
- 'width': str(size[width]),
- 'height': str(size[height]),
- 'style': style,
- }
-
- doc = ElementTree.ElementTree(ElementTree.Element(container,
- {'xmlns:inkscape':"http://www.inkscape.org/namespaces/inkscape",
- 'xmlns:xlink':"http://www.w3.org/1999/xlink",
- 'width':str(pgSize[width]),
- 'height':str(pgSize[height]),
- }))
-
- sub = ElementTree.SubElement
-
- root = doc.getroot()
-
- def makeClones(under, to):
- for r in range(0,num[rows]):
- for c in range(0,num[cols]):
- if r == 0 and c == 0: continue
- sub(under, 'use', {
- 'xlink:href': '#' + to,
- 'transform': 'translate(%f,%f)' %
- (c*sep[width], r*sep[height])})
-
- # guidelayer #####################################################
- if set(['inner', 'outer']).intersection(show):
- layer = sub(root, 'g', {'id':'guidelayer',
- 'inkscape:groupmode':'layer'})
- if 'inner' in show:
- padbox[1]['id'] = 'innerguide'
- padbox[1]['style'] = padbox[1]['style'].replace('stroke:#000000',
- 'stroke:#8080ff')
- sub(layer, *padbox)
- del padbox[1]['id']
- padbox[1]['style'] = padbox[1]['style'].replace('stroke:#8080ff',
- 'stroke:#000000')
- makeClones(layer, 'innerguide')
- if 'outer' in show:
- margbox[1]['id'] = 'outerguide'
- margbox[1]['style'] = padbox[1]['style'].replace('stroke:#000000',
- 'stroke:#8080ff')
- sub(layer, *margbox)
- del margbox[1]['id']
- margbox[1]['style'] = padbox[1]['style'].replace('stroke:#8080ff',
- 'stroke:#000000')
- makeClones(layer, 'outerguide')
-
- # crosslayer #####################################################
- if set(['crosses']).intersection(show):
- layer = sub(root, 'g', {'id':'cutlayer',
- 'inkscape:groupmode':'layer'})
-
- if 'crosses' in show:
- crosslen = 12
- group = sub(layer, 'g', id='cross')
- x,y = 0,0
- path = 'M%f %f' % (x+pgEdge[left] + margin[left],
- y+pgEdge[top] + margin[top]-crosslen)
- path += ' L%f %f' % (x+pgEdge[left] + margin[left],
- y+pgEdge[top] + margin[top]+crosslen)
- path += ' M%f %f' % (x+pgEdge[left] + margin[left]-crosslen,
- y+pgEdge[top] + margin[top])
- path += ' L%f %f' % (x+pgEdge[left] + margin[left]+crosslen,
- y+pgEdge[top] + margin[top])
- sub(group, 'path', style=style+'stroke-width:0.05',
- d = path, id = 'crossmarker')
- for r in 0, 1:
- for c in 0, 1:
- if r or c:
- x,y = c*size[width], r*size[height]
- sub(group, 'use', {
- 'xlink:href': '#crossmarker',
- 'transform': 'translate(%f,%f)' %
- (x,y)})
- makeClones(layer, 'cross')
-
- # clonelayer #####################################################
- layer = sub(root, 'g', {'id':'clonelayer', 'inkscape:groupmode':'layer'})
- makeClones(layer, 'main')
-
- # mainlayer ######################################################
- layer = sub(root, 'g', {'id':'mainlayer', 'inkscape:groupmode':'layer'})
- group = sub(layer, 'g', {'id':'main'})
-
- if 'innerbox' in show:
- sub(group, *padbox)
- if 'outerbox' in show:
- sub(group, *margbox)
- if 'holder' in show:
- x, y = (pgEdge[left] + margin[left] + padding[left],
- pgEdge[top] + margin[top] + padding[top])
- w, h = (size[width] - padding[left] - padding[right],
- size[height] - padding[top] - padding[bottom])
- path = 'M%f %f' % (x + w/2., y)
- path += ' L%f %f' % (x + w, y + h/2.)
- path += ' L%f %f' % (x + w/2., y + h)
- path += ' L%f %f' % (x, y + h/2.)
- path += ' Z'
- sub(group, 'path', style=style, d = path)
-
- if returnTree:
- return doc
- else:
- return ElementTree.tostring(root)
-
-if __name__ == '__main__':
- print GenerateNup(num=(10,3), margin=(5,5), show=['default', 'outer'])
-#@-node:tbrown.20070622103716.2:GenerateNup
-#@-others
-#@-node:tbrown.20070622094435.1:@thin pageframe.py
-#@-leo
-
-
diff --git a/share/extensions/measure.py b/share/extensions/measure.py
index cdccb6bb8..e7c91feec 100755
--- a/share/extensions/measure.py
+++ b/share/extensions/measure.py
@@ -188,13 +188,13 @@ class Length(inkex.Effect):
factor = self.unittouu(doc.get('height'))/float(viewh)
factor /= self.unittouu('1px')
self.options.fontsize /= factor
+ factor *= scale/self.unittouu('1'+self.options.unit)
# loop over all selected paths
for id, node in self.selected.iteritems():
if node.tag == inkex.addNS('path','svg'):
mat = simpletransform.composeParents(node, [[1.0, 0.0, 0.0], [0.0, 1.0, 0.0]])
p = cubicsuperpath.parsePath(node.get('d'))
simpletransform.applyTransformToPath(mat, p)
- factor *= scale/self.unittouu('1'+self.options.unit)
if self.options.type == "length":
slengths, stotal = csplength(p)
self.group = inkex.etree.SubElement(node.getparent(),inkex.addNS('text','svg'))
diff --git a/share/extensions/plotter.inx b/share/extensions/plotter.inx
index 5a6d8ce06..17b2ff185 100644
--- a/share/extensions/plotter.inx
+++ b/share/extensions/plotter.inx
@@ -27,7 +27,25 @@
<item value="57600">57600</item>
<item value="115200">115200</item>
</param>
- <param name="flowControl" type="enum" _gui-text="Flow control:" _gui-description="The Software / Hardware flow control of your serial connection (Default: Software)">
+ <param name="serialByteSize" type="enum" _gui-text="Serial byte size:" _gui-description="The Byte size of your serial connection, 99% of all plotters use the default setting (Default: 8 Bits)">
+ <item value="eight">8 Bits</item>
+ <item value="seven">7 Bits</item>
+ <item value="six">6 Bits</item>
+ <item value="five">5 Bits</item>
+ </param>
+ <param name="serialStopBits" type="enum" _gui-text="Serial stop bits:" _gui-description="The Stop bits of your serial connection, 99% of all plotters use the default setting (Default: 1 Bit)">
+ <item value="one">1 Bit</item>
+ <item value="onePointFive">1.5 Bits</item>
+ <item value="two">2 Bits</item>
+ </param>
+ <param name="serialParity" type="enum" _gui-text="Serial parity:" _gui-description="The Parity of your serial connection, 99% of all plotters use the default setting (Default: None)">
+ <item value="none">None</item>
+ <item value="even">Even</item>
+ <item value="odd">Odd</item>
+ <item value="mark">Mark</item>
+ <item value="space">Space</item>
+ </param>
+ <param name="serialFlowControl" type="enum" _gui-text="Serial flow control:" _gui-description="The Software / Hardware flow control of your serial connection (Default: Software)">
<_item value="xonxoff">Software (XON/XOFF)</_item>
<_item value="rtscts">Hardware (RTS/CTS)</_item>
<_item value="dsrdtrrtscts">Hardware (DSR/DTR + RTS/CTS)</_item>
@@ -47,9 +65,9 @@
<page name="plotter" _gui-text="Plotter Settings ">
<param name="resolutionX" type="float" min="1.0" max="4096.0" precision="1" _gui-text="Resolution X (dpi):" _gui-description="The amount of steps the plotter moves if it moves for 1 inch on the X axis (Default: 1016.0)">1016.0</param>
<param name="resolutionY" type="float" min="1.0" max="4096.0" precision="1" _gui-text="Resolution Y (dpi):" _gui-description="The amount of steps the plotter moves if it moves for 1 inch on the Y axis (Default: 1016.0)">1016.0</param>
- <param name="pen" type="int" min="0" max="99" _gui-text="Pen number:" _gui-description="The number of the pen (tool) to use (Standard: '1')">1</param>
- <param name="force" type="int" min="0" max="1000" _gui-text="Pen force (g):" _gui-description="The amount of force pushing down the pen in grams, set to 0 to omit command; most plotters ignore this command (Default: 0)">0</param>
- <param name="speed" type="int" min="0" max="10000" _gui-text="Pen speed (cm/s or mm/s):" _gui-description="The speed the pen will move with in centimeters or millimeters per second (depending on your plotter model), set to 0 to omit command. Most plotters ignore this command. (Default: 0)">0</param>
+ <param name="pen" type="int" min="0" max="99" _gui-text="Pen number:" _gui-description="The number of the pen (tool) to use (Standard: '1')">1</param>
+ <param name="force" type="int" min="0" max="1000" _gui-text="Pen force (g):" _gui-description="The amount of force pushing down the pen in grams, set to 0 to omit command; most plotters ignore this command (Default: 0)">0</param>
+ <param name="speed" type="int" min="0" max="10000" _gui-text="Pen speed (cm/s or mm/s):" _gui-description="The speed the pen will move with in centimeters or millimeters per second (depending on your plotter model), set to 0 to omit command. Most plotters ignore this command. (Default: 0)">0</param>
<param name="orientation" type="enum" _gui-text="Rotation (°, clockwise):" _gui-description="Rotation of the drawing (Default: 0°)">
<item value="0">0</item>
<item value="90">90</item>
@@ -58,16 +76,18 @@
</param>
<param name="mirrorX" type="boolean" _gui-text="Mirror X axis" _gui-description="Check this to mirror the X axis (Default: Unchecked)">false</param>
<param name="mirrorY" type="boolean" _gui-text="Mirror Y axis" _gui-description="Check this to mirror the Y axis (Default: Unchecked)">false</param>
- <param name="center" type="boolean" _gui-text="Center zero point" _gui-description="Check this if your plotter uses a centered zero point (Default: Unchecked)">false</param>
+ <param name="center" type="boolean" _gui-text="Center zero point" _gui-description="Check this if your plotter uses a centered zero point (Default: Unchecked)">false</param>
+ <param name="space" type="description">&#xa0;</param>
+ <_param name="multiplePensHelp" type="description">If you want to use multiple pens on your pen plotter create one layer for each pen, name the layers "Pen 1", "Pen 2", etc., and put your drawings in the corresponding layers. This overrules the pen number option above.</_param>
</page>
<page name="misc" _gui-text="Plot Features ">
- <param name="overcut" type="float" min="0.0" max="100.0" precision="2" _gui-text="Overcut (mm):" _gui-description="The distance in mm that will be cut over the starting point of the path to prevent open paths, set to 0.0 to omit command (Default: 1.00)">1.00</param>
- <param name="toolOffset" type="float" min="0.0" max="20.0" precision="2" _gui-text="Tool offset (mm):" _gui-description="The offset from the tool tip to the tool axis in mm, set to 0.0 to omit command (Default: 0.25)">0.25</param>
- <param name="precut" type="boolean" _gui-text="Use precut" _gui-description="Check this to cut a small line before the real drawing starts to correctly align the tool orientation. (Default: Checked)">true</param>
- <param name="flat" type="float" min="0.1" max="10.0" precision="1" _gui-text="Curve flatness:" _gui-description="Curves are divided into lines, this number controls how fine the curves will be reproduced, the smaller the finer (Default: '1.2')">1.2</param>
- <param name="autoAlign" type="boolean" _gui-text="Auto align" _gui-description="Check this to auto align the drawing to the zero point (Plus the tool offset if used). If unchecked you have to make sure that all parts of your drawing are within the document border! (Default: Checked)">true</param>
- <param name="space" type="description">&#xa0;</param>
- <param name="debug" type="boolean" _gui-text="Show debug information" _gui-description="Check this to get verbose information about the plot without actually sending something to the plotter (A.k.a. data dump) (Default: Unchecked)">false</param>
+ <param name="overcut" type="float" min="0.0" max="100.0" precision="2" _gui-text="Overcut (mm):" _gui-description="The distance in mm that will be cut over the starting point of the path to prevent open paths, set to 0.0 to omit command (Default: 1.00)">1.00</param>
+ <param name="toolOffset" type="float" min="0.0" max="20.0" precision="2" _gui-text="Tool offset (mm):" _gui-description="The offset from the tool tip to the tool axis in mm, set to 0.0 to omit command (Default: 0.25)">0.25</param>
+ <param name="precut" type="boolean" _gui-text="Use precut" _gui-description="Check this to cut a small line before the real drawing starts to correctly align the tool orientation. (Default: Checked)">true</param>
+ <param name="flat" type="float" min="0.1" max="10.0" precision="1" _gui-text="Curve flatness:" _gui-description="Curves are divided into lines, this number controls how fine the curves will be reproduced, the smaller the finer (Default: '1.2')">1.2</param>
+ <param name="autoAlign" type="boolean" _gui-text="Auto align" _gui-description="Check this to auto align the drawing to the zero point (Plus the tool offset if used). If unchecked you have to make sure that all parts of your drawing are within the document border! (Default: Checked)">true</param>
+ <param name="space" type="description">&#xa0;</param>
+ <param name="debug" type="boolean" _gui-text="Show debug information" _gui-description="Check this to get verbose information about the plot without actually sending something to the plotter (A.k.a. data dump) (Default: Unchecked)">false</param>
</page>
</param>
<_param name="settingsHelp" type="description">All these settings depend on the plotter you use, for more information please consult the manual or homepage for your plotter.</_param>
diff --git a/share/extensions/plotter.py b/share/extensions/plotter.py
index 7e24d0824..c0f180f60 100644
--- a/share/extensions/plotter.py
+++ b/share/extensions/plotter.py
@@ -34,27 +34,30 @@ class Plot(inkex.Effect):
def __init__(self):
inkex.Effect.__init__(self)
- self.OptionParser.add_option('--tab', action='store', type='string', dest='tab')
- self.OptionParser.add_option('--serialPort', action='store', type='string', dest='serialPort', default='COM1', help='Serial port')
- self.OptionParser.add_option('--serialBaudRate', action='store', type='string', dest='serialBaudRate', default='9600', help='Serial Baud rate')
- self.OptionParser.add_option('--flowControl', action='store', type='string', dest='flowControl', default='0', help='Flow control')
- self.OptionParser.add_option('--commandLanguage', action='store', type='string', dest='commandLanguage', default='hpgl', help='Command Language')
- self.OptionParser.add_option('--initCommands', action='store', type='string', dest='initCommands', default='', help='Initialization commands')
- self.OptionParser.add_option('--resolutionX', action='store', type='float', dest='resolutionX', default=1016.0, help='Resolution X (dpi)')
- self.OptionParser.add_option('--resolutionY', action='store', type='float', dest='resolutionY', default=1016.0, help='Resolution Y (dpi)')
- self.OptionParser.add_option('--pen', action='store', type='int', dest='pen', default=1, help='Pen number')
- self.OptionParser.add_option('--force', action='store', type='int', dest='force', default=24, help='Pen force (g)')
- self.OptionParser.add_option('--speed', action='store', type='int', dest='speed', default=20, help='Pen speed (cm/s)')
- self.OptionParser.add_option('--orientation', action='store', type='string', dest='orientation', default='90', help='Rotation (Clockwise)')
- self.OptionParser.add_option('--mirrorX', action='store', type='inkbool', dest='mirrorX', default='FALSE', help='Mirror X axis')
- self.OptionParser.add_option('--mirrorY', action='store', type='inkbool', dest='mirrorY', default='FALSE', help='Mirror Y axis')
- self.OptionParser.add_option('--center', action='store', type='inkbool', dest='center', default='FALSE', help='Center zero point')
- self.OptionParser.add_option('--overcut', action='store', type='float', dest='overcut', default=1.0, help='Overcut (mm)')
- self.OptionParser.add_option('--toolOffset', action='store', type='float', dest='toolOffset', default=0.25, help='Tool offset (mm)')
- self.OptionParser.add_option('--precut', action='store', type='inkbool', dest='precut', default='TRUE', help='Use precut')
- self.OptionParser.add_option('--flat', action='store', type='float', dest='flat', default=1.2, help='Curve flatness')
- self.OptionParser.add_option('--autoAlign', action='store', type='inkbool', dest='autoAlign', default='TRUE', help='Auto align')
- self.OptionParser.add_option('--debug', action='store', type='inkbool', dest='debug', default='FALSE', help='Show debug information')
+ self.OptionParser.add_option('--tab', action='store', type='string', dest='tab')
+ self.OptionParser.add_option('--serialPort', action='store', type='string', dest='serialPort', default='COM1', help='Serial port')
+ self.OptionParser.add_option('--serialBaudRate', action='store', type='string', dest='serialBaudRate', default='9600', help='Serial Baud rate')
+ self.OptionParser.add_option('--serialByteSize', action='store', type='string', dest='serialByteSize', default='eight', help='Serial byte size')
+ self.OptionParser.add_option('--serialStopBits', action='store', type='string', dest='serialStopBits', default='one', help='Serial stop bits')
+ self.OptionParser.add_option('--serialParity', action='store', type='string', dest='serialParity', default='none', help='Serial parity')
+ self.OptionParser.add_option('--serialFlowControl', action='store', type='string', dest='serialFlowControl', default='0', help='Flow control')
+ self.OptionParser.add_option('--commandLanguage', action='store', type='string', dest='commandLanguage', default='hpgl', help='Command Language')
+ self.OptionParser.add_option('--initCommands', action='store', type='string', dest='initCommands', default='', help='Initialization commands')
+ self.OptionParser.add_option('--resolutionX', action='store', type='float', dest='resolutionX', default=1016.0, help='Resolution X (dpi)')
+ self.OptionParser.add_option('--resolutionY', action='store', type='float', dest='resolutionY', default=1016.0, help='Resolution Y (dpi)')
+ self.OptionParser.add_option('--pen', action='store', type='int', dest='pen', default=1, help='Pen number')
+ self.OptionParser.add_option('--force', action='store', type='int', dest='force', default=24, help='Pen force (g)')
+ self.OptionParser.add_option('--speed', action='store', type='int', dest='speed', default=20, help='Pen speed (cm/s)')
+ self.OptionParser.add_option('--orientation', action='store', type='string', dest='orientation', default='90', help='Rotation (Clockwise)')
+ self.OptionParser.add_option('--mirrorX', action='store', type='inkbool', dest='mirrorX', default='FALSE', help='Mirror X axis')
+ self.OptionParser.add_option('--mirrorY', action='store', type='inkbool', dest='mirrorY', default='FALSE', help='Mirror Y axis')
+ self.OptionParser.add_option('--center', action='store', type='inkbool', dest='center', default='FALSE', help='Center zero point')
+ self.OptionParser.add_option('--overcut', action='store', type='float', dest='overcut', default=1.0, help='Overcut (mm)')
+ self.OptionParser.add_option('--toolOffset', action='store', type='float', dest='toolOffset', default=0.25, help='Tool offset (mm)')
+ self.OptionParser.add_option('--precut', action='store', type='inkbool', dest='precut', default='TRUE', help='Use precut')
+ self.OptionParser.add_option('--flat', action='store', type='float', dest='flat', default=1.2, help='Curve flatness')
+ self.OptionParser.add_option('--autoAlign', action='store', type='inkbool', dest='autoAlign', default='TRUE', help='Auto align')
+ self.OptionParser.add_option('--debug', action='store', type='inkbool', dest='debug', default='FALSE', help='Show debug information')
def effect(self):
# get hpgl data
@@ -98,12 +101,12 @@ class Plot(inkex.Effect):
def convertToHpgl(self):
# convert raw HPGL to HPGL
- hpglInit = 'IN;SP%d' % self.options.pen
+ hpglInit = 'IN'
if self.options.force > 0:
hpglInit += ';FS%d' % self.options.force
if self.options.speed > 0:
hpglInit += ';VS%d' % self.options.speed
- self.hpgl = hpglInit + self.hpgl + ';PU0,0;SP0;IN; '
+ self.hpgl = hpglInit + self.hpgl + ';SP0;PU0,0;IN; '
def convertToDmpl(self):
# convert HPGL to DMPL
@@ -119,22 +122,23 @@ class Plot(inkex.Effect):
# Z = Reset plotter
# n,n, = Coordinate pair
self.hpgl = self.hpgl.replace(';', ',')
+ self.hpgl = self.hpgl.replace('SP', 'P')
self.hpgl = self.hpgl.replace('PU', 'U')
self.hpgl = self.hpgl.replace('PD', 'D')
- dmplInit = ';:HAL0P%d' % self.options.pen
+ dmplInit = ';:HAL0'
if self.options.speed > 0:
dmplInit += 'V%d' % self.options.speed
dmplInit += 'EC1'
- self.hpgl = dmplInit + self.hpgl[1:] + ',U0,0,P0Z '
+ self.hpgl = dmplInit + self.hpgl[1:] + ',P0,U0,0,Z '
def convertToKNK(self):
# convert HPGL to KNK Plotter Language
- hpglInit = 'ZG;SP%d' % self.options.pen
+ hpglInit = 'ZG'
if self.options.force > 0:
hpglInit += ';FS%d' % self.options.force
if self.options.speed > 0:
hpglInit += ';VS%d' % self.options.speed
- self.hpgl = hpglInit + self.hpgl + ';PU0,0;SP0;@ '
+ self.hpgl = hpglInit + self.hpgl + ';SP0;PU0,0;@ '
def sendHpglToSerial(self):
# gracefully exit script when pySerial is missing
@@ -146,17 +150,49 @@ class Plot(inkex.Effect):
+ "\n2. Extract the \"serial\" subfolder from the zip to the following folder: C:\\[Program files]\\inkscape\\python\\Lib\\"
+ "\n3. Restart Inkscape."))
return
- # send data to plotter
+ # init serial framework
mySerial = serial.Serial()
+ # set serial port
mySerial.port = self.options.serialPort
+ # set baudrate
mySerial.baudrate = self.options.serialBaudRate
+ # set bytesize
+ if self.options.serialByteSize == 'five':
+ mySerial.bytesize = serial.FIVEBITS
+ if self.options.serialByteSize == 'six':
+ mySerial.bytesize = serial.SIXBITS
+ if self.options.serialByteSize == 'seven':
+ mySerial.bytesize = serial.SEVENBITS
+ if self.options.serialByteSize == 'eight':
+ mySerial.bytesize = serial.EIGHTBITS
+ # set stopbits
+ if self.options.serialStopBits == 'one':
+ mySerial.stopbits = serial.STOPBITS_ONE
+ if self.options.serialStopBits == 'onePointFive':
+ mySerial.stopbits = serial.STOPBITS_ONE_POINT_FIVE
+ if self.options.serialStopBits == 'two':
+ mySerial.stopbits = serial.STOPBITS_TWO
+ # set parity
+ if self.options.serialParity == 'none':
+ mySerial.parity = serial.PARITY_NONE
+ if self.options.serialParity == 'even':
+ mySerial.parity = serial.PARITY_EVEN
+ if self.options.serialParity == 'odd':
+ mySerial.parity = serial.PARITY_ODD
+ if self.options.serialParity == 'mark':
+ mySerial.parity = serial.PARITY_MARK
+ if self.options.serialParity == 'space':
+ mySerial.parity = serial.PARITY_SPACE
+ # set short timeout to avoid locked up interface
mySerial.timeout = 0.1
- if self.options.flowControl == 'xonxoff':
+ # set flow control
+ if self.options.serialFlowControl == 'xonxoff':
mySerial.xonxoff = True
- if self.options.flowControl == 'rtscts' or self.options.flowControl == 'dsrdtrrtscts':
+ if self.options.serialFlowControl == 'rtscts' or self.options.serialFlowControl == 'dsrdtrrtscts':
mySerial.rtscts = True
- if self.options.flowControl == 'dsrdtrrtscts':
+ if self.options.serialFlowControl == 'dsrdtrrtscts':
mySerial.dsrdtr = True
+ # try to establish connection
try:
mySerial.open()
except Exception as inst:
@@ -166,6 +202,7 @@ class Plot(inkex.Effect):
else:
type, value, traceback = sys.exc_info()
raise ValueError, ('', type, value), traceback
+ # send data to plotter
if self.options.initCommands != '':
mySerial.write(self.options.initCommands.decode('string_escape'))
mySerial.write(self.hpgl)
@@ -177,7 +214,10 @@ class Plot(inkex.Effect):
inkex.errormsg("---------------------------------\nDebug information\n---------------------------------\n\nSettings:\n")
inkex.errormsg(' Serial Port: ' + self.options.serialPort)
inkex.errormsg(' Serial baud rate: ' + self.options.serialBaudRate)
- inkex.errormsg(' Flow control: ' + self.options.flowControl)
+ inkex.errormsg(' Serial byte size: ' + self.options.serialByteSize + ' Bits')
+ inkex.errormsg(' Serial stop bits: ' + self.options.serialStopBits + ' Bits')
+ inkex.errormsg(' Serial parity: ' + self.options.serialParity)
+ inkex.errormsg(' Serial Flow control: ' + self.options.serialFlowControl)
inkex.errormsg(' Command language: ' + self.options.commandLanguage)
inkex.errormsg(' Initialization commands: ' + self.options.initCommands)
inkex.errormsg(' Resolution X (dpi): ' + str(self.options.resolutionX))
@@ -223,7 +263,7 @@ class Plot(inkex.Effect):
inkex.errormsg(' Flatness: ' + str(debugObject.flat) + ' plotter steps')
inkex.errormsg(' Tool offset flatness: ' + str(debugObject.toolOffsetFlat) + ' plotter steps')
inkex.errormsg("\n" + self.options.commandLanguage + " data:\n")
- inkex.errormsg(self.hpgl)
+ inkex.errormsg(self.options.initCommands + self.hpgl)
if __name__ == '__main__':
# start extension
diff --git a/share/extensions/scour.inx b/share/extensions/scour.inx
index 45719deeb..c97eec502 100644
--- a/share/extensions/scour.inx
+++ b/share/extensions/scour.inx
@@ -2,9 +2,9 @@
<inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension">
<_name>Optimized SVG Output</_name>
<id>org.inkscape.output.scour</id>
- <dependency type="executable" location="extensions">scour.py</dependency>
- <dependency type="executable" location="extensions">svg_regex.py</dependency>
- <dependency type="executable" location="extensions">yocto_css.py</dependency>
+ <dependency type="executable" location="extensions">scour/scour.py</dependency>
+ <dependency type="executable" location="extensions">scour/svg_regex.py</dependency>
+ <dependency type="executable" location="extensions">scour/yocto_css.py</dependency>
<param name="tab" type="notebook">
<page name="Options" _gui-text="Options">
<param name="simplify-colors" type="boolean" _gui-text="Shorten color values">true</param>
@@ -63,6 +63,6 @@
<_filetypetooltip>Scalable Vector Graphics</_filetypetooltip>
</output>
<script>
- <command reldir="extensions" interpreter="python">scour.inkscape.py</command>
+ <command reldir="extensions" interpreter="python">scour/scour.inkscape.py</command>
</script>
</inkscape-extension>
diff --git a/share/extensions/scour/Makefile.am b/share/extensions/scour/Makefile.am
new file mode 100644
index 000000000..8a6f42544
--- /dev/null
+++ b/share/extensions/scour/Makefile.am
@@ -0,0 +1,13 @@
+
+scourdir = $(datadir)/inkscape/extensions/scour
+
+scour_DATA = \
+ scour.py \
+ scour.inkscape.py \
+ svg_regex.py \
+ svg_transform.py \
+ yocto_css.py
+
+EXTRA_DIST = \
+ $(scour_DATA)
+
diff --git a/share/extensions/scour.inkscape.py b/share/extensions/scour/scour.inkscape.py
index f161a09c2..f161a09c2 100755..100644
--- a/share/extensions/scour.inkscape.py
+++ b/share/extensions/scour/scour.inkscape.py
diff --git a/share/extensions/scour.py b/share/extensions/scour/scour.py
index 236529daa..236529daa 100644
--- a/share/extensions/scour.py
+++ b/share/extensions/scour/scour.py
diff --git a/share/extensions/svg_regex.py b/share/extensions/scour/svg_regex.py
index 6321bff0e..6321bff0e 100755..100644
--- a/share/extensions/svg_regex.py
+++ b/share/extensions/scour/svg_regex.py
diff --git a/share/extensions/svg_transform.py b/share/extensions/scour/svg_transform.py
index 860c1df5d..860c1df5d 100755..100644
--- a/share/extensions/svg_transform.py
+++ b/share/extensions/scour/svg_transform.py
diff --git a/share/extensions/yocto_css.py b/share/extensions/scour/yocto_css.py
index c6bd0c37e..c6bd0c37e 100755..100644
--- a/share/extensions/yocto_css.py
+++ b/share/extensions/scour/yocto_css.py
diff --git a/share/extensions/svg2xaml.xsl b/share/extensions/svg2xaml.xsl
index d2796c93c..c384b022f 100755
--- a/share/extensions/svg2xaml.xsl
+++ b/share/extensions/svg2xaml.xsl
@@ -1266,25 +1266,28 @@ exclude-result-prefixes="rdf xlink xs exsl libxslt inkscape">
-->
<xsl:template mode="fill_rule" match="*">
<xsl:choose>
- <xsl:when test="@fill-rule and (@fill-rule = 'nonzero' or @fill-rule = 'evenodd')">
- <xsl:attribute name="FillRule">
- <xsl:value-of select="normalize-space(@fill-rule)" />
- </xsl:attribute>
+ <xsl:when test="@fill-rule and (@fill-rule = 'nonzero')">
+ <xsl:attribute name="FillRule">NonZero</xsl:attribute>
+ </xsl:when>
+ <xsl:when test="@fill-rule and (@fill-rule = 'evenodd')">
+ <xsl:attribute name="FillRule">EvenOdd</xsl:attribute>
</xsl:when>
<xsl:when test="@style and contains(@style, 'fill-rule:')">
<xsl:variable name="FillRule" select="normalize-space(substring-after(@style, 'fill-rule:'))" />
<xsl:choose>
<xsl:when test="contains($FillRule, ';')">
- <xsl:if test="substring-before($FillRule, ';') = 'nonzero' or substring-before($FillRule, ';') = 'evenodd'">
- <xsl:attribute name="FillRule">
- <xsl:value-of select="substring-before($FillRule, ';')" />
- </xsl:attribute>
+ <xsl:if test="substring-before($FillRule, ';') = 'nonzero'">
+ <xsl:attribute name="FillRule">NonZero</xsl:attribute>
+ </xsl:if>
+ <xsl:if test="substring-before($FillRule, ';') = 'evenodd'">
+ <xsl:attribute name="FillRule">EvenOdd</xsl:attribute>
</xsl:if>
</xsl:when>
- <xsl:when test="$FillRule = 'nonzero' or $FillRule = 'evenodd'">
- <xsl:attribute name="FillRule">
- <xsl:value-of select="$FillRule" />
- </xsl:attribute>
+ <xsl:when test="$FillRule = 'nonzero'">
+ <xsl:attribute name="FillRule">NonZero</xsl:attribute>
+ </xsl:when>
+ <xsl:when test="$FillRule = 'evenodd'">
+ <xsl:attribute name="FillRule">EvenOdd</xsl:attribute>
</xsl:when>
</xsl:choose>
</xsl:when>
diff --git a/share/extensions/synfig_prepare.py b/share/extensions/synfig_prepare.py
index c6ad48c97..ebc50fd8e 100755
--- a/share/extensions/synfig_prepare.py
+++ b/share/extensions/synfig_prepare.py
@@ -86,7 +86,7 @@ class InkscapeActionGroup(object):
def select_id(self, object_id):
"""Select object with given id"""
- self.command += "--select='%s' " % (object_id)
+ self.command += "--select=%s " % (object_id)
if not self.has_selection:
self.has_selection = True
diff --git a/share/extensions/webslicer_export.py b/share/extensions/webslicer_export.py
index c9ea761a7..a8a3c67ba 100755
--- a/share/extensions/webslicer_export.py
+++ b/share/extensions/webslicer_export.py
@@ -72,7 +72,13 @@ class WebSlicer_Export(WebSlicer_Effect):
else:
inkex.errormsg(_('The directory "%s" does not exists.') % self.options.dir)
return
- self.unique_html_id( self.get_slicer_layer() )
+ # Check whether slicer layer exists (bug #1198826)
+ slicer_layer = self.get_slicer_layer()
+ if slicer_layer is None:
+ inkex.errormsg(_('No slicer layer found.'))
+ return {'error':'No slicer layer found.'}
+ else:
+ self.unique_html_id( slicer_layer )
return None