/[ascend]/branches/mike/pygtk/canvas/blockcanvas.py
ViewVC logotype

Annotation of /branches/mike/pygtk/canvas/blockcanvas.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1959 - (hide annotations) (download) (as text)
Mon Nov 17 11:51:01 2008 UTC (10 years, 8 months ago) by jpye
Original Path: trunk/pygtk/canvas/blockcanvas.py
File MIME type: text/x-python
File size: 1652 byte(s)
Started working on reattach_ascend.
1 jpye 1942 from gaphas import Canvas
2    
3     class BlockCanvas(Canvas):
4     def update_constraints(self, items):
5     """
6     Update constraints. Also variables may be marked as dirty before the
7     constraint solver kicks in.
8     """
9     # request solving of external constraints associated with dirty items
10     request_resolve = self._solver.request_resolve
11     for item in items:
12     if hasattr(item,'ports'):
13     for p in item.ports:
14     request_resolve(p.x)
15     request_resolve(p.y)
16    
17     super(BlockCanvas,self).update_constraints(items)
18    
19     def _normalize(self, items):
20     """
21     Correct offset of ports due to movement of left-side handles.
22     """
23     dirty_matrix_items = set()
24     for item in items:
25     if not hasattr(item, 'ports'):
26     continue
27     handles = item.handles()
28     ports = item.ports
29     if not handles or not ports:
30     continue
31     x, y = map(float, handles[0].pos)
32     # Dirty marking is done by the superclass' method
33     if x:
34     for p in ports:
35     p.x._value -= x
36     if y:
37     for p in ports:
38     p.y._value -= y
39     dirty_matrix_items.update(super(BlockCanvas, self)._normalize(items))
40     return dirty_matrix_items
41    
42 jpye 1959 def reattach_ascend(self, library):
43     # FIXME still need a way of iterating through these items
44     items = []
45     for item in items:
46     if not hasattr(item, 'ports'):
47     continue
48     if item.blocktype.type is None:
49     item.blocktype.reattach_ascend(library)
50 jpye 1954
51 jpye 1959

john.pye@anu.edu.au
ViewVC Help
Powered by ViewVC 1.1.22