]> git.donarmstrong.com Git - lilypond.git/blob - lily/include/simple-spacer.hh
release: 1.2.8
[lilypond.git] / lily / include / simple-spacer.hh
1 /*   
2   simple-spacer.hh -- declare Simple_spacer
3   
4   source file of the GNU LilyPond music typesetter
5   
6   (c) 1999 Han-Wen Nienhuys <hanwen@cs.uu.nl>
7   
8  */
9
10 #ifndef SIMPLE_SPACER_HH
11 #define SIMPLE_SPACER_HH
12
13 #include "parray.hh"
14 #include "line-spacer.hh"
15
16
17 struct Spring_description
18 {
19   Real ideal_f_;
20   Real hooke_f_;
21   bool active_b_;
22
23   Real block_force_f_;
24
25   Real length (Real force) const;
26   Spring_description ();
27   Real energy_f (Real) const;
28 };
29
30 /**
31    A simple spacing constraint solver. The approach:
32
33    Stretch the line uniformly until none of the constraints (rods)
34    block.  It then is very wide.
35
36
37       Compress until the next constraint blocks,
38
39       Mark the springs over the constrained part to be non-active.
40       
41    Repeat with the smaller set of non-active constraints, until all
42    constraints blocked, or until the line is as short as desired.
43
44    This is much simpler, and much much faster than full scale
45    Constrained QP. On the other hand, a situation like this will not
46    be typeset as dense as possible, because
47
48    c4                   c4           c4                  c4
49    veryveryverylongsyllable2         veryveryverylongsyllable2
50    " "4                 veryveryverylongsyllable2        syllable4
51
52
53    can be further compressed to
54
55
56    c4    c4                        c4   c4
57    veryveryverylongsyllable2       veryveryverylongsyllable2
58    " "4  veryveryverylongsyllable2      syllable4
59
60
61    Perhaps this is not a bad thing, because the 1st looks better anyway.  */
62 struct Simple_spacer: public Line_spacer
63 {
64   Array<Spring_description> springs_;
65   Real force_f_;
66
67   Simple_spacer ();
68   
69   virtual void solve (Column_x_positions *) const;
70   virtual void lower_bound_solution (Column_x_positions *) const;
71   virtual void add_columns (Link_array<Paper_column>);
72     
73   void my_solve_linelen ();
74   void my_solve_natural_len ();
75   Real active_springs_stiffness () const;
76   Real range_stiffness (int, int) const;
77   void add_rod (int l, int r, Real dist);
78   Real range_ideal_len (int l, int r)const;
79   Real active_blocking_force ()const;
80   Real configuration_length ()const;
81   void set_active_states ();
82   Real energy_f () const;
83
84   bool active_b () const;
85 };
86
87 #endif /* SIMPLE_SPACER_HH */
88