summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsu_v <suv-sf@users.sourceforge.net>2015-10-20 21:20:32 +0000
committer~suv <suv-sf@users.sourceforge.net>2015-10-20 21:20:32 +0000
commit12c71f5e63f038d334bd8dfea9a2ab16dc134c50 (patch)
tree17c1f34af2fd3812346823d18e7bafe9b859cfa8
parentExtensions. Move invertTransform() from voronoi2svg.py to shared module simpl... (diff)
downloadinkscape-12c71f5e63f038d334bd8dfea9a2ab16dc134c50.tar.gz
inkscape-12c71f5e63f038d334bd8dfea9a2ab16dc134c50.zip
Extensions. Fix view center for Render extensions applied in transformed layers or groups (bug #1503882)
Fixed bugs: - https://launchpad.net/bugs/1503882 (bzr r14425.1.2)
-rwxr-xr-xshare/extensions/grid_cartesian.py6
-rwxr-xr-xshare/extensions/grid_isometric.py6
-rwxr-xr-xshare/extensions/grid_polar.py4
-rwxr-xr-xshare/extensions/hershey.py4
-rwxr-xr-xshare/extensions/lindenmayer.py3
-rwxr-xr-xshare/extensions/polyhedron_3d.py4
-rwxr-xr-xshare/extensions/render_barcode.py3
-rwxr-xr-xshare/extensions/render_barcode_datamatrix.py3
-rwxr-xr-xshare/extensions/render_barcode_qrcode.py3
-rwxr-xr-xshare/extensions/render_gear_rack.py6
-rwxr-xr-xshare/extensions/render_gears.py4
-rwxr-xr-xshare/extensions/rtree.py3
-rw-r--r--share/extensions/simpletransform.py6
-rwxr-xr-xshare/extensions/spirograph.py6
-rwxr-xr-xshare/extensions/triangle.py3
-rwxr-xr-xshare/extensions/whirl.py10
-rwxr-xr-xshare/extensions/wireframe_sphere.py3
17 files changed, 54 insertions, 23 deletions
diff --git a/share/extensions/grid_cartesian.py b/share/extensions/grid_cartesian.py
index 23df0ff84..ae4c6b6b4 100755
--- a/share/extensions/grid_cartesian.py
+++ b/share/extensions/grid_cartesian.py
@@ -25,6 +25,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
import inkex
import simplestyle, sys
from math import *
+from simpletransform import computePointInNode
def draw_SVG_line(x1, y1, x2, y2, width, name, parent):
style = { 'stroke': '#000000', 'stroke-width':str(width), 'fill': 'none' }
@@ -139,8 +140,9 @@ class Grid_Polar(inkex.Effect):
# Embed grid in group
#Put in in the centre of the current view
- t = 'translate(' + str( self.view_center[0]- xmax/2.0) + ',' + \
- str( self.view_center[1]- ymax/2.0) + ')'
+ view_center = computePointInNode(list(self.view_center), self.current_layer)
+ t = 'translate(' + str( view_center[0]- xmax/2.0) + ',' + \
+ str( view_center[1]- ymax/2.0) + ')'
g_attribs = {inkex.addNS('label','inkscape'):'Grid_Polar:X' + \
str( self.options.x_divs )+':Y'+str( self.options.y_divs ),
'transform':t }
diff --git a/share/extensions/grid_isometric.py b/share/extensions/grid_isometric.py
index 8ac407613..6202fd9e2 100755
--- a/share/extensions/grid_isometric.py
+++ b/share/extensions/grid_isometric.py
@@ -26,6 +26,7 @@
import inkex
import simplestyle, sys
from math import *
+from simpletransform import computePointInNode
def draw_SVG_line(x1, y1, x2, y2, width, name, parent):
@@ -101,8 +102,9 @@ class Grid_Polar(inkex.Effect):
#Embed grid in group
#Put in in the centre of the current view
- t = 'translate(' + str( self.view_center[0]- xmax/2.0) + ',' + \
- str( self.view_center[1]- ymax/2.0) + ')'
+ view_center = computePointInNode(list(self.view_center), self.current_layer)
+ t = 'translate(' + str( view_center[0]- xmax/2.0) + ',' + \
+ str( view_center[1]- ymax/2.0) + ')'
g_attribs = {inkex.addNS('label','inkscape'):'Grid_Polar:X' + \
str( self.options.x_divs )+':Y'+str( self.options.y_divs ),
'transform':t }
diff --git a/share/extensions/grid_polar.py b/share/extensions/grid_polar.py
index 17c3499cb..350b21195 100755
--- a/share/extensions/grid_polar.py
+++ b/share/extensions/grid_polar.py
@@ -23,6 +23,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
import inkex
import simplestyle, sys
from math import *
+from simpletransform import computePointInNode
def draw_SVG_circle(r, cx, cy, width, fill, name, parent):
style = { 'stroke': '#000000', 'stroke-width':str(width), 'fill': fill }
@@ -131,7 +132,8 @@ class Grid_Polar(inkex.Effect):
# Embed grid in group
#Put in in the centre of the current view
- t = 'translate(' + str( self.view_center[0] ) + ',' + str( self.view_center[1] ) + ')'
+ view_center = computePointInNode(list(self.view_center), self.current_layer)
+ t = 'translate(' + str( view_center[0] ) + ',' + str( view_center[1] ) + ')'
g_attribs = {inkex.addNS('label','inkscape'):'Grid_Polar:R' +
str( self.options.r_divs )+':A'+str( self.options.a_divs ),
'transform':t }
diff --git a/share/extensions/hershey.py b/share/extensions/hershey.py
index 1ddabfbe0..d0b27b129 100755
--- a/share/extensions/hershey.py
+++ b/share/extensions/hershey.py
@@ -22,6 +22,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
import hersheydata #data file w/ Hershey font data
import inkex
import simplestyle
+from simpletransform import computePointInNode
Debug = False
@@ -98,7 +99,8 @@ class Hershey( inkex.Effect ):
w = wmax
# Translate group to center of view, approximately
- t = 'translate(' + str( self.view_center[0] - scale*w/2) + ',' + str( self.view_center[1] ) + ')'
+ view_center = computePointInNode(list(self.view_center), self.current_layer)
+ t = 'translate(' + str( view_center[0] - scale*w/2) + ',' + str( view_center[1] ) + ')'
if scale != 1:
t += ' scale(' + str(scale) + ')'
g.set( 'transform',t)
diff --git a/share/extensions/lindenmayer.py b/share/extensions/lindenmayer.py
index 2e058f541..eb0d84328 100755
--- a/share/extensions/lindenmayer.py
+++ b/share/extensions/lindenmayer.py
@@ -17,6 +17,7 @@ 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, pturtle, random
+from simpletransform import computePointInNode
def stripme(s):
return s.strip()
@@ -68,7 +69,7 @@ class LSystem(inkex.Effect):
return self.turtle.getPath()
def __compose_path(self, string):
self.turtle.pu()
- self.turtle.setpos(self.view_center)
+ self.turtle.setpos(computePointInNode(list(self.view_center), self.current_layer))
self.turtle.pd()
for c in string:
if c in 'ABCDEF':
diff --git a/share/extensions/polyhedron_3d.py b/share/extensions/polyhedron_3d.py
index f191d7f89..8e4a8e8e6 100755
--- a/share/extensions/polyhedron_3d.py
+++ b/share/extensions/polyhedron_3d.py
@@ -55,6 +55,7 @@ from math import *
# local library
import inkex
import simplestyle
+from simpletransform import computePointInNode
inkex.localize()
@@ -467,7 +468,8 @@ class Poly_3D(inkex.Effect):
#INKSCAPE GROUP TO CONTAIN THE POLYHEDRON
#Put in in the centre of the current view
- poly_transform = 'translate(' + str( self.view_center[0]) + ',' + str( self.view_center[1]) + ')'
+ view_center = computePointInNode(list(self.view_center), self.current_layer)
+ poly_transform = 'translate(' + str( view_center[0]) + ',' + str( view_center[1]) + ')'
if scale != 1:
poly_transform += ' scale(' + str(scale) + ')'
#we will put all the rotations in the object name, so it can be repeated in
diff --git a/share/extensions/render_barcode.py b/share/extensions/render_barcode.py
index 694dcc8f3..4f1464a92 100755
--- a/share/extensions/render_barcode.py
+++ b/share/extensions/render_barcode.py
@@ -24,6 +24,7 @@ Barcode module provided for outside or scripting.
import inkex
import sys
from Barcode import getBarcode
+from simpletransform import computePointInNode
class InsertBarcode(inkex.Effect):
def __init__(self):
@@ -42,7 +43,7 @@ class InsertBarcode(inkex.Effect):
help="Text to print on barcode")
def effect(self):
- x, y = self.view_center
+ x, y = computePointInNode(list(self.view_center), self.current_layer)
bargen = getBarcode( self.options.type,
text=self.options.text,
height=self.options.height,
diff --git a/share/extensions/render_barcode_datamatrix.py b/share/extensions/render_barcode_datamatrix.py
index 83d009db8..72ffddbe6 100755
--- a/share/extensions/render_barcode_datamatrix.py
+++ b/share/extensions/render_barcode_datamatrix.py
@@ -54,6 +54,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
# local library
import inkex
import simplestyle
+from simpletransform import computePointInNode
inkex.localize()
@@ -680,7 +681,7 @@ class DataMatrix(inkex.Effect):
#INKSCAPE GROUP TO CONTAIN EVERYTHING
- centre = self.view_center #Put in in the centre of the current view
+ centre = tuple(computePointInNode(list(self.view_center), self.current_layer)) #Put in in the centre of the current view
grp_transform = 'translate' + str( centre ) + ' scale(%f)' % scale
grp_name = 'DataMatrix'
grp_attribs = {inkex.addNS('label','inkscape'):grp_name,
diff --git a/share/extensions/render_barcode_qrcode.py b/share/extensions/render_barcode_qrcode.py
index 7b4895195..d4cffd3e2 100755
--- a/share/extensions/render_barcode_qrcode.py
+++ b/share/extensions/render_barcode_qrcode.py
@@ -2,6 +2,7 @@
import math, sys
import inkex
+from simpletransform import computePointInNode
inkex.localize()
@@ -1057,7 +1058,7 @@ class QRCodeInkscape(inkex.Effect):
#INKSCAPE GROUP TO CONTAIN EVERYTHING
so.TEXT = unicode(so.TEXT, so.input_encode)
- centre = self.view_center #Put in in the centre of the current view
+ centre = tuple(computePointInNode(list(self.view_center), self.current_layer)) #Put in in the centre of the current view
grp_transform = 'translate' + str( centre ) + ' scale(%f)' % scale
grp_name = 'QR Code: '+so.TEXT
grp_attribs = {inkex.addNS('label','inkscape'):grp_name,
diff --git a/share/extensions/render_gear_rack.py b/share/extensions/render_gear_rack.py
index dfecf0438..63433aadb 100755
--- a/share/extensions/render_gear_rack.py
+++ b/share/extensions/render_gear_rack.py
@@ -19,6 +19,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
import inkex
import simplestyle
+from simpletransform import computePointInNode
from math import *
@@ -85,8 +86,9 @@ class RackGear(inkex.Effect):
# Embed gear in group to make animation easier:
# Translate group, Rotate path.
- t = 'translate(' + str(self.view_center[0]) + ',' + \
- str(self.view_center[1]) + ')'
+ view_center = computePointInNode(list(self.view_center), self.current_layer)
+ t = 'translate(' + str(view_center[0]) + ',' + \
+ str(view_center[1]) + ')'
g_attribs = {
inkex.addNS('label', 'inkscape'): 'RackGear' + str(length),
'transform': t}
diff --git a/share/extensions/render_gears.py b/share/extensions/render_gears.py
index 8a481cdb9..2584117f2 100755
--- a/share/extensions/render_gears.py
+++ b/share/extensions/render_gears.py
@@ -20,6 +20,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
import inkex
import simplestyle, sys
+from simpletransform import computePointInNode
from math import *
import string
@@ -158,7 +159,8 @@ class Gears(inkex.Effect):
# Embed gear in group to make animation easier:
# Translate group, Rotate path.
- t = 'translate(' + str( self.view_center[0] ) + ',' + str( self.view_center[1] ) + ')'
+ view_center = computePointInNode(list(self.view_center), self.current_layer)
+ t = 'translate(' + str( view_center[0] ) + ',' + str( view_center[1] ) + ')'
g_attribs = {inkex.addNS('label','inkscape'):'Gear' + str( teeth ),
'transform':t }
g = inkex.etree.SubElement(self.current_layer, 'g', g_attribs)
diff --git a/share/extensions/rtree.py b/share/extensions/rtree.py
index 7123beb1e..c0dc1cca6 100755
--- a/share/extensions/rtree.py
+++ b/share/extensions/rtree.py
@@ -18,6 +18,7 @@ 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, pturtle, random
+from simpletransform import computePointInNode
def rtree(turtle, size, min, pt=False):
if size < min:
@@ -61,7 +62,7 @@ class RTreeTurtle(inkex.Effect):
'fill': 'none'}
t = pturtle.pTurtle()
t.pu()
- t.setpos(self.view_center)
+ t.setpos(computePointInNode(list(self.view_center), self.current_layer))
t.pd()
rtree(t, self.options.size, self.options.minimum, self.options.pentoggle)
diff --git a/share/extensions/simpletransform.py b/share/extensions/simpletransform.py
index 7fb2b37f0..8b6f46935 100644
--- a/share/extensions/simpletransform.py
+++ b/share/extensions/simpletransform.py
@@ -252,4 +252,10 @@ def computeBBox(aList,mat=[[1,0,0],[0,1,0]]):
return bbox
+def computePointInNode(pt, node, mat=[[1.0, 0.0, 0.0], [0.0, 1.0, 0.0]]):
+ if node.getparent() is not None:
+ applyTransformToPoint(invertTransform(composeParents(node, mat)), pt)
+ return pt
+
+
# vim: expandtab shiftwidth=4 tabstop=8 softtabstop=4 fileencoding=utf-8 textwidth=99
diff --git a/share/extensions/spirograph.py b/share/extensions/spirograph.py
index 77a258d5f..e702344a5 100755
--- a/share/extensions/spirograph.py
+++ b/share/extensions/spirograph.py
@@ -17,6 +17,7 @@ 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 simpletransform import computePointInNode
class Spirograph(inkex.Effect):
def __init__(self):
@@ -81,12 +82,13 @@ class Spirograph(inkex.Effect):
theta = i * scale
+ view_center = computePointInNode(list(self.view_center), self.current_layer)
x = a * math.cos(theta + rotation) + \
self.options.penr * math.cos(ratio * theta + rotation) * flip + \
- self.view_center[0]
+ view_center[0]
y = a * math.sin(theta + rotation) - \
self.options.penr * math.sin(ratio * theta + rotation) + \
- self.view_center[1]
+ view_center[1]
dx = (-a * math.sin(theta + rotation) - \
ratio * self.options.penr * math.sin(ratio * theta + rotation) * flip) * scale / 3
diff --git a/share/extensions/triangle.py b/share/extensions/triangle.py
index 019db3147..ecd977d40 100755
--- a/share/extensions/triangle.py
+++ b/share/extensions/triangle.py
@@ -34,6 +34,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
import inkex
import simplestyle, sys
+from simpletransform import computePointInNode
from math import *
def draw_SVG_tri( (x1, y1), (x2, y2), (x3, y3), (ox,oy), width, name, parent):
@@ -121,7 +122,7 @@ class Grid_Polar(inkex.Effect):
def effect(self):
tri = self.current_layer
- offset = (self.view_center[0],self.view_center[1]) #the offset require to centre the triangle
+ offset = computePointInNode(list(self.view_center), self.current_layer) #the offset require to centre the triangle
self.options.s_a = self.unittouu(str(self.options.s_a) + 'px')
self.options.s_b = self.unittouu(str(self.options.s_b) + 'px')
self.options.s_c = self.unittouu(str(self.options.s_c) + 'px')
diff --git a/share/extensions/whirl.py b/share/extensions/whirl.py
index cea9da8df..7ee9cc0a2 100755
--- a/share/extensions/whirl.py
+++ b/share/extensions/whirl.py
@@ -17,6 +17,7 @@ along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
'''
import math, inkex, cubicsuperpath
+from simpletransform import computePointInNode
class Whirl(inkex.Effect):
def __init__(self):
@@ -30,6 +31,7 @@ class Whirl(inkex.Effect):
dest="rotation", default=True,
help="direction of rotation")
def effect(self):
+ view_center = computePointInNode(list(self.view_center), self.current_layer)
for id, node in self.selected.iteritems():
rotation = -1
if self.options.rotation == True:
@@ -41,16 +43,16 @@ class Whirl(inkex.Effect):
for sub in p:
for csp in sub:
for point in csp:
- point[0] -= self.view_center[0]
- point[1] -= self.view_center[1]
+ point[0] -= view_center[0]
+ point[1] -= view_center[1]
dist = math.sqrt((point[0] ** 2) + (point[1] ** 2))
if dist != 0:
a = rotation * dist * whirl
theta = math.atan2(point[1], point[0]) + a
point[0] = (dist * math.cos(theta))
point[1] = (dist * math.sin(theta))
- point[0] += self.view_center[0]
- point[1] += self.view_center[1]
+ point[0] += view_center[0]
+ point[1] += view_center[1]
node.set('d',cubicsuperpath.formatPath(p))
if __name__ == '__main__':
diff --git a/share/extensions/wireframe_sphere.py b/share/extensions/wireframe_sphere.py
index bcd676dc4..bda06af21 100755
--- a/share/extensions/wireframe_sphere.py
+++ b/share/extensions/wireframe_sphere.py
@@ -59,6 +59,7 @@ from math import *
# local library
import inkex
import simplestyle
+from simpletransform import computePointInNode
inkex.localize()
@@ -129,7 +130,7 @@ class Wireframe_Sphere(inkex.Effect):
#INKSCAPE GROUP TO CONTAIN EVERYTHING
- centre = self.view_center #Put in in the centre of the current view
+ centre = tuple(computePointInNode(list(self.view_center), self.current_layer)) #Put in in the centre of the current view
grp_transform = 'translate' + str( centre ) + flip
grp_name = 'WireframeSphere'
grp_attribs = {inkex.addNS('label','inkscape'):grp_name,