Changeset 1013

Show
Ignore:
Timestamp:
09/13/06 03:32:51 (2 years ago)
Author:
arjanmol
Message:

--

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • gaphas/trunk/ChangeLog

    r1002 r1013  
     12006-09-13  Arjan Molenaar  <arjan_at_yirdis_dot_nl> 
     2 
     3        * canvas.py: added get_all_children(node) 
     4        * tool.py (ItemTool): also mark handles of children dirty on movement 
     5 
    162006-09-08  Arjan Molenaar  <arjan_at_yirdis_dot_nl> 
    27 
  • gaphas/trunk/demo.py

    r1002 r1013  
    3838        cr.line_to(0, 0) 
    3939        cr.line_to(10, 10) 
     40        print '===================== begin stroke()' 
    4041        cr.stroke() 
     42        print '--------------------- end stroke()' 
     43 
    4144 
    4245 
  • gaphas/trunk/gaphas/canvas.py

    r999 r1013  
    186186        """ 
    187187        return self._tree.get_children(item) 
     188 
     189    def get_all_children(self, item): 
     190        """See tree.Tree.get_all_children() 
     191            >>> c = Canvas() 
     192            >>> from gaphas import item 
     193            >>> i = item.Item() 
     194            >>> c.add(i) 
     195            >>> ii = item.Item() 
     196            >>> c.add(ii, i) 
     197            >>> iii = item.Item() 
     198            >>> c.add(iii, ii) 
     199            >>> list(c.get_all_children(iii)) 
     200            [] 
     201            >>> list(c.get_all_children(ii)) 
     202            [<gaphas.item.Item ...>] 
     203            >>> list(c.get_all_children(i)) 
     204            [<gaphas.item.Item ...>, <gaphas.item.Item ...>] 
     205        """ 
     206        return self._tree.get_all_children(item) 
    188207 
    189208    def get_connected_items(self, item): 
  • gaphas/trunk/gaphas/item.py

    r1002 r1013  
    540540        h0, h1 = self._handles[-2:] 
    541541        draw_line_end(self._handles[-1], self._tail_angle, self.draw_tail) 
     542        print '=== line stroke()' 
    542543        cr.stroke() 
     544        print '--- end line stroke()' 
    543545 
    544546 
  • gaphas/trunk/gaphas/tool.py

    r1001 r1013  
    277277                    h.y.dirty() 
    278278 
     279                # Also mark handles of child items as dirty 
     280                for child in view.canvas.get_all_children(i): 
     281                    for h in child.handles(): 
     282                        h.x.dirty() 
     283                        h.y.dirty() 
     284 
    279285            # Now do the actual moving. 
    280286            for i in view.selected_items: 
     
    285291 
    286292                # Calculate the distance the item has to be moved 
    287                 dx, dy = view.transform_distance_c2w(event.x - self.last_x, event.y - self.last_y) 
     293                dx, dy = view.transform_distance_c2w(event.x - self.last_x, 
     294                                                     event.y - self.last_y) 
    288295                # Move the item and schedule it for an update 
    289296                i.matrix.translate(*view.canvas.get_matrix_w2i(i).transform_distance(dx, dy)) 
     
    292299                b = view.get_item_bounding_box(i) 
    293300                view.queue_draw_item(i, handles=True) 
    294                 view.queue_draw_area(b[0] + dx-1, b[1] + dy-1, b[2] - b[0]+2, b[3] - b[1]+2) 
     301                view.queue_draw_area(b[0] + dx-1, b[1] + dy-1, 
     302                                     b[2] - b[0]+2, b[3] - b[1]+2) 
    295303            self.last_x, self.last_y = event.x, event.y 
    296304            return True 
  • gaphas/trunk/gaphas/tree.py

    r997 r1013  
    5656        siblings = self._children[parent] 
    5757        return siblings[siblings.index(node) - 1] 
     58 
     59    def get_all_children(self, node): 
     60        """Iterate all children (and children of children and so forth) 
     61        """ 
     62        children = self.get_children(node) 
     63        for c in children: 
     64            yield c 
     65            for cc in self.get_all_children(c): 
     66                yield cc 
    5867 
    5968    def get_ancestors(self, node): 
     
    182191    assert tree._nodes == [n1, n3, n4, n5, n2] 
    183192 
     193    all_ch = list(tree.get_all_children(n1)) 
     194    assert all_ch == [ n3, n4, n5 ], all_ch 
     195 
    184196    tree.remove(n4) 
    185197    assert tree._nodes == [n1, n3, n2] 
     
    191203    assert tree._nodes == [n2] 
    192204 
    193  
    194205if __name__ == '__main__': 
    195206    test_add() 
    196207    test_remove() 
     208 
     209# vi:sw=4:et 
  • gaphas/trunk/gaphas/view.py

    r997 r1013  
    6666 
    6767    def _update_bounds(self, bounds): 
    68         if not self._bounds: 
    69             self._bounds = Rectangle(*bounds) 
    70         else: 
    71             self._bounds += bounds 
     68        print 'update bounds with', bounds 
     69        if bounds: 
     70            if not self._bounds: 
     71                self._bounds = Rectangle(*bounds) 
     72            else: 
     73                self._bounds += bounds 
    7274 
    7375    def _extents(self, extents_func, line_width=False):