Changeset 1643

Show
Ignore:
Timestamp:
07/16/07 10:23:39 (1 year ago)
Author:
wrobe..@pld-linux.org
Message:

- line connection cleanup

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • gaphas/branches/hw/gaphas/examples.py

    r1642 r1643  
    209209 
    210210            if abs(hx - ax) < 0.01: 
    211                 return handles[NW], handles[SW], (hy - ay) / (by - ay) 
     211                return handles[NW], handles[SW] 
    212212            elif abs(hy - ay) < 0.01: 
    213                 return handles[NW], handles[NE], (hx - ax) / (bx - ax) 
     213                return handles[NW], handles[NE] 
    214214            elif abs(hx - bx) < 0.01: 
    215                 return handles[NE], handles[SE],  (hy - ay) / (by - ay) 
     215                return handles[NE], handles[SE] 
    216216            else: 
    217                 return handles[SW], handles[SE], (hx - ax) / (bx - ax) 
     217                return handles[SW], handles[SE] 
    218218            assert False 
    219219 
     
    224224            except KeyError: 
    225225                pass # constraint was alreasy removed 
    226             handle._connect_constraint = None 
    227226            handle.connected_to = None 
    228227            # Remove disconnect handler: 
     
    233232        if glue_item and glue_item is handle.connected_to: 
    234233            try: 
    235                 view.canvas.solver.remove_constraint(handle._c1) 
    236                 view.canvas.solver.remove_constraint(handle._c2) 
     234                item.remove_iconstraint(handle) 
    237235            except KeyError: 
    238236                pass # constraint was already removed 
    239237 
    240  
    241             assert False, 'not now!' 
    242             h1, h2, b = side(handle, glue_item) 
    243             handle._c1 = BalanceConstraint(band=(h1.x, h1.x), v=handle.x) 
    244             handle._c2 = BalanceConstraint(band=(h2.y, h2.y), v=handle.y) 
    245             view.canvas.solver.add_constraint(handle._c1) 
    246             view.canvas.solver.add_constraint(handle._c2) 
     238            h1, h2 = side(handle, glue_item) 
     239            lc = LineConstraint(line=(h1.pos, h2.pos), point=handle.pos) 
     240            pdata = { 
     241                h1.pos: glue_item, 
     242                h2.pos: glue_item, 
     243                handle.pos: item, 
     244            } 
     245 
     246            view.canvas.proj(lc, xy=pdata) 
     247            view.canvas.proj(lc, xy=pdata, f=lc.update_ratio) 
     248            lc.update_ratio() 
     249            item.add_iconstraint(handle, lc) 
     250 
    247251            handle.disconnect = handle_disconnect 
    248252            return 
     
    254258        if glue_item: 
    255259            if isinstance(glue_item, Box): 
    256                 h1, h2, b = side(handle, glue_item) 
     260                h1, h2 = side(handle, glue_item) 
    257261 
    258262                # Make a constraint that keeps into account item coordinates.