def ExtendBlend(self, start, end, steps): idx = self.objects.index(start) if idx == 0: inter = BlendInterpolation(steps, end, start) return CreateMultiUndo(self.insert(inter, 0), self.insert(end, 0)) elif idx == len(self.objects) - 1: inter = BlendInterpolation(steps, start, end) return CreateMultiUndo(self.insert(inter, None), self.insert(end, None))
def do_remove_child(self, idx): undo = [] try: if idx % 2 == 0: # a control object if self.document is not None: undo.append(self.document.AddClearRect(self.bounding_rect)) if len(self.objects) > 3: if idx == 0: undo.append(self.remove(1)) undo.append(self.remove(0)) elif idx == len(self.objects) - 1: undo.append(self.remove(idx)) undo.append(self.remove(idx - 1)) else: steps = self.objects[idx + 1].Steps() \ + self.objects[idx - 1].Steps() u = (UndoAfter, CreateMultiUndo(self.remove(idx + 1), self.remove(idx)), self.objects[idx - 1].SetParameters(steps)) undo.append(u) else: # remove one of only two control objects -> Remove self undo.append(self.parent.Remove(self)) return CreateListUndo(undo) else: # XXX implement this case raise ValueError, 'BlendGroup: cannot remove non control child' except: Undo(CreateListUndo(undo)) raise
def RemoveTransformation(self): if self.trafo.matrix() != IdentityMatrix: trafo = self.trafo try: undostyle = Primitive.Transform(self, trafo.inverse()) except SingularMatrix: undostyle = None undotrafo = self.set_transformation(Translation(trafo.offset())) return CreateMultiUndo(undostyle, undotrafo) return NullUndo
def RemoveTransformation(self): if self.trafo.matrix() != IdentityMatrix: a = self.properties trafo = self.trafo llx, lly, urx, ury = a.font.TextCoordBox(self.text, a.font_size, a) try: undostyle = Primitive.Transform(self, trafo.inverse()) except SingularMatrix: undostyle = None undotrafo = self.set_transformation(Translation(trafo.offset())) return CreateMultiUndo(undostyle, undotrafo) return NullUndo
def Transform(self, trafo, transform_properties = 1): undostyle = undo = NullUndo try: rect = self.bounding_rect undo = RectangularObject.Transform(self, trafo) if transform_properties: rects = (rect, self.bounding_rect) undostyle = Primitive.Transform(self, trafo, rects = rects) return CreateMultiUndo(undostyle, undo) except: Undo(undo) Undo(undostyle) raise
def ButtonUp(self, p, button, state): p = self.apply_constraint(p, state) Editor.DragStop(self, p) start_angle, end_angle, arc_type = self.angles() return CreateMultiUndo(self.object.SetAngles(start_angle, end_angle), self.object.SetArcType(arc_type))