LCOV - code coverage report
Current view: top level - src/engraving/dom - range.h Coverage Total Hit
Test: filtered_coverage.info Lines: 100.0 % 6 6
Test Date: 2026-11-05 04:07:02

            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              : #pragma once
      24              : 
      25              : #include <list>
      26              : #include <vector>
      27              : 
      28              : #include "global/allocator.h"
      29              : 
      30              : #include "../types/fraction.h"
      31              : #include "../types/types.h"
      32              : 
      33              : namespace mu::engraving {
      34              : class EngravingItem;
      35              : class Measure;
      36              : class Tuplet;
      37              : class Segment;
      38              : class Spanner;
      39              : class ScoreRange;
      40              : class ChordRest;
      41              : class Chord;
      42              : class Note;
      43              : class Score;
      44              : class Tie;
      45              : class BarLine;
      46              : class Spacer;
      47              : class Marker;
      48              : class Volta;
      49              : 
      50              : //---------------------------------------------------------
      51              : //   TrackList
      52              : //---------------------------------------------------------
      53              : 
      54              : class TrackList : public std::vector<EngravingItem*>
      55              : {
      56          472 :     OBJECT_ALLOCATOR(engraving, TrackList)
      57              : 
      58              : public:
      59              :     typedef std::map<Chord*, Chord*> ClonedChordMap;
      60              : 
      61          236 :     TrackList(ScoreRange* r) { m_range = r; }
      62              :     ~TrackList();
      63              : 
      64           73 :     Fraction ticks() const { return m_duration; }
      65              :     ScoreRange* range() const { return m_range; }
      66              : 
      67          229 :     track_idx_t track() const { return m_track; }
      68          236 :     void setTrack(track_idx_t val) { m_track = val; }
      69              : 
      70              :     void read(const Segment* fs, const Segment* ls);
      71              :     bool write(Score*, const Fraction&) const;
      72              : 
      73              :     void appendGap(const Fraction&, Score* score);
      74              :     bool truncate(const Fraction&);
      75              :     void dump() const;
      76              : 
      77              : private:
      78              : 
      79              :     Tuplet* writeTuplet(Tuplet* parent, Tuplet* tuplet, Measure*& measure, Fraction& rest) const;
      80              :     void append(EngravingItem*);
      81              :     void appendTuplet(Tuplet* srcTuplet, Tuplet* dstTuplet);
      82              :     void combineTuplet(Tuplet* dst, Tuplet* src);
      83              : 
      84              :     Fraction m_duration;
      85              :     ScoreRange* m_range = nullptr;
      86              :     track_idx_t m_track = 0;
      87              :     ClonedChordMap m_clonedChord;
      88              : };
      89              : 
      90              : //---------------------------------------------------------
      91              : //   Annotation
      92              : //---------------------------------------------------------
      93              : 
      94              : struct Annotation {
      95              :     Fraction tick;
      96              :     EngravingItem* e = nullptr;
      97              : };
      98              : 
      99              : //---------------------------------------------------------
     100              : //   ScoreRange
     101              : //---------------------------------------------------------
     102              : 
     103              : class ScoreRange
     104              : {
     105              : public:
     106           51 :     ScoreRange() {}
     107              :     ~ScoreRange();
     108              :     void read(Segment* first, Segment* last, bool readSpanner = true);
     109              :     bool write(Score*, const Fraction&) const;
     110              :     Fraction ticks() const;
     111              :     Segment* first() const { return m_first; }
     112              :     Segment* last() const { return m_last; }
     113              :     void fill(const Fraction&);
     114              :     bool truncate(const Fraction&);
     115              : 
     116              : protected:
     117              :     std::vector<Spanner*> m_spanner;
     118              :     std::vector<Annotation> m_annotations;
     119              : 
     120              : private:
     121              :     struct BarLinesBackup
     122              :     {
     123              :         Fraction sPosition;
     124              :         bool formerMeasureStartOrEnd;
     125              :         BarLine* bl = nullptr;
     126              :     };
     127              :     std::vector<BarLinesBackup> m_barLines;
     128              : 
     129              :     void backupBarLines(Segment* first, Segment* last);
     130              :     bool insertBarLine(Measure* m, const BarLinesBackup& barLine) const;
     131              :     void restoreBarLines(Score* score, const Fraction& tick) const;
     132              :     void deleteBarLines();
     133              : 
     134              :     struct BreaksBackup
     135              :     {
     136              :         Fraction sPosition;
     137              :         LayoutBreakType lBreakType;
     138              :     };
     139              :     std::vector<BreaksBackup> m_breaks;
     140              : 
     141              :     void backupBreaks(Segment* first, Segment* last);
     142              :     void restoreBreaks(Score* score, const Fraction& tick) const;
     143              : 
     144              :     struct StartEndRepeatBackup
     145              :     {
     146              :         Fraction sPosition;
     147              :         bool isStartRepeat;
     148              :     };
     149              :     std::vector<StartEndRepeatBackup> m_startEndRepeats;
     150              : 
     151              :     void backupRepeats(Segment* first, Segment* last);
     152              :     void restoreRepeats(Score* score, const Fraction& tick) const;
     153              : 
     154              :     struct SpacerBackup
     155              :     {
     156              :         Fraction sPosition;
     157              :         staff_idx_t staffIdx;
     158              :         Spacer* s = nullptr;
     159              :     };
     160              : 
     161              :     void backupSpacers(Segment* first, Segment* last);
     162              :     void restoreSpacers(Score* score, const Fraction& tick) const;
     163              :     void deleteSpacers();
     164              : 
     165              :     struct JumpsMarkersBackup
     166              :     {
     167              :         Fraction sPosition;
     168              :         EngravingItem* e = nullptr;
     169              :     };
     170              : 
     171              :     bool endOfMeasureElement(EngravingItem* e) const;
     172              :     void backupJumpsAndMarkers(Segment* first, Segment* last);
     173              :     void restoreJumpsAndMarkers(Score* score, const Fraction& tick) const;
     174              :     void deleteJumpsAndMarkers();
     175              : 
     176              :     void restoreVolta(Score* score, const Fraction& tick, Volta* v) const;
     177              : 
     178              :     friend class TrackList;
     179              : 
     180              :     std::vector<TrackList*> m_tracks;
     181              :     std::vector<Tie*> m_startTies;
     182              :     std::vector<SpacerBackup> m_spacers;
     183              :     std::vector<JumpsMarkersBackup> m_jumpsMarkers;
     184              :     Segment* m_first = nullptr;
     185              :     Segment* m_last = nullptr;
     186              : };
     187              : }
        

Generated by: LCOV version 2.0-1