From 4fe67f94f765d19a2c1c94e455ddecb166da30dd Mon Sep 17 00:00:00 2001 From: pjrm Date: Tue, 7 Apr 2009 06:42:09 +0000 Subject: [PATCH] noop: In share/extensions: svn propset svn:eol-style native *.py *.inx In four cases, there were a mix of end-of-line styles. --- share/extensions/dxf_input.py | 680 +++++++++++----------- share/extensions/foldable-box.inx | 18 +- share/extensions/grid_cartesian.inx | 72 +-- share/extensions/grid_polar.inx | 70 +-- share/extensions/guides_creator.inx | 8 +- share/extensions/hpgl_output.py | 96 ++-- share/extensions/polyhedron_3d.inx | 196 +++---- share/extensions/printing-marks.inx | 98 ++-- share/extensions/printing-marks.py | 860 ++++++++++++++-------------- share/extensions/svgcalendar.inx | 274 ++++----- share/extensions/triangle.inx | 54 +- 11 files changed, 1213 insertions(+), 1213 deletions(-) diff --git a/share/extensions/dxf_input.py b/share/extensions/dxf_input.py index 6937825a2..d2e645ea1 100644 --- a/share/extensions/dxf_input.py +++ b/share/extensions/dxf_input.py @@ -1,340 +1,340 @@ -#!/usr/bin/env python -''' -dxf_input.py - input a DXF file >= (AutoCAD Release 13 == AC1012) - -Copyright (C) 2008, 2009 Alvin Penner, penner@vaxxine.com -Copyright (C) 2009 Christian Mayer, inkscape@christianmayer.de -- thanks to Aaron Spike for inkex.py and simplestyle.py -- without which this would not have been possible - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -''' - -import inkex, simplestyle, math -from StringIO import StringIO - -def export_MTEXT(): - # mandatory group codes : (1, 10, 20) (text, x, y) - if vals[groups['1']] and vals[groups['10']] and vals[groups['20']]: - x = vals[groups['10']][0] - y = vals[groups['20']][0] - # optional group codes : (40, 50) (text height mm, text angle) - size = 12 # default fontsize in px - if vals[groups['40']]: - size = scale*vals[groups['40']][0] - attribs = {'x': '%f' % x, 'y': '%f' % y, 'style': 'font-size: %dpx; fill: %s' % (size, color)} - angle = 0 # default angle in degrees - if vals[groups['50']]: - angle = vals[groups['50']][0] - attribs.update({'transform': 'rotate (%f %f %f)' % (-angle, x, y)}) - attribs.update({inkex.addNS('linespacing','sodipodi'): '125%'}) - node = inkex.etree.SubElement(layer, 'text', attribs) - text = vals[groups['1']][0] - found = text.find('\P') # new line - while found > -1: - tspan = inkex.etree.SubElement(node , 'tspan', {inkex.addNS('role','sodipodi'): 'line'}) - tspan.text = text[:found] - text = text[(found+2):] - found = text.find('\P') - tspan = inkex.etree.SubElement(node , 'tspan', {inkex.addNS('role','sodipodi'): 'line'}) - tspan.text = text - -def export_POINT(): - # mandatory group codes : (10, 20) (x, y) - if vals[groups['10']] and vals[groups['20']]: - generate_ellipse(vals[groups['10']][0], vals[groups['20']][0], w/2, 0.0, 1.0, 0.0, 0.0) - -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), - scale*(vals[groups['21']][0] - ymax)) - attribs = {'d': path, 'style': style} - inkex.etree.SubElement(layer, 'path', attribs) - -def export_SPLINE(): - # mandatory group codes : (10, 20, 70) (x, y, flags) - if vals[groups['10']] and vals[groups['20']] and vals[groups['70']]: - if not (vals[groups['70']][0] & 3) and len(vals[groups['10']]) == 4 and len(vals[groups['20']]) == 4: - path = 'M %f,%f C %f,%f %f,%f %f,%f' % (vals[groups['10']][0], vals[groups['20']][0], vals[groups['10']][1], vals[groups['20']][1], vals[groups['10']][2], vals[groups['20']][2], vals[groups['10']][3], vals[groups['20']][3]) - attribs = {'d': path, 'style': style} - inkex.etree.SubElement(layer, 'path', attribs) - if not (vals[groups['70']][0] & 3) and len(vals[groups['10']]) == 3 and len(vals[groups['20']]) == 3: - path = 'M %f,%f Q %f,%f %f,%f' % (vals[groups['10']][0], vals[groups['20']][0], vals[groups['10']][1], vals[groups['20']][1], vals[groups['10']][2], vals[groups['20']][2]) - attribs = {'d': path, 'style': style} - inkex.etree.SubElement(layer, 'path', attribs) - -def export_CIRCLE(): - # mandatory group codes : (10, 20, 40) (x, y, radius) - if vals[groups['10']] and vals[groups['20']] and vals[groups['40']]: - generate_ellipse(vals[groups['10']][0], vals[groups['20']][0], scale*vals[groups['40']][0], 0.0, 1.0, 0.0, 0.0) - -def export_ARC(): - # mandatory group codes : (10, 20, 40, 50, 51) (x, y, radius, angle1, angle2) - if vals[groups['10']] and vals[groups['20']] and vals[groups['40']] and vals[groups['50']] and vals[groups['51']]: - generate_ellipse(vals[groups['10']][0], vals[groups['20']][0], scale*vals[groups['40']][0], 0.0, 1.0, vals[groups['50']][0]*math.pi/180.0, vals[groups['51']][0]*math.pi/180.0) - -def export_ELLIPSE(): - # mandatory group codes : (10, 11, 20, 21, 40, 41, 42) (xc, xm, yc, ym, width ratio, angle1, angle2) - if vals[groups['10']] and vals[groups['11']] and vals[groups['20']] and vals[groups['21']] and vals[groups['40']] and vals[groups['41']] and vals[groups['42']]: - generate_ellipse(vals[groups['10']][0], vals[groups['20']][0], scale*vals[groups['11']][0], scale*vals[groups['21']][0], vals[groups['40']][0], vals[groups['41']][0], vals[groups['42']][0]) - -def export_LEADER(): - # mandatory group codes : (10, 20) (x, y) - if vals[groups['10']] and vals[groups['20']]: - if len(vals[groups['10']]) > 1 and len(vals[groups['20']]) == len(vals[groups['10']]): - path = 'M %f,%f' % (vals[groups['10']][0], vals[groups['20']][0]) - for i in range (1, len(vals[groups['10']])): - path += ' %f,%f' % (vals[groups['10']][i], vals[groups['20']][i]) - attribs = {'d': path, 'style': style} - inkex.etree.SubElement(layer, 'path', attribs) - -def export_LWPOLYLINE(): - # mandatory group codes : (10, 20, 70) (x, y, flags) - if vals[groups['10']] and vals[groups['20']] and vals[groups['70']]: - if len(vals[groups['10']]) > 1 and len(vals[groups['20']]) == len(vals[groups['10']]): - # optional group codes : (42) (bulge) - iseqs = 0 - ibulge = 0 - while seqs[iseqs] != '20': - iseqs += 1 - path = 'M %f,%f' % (vals[groups['10']][0], vals[groups['20']][0]) - xold = vals[groups['10']][0] - yold = vals[groups['20']][0] - for i in range (1, len(vals[groups['10']])): - bulge = 0 - iseqs += 1 - while seqs[iseqs] != '20': - if seqs[iseqs] == '42': - bulge = vals[groups['42']][ibulge] - ibulge += 1 - iseqs += 1 - if bulge: - sweep = 0 # sweep CCW - if bulge < 0: - sweep = 1 # sweep CW - bulge = -bulge - large = 0 # large-arc-flag - if bulge > 1: - large = 1 - r = math.sqrt((vals[groups['10']][i] - xold)**2 + (vals[groups['20']][i] - yold)**2) - r = 0.25*r*(bulge + 1.0/bulge) - path += ' A %f,%f 0.0 %d %d %f,%f' % (r, r, large, sweep, vals[groups['10']][i], vals[groups['20']][i]) - else: - path += ' L %f,%f' % (vals[groups['10']][i], vals[groups['20']][i]) - xold = vals[groups['10']][i] - yold = vals[groups['20']][i] - if vals[groups['70']][0] == 1: # closed path - path += ' z' - attribs = {'d': path, 'style': style} - inkex.etree.SubElement(layer, 'path', attribs) - -def export_HATCH(): - # mandatory group codes : (10, 20, 72, 93) (x, y, Edge Type, Number of edges) - if vals[groups['10']] and vals[groups['20']] and vals[groups['72']] and vals[groups['93']]: - if len(vals[groups['10']]) > 1 and len(vals[groups['20']]) == len(vals[groups['10']]): - # optional group codes : (11, 21, 40, 50, 51, 73) (x, y, r, angle1, angle2, CCW) - i10 = 1 # count start points - i11 = 0 # count line end points - i40 = 0 # count circles - i72 = 0 # count edge type flags - path = '' - for i in range (0, len(vals[groups['93']])): - xc = vals[groups['10']][i10] - yc = vals[groups['20']][i10] - if vals[groups['72']][i72] == 2: # arc - rm = scale*vals[groups['40']][i40] - a1 = vals[groups['50']][i40] - path += 'M %f,%f ' % (xc + rm*math.cos(a1*math.pi/180.0), yc + rm*math.sin(a1*math.pi/180.0)) - else: - a1 = 0 - path += 'M %f,%f ' % (xc, yc) - for j in range(0, vals[groups['93']][i]): - if vals[groups['72']][i72] == 2: # arc - xc = vals[groups['10']][i10] - yc = vals[groups['20']][i10] - rm = scale*vals[groups['40']][i40] - a2 = vals[groups['51']][i40] - diff = (a2 - a1 + 360) % (360) - sweep = 1 - vals[groups['73']][i40] # sweep CCW - large = 0 # large-arc-flag - if diff: - path += 'A %f,%f 0.0 %d %d %f,%f ' % (rm, rm, large, sweep, xc + rm*math.cos(a2*math.pi/180.0), yc + rm*math.sin(a2*math.pi/180.0)) - else: - path += 'A %f,%f 0.0 %d %d %f,%f ' % (rm, rm, large, sweep, xc + rm*math.cos((a1+180.0)*math.pi/180.0), yc + rm*math.sin((a1+180.0)*math.pi/180.0)) - path += 'A %f,%f 0.0 %d %d %f,%f ' % (rm, rm, large, sweep, xc + rm*math.cos(a1*math.pi/180.0), yc + rm*math.sin(a1*math.pi/180.0)) - i40 += 1 - i72 += 1 - elif vals[groups['72']][i72] == 1: # line - path += 'L %f,%f ' % (scale*(vals[groups['11']][i11] - xmin), -scale*(vals[groups['21']][i11] - ymax)) - i11 += 1 - i72 += 1 - elif vals[groups['72']][i72] == 0: # polyline - if j > 0: - path += 'L %f,%f ' % (vals[groups['10']][i10], vals[groups['20']][i10]) - if j == vals[groups['93']][i] - 1: - i72 += 1 - i10 += 1 - path += "z " - style = simplestyle.formatStyle({'fill': '%s' % color}) - attribs = {'d': path, 'style': style} - inkex.etree.SubElement(layer, 'path', attribs) - -def export_DIMENSION(): - # mandatory group codes : (10, 11, 13, 14, 20, 21, 23, 24) (x1..4, y1..4) - if vals[groups['10']] and vals[groups['11']] and vals[groups['13']] and vals[groups['14']] and vals[groups['20']] and vals[groups['21']] and vals[groups['23']] and vals[groups['24']]: - dx = abs(vals[groups['10']][0] - vals[groups['13']][0]) - dy = abs(vals[groups['20']][0] - vals[groups['23']][0]) - if (vals[groups['10']][0] == vals[groups['14']][0]) and dx > 0.00001: - d = dx/scale - dy = 0 - path = 'M %f,%f %f,%f' % (vals[groups['10']][0], vals[groups['20']][0], vals[groups['13']][0], vals[groups['20']][0]) - elif (vals[groups['20']][0] == vals[groups['24']][0]) and dy > 0.00001: - d = dy/scale - dx = 0 - path = 'M %f,%f %f,%f' % (vals[groups['10']][0], vals[groups['20']][0], vals[groups['10']][0], vals[groups['23']][0]) - else: - return - attribs = {'d': path, 'style': style + '; marker-start: url(#DistanceX); marker-end: url(#DistanceX)'} - inkex.etree.SubElement(layer, 'path', attribs) - x = scale*(vals[groups['11']][0] - xmin) - y = - scale*(vals[groups['21']][0] - ymax) - size = 3 # default fontsize in px - attribs = {'x': '%f' % x, 'y': '%f' % y, 'style': 'font-size: %dpx; fill: %s' % (size, color)} - if dx == 0: - attribs.update({'transform': 'rotate (%f %f %f)' % (-90, x, y)}) - node = inkex.etree.SubElement(layer, 'text', attribs) - tspan = inkex.etree.SubElement(node , 'tspan', {inkex.addNS('role','sodipodi'): 'line'}) - tspan.text = '%.2f' % d - -def generate_ellipse(xc, yc, xm, ym, w, a1, a2): - rm = math.sqrt(xm*xm + ym*ym) - a = math.atan2(ym, xm) - diff = (a2 - a1 + 2*math.pi) % (2*math.pi) - if diff: # open arc - large = 0 # large-arc-flag - if diff > math.pi: - large = 1 - xt = rm*math.cos(a1) - yt = w*rm*math.sin(a1) - x1 = xt*math.cos(a) - yt*math.sin(a) - y1 = xt*math.sin(a) + yt*math.cos(a) - xt = rm*math.cos(a2) - yt = w*rm*math.sin(a2) - x2 = xt*math.cos(a) - yt*math.sin(a) - y2 = xt*math.sin(a) + yt*math.cos(a) - path = 'M %f,%f A %f,%f %f %d 0 %f,%f' % (xc+x1, yc-y1, rm, w*rm, -180.0*a/math.pi, large, xc+x2, yc-y2) - else: # closed arc - path = 'M %f,%f A %f,%f %f 1 0 %f,%f %f,%f %f 1 0 %f,%f z' % (xc+xm, yc-ym, rm, w*rm, -180.0*a/math.pi, xc-xm, yc+ym, rm, w*rm, -180.0*a/math.pi, xc+xm, yc-ym) - attribs = {'d': path, 'style': style} - inkex.etree.SubElement(layer, 'path', attribs) - -def get_line(): - return (stream.readline().strip(), stream.readline().strip()) - -def get_group(group): - line = get_line() - if line[0] == group: - return float(line[1]) - else: - return 0.0 - -# 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, 'ENDSEC': ''} -groups = {'1': 0, '8': 1, '10': 2, '11': 3, '13': 4, '14': 5, '20': 6, '21': 7, '23': 8, '24': 9, '40': 10, '41': 11, '42': 12, '50': 13, '51': 14, '62': 15, '70': 16, '72': 17, '73': 18, '93': 19, '370': 20} -colors = { 1: '#FF0000', 2: '#FFFF00', 3: '#00FF00', 4: '#00FFFF', 5: '#0000FF', - 6: '#FF00FF', 8: '#414141', 9: '#808080', 30: '#FF7F00', - 250: '#333333', 251: '#505050', 252: '#696969', 253: '#828282', 254: '#BEBEBE', 255: '#FFFFFF'} - -doc = inkex.etree.parse(StringIO('')) -defs = inkex.etree.SubElement(doc.getroot(), 'defs', {} ) -marker = inkex.etree.SubElement(defs, 'marker', {'id': 'DistanceX', 'orient': 'auto', 'refX': '0.0', 'refY': '0.0', 'style': 'overflow:visible'}) -inkex.etree.SubElement(marker, 'path', {'d': 'M 3,-3 L -3,3 M 0,-5 L 0,5', 'style': 'stroke:#000000; stroke-width:0.5'}) -stream = open(inkex.sys.argv[1], 'r') -xmax = xmin = 0.0 -ymax = 297.0 # default A4 height in mm -line = get_line() -flag = 0 -layer_colors = {} # store colors by layer -layer_nodes = {} # store nodes by layer -while line[0] and line[1] != 'ENTITIES': - line = get_line() - if line[1] == '$EXTMIN': - xmin = get_group('10') - if line[1] == '$EXTMAX': - xmax = get_group('10') - ymax = get_group('20') - if flag and line[0] == '2': - name = unicode(line[1], "iso-8859-1") - attribs = {inkex.addNS('groupmode','inkscape'): 'layer', inkex.addNS('label','inkscape'): '%s' % name} - layer_nodes[name] = inkex.etree.SubElement(doc.getroot(), 'g', attribs) - if line[0] == '2' and line[1] == 'LAYER': - flag = 1 - if flag and line[0] == '62': - layer_colors[name] = int(line[1]) - if line[0] == '0' and line[1] == 'ENDTAB': - flag = 0 - -scale = 90.0/25.4 # default convert from mm to pixels -if xmax > xmin: - scale *= 210.0/(xmax - xmin) # scale to A4 width -entity = '' -while line[0] and line[1] != 'ENDSEC': - line = get_line() - if entity and groups.has_key(line[0]): - seqs.append(line[0]) # list of group codes - if line[0] == '1' or line[0] == '8': # text value - val = line[1].replace('\~', ' ') - val = inkex.re.sub( '\\\\A.*;', '', val) - val = inkex.re.sub( '\\\\H.*;', '', val) - val = inkex.re.sub( '\\\\S.*;', '', val) - val = inkex.re.sub( '\\\\W.*;', '', val) - val = unicode(val, "iso-8859-1") - elif line[0] == '62' or line[0] == '70' 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 = - scale*(float(line[1]) - ymax) - else: # unscaled float value - val = float(line[1]) - vals[groups[line[0]]].append(val) - elif entities.has_key(line[1]): - if entities.has_key(entity): - color = '#000000' # default color - if vals[groups['8']]: # Common Layer Name - layer = layer_nodes[vals[groups['8']][0]] - if layer_colors.has_key(vals[groups['8']][0]): - if colors.has_key(layer_colors[vals[groups['8']][0]]): - color = colors[layer_colors[vals[groups['8']][0]]] - if vals[groups['62']]: # Common Color Number - if colors.has_key(vals[groups['62']][0]): - color = colors[vals[groups['62']][0]] - style = simplestyle.formatStyle({'stroke': '%s' % color, 'fill': 'none'}) - w = 0.5 # default lineweight for POINT - if vals[groups['370']]: # Common Lineweight - if vals[groups['370']][0] > 0: - w = 90.0/25.4*vals[groups['370']][0]/100.0 - if w < 0.5: - w = 0.5 - style = simplestyle.formatStyle({'stroke': '%s' % color, 'fill': 'none', 'stroke-width': '%.1f' % w}) - entities[entity]() - entity = line[1] - vals = [[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[]] - seqs = [] - -doc.write(inkex.sys.stdout) - -# vim: expandtab shiftwidth=4 tabstop=8 softtabstop=4 encoding=utf-8 textwidth=99 +#!/usr/bin/env python +''' +dxf_input.py - input a DXF file >= (AutoCAD Release 13 == AC1012) + +Copyright (C) 2008, 2009 Alvin Penner, penner@vaxxine.com +Copyright (C) 2009 Christian Mayer, inkscape@christianmayer.de +- thanks to Aaron Spike for inkex.py and simplestyle.py +- without which this would not have been possible + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +''' + +import inkex, simplestyle, math +from StringIO import StringIO + +def export_MTEXT(): + # mandatory group codes : (1, 10, 20) (text, x, y) + if vals[groups['1']] and vals[groups['10']] and vals[groups['20']]: + x = vals[groups['10']][0] + y = vals[groups['20']][0] + # optional group codes : (40, 50) (text height mm, text angle) + size = 12 # default fontsize in px + if vals[groups['40']]: + size = scale*vals[groups['40']][0] + attribs = {'x': '%f' % x, 'y': '%f' % y, 'style': 'font-size: %dpx; fill: %s' % (size, color)} + angle = 0 # default angle in degrees + if vals[groups['50']]: + angle = vals[groups['50']][0] + attribs.update({'transform': 'rotate (%f %f %f)' % (-angle, x, y)}) + attribs.update({inkex.addNS('linespacing','sodipodi'): '125%'}) + node = inkex.etree.SubElement(layer, 'text', attribs) + text = vals[groups['1']][0] + found = text.find('\P') # new line + while found > -1: + tspan = inkex.etree.SubElement(node , 'tspan', {inkex.addNS('role','sodipodi'): 'line'}) + tspan.text = text[:found] + text = text[(found+2):] + found = text.find('\P') + tspan = inkex.etree.SubElement(node , 'tspan', {inkex.addNS('role','sodipodi'): 'line'}) + tspan.text = text + +def export_POINT(): + # mandatory group codes : (10, 20) (x, y) + if vals[groups['10']] and vals[groups['20']]: + generate_ellipse(vals[groups['10']][0], vals[groups['20']][0], w/2, 0.0, 1.0, 0.0, 0.0) + +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), - scale*(vals[groups['21']][0] - ymax)) + attribs = {'d': path, 'style': style} + inkex.etree.SubElement(layer, 'path', attribs) + +def export_SPLINE(): + # mandatory group codes : (10, 20, 70) (x, y, flags) + if vals[groups['10']] and vals[groups['20']] and vals[groups['70']]: + if not (vals[groups['70']][0] & 3) and len(vals[groups['10']]) == 4 and len(vals[groups['20']]) == 4: + path = 'M %f,%f C %f,%f %f,%f %f,%f' % (vals[groups['10']][0], vals[groups['20']][0], vals[groups['10']][1], vals[groups['20']][1], vals[groups['10']][2], vals[groups['20']][2], vals[groups['10']][3], vals[groups['20']][3]) + attribs = {'d': path, 'style': style} + inkex.etree.SubElement(layer, 'path', attribs) + if not (vals[groups['70']][0] & 3) and len(vals[groups['10']]) == 3 and len(vals[groups['20']]) == 3: + path = 'M %f,%f Q %f,%f %f,%f' % (vals[groups['10']][0], vals[groups['20']][0], vals[groups['10']][1], vals[groups['20']][1], vals[groups['10']][2], vals[groups['20']][2]) + attribs = {'d': path, 'style': style} + inkex.etree.SubElement(layer, 'path', attribs) + +def export_CIRCLE(): + # mandatory group codes : (10, 20, 40) (x, y, radius) + if vals[groups['10']] and vals[groups['20']] and vals[groups['40']]: + generate_ellipse(vals[groups['10']][0], vals[groups['20']][0], scale*vals[groups['40']][0], 0.0, 1.0, 0.0, 0.0) + +def export_ARC(): + # mandatory group codes : (10, 20, 40, 50, 51) (x, y, radius, angle1, angle2) + if vals[groups['10']] and vals[groups['20']] and vals[groups['40']] and vals[groups['50']] and vals[groups['51']]: + generate_ellipse(vals[groups['10']][0], vals[groups['20']][0], scale*vals[groups['40']][0], 0.0, 1.0, vals[groups['50']][0]*math.pi/180.0, vals[groups['51']][0]*math.pi/180.0) + +def export_ELLIPSE(): + # mandatory group codes : (10, 11, 20, 21, 40, 41, 42) (xc, xm, yc, ym, width ratio, angle1, angle2) + if vals[groups['10']] and vals[groups['11']] and vals[groups['20']] and vals[groups['21']] and vals[groups['40']] and vals[groups['41']] and vals[groups['42']]: + generate_ellipse(vals[groups['10']][0], vals[groups['20']][0], scale*vals[groups['11']][0], scale*vals[groups['21']][0], vals[groups['40']][0], vals[groups['41']][0], vals[groups['42']][0]) + +def export_LEADER(): + # mandatory group codes : (10, 20) (x, y) + if vals[groups['10']] and vals[groups['20']]: + if len(vals[groups['10']]) > 1 and len(vals[groups['20']]) == len(vals[groups['10']]): + path = 'M %f,%f' % (vals[groups['10']][0], vals[groups['20']][0]) + for i in range (1, len(vals[groups['10']])): + path += ' %f,%f' % (vals[groups['10']][i], vals[groups['20']][i]) + attribs = {'d': path, 'style': style} + inkex.etree.SubElement(layer, 'path', attribs) + +def export_LWPOLYLINE(): + # mandatory group codes : (10, 20, 70) (x, y, flags) + if vals[groups['10']] and vals[groups['20']] and vals[groups['70']]: + if len(vals[groups['10']]) > 1 and len(vals[groups['20']]) == len(vals[groups['10']]): + # optional group codes : (42) (bulge) + iseqs = 0 + ibulge = 0 + while seqs[iseqs] != '20': + iseqs += 1 + path = 'M %f,%f' % (vals[groups['10']][0], vals[groups['20']][0]) + xold = vals[groups['10']][0] + yold = vals[groups['20']][0] + for i in range (1, len(vals[groups['10']])): + bulge = 0 + iseqs += 1 + while seqs[iseqs] != '20': + if seqs[iseqs] == '42': + bulge = vals[groups['42']][ibulge] + ibulge += 1 + iseqs += 1 + if bulge: + sweep = 0 # sweep CCW + if bulge < 0: + sweep = 1 # sweep CW + bulge = -bulge + large = 0 # large-arc-flag + if bulge > 1: + large = 1 + r = math.sqrt((vals[groups['10']][i] - xold)**2 + (vals[groups['20']][i] - yold)**2) + r = 0.25*r*(bulge + 1.0/bulge) + path += ' A %f,%f 0.0 %d %d %f,%f' % (r, r, large, sweep, vals[groups['10']][i], vals[groups['20']][i]) + else: + path += ' L %f,%f' % (vals[groups['10']][i], vals[groups['20']][i]) + xold = vals[groups['10']][i] + yold = vals[groups['20']][i] + if vals[groups['70']][0] == 1: # closed path + path += ' z' + attribs = {'d': path, 'style': style} + inkex.etree.SubElement(layer, 'path', attribs) + +def export_HATCH(): + # mandatory group codes : (10, 20, 72, 93) (x, y, Edge Type, Number of edges) + if vals[groups['10']] and vals[groups['20']] and vals[groups['72']] and vals[groups['93']]: + if len(vals[groups['10']]) > 1 and len(vals[groups['20']]) == len(vals[groups['10']]): + # optional group codes : (11, 21, 40, 50, 51, 73) (x, y, r, angle1, angle2, CCW) + i10 = 1 # count start points + i11 = 0 # count line end points + i40 = 0 # count circles + i72 = 0 # count edge type flags + path = '' + for i in range (0, len(vals[groups['93']])): + xc = vals[groups['10']][i10] + yc = vals[groups['20']][i10] + if vals[groups['72']][i72] == 2: # arc + rm = scale*vals[groups['40']][i40] + a1 = vals[groups['50']][i40] + path += 'M %f,%f ' % (xc + rm*math.cos(a1*math.pi/180.0), yc + rm*math.sin(a1*math.pi/180.0)) + else: + a1 = 0 + path += 'M %f,%f ' % (xc, yc) + for j in range(0, vals[groups['93']][i]): + if vals[groups['72']][i72] == 2: # arc + xc = vals[groups['10']][i10] + yc = vals[groups['20']][i10] + rm = scale*vals[groups['40']][i40] + a2 = vals[groups['51']][i40] + diff = (a2 - a1 + 360) % (360) + sweep = 1 - vals[groups['73']][i40] # sweep CCW + large = 0 # large-arc-flag + if diff: + path += 'A %f,%f 0.0 %d %d %f,%f ' % (rm, rm, large, sweep, xc + rm*math.cos(a2*math.pi/180.0), yc + rm*math.sin(a2*math.pi/180.0)) + else: + path += 'A %f,%f 0.0 %d %d %f,%f ' % (rm, rm, large, sweep, xc + rm*math.cos((a1+180.0)*math.pi/180.0), yc + rm*math.sin((a1+180.0)*math.pi/180.0)) + path += 'A %f,%f 0.0 %d %d %f,%f ' % (rm, rm, large, sweep, xc + rm*math.cos(a1*math.pi/180.0), yc + rm*math.sin(a1*math.pi/180.0)) + i40 += 1 + i72 += 1 + elif vals[groups['72']][i72] == 1: # line + path += 'L %f,%f ' % (scale*(vals[groups['11']][i11] - xmin), -scale*(vals[groups['21']][i11] - ymax)) + i11 += 1 + i72 += 1 + elif vals[groups['72']][i72] == 0: # polyline + if j > 0: + path += 'L %f,%f ' % (vals[groups['10']][i10], vals[groups['20']][i10]) + if j == vals[groups['93']][i] - 1: + i72 += 1 + i10 += 1 + path += "z " + style = simplestyle.formatStyle({'fill': '%s' % color}) + attribs = {'d': path, 'style': style} + inkex.etree.SubElement(layer, 'path', attribs) + +def export_DIMENSION(): + # mandatory group codes : (10, 11, 13, 14, 20, 21, 23, 24) (x1..4, y1..4) + if vals[groups['10']] and vals[groups['11']] and vals[groups['13']] and vals[groups['14']] and vals[groups['20']] and vals[groups['21']] and vals[groups['23']] and vals[groups['24']]: + dx = abs(vals[groups['10']][0] - vals[groups['13']][0]) + dy = abs(vals[groups['20']][0] - vals[groups['23']][0]) + if (vals[groups['10']][0] == vals[groups['14']][0]) and dx > 0.00001: + d = dx/scale + dy = 0 + path = 'M %f,%f %f,%f' % (vals[groups['10']][0], vals[groups['20']][0], vals[groups['13']][0], vals[groups['20']][0]) + elif (vals[groups['20']][0] == vals[groups['24']][0]) and dy > 0.00001: + d = dy/scale + dx = 0 + path = 'M %f,%f %f,%f' % (vals[groups['10']][0], vals[groups['20']][0], vals[groups['10']][0], vals[groups['23']][0]) + else: + return + attribs = {'d': path, 'style': style + '; marker-start: url(#DistanceX); marker-end: url(#DistanceX)'} + inkex.etree.SubElement(layer, 'path', attribs) + x = scale*(vals[groups['11']][0] - xmin) + y = - scale*(vals[groups['21']][0] - ymax) + size = 3 # default fontsize in px + attribs = {'x': '%f' % x, 'y': '%f' % y, 'style': 'font-size: %dpx; fill: %s' % (size, color)} + if dx == 0: + attribs.update({'transform': 'rotate (%f %f %f)' % (-90, x, y)}) + node = inkex.etree.SubElement(layer, 'text', attribs) + tspan = inkex.etree.SubElement(node , 'tspan', {inkex.addNS('role','sodipodi'): 'line'}) + tspan.text = '%.2f' % d + +def generate_ellipse(xc, yc, xm, ym, w, a1, a2): + rm = math.sqrt(xm*xm + ym*ym) + a = math.atan2(ym, xm) + diff = (a2 - a1 + 2*math.pi) % (2*math.pi) + if diff: # open arc + large = 0 # large-arc-flag + if diff > math.pi: + large = 1 + xt = rm*math.cos(a1) + yt = w*rm*math.sin(a1) + x1 = xt*math.cos(a) - yt*math.sin(a) + y1 = xt*math.sin(a) + yt*math.cos(a) + xt = rm*math.cos(a2) + yt = w*rm*math.sin(a2) + x2 = xt*math.cos(a) - yt*math.sin(a) + y2 = xt*math.sin(a) + yt*math.cos(a) + path = 'M %f,%f A %f,%f %f %d 0 %f,%f' % (xc+x1, yc-y1, rm, w*rm, -180.0*a/math.pi, large, xc+x2, yc-y2) + else: # closed arc + path = 'M %f,%f A %f,%f %f 1 0 %f,%f %f,%f %f 1 0 %f,%f z' % (xc+xm, yc-ym, rm, w*rm, -180.0*a/math.pi, xc-xm, yc+ym, rm, w*rm, -180.0*a/math.pi, xc+xm, yc-ym) + attribs = {'d': path, 'style': style} + inkex.etree.SubElement(layer, 'path', attribs) + +def get_line(): + return (stream.readline().strip(), stream.readline().strip()) + +def get_group(group): + line = get_line() + if line[0] == group: + return float(line[1]) + else: + return 0.0 + +# 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, 'ENDSEC': ''} +groups = {'1': 0, '8': 1, '10': 2, '11': 3, '13': 4, '14': 5, '20': 6, '21': 7, '23': 8, '24': 9, '40': 10, '41': 11, '42': 12, '50': 13, '51': 14, '62': 15, '70': 16, '72': 17, '73': 18, '93': 19, '370': 20} +colors = { 1: '#FF0000', 2: '#FFFF00', 3: '#00FF00', 4: '#00FFFF', 5: '#0000FF', + 6: '#FF00FF', 8: '#414141', 9: '#808080', 30: '#FF7F00', + 250: '#333333', 251: '#505050', 252: '#696969', 253: '#828282', 254: '#BEBEBE', 255: '#FFFFFF'} + +doc = inkex.etree.parse(StringIO('')) +defs = inkex.etree.SubElement(doc.getroot(), 'defs', {} ) +marker = inkex.etree.SubElement(defs, 'marker', {'id': 'DistanceX', 'orient': 'auto', 'refX': '0.0', 'refY': '0.0', 'style': 'overflow:visible'}) +inkex.etree.SubElement(marker, 'path', {'d': 'M 3,-3 L -3,3 M 0,-5 L 0,5', 'style': 'stroke:#000000; stroke-width:0.5'}) +stream = open(inkex.sys.argv[1], 'r') +xmax = xmin = 0.0 +ymax = 297.0 # default A4 height in mm +line = get_line() +flag = 0 +layer_colors = {} # store colors by layer +layer_nodes = {} # store nodes by layer +while line[0] and line[1] != 'ENTITIES': + line = get_line() + if line[1] == '$EXTMIN': + xmin = get_group('10') + if line[1] == '$EXTMAX': + xmax = get_group('10') + ymax = get_group('20') + if flag and line[0] == '2': + name = unicode(line[1], "iso-8859-1") + attribs = {inkex.addNS('groupmode','inkscape'): 'layer', inkex.addNS('label','inkscape'): '%s' % name} + layer_nodes[name] = inkex.etree.SubElement(doc.getroot(), 'g', attribs) + if line[0] == '2' and line[1] == 'LAYER': + flag = 1 + if flag and line[0] == '62': + layer_colors[name] = int(line[1]) + if line[0] == '0' and line[1] == 'ENDTAB': + flag = 0 + +scale = 90.0/25.4 # default convert from mm to pixels +if xmax > xmin: + scale *= 210.0/(xmax - xmin) # scale to A4 width +entity = '' +while line[0] and line[1] != 'ENDSEC': + line = get_line() + if entity and groups.has_key(line[0]): + seqs.append(line[0]) # list of group codes + if line[0] == '1' or line[0] == '8': # text value + val = line[1].replace('\~', ' ') + val = inkex.re.sub( '\\\\A.*;', '', val) + val = inkex.re.sub( '\\\\H.*;', '', val) + val = inkex.re.sub( '\\\\S.*;', '', val) + val = inkex.re.sub( '\\\\W.*;', '', val) + val = unicode(val, "iso-8859-1") + elif line[0] == '62' or line[0] == '70' 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 = - scale*(float(line[1]) - ymax) + else: # unscaled float value + val = float(line[1]) + vals[groups[line[0]]].append(val) + elif entities.has_key(line[1]): + if entities.has_key(entity): + color = '#000000' # default color + if vals[groups['8']]: # Common Layer Name + layer = layer_nodes[vals[groups['8']][0]] + if layer_colors.has_key(vals[groups['8']][0]): + if colors.has_key(layer_colors[vals[groups['8']][0]]): + color = colors[layer_colors[vals[groups['8']][0]]] + if vals[groups['62']]: # Common Color Number + if colors.has_key(vals[groups['62']][0]): + color = colors[vals[groups['62']][0]] + style = simplestyle.formatStyle({'stroke': '%s' % color, 'fill': 'none'}) + w = 0.5 # default lineweight for POINT + if vals[groups['370']]: # Common Lineweight + if vals[groups['370']][0] > 0: + w = 90.0/25.4*vals[groups['370']][0]/100.0 + if w < 0.5: + w = 0.5 + style = simplestyle.formatStyle({'stroke': '%s' % color, 'fill': 'none', 'stroke-width': '%.1f' % w}) + entities[entity]() + entity = line[1] + vals = [[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[]] + seqs = [] + +doc.write(inkex.sys.stdout) + +# vim: expandtab shiftwidth=4 tabstop=8 softtabstop=4 encoding=utf-8 textwidth=99 diff --git a/share/extensions/foldable-box.inx b/share/extensions/foldable-box.inx index 356947317..e53bc8b74 100644 --- a/share/extensions/foldable-box.inx +++ b/share/extensions/foldable-box.inx @@ -1,7 +1,7 @@ <_name>Foldable Box - org.inkscape.render.foldable-box + org.inkscape.render.foldable-box foldable-box.py inkex.py 10.0 @@ -9,14 +9,14 @@ 3.0 0.01 0.6 - - px - pt - in - cm - mm - - true + + px + pt + in + cm + mm + + true all diff --git a/share/extensions/grid_cartesian.inx b/share/extensions/grid_cartesian.inx index 576d131a9..ecec105de 100644 --- a/share/extensions/grid_cartesian.inx +++ b/share/extensions/grid_cartesian.inx @@ -1,36 +1,36 @@ - - - <_name>Cartesian Grid - grid.cartesian - grid_cartesian.py - inkex.py - 6 - 100.0 - 2 - false - 5 - 4 - 2 - 1 - 0.3 - 5 - 100.0 - 1 - false - 5 - 4 - 2 - 1 - 0.3 - 3 - - - all - - - - - - + + + <_name>Cartesian Grid + grid.cartesian + grid_cartesian.py + inkex.py + 6 + 100.0 + 2 + false + 5 + 4 + 2 + 1 + 0.3 + 5 + 100.0 + 1 + false + 5 + 4 + 2 + 1 + 0.3 + 3 + + + all + + + + + + diff --git a/share/extensions/grid_polar.inx b/share/extensions/grid_polar.inx index fa4098bf4..ec73681fa 100644 --- a/share/extensions/grid_polar.inx +++ b/share/extensions/grid_polar.inx @@ -1,35 +1,35 @@ - - - <_name>Polar Grid - grids.polar - grid_polar.py - inkex.py - 5 - 50.0 - 3 - false - 2 - 1 - 24 - 4 - 1 - 2 - 2 - 1 - 5.0 - - <_option value="none">None - <_option value="deg">Degrees - 18 - 24 - - - all - - - - - - + + + <_name>Polar Grid + grids.polar + grid_polar.py + inkex.py + 5 + 50.0 + 3 + false + 2 + 1 + 24 + 4 + 1 + 2 + 2 + 1 + 5.0 + + <_option value="none">None + <_option value="deg">Degrees + 18 + 24 + + + all + + + + + + diff --git a/share/extensions/guides_creator.inx b/share/extensions/guides_creator.inx index 1ec0a6584..23fed9d56 100644 --- a/share/extensions/guides_creator.inx +++ b/share/extensions/guides_creator.inx @@ -12,24 +12,24 @@ <_option value="0">None <_option value="2">1/2 - <_option value="3">1/3 + <_option value="3">1/3 <_option value="4">1/4 <_option value="5">1/5 <_option value="6">1/6 <_option value="7">1/7 - <_option value="8">1/8 + <_option value="8">1/8 <_option value="9">1/9 <_option value="10">1/10 <_option value="0">None <_option value="2">1/2 - <_option value="3">1/3 + <_option value="3">1/3 <_option value="4">1/4 <_option value="5">1/5 <_option value="6">1/6 <_option value="7">1/7 - <_option value="8">1/8 + <_option value="8">1/8 <_option value="9">1/9 <_option value="10">1/10 diff --git a/share/extensions/hpgl_output.py b/share/extensions/hpgl_output.py index f327df2f9..306fc0e8b 100644 --- a/share/extensions/hpgl_output.py +++ b/share/extensions/hpgl_output.py @@ -1,48 +1,48 @@ -#!/usr/bin/env python -''' -Copyright (C) 2008 Aaron Spike, aaron@ekips.org - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -''' -import inkex, cubicsuperpath, simplepath, cspsubdiv - -class MyEffect(inkex.Effect): - def __init__(self): - inkex.Effect.__init__(self) - self.OptionParser.add_option("-f", "--flatness", - action="store", type="float", - dest="flat", default=10.0, - help="Minimum flatness of the subdivided curves") - self.hpgl = ['IN;SP1;'] - def output(self): - print ''.join(self.hpgl) - def effect(self): - path = '//svg:path' - for node in self.document.getroot().xpath(path, namespaces=inkex.NSS): - d = node.get('d') - if len(simplepath.parsePath(d)): - p = cubicsuperpath.parsePath(d) - cspsubdiv.cspsubdiv(p, self.options.flat) - for sp in p: - first = True - for csp in sp: - cmd = 'PD' - if first: - cmd = 'PU' - first = False - self.hpgl.append('%s%s,%s;' % (cmd,csp[1][0],csp[1][1])) - -e = MyEffect() -e.affect() +#!/usr/bin/env python +''' +Copyright (C) 2008 Aaron Spike, aaron@ekips.org + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +''' +import inkex, cubicsuperpath, simplepath, cspsubdiv + +class MyEffect(inkex.Effect): + def __init__(self): + inkex.Effect.__init__(self) + self.OptionParser.add_option("-f", "--flatness", + action="store", type="float", + dest="flat", default=10.0, + help="Minimum flatness of the subdivided curves") + self.hpgl = ['IN;SP1;'] + def output(self): + print ''.join(self.hpgl) + def effect(self): + path = '//svg:path' + for node in self.document.getroot().xpath(path, namespaces=inkex.NSS): + d = node.get('d') + if len(simplepath.parsePath(d)): + p = cubicsuperpath.parsePath(d) + cspsubdiv.cspsubdiv(p, self.options.flat) + for sp in p: + first = True + for csp in sp: + cmd = 'PD' + if first: + cmd = 'PU' + first = False + self.hpgl.append('%s%s,%s;' % (cmd,csp[1][0],csp[1][1])) + +e = MyEffect() +e.affect() diff --git a/share/extensions/polyhedron_3d.inx b/share/extensions/polyhedron_3d.inx index 17c80814e..4f1de90c7 100644 --- a/share/extensions/polyhedron_3d.inx +++ b/share/extensions/polyhedron_3d.inx @@ -1,98 +1,98 @@ - - - <_name>3D Polyhedron - math.polyhedron.3d - polyhedron_3d.py - inkex.py - - - - <_option value="cube">Cube - <_option value="trunc_cube">Truncated Cube - <_option value="snub_cube">Snub Cube - <_option value="cuboct">Cuboctohedron - <_option value="tet">Tetrahedron - <_option value="trunc_tet">Truncated Tetrahedron - <_option value="oct">Octahedron - <_option value="trunc_oct">Truncated Octahedron - <_option value="icos">Icosahedron - <_option value="trunc_icos">Truncated Icosahedron - <_option value="small_triam_icos">Small Triambic Icosahedron - <_option value="dodec">Dodecahedron - <_option value="trunc_dodec">Truncated Dodecahedron - <_option value="snub_dodec">Snub Dodecahedron - <_option value="great_dodec">Great Dodecahedron - <_option value="great_stel_dodec">Great Stellated Dodecahedron - <_option value="from_file">Load From File - - great_rhombicuboct.obj - - <_option value="face">Face-Specified - <_option value="edge">Edge-Specified - 0 - - - - <_option value="x">X-Axis - <_option value="y">Y-Axis - <_option value="z">Z-Axis - 0 - - <_option value="x">X-Axis - <_option value="y">Y-Axis - <_option value="z">Z-Axis - 0 - - <_option value="x">X-Axis - <_option value="y">Y-Axis - <_option value="z">Z-Axis - 0 - - <_option value="x">X-Axis - <_option value="y">Y-Axis - <_option value="z">Z-Axis - 0 - - <_option value="x">X-Axis - <_option value="y">Y-Axis - <_option value="z">Z-Axis - 0 - - <_option value="x">X-Axis - <_option value="y">Y-Axis - <_option value="z">Z-Axis - 0 - - - 100 - 255 - 0 - 0 - 100 - 100 - 2 - 0 - 1 - 1 - -2 - - <_option value="vtx">Vertices - <_option value="edg">Edges - <_option value="fce">Faces - 0 - - <_option value="max">Maximum - <_option value="min">Minimum - <_option value="mean">Mean - - - - all - - - - - - + + + <_name>3D Polyhedron + math.polyhedron.3d + polyhedron_3d.py + inkex.py + + + + <_option value="cube">Cube + <_option value="trunc_cube">Truncated Cube + <_option value="snub_cube">Snub Cube + <_option value="cuboct">Cuboctohedron + <_option value="tet">Tetrahedron + <_option value="trunc_tet">Truncated Tetrahedron + <_option value="oct">Octahedron + <_option value="trunc_oct">Truncated Octahedron + <_option value="icos">Icosahedron + <_option value="trunc_icos">Truncated Icosahedron + <_option value="small_triam_icos">Small Triambic Icosahedron + <_option value="dodec">Dodecahedron + <_option value="trunc_dodec">Truncated Dodecahedron + <_option value="snub_dodec">Snub Dodecahedron + <_option value="great_dodec">Great Dodecahedron + <_option value="great_stel_dodec">Great Stellated Dodecahedron + <_option value="from_file">Load From File + + great_rhombicuboct.obj + + <_option value="face">Face-Specified + <_option value="edge">Edge-Specified + 0 + + + + <_option value="x">X-Axis + <_option value="y">Y-Axis + <_option value="z">Z-Axis + 0 + + <_option value="x">X-Axis + <_option value="y">Y-Axis + <_option value="z">Z-Axis + 0 + + <_option value="x">X-Axis + <_option value="y">Y-Axis + <_option value="z">Z-Axis + 0 + + <_option value="x">X-Axis + <_option value="y">Y-Axis + <_option value="z">Z-Axis + 0 + + <_option value="x">X-Axis + <_option value="y">Y-Axis + <_option value="z">Z-Axis + 0 + + <_option value="x">X-Axis + <_option value="y">Y-Axis + <_option value="z">Z-Axis + 0 + + + 100 + 255 + 0 + 0 + 100 + 100 + 2 + 0 + 1 + 1 + -2 + + <_option value="vtx">Vertices + <_option value="edg">Edges + <_option value="fce">Faces + 0 + + <_option value="max">Maximum + <_option value="min">Minimum + <_option value="mean">Mean + + + + all + + + + + + diff --git a/share/extensions/printing-marks.inx b/share/extensions/printing-marks.inx index a893dedd6..c8ebad377 100644 --- a/share/extensions/printing-marks.inx +++ b/share/extensions/printing-marks.inx @@ -1,49 +1,49 @@ - - - <_name>Printing Marks - org.inkscape.printing.marks - printing-marks.py - inkex.py - - - - true - false - true - false - true - false - - - - <_item value="selection">Selection - <_item value="canvas">Canvas - - - px - pt - in - cm - mm - - 5 - <_param name="bleed_settings" type="description">Bleed Margin - 5 - 5 - 5 - 5 - - - - - all - - - - - - - - + + + <_name>Printing Marks + org.inkscape.printing.marks + printing-marks.py + inkex.py + + + + true + false + true + false + true + false + + + + <_item value="selection">Selection + <_item value="canvas">Canvas + + + px + pt + in + cm + mm + + 5 + <_param name="bleed_settings" type="description">Bleed Margin + 5 + 5 + 5 + 5 + + + + + all + + + + + + + + diff --git a/share/extensions/printing-marks.py b/share/extensions/printing-marks.py index 710b71b1c..6128d7027 100644 --- a/share/extensions/printing-marks.py +++ b/share/extensions/printing-marks.py @@ -1,430 +1,430 @@ -#!/usr/bin/env python -''' -This extension allows you to draw crop, registration and other -printing marks in Inkscape. - -Authors: - Nicolas Dufour - Association Inkscape-fr - Aurelio A. Heckert - -Copyright (C) 2008 Authors - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -''' - -import inkex, simplestyle, math - -class Printing_Marks (inkex.Effect): - - # Default parameters - stroke_width = 0.25 - mark_size = inkex.unittouu('1cm') - min_mark_margin = inkex.unittouu('3mm') - - def __init__(self): - inkex.Effect.__init__(self) - self.OptionParser.add_option("--tab", - action="store", type="string", - dest="tab") - self.OptionParser.add_option("--where", - action="store", type="string", - dest="where_to_crop", default=True, - help="Apply crop marks to...") - self.OptionParser.add_option("--crop_marks", - action="store", type="inkbool", - dest="crop_marks", default=True, - help="Draw crop Marks?") - self.OptionParser.add_option("--bleed_marks", - action="store", type="inkbool", - dest="bleed_marks", default=False, - help="Draw Bleed Marks?") - self.OptionParser.add_option("--registration_marks", - action="store", type="inkbool", - dest="reg_marks", default=False, - help="Draw Registration Marks?") - self.OptionParser.add_option("--star_target", - action="store", type="inkbool", - dest="star_target", default=False, - help="Draw Star Target?") - self.OptionParser.add_option("--colour_bars", - action="store", type="inkbool", - dest="colour_bars", default=False, - help="Draw Colour Bars?") - self.OptionParser.add_option("--page_info", - action="store", type="inkbool", - dest="page_info", default=False, - help="Draw Page Information?") - self.OptionParser.add_option("--unit", - action="store", type="string", - dest="unit", default=100.0, - help="Draw measurment") - self.OptionParser.add_option("--crop_offset", - action="store", type="float", - dest="crop_offset", default=0, - help="Offset") - self.OptionParser.add_option("--bleed_top", - action="store", type="float", - dest="bleed_top", default=0, - help="Bleed Top Size") - self.OptionParser.add_option("--bleed_bottom", - action="store", type="float", - dest="bleed_bottom", default=0, - help="Bleed Bottom Size") - self.OptionParser.add_option("--bleed_left", - action="store", type="float", - dest="bleed_left", default=0, - help="Bleed Left Size") - self.OptionParser.add_option("--bleed_right", - action="store", type="float", - dest="bleed_right", default=0, - help="Bleed Right Size") - - - def draw_crop_line(self, x1, y1, x2, y2, name, parent): - style = { 'stroke': '#000000', 'stroke-width': str(self.stroke_width), - 'fill': 'none'} - line_attribs = {'style': simplestyle.formatStyle(style), - 'id': name, - 'd': 'M '+str(x1)+','+str(y1)+' L '+str(x2)+','+str(y2)} - inkex.etree.SubElement(parent, 'path', line_attribs) - - def draw_bleed_line(self, x1, y1, x2, y2, name, parent): - style = { 'stroke': '#000000', 'stroke-width': str(self.stroke_width), - 'fill': 'none', - 'stroke-miterlimit': '4', 'stroke-dasharray': '4, 2, 1, 2', - 'stroke-dashoffset': '0' } - line_attribs = {'style': simplestyle.formatStyle(style), - 'id': name, - 'd': 'M '+str(x1)+','+str(y1)+' L '+str(x2)+','+str(y2)} - inkex.etree.SubElement(parent, 'path', line_attribs) - - def draw_reg_circles(self, cx, cy, r, name, colours, parent): - for i in range(len(colours)): - style = {'stroke':colours[i], 'stroke-width':str(r / len(colours)), - 'fill':'none'} - circle_attribs = {'style':simplestyle.formatStyle(style), - inkex.addNS('label','inkscape'):name, - 'cx':str(cx), 'cy':str(cy), - 'r':str((r / len(colours)) * (i + 0.5))} - inkex.etree.SubElement(parent, inkex.addNS('circle','svg'), - circle_attribs) - - def draw_reg_marks(self, cx, cy, rotate, name, parent): - colours = ['#000000','#00ffff','#ff00ff','#ffff00','#000000'] - g = inkex.etree.SubElement(parent, 'g', { 'id': name }) - for i in range(len(colours)): - style = {'fill':colours[i], 'fill-opacity':'1', 'stroke':'none'} - r = (self.mark_size/2) - step = r - stroke = r / len(colours) - regoffset = stroke * i - regmark_attribs = {'style': simplestyle.formatStyle(style), - 'd': 'm' +\ - ' '+str(-regoffset)+','+str(r) +\ - ' '+str(-stroke) +',0' +\ - ' '+str(step) +','+str(-r) +\ - ' '+str(-step) +','+str(-r) +\ - ' '+str(stroke) +',0' +\ - ' '+str(step) +','+str(r) +\ - ' '+str(-step) +','+str(r) +\ - ' z', - 'transform': 'translate('+str(cx)+','+str(cy)+ \ - ') rotate('+str(rotate)+')'} - inkex.etree.SubElement(g, 'path', regmark_attribs) - - def draw_star_target(self, cx, cy, name, parent): - r = (self.mark_size/2) - style = {'fill':'#000', 'fill-opacity':'1', 'stroke':'none'} - d = ' M 0,0' - i = 0 - while i < ( 2 * math.pi ): - i += math.pi / 16 - d += ' L 0,0 ' +\ - ' L '+ str(math.sin(i)*r) +','+ str(math.cos(i)*r) +\ - ' L '+ str(math.sin(i+0.09)*r) +','+ str(math.cos(i+0.09)*r) - regmark_attribs = {'style':simplestyle.formatStyle(style), - inkex.addNS('label','inkscape'):name, - 'transform':'translate('+str(cx)+','+str(cy)+')', - 'd':d} - inkex.etree.SubElement(parent, inkex.addNS('path','svg'), - regmark_attribs) - - def draw_coluor_bars(self, cx, cy, rotate, name, parent): - g = inkex.etree.SubElement(parent, 'g', { - 'id':name, - 'transform':'translate('+str(cx)+','+str(cy)+\ - ') rotate('+str(rotate)+')' }) - l = min( self.mark_size / 3, max(self.width,self.height) / 45 ) - for bar in [{'c':'*', 'stroke':'#000', 'x':0, 'y':-(l+1)}, - {'c':'r', 'stroke':'#0FF', 'x':0, 'y':0}, - {'c':'g', 'stroke':'#F0F', 'x':(l*11)+1, 'y':-(l+1)}, - {'c':'b', 'stroke':'#FF0', 'x':(l*11)+1, 'y':0} - ]: - i = 0 - while i <= 1: - cr = '255' - cg = '255' - cb = '255' - if bar['c'] == 'r' or bar['c'] == '*' : cr = str(255*i) - if bar['c'] == 'g' or bar['c'] == '*' : cg = str(255*i) - if bar['c'] == 'b' or bar['c'] == '*' : cb = str(255*i) - r_att = {'fill':'rgb('+cr+','+cg+','+cb+')', - 'stroke':bar['stroke'], - 'stroke-width':'0.5', - 'x':str((l*i*10)+bar['x']), 'y':str(bar['y']), - 'width':str(l), 'height':str(l)} - r = inkex.etree.SubElement(g, 'rect', r_att) - i += 0.1 - - def effect(self): - - if self.options.where_to_crop == 'selection' : - inkex.errormsg('Sory, the crop to selection is a TODO feature') - - # Get SVG document dimensions - svg = self.document.getroot() - self.width = width = inkex.unittouu(svg.get('width')) - self.height = height = inkex.unittouu(svg.attrib['height']) - - # Convert parameters to user unit - offset = inkex.unittouu(str(self.options.crop_offset) + \ - self.options.unit) - bt = inkex.unittouu(str(self.options.bleed_top) + self.options.unit) - bb = inkex.unittouu(str(self.options.bleed_bottom) + self.options.unit) - bl = inkex.unittouu(str(self.options.bleed_left) + self.options.unit) - br = inkex.unittouu(str(self.options.bleed_right) + self.options.unit) - # Bleed margin - if bt < offset : bmt = 0 - else : bmt = bt - offset - if bb < offset : bmb = 0 - else : bmb = bb - offset - if bl < offset : bml = 0 - else : bml = bl - offset - if br < offset : bmr = 0 - else : bmr = br - offset - - # Define the new document limits - left = - offset - right = width + offset - top = - offset - bottom = height + offset - - # Test if printing-marks layer existis - layer = self.document.xpath( - '//*[@id="printing-marks" and @inkscape:groupmode="layer"]', - namespaces=inkex.NSS) - if layer: svg.remove(layer[0]) # remove if it existis - # Create a new layer - layer = inkex.etree.SubElement(svg, 'g') - layer.set('id', 'printing-marks') - layer.set(inkex.addNS('label', 'inkscape'), 'Printing Marks') - layer.set(inkex.addNS('groupmode', 'inkscape'), 'layer') - layer.set(inkex.addNS('insensitive', 'sodipodi'), 'true') - - # Crop Mark - if self.options.crop_marks == True: - # Create a group for Crop Mark - g_attribs = {inkex.addNS('label','inkscape'):'CropMarks', - 'id':'CropMarks'} - g_crops = inkex.etree.SubElement(layer, 'g', g_attribs) - - # Top left Mark - self.draw_crop_line(0, top, - 0, top - self.mark_size, - 'cropTL1', g_crops) - self.draw_crop_line(left, 0, - left - self.mark_size, 0, - 'cropTL2', g_crops) - - # Top right Mark - self.draw_crop_line(width, top, - width , top - self.mark_size, - 'cropTR1', g_crops) - self.draw_crop_line(right, 0, - right + self.mark_size, 0, - 'cropTR2', g_crops) - - # Bottom left Mark - self.draw_crop_line(0, bottom, - 0, bottom + self.mark_size, - 'cropBL1', g_crops) - self.draw_crop_line(left, height, - left - self.mark_size, height, - 'cropBL2', g_crops) - - # Bottom right Mark - self.draw_crop_line(width, bottom, - width, bottom + self.mark_size, - 'cropBR1', g_crops) - self.draw_crop_line(right, height, - right + self.mark_size, height, - 'cropBR2', g_crops) - - # Bleed Mark - if self.options.bleed_marks == True: - # Create a group for Bleed Mark - g_attribs = {inkex.addNS('label','inkscape'):'BleedMarks', - 'id':'BleedMarks'} - g_bleed = inkex.etree.SubElement(layer, 'g', g_attribs) - - # Top left Mark - self.draw_bleed_line(-bl, top - bmt, - -bl, top - bmt - self.mark_size, - 'bleedTL1', g_bleed) - self.draw_bleed_line(left - bml, -bt, - left - bml - self.mark_size, -bt, - 'bleedTL2', g_bleed) - - # Top right Mark - self.draw_bleed_line(width + br, top - bmt, - width + br, top - bmt - self.mark_size, - 'bleedTR1', g_bleed) - self.draw_bleed_line(right + bmr, -bt, - right + bmr + self.mark_size, -bt, - 'bleedTR2', g_bleed) - - # Bottom left Mark - self.draw_bleed_line(-bl, bottom + bmb, - -bl, bottom + bmb + self.mark_size, - 'bleedBL1', g_bleed) - self.draw_bleed_line(left - bml, height + bb, - left - bml - self.mark_size, height + bb, - 'bleedBL2', g_bleed) - - # Bottom right Mark - self.draw_bleed_line(width + br, bottom + bmb, - width + br, bottom + bmb + self.mark_size, - 'bleedBR1', g_bleed) - self.draw_bleed_line(right + bmr, height + bb, - right + bmr + self.mark_size, height + bb, - 'bleedBR2', g_bleed) - - # Registration Mark - if self.options.reg_marks == True: - # Create a group for Registration Mark - g_attribs = {inkex.addNS('label','inkscape'):'RegistrationMarks', - 'id':'RegistrationMarks'} - g_center = inkex.etree.SubElement(layer, 'g', g_attribs) - - # Left Mark - cx = max( bml + offset, self.min_mark_margin ) - self.draw_reg_marks(-cx - (self.mark_size/2), - (height/2) - self.mark_size*1.5, - '0', 'regMarkL', g_center) - - # Right Mark - cx = max( bmr + offset, self.min_mark_margin ) - self.draw_reg_marks(width + cx + (self.mark_size/2), - (height/2) - self.mark_size*1.5, - '180', 'regMarkR', g_center) - - # Top Mark - cy = max( bmt + offset, self.min_mark_margin ) - self.draw_reg_marks((width/2), - -cy - (self.mark_size/2), - '90', 'regMarkT', g_center) - - # Bottom Mark - cy = max( bmb + offset, self.min_mark_margin ) - self.draw_reg_marks((width/2), - height + cy + (self.mark_size/2), - '-90', 'regMarkB', g_center) - - # Star Target - if self.options.star_target == True: - # Create a group for Star Target - g_attribs = {inkex.addNS('label','inkscape'):'StarTarget', - 'id':'StarTarget'} - g_center = inkex.etree.SubElement(layer, 'g', g_attribs) - - if height < width : - # Left Star - cx = max( bml + offset, self.min_mark_margin ) - self.draw_star_target(-cx - (self.mark_size/2), - (height/2), - 'starTargetL', g_center) - # Right Star - cx = max( bmr + offset, self.min_mark_margin ) - self.draw_star_target(width + cx + (self.mark_size/2), - (height/2), - 'starTargetR', g_center) - else : - # Top Star - cy = max( bmt + offset, self.min_mark_margin ) - self.draw_star_target((width/2) - self.mark_size*1.5, - -cy - (self.mark_size/2), - 'starTargetT', g_center) - # Bottom Star - cy = max( bmb + offset, self.min_mark_margin ) - self.draw_star_target((width/2) - self.mark_size*1.5, - height + cy + (self.mark_size/2), - 'starTargetB', g_center) - - - # Colour Bars - if self.options.colour_bars == True: - # Create a group for Colour Bars - g_attribs = {inkex.addNS('label','inkscape'):'ColourBars', - 'id':'PrintingColourBars'} - g_center = inkex.etree.SubElement(layer, 'g', g_attribs) - - if height > width : - # Left Bars - cx = max( bml + offset, self.min_mark_margin ) - self.draw_coluor_bars(-cx - (self.mark_size/2), - height/2, - 90, - 'PrintingColourBarsL', g_center) - # Right Bars - cx = max( bmr + offset, self.min_mark_margin ) - self.draw_coluor_bars(width + cx + (self.mark_size/2), - height/2, - 90, - 'PrintingColourBarsR', g_center) - else : - # Top Bars - cy = max( bmt + offset, self.min_mark_margin ) - self.draw_coluor_bars(width/2, - -cy - (self.mark_size/2), - 0, - 'PrintingColourBarsT', g_center) - # Bottom Bars - cy = max( bmb + offset, self.min_mark_margin ) - self.draw_coluor_bars(width/2, - height + cy + (self.mark_size/2), - 0, - 'PrintingColourBarsB', g_center) - - - # Page Information - if self.options.page_info == True: - # Create a group for Page Information - g_attribs = {inkex.addNS('label','inkscape'):'PageInformation', - 'id':'PageInformation'} - g_pag_info = inkex.etree.SubElement(layer, 'g', g_attribs) - y_margin = max( bmb + offset, self.min_mark_margin ) - txt_attribs = {'style':'font-size:12px;font-style:normal;font-weight:normal;fill:#000000;font-family:Bitstream Vera Sans,sans-serif;text-anchor:middle;text-align:center', - 'x':str(width/2), 'y':str(height+y_margin+self.mark_size+20)} - txt = inkex.etree.SubElement(g_pag_info, 'text', txt_attribs) - txt.text = 'Page size: ' +\ - str(round(inkex.uutounit(width,self.options.unit),2)) +\ - 'x' +\ - str(round(inkex.uutounit(height,self.options.unit),2)) +\ - ' ' + self.options.unit - - -if __name__ == '__main__': - e = Printing_Marks() - e.affect() +#!/usr/bin/env python +''' +This extension allows you to draw crop, registration and other +printing marks in Inkscape. + +Authors: + Nicolas Dufour - Association Inkscape-fr + Aurelio A. Heckert + +Copyright (C) 2008 Authors + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +''' + +import inkex, simplestyle, math + +class Printing_Marks (inkex.Effect): + + # Default parameters + stroke_width = 0.25 + mark_size = inkex.unittouu('1cm') + min_mark_margin = inkex.unittouu('3mm') + + def __init__(self): + inkex.Effect.__init__(self) + self.OptionParser.add_option("--tab", + action="store", type="string", + dest="tab") + self.OptionParser.add_option("--where", + action="store", type="string", + dest="where_to_crop", default=True, + help="Apply crop marks to...") + self.OptionParser.add_option("--crop_marks", + action="store", type="inkbool", + dest="crop_marks", default=True, + help="Draw crop Marks?") + self.OptionParser.add_option("--bleed_marks", + action="store", type="inkbool", + dest="bleed_marks", default=False, + help="Draw Bleed Marks?") + self.OptionParser.add_option("--registration_marks", + action="store", type="inkbool", + dest="reg_marks", default=False, + help="Draw Registration Marks?") + self.OptionParser.add_option("--star_target", + action="store", type="inkbool", + dest="star_target", default=False, + help="Draw Star Target?") + self.OptionParser.add_option("--colour_bars", + action="store", type="inkbool", + dest="colour_bars", default=False, + help="Draw Colour Bars?") + self.OptionParser.add_option("--page_info", + action="store", type="inkbool", + dest="page_info", default=False, + help="Draw Page Information?") + self.OptionParser.add_option("--unit", + action="store", type="string", + dest="unit", default=100.0, + help="Draw measurment") + self.OptionParser.add_option("--crop_offset", + action="store", type="float", + dest="crop_offset", default=0, + help="Offset") + self.OptionParser.add_option("--bleed_top", + action="store", type="float", + dest="bleed_top", default=0, + help="Bleed Top Size") + self.OptionParser.add_option("--bleed_bottom", + action="store", type="float", + dest="bleed_bottom", default=0, + help="Bleed Bottom Size") + self.OptionParser.add_option("--bleed_left", + action="store", type="float", + dest="bleed_left", default=0, + help="Bleed Left Size") + self.OptionParser.add_option("--bleed_right", + action="store", type="float", + dest="bleed_right", default=0, + help="Bleed Right Size") + + + def draw_crop_line(self, x1, y1, x2, y2, name, parent): + style = { 'stroke': '#000000', 'stroke-width': str(self.stroke_width), + 'fill': 'none'} + line_attribs = {'style': simplestyle.formatStyle(style), + 'id': name, + 'd': 'M '+str(x1)+','+str(y1)+' L '+str(x2)+','+str(y2)} + inkex.etree.SubElement(parent, 'path', line_attribs) + + def draw_bleed_line(self, x1, y1, x2, y2, name, parent): + style = { 'stroke': '#000000', 'stroke-width': str(self.stroke_width), + 'fill': 'none', + 'stroke-miterlimit': '4', 'stroke-dasharray': '4, 2, 1, 2', + 'stroke-dashoffset': '0' } + line_attribs = {'style': simplestyle.formatStyle(style), + 'id': name, + 'd': 'M '+str(x1)+','+str(y1)+' L '+str(x2)+','+str(y2)} + inkex.etree.SubElement(parent, 'path', line_attribs) + + def draw_reg_circles(self, cx, cy, r, name, colours, parent): + for i in range(len(colours)): + style = {'stroke':colours[i], 'stroke-width':str(r / len(colours)), + 'fill':'none'} + circle_attribs = {'style':simplestyle.formatStyle(style), + inkex.addNS('label','inkscape'):name, + 'cx':str(cx), 'cy':str(cy), + 'r':str((r / len(colours)) * (i + 0.5))} + inkex.etree.SubElement(parent, inkex.addNS('circle','svg'), + circle_attribs) + + def draw_reg_marks(self, cx, cy, rotate, name, parent): + colours = ['#000000','#00ffff','#ff00ff','#ffff00','#000000'] + g = inkex.etree.SubElement(parent, 'g', { 'id': name }) + for i in range(len(colours)): + style = {'fill':colours[i], 'fill-opacity':'1', 'stroke':'none'} + r = (self.mark_size/2) + step = r + stroke = r / len(colours) + regoffset = stroke * i + regmark_attribs = {'style': simplestyle.formatStyle(style), + 'd': 'm' +\ + ' '+str(-regoffset)+','+str(r) +\ + ' '+str(-stroke) +',0' +\ + ' '+str(step) +','+str(-r) +\ + ' '+str(-step) +','+str(-r) +\ + ' '+str(stroke) +',0' +\ + ' '+str(step) +','+str(r) +\ + ' '+str(-step) +','+str(r) +\ + ' z', + 'transform': 'translate('+str(cx)+','+str(cy)+ \ + ') rotate('+str(rotate)+')'} + inkex.etree.SubElement(g, 'path', regmark_attribs) + + def draw_star_target(self, cx, cy, name, parent): + r = (self.mark_size/2) + style = {'fill':'#000', 'fill-opacity':'1', 'stroke':'none'} + d = ' M 0,0' + i = 0 + while i < ( 2 * math.pi ): + i += math.pi / 16 + d += ' L 0,0 ' +\ + ' L '+ str(math.sin(i)*r) +','+ str(math.cos(i)*r) +\ + ' L '+ str(math.sin(i+0.09)*r) +','+ str(math.cos(i+0.09)*r) + regmark_attribs = {'style':simplestyle.formatStyle(style), + inkex.addNS('label','inkscape'):name, + 'transform':'translate('+str(cx)+','+str(cy)+')', + 'd':d} + inkex.etree.SubElement(parent, inkex.addNS('path','svg'), + regmark_attribs) + + def draw_coluor_bars(self, cx, cy, rotate, name, parent): + g = inkex.etree.SubElement(parent, 'g', { + 'id':name, + 'transform':'translate('+str(cx)+','+str(cy)+\ + ') rotate('+str(rotate)+')' }) + l = min( self.mark_size / 3, max(self.width,self.height) / 45 ) + for bar in [{'c':'*', 'stroke':'#000', 'x':0, 'y':-(l+1)}, + {'c':'r', 'stroke':'#0FF', 'x':0, 'y':0}, + {'c':'g', 'stroke':'#F0F', 'x':(l*11)+1, 'y':-(l+1)}, + {'c':'b', 'stroke':'#FF0', 'x':(l*11)+1, 'y':0} + ]: + i = 0 + while i <= 1: + cr = '255' + cg = '255' + cb = '255' + if bar['c'] == 'r' or bar['c'] == '*' : cr = str(255*i) + if bar['c'] == 'g' or bar['c'] == '*' : cg = str(255*i) + if bar['c'] == 'b' or bar['c'] == '*' : cb = str(255*i) + r_att = {'fill':'rgb('+cr+','+cg+','+cb+')', + 'stroke':bar['stroke'], + 'stroke-width':'0.5', + 'x':str((l*i*10)+bar['x']), 'y':str(bar['y']), + 'width':str(l), 'height':str(l)} + r = inkex.etree.SubElement(g, 'rect', r_att) + i += 0.1 + + def effect(self): + + if self.options.where_to_crop == 'selection' : + inkex.errormsg('Sory, the crop to selection is a TODO feature') + + # Get SVG document dimensions + svg = self.document.getroot() + self.width = width = inkex.unittouu(svg.get('width')) + self.height = height = inkex.unittouu(svg.attrib['height']) + + # Convert parameters to user unit + offset = inkex.unittouu(str(self.options.crop_offset) + \ + self.options.unit) + bt = inkex.unittouu(str(self.options.bleed_top) + self.options.unit) + bb = inkex.unittouu(str(self.options.bleed_bottom) + self.options.unit) + bl = inkex.unittouu(str(self.options.bleed_left) + self.options.unit) + br = inkex.unittouu(str(self.options.bleed_right) + self.options.unit) + # Bleed margin + if bt < offset : bmt = 0 + else : bmt = bt - offset + if bb < offset : bmb = 0 + else : bmb = bb - offset + if bl < offset : bml = 0 + else : bml = bl - offset + if br < offset : bmr = 0 + else : bmr = br - offset + + # Define the new document limits + left = - offset + right = width + offset + top = - offset + bottom = height + offset + + # Test if printing-marks layer existis + layer = self.document.xpath( + '//*[@id="printing-marks" and @inkscape:groupmode="layer"]', + namespaces=inkex.NSS) + if layer: svg.remove(layer[0]) # remove if it existis + # Create a new layer + layer = inkex.etree.SubElement(svg, 'g') + layer.set('id', 'printing-marks') + layer.set(inkex.addNS('label', 'inkscape'), 'Printing Marks') + layer.set(inkex.addNS('groupmode', 'inkscape'), 'layer') + layer.set(inkex.addNS('insensitive', 'sodipodi'), 'true') + + # Crop Mark + if self.options.crop_marks == True: + # Create a group for Crop Mark + g_attribs = {inkex.addNS('label','inkscape'):'CropMarks', + 'id':'CropMarks'} + g_crops = inkex.etree.SubElement(layer, 'g', g_attribs) + + # Top left Mark + self.draw_crop_line(0, top, + 0, top - self.mark_size, + 'cropTL1', g_crops) + self.draw_crop_line(left, 0, + left - self.mark_size, 0, + 'cropTL2', g_crops) + + # Top right Mark + self.draw_crop_line(width, top, + width , top - self.mark_size, + 'cropTR1', g_crops) + self.draw_crop_line(right, 0, + right + self.mark_size, 0, + 'cropTR2', g_crops) + + # Bottom left Mark + self.draw_crop_line(0, bottom, + 0, bottom + self.mark_size, + 'cropBL1', g_crops) + self.draw_crop_line(left, height, + left - self.mark_size, height, + 'cropBL2', g_crops) + + # Bottom right Mark + self.draw_crop_line(width, bottom, + width, bottom + self.mark_size, + 'cropBR1', g_crops) + self.draw_crop_line(right, height, + right + self.mark_size, height, + 'cropBR2', g_crops) + + # Bleed Mark + if self.options.bleed_marks == True: + # Create a group for Bleed Mark + g_attribs = {inkex.addNS('label','inkscape'):'BleedMarks', + 'id':'BleedMarks'} + g_bleed = inkex.etree.SubElement(layer, 'g', g_attribs) + + # Top left Mark + self.draw_bleed_line(-bl, top - bmt, + -bl, top - bmt - self.mark_size, + 'bleedTL1', g_bleed) + self.draw_bleed_line(left - bml, -bt, + left - bml - self.mark_size, -bt, + 'bleedTL2', g_bleed) + + # Top right Mark + self.draw_bleed_line(width + br, top - bmt, + width + br, top - bmt - self.mark_size, + 'bleedTR1', g_bleed) + self.draw_bleed_line(right + bmr, -bt, + right + bmr + self.mark_size, -bt, + 'bleedTR2', g_bleed) + + # Bottom left Mark + self.draw_bleed_line(-bl, bottom + bmb, + -bl, bottom + bmb + self.mark_size, + 'bleedBL1', g_bleed) + self.draw_bleed_line(left - bml, height + bb, + left - bml - self.mark_size, height + bb, + 'bleedBL2', g_bleed) + + # Bottom right Mark + self.draw_bleed_line(width + br, bottom + bmb, + width + br, bottom + bmb + self.mark_size, + 'bleedBR1', g_bleed) + self.draw_bleed_line(right + bmr, height + bb, + right + bmr + self.mark_size, height + bb, + 'bleedBR2', g_bleed) + + # Registration Mark + if self.options.reg_marks == True: + # Create a group for Registration Mark + g_attribs = {inkex.addNS('label','inkscape'):'RegistrationMarks', + 'id':'RegistrationMarks'} + g_center = inkex.etree.SubElement(layer, 'g', g_attribs) + + # Left Mark + cx = max( bml + offset, self.min_mark_margin ) + self.draw_reg_marks(-cx - (self.mark_size/2), + (height/2) - self.mark_size*1.5, + '0', 'regMarkL', g_center) + + # Right Mark + cx = max( bmr + offset, self.min_mark_margin ) + self.draw_reg_marks(width + cx + (self.mark_size/2), + (height/2) - self.mark_size*1.5, + '180', 'regMarkR', g_center) + + # Top Mark + cy = max( bmt + offset, self.min_mark_margin ) + self.draw_reg_marks((width/2), + -cy - (self.mark_size/2), + '90', 'regMarkT', g_center) + + # Bottom Mark + cy = max( bmb + offset, self.min_mark_margin ) + self.draw_reg_marks((width/2), + height + cy + (self.mark_size/2), + '-90', 'regMarkB', g_center) + + # Star Target + if self.options.star_target == True: + # Create a group for Star Target + g_attribs = {inkex.addNS('label','inkscape'):'StarTarget', + 'id':'StarTarget'} + g_center = inkex.etree.SubElement(layer, 'g', g_attribs) + + if height < width : + # Left Star + cx = max( bml + offset, self.min_mark_margin ) + self.draw_star_target(-cx - (self.mark_size/2), + (height/2), + 'starTargetL', g_center) + # Right Star + cx = max( bmr + offset, self.min_mark_margin ) + self.draw_star_target(width + cx + (self.mark_size/2), + (height/2), + 'starTargetR', g_center) + else : + # Top Star + cy = max( bmt + offset, self.min_mark_margin ) + self.draw_star_target((width/2) - self.mark_size*1.5, + -cy - (self.mark_size/2), + 'starTargetT', g_center) + # Bottom Star + cy = max( bmb + offset, self.min_mark_margin ) + self.draw_star_target((width/2) - self.mark_size*1.5, + height + cy + (self.mark_size/2), + 'starTargetB', g_center) + + + # Colour Bars + if self.options.colour_bars == True: + # Create a group for Colour Bars + g_attribs = {inkex.addNS('label','inkscape'):'ColourBars', + 'id':'PrintingColourBars'} + g_center = inkex.etree.SubElement(layer, 'g', g_attribs) + + if height > width : + # Left Bars + cx = max( bml + offset, self.min_mark_margin ) + self.draw_coluor_bars(-cx - (self.mark_size/2), + height/2, + 90, + 'PrintingColourBarsL', g_center) + # Right Bars + cx = max( bmr + offset, self.min_mark_margin ) + self.draw_coluor_bars(width + cx + (self.mark_size/2), + height/2, + 90, + 'PrintingColourBarsR', g_center) + else : + # Top Bars + cy = max( bmt + offset, self.min_mark_margin ) + self.draw_coluor_bars(width/2, + -cy - (self.mark_size/2), + 0, + 'PrintingColourBarsT', g_center) + # Bottom Bars + cy = max( bmb + offset, self.min_mark_margin ) + self.draw_coluor_bars(width/2, + height + cy + (self.mark_size/2), + 0, + 'PrintingColourBarsB', g_center) + + + # Page Information + if self.options.page_info == True: + # Create a group for Page Information + g_attribs = {inkex.addNS('label','inkscape'):'PageInformation', + 'id':'PageInformation'} + g_pag_info = inkex.etree.SubElement(layer, 'g', g_attribs) + y_margin = max( bmb + offset, self.min_mark_margin ) + txt_attribs = {'style':'font-size:12px;font-style:normal;font-weight:normal;fill:#000000;font-family:Bitstream Vera Sans,sans-serif;text-anchor:middle;text-align:center', + 'x':str(width/2), 'y':str(height+y_margin+self.mark_size+20)} + txt = inkex.etree.SubElement(g_pag_info, 'text', txt_attribs) + txt.text = 'Page size: ' +\ + str(round(inkex.uutounit(width,self.options.unit),2)) +\ + 'x' +\ + str(round(inkex.uutounit(height,self.options.unit),2)) +\ + ' ' + self.options.unit + + +if __name__ == '__main__': + e = Printing_Marks() + e.affect() diff --git a/share/extensions/svgcalendar.inx b/share/extensions/svgcalendar.inx index 8d8f2d567..e01666870 100644 --- a/share/extensions/svgcalendar.inx +++ b/share/extensions/svgcalendar.inx @@ -1,139 +1,139 @@ - - - <_name>Calendar - org.inkscape.render.calendar - - svgcalendar.py - inkex.py - - - - 0 - 0 - true - - <_item value="sun">Sunday - <_item value="mon">Monday - - - <_item value="sat+sun">Saturday and Sunday - <_item value="sat">Saturday - <_item value="sun">Sunday - - - - true - <_param name="organize-help" type="description">The options above has no value with the upper checked. + + + <_name>Calendar + org.inkscape.render.calendar + + svgcalendar.py + inkex.py + + + + 0 + 0 + true + + <_item value="sun">Sunday + <_item value="mon">Monday + + + <_item value="sat+sun">Saturday and Sunday + <_item value="sat">Saturday + <_item value="sun">Sunday + + + + true + <_param name="organize-help" type="description">The options above has no value with the upper checked. 3 6cm - 1cm - - - #808080 - #686868 - #909090 - #000000 - #787878 - #B0B0B0 - - - <_param name="l10n-help" type="description">You may change the names for other languages: - <_param name="month-names" type="string" _gui-text="Month names">January February March April May June July August September October November December - <_param name="day-names" type="string" _gui-text="Day names">Sun Mon Tue Wed Thu Fri Sat - <_param name="day-names-help" type="description">(The day names list must start from Sunday) - - arabic - big5-tw - big5-hkscs - chinese - cp737 - cp856 - cp874 - cp875 - cp1006 - cyrillic - cyrillic-asian - eucjis2004 - eucjisx0213 - gbk - gb18030-2000 - greek - hebrew - hz-gb - IBM037 - IBM424 - IBM437 - IBM500 - IBM775 - IBM850 - IBM852 - IBM855 - IBM857 - IBM860 - IBM861 - IBM862 - IBM863 - IBM864 - IBM865 - IBM866 - IBM869 - IBM1026 - IBM1140 - iso-2022-jp - iso-2022-jp-1 - iso-2022-jp-2 - iso-2022-jp-2004 - iso-2022-jp-3 - iso-2022-jp-ext - iso-2022-kr - johab - korean - koi8_r - koi8_u - latin1 - latin2 - latin3 - latin4 - latin5 - latin6 - latin8 - Latin - iso-8859-15 - Western Europe - macgreek - maciceland - maccentraleurope - macroman - macturkish - ms932 - ms949 - ms950 - sjis - sjis2004 - sjisx0213 - u-jis - us-ascii - Windows - Central and Eastern Europe - Windows - Russian and more - Windows - Western Europe - Windows - Greek - Windows - Turkish - Windows - Hebrew - Windows - Arabic - Windows - Baltic languages - Windows - Vietnamese - UTF-32 - All languages - UTF-16 - All languages - UTF-8 - All languages - - <_param name="encoding-help" type="description">(Select your system encoding. More information at http://docs.python.org/library/codecs.html#standard-encodings) - - - - all - - - - - - + 1cm + + + #808080 + #686868 + #909090 + #000000 + #787878 + #B0B0B0 + + + <_param name="l10n-help" type="description">You may change the names for other languages: + <_param name="month-names" type="string" _gui-text="Month names">January February March April May June July August September October November December + <_param name="day-names" type="string" _gui-text="Day names">Sun Mon Tue Wed Thu Fri Sat + <_param name="day-names-help" type="description">(The day names list must start from Sunday) + + arabic + big5-tw + big5-hkscs + chinese + cp737 + cp856 + cp874 + cp875 + cp1006 + cyrillic + cyrillic-asian + eucjis2004 + eucjisx0213 + gbk + gb18030-2000 + greek + hebrew + hz-gb + IBM037 + IBM424 + IBM437 + IBM500 + IBM775 + IBM850 + IBM852 + IBM855 + IBM857 + IBM860 + IBM861 + IBM862 + IBM863 + IBM864 + IBM865 + IBM866 + IBM869 + IBM1026 + IBM1140 + iso-2022-jp + iso-2022-jp-1 + iso-2022-jp-2 + iso-2022-jp-2004 + iso-2022-jp-3 + iso-2022-jp-ext + iso-2022-kr + johab + korean + koi8_r + koi8_u + latin1 + latin2 + latin3 + latin4 + latin5 + latin6 + latin8 + Latin - iso-8859-15 - Western Europe + macgreek + maciceland + maccentraleurope + macroman + macturkish + ms932 + ms949 + ms950 + sjis + sjis2004 + sjisx0213 + u-jis + us-ascii + Windows - Central and Eastern Europe + Windows - Russian and more + Windows - Western Europe + Windows - Greek + Windows - Turkish + Windows - Hebrew + Windows - Arabic + Windows - Baltic languages + Windows - Vietnamese + UTF-32 - All languages + UTF-16 - All languages + UTF-8 - All languages + + <_param name="encoding-help" type="description">(Select your system encoding. More information at http://docs.python.org/library/codecs.html#standard-encodings) + + + + all + + + + + + diff --git a/share/extensions/triangle.inx b/share/extensions/triangle.inx index 0cd12c833..3c79ca42c 100644 --- a/share/extensions/triangle.inx +++ b/share/extensions/triangle.inx @@ -1,28 +1,28 @@ - - - <_name>Triangle - math.triangle - triangle.py - inkex.py - 100.0 - 100.0 - 100.0 - 60 - 30 - 90 - - <_option value="3_sides">From Three Sides - <_option value="s_ab_a_c">From Sides a, b and Angle c - <_option value="s_ab_a_a">From Sides a, b and Angle a - <_option value="s_a_a_ab">From Side a and Angles a, b - <_option value="s_c_a_ab">From Side c and Angles a, b - - all - - - - - + + + <_name>Triangle + math.triangle + triangle.py + inkex.py + 100.0 + 100.0 + 100.0 + 60 + 30 + 90 + + <_option value="3_sides">From Three Sides + <_option value="s_ab_a_c">From Sides a, b and Angle c + <_option value="s_ab_a_a">From Sides a, b and Angle a + <_option value="s_a_a_ab">From Side a and Angles a, b + <_option value="s_c_a_ab">From Side c and Angles a, b + + all + + + + + -- 2.30.2