Changeset 1793

Show
Ignore:
Timestamp:
07/30/07 14:09:18 (1 year ago)
Author:
wrobe..@pld-linux.org
Message:

- documentation updates

Files:

Legend:

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

    r1762 r1793  
    11""" 
    2 This module contains several flavors of constraint solver classes. 
    3 Each has a method solve_for(name) and a method set(\*\*kwds). These methods 
    4 are used by the constraint solver (solver.Solver) to set the variables. 
    5  
    6 Variables should be of type solver.Variable. 
    7  
    8 Available constraints are: 
    9  
    10 - EqualsConstraint - make 'a' and 'b' equal 
    11 - LessThanConstraint - ensure one variable stays smaller than the orther 
    12 - EquationConstraint - solve a linear equation 
    13  
    14 # TODO: 
    15  
    16 - LineConstraint - Solves the equation where a line is connected to 
    17        a line or side at a specific point. 
    18 - LineToCenterConstraint - constraint to be used when a line connects 
    19        to a rectangular element. The line is connected on the side, but 
    20        keeps opointing to the center 
    21 - ShortestLineConstraint - The last segment of the line is pointing to 
    22        a rectangualar or line like object and the length of the line 
    23        is kept to a minimum 
     2Module ``gaphas.constraint`` contains several flavors of constraint solver 
     3classes (constraints for short), for example 
     4 - equality constraint - two variables should have the same value 
     5 - less than constraint - keep one variables smaller than other 
     6 
     7Variables should be of type ``gaphas.solver.Variable``. 
     8 
     9See classes' documentation below for constraints description and for 
     10examples of their usage. 
     11 
     12New constraint class should derive from Constraint class abstract class and 
     13implement Constraint.solve_for(Variable) method to update a variable with 
     14appropriate value. 
    2415""" 
    2516 
     
    111102 
    112103 
    113  
    114  
    115104    def solve_for(self, var): 
    116105        """ 
     
    124113class EqualsConstraint(Constraint): 
    125114    """ 
    126     Simple Constraint, takes two arguments: 'a' and 'b'. When solved the 
    127     attribute passed to solve_for() is set equal to the other. 
    128  
     115    Constraint, which ensures that two arguments ``a`` and ``b`` are equal, 
     116    for example 
    129117    >>> from solver import Variable 
    130118    >>> a, b = Variable(1.0), Variable(2.0) 
     
    150138                (self.a, self.b.value) or \ 
    151139                (self.b, self.a.value))) 
     140 
    152141 
    153142 
     
    185174        v = (self.a.value + self.b.value) / 2.0 
    186175        _update(self.center, v) 
     176 
    187177 
    188178