1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
|
/*
This file is part of LilyPond, the GNU music typesetter.
Copyright (C) 2011--2015 Mike Solomon <mike@mikesolomon.org>
LilyPond is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
LilyPond is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with LilyPond. If not, see <http://www.gnu.org/licenses/>.
*/
#include "engraver.hh"
#include "international.hh"
#include "pointer-group-interface.hh"
#include "spanner.hh"
#include "stream-event.hh"
#include "warn.hh"
#include "item.hh"
#include "translator.icc"
class Concurrent_hairpin_engraver : public Engraver
{
public:
TRANSLATOR_DECLARATIONS (Concurrent_hairpin_engraver);
protected:
void acknowledge_hairpin (Grob_info);
void acknowledge_end_hairpin (Grob_info);
void stop_translation_timestep ();
void finalize ();
private:
vector<Grob *> arriving_hairpins_;
vector<Grob *> departing_hairpins_;
vector<Grob *> hairpins_hanging_out_;
};
Concurrent_hairpin_engraver::Concurrent_hairpin_engraver ()
{
}
void
Concurrent_hairpin_engraver::acknowledge_hairpin (Grob_info info)
{
arriving_hairpins_.push_back (info.grob ());
}
void
Concurrent_hairpin_engraver::acknowledge_end_hairpin (Grob_info info)
{
departing_hairpins_.push_back (info.grob ());
}
void
Concurrent_hairpin_engraver::stop_translation_timestep ()
{
for (vsize i = 0; i < departing_hairpins_.size (); i++)
for (vsize j = 0; j < hairpins_hanging_out_.size (); j++)
if (departing_hairpins_[i] == hairpins_hanging_out_[j])
{
hairpins_hanging_out_.erase (hairpins_hanging_out_.begin () + j);
break;
}
if (arriving_hairpins_.size ())
{
if (arriving_hairpins_.size () > 1)
for (vsize i = 0; i < arriving_hairpins_.size () - 1; i++)
for (vsize j = i + 1; j < arriving_hairpins_.size (); j++)
{
Pointer_group_interface::add_grob (arriving_hairpins_[i], ly_symbol2scm ("concurrent-hairpins"), arriving_hairpins_[j]);
Pointer_group_interface::add_grob (arriving_hairpins_[j], ly_symbol2scm ("concurrent-hairpins"), arriving_hairpins_[i]);
}
for (vsize i = 0; i < arriving_hairpins_.size (); i++)
for (vsize j = 0; j < hairpins_hanging_out_.size (); j++)
{
Pointer_group_interface::add_grob (arriving_hairpins_[i], ly_symbol2scm ("concurrent-hairpins"), hairpins_hanging_out_[j]);
Pointer_group_interface::add_grob (hairpins_hanging_out_[j], ly_symbol2scm ("concurrent-hairpins"), arriving_hairpins_[i]);
}
}
hairpins_hanging_out_.insert (hairpins_hanging_out_.end (), arriving_hairpins_.begin (), arriving_hairpins_.end ());
arriving_hairpins_.resize (0);
departing_hairpins_.resize (0);
}
void
Concurrent_hairpin_engraver::finalize ()
{
hairpins_hanging_out_.resize (0);
}
void
Concurrent_hairpin_engraver::boot ()
{
ADD_ACKNOWLEDGER (Concurrent_hairpin_engraver, hairpin);
ADD_END_ACKNOWLEDGER (Concurrent_hairpin_engraver, hairpin);
}
ADD_TRANSLATOR (Concurrent_hairpin_engraver,
/* doc */
"Collect concurrent hairpins.",
/* create */
"",
/* read */
"",
/* write */
""
);
|