Changeset 1839

Show
Ignore:
Timestamp:
08/06/07 00:02:17 (1 year ago)
Author:
arj..@yirdis.nl
Message:
  • Use WeakKeyRefDictionary to store i2v/v2i matrices.
  • some doc updates.
Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • gaphas/trunk/gaphas/item.py

    r1816 r1839  
    77 
    88from math import atan2 
     9from weakref import WeakKeyDictionary 
    910 
    1011from matrix import Matrix 
     
    118119    Attributes: 
    119120 
    120     - _canvas:      canvas, which owns an item 
    121     - _handles:     list of handles owned by an item 
    122     - _constraints: item's constraints 
    123     - matrix:       item's transformation matrix 
    124     - _matrix_i2c:  item to canvas coordinates matrix 
    125     - _matrix_c2i:  canvas to item coordinates matrix 
    126     - _matrix_i2v:  item to view coordinates matrices 
    127     - _matrix_v2i:  view to item coordinates matrices 
    128     - _sort_key:  used to sort items 
     121    :matrix: item's transformation matrix 
     122    :canvas: canvas, which owns an item 
     123     
     124    Private: 
     125 
     126    :_canvas:      canvas, which owns an item 
     127    :_handles:     list of handles owned by an item 
     128    :_constraints: item's constraints 
     129    :_matrix_i2c:  item to canvas coordinates matrix 
     130    :_matrix_c2i:  canvas to item coordinates matrix 
     131    :_matrix_i2v:  item to view coordinates matrices 
     132    :_matrix_v2i:  view to item coordinates matrices 
     133    :_sort_key:  used to sort items 
    129134    """ 
    130135 
     
    135140        self._constraints = [] 
    136141 
     142        # used by gaphas.canvas.Canvas to hold conversion matrices 
    137143        self._matrix_i2c = None 
    138144        self._matrix_2ci = None 
    139         self._matrix_i2v = {} 
    140         self._matrix_v2i = {} 
    141  
     145 
     146        # used by gaphas.view.View to hold item 2 view matrices (view=key) 
     147        self._matrix_i2v = WeakKeyDictionary() 
     148        self._matrix_v2i = WeakKeyDictionary() 
     149 
     150        # Used by gaphas.sorter.Sorter to order items fast. 
    142151        self._sort_key = None 
    143152 
  • gaphas/trunk/gaphas/matrix.py

    r1732 r1839  
    44 
    55Matrix 
    6 -------------- 
    7 Small utility class wrapping cairo.Matrix. The UndoableMatrix class 
     6------ 
     7Small utility class wrapping cairo.Matrix. The `Matrix` class 
    88adds state preservation capabilities. 
    99""" 
  • gaphas/trunk/gaphas/view.py

    r1838 r1839  
    639639    def do_unrealize(self): 
    640640        if self.canvas: 
     641            # Although Item._matrix_{i2v|v2i} keys are automatically removed 
     642            # (weak refs), better do it explicitly to be sure. 
    641643            for item in self.canvas.get_all_items(): 
    642644                try: