MuseScore  3.4
Music composition and notation
repeatlist.h
Go to the documentation of this file.
1 //=============================================================================
2 // MuseScore
3 // Music Composition & Notation
4 //
5 // Copyright (C) 2009-2011 Werner Schweer
6 //
7 // This program is free software; you can redistribute it and/or modify
8 // it under the terms of the GNU General Public License version 2
9 // as published by the Free Software Foundation and appearing in
10 // the file LICENCE.GPL
11 //=============================================================================
12 
13 #ifndef __REPEATLIST_H__
14 #define __REPEATLIST_H__
15 
16 namespace Ms {
17 
18 class Score;
19 class Measure;
20 class Volta;
21 class Jump;
22 
23 //---------------------------------------------------------
24 // RepeatSegment
25 //---------------------------------------------------------
26 
28  private:
29  QList<std::pair<Measure*, int>> measureList; //measure, playbackCount
30  public:
31  int tick; // start tick
32  int utick;
33  qreal utime;
34  qreal timeOffset;
35 
36  RepeatSegment();
37  RepeatSegment(RepeatSegment * const, Measure * const fromMeasure, Measure * const untilMeasure);
38  void addMeasure(Measure * const);
39  bool containsMeasure(Measure const * const) const;
40  int len() const;
41  int playbackCount(Measure * const) const;
42 
43  Measure* firstMeasure() const { return measureList.empty() ? nullptr : measureList.front().first; }
44  Measure* lastMeasure() const { return measureList.empty() ? nullptr : measureList.back().first; }
45 
46  friend class RepeatList;
47  };
48 
49 //---------------------------------------------------------
50 // RepeatList
51 //---------------------------------------------------------
52 
53 class RepeatList: public QList<RepeatSegment*>
54  {
56  mutable unsigned idx1, idx2; // cached values
57 
58  bool _expanded = false;
59  bool _scoreChanged = true;
60 
61  std::map<Volta*, Measure*> _voltaRanges; // open volta possibly ends past the end of its spanner, used during unwind
62  std::set<Jump*> _jumpsTaken; // take the jumps only once, so track them during unwind
63 
64  void preProcessVoltas();
65  std::map<Volta*, Measure*>::const_iterator searchVolta(Measure * const) const;
66  void unwindSection(Measure * const fm, Measure * const em);
67  Measure* findStartRepeat(Measure * const) const;
68  int findStartFromRepeatCount(Measure * const startFrom) const;
69  bool isFinalPlaythrough(Measure * const measure, QList<RepeatSegment*>::const_iterator repeatSegmentIt) const;
70 
71  void unwind();
72  void flatten();
73 
74  public:
75  RepeatList(Score* s);
76  RepeatList(const RepeatList&) = delete;
77  RepeatList& operator=(const RepeatList&) = delete;
78  ~RepeatList();
79  void update(bool expand);
80  void setScoreChanged() { _scoreChanged = true; }
81  const Score* score() const { return _score; }
82  int utick2tick(int tick) const;
83  int tick2utick(int tick) const;
84  void dump() const;
85  int utime2utick(qreal) const;
86  qreal utick2utime(int) const;
87  void updateTempo();
88  int ticks() const;
89  };
90 
91 
92 } // namespace Ms
93 #endif
94 
RepeatSegment()
Definition: repeatlist.cpp:74
qreal timeOffset
Definition: repeatlist.h:34
Score * _score
Definition: repeatlist.h:55
void addMeasure(Measure *const)
Definition: repeatlist.cpp:106
one measure in a system
Definition: measure.h:65
std::map< Volta *, Measure * > _voltaRanges
Definition: repeatlist.h:61
Measure * firstMeasure() const
Definition: repeatlist.h:43
qreal utime
Definition: repeatlist.h:33
void setScoreChanged()
Definition: repeatlist.h:80
Definition: score.h:391
std::set< Jump * > _jumpsTaken
Definition: repeatlist.h:62
friend class RepeatList
Definition: repeatlist.h:46
Definition: repeatlist.h:53
bool empty() const
Definition: measure.cpp:2802
const Score * score() const
Definition: repeatlist.h:81
bool containsMeasure(Measure const *const) const
Definition: repeatlist.cpp:115
Definition: aeolus.cpp:26
QList< std::pair< Measure *, int > > measureList
Definition: repeatlist.h:29
int len() const
Definition: repeatlist.cpp:125
Definition: repeatlist.h:27
Measure * lastMeasure() const
Definition: repeatlist.h:44
int utick
Definition: repeatlist.h:32
int tick
Definition: repeatlist.h:31
int playbackCount(Measure *const) const
Definition: repeatlist.cpp:136
unsigned idx2
Definition: repeatlist.h:56