Changeset 1084

Show
Ignore:
Timestamp:
11/21/06 06:56:23 (2 years ago)
Author:
arjanmol
Message:

cleaned up gaphor.misc a bit, some more connector code

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • gaphor/branches/new-canvas/gaphor/__init__.py

    r1007 r1084  
    1111#del pygtk 
    1212 
    13 import misc.singleton 
    1413import misc.logger 
    1514 
  • gaphor/branches/new-canvas/gaphor/adapters/connectors.py

    r1081 r1084  
    1111from gaphor.diagram.interfaces import IConnect 
    1212from gaphor.diagram import items 
    13  
     13from gaphor.misc.ipair import ipair 
    1414 
    1515class AbstractConnect(object): 
     
    150150    def _glue(self, handle, x, y): 
    151151        """ 
    152         Return the point on the element (DiagramLine) closest to (x, y) 
     152        Return the segment and  point on the element (DiagramLine) 
     153        closest to (x, y). 
    153154        """ 
    154155        h = self.line.handles() 
    155156        pos = (x, y) 
    156         h0 = h[0] 
    157157        min_d = None 
    158158        segment = -1 
    159159        min_p = None 
    160160        dlp = geometry.distance_line_point 
    161         for s, h1 in enumerate(h[1:]): 
     161        for s, (h0, h1) in enumerate(ipair(h)): 
    162162            d, p = dlp(h0.pos, h1.pos, pos) 
    163163            if not s or d < min_d: 
     
    194194    Connect a comment line to a comment item. 
    195195    Connect Comment.annotatedElement to any element 
    196      
    197     TODO: adapt both ElementItem and DiagramLine 
    198     use component.provideAdapter? 
    199196    """ 
    200197    component.adapts(items.ElementItem, items.CommentLineItem) 
     
    248245component.provideAdapter(CommentLineElementConnect) 
    249246 
     247 
    250248class CommentLineLineConnect(LineConnect): 
    251249    """ 
    252250    Connect a comment line to a comment item. 
    253251    Connect Comment.annotatedElement to any element 
    254      
    255     TODO: adapt both ElementItem and DiagramLine 
    256     use component.provideAdapter? 
    257252    """ 
    258253    component.adapts(items.DiagramLine, items.CommentLineItem) 
     
    268263        connected_to = opposite.connected_to 
    269264        if connected_to is element: 
    270             #print 'item identical', connected_to, element 
    271265            return None 
    272266 
     
    275269                (not (connected_to.subject or element.subject)) \ 
    276270                 and connected_to.subject is element.subject: 
    277             #print 'Subjects none or match:', connected_to.subject, element.subject 
    278271            return None 
    279272 
  • gaphor/branches/new-canvas/gaphor/diagram/tests/test_handletool.py

    r1019 r1084  
    206206 
    207207 
     208# vim:sw=4:et:ai 
  • gaphor/branches/new-canvas/gaphor/tests/test_storage.py

    r1079 r1084  
    202202        c2 = diagram.create(items.ClassItem, subject=UML.create(UML.Class)) 
    203203        c2.matrix.translate(200, 200) 
    204         c2.request_update() 
    205         diagram.canvas.update_now() 
     204        diagram.canvas.update_matrix(c2) 
    206205        assert tuple(diagram.canvas.get_matrix_i2w(c2)) == (1, 0, 0, 1, 200, 200) 
    207206