Fixed deprecations in Travel

This commit is contained in:
Mario Voigt 2020-08-23 14:33:09 +02:00
parent 8114065ff1
commit 07096bb201

View File

@ -22,7 +22,6 @@ from __future__ import division
from copy import deepcopy from copy import deepcopy
import inkex import inkex
from inkex.paths import Path, CubicSuperPath from inkex.paths import Path, CubicSuperPath
import simplepath
from inkex.transforms import Transform from inkex.transforms import Transform
import numpy as np import numpy as np
from lxml import etree from lxml import etree
@ -100,7 +99,7 @@ class Travel(inkex.Effect):
doc_h = self.svg.unittouu(svg.get('height')) doc_h = self.svg.unittouu(svg.get('height'))
# get selected items and validate # get selected items and validate
selected = self.svg.get_z_selected() selected = svg.selection.paint_order()
if not selected: if not selected:
inkex.errormsg('Exactly two objects must be selected: a rect and a template. See "help" for details.') inkex.errormsg('Exactly two objects must be selected: a rect and a template. See "help" for details.')
@ -199,7 +198,7 @@ class Travel(inkex.Effect):
ys += y_0 ys += y_0
# get obj center # get obj center
b_box = Path(Path(obj_p)).bounding_box() b_box = Path(obj_p).bounding_box()
c_x = 0.5 * (b_box.left + b_box.right) c_x = 0.5 * (b_box.left + b_box.right)
c_y = 0.5 * (b_box.top + b_box.bottom) c_y = 0.5 * (b_box.top + b_box.bottom)
@ -219,32 +218,28 @@ class Travel(inkex.Effect):
path = deepcopy(obj_p) path = deepcopy(obj_p)
# move to origin # move to origin
#Path(path).translate(-x_0, -y_0) path = Path(path).translate(-x_0, -y_0)
simplepath.translatePath(path, -x_0, -y_0)
# move rotation anchor accordingly # move rotation anchor accordingly
r_x_1 = r_x - x_0 r_x_1 = r_x - x_0
r_y_1 = r_y - y_0 r_y_1 = r_y - y_0
# scale # scale
#Path(path).scale(x_size, y_size) path = Path(path).scale(x_size, y_size)
simplepath.scalePath(path, x_size, y_size)
# scale rotation anchor accordingly # scale rotation anchor accordingly
r_x_2 = r_x_1 * x_size r_x_2 = r_x_1 * x_size
r_y_2 = r_y_1 * y_size r_y_2 = r_y_1 * y_size
# move to final location # move to final location
#Path(path).translate(x, y) path = Path(path).translate(x, y)
simplepath.translatePath(path, x, y)
# move rotation anchor accordingly # move rotation anchor accordingly
r_x_3 = r_x_2 + x r_x_3 = r_x_2 + x
r_y_3 = r_y_2 + y r_y_3 = r_y_2 + y
# rotate # rotate
#simplepath.rotatePath(path, -theta, cx=r_x_3, cy=r_y_3) path = Path(path).rotate(-theta, (r_x_3, r_y_3))
Path(path).rotate(-theta, (r_x_3, r_y_3))
paths.append(path) paths.append(path)
parent = self.svg.get_current_layer() parent = self.svg.get_current_layer()