def break_apart_selected(self): before = self._get_layers_snapshot() sel_before = [] + self.selection.objs obj = self.selection.objs[0] parent = obj.parent index = parent.childs.index(obj) config = obj.config paths = libgeom.get_transformed_path(obj) objs = [] obj.parent.childs.remove(obj) for path in paths: if path and path[1]: curve = model.Curve(config, parent) curve.paths = [path, ] curve.style = deepcopy(obj.style) objs += [curve, ] parent.childs.insert(index, curve) curve.update() after = self._get_layers_snapshot() self.selection.set(objs) transaction = [ [[self._set_layers_snapshot, before], [self._set_selection, sel_before]], [[self._set_layers_snapshot, after], [self._set_selection, objs]], False] self.add_undo(transaction) self.selection.update()
def break_apart_selected(self): before = self._get_layers_snapshot() sel_before = [] + self.selection.objs obj = self.selection.objs[0] parent = obj.parent index = parent.childs.index(obj) config = obj.config paths = libgeom.get_transformed_path(obj) objs = [] obj.parent.childs.remove(obj) for path in paths: if path and path[1]: curve = model.Curve(config, parent) curve.paths = [ path, ] curve.style = deepcopy(obj.style) objs += [ curve, ] parent.childs.insert(index, curve) curve.update() after = self._get_layers_snapshot() self.selection.set(objs) transaction = [[[self._set_layers_snapshot, before], [self._set_selection, sel_before]], [[self._set_layers_snapshot, after], [self._set_selection, objs]], False] self.add_undo(transaction) self.selection.update()
def combine_selected(self): before = self._get_layers_snapshot() sel_before = [] + self.selection.objs objs = self.selection.objs parent = objs[0].parent index = parent.childs.index(objs[0]) style = deepcopy(objs[0].style) parent = objs[0].parent config = objs[0].config paths = [] for obj in objs: paths += libgeom.get_transformed_path(obj) result = model.Curve(config, parent) result.paths = paths result.style = style result.update() for obj in objs: obj.parent.childs.remove(obj) parent.childs.insert(index, result) after = self._get_layers_snapshot() self.selection.set([result, ]) transaction = [ [[self._set_layers_snapshot, before], [self._set_selection, sel_before]], [[self._set_layers_snapshot, after], [self._set_selection, [result, ]]], False] self.add_undo(transaction) self.selection.update()
def combine_selected(self): before = self._get_layers_snapshot() sel_before = [] + self.selection.objs objs = self.selection.objs parent = objs[0].parent index = parent.childs.index(objs[0]) style = deepcopy(objs[0].style) parent = objs[0].parent config = objs[0].config paths = [] for obj in objs: paths += libgeom.get_transformed_path(obj) result = model.Curve(config, parent) result.paths = paths result.style = style result.update() for obj in objs: obj.parent.childs.remove(obj) parent.childs.insert(index, result) after = self._get_layers_snapshot() self.selection.set([ result, ]) transaction = [[[self._set_layers_snapshot, before], [self._set_selection, sel_before]], [[self._set_layers_snapshot, after], [self._set_selection, [ result, ]]], False] self.add_undo(transaction) self.selection.update()