2 dot-column.cc -- implement Dot_column
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--1999 Han-Wen Nienhuys <hanwen@cs.uu.nl>
10 #include "dot-column.hh"
11 #include "rhythmic-head.hh"
14 Dot_column::add_dots (Dots
*d
)
22 Dot_column::add_head (Rhythmic_head
*r
)
28 add_dots (r
->dots_l_
);
32 Dot_column::do_substitute_element_pointer (Score_element
*o
,Score_element
*n
)
34 Note_head_side::do_substitute_element_pointer (o
,n
);
35 if (Dots
* d
= dynamic_cast<Dots
*> (o
))
36 dot_l_arr_
.substitute (d
, dynamic_cast<Dots
*> (n
));
40 Dot_column::compare (Dots
* const &d1
, Dots
* const &d2
)
42 return d1
->position_i_
- d2
->position_i_
;
46 Dot_column::do_pre_processing ()
48 dot_l_arr_
.sort (Dot_column::compare
);
49 Note_head_side::do_pre_processing ();
52 Dot_column::Dot_column ()
54 notehead_align_dir_
= RIGHT
;
55 set_axes(X_AXIS
,X_AXIS
);
59 Will fuck up in this case.
74 Dot_column::do_post_processing ()
76 if (dot_l_arr_
.size () < 2)
81 Array
<int> taken_posns
;
83 for (int i
=0; i
< dot_l_arr_
.size (); i
++)
85 for (int j
=0; j
< taken_posns
.size (); j
++)
86 if (taken_posns
[j
] == dot_l_arr_
[i
]->position_i_
)
88 taken_posns
.push (dot_l_arr_
[i
]->position_i_
);
89 s
.unite (Slice (dot_l_arr_
[i
]->position_i_
,dot_l_arr_
[i
]->position_i_
));
95 int middle
= s
.center ();
99 int pos
= middle
- dot_l_arr_
.size () + 1;
101 pos
++; // center () rounds down.
103 for (int i
=0; i
<dot_l_arr_
.size (); pos
+= 2, i
++)
105 dot_l_arr_
[i
]->position_i_
= pos
;