Line data Source code
1 : /*
2 : * SPDX-License-Identifier: GPL-3.0-only
3 : * MuseScore-Studio-CLA-applies
4 : *
5 : * MuseScore Studio
6 : * Music Composition & Notation
7 : *
8 : * Copyright (C) 2021 MuseScore Limited and others
9 : *
10 : * This program is free software: you can redistribute it and/or modify
11 : * it under the terms of the GNU General Public License version 3 as
12 : * published by the Free Software Foundation.
13 : *
14 : * This program is distributed in the hope that it will be useful,
15 : * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 : * GNU General Public License for more details.
18 : *
19 : * You should have received a copy of the GNU General Public License
20 : * along with this program. If not, see <https://www.gnu.org/licenses/>.
21 : */
22 :
23 : #ifndef MU_ENGRAVING_GROUPS_H
24 : #define MU_ENGRAVING_GROUPS_H
25 :
26 : #include <unordered_map>
27 :
28 : #include "../types/groupnode.h"
29 : #include "../types/types.h"
30 : #include "durationtype.h"
31 :
32 : namespace mu::engraving {
33 : class ChordRest;
34 :
35 : //---------------------------------------------------------
36 : // @@ Groups
37 : /// GroupNodes must be sorted by tick
38 : //---------------------------------------------------------
39 :
40 : class Groups
41 : {
42 : public:
43 3604 : Groups() {}
44 266 : Groups(const GroupNodes& nodes)
45 266 : : m_nodes(nodes) {}
46 :
47 28 : const GroupNodes& nodes() const { return m_nodes; }
48 154314 : bool empty() const { return m_nodes.empty(); }
49 30 : void addNode(const GroupNode& n) { m_nodes.push_back(n); }
50 :
51 : BeamMode beamMode(int tick, DurationType d) const;
52 : void addStop(int pos, DurationType d, BeamMode bm);
53 125 : bool operator==(const Groups& g) const
54 : {
55 125 : if (g.m_nodes.size() != m_nodes.size()) {
56 0 : return false;
57 : }
58 125 : for (size_t i = 0; i < m_nodes.size(); ++i) {
59 0 : if (!(g.m_nodes.at(i) == m_nodes.at(i))) {
60 0 : return false;
61 : }
62 : }
63 125 : return true;
64 : }
65 :
66 : void dump(const char*) const;
67 :
68 : static const Groups& endings(const Fraction& f);
69 : static BeamMode baseBeamMode(const ChordRest* cr, const ChordRest* prev = 0);
70 : static BeamMode actualBeamMode(const ChordRest* cr, const ChordRest* prev);
71 : static BeamMode actualBeamMode(const ChordRest* cr, const ChordRest* prev, const std::unordered_map<int, TDuration>* beatSubdivision);
72 :
73 : private:
74 : GroupNodes m_nodes;
75 : };
76 : } // namespace mu::engraving
77 :
78 : #endif
|