diff options
| author | Alvin Penner <penner@vaxxine.com> | 2014-02-14 21:44:22 +0000 |
|---|---|---|
| committer | apenner <penner@vaxxine.com> | 2014-02-14 21:44:22 +0000 |
| commit | 098d591a3e183fa03f2f46da2afcabff709d8c49 (patch) | |
| tree | 8cc4bac3eb9f390272dcc3faff90ddc7a93af034 | |
| parent | extensions. ink2canvas.py. pass reference to self (Bug 1258473) (diff) | |
| download | inkscape-098d591a3e183fa03f2f46da2afcabff709d8c49.tar.gz inkscape-098d591a3e183fa03f2f46da2afcabff709d8c49.zip | |
Extensions. Scaling of command-line bbox into document units, Part 4 (Bug 1240455)
(bzr r13028)
| -rwxr-xr-x | share/extensions/dimension.py | 21 | ||||
| -rwxr-xr-x | share/extensions/perspective.py | 5 | ||||
| -rwxr-xr-x | share/extensions/printing_marks.py | 17 | ||||
| -rwxr-xr-x | share/extensions/summersnight.py | 5 |
4 files changed, 26 insertions, 22 deletions
diff --git a/share/extensions/dimension.py b/share/extensions/dimension.py index 4285effeb..30b674201 100755 --- a/share/extensions/dimension.py +++ b/share/extensions/dimension.py @@ -100,8 +100,9 @@ class Dimension(pathmodifier.PathModifier): return line def effect(self): - self.xoffset = self.options.xoffset - self.yoffset = self.options.yoffset + scale = self.unittouu('1px') # convert to document units + self.xoffset = scale*self.options.xoffset + self.yoffset = scale*self.options.yoffset # query inkscape about the bounding box if len(self.options.ids) == 0: @@ -117,11 +118,11 @@ class Dimension(pathmodifier.PathModifier): if bsubprocess: p = Popen('inkscape --query-%s --query-id=%s "%s"' % (query,id,file), shell=True, stdout=PIPE, stderr=PIPE) rc = p.wait() - q[query] = float(p.stdout.read()) + q[query] = scale*float(p.stdout.read()) err = p.stderr.read() else: f,err = os.popen3('inkscape --query-%s --query-id=%s "%s"' % (query,id,file))[1:] - q[query] = float(f.read()) + q[query] = scale*float(f.read()) f.close() err.close() self.bbox = (q['x'], q['x']+q['width'], q['y'], q['y']+q['height']) @@ -146,29 +147,29 @@ class Dimension(pathmodifier.PathModifier): line = self.dimHLine(self.bbox[2], [0, 1]) line.set('marker-start', 'url(#Arrow1Lstart)') line.set('marker-end', 'url(#Arrow1Lend)') - line.set('stroke-width', '1') + line.set('stroke-width', str(scale)) group.append(line) line = self.dimVLine(self.bbox[0], [0, 2]) - line.set('stroke-width', '0.5') + line.set('stroke-width', str(0.5*scale)) group.append(line) line = self.dimVLine(self.bbox[1], [0, 2]) - line.set('stroke-width', '0.5') + line.set('stroke-width', str(0.5*scale)) group.append(line) line = self.dimVLine(self.bbox[0], [1, 0]) line.set('marker-start', 'url(#Arrow1Lstart)') line.set('marker-end', 'url(#Arrow1Lend)') - line.set('stroke-width', '1') + line.set('stroke-width', str(scale)) group.append(line) line = self.dimHLine(self.bbox[2], [2, 0]) - line.set('stroke-width', '0.5') + line.set('stroke-width', str(0.5*scale)) group.append(line) line = self.dimHLine(self.bbox[3], [2, 0]) - line.set('stroke-width', '0.5') + line.set('stroke-width', str(0.5*scale)) group.append(line) for id, node in self.selected.iteritems(): diff --git a/share/extensions/perspective.py b/share/extensions/perspective.py index 8a0ffeb0b..044257ae8 100755 --- a/share/extensions/perspective.py +++ b/share/extensions/perspective.py @@ -54,6 +54,7 @@ class Project(inkex.Effect): exit() #obj is selected second + scale = self.unittouu('1px') # convert to document units obj = self.selected[self.options.ids[0]] envelope = self.selected[self.options.ids[1]] if obj.get(inkex.addNS('type','sodipodi')): @@ -80,11 +81,11 @@ class Project(inkex.Effect): if bsubprocess: p = Popen('inkscape --query-%s --query-id=%s "%s"' % (query,id,file), shell=True, stdout=PIPE, stderr=PIPE) rc = p.wait() - q[query] = float(p.stdout.read()) + q[query] = scale*float(p.stdout.read()) err = p.stderr.read() else: f,err = os.popen3('inkscape --query-%s --query-id=%s "%s"' % (query,id,file))[1:] - q[query] = float(f.read()) + q[query] = scale*float(f.read()) f.close() err.close() sp = array([[q['x'], q['y']+q['height']],[q['x'], q['y']],[q['x']+q['width'], q['y']],[q['x']+q['width'], q['y']+q['height']]], dtype=float64) diff --git a/share/extensions/printing_marks.py b/share/extensions/printing_marks.py index 5c6ac3a61..0306048d6 100755 --- a/share/extensions/printing_marks.py +++ b/share/extensions/printing_marks.py @@ -191,20 +191,21 @@ class Printing_Marks (inkex.Effect): i += 0.1 def get_selection_area(self): + scale = self.unittouu('1px') # convert to document units sel_area = {} min_x, min_y, max_x, max_y = False, False, False, False for id in self.options.ids: sel_area[id] = {} for att in [ "x", "y", "width", "height" ]: args = [ "inkscape", "-I", id, "--query-"+att, self.svg_file ] - sel_area[id][att] = \ - Popen(args, stdout=PIPE, stderr=PIPE).communicate()[0] - current_min_x = float( sel_area[id]["x"] ) - current_min_y = float( sel_area[id]["y"] ) - current_max_x = float( sel_area[id]["x"] ) + \ - float( sel_area[id]["width"] ) - current_max_y = float( sel_area[id]["y"] ) + \ - float( sel_area[id]["height"] ) + sel_area[id][att] = scale* \ + float(Popen(args, stdout=PIPE, stderr=PIPE).communicate()[0]) + current_min_x = sel_area[id]["x"] + current_min_y = sel_area[id]["y"] + current_max_x = sel_area[id]["x"] + \ + sel_area[id]["width"] + current_max_y = sel_area[id]["y"] + \ + sel_area[id]["height"] if not min_x: min_x = current_min_x if not min_y: min_y = current_min_y if not max_x: max_x = current_max_x diff --git a/share/extensions/summersnight.py b/share/extensions/summersnight.py index aea5cea55..67413a05c 100755 --- a/share/extensions/summersnight.py +++ b/share/extensions/summersnight.py @@ -45,6 +45,7 @@ class Project(inkex.Effect): exit() #obj is selected second + scale = self.unittouu('1px') # convert to document units obj = self.selected[self.options.ids[0]] trafo = self.selected[self.options.ids[1]] if obj.get(inkex.addNS('type','sodipodi')): @@ -75,11 +76,11 @@ class Project(inkex.Effect): if bsubprocess: p = Popen('inkscape --query-%s --query-id=%s "%s"' % (query,id,file), shell=True, stdout=PIPE, stderr=PIPE) rc = p.wait() - self.q[query] = float(p.stdout.read()) + self.q[query] = scale*float(p.stdout.read()) err = p.stderr.read() else: f,err = os.popen3('inkscape --query-%s --query-id=%s "%s"' % (query,id,file))[1:] - self.q[query] = float(f.read()) + self.q[query] = scale*float(f.read()) f.close() err.close() |
