Changeset 1893
- Timestamp:
- 08/09/07 06:15:50 (1 year ago)
- Files:
-
- gaphas/trunk/gaphas/item.py (modified) (4 diffs)
- gaphas/trunk/gaphas/state.py (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
gaphas/trunk/gaphas/item.py
r1883 r1893 524 524 525 525 @observed 526 def _reversible_insert_handle(self, index, handle): 527 self._handles.insert(index, handle) 528 529 @observed 530 def _reversible_remove_handle(self, handle): 531 self._handles.remove(handle) 532 533 reversible_pair(_reversible_insert_handle, _reversible_remove_handle, \ 534 bind1={'index': lambda self, handle: self._handles.index(handle)}) 535 536 526 537 def split_segment(self, segment, parts=2): 527 538 """ … … 564 575 dx, dy = h1.x - h0.x, h1.y - h0.y 565 576 new_h = Handle(h0.x + dx / parts, h0.y + dy / parts, strength=WEAK) 566 self._handles.insert(segment + 1, new_h) 567 # TODO: reconnect connected handles. 577 self._reversible_insert_handle(segment + 1, new_h) 568 578 if parts > 2: 569 579 do_split(segment + 1, parts - 1) 570 580 do_split(segment, parts) 571 # TODO: or reconnect them from here.572 581 # Force orthogonal constraints to be recreated 573 582 self.orthogonal = self.orthogonal 574 583 return self._handles[segment+1:segment+parts] 575 584 576 @observed577 585 def merge_segment(self, segment, parts=2): 578 586 """ … … 611 619 if segment == 0: segment = 1 612 620 deleted_handles = self._handles[segment:segment+parts-1] 613 del self._handles[segment]621 self._reversible_remove_handle(self._handles[segment]) 614 622 if parts > 2: 615 623 self.merge_segment(segment, parts - 1) … … 619 627 return deleted_handles 620 628 621 reversible_pair(split_segment, merge_segment) 622 623 629 624 630 def opposite(self, handle): 625 631 """ gaphas/trunk/gaphas/state.py
r1815 r1893 49 49 Simple observer, dispatches events to functions registered in the observers 50 50 list. 51 On the function an __observer__ property is set, which references to the 52 observer decorator. This is nessesary, since the event handlers expect the 53 outer most function to be returned (that's what they see). 51 52 On the function an ``__observer__`` property is set, which references to 53 the observer decorator. This is nessesary, since the event handlers expect 54 the outer most function to be returned (that's what they see). 55 56 Also note that the events are dispatched *before* the function is invoked. 57 This is an important feature, esp. for the reverter code. 54 58 """ 55 59 def wrapper(func, *args, **kwargs):
