Changeset 1075

Show
Ignore:
Timestamp:
11/17/06 04:43:44 (2 years ago)
Author:
arjanmol
Message:
  • item: added horizontal property to line
  • solver: added eq, ne to Variable
Files:

Legend:

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

    r1065 r1075  
    324324    @async(single=True, priority=PRIORITY_HIGH_IDLE) 
    325325    def update(self): 
    326         """Update the canavs, if called from within a gtk-mainloop, the 
     326        """Update the canvas, if called from within a gtk-mainloop, the 
    327327        update job is scheduled as idle job. 
    328328        """ 
  • gaphas/trunk/gaphas/item.py

    r1045 r1075  
    336336     - orthogonal (bool): wherther or not the line should be orthogonal 
    337337         (only straight angles) 
     338     - horizontal: first line segment is horizontal 
    338339     - line_width: width of the line to be drawn 
    339340 
     
    352353        self.fuzzyness = 0 
    353354        self._orthogonal = [] 
     355        self._horizontal = False 
    354356        self._head_angle = self._tail_angle = 0 
    355357 
     
    373375        add = self.canvas.solver.add_constraint 
    374376        cons = self._orthogonal 
     377        rest = self._horizontal and 1 or 0 
    375378        for pos, (h0, h1) in enumerate(zip(h, h[1:])): 
    376             if pos % 2: # odd 
     379            if pos % 2 == rest: # odd 
    377380                cons.append(add(eq(a=h0.x, b=h1.x))) 
    378381            else: 
     
    382385 
    383386    orthogonal = property(lambda s: s._orthogonal != [], _set_orthogonal) 
     387 
     388    def _set_horizontal(self, horizontal): 
     389        self._horizontal = horizontal 
     390        self._set_orthogonal(self._orthogonal) 
     391 
     392    horizontal = property(lambda s: s._horizontal != [], _set_horizontal) 
    384393 
    385394    def setup_canvas(self): 
  • gaphas/trunk/gaphas/solver.py

    r998 r1075  
    5959    def __float__(self): 
    6060        return float(self._value) 
     61 
     62    def __eq__(self, other): 
     63        """ 
     64        >>> Variable(5) == 5 
     65        True 
     66        >>> Variable(5) == 4 
     67        False 
     68        >>> Variable(5) != 5 
     69        False 
     70        """ 
     71        return self._value.__eq__(float(other)) 
     72 
     73    def __ne__(self, other): 
     74        """ 
     75        >>> Variable(5) != 4 
     76        True 
     77        >>> Variable(5) != 5 
     78        False 
     79        """ 
     80        return self._value.__ne__(float(other)) 
    6181 
    6282    def __gt__(self, other):