DiaSolver

Name

DiaSolver -- A linear constraint solver.

Synopsis



#define     DIA_SOLVER                      (obj)
struct      DiaSolver;
DiaSolver*  dia_solver_new                  (void);
void        dia_solver_add_constraint       (DiaSolver *solver,
                                             DiaConstraint *constraint);
void        dia_solver_remove_constraint    (DiaSolver *solver,
                                             DiaConstraint *constraint);
void        dia_solver_resolve              (DiaSolver *solver);

Object Hierarchy


  GObject
   +----DiaSolver

Description

This is the main class of DiaCanvas2's constraint solving capabilities. One should create a set of constraints and add them to the solver. If you call dia_solver_resolve() the solver will try to satisfy all constraints. The variables that are changed depends on the strength of a variable: weaker variables are more likely to change than stronger variables. A good example is a box and a line: you probably want the line to move if you drag the box, but the box should stay where it is if the line is moved (this is the way lines and boxes are implemented by default in DiaCanvas2).

The solver can deal with cyclic constraints in quite a primitive way: it will keep track of the constraints it has resolved and will refuse to resolve a constraint twice. Due to the design of DiaCanvas2 it is quite unlikely complex cyclic relationships will occur.

Details

DIA_SOLVER()

#define DIA_SOLVER(obj)		(G_TYPE_CHECK_INSTANCE_CAST ((obj), DIA_TYPE_SOLVER, DiaSolver))

obj :


struct DiaSolver

struct DiaSolver;


dia_solver_new ()

DiaSolver*  dia_solver_new                  (void);

Create a new, empty constaint solver.

Returns :

A new constraint solver.


dia_solver_add_constraint ()

void        dia_solver_add_constraint       (DiaSolver *solver,
                                             DiaConstraint *constraint);

Add constraint to solver. The constraint is marked immutable.

solver :

constraint :


dia_solver_remove_constraint ()

void        dia_solver_remove_constraint    (DiaSolver *solver,
                                             DiaConstraint *constraint);

Remove constraint from the solver.

solver :

constraint :


dia_solver_resolve ()

void        dia_solver_resolve              (DiaSolver *solver);

Try to make all constraints true.

solver :

See Also

DiaConstraint, DiaExpression, DiaVariable, DiaStrength