lilypond-1.5.10
[lilypond.git] / lily / include / simple-spacer.hh
blob8115e25587d81df6221b0d83babe6b5187602397
1 /*
2 simple-spacer.hh -- declare Simple_spacer
4 source file of the GNU LilyPond music typesetter
6 (c) 1999--2001 Han-Wen Nienhuys <hanwen@cs.uu.nl>
8 */
10 #ifndef SIMPLE_SPACER_HH
11 #define SIMPLE_SPACER_HH
13 #include "parray.hh"
14 #include "lily-proto.hh"
17 struct Spring_description
19 Real ideal_f_;
20 Real hooke_f_;
21 bool active_b_;
23 Real block_force_f_;
25 Real length (Real force) const;
26 Spring_description ();
28 bool sane_b () const;
31 /**
32 A simple spacing constraint solver. The approach:
34 Stretch the line uniformly until none of the constraints (rods)
35 block. It then is very wide.
38 Compress until the next constraint blocks,
40 Mark the springs over the constrained part to be non-active.
42 Repeat with the smaller set of non-active constraints, until all
43 constraints blocked, or until the line is as short as desired.
45 This is much simpler, and much much faster than full scale
46 Constrained QP. On the other hand, a situation like this will not
47 be typeset as dense as possible, because
49 c4 c4 c4 c4
50 veryveryverylongsyllable2 veryveryverylongsyllable2
51 " "4 veryveryverylongsyllable2 syllable4
54 can be further compressed to
57 c4 c4 c4 c4
58 veryveryverylongsyllable2 veryveryverylongsyllable2
59 " "4 veryveryverylongsyllable2 syllable4
62 Perhaps this is not a bad thing, because the 1st looks better anyway. */
63 struct Simple_spacer
65 Array<Spring_description> springs_;
66 Link_array<Grob> spaced_cols_;
67 Link_array<Grob> loose_cols_;
68 Real force_f_;
69 Real indent_f_;
70 Real line_len_f_;
71 Real default_space_f_;
74 Simple_spacer ();
76 void solve (Column_x_positions *) const;
77 void add_columns (Link_array<Grob>);
78 void my_solve_linelen ();
79 void my_solve_natural_len ();
80 Real active_springs_stiffness () const;
81 Real range_stiffness (int, int) const;
82 void add_rod (int l, int r, Real dist);
83 Real range_ideal_len (int l, int r)const;
84 Real active_blocking_force ()const;
85 Real configuration_length ()const;
86 void set_active_states ();
87 bool active_b () const;
90 #endif /* SIMPLE_SPACER_HH */