Changeset 997
- Timestamp:
- 09/06/06 02:24:06 (2 years ago)
- Files:
-
- gaphas/trunk/ChangeLog (modified) (1 diff)
- gaphas/trunk/demo.py (modified) (1 diff)
- gaphas/trunk/gaphas/canvas.py (modified) (4 diffs)
- gaphas/trunk/gaphas/constraint.py (modified) (1 diff)
- gaphas/trunk/gaphas/item.py (modified) (1 diff)
- gaphas/trunk/gaphas/tree.py (modified) (1 diff)
- gaphas/trunk/gaphas/view.py (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
gaphas/trunk/ChangeLog
r984 r997 1 2006-09-06 Arjan Molenaar <arjan_at_yirdis_dot_nl> 2 3 * There have been several fixes from within the gaphas tree. 4 * util.py: new file. 5 * canvas.py: fixed remove behavior up to some degree (should still 6 handle handles and constraints). 7 1 8 2006-08-26 Arjan Molenaar <arjan_at_yirdis_dot_nl> 2 9 gaphas/trunk/demo.py
r978 r997 212 212 v.add(b) 213 213 214 b = gtk.Button('Delete focused') 215 216 def on_clicked(button): 217 if view.focused_item: 218 canvas.remove(view.focused_item) 219 print 'items:', canvas.get_all_items() 220 221 b.connect('clicked', on_clicked) 222 v.add(b) 223 214 224 # b = gtk.Button('Cursor') 215 225 # gaphas/trunk/gaphas/canvas.py
r991 r997 79 79 [] 80 80 >>> i._canvas 81 82 TODO: Remove constraints on items connected to the removed item 81 83 """ 82 84 self._tree.remove(item) 83 85 item.canvas = None 86 87 self._update_views((item,)) 84 88 self._dirty_items.discard(item) 85 89 self._dirty_matrix_items.discard(item) 86 90 87 88 91 def get_all_items(self): 89 92 """Get a list of all items … … 164 167 [<gaphas.item.Item ...>] 165 168 >>> list(c.get_children(i)) 166 [<gaphas.item.Item ...> , <gaphas.item.Item ...>]169 [<gaphas.item.Item ...>] 167 170 """ 168 171 return self._tree.get_children(item) 172 173 def get_connected_items(self, item): 174 """Return a set of items that are connected to @item. 175 The list contains tuples (item, handle). As a result an item may be 176 in the list more than once (depending on the number of handles that 177 are connected). If @item is connected to itself it will also appear 178 in the list. 179 180 >>> c = Canvas() 181 >>> from gaphas import item 182 >>> i = item.Line() 183 >>> c.add(i) 184 >>> ii = item.Line() 185 >>> c.add(ii) 186 >>> iii = item.Line() 187 >>> c.add (iii) 188 >>> i.handles()[0].connected_to = ii 189 >>> list(c.get_connected_items(i)) 190 [] 191 >>> ii.handles()[0].connected_to = iii 192 >>> list(c.get_connected_items(ii)) 193 [(<gaphas.item.Line ...>, <Handle object on (0, 0)>)] 194 >>> list(c.get_connected_items(iii)) 195 [(<gaphas.item.Line ...>, <Handle object on (0, 0)>)] 196 """ 197 connected_items = set() 198 for i in self.get_all_items(): 199 for h in i.handles(): 200 if h.connected_to is item: 201 connected_items.add((i, h)) 202 return connected_items 169 203 170 204 def get_matrix_i2w(self, item, calculate=False): … … 254 288 @async(single=True, priority=PRIORITY_HIGH_IDLE) 255 289 def update(self): 290 """Update the canavs, if called from within a gtk-mainloop, the 291 update job is scheduled as idle job. 292 """ 256 293 if not self._in_update: 257 294 self.update_now() … … 405 442 if __name__ == '__main__': 406 443 import doctest 407 doctest.testmod( )444 doctest.testmod(optionflags=doctest.ELLIPSIS) 408 445 409 446 # vim:sw=4:et gaphas/trunk/gaphas/constraint.py
r989 r997 32 32 33 33 def variables(self): 34 """return an iterator which iterates over the variables that are 35 held by this constraint. 36 """ 34 37 raise NotImplemented 35 38 36 39 def solve_for(self, var): 40 """Solve the constraint for a given variable. 41 The variable itself is updated. 42 """ 37 43 raise NotImplemented 38 44 gaphas/trunk/gaphas/item.py
r995 r997 381 381 """ 382 382 for c in self._orthogonal: 383 self.canvas.solver.remove (c)383 self.canvas.solver.remove_constraint(c) 384 384 385 385 def split_segment(self, segment, parts=2): gaphas/trunk/gaphas/tree.py
r945 r997 97 97 """ 98 98 # First remove children: 99 children = self._children[node]99 children = list(self._children[node]) 100 100 for c in children: 101 101 self.remove(c) gaphas/trunk/gaphas/view.py
r967 r997 328 328 329 329 # Make sure everything's updated 330 self.request_update(self. canvas.get_all_items())330 self.request_update(self._canvas.get_all_items()) 331 331 a = self.allocation 332 332 super(View, self).queue_draw_area(0, 0, a.width, a.height) … … 385 385 assert self.canvas 386 386 wx, wy = self.transform_point_c2w(x, y) 387 return self. canvas.get_matrix_w2i(item).transform_point(wx, wy)387 return self._canvas.get_matrix_w2i(item).transform_point(wx, wy) 388 388 389 389 def transform_point_i2c(self, item, x, y): … … 391 391 """ 392 392 assert self.canvas 393 wx, wy = self. canvas.get_matrix_i2w(item).transform_point(x, y)393 wx, wy = self._canvas.get_matrix_i2w(item).transform_point(x, y) 394 394 return self.transform_point_w2c(wx, wy) 395 395 … … 473 473 with_handles.add(self._focused_item) 474 474 475 all_items = self._canvas.get_all_items() 476 removed = [i for i in items if i not in all_items] 477 475 478 for i in items: 476 479 self.queue_draw_item(i, handles=(i in with_handles)) 480 481 # Remove removed items: 482 for i in removed: 483 self.selected_items.discard(i) 484 if i is self.focused_item: 485 self.focused_item = None 486 if i is self.hovered_item: 487 self.hovered_item = None 477 488 478 489 # Pseudo-draw … … 552 563 553 564 # Force recalculation of the bounding boxes: 554 self.request_update(self. canvas.get_all_items())565 self.request_update(self._canvas.get_all_items()) 555 566 556 567 a = self.allocation
