2018-06-30 17:02:33 +00:00
|
|
|
import inkex
|
|
|
|
import cubicsuperpath
|
|
|
|
|
|
|
|
from .base import InkstitchExtension
|
|
|
|
from ..i18n import _
|
|
|
|
from ..elements import SatinColumn
|
|
|
|
|
2018-08-22 00:32:50 +00:00
|
|
|
|
2018-06-30 17:02:33 +00:00
|
|
|
class Flip(InkstitchExtension):
|
|
|
|
def flip(self, satin):
|
2018-07-07 19:31:59 +00:00
|
|
|
csp = satin.path
|
2018-06-30 17:02:33 +00:00
|
|
|
|
|
|
|
if len(csp) > 1:
|
2018-09-29 20:00:36 +00:00
|
|
|
first, second = satin.rail_indices
|
2018-06-30 17:02:33 +00:00
|
|
|
csp[first], csp[second] = csp[second], csp[first]
|
|
|
|
|
|
|
|
satin.node.set("d", cubicsuperpath.formatPath(csp))
|
|
|
|
|
|
|
|
def effect(self):
|
|
|
|
if not self.get_elements():
|
|
|
|
return
|
|
|
|
|
|
|
|
if not self.selected:
|
|
|
|
inkex.errormsg(_("Please select one or more satin columns to flip."))
|
|
|
|
return
|
|
|
|
|
|
|
|
for element in self.elements:
|
|
|
|
if isinstance(element, SatinColumn):
|
|
|
|
self.flip(element)
|