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-19 04:14:36

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

Generated by: LCOV version 2.0-1