From 0d0d4e45ca1ad1da2f70f3a7ad54e974c9c9b79c Mon Sep 17 00:00:00 2001 From: Alvin Penner Date: Thu, 20 Aug 2015 08:32:37 -0400 Subject: extensions. dxf input. Implement extrude option, and allow blocks to be reflected. (Bug 1483807 and Bug 1409486) Fixed bugs: - https://launchpad.net/bugs/1483807 (bzr r14312) --- share/extensions/dxf_input.py | 36 ++++++++++++++++++++++++++---------- 1 file changed, 26 insertions(+), 10 deletions(-) (limited to 'share/extensions') diff --git a/share/extensions/dxf_input.py b/share/extensions/dxf_input.py index f0a1296f1..362f35be9 100755 --- a/share/extensions/dxf_input.py +++ b/share/extensions/dxf_input.py @@ -75,7 +75,7 @@ def export_POINT(): def export_LINE(): # mandatory group codes : (10, 11, 20, 21) (x1, x2, y1, y2) if vals[groups['10']] and vals[groups['11']] and vals[groups['20']] and vals[groups['21']]: - path = 'M %f,%f %f,%f' % (vals[groups['10']][0], vals[groups['20']][0], scale*(vals[groups['11']][0] - xmin), height - scale*(vals[groups['21']][0] - ymin)) + path = 'M %f,%f %f,%f' % (vals[groups['10']][0], vals[groups['20']][0], scale*(extrude*vals[groups['11']][0] - xmin), height - scale*(vals[groups['21']][0] - ymin)) attribs = {'d': path, 'style': style} inkex.etree.SubElement(layer, 'path', attribs) @@ -230,7 +230,7 @@ def export_HATCH(): i40 += 1 i72 += 1 elif vals[groups['72']][i72] == 1: # line - path += 'L %f,%f ' % (scale*(vals[groups['11']][i11] - xmin), height - scale*(vals[groups['21']][i11] - ymin)) + path += 'L %f,%f ' % (scale*(extrude*vals[groups['11']][i11] - xmin), height - scale*(vals[groups['21']][i11] - ymin)) i11 += 1 i72 += 1 i10 += 1 @@ -259,7 +259,7 @@ def export_DIMENSION(): return attribs = {'d': path, 'style': style + '; marker-start: url(#DistanceX); marker-end: url(#DistanceX); stroke-width: 0.25px'} inkex.etree.SubElement(layer, 'path', attribs) - x = scale*(vals[groups['11']][0] - xmin) + x = scale*(extrude*vals[groups['11']][0] - xmin) y = height - scale*(vals[groups['21']][0] - ymin) size = 12 # default fontsize in px if vals[groups['3']]: @@ -279,7 +279,11 @@ def export_INSERT(): if vals[groups['2']] and vals[groups['10']] and vals[groups['20']]: x = vals[groups['10']][0] + scale*xmin y = vals[groups['20']][0] - scale*ymin - height - attribs = {'x': '%f' % x, 'y': '%f' % y, inkex.addNS('href','xlink'): '#' + quote(vals[groups['2']][0].replace(" ", "_").encode("utf-8"))} + attribs = {inkex.addNS('href','xlink'): '#' + quote(vals[groups['2']][0].replace(" ", "_").encode("utf-8"))} + tform = 'translate(%f, %f)' % (x, y) + if vals[groups['41']] and vals[groups['42']]: + tform += ' scale(%f, %f)' % (vals[groups['41']][0], vals[groups['42']][0]) + attribs.update({'transform': tform}) inkex.etree.SubElement(layer, 'use', attribs) def export_BLOCK(): @@ -338,7 +342,7 @@ def get_group(group): # define DXF Entities and specify which Group Codes to monitor entities = {'MTEXT': export_MTEXT, 'TEXT': export_MTEXT, 'POINT': export_POINT, 'LINE': export_LINE, 'SPLINE': export_SPLINE, 'CIRCLE': export_CIRCLE, 'ARC': export_ARC, 'ELLIPSE': export_ELLIPSE, 'LEADER': export_LEADER, 'LWPOLYLINE': export_LWPOLYLINE, 'HATCH': export_HATCH, 'DIMENSION': export_DIMENSION, 'INSERT': export_INSERT, 'BLOCK': export_BLOCK, 'ENDBLK': export_ENDBLK, 'ATTDEF': export_ATTDEF, 'VIEWPORT': False, 'ENDSEC': False} -groups = {'1': 0, '2': 1, '3': 2, '6': 3, '8': 4, '10': 5, '11': 6, '13': 7, '14': 8, '20': 9, '21': 10, '23': 11, '24': 12, '40': 13, '41': 14, '42': 15, '50': 16, '51': 17, '62': 18, '70': 19, '72': 20, '73': 21, '92': 22, '93': 23, '370': 24} +groups = {'1': 0, '2': 1, '3': 2, '6': 3, '8': 4, '10': 5, '11': 6, '13': 7, '14': 8, '20': 9, '21': 10, '23': 11, '24': 12, '40': 13, '41': 14, '42': 15, '50': 16, '51': 17, '62': 18, '70': 19, '72': 20, '73': 21, '92': 22, '93': 23, '230': 24, '370': 25} colors = { 1: '#FF0000', 2: '#FFFF00', 3: '#00FF00', 4: '#00FFFF', 5: '#0000FF', 6: '#FF00FF', 8: '#414141', 9: '#808080', 12: '#BD0000', 30: '#FF7F00', 250: '#333333', 251: '#505050', 252: '#696969', 253: '#828282', 254: '#BEBEBE', 255: '#FFFFFF'} @@ -468,10 +472,6 @@ while line[0] and (line[1] != 'ENDSEC' or not inENTITIES): val = val.decode('unicode_escape') elif line[0] == '62' or line[0] == '70' or line[0] == '92' or line[0] == '93': val = int(line[1]) - elif line[0] == '10' or line[0] == '13' or line[0] == '14': # scaled float x value - val = scale*(float(line[1]) - xmin) - elif line[0] == '20' or line[0] == '23' or line[0] == '24': # scaled float y value - val = height - scale*(float(line[1]) - ymin) else: # unscaled float value val = float(line[1]) vals[groups[line[0]]].append(val) @@ -502,10 +502,26 @@ while line[0] and (line[1] != 'ENDSEC' or not inENTITIES): if vals[groups['6']]: # Common Linetype if linetypes.has_key(vals[groups['6']][0]): style += ';' + linetypes[vals[groups['6']][0]] + extrude = 1.0 + if vals[groups['230']]: + extrude = float(vals[groups['230']][0]) + for xgrp in ['10', '13', '14']: # scale/reflect x values + if vals[groups[xgrp]]: + for i in range (0, len(vals[groups[xgrp]])): + vals[groups[xgrp]][i] = scale*(extrude*vals[groups[xgrp]][i] - xmin) + for ygrp in ['20', '23', '24']: # scale y values + if vals[groups[ygrp]]: + for i in range (0, len(vals[groups[ygrp]])): + vals[groups[ygrp]][i] = height - scale*(vals[groups[ygrp]][i] - ymin) + if (extrude == -1.0): # reflect angles + if vals[groups['50']] and vals[groups['51']]: + temp = vals[groups['51']][0] + vals[groups['51']][0] = 180.0 - vals[groups['50']][0] + vals[groups['50']][0] = 180.0 - temp if entities[entity]: entities[entity]() entity = line[1] - vals = [[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[]] + vals = [[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[]] seqs = [] if polylines: -- cgit v1.2.3 From 208fcc039c9d96f877a996ecef696d0ffe76701f Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Fri, 21 Aug 2015 00:32:24 +0200 Subject: Updated seamless pattern extension to V0.5, Thanks Maren for the strings and patience (bzr r14313) --- share/extensions/seamless_pattern.py | 358 +++++++++++++++++++--------------- share/extensions/seamless_pattern.svg | 184 +++++++++-------- 2 files changed, 301 insertions(+), 241 deletions(-) (limited to 'share/extensions') diff --git a/share/extensions/seamless_pattern.py b/share/extensions/seamless_pattern.py index f48de954a..d75fb1063 100644 --- a/share/extensions/seamless_pattern.py +++ b/share/extensions/seamless_pattern.py @@ -1,159 +1,199 @@ -#!/usr/bin/env python - -# Written by Jabiertxof -# V.04 - -import inkex -import re -import os -from lxml import etree - -class C(inkex.Effect): - def __init__(self): - inkex.Effect.__init__(self) - self.OptionParser.add_option("-w", "--width", action="store", type="int", dest="desktop_width", default="100", help="Custom width") - self.OptionParser.add_option("-z", "--height", action="store", type="int", dest="desktop_height", default="100", help="Custom height") - - def effect(self): - - width = self.options.desktop_width - height = self.options.desktop_height - path = os.path.dirname(os.path.realpath(__file__)) - self.document = etree.parse(os.path.join(path, "seamless_pattern.svg")) - root = self.document.getroot() - root.set("id", "SVGRoot") - root.set("width", str(width) + 'px') - root.set("height", str(height) + 'px') - root.set("viewBox", "0 0 " + str(width) + " " + str(height) ) - - xpathStr = '//svg:rect[@id="clipPathRect"]' - clipPathRect = root.xpath(xpathStr, namespaces=inkex.NSS) - if clipPathRect != []: - clipPathRect[0].set("width", str(width)) - clipPathRect[0].set("height", str(height)) - - xpathStr = '//svg:g[@id="designTop"] | //svg:g[@id="designBottom"]' - designZone = root.xpath(xpathStr, namespaces=inkex.NSS) - if designZone != []: - designZone[0].set("transform", "scale(" + str(width/100.) + ","+ str(height/100.) + ")") - designZone[1].set("transform", "scale(" + str(width/100.) + ","+ str(height/100.) + ")") - - xpathStr = '//svg:use[@id="top1"] | //svg:use[@id="bottom1"]' - pattern1 = root.xpath(xpathStr, namespaces=inkex.NSS) - if pattern1 != []: - pattern1[0].set("transform", "translate(" + str(-width) + "," + str(-height) + ")") - pattern1[1].set("transform", "translate(" + str(-width) + "," + str(-height) + ")") - - xpathStr = '//svg:use[@id="top2"] | //svg:use[@id="bottom2"]' - pattern2 = root.xpath(xpathStr, namespaces=inkex.NSS) - if pattern2 != []: - pattern2[0].set("transform", "translate(0," + str(-height) +")" ) - pattern2[1].set("transform", "translate(0," + str(-height) +")" ) - - xpathStr = '//svg:use[@id="top3"] | //svg:use[@id="bottom3"]' - pattern3 = root.xpath(xpathStr, namespaces=inkex.NSS) - if pattern3 != []: - pattern3[0].set("transform", "translate(" + str(width) + "," + str(-height) + ")" ) - pattern3[1].set("transform", "translate(" + str(width) + "," + str(-height) + ")" ) - - xpathStr = '//svg:use[@id="top4"] | //svg:use[@id="bottom4"]' - pattern4 = root.xpath(xpathStr, namespaces=inkex.NSS) - if pattern4 != []: - pattern4[0].set("transform", "translate(" + str(-width) + ",0)" ) - pattern4[1].set("transform", "translate(" + str(-width) + ",0)" ) - - xpathStr = '//svg:use[@id="top5"] | //svg:use[@id="bottom5"]' - pattern5 = root.xpath(xpathStr, namespaces=inkex.NSS) - if pattern5 != []: - pattern5[0].set("transform", "translate(0,0)" ) - pattern5[1].set("transform", "translate(0,0)" ) - - xpathStr = '//svg:use[@id="top6"] | //svg:use[@id="bottom6"]' - pattern6 = root.xpath(xpathStr, namespaces=inkex.NSS) - if pattern6 != []: - pattern6[0].set("transform", "translate(" + str(width) + ",0)" ) - pattern6[1].set("transform", "translate(" + str(width) + ",0)" ) - - xpathStr = '//svg:use[@id="top7"] | //svg:use[@id="bottom7"]' - pattern7 = root.xpath(xpathStr, namespaces=inkex.NSS) - if pattern7 != []: - pattern7[0].set("transform", "translate(" + str(-width) + "," + str(height) + ")" ) - pattern7[1].set("transform", "translate(" + str(-width) + "," + str(height) + ")" ) - - xpathStr = '//svg:use[@id="top8"] | //svg:use[@id="bottom8"]' - pattern8 = root.xpath(xpathStr, namespaces=inkex.NSS) - if pattern8 != []: - pattern8[0].set("transform", "translate(0," + str(height) + ")" ) - pattern8[1].set("transform", "translate(0," + str(height) + ")" ) - - xpathStr = '//svg:use[@id="top9"] | //svg:use[@id="bottom9"]' - pattern9 = root.xpath(xpathStr, namespaces=inkex.NSS) - if pattern9 != []: - pattern9[0].set("transform", "translate(" + str(width) + "," + str(height) + ")" ) - pattern9[1].set("transform", "translate(" + str(width) + "," + str(height) + ")" ) - - xpathStr = '//svg:use[@id="clonePreview1"]' - clonePreview1 = root.xpath(xpathStr, namespaces=inkex.NSS) - if clonePreview1 != []: - clonePreview1[0].set("transform", "translate(0," + str(height) + ")" ) - - xpathStr = '//svg:use[@id="clonePreview2"]' - clonePreview2 = root.xpath(xpathStr, namespaces=inkex.NSS) - if clonePreview2 != []: - clonePreview2[0].set("transform", "translate(0," + str(height * 2) + ")" ) - - xpathStr = '//svg:use[@id="clonePreview3"]' - clonePreview3 = root.xpath(xpathStr, namespaces=inkex.NSS) - if clonePreview3 != []: - clonePreview3[0].set("transform", "translate(" + str(width) + ",0)" ) - - xpathStr = '//svg:use[@id="clonePreview4"]' - clonePreview4 = root.xpath(xpathStr, namespaces=inkex.NSS) - if clonePreview4 != []: - clonePreview4[0].set("transform", "translate(" + str(width) + "," + str(height) + ")" ) - - xpathStr = '//svg:use[@id="clonePreview5"]' - clonePreview5 = root.xpath(xpathStr, namespaces=inkex.NSS) - if clonePreview5 != []: - clonePreview5[0].set("transform", "translate(" + str(width) + "," + str(height * 2) + ")" ) - - xpathStr = '//svg:use[@id="clonePreview6"]' - clonePreview6 = root.xpath(xpathStr, namespaces=inkex.NSS) - if clonePreview6 != []: - clonePreview6[0].set("transform", "translate(" + str(width*2) + ", 0)" ) - - xpathStr = '//svg:use[@id="clonePreview7"]' - clonePreview7 = root.xpath(xpathStr, namespaces=inkex.NSS) - if clonePreview7 != []: - clonePreview7[0].set("transform", "translate(" + str(width*2) + "," + str(height) + ")" ) - - xpathStr = '//svg:use[@id="clonePreview8"]' - clonePreview8 = root.xpath(xpathStr, namespaces=inkex.NSS) - if clonePreview8 != []: - clonePreview8[0].set("transform", "translate(" + str(width*2) + "," + str(height*2) + ")" ) - - xpathStr = '//svg:use[@id="fullPatternClone"]' - patternGenerator = root.xpath(xpathStr, namespaces=inkex.NSS) - if patternGenerator != []: - patternGenerator[0].set("transform", "translate(" + str(width * 2) + ",-" + str(height) + ")" ) - patternGenerator[0].set("{http://www.inkscape.org/namespaces/inkscape}tile-cx", str(width/2)) - patternGenerator[0].set("{http://www.inkscape.org/namespaces/inkscape}tile-cy", str(height/2)) - patternGenerator[0].set("{http://www.inkscape.org/namespaces/inkscape}tile-w", str(width)) - patternGenerator[0].set("{http://www.inkscape.org/namespaces/inkscape}tile-h", str(height)) - patternGenerator[0].set("{http://www.inkscape.org/namespaces/inkscape}tile-x0", str(width)) - patternGenerator[0].set("{http://www.inkscape.org/namespaces/inkscape}tile-y0", str(height)) - patternGenerator[0].set("width", str(width)) - patternGenerator[0].set("height", str(height)) - - namedview = root.find(inkex.addNS('namedview', 'sodipodi')) - if namedview is None: - namedview = inkex.etree.SubElement( root, inkex.addNS('namedview', 'sodipodi') ); - - namedview.set(inkex.addNS('document-units', 'inkscape'), 'px') - - namedview.set(inkex.addNS('cx', 'inkscape'), str((width*5.5)/2.0) ) - namedview.set(inkex.addNS('cy', 'inkscape'), "0" ) - namedview.set(inkex.addNS('zoom', 'inkscape'), str(1.0 / (width/100.0)) ) - -c = C() -c.affect() +#!/usr/bin/env python + +# Written by Jabiertxof +# V.05 + +import inkex, sys, re, os +from lxml import etree + +class C(inkex.Effect): + def __init__(self): + inkex.Effect.__init__(self) + self.OptionParser.add_option("-w", "--width", action="store", type="int", dest="desktop_width", default="100", help="Custom width") + self.OptionParser.add_option("-z", "--height", action="store", type="int", dest="desktop_height", default="100", help="Custom height") + + def effect(self): + saveout = sys.stdout + sys.stdout = sys.stderr + width = self.options.desktop_width + height = self.options.desktop_height + if height == 0 | width == 0: + return; + factor = float(width)/float(height) + path = os.path.dirname(os.path.realpath(__file__)) + self.document = etree.parse(os.path.join(path, "seamless_pattern.svg")) + root = self.document.getroot() + root.set("id", "SVGRoot") + root.set("width", str(width) + 'px') + root.set("height", str(height) + 'px') + root.set("viewBox", "0 0 " + str(width) + " " + str(height) ) + + xpathStr = '//svg:rect[@id="clipPathRect"]' + clipPathRect = root.xpath(xpathStr, namespaces=inkex.NSS) + if clipPathRect != []: + clipPathRect[0].set("width", str(width)) + clipPathRect[0].set("height", str(height)) + + xpathStr = '//svg:pattern[@id="Checkerboard"]' + designZoneData = root.xpath(xpathStr, namespaces=inkex.NSS) + if designZoneData != []: + if factor <= 1: + designZoneData[0].set("patternTransform", "scale(" + str(10.0) + "," + str(factor * 10) + ")") + else: + designZoneData[0].set("patternTransform", "scale(" + str(10.0/factor) + "," + str(10.0) + ")") + + xpathStr = '//svg:g[@id="designTop"] | //svg:g[@id="designBottom"] | //svg:g[@id="transparencyPreview"]' + designZone = root.xpath(xpathStr, namespaces=inkex.NSS) + if designZone != []: + designZone[0].set("transform", "scale(" + str(width/100.0) + "," + str(height/100.0) + ")") + designZone[1].set("transform", "scale(" + str(width /100.0) + "," + str(height/100.0) + ")") + designZone[2].set("transform", "scale(" + str(width /100.0) + "," + str(height/100.0) + ")") + + xpathStr = '//svg:g[@id="designTop"]/child::*' + designZoneData = root.xpath(xpathStr, namespaces=inkex.NSS) + if designZoneData != []: + if factor <= 1: + designZoneData[0].set("transform", "scale(1," + str(factor) + ")") + designZoneData[1].set("transform", "scale(1," + str(factor) + ")") + designZoneData[2].set("transform", "scale(1," + str(factor) + ")") + else: + designZoneData[0].set("transform", "scale(" + str(1.0/factor) + ",1)") + designZoneData[1].set("transform", "scale(" + str(1.0/factor) + ",1)") + designZoneData[2].set("transform", "scale(" + str(1.0/factor) + ",1)") + + xpathStr = '//svg:g[@id="textPreview"]' + previewText = root.xpath(xpathStr, namespaces=inkex.NSS) + if previewText != []: + if factor <= 1: + previewText[0].set("transform", "translate(" + str(width * 2) + ",0) scale(" + str(width/100.0) + "," + str((height/100.0) * factor) + ")") + else: + previewText[0].set("transform", "translate(" + str(width * 2) + ",0) scale(" + str((width/100.0)/factor) + "," + str(height/100.0) + ")") + + xpathStr = '//svg:g[@id="infoGroup"]' + infoGroup = root.xpath(xpathStr, namespaces=inkex.NSS) + if infoGroup != []: + if factor <= 1: + infoGroup[0].set("transform", "scale(" + str(width/100.0) + "," + str((height/100.0) * factor) + ")") + else: + infoGroup[0].set("transform", "scale(" + str(width/1000.0) + "," + str((height/1000.0) * factor) + ")") + + xpathStr = '//svg:use[@id="top1"] | //svg:use[@id="bottom1"]' + pattern1 = root.xpath(xpathStr, namespaces=inkex.NSS) + if pattern1 != []: + pattern1[0].set("transform", "translate(" + str(-width) + "," + str(-height) + ")") + pattern1[1].set("transform", "translate(" + str(-width) + "," + str(-height) + ")") + + xpathStr = '//svg:use[@id="top2"] | //svg:use[@id="bottom2"]' + pattern2 = root.xpath(xpathStr, namespaces=inkex.NSS) + if pattern2 != []: + pattern2[0].set("transform", "translate(0," + str(-height) +")" ) + pattern2[1].set("transform", "translate(0," + str(-height) +")" ) + + xpathStr = '//svg:use[@id="top3"] | //svg:use[@id="bottom3"]' + pattern3 = root.xpath(xpathStr, namespaces=inkex.NSS) + if pattern3 != []: + pattern3[0].set("transform", "translate(" + str(width) + "," + str(-height) + ")" ) + pattern3[1].set("transform", "translate(" + str(width) + "," + str(-height) + ")" ) + + xpathStr = '//svg:use[@id="top4"] | //svg:use[@id="bottom4"]' + pattern4 = root.xpath(xpathStr, namespaces=inkex.NSS) + if pattern4 != []: + pattern4[0].set("transform", "translate(" + str(-width) + ",0)" ) + pattern4[1].set("transform", "translate(" + str(-width) + ",0)" ) + + xpathStr = '//svg:use[@id="top5"] | //svg:use[@id="bottom5"]' + pattern5 = root.xpath(xpathStr, namespaces=inkex.NSS) + if pattern5 != []: + pattern5[0].set("transform", "translate(0,0)" ) + pattern5[1].set("transform", "translate(0,0)" ) + + xpathStr = '//svg:use[@id="top6"] | //svg:use[@id="bottom6"]' + pattern6 = root.xpath(xpathStr, namespaces=inkex.NSS) + if pattern6 != []: + pattern6[0].set("transform", "translate(" + str(width) + ",0)" ) + pattern6[1].set("transform", "translate(" + str(width) + ",0)" ) + + xpathStr = '//svg:use[@id="top7"] | //svg:use[@id="bottom7"]' + pattern7 = root.xpath(xpathStr, namespaces=inkex.NSS) + if pattern7 != []: + pattern7[0].set("transform", "translate(" + str(-width) + "," + str(height) + ")" ) + pattern7[1].set("transform", "translate(" + str(-width) + "," + str(height) + ")" ) + + xpathStr = '//svg:use[@id="top8"] | //svg:use[@id="bottom8"]' + pattern8 = root.xpath(xpathStr, namespaces=inkex.NSS) + if pattern8 != []: + pattern8[0].set("transform", "translate(0," + str(height) + ")" ) + pattern8[1].set("transform", "translate(0," + str(height) + ")" ) + + xpathStr = '//svg:use[@id="top9"] | //svg:use[@id="bottom9"]' + pattern9 = root.xpath(xpathStr, namespaces=inkex.NSS) + if pattern9 != []: + pattern9[0].set("transform", "translate(" + str(width) + "," + str(height) + ")" ) + pattern9[1].set("transform", "translate(" + str(width) + "," + str(height) + ")" ) + + xpathStr = '//svg:use[@id="clonePreview1"]' + clonePreview1 = root.xpath(xpathStr, namespaces=inkex.NSS) + if clonePreview1 != []: + clonePreview1[0].set("transform", "translate(0," + str(height) + ")" ) + + xpathStr = '//svg:use[@id="clonePreview2"]' + clonePreview2 = root.xpath(xpathStr, namespaces=inkex.NSS) + if clonePreview2 != []: + clonePreview2[0].set("transform", "translate(0," + str(height * 2) + ")" ) + + xpathStr = '//svg:use[@id="clonePreview3"]' + clonePreview3 = root.xpath(xpathStr, namespaces=inkex.NSS) + if clonePreview3 != []: + clonePreview3[0].set("transform", "translate(" + str(width) + ",0)" ) + + xpathStr = '//svg:use[@id="clonePreview4"]' + clonePreview4 = root.xpath(xpathStr, namespaces=inkex.NSS) + if clonePreview4 != []: + clonePreview4[0].set("transform", "translate(" + str(width) + "," + str(height) + ")" ) + + xpathStr = '//svg:use[@id="clonePreview5"]' + clonePreview5 = root.xpath(xpathStr, namespaces=inkex.NSS) + if clonePreview5 != []: + clonePreview5[0].set("transform", "translate(" + str(width) + "," + str(height * 2) + ")" ) + + xpathStr = '//svg:use[@id="clonePreview6"]' + clonePreview6 = root.xpath(xpathStr, namespaces=inkex.NSS) + if clonePreview6 != []: + clonePreview6[0].set("transform", "translate(" + str(width*2) + ", 0)" ) + + xpathStr = '//svg:use[@id="clonePreview7"]' + clonePreview7 = root.xpath(xpathStr, namespaces=inkex.NSS) + if clonePreview7 != []: + clonePreview7[0].set("transform", "translate(" + str(width*2) + "," + str(height) + ")" ) + + xpathStr = '//svg:use[@id="clonePreview8"]' + clonePreview8 = root.xpath(xpathStr, namespaces=inkex.NSS) + if clonePreview8 != []: + clonePreview8[0].set("transform", "translate(" + str(width*2) + "," + str(height*2) + ")" ) + + xpathStr = '//svg:use[@id="fullPatternClone"]' + patternGenerator = root.xpath(xpathStr, namespaces=inkex.NSS) + if patternGenerator != []: + patternGenerator[0].set("transform", "translate(" + str(width * 2) + ",-" + str(height) + ")" ) + patternGenerator[0].set("{http://www.inkscape.org/namespaces/inkscape}tile-cx", str(width/2)) + patternGenerator[0].set("{http://www.inkscape.org/namespaces/inkscape}tile-cy", str(height/2)) + patternGenerator[0].set("{http://www.inkscape.org/namespaces/inkscape}tile-w", str(width)) + patternGenerator[0].set("{http://www.inkscape.org/namespaces/inkscape}tile-h", str(height)) + patternGenerator[0].set("{http://www.inkscape.org/namespaces/inkscape}tile-x0", str(width)) + patternGenerator[0].set("{http://www.inkscape.org/namespaces/inkscape}tile-y0", str(height)) + patternGenerator[0].set("width", str(width)) + patternGenerator[0].set("height", str(height)) + + namedview = root.find(inkex.addNS('namedview', 'sodipodi')) + if namedview is None: + namedview = inkex.etree.SubElement( root, inkex.addNS('namedview', 'sodipodi') ); + + namedview.set(inkex.addNS('document-units', 'inkscape'), 'px') + + namedview.set(inkex.addNS('cx', 'inkscape'), str((width*5.5)/2.0) ) + namedview.set(inkex.addNS('cy', 'inkscape'), "0" ) + namedview.set(inkex.addNS('zoom', 'inkscape'), str(1.0 / (width/100.00)) ) + sys.stdout = saveout + +c = C() +c.affect() diff --git a/share/extensions/seamless_pattern.svg b/share/extensions/seamless_pattern.svg index 7ed009394..729d8cf94 100644 --- a/share/extensions/seamless_pattern.svg +++ b/share/extensions/seamless_pattern.svg @@ -1,86 +1,106 @@ - - - - - - - - - - - - - - - - - image/svg+xml - - - - - - - Seamless Pattern - Seamless Pattern - Seamless Pattern - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Seamless pattern - You can use "design top" layer and "design bottom" layer inside this seamless pattern to design.Go to Patern -root- layer to use the seamless patern. - + + + + + + + + + + + + + + + + + + + + +image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +Seamless pattern +Use the layers "Pattern Foreground" and "Pattern Background" on the pattern page to create your design. The separation into two layers will make it easier for you to create and edit overlapping content like a foreground drawing with a background fill.The layer named "Pattern" is for using the seamless pattern, copying it to other documents, adding opacity etc. Select the group on the page, and use Object->Pattern->Objects to Pattern to convert your creation into a fill pattern.The layer "Preview Background" provides an easy way to preview your creation if it contains transparency.Changing this layer's visibility will not alter the pattern.If an object is moved outside the pattern/page limits, it will be difficult to select it. To move it back onto the page, select the object using the rubberband selection (click and drag a selection box) with the selection tool.Then move it back onto the page, using the arrow keys or the "Align and Distribute" dialog (Shift+Ctrl+A). + + + + + + + + + + + + + + + + +Seamless Pattern +Seamless Pattern +Seamless Pattern + -- cgit v1.2.3 From c65c869d6425d3a727b59ed5128a069a00d76154 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Sat, 22 Aug 2015 18:16:19 +0200 Subject: Set root layer as current in seamless pattern (bzr r14315) --- share/extensions/seamless_pattern.svg | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'share/extensions') diff --git a/share/extensions/seamless_pattern.svg b/share/extensions/seamless_pattern.svg index 729d8cf94..d81460701 100644 --- a/share/extensions/seamless_pattern.svg +++ b/share/extensions/seamless_pattern.svg @@ -2,7 +2,7 @@ - + @@ -23,7 +23,7 @@ image/svg+xml - + @@ -82,7 +82,7 @@ Seamless pattern -Use the layers "Pattern Foreground" and "Pattern Background" on the pattern page to create your design. The separation into two layers will make it easier for you to create and edit overlapping content like a foreground drawing with a background fill.The layer named "Pattern" is for using the seamless pattern, copying it to other documents, adding opacity etc. Select the group on the page, and use Object->Pattern->Objects to Pattern to convert your creation into a fill pattern.The layer "Preview Background" provides an easy way to preview your creation if it contains transparency.Changing this layer's visibility will not alter the pattern.If an object is moved outside the pattern/page limits, it will be difficult to select it. To move it back onto the page, select the object using the rubberband selection (click and drag a selection box) with the selection tool.Then move it back onto the page, using the arrow keys or the "Align and Distribute" dialog (Shift+Ctrl+A). +Use the layers "Pattern Foreground" and "Pattern Background" on the pattern page to create your design. The separation into two layers will make it easier for you to create and edit overlapping content like a foreground drawing with a background fill.The layer named "Pattern" is for using the seamless pattern, copying it to other documents, adding opacity etc. Select the group on the page, and use Object->Pattern->Objects to Pattern to convert your creation into a fill pattern.The layer "Preview Background" provides an easy way to preview your creation if it contains transparency.Changing this layer's visibility will not alter the pattern.If an object is moved outside the pattern/page limits, it will be difficult to select it. To move it back onto the page, select the object using the rubberband selection (click and drag a selection box) with the selection tool.Then move it back onto the page, using the arrow keys or the "Align and Distribute" dialog (Shift+Ctrl+A). -- cgit v1.2.3 From 65593fb91bb42ddf0d4644b6e7f3b20e468f2508 Mon Sep 17 00:00:00 2001 From: Alvin Penner Date: Tue, 1 Sep 2015 08:15:52 -0400 Subject: extensions. dxf_outlines. add support for line, circle, ellipse. (Bug 1489320 and Bug 1474347) Fixed bugs: - https://launchpad.net/bugs/1489320 (bzr r14338) --- share/extensions/dxf_outlines.py | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) (limited to 'share/extensions') diff --git a/share/extensions/dxf_outlines.py b/share/extensions/dxf_outlines.py index 091606ba3..a45100cf5 100755 --- a/share/extensions/dxf_outlines.py +++ b/share/extensions/dxf_outlines.py @@ -211,12 +211,28 @@ class MyEffect(inkex.Effect): y = float(node.get('y')) width = float(node.get('width')) height = float(node.get('height')) - p = [[[x, y],[x, y],[x, y]]] - p.append([[x + width, y],[x + width, y],[x + width, y]]) - p.append([[x + width, y + height],[x + width, y + height],[x + width, y + height]]) - p.append([[x, y + height],[x, y + height],[x, y + height]]) - p.append([[x, y],[x, y],[x, y]]) - p = [p] + d = "m %s,%s %s,%s %s,%s %s,%s z" % (x, y, width, 0, 0, height, -width, 0) + p = cubicsuperpath.parsePath(d) + elif node.tag == inkex.addNS('line','svg'): + x1 = float(node.get('x1')) + x2 = float(node.get('x2')) + y1 = float(node.get('y1')) + y2 = float(node.get('y2')) + d = "M %s,%s L %s,%s" % (x1, y1, x2, y2) + p = cubicsuperpath.parsePath(d) + elif node.tag == inkex.addNS('circle','svg'): + cx = float(node.get('cx')) + cy = float(node.get('cy')) + r = float(node.get('r')) + d = "m %s,%s a %s,%s 0 0 1 %s,%s %s,%s 0 0 1 %s,%s z" % (cx + r, cy, r, r, -2*r, 0, r, r, 2*r, 0) + p = cubicsuperpath.parsePath(d) + elif node.tag == inkex.addNS('ellipse','svg'): + cx = float(node.get('cx')) + cy = float(node.get('cy')) + rx = float(node.get('rx')) + ry = float(node.get('ry')) + d = "m %s,%s a %s,%s 0 0 1 %s,%s %s,%s 0 0 1 %s,%s z" % (cx + rx, cy, rx, ry, -2*rx, 0, rx, ry, 2*rx, 0) + p = cubicsuperpath.parsePath(d) else: return trans = node.get('transform') -- cgit v1.2.3 From d6ea1d90b2c44e1d11d63342dcae621d8158ec48 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Tue, 8 Sep 2015 21:03:04 +0200 Subject: fix a opacity bug problem pointed by Maren in seamless pattern (bzr r14348) --- share/extensions/seamless_pattern.svg | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'share/extensions') diff --git a/share/extensions/seamless_pattern.svg b/share/extensions/seamless_pattern.svg index d81460701..9b33970d5 100644 --- a/share/extensions/seamless_pattern.svg +++ b/share/extensions/seamless_pattern.svg @@ -2,7 +2,7 @@ - + @@ -14,9 +14,6 @@ - - - @@ -30,7 +27,7 @@ - + -- cgit v1.2.3 From dad4eb8f178edfda80ce46cc2ed57764490477b2 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Tue, 8 Sep 2015 21:18:14 +0200 Subject: update version of seamless pattern extension (bzr r14349) --- share/extensions/seamless_pattern.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'share/extensions') diff --git a/share/extensions/seamless_pattern.py b/share/extensions/seamless_pattern.py index d75fb1063..11ed4c356 100644 --- a/share/extensions/seamless_pattern.py +++ b/share/extensions/seamless_pattern.py @@ -1,7 +1,7 @@ #!/usr/bin/env python # Written by Jabiertxof -# V.05 +# V.06 import inkex, sys, re, os from lxml import etree -- cgit v1.2.3 From 7f0069d359b3f41addc520a9687c1922c899e4b3 Mon Sep 17 00:00:00 2001 From: Nicolas Dufour Date: Thu, 10 Sep 2015 11:43:47 +0200 Subject: Documentation. Updating the FAQ link in the Help>FAQ menu. Updating doc links (FAQ, K&M and man) in the PO files. (bzr r14355) --- share/extensions/inkscape_help_faq.inx | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'share/extensions') diff --git a/share/extensions/inkscape_help_faq.inx b/share/extensions/inkscape_help_faq.inx index aa2afcb2c..fda97c08b 100644 --- a/share/extensions/inkscape_help_faq.inx +++ b/share/extensions/inkscape_help_faq.inx @@ -2,9 +2,8 @@ <_name>FAQ org.inkscape.help.faq - launch_webbrowser.py - - <_param name="url" gui-hidden="true" type="string">http://wiki.inkscape.org/wiki/index.php/FAQ + launch_webbrowser.py + https://inkscape.org/learn/faq/ all -- cgit v1.2.3 From 1654c7cdf0cdedf2d2c5befa560bcc5688428c65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20W=C3=BCst?= Date: Sun, 13 Sep 2015 17:30:35 +0200 Subject: Extensions: changed wording for tool offset correction (bzr r14359) --- share/extensions/hpgl_output.inx | 4 ++-- share/extensions/hpgl_output.py | 2 +- share/extensions/plotter.inx | 4 ++-- share/extensions/plotter.py | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) (limited to 'share/extensions') diff --git a/share/extensions/hpgl_output.inx b/share/extensions/hpgl_output.inx index 7fa900dc8..673be29bb 100644 --- a/share/extensions/hpgl_output.inx +++ b/share/extensions/hpgl_output.inx @@ -28,8 +28,8 @@ 1.00 - 0.25 - true + 0.25 + true 1.2 true diff --git a/share/extensions/hpgl_output.py b/share/extensions/hpgl_output.py index fc4f248af..78edba53b 100755 --- a/share/extensions/hpgl_output.py +++ b/share/extensions/hpgl_output.py @@ -41,7 +41,7 @@ class HpglOutput(inkex.Effect): 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('--toolOffset', action='store', type='float', dest='toolOffset', default=0.25, help='Tool (Knife) offset correction (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') diff --git a/share/extensions/plotter.inx b/share/extensions/plotter.inx index 17b2ff185..84c9596fe 100644 --- a/share/extensions/plotter.inx +++ b/share/extensions/plotter.inx @@ -82,8 +82,8 @@ 1.00 - 0.25 - true + 0.25 + true 1.2 true   diff --git a/share/extensions/plotter.py b/share/extensions/plotter.py index c0f180f60..e579e2630 100644 --- a/share/extensions/plotter.py +++ b/share/extensions/plotter.py @@ -53,7 +53,7 @@ class Plot(inkex.Effect): 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('--toolOffset', action='store', type='float', dest='toolOffset', default=0.25, help='Tool (Knife) offset correction (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') -- cgit v1.2.3 From 43783fa8293b066329d00b523d8931326feb7b60 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20W=C3=BCst?= Date: Sun, 13 Sep 2015 17:55:36 +0200 Subject: Extensions: removed pre stream commands feature (too complicated, not needed) (bzr r14360) --- share/extensions/plotter.inx | 1 - share/extensions/plotter.py | 6 +----- 2 files changed, 1 insertion(+), 6 deletions(-) (limited to 'share/extensions') diff --git a/share/extensions/plotter.inx b/share/extensions/plotter.inx index 84c9596fe..6a8bfb3d4 100644 --- a/share/extensions/plotter.inx +++ b/share/extensions/plotter.inx @@ -56,7 +56,6 @@ <_item value="DMPL">DMPL <_item value="KNK">KNK Plotter (HPGL variant) -   <_param name="freezeHelp" type="description">Using wrong settings can under certain circumstances cause Inkscape to freeze. Always save your work before plotting! <_param name="serialHelp" type="description">This can be a physical serial connection or a USB-to-Serial bridge. Ask your plotter manufacturer for drivers if needed. diff --git a/share/extensions/plotter.py b/share/extensions/plotter.py index e579e2630..7e34f2953 100644 --- a/share/extensions/plotter.py +++ b/share/extensions/plotter.py @@ -42,7 +42,6 @@ class Plot(inkex.Effect): 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') @@ -203,8 +202,6 @@ class Plot(inkex.Effect): 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) mySerial.read(2) mySerial.close() @@ -219,7 +216,6 @@ class Plot(inkex.Effect): 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)) inkex.errormsg(' Resolution Y (dpi): ' + str(self.options.resolutionY)) inkex.errormsg(' Pen number: ' + str(self.options.pen)) @@ -263,7 +259,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.options.initCommands + self.hpgl) + inkex.errormsg(self.hpgl) if __name__ == '__main__': # start extension -- cgit v1.2.3 From 7d9a119b16e8991f4bc05b9fbafa6284e5e601ce Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Sun, 13 Sep 2015 18:49:50 +0200 Subject: Clean up the executable bits for extensions (bzr r14361) --- share/extensions/fractalize.inx | 0 share/extensions/hersheydata.py | 0 share/extensions/jessyInk.js | 0 share/extensions/svg2fxg.inx | 0 share/extensions/svg2fxg.xsl | 0 share/extensions/svg2xaml.xsl | 0 6 files changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 share/extensions/fractalize.inx mode change 100755 => 100644 share/extensions/hersheydata.py mode change 100755 => 100644 share/extensions/jessyInk.js mode change 100755 => 100644 share/extensions/svg2fxg.inx mode change 100755 => 100644 share/extensions/svg2fxg.xsl mode change 100755 => 100644 share/extensions/svg2xaml.xsl (limited to 'share/extensions') diff --git a/share/extensions/fractalize.inx b/share/extensions/fractalize.inx old mode 100755 new mode 100644 diff --git a/share/extensions/hersheydata.py b/share/extensions/hersheydata.py old mode 100755 new mode 100644 diff --git a/share/extensions/jessyInk.js b/share/extensions/jessyInk.js old mode 100755 new mode 100644 diff --git a/share/extensions/svg2fxg.inx b/share/extensions/svg2fxg.inx old mode 100755 new mode 100644 diff --git a/share/extensions/svg2fxg.xsl b/share/extensions/svg2fxg.xsl old mode 100755 new mode 100644 diff --git a/share/extensions/svg2xaml.xsl b/share/extensions/svg2xaml.xsl old mode 100755 new mode 100644 -- cgit v1.2.3 From 1245fa37694b8cce14639bfc9b016aa4bd23776c Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Sun, 13 Sep 2015 19:09:56 +0200 Subject: Second round of extension executable bit cleanup. Add/remove executable bits and shebangs as appropriate. The extension entry point should be executable, while Python files that contain libraries and are not entry points should not be executable. Shebang lines should only be present in executable files. (bzr r14362) --- share/extensions/dia2svg.sh | 2 +- share/extensions/dm2svg.py | 0 share/extensions/empty_business_card.py | 0 share/extensions/empty_desktop.py | 0 share/extensions/empty_dvd_cover.py | 0 share/extensions/empty_generic.py | 0 share/extensions/empty_icon.py | 0 share/extensions/empty_page.py | 0 share/extensions/empty_video.py | 0 share/extensions/hpgl_decoder.py | 3 +-- share/extensions/hpgl_encoder.py | 3 +-- share/extensions/hpgl_input.py | 0 share/extensions/ink2canvas/canvas.py | 1 - share/extensions/ink2canvas/svg.py | 1 - share/extensions/inkscape_follow_link.py | 0 share/extensions/plotter.py | 0 share/extensions/print_win32_vector.py | 0 share/extensions/render_gear_rack.py | 2 +- share/extensions/render_gears.py | 2 +- share/extensions/scour/scour.inkscape.py | 0 share/extensions/scour/scour.py | 0 share/extensions/scour/svg_regex.py | 1 - share/extensions/scour/svg_transform.py | 1 - share/extensions/scour/yocto_css.py | 1 - share/extensions/seamless_pattern.py | 0 share/extensions/simplepath.py | 1 - share/extensions/simplestyle.py | 1 - share/extensions/simpletransform.py | 1 - share/extensions/sk2svg.sh | 2 +- share/extensions/text_merge.py | 0 30 files changed, 6 insertions(+), 16 deletions(-) mode change 100644 => 100755 share/extensions/dm2svg.py mode change 100644 => 100755 share/extensions/empty_business_card.py mode change 100644 => 100755 share/extensions/empty_desktop.py mode change 100644 => 100755 share/extensions/empty_dvd_cover.py mode change 100644 => 100755 share/extensions/empty_generic.py mode change 100644 => 100755 share/extensions/empty_icon.py mode change 100644 => 100755 share/extensions/empty_page.py mode change 100644 => 100755 share/extensions/empty_video.py mode change 100644 => 100755 share/extensions/hpgl_input.py mode change 100644 => 100755 share/extensions/inkscape_follow_link.py mode change 100644 => 100755 share/extensions/plotter.py mode change 100644 => 100755 share/extensions/print_win32_vector.py mode change 100644 => 100755 share/extensions/render_gear_rack.py mode change 100644 => 100755 share/extensions/render_gears.py mode change 100644 => 100755 share/extensions/scour/scour.inkscape.py mode change 100644 => 100755 share/extensions/scour/scour.py mode change 100644 => 100755 share/extensions/seamless_pattern.py mode change 100755 => 100644 share/extensions/simplepath.py mode change 100755 => 100644 share/extensions/simpletransform.py mode change 100644 => 100755 share/extensions/text_merge.py (limited to 'share/extensions') diff --git a/share/extensions/dia2svg.sh b/share/extensions/dia2svg.sh index 0e3155f59..86acd593e 100755 --- a/share/extensions/dia2svg.sh +++ b/share/extensions/dia2svg.sh @@ -1,4 +1,4 @@ -#! /bin/sh +#!/bin/sh rc=0 diff --git a/share/extensions/dm2svg.py b/share/extensions/dm2svg.py old mode 100644 new mode 100755 diff --git a/share/extensions/empty_business_card.py b/share/extensions/empty_business_card.py old mode 100644 new mode 100755 diff --git a/share/extensions/empty_desktop.py b/share/extensions/empty_desktop.py old mode 100644 new mode 100755 diff --git a/share/extensions/empty_dvd_cover.py b/share/extensions/empty_dvd_cover.py old mode 100644 new mode 100755 diff --git a/share/extensions/empty_generic.py b/share/extensions/empty_generic.py old mode 100644 new mode 100755 diff --git a/share/extensions/empty_icon.py b/share/extensions/empty_icon.py old mode 100644 new mode 100755 diff --git a/share/extensions/empty_page.py b/share/extensions/empty_page.py old mode 100644 new mode 100755 diff --git a/share/extensions/empty_video.py b/share/extensions/empty_video.py old mode 100644 new mode 100755 diff --git a/share/extensions/hpgl_decoder.py b/share/extensions/hpgl_decoder.py index cd900202b..a54a81e81 100644 --- a/share/extensions/hpgl_decoder.py +++ b/share/extensions/hpgl_decoder.py @@ -1,4 +1,3 @@ -#!/usr/bin/env python # coding=utf-8 ''' Copyright (C) 2013 Sebastian Wüst, sebi@timewaster.de @@ -100,4 +99,4 @@ class hpglDecoder: self.oldCoordinates = (float(parameters[-2]), float(parameters[-1])) -# vim: expandtab shiftwidth=4 tabstop=8 softtabstop=4 fileencoding=utf-8 textwidth=99 \ No newline at end of file +# vim: expandtab shiftwidth=4 tabstop=8 softtabstop=4 fileencoding=utf-8 textwidth=99 diff --git a/share/extensions/hpgl_encoder.py b/share/extensions/hpgl_encoder.py index 83b1b7297..0e4158725 100644 --- a/share/extensions/hpgl_encoder.py +++ b/share/extensions/hpgl_encoder.py @@ -1,4 +1,3 @@ -#!/usr/bin/env python # coding=utf-8 ''' Copyright (C) 2008 Aaron Spike, aaron@ekips.org @@ -375,4 +374,4 @@ class hpglEncoder: 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 +# vim: expandtab shiftwidth=4 tabstop=8 softtabstop=4 fileencoding=utf-8 textwidth=99 diff --git a/share/extensions/hpgl_input.py b/share/extensions/hpgl_input.py old mode 100644 new mode 100755 diff --git a/share/extensions/ink2canvas/canvas.py b/share/extensions/ink2canvas/canvas.py index 1f574a63e..139835f0e 100644 --- a/share/extensions/ink2canvas/canvas.py +++ b/share/extensions/ink2canvas/canvas.py @@ -1,4 +1,3 @@ -#!/usr/bin/env python ''' Copyright (C) 2011 Karlisson Bezerra diff --git a/share/extensions/ink2canvas/svg.py b/share/extensions/ink2canvas/svg.py index 7f3769e3c..b60b2ca9f 100644 --- a/share/extensions/ink2canvas/svg.py +++ b/share/extensions/ink2canvas/svg.py @@ -1,4 +1,3 @@ -#!/usr/bin/env python ''' Copyright (C) 2011 Karlisson Bezerra diff --git a/share/extensions/inkscape_follow_link.py b/share/extensions/inkscape_follow_link.py old mode 100644 new mode 100755 diff --git a/share/extensions/plotter.py b/share/extensions/plotter.py old mode 100644 new mode 100755 diff --git a/share/extensions/print_win32_vector.py b/share/extensions/print_win32_vector.py old mode 100644 new mode 100755 diff --git a/share/extensions/render_gear_rack.py b/share/extensions/render_gear_rack.py old mode 100644 new mode 100755 index 68c5d050e..dfecf0438 --- a/share/extensions/render_gear_rack.py +++ b/share/extensions/render_gear_rack.py @@ -1,4 +1,4 @@ -#! /usr/bin/env python +#!/usr/bin/env python ''' Copyright (C) 2013 Brett Graham (hahahaha @ hahaha.org) diff --git a/share/extensions/render_gears.py b/share/extensions/render_gears.py old mode 100644 new mode 100755 index 5fdb0d4f6..8a481cdb9 --- a/share/extensions/render_gears.py +++ b/share/extensions/render_gears.py @@ -1,4 +1,4 @@ -#! /usr/bin/env python +#!/usr/bin/env python ''' Copyright (C) 2007 Aaron Spike (aaron @ ekips.org) Copyright (C) 2007 Tavmjong Bah (tavmjong @ free.fr) diff --git a/share/extensions/scour/scour.inkscape.py b/share/extensions/scour/scour.inkscape.py old mode 100644 new mode 100755 diff --git a/share/extensions/scour/scour.py b/share/extensions/scour/scour.py old mode 100644 new mode 100755 diff --git a/share/extensions/scour/svg_regex.py b/share/extensions/scour/svg_regex.py index 6321bff0e..00b615873 100644 --- a/share/extensions/scour/svg_regex.py +++ b/share/extensions/scour/svg_regex.py @@ -1,4 +1,3 @@ -#!/usr/bin/env python # This software is OSI Certified Open Source Software. # OSI Certified is a certification mark of the Open Source Initiative. # diff --git a/share/extensions/scour/svg_transform.py b/share/extensions/scour/svg_transform.py index 860c1df5d..0e002bae1 100644 --- a/share/extensions/scour/svg_transform.py +++ b/share/extensions/scour/svg_transform.py @@ -1,4 +1,3 @@ -#!/usr/bin/env python # -*- coding: utf-8 -*- # SVG transformation list parser diff --git a/share/extensions/scour/yocto_css.py b/share/extensions/scour/yocto_css.py index c6bd0c37e..97c4f41bc 100644 --- a/share/extensions/scour/yocto_css.py +++ b/share/extensions/scour/yocto_css.py @@ -1,4 +1,3 @@ -#!/usr/bin/env python # -*- coding: utf-8 -*- # yocto-css, an extremely bare minimum CSS parser diff --git a/share/extensions/seamless_pattern.py b/share/extensions/seamless_pattern.py old mode 100644 new mode 100755 diff --git a/share/extensions/simplepath.py b/share/extensions/simplepath.py old mode 100755 new mode 100644 index 94ab09242..514dd4666 --- a/share/extensions/simplepath.py +++ b/share/extensions/simplepath.py @@ -1,4 +1,3 @@ -#!/usr/bin/env python """ simplepath.py functions for digesting paths into a simple list structure diff --git a/share/extensions/simplestyle.py b/share/extensions/simplestyle.py index 806b81813..ca33e68a4 100644 --- a/share/extensions/simplestyle.py +++ b/share/extensions/simplestyle.py @@ -1,4 +1,3 @@ -#!/usr/bin/env python """ simplestyle.py Two simple functions for working with inline css diff --git a/share/extensions/simpletransform.py b/share/extensions/simpletransform.py old mode 100755 new mode 100644 index 47cc61ec8..8a097f46e --- a/share/extensions/simpletransform.py +++ b/share/extensions/simpletransform.py @@ -1,4 +1,3 @@ -#!/usr/bin/env python ''' Copyright (C) 2006 Jean-Francois Barraud, barraud@math.univ-lille1.fr Copyright (C) 2010 Alvin Penner, penner@vaxxine.com diff --git a/share/extensions/sk2svg.sh b/share/extensions/sk2svg.sh index dbfb3d1f7..886e92e58 100755 --- a/share/extensions/sk2svg.sh +++ b/share/extensions/sk2svg.sh @@ -1,4 +1,4 @@ -#! /bin/sh +#!/bin/sh rc=0 diff --git a/share/extensions/text_merge.py b/share/extensions/text_merge.py old mode 100644 new mode 100755 -- cgit v1.2.3 From 9583d39d2cd19668b1b6c727d1f68203e1344480 Mon Sep 17 00:00:00 2001 From: Alvin Penner Date: Tue, 15 Sep 2015 11:13:54 -0400 Subject: extensions. generate_voronoi.py. allow for translation of parent layer, and scaling of units. (Bug 1495204) Fixed bugs: - https://launchpad.net/bugs/1495204 (bzr r14369) --- share/extensions/generate_voronoi.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'share/extensions') diff --git a/share/extensions/generate_voronoi.py b/share/extensions/generate_voronoi.py index 4ab67dcd6..7acd1be5f 100755 --- a/share/extensions/generate_voronoi.py +++ b/share/extensions/generate_voronoi.py @@ -24,7 +24,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA import random # local library import inkex -import simplestyle +import simplestyle, simpletransform import voronoi inkex.localize() @@ -93,17 +93,21 @@ class Pattern(inkex.Effect): if not self.options.ids: inkex.errormsg(_("Please select an object")) exit() + scale = self.unittouu('1px') # convert to document units + self.options.size *= scale + self.options.border *= scale q = {'x':0,'y':0,'width':0,'height':0} # query the bounding box of ids[0] for query in q.keys(): p = Popen('inkscape --query-%s --query-id=%s "%s"' % (query, self.options.ids[0], self.args[-1]), shell=True, stdout=PIPE, stderr=PIPE) rc = p.wait() - q[query] = float(p.stdout.read()) + q[query] = scale*float(p.stdout.read()) + mat = simpletransform.composeParents(self.selected[self.options.ids[0]], [[1.0, 0.0, 0.0], [0.0, 1.0, 0.0]]) defs = self.xpathSingle('/svg:svg//svg:defs') pattern = inkex.etree.SubElement(defs ,inkex.addNS('pattern','svg')) pattern.set('id', 'Voronoi' + str(random.randint(1, 9999))) pattern.set('width', str(q['width'])) pattern.set('height', str(q['height'])) - pattern.set('patternTransform', 'translate(%s,%s)' % (q['x'], q['y'])) + pattern.set('patternTransform', 'translate(%s,%s)' % (q['x'] - mat[0][2], q['y'] - mat[1][2])) pattern.set('patternUnits', 'userSpaceOnUse') # generate random pattern of points @@ -174,7 +178,8 @@ class Pattern(inkex.Effect): if x1 or x2 or y1 or y2: path += 'M %.3f,%.3f %.3f,%.3f ' % (x1, y1, x2, y2) - attribs = {'d': path, 'style': 'stroke:#000000'} + patternstyle = {'stroke': '#000000', 'stroke-width': str(scale)} + attribs = {'d': path, 'style': simplestyle.formatStyle(patternstyle)} inkex.etree.SubElement(pattern, inkex.addNS('path', 'svg'), attribs) # link selected object to pattern -- cgit v1.2.3 From a37006313230abab62a96554785f2f9286e24183 Mon Sep 17 00:00:00 2001 From: su_v Date: Wed, 16 Sep 2015 23:46:22 +0200 Subject: Extensions. Interpolate: optionally use z-order instead of selection order (workaround for reversed selection order with live preview) (bzr r14371) --- share/extensions/interp.inx | 1 + share/extensions/interp.py | 28 ++++++++++++++++++++-------- 2 files changed, 21 insertions(+), 8 deletions(-) (limited to 'share/extensions') diff --git a/share/extensions/interp.inx b/share/extensions/interp.inx index cd5d32343..470d5dc10 100644 --- a/share/extensions/interp.inx +++ b/share/extensions/interp.inx @@ -9,6 +9,7 @@ 2 true false + false path diff --git a/share/extensions/interp.py b/share/extensions/interp.py index 459190c0e..d3a1f1468 100755 --- a/share/extensions/interp.py +++ b/share/extensions/interp.py @@ -16,7 +16,7 @@ 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 ''' -import inkex, cubicsuperpath, simplestyle, copy, math, bezmisc, simpletransform +import inkex, cubicsuperpath, simplestyle, copy, math, bezmisc, simpletransform, pathmodifier def numsegs(csp): return sum([len(p)-1 for p in csp]) @@ -103,6 +103,10 @@ class Interp(inkex.Effect): action="store", type="inkbool", dest="style", default=True, help="try interpolation of some style properties") + self.OptionParser.add_option("--zsort", + action="store", type="inkbool", + dest="zsort", default=True, + help="use z-order instead of selection order") def tweenstyleunit(self, property, start, end, time): # moved here so we can call 'unittouu' sp = self.unittouu(start[property]) @@ -122,7 +126,15 @@ class Interp(inkex.Effect): paths = {} styles = {} - for id in self.options.ids: + + if self.options.zsort: + # work around selection order swapping with Live Preview + sorted_ids = pathmodifier.zSort(self.document.getroot(),self.selected.keys()) + else: + # use selection order (default) + sorted_ids = self.options.ids + + for id in sorted_ids: node = self.selected[id] if node.tag ==inkex.addNS('path','svg'): paths[id] = cubicsuperpath.parsePath(node.get('d')) @@ -131,13 +143,13 @@ class Interp(inkex.Effect): if trans: simpletransform.applyTransformToPath(simpletransform.parseTransform(trans), paths[id]) else: - self.options.ids.remove(id) + sorted_ids.remove(id) - for i in range(1,len(self.options.ids)): - start = copy.deepcopy(paths[self.options.ids[i-1]]) - end = copy.deepcopy(paths[self.options.ids[i]]) - sst = copy.deepcopy(styles[self.options.ids[i-1]]) - est = copy.deepcopy(styles[self.options.ids[i]]) + for i in range(1,len(sorted_ids)): + start = copy.deepcopy(paths[sorted_ids[i-1]]) + end = copy.deepcopy(paths[sorted_ids[i]]) + sst = copy.deepcopy(styles[sorted_ids[i-1]]) + est = copy.deepcopy(styles[sorted_ids[i]]) basestyle = copy.deepcopy(sst) if basestyle.has_key('stroke-width'): basestyle['stroke-width'] = self.tweenstyleunit('stroke-width',sst,est,0) -- cgit v1.2.3 From be7d8f9bf1b78cf0492b4d995348851f0ba1ffc1 Mon Sep 17 00:00:00 2001 From: su_v Date: Thu, 17 Sep 2015 02:29:32 +0200 Subject: Extensions. Interpolate: set same default value for zsort in OptionParser as in the GUI (bzr r14373) --- share/extensions/interp.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'share/extensions') diff --git a/share/extensions/interp.py b/share/extensions/interp.py index d3a1f1468..093a98fda 100755 --- a/share/extensions/interp.py +++ b/share/extensions/interp.py @@ -105,7 +105,7 @@ class Interp(inkex.Effect): help="try interpolation of some style properties") self.OptionParser.add_option("--zsort", action="store", type="inkbool", - dest="zsort", default=True, + dest="zsort", default=False, help="use z-order instead of selection order") def tweenstyleunit(self, property, start, end, time): # moved here so we can call 'unittouu' -- cgit v1.2.3 From e3695d9cfcc753be45cbee0733751f6950191145 Mon Sep 17 00:00:00 2001 From: su_v Date: Thu, 17 Sep 2015 02:33:36 +0200 Subject: Extensions. Interpolate attribute in group: use z-order instead of selection order for multiple selection (bzr r14374) --- share/extensions/interp_att_g.inx | 1 + share/extensions/interp_att_g.py | 13 +++++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) (limited to 'share/extensions') diff --git a/share/extensions/interp_att_g.inx b/share/extensions/interp_att_g.inx index 39c043519..7a0ef1d5c 100644 --- a/share/extensions/interp_att_g.inx +++ b/share/extensions/interp_att_g.inx @@ -40,6 +40,7 @@ cm mm + true <_param name="intro" type="description">This effect applies a value for any interpolatable attribute for all elements inside the selected group or for all elements in a multiple selection. diff --git a/share/extensions/interp_att_g.py b/share/extensions/interp_att_g.py index 0798f7f58..168e7ffb0 100755 --- a/share/extensions/interp_att_g.py +++ b/share/extensions/interp_att_g.py @@ -23,6 +23,7 @@ import string # local library import inkex import simplestyle +from pathmodifier import zSort inkex.localize() @@ -58,6 +59,10 @@ class InterpAttG(inkex.Effect): action="store", type="string", dest="unit", default="color", help="Values unit.") + self.OptionParser.add_option("--zsort", + action="store", type="inkbool", + dest="zsort", default=True, + help="use z-order instead of selection order") self.OptionParser.add_option("--tab", action="store", type="string", dest="tab", @@ -116,8 +121,12 @@ class InterpAttG(inkex.Effect): return False if len( self.selected ) > 1: # multiple selection - self.collection = self.options.ids - for i in self.options.ids: + if self.options.zsort: + sorted_ids = zSort(self.document.getroot(),self.selected.keys()) + else: + sorted_ids = self.options.ids + self.collection = list(sorted_ids) + for i in sorted_ids: path = '//*[@id="%s"]' % i self.collection[self.tot_el] = self.document.xpath(path, namespaces=inkex.NSS)[0] self.tot_el += 1 -- cgit v1.2.3 From 06fc0578617c3cf0839f5f21c6faa7764dd94ebb Mon Sep 17 00:00:00 2001 From: su_v Date: Tue, 22 Sep 2015 13:30:22 +0200 Subject: Extensions. Fix for bug #1496804 (Flatten Beziers: raise lower limit for flatness factor to prevent endless loop in python script) (bzr r14381) --- share/extensions/flatten.inx | 2 +- share/extensions/flatten.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'share/extensions') diff --git a/share/extensions/flatten.inx b/share/extensions/flatten.inx index 4c8298623..74b939c02 100644 --- a/share/extensions/flatten.inx +++ b/share/extensions/flatten.inx @@ -4,7 +4,7 @@ org.ekips.filter.flatten flatten.py inkex.py - 10.0 + 10.0 path diff --git a/share/extensions/flatten.py b/share/extensions/flatten.py index ce6915086..f5add5fc5 100755 --- a/share/extensions/flatten.py +++ b/share/extensions/flatten.py @@ -40,7 +40,7 @@ class MyEffect(inkex.Effect): cmd = 'M' first = False np.append([cmd,[csp[1][0],csp[1][1]]]) - node.set('d',simplepath.formatPath(np)) + node.set('d',simplepath.formatPath(np)) if __name__ == '__main__': e = MyEffect() -- cgit v1.2.3 From aa71e0a6b6204fb138f71447f7acfc77abcd2e40 Mon Sep 17 00:00:00 2001 From: su_v Date: Tue, 22 Sep 2015 18:12:36 +0200 Subject: Extensions. Fix some broken Vim modelines (bzr r14382) --- share/extensions/restack.py | 2 +- share/extensions/text_extract.py | 2 +- share/extensions/text_merge.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'share/extensions') diff --git a/share/extensions/restack.py b/share/extensions/restack.py index 507353025..dc877cd9e 100755 --- a/share/extensions/restack.py +++ b/share/extensions/restack.py @@ -151,4 +151,4 @@ if __name__ == '__main__': e.affect() -# vim: expandtab shiftwidth=4 tabstop=8 softtabstop=4 encoding=utf-8 textwidth=99 +# vim: expandtab shiftwidth=4 tabstop=8 softtabstop=4 fileencoding=utf-8 textwidth=99 diff --git a/share/extensions/text_extract.py b/share/extensions/text_extract.py index dfcddefdc..b6b575dfc 100755 --- a/share/extensions/text_extract.py +++ b/share/extensions/text_extract.py @@ -163,4 +163,4 @@ if __name__ == '__main__': e = Extract() e.affect() -# vim: expandtab shiftwidth=4 tabstop=8 softtabstop=4 encoding=utf-8 textwidth=99 +# vim: expandtab shiftwidth=4 tabstop=8 softtabstop=4 fileencoding=utf-8 textwidth=99 diff --git a/share/extensions/text_merge.py b/share/extensions/text_merge.py index 625f14b75..a3ba29022 100755 --- a/share/extensions/text_merge.py +++ b/share/extensions/text_merge.py @@ -199,4 +199,4 @@ if __name__ == '__main__': e = Merge() e.affect() -# vim: expandtab shiftwidth=4 tabstop=8 softtabstop=4 encoding=utf-8 textwidth=99 +# vim: expandtab shiftwidth=4 tabstop=8 softtabstop=4 fileencoding=utf-8 textwidth=99 -- cgit v1.2.3 From f3db50c7e73bccc044da97d927927085209d3007 Mon Sep 17 00:00:00 2001 From: su_v Date: Thu, 24 Sep 2015 15:46:50 +0200 Subject: Extensions: fix for bug #1459295 (Measure Path: area of CW paths has wrong sign (negative)) (bzr r14384) --- share/extensions/measure.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'share/extensions') diff --git a/share/extensions/measure.py b/share/extensions/measure.py index e7c91feec..0b01ae9c3 100755 --- a/share/extensions/measure.py +++ b/share/extensions/measure.py @@ -199,7 +199,7 @@ class Length(inkex.Effect): slengths, stotal = csplength(p) self.group = inkex.etree.SubElement(node.getparent(),inkex.addNS('text','svg')) elif self.options.type == "area": - stotal = csparea(p)*factor*self.options.scale + stotal = abs(csparea(p)*factor*self.options.scale) self.group = inkex.etree.SubElement(node.getparent(),inkex.addNS('text','svg')) else: xc, yc = cspcofm(p) -- cgit v1.2.3 From b5c6cb107bdcc23444ab66ea0d21245dafd9c059 Mon Sep 17 00:00:00 2001 From: su_v Date: Wed, 30 Sep 2015 01:43:25 +0200 Subject: Extensions. Measure Path: Add more layout options for text (Bug #1460422) (bzr r14388) --- share/extensions/measure.inx | 33 ++++++++++++-- share/extensions/measure.py | 105 ++++++++++++++++++++++++++++++++++++------- 2 files changed, 117 insertions(+), 21 deletions(-) (limited to 'share/extensions') diff --git a/share/extensions/measure.inx b/share/extensions/measure.inx index 8fae020e0..7a6598bc7 100644 --- a/share/extensions/measure.inx +++ b/share/extensions/measure.inx @@ -11,11 +11,36 @@ <_item msgctxt="measure extension" value="area">Area <_item msgctxt="measure extension" value="cofm">Center of Mass - - <_item msgctxt="measure extension" value="textonpath">Text On Path - <_item msgctxt="measure extension" value="angle">Fixed Angle + + + + <_item value="default">Default + <_item value="TaP_start">Text on Path, Start + <_item value="TaP_middle">Text on Path, Middle + <_item value="TaP_end">Text on Path, End + <_item value="FT_start">Fixed Text, Start of Path + <_item value="FT_bbox">Fixed Text, Center of BBox + <_item value="FT_mass">Fixed Text, Center of Mass + + + + custom + 50 + + <_item value="start">Left + <_item value="middle">Center + <_item value="end">Right + + + + + <_item value="start">Start of Path + <_item value="center">Center of BBox + <_item value="mass">Center of Mass + + 0 + - 0 12 -6 2 diff --git a/share/extensions/measure.py b/share/extensions/measure.py index 0b01ae9c3..9fc632c2a 100755 --- a/share/extensions/measure.py +++ b/share/extensions/measure.py @@ -5,6 +5,7 @@ It adds text to the selected path containing the length in a given unit. Area and Center of Mass calculated using Green's Theorem: http://mathworld.wolfram.com/GreensTheorem.html +Copyright (C) 2015 ~suv Copyright (C) 2010 Alvin Penner Copyright (C) 2006 Georg Wiora Copyright (C) 2006 Nathan Hurst @@ -41,7 +42,14 @@ import cubicsuperpath import bezmisc inkex.localize() -locale.setlocale(locale.LC_ALL, '') + +# On darwin, fall back to C in cases of +# - incorrect locale IDs (see comments in bug #406662) +# - https://bugs.python.org/issue18378 +try: + locale.setlocale(locale.LC_ALL, '') +except locale.Error: + locale.setlocale(locale.LC_ALL, 'C') # third party try: @@ -130,17 +138,37 @@ class Length(inkex.Effect): def __init__(self): inkex.Effect.__init__(self) self.OptionParser.add_option("--type", - action="store", type="string", - dest="type", default="length", + action="store", type="string", + dest="mtype", default="length", help="Type of measurement") self.OptionParser.add_option("--format", - action="store", type="string", - dest="format", default="textonpath", + action="store", type="string", + dest="mformat", default="textonpath", help="Text Orientation") + self.OptionParser.add_option("--presetFormat", + action="store", type="string", + dest="presetFormat", default="TaP_start", + help="Preset text layout") + self.OptionParser.add_option("--startOffset", + action="store", type="string", + dest="startOffset", default="custom", + help="Text Offset along Path") + self.OptionParser.add_option("--startOffsetCustom", + action="store", type="int", + dest="startOffsetCustom", default=50, + help="Text Offset along Path") + self.OptionParser.add_option("--anchor", + action="store", type="string", + dest="anchor", default="start", + help="Text Anchor") + self.OptionParser.add_option("--position", + action="store", type="string", + dest="position", default="start", + help="Text Position") self.OptionParser.add_option("--angle", - action="store", type="float", + action="store", type="float", dest="angle", default=0, - help="Angle") + help="Angle") self.OptionParser.add_option("-f", "--fontsize", action="store", type="int", dest="fontsize", default=20, @@ -175,6 +203,8 @@ class Length(inkex.Effect): help="dummy") def effect(self): + if self.options.mformat == '"presets"': + self.setPreset() # get number of digits prec = int(self.options.precision) scale = self.unittouu('1px') # convert to document units @@ -195,10 +225,10 @@ class Length(inkex.Effect): 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) - if self.options.type == "length": + if self.options.mtype == "length": slengths, stotal = csplength(p) self.group = inkex.etree.SubElement(node.getparent(),inkex.addNS('text','svg')) - elif self.options.type == "area": + elif self.options.mtype == "area": stotal = abs(csparea(p)*factor*self.options.scale) self.group = inkex.etree.SubElement(node.getparent(),inkex.addNS('text','svg')) else: @@ -209,16 +239,57 @@ class Length(inkex.Effect): continue # Format the length as string lenstr = locale.format("%(len)25."+str(prec)+"f",{'len':round(stotal*factor*self.options.scale,prec)}).strip() - if self.options.format == 'textonpath': - if self.options.type == "length": - self.addTextOnPath(self.group, 0, 0, lenstr+' '+self.options.unit, id, 'start', '50%', self.options.offset) + if self.options.mformat == '"textonpath"': + startOffset = self.options.startOffset + if startOffset == "custom": + startOffset = str(self.options.startOffsetCustom) + '%' + if self.options.mtype == "length": + self.addTextOnPath(self.group, 0, 0, lenstr+' '+self.options.unit, id, self.options.anchor, startOffset, self.options.offset) else: - self.addTextOnPath(self.group, 0, 0, lenstr+' '+self.options.unit+'^2', id, 'start', '0%', self.options.offset) - else: - if self.options.type == "length": - self.addTextWithTspan(self.group, p[0][0][1][0], p[0][0][1][1], lenstr+' '+self.options.unit, id, 'start', -int(self.options.angle), self.options.offset + self.options.fontsize/2) + self.addTextOnPath(self.group, 0, 0, lenstr+' '+self.options.unit+'^2', id, self.options.anchor, startOffset, self.options.offset) + elif self.options.mformat == '"fixedtext"': + if self.options.position == "mass": + tx, ty = cspcofm(p) + anchor = 'middle' + elif self.options.position == "center": + bbox = simpletransform.computeBBox([node]) + tx = bbox[0] + (bbox[1] - bbox[0])/2.0 + ty = bbox[2] + (bbox[3] - bbox[2])/2.0 + anchor = 'middle' + else: # default + tx = p[0][0][1][0] + ty = p[0][0][1][1] + anchor = 'start' + if self.options.mtype == "length": + self.addTextWithTspan(self.group, tx, ty, lenstr+' '+self.options.unit, id, anchor, -int(self.options.angle), self.options.offset + self.options.fontsize/2) else: - self.addTextWithTspan(self.group, p[0][0][1][0], p[0][0][1][1], lenstr+' '+self.options.unit+'^2', id, 'start', -int(self.options.angle), -self.options.offset + self.options.fontsize/2) + self.addTextWithTspan(self.group, tx, ty, lenstr+' '+self.options.unit+'^2', id, anchor, -int(self.options.angle), -self.options.offset + self.options.fontsize/2) + else: + # center of mass, no text + pass + + def setPreset(self): + # keep dict in sync with enum in INX file: + preset_dict = { + 'default_length': ['"textonpath"', "50%", "start", None, None], + 'default_area': ['"fixedtext"', None, None, "start", 0.0], + 'default_cofm': [None, None, None, None, None], + 'TaP_start': ['"textonpath"', "0%", "start", None, None], + 'TaP_middle': ['"textonpath"', "50%", "middle", None, None], + 'TaP_end': ['"textonpath"', "100%", "end", None, None], + 'FT_start': ['"fixedtext"', None, None, "start", 0.0], + 'FT_bbox': ['"fixedtext"', None, None, "center", 0.0], + 'FT_mass': ['"fixedtext"', None, None, "mass", 0.0], + } + if self.options.presetFormat == "default": + current_preset = 'default_' + self.options.mtype + else: + current_preset = self.options.presetFormat + self.options.mformat = preset_dict[current_preset][0] + self.options.startOffset = preset_dict[current_preset][1] + self.options.anchor = preset_dict[current_preset][2] + self.options.position = preset_dict[current_preset][3] + self.options.angle = preset_dict[current_preset][4] def addCross(self, node, x, y, scale): l = 3*scale # 3 pixels in document units -- cgit v1.2.3 From e98762faf4bdaa6cf685ee9e60d53ba5f36ac15b Mon Sep 17 00:00:00 2001 From: Alvin Penner Date: Sun, 4 Oct 2015 18:38:34 -0400 Subject: extensions. guillotine.py. fix Bug 1502041 Fixed bugs: - https://launchpad.net/bugs/1502041 (bzr r14397) --- share/extensions/guillotine.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'share/extensions') diff --git a/share/extensions/guillotine.py b/share/extensions/guillotine.py index bd077d60a..15a0fba96 100755 --- a/share/extensions/guillotine.py +++ b/share/extensions/guillotine.py @@ -88,11 +88,11 @@ class Guillotine(inkex.Effect): for g in xpath: guide = {} (x, y) = g.attrib['position'].split(',') - if g.attrib['orientation'] == '0,1': + if g.attrib['orientation'][:2] == '0,': guide['orientation'] = 'horizontal' guide['position'] = y guides.append(guide) - elif g.attrib['orientation'] == '1,0': + elif g.attrib['orientation'][-2:] == ',0': guide['orientation'] = 'vertical' guide['position'] = x guides.append(guide) -- cgit v1.2.3 From 5e3184580abd601f97d3f039a89fd649f6bd8fd4 Mon Sep 17 00:00:00 2001 From: su_v Date: Wed, 7 Oct 2015 23:32:24 +0200 Subject: Extensions. DXF export: support default values for omitted attributes of basic SVG shapes (line, rect, circle, ellipse) (bzr r14398) --- share/extensions/dxf_outlines.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'share/extensions') diff --git a/share/extensions/dxf_outlines.py b/share/extensions/dxf_outlines.py index a45100cf5..b7ae0ef14 100755 --- a/share/extensions/dxf_outlines.py +++ b/share/extensions/dxf_outlines.py @@ -207,28 +207,28 @@ class MyEffect(inkex.Effect): return p = cubicsuperpath.parsePath(d) elif node.tag == inkex.addNS('rect','svg'): - x = float(node.get('x')) - y = float(node.get('y')) + x = float(node.get('x', 0)) + y = float(node.get('y', 0)) width = float(node.get('width')) height = float(node.get('height')) d = "m %s,%s %s,%s %s,%s %s,%s z" % (x, y, width, 0, 0, height, -width, 0) p = cubicsuperpath.parsePath(d) elif node.tag == inkex.addNS('line','svg'): - x1 = float(node.get('x1')) - x2 = float(node.get('x2')) - y1 = float(node.get('y1')) - y2 = float(node.get('y2')) + x1 = float(node.get('x1', 0)) + x2 = float(node.get('x2', 0)) + y1 = float(node.get('y1', 0)) + y2 = float(node.get('y2', 0)) d = "M %s,%s L %s,%s" % (x1, y1, x2, y2) p = cubicsuperpath.parsePath(d) elif node.tag == inkex.addNS('circle','svg'): - cx = float(node.get('cx')) - cy = float(node.get('cy')) + cx = float(node.get('cx', 0)) + cy = float(node.get('cy', 0)) r = float(node.get('r')) d = "m %s,%s a %s,%s 0 0 1 %s,%s %s,%s 0 0 1 %s,%s z" % (cx + r, cy, r, r, -2*r, 0, r, r, 2*r, 0) p = cubicsuperpath.parsePath(d) elif node.tag == inkex.addNS('ellipse','svg'): - cx = float(node.get('cx')) - cy = float(node.get('cy')) + cx = float(node.get('cx', 0)) + cy = float(node.get('cy', 0)) rx = float(node.get('rx')) ry = float(node.get('ry')) d = "m %s,%s a %s,%s 0 0 1 %s,%s %s,%s 0 0 1 %s,%s z" % (cx + rx, cy, rx, ry, -2*rx, 0, rx, ry, 2*rx, 0) -- cgit v1.2.3 From fc8d6dbbd964ddb260286e5af7f0a1fb05a737e3 Mon Sep 17 00:00:00 2001 From: su_v Date: Sun, 11 Oct 2015 08:45:15 +0200 Subject: Extensions. Random Tree: optionally omit redundant segments (bug #1500124) Fixed bugs: - https://launchpad.net/bugs/1500124 (bzr r14403) --- share/extensions/rtree.inx | 1 + share/extensions/rtree.py | 17 +++++++++++++---- 2 files changed, 14 insertions(+), 4 deletions(-) (limited to 'share/extensions') diff --git a/share/extensions/rtree.inx b/share/extensions/rtree.inx index 5fcac5560..8f6baee7d 100644 --- a/share/extensions/rtree.inx +++ b/share/extensions/rtree.inx @@ -6,6 +6,7 @@ inkex.py 100.0 40.0 + false all diff --git a/share/extensions/rtree.py b/share/extensions/rtree.py index db677d0d5..7123beb1e 100755 --- a/share/extensions/rtree.py +++ b/share/extensions/rtree.py @@ -1,6 +1,7 @@ #!/usr/bin/env python ''' Copyright (C) 2005 Aaron Spike, aaron@ekips.org +Copyright (C) 2015 su_v, 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 @@ -18,19 +19,23 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ''' import inkex, simplestyle, pturtle, random -def rtree(turtle, size, min): +def rtree(turtle, size, min, pt=False): if size < min: return turtle.fd(size) turn = random.uniform(20, 40) turtle.lt(turn) - rtree(turtle, size*random.uniform(0.5,0.9), min) + rtree(turtle, size*random.uniform(0.5,0.9), min, pt) turtle.rt(turn) turn = random.uniform(20, 40) turtle.rt(turn) - rtree(turtle, size*random.uniform(0.5,0.9), min) + rtree(turtle, size*random.uniform(0.5,0.9), min, pt) turtle.lt(turn) + if pt: + turtle.pu() turtle.bk(size) + if pt: + turtle.pd() class RTreeTurtle(inkex.Effect): def __init__(self): @@ -43,6 +48,10 @@ class RTreeTurtle(inkex.Effect): action="store", type="float", dest="minimum", default=4.0, help="minimum branch size") + self.OptionParser.add_option("--pentoggle", + action="store", type="inkbool", + dest="pentoggle", default=False, + help="Lift pen for backward steps") def effect(self): self.options.size = self.unittouu(str(self.options.size) + 'px') self.options.minimum = self.unittouu(str(self.options.minimum) + 'px') @@ -54,7 +63,7 @@ class RTreeTurtle(inkex.Effect): t.pu() t.setpos(self.view_center) t.pd() - rtree(t, self.options.size, self.options.minimum) + rtree(t, self.options.size, self.options.minimum, self.options.pentoggle) attribs = {'d':t.getPath(),'style':simplestyle.formatStyle(s)} inkex.etree.SubElement(self.current_layer, inkex.addNS('path','svg'), attribs) -- cgit v1.2.3 From 9fa924d089746158ea4721a4a0e2dcab08f92121 Mon Sep 17 00:00:00 2001 From: su_v Date: Tue, 20 Oct 2015 13:49:11 +0200 Subject: Extensions. Restack - add options to reverse, shuffle Z-order of selection (bug #1498583) Fixed bugs: - https://launchpad.net/bugs/1498583 (bzr r14424) --- share/extensions/restack.inx | 62 ++++++++++++++++++++++++----------- share/extensions/restack.py | 77 +++++++++++++++++++++++++++++++++++++++----- 2 files changed, 112 insertions(+), 27 deletions(-) (limited to 'share/extensions') diff --git a/share/extensions/restack.inx b/share/extensions/restack.inx index 67f0f777a..4f5f577cb 100644 --- a/share/extensions/restack.inx +++ b/share/extensions/restack.inx @@ -4,25 +4,49 @@ org.inkscape.filter.restack restack.py inkex.py - - <_item value="lr">Left to Right (0) - <_item value="bt">Bottom to Top (90) - <_item value="rl">Right to Left (180) - <_item value="tb">Top to Bottom (270) - <_item value="ro">Radial Outward - <_item value="ri">Radial Inward - <_item value="aa">Arbitrary Angle - - 0.00 - - <_item value="l">Left - <_item value="m">Middle - <_item value="r">Right - - - <_item value="t">Top - <_item value="m">Middle - <_item value="b">Bottom + + + <_param name="desc_dir" type="description" appearance="header">Restack Direction + + + + <_item value="lr">Left to Right (0) + <_item value="bt">Bottom to Top (90) + <_item value="rl">Right to Left (180) + <_item value="tb">Top to Bottom (270) + <_item value="ro">Radial Outward + <_item value="ri">Radial Inward + + + + 0.00 + + + <_param name="desc_ref" type="description" appearance="header">Object Reference Point + + <_item value="l">Left + <_item value="m">Middle + <_item value="r">Right + + + <_item value="t">Top + <_item value="m">Middle + <_item value="b">Bottom + + + + <_param name="desc_zsort" type="description" appearance="header">Restack Mode + + <_item value="rev">Reverse Z-Order + <_item value="rand">Shuffle Z-Order + + + + <_param name="desc_help" type="description">This extension changes the z-order of objects based on their position on the canvas or their current z-order. + +Selection: +The extension restacks either objects inside a single selected group, or a selection of multiple objects on the current drawing level (layer or group). + path diff --git a/share/extensions/restack.py b/share/extensions/restack.py index dc877cd9e..b76e0f765 100755 --- a/share/extensions/restack.py +++ b/share/extensions/restack.py @@ -21,7 +21,10 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. """ -import inkex, os, csv, math +import inkex, os, csv, math, random +from pathmodifier import zSort + +inkex.localize() try: from subprocess import Popen, PIPE @@ -48,13 +51,49 @@ class Restack(inkex.Effect): action="store", type="string", dest="yanchor", default="m", help="vertical point to compare") + self.OptionParser.add_option("--zsort", + action="store", type="string", + dest="zsort", default="rev", + help="Restack mode based on Z-Order") + self.OptionParser.add_option("--tab", + action="store", type="string", + dest="tab", + help="The selected UI-tab when OK was pressed") + self.OptionParser.add_option("--nb_direction", + action="store", type="string", + dest="nb_direction", + help="The selected UI-tab when OK was pressed") + def effect(self): - if len( self.selected ) > 0: + if self.options.tab == '"help"': + pass + elif len(self.selected) > 0: + if self.options.tab == '"positional"': + self.restack_positional() + elif self.options.tab == '"z_order"': + self.restack_z_order() + else: + inkex.errormsg(_("There is no selection to restack.")) + + def restack_positional(self): + if 1: # to be removed (workaround for smaller bzr diff) + objects = {} objlist = [] - svg = self.document.getroot() - parentnode = self.current_layer file = self.args[ -1 ] + if self.options.nb_direction == '"custom"': + self.options.direction = "aa" + + # process selection to get list of objects to be arranged + firstobject = self.selected[self.options.ids[0]] + if len(self.selected) == 1 and firstobject.tag == inkex.addNS('g', 'svg'): + parentnode = firstobject + for child in parentnode.iterchildren(): + objects[child.get('id')] = child + else: + parentnode = self.current_layer + objects = self.selected + #get all bounding boxes in file by calling inkscape again with the --query-all command line option #it returns a comma separated list structured id,x,y,w,h if bsubprocess: @@ -81,13 +120,13 @@ class Restack(inkex.Effect): f.close #find the center of all selected objects **Not the average! - x,y,w,h = dimen[self.selected.keys()[0]] + x,y,w,h = dimen[objects.keys()[0]] minx = x miny = y maxx = x + w maxy = y + h - for id, node in self.selected.iteritems(): + for id, node in objects.iteritems(): # get the bounding box x,y,w,h = dimen[id] if x < minx: @@ -103,7 +142,7 @@ class Restack(inkex.Effect): midy = (miny + maxy) / 2 #calculate distances for each selected object - for id, node in self.selected.iteritems(): + for id, node in objects.iteritems(): # get the bounding box x,y,w,h = dimen[id] @@ -144,7 +183,29 @@ class Restack(inkex.Effect): objlist.sort() #move them to the top of the object stack in this order. for item in objlist: - parentnode.append( self.selected[item[1]]) + parentnode.append( objects[item[1]]) + + def restack_z_order(self): + parentnode = None + objects = [] + if len(self.selected) == 1: + firstobject = self.selected[self.options.ids[0]] + if firstobject.tag == inkex.addNS('g', 'svg'): + parentnode = firstobject + for child in parentnode.iterchildren(reversed=False): + objects.append(child) + else: + parentnode = self.current_layer + for id_ in zSort(self.document.getroot(), self.selected.keys()): + objects.append(self.selected[id_]) + if self.options.zsort == "rev": + objects.reverse() + elif self.options.zsort == "rand": + random.shuffle(objects) + if parentnode is not None: + for item in objects: + parentnode.append(item) + if __name__ == '__main__': e = Restack() -- cgit v1.2.3 From 87d0a984dec7a5f4cfce15a38b365f162ad21c49 Mon Sep 17 00:00:00 2001 From: su_v Date: Tue, 20 Oct 2015 14:09:50 +0200 Subject: Extensions. Restack - fix indentation level (follow-up to rev 14424, bug #1498583) (bzr r14425) --- share/extensions/restack.py | 215 ++++++++++++++++++++++---------------------- 1 file changed, 107 insertions(+), 108 deletions(-) (limited to 'share/extensions') diff --git a/share/extensions/restack.py b/share/extensions/restack.py index b76e0f765..67d738a13 100755 --- a/share/extensions/restack.py +++ b/share/extensions/restack.py @@ -76,114 +76,113 @@ class Restack(inkex.Effect): inkex.errormsg(_("There is no selection to restack.")) def restack_positional(self): - if 1: # to be removed (workaround for smaller bzr diff) - objects = {} - objlist = [] - file = self.args[ -1 ] - - if self.options.nb_direction == '"custom"': - self.options.direction = "aa" - - # process selection to get list of objects to be arranged - firstobject = self.selected[self.options.ids[0]] - if len(self.selected) == 1 and firstobject.tag == inkex.addNS('g', 'svg'): - parentnode = firstobject - for child in parentnode.iterchildren(): - objects[child.get('id')] = child - else: - parentnode = self.current_layer - objects = self.selected - - #get all bounding boxes in file by calling inkscape again with the --query-all command line option - #it returns a comma separated list structured id,x,y,w,h - if bsubprocess: - p = Popen('inkscape --query-all "%s"' % (file), shell=True, stdout=PIPE, stderr=PIPE) - err = p.stderr - f = p.communicate()[0] - try: - reader=csv.CSVParser().parse_string(f) #there was a module cvs.py in earlier inkscape that behaved differently - except: - reader=csv.reader(f.split( os.linesep )) - err.close() - else: - _,f,err = os.popen3('inkscape --query-all "%s"' % ( file ) ) - reader=csv.reader( f ) - err.close() - - #build a dictionary with id as the key - dimen = dict() - for line in reader: - if len(line) > 0: - dimen[line[0]] = map( float, line[1:]) - - if not bsubprocess: #close file if opened using os.popen3 - f.close - - #find the center of all selected objects **Not the average! - x,y,w,h = dimen[objects.keys()[0]] - minx = x - miny = y - maxx = x + w - maxy = y + h - - for id, node in objects.iteritems(): - # get the bounding box - x,y,w,h = dimen[id] - if x < minx: - minx = x - if (x + w) > maxx: - maxx = x + w - if y < miny: - miny = y - if (y + h) > maxy: - maxy = y + h - - midx = (minx + maxx) / 2 - midy = (miny + maxy) / 2 - - #calculate distances for each selected object - for id, node in objects.iteritems(): - # get the bounding box - x,y,w,h = dimen[id] - - # calc the comparison coords - if self.options.xanchor == "l": - cx = x - elif self.options.xanchor == "r": - cx = x + w - else: # middle - cx = x + w / 2 - - if self.options.yanchor == "t": - cy = y - elif self.options.yanchor == "b": - cy = y + h - else: # middle - cy = y + h / 2 - - #direction chosen - if self.options.direction == "tb" or (self.options.direction == "aa" and self.options.angle == 270): - objlist.append([cy,id]) - elif self.options.direction == "bt" or (self.options.direction == "aa" and self.options.angle == 90): - objlist.append([-cy,id]) - elif self.options.direction == "lr" or (self.options.direction == "aa" and (self.options.angle == 0 or self.options.angle == 360)): - objlist.append([cx,id]) - elif self.options.direction == "rl" or (self.options.direction == "aa" and self.options.angle == 180): - objlist.append([-cx,id]) - elif self.options.direction == "aa": - distance = math.hypot(cx,cy)*(math.cos(math.radians(-self.options.angle)-math.atan2(cy, cx))) - objlist.append([distance,id]) - elif self.options.direction == "ro": - distance = math.hypot(midx - cx, midy - cy) - objlist.append([distance,id]) - elif self.options.direction == "ri": - distance = -math.hypot(midx - cx, midy - cy) - objlist.append([distance,id]) - - objlist.sort() - #move them to the top of the object stack in this order. - for item in objlist: - parentnode.append( objects[item[1]]) + objects = {} + objlist = [] + file = self.args[ -1 ] + + if self.options.nb_direction == '"custom"': + self.options.direction = "aa" + + # process selection to get list of objects to be arranged + firstobject = self.selected[self.options.ids[0]] + if len(self.selected) == 1 and firstobject.tag == inkex.addNS('g', 'svg'): + parentnode = firstobject + for child in parentnode.iterchildren(): + objects[child.get('id')] = child + else: + parentnode = self.current_layer + objects = self.selected + + #get all bounding boxes in file by calling inkscape again with the --query-all command line option + #it returns a comma separated list structured id,x,y,w,h + if bsubprocess: + p = Popen('inkscape --query-all "%s"' % (file), shell=True, stdout=PIPE, stderr=PIPE) + err = p.stderr + f = p.communicate()[0] + try: + reader=csv.CSVParser().parse_string(f) #there was a module cvs.py in earlier inkscape that behaved differently + except: + reader=csv.reader(f.split( os.linesep )) + err.close() + else: + _,f,err = os.popen3('inkscape --query-all "%s"' % ( file ) ) + reader=csv.reader( f ) + err.close() + + #build a dictionary with id as the key + dimen = dict() + for line in reader: + if len(line) > 0: + dimen[line[0]] = map( float, line[1:]) + + if not bsubprocess: #close file if opened using os.popen3 + f.close + + #find the center of all selected objects **Not the average! + x,y,w,h = dimen[objects.keys()[0]] + minx = x + miny = y + maxx = x + w + maxy = y + h + + for id, node in objects.iteritems(): + # get the bounding box + x,y,w,h = dimen[id] + if x < minx: + minx = x + if (x + w) > maxx: + maxx = x + w + if y < miny: + miny = y + if (y + h) > maxy: + maxy = y + h + + midx = (minx + maxx) / 2 + midy = (miny + maxy) / 2 + + #calculate distances for each selected object + for id, node in objects.iteritems(): + # get the bounding box + x,y,w,h = dimen[id] + + # calc the comparison coords + if self.options.xanchor == "l": + cx = x + elif self.options.xanchor == "r": + cx = x + w + else: # middle + cx = x + w / 2 + + if self.options.yanchor == "t": + cy = y + elif self.options.yanchor == "b": + cy = y + h + else: # middle + cy = y + h / 2 + + #direction chosen + if self.options.direction == "tb" or (self.options.direction == "aa" and self.options.angle == 270): + objlist.append([cy,id]) + elif self.options.direction == "bt" or (self.options.direction == "aa" and self.options.angle == 90): + objlist.append([-cy,id]) + elif self.options.direction == "lr" or (self.options.direction == "aa" and (self.options.angle == 0 or self.options.angle == 360)): + objlist.append([cx,id]) + elif self.options.direction == "rl" or (self.options.direction == "aa" and self.options.angle == 180): + objlist.append([-cx,id]) + elif self.options.direction == "aa": + distance = math.hypot(cx,cy)*(math.cos(math.radians(-self.options.angle)-math.atan2(cy, cx))) + objlist.append([distance,id]) + elif self.options.direction == "ro": + distance = math.hypot(midx - cx, midy - cy) + objlist.append([distance,id]) + elif self.options.direction == "ri": + distance = -math.hypot(midx - cx, midy - cy) + objlist.append([distance,id]) + + objlist.sort() + #move them to the top of the object stack in this order. + for item in objlist: + parentnode.append( objects[item[1]]) def restack_z_order(self): parentnode = None -- cgit v1.2.3 From b85011acb374f9b85fc6def1507747bb4da60c00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20W=C3=BCst?= Date: Sat, 24 Oct 2015 14:42:23 +0200 Subject: Extensions. Fixed 'none' setting in flow control dropdown. Fixes bug #1509580 Fixed bugs: - https://launchpad.net/bugs/1509580 (bzr r14429) --- share/extensions/plotter.inx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'share/extensions') diff --git a/share/extensions/plotter.inx b/share/extensions/plotter.inx index 6a8bfb3d4..c91857b05 100644 --- a/share/extensions/plotter.inx +++ b/share/extensions/plotter.inx @@ -49,7 +49,7 @@ <_item value="xonxoff">Software (XON/XOFF) <_item value="rtscts">Hardware (RTS/CTS) <_item value="dsrdtrrtscts">Hardware (DSR/DTR + RTS/CTS) - <_item msgctxt="Flow control" value="">None + <_item value="none">None <_item value="HPGL">HPGL -- cgit v1.2.3 From 53d5e152527c05fd1f7dd14e83a15ec7d3a3d61c Mon Sep 17 00:00:00 2001 From: Alvin Penner Date: Sat, 31 Oct 2015 08:30:05 -0400 Subject: extensions. dxf input. do not use zero font size (Bug 1510909) Fixed bugs: - https://launchpad.net/bugs/1510909 (bzr r14437) --- share/extensions/dxf_input.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'share/extensions') diff --git a/share/extensions/dxf_input.py b/share/extensions/dxf_input.py index 362f35be9..acfed0921 100755 --- a/share/extensions/dxf_input.py +++ b/share/extensions/dxf_input.py @@ -35,7 +35,7 @@ def export_MTEXT(): y = vals[groups['20']][0] # optional group codes : (21, 40, 50) (direction, text height mm, text angle) size = 12 # default fontsize in px - if vals[groups['40']]: + if vals[groups['40']] and vals[groups['40']][0]: size = scale*vals[groups['40']][0] attribs = {'x': '%f' % x, 'y': '%f' % y, 'style': 'font-size: %.1fpx; fill: %s; font-family: %s' % (size, color, options.font)} angle = 0 # default angle in degrees -- cgit v1.2.3 From e40c7e81cc683c8c937486c4a53f9758752bbbe6 Mon Sep 17 00:00:00 2001 From: Yuri Chornoivan <> Date: Sun, 1 Nov 2015 13:49:27 +0100 Subject: Typo fix (bzr r14439) --- share/extensions/image_attributes.inx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'share/extensions') diff --git a/share/extensions/image_attributes.inx b/share/extensions/image_attributes.inx index a353d17e5..d9ae9cefb 100644 --- a/share/extensions/image_attributes.inx +++ b/share/extensions/image_attributes.inx @@ -14,7 +14,7 @@ <_param name="basic_desc1" type="description">Render all bitmap images like in older Inskcape versions. Available options: - true + true false -- cgit v1.2.3 From 545524ad9caf0e7d1d9a26db699e834317c49eab Mon Sep 17 00:00:00 2001 From: Nicolas Dufour Date: Wed, 2 Dec 2015 12:09:13 +0100 Subject: XAML. Fix for Bug #1521686 (Exported Xaml mistaken due to wrong format number (locale)). Fixed bugs: - https://launchpad.net/bugs/1521686 (bzr r14497) --- share/extensions/svg2xaml.xsl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'share/extensions') diff --git a/share/extensions/svg2xaml.xsl b/share/extensions/svg2xaml.xsl index c384b022f..abc519065 100644 --- a/share/extensions/svg2xaml.xsl +++ b/share/extensions/svg2xaml.xsl @@ -2385,7 +2385,7 @@ exclude-result-prefixes="rdf xlink xs exsl libxslt inkscape"> - + -- cgit v1.2.3