LCOV - code coverage report
Current view: top level - src/engraving/dom - engravingobject.h Coverage Total Hit
Test: filtered_coverage.info Lines: 89.3 % 393 351
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 <type_traits>
      26              : #include <vector>
      27              : 
      28              : #include "global/allocator.h"
      29              : 
      30              : #include "../devtools/iengravingelementsprovider.h"
      31              : 
      32              : #include "../style/styledef.h"
      33              : 
      34              : #include "../types/propertyvalue.h"
      35              : #include "../types/types.h"
      36              : 
      37              : #include "../infrastructure/rtti.h" // IWYU pragma: export
      38              : #include "../infrastructure/eid.h"
      39              : 
      40              : namespace mu::engraving {
      41              : class Accidental;
      42              : class ActionIcon;
      43              : class Ambitus;
      44              : class Arpeggio;
      45              : class Articulation;
      46              : class BSymbol;
      47              : class BagpipeEmbellishment;
      48              : class BarLine;
      49              : class Beam;
      50              : class BeamSegment;
      51              : class Bend;
      52              : class Box;
      53              : class Bracket;
      54              : class BracketItem;
      55              : class Breath;
      56              : class Chord;
      57              : class ChordBracket;
      58              : class ChordLine;
      59              : class ChordRest;
      60              : class Clef;
      61              : class Capo;
      62              : class DeadSlapped;
      63              : class DummyParent;
      64              : class DurationElement;
      65              : class Dynamic;
      66              : class Expression;
      67              : class EngravingItem;
      68              : class EngravingObject;
      69              : class FBox;
      70              : class FSymbol;
      71              : class Fermata;
      72              : class FiguredBass;
      73              : class FiguredBassItem;
      74              : class Fingering;
      75              : class FretDiagram;
      76              : class Glissando;
      77              : class GlissandoSegment;
      78              : class GraceNotesGroup;
      79              : class GradualTempoChange;
      80              : class GradualTempoChangeSegment;
      81              : class GuitarBend;
      82              : class GuitarBendSegment;
      83              : class GuitarBendHold;
      84              : class GuitarBendHoldSegment;
      85              : class GuitarBendText;
      86              : class HBox;
      87              : class Hairpin;
      88              : class HairpinSegment;
      89              : class HammerOnPullOff;
      90              : class HammerOnPullOffSegment;
      91              : class HammerOnPullOffText;
      92              : class HarmonicMark;
      93              : class HarmonicMarkSegment;
      94              : class Harmony;
      95              : class HarpPedalDiagram;
      96              : class Hook;
      97              : class Image;
      98              : class IndicatorIcon;
      99              : class InstrumentChange;
     100              : class InstrumentName;
     101              : class Jump;
     102              : class KeySig;
     103              : class Lasso;
     104              : class LayoutBreak;
     105              : class LaissezVib;
     106              : class LaissezVibSegment;
     107              : class LedgerLine;
     108              : class LetRing;
     109              : class LetRingSegment;
     110              : class LineSegment;
     111              : class Lyrics;
     112              : class LyricsLine;
     113              : class LyricsLineSegment;
     114              : class MMRest;
     115              : class MMRestRange;
     116              : class Marker;
     117              : class MasterScore;
     118              : class Measure;
     119              : class MeasureBase;
     120              : class MeasureNumber;
     121              : class MeasureRepeat;
     122              : class MStyle;
     123              : class Note;
     124              : class NoteDot;
     125              : class NoteHead;
     126              : class NoteLine;
     127              : class NoteLineSegment;
     128              : class Ornament;
     129              : class Ottava;
     130              : class OttavaSegment;
     131              : class Page;
     132              : class PageLockIndicator;
     133              : class PalmMute;
     134              : class PalmMuteSegment;
     135              : class Parenthesis;
     136              : class Part;
     137              : class PartialLyricsLine;
     138              : class PartialLyricsLineSegment;
     139              : class PartialTie;
     140              : class PartialTieSegment;
     141              : class Pedal;
     142              : class PedalSegment;
     143              : class PickScrape;
     144              : class PickScrapeSegment;
     145              : class PlayCountText;
     146              : class PlayTechAnnotation;
     147              : class Rasgueado;
     148              : class RasgueadoSegment;
     149              : class RehearsalMark;
     150              : class Rest;
     151              : class Score;
     152              : class Segment;
     153              : class SharedPart;
     154              : class SLine;
     155              : class Slur;
     156              : class SlurSegment;
     157              : class SlurTie;
     158              : class SlurTieSegment;
     159              : class Spacer;
     160              : class Spanner;
     161              : class SpannerSegment;
     162              : class Staff;
     163              : class StaffLines;
     164              : class StaffState;
     165              : class StaffText;
     166              : class StaveSharingLabel;
     167              : class StaffTextBase;
     168              : class StaffTypeChange;
     169              : class StaffVisibilityIndicator;
     170              : class Stem;
     171              : class StemSlash;
     172              : class Sticking;
     173              : class StringTunings;
     174              : class Symbol;
     175              : class System;
     176              : class SystemDivider;
     177              : class SystemLockIndicator;
     178              : class SystemText;
     179              : class SoundFlag;
     180              : class Tapping;
     181              : class TappingHalfSlur;
     182              : class TappingHalfSlurSegment;
     183              : class TBox;
     184              : class TempoText;
     185              : class Text;
     186              : class TextBase;
     187              : class TextLine;
     188              : class TextLineBase;
     189              : class TextLineBaseSegment;
     190              : class TextLineSegment;
     191              : class Tie;
     192              : class TieSegment;
     193              : class TimeSig;
     194              : class TimeTickAnchor;
     195              : class TremoloBar;
     196              : class Trill;
     197              : class TrillSegment;
     198              : class TripletFeel;
     199              : class Tuplet;
     200              : class VBox;
     201              : class Vibrato;
     202              : class VibratoSegment;
     203              : class Volta;
     204              : class VoltaSegment;
     205              : class WhammyBar;
     206              : class WhammyBarSegment;
     207              : class ShadowNote;
     208              : 
     209              : class LinkedObjects;
     210              : 
     211              : enum class Pid : short;
     212              : enum class PropertyFlags : char;
     213              : 
     214              : using EngravingObjectList = std::vector<EngravingObject*>;
     215              : using EngravingItemList = std::vector<EngravingItem*>;
     216              : 
     217              : //! Parameter type for a parent that is either a real parent of one of the given types,
     218              : //! or the dummy, i.e. no parent at all. It holds nothing but the pointer and makes no
     219              : //! difference at runtime; the point is that "not attached to anything" has to be said
     220              : //! rather than slipped in as a pointer of the wrong kind.
     221              : //!
     222              : //! Best-effort only: it narrows what a call site can pass, it does not prove anything.
     223              : template<typename ... ParentTypes>
     224              : class DummyParentOr
     225              : {
     226              : public:
     227              :     template<typename T, std::enable_if_t<std::is_same_v<T, DummyParent>
     228              :                                           || (std::is_base_of_v<ParentTypes, T> || ...), int> = 0>
     229       655486 :     DummyParentOr(T* parent)
     230       655486 :         : m_parent(parent) {}
     231              : 
     232       658627 :     operator EngravingObject*() const {
     233       658627 :         return m_parent;
     234              :     }
     235              : 
     236              :     //! The parent as one of the accepted types, or null when it is the dummy - i.e.
     237              :     //! when there is no parent to speak to yet.
     238              :     template<typename T>
     239              :     T* as() const;
     240              : 
     241              : private:
     242              :     EngravingObject* m_parent = nullptr;
     243              : };
     244              : 
     245              : //! The given parent if there is one, the dummy otherwise.
     246              : template<typename T>
     247         2943 : DummyParentOr<T> parentOrDummy(T* parent, DummyParent* dummy)
     248              : {
     249         2943 :     return parent ? DummyParentOr<T>(parent) : DummyParentOr<T>(dummy);
     250              : }
     251              : 
     252              : class EngravingObject
     253              : {
     254              : public:
     255              :     EngravingObject(const ElementType& type, EngravingObject* parent);
     256              :     EngravingObject(const EngravingObject& se);
     257              : 
     258              :     virtual ~EngravingObject();
     259              : 
     260    340995834 :     inline ElementType type() const { return m_type; }
     261    118424977 :     inline bool isType(ElementType t) const { return t == m_type; }
     262              :     const char* typeName() const;
     263              :     virtual TranslatableString typeUserName() const;
     264              :     virtual String translatedTypeUserName() const;
     265              : 
     266              :     EID eid() const;
     267              :     void setEID(EID id) const;
     268              :     EID assignNewEID() const;
     269              : 
     270              :     //! The raw tree link, i.e. the inverse of children(): the ownership parent
     271              :     //! if there is one, otherwise the dummy the object is parked on. Prefer
     272              :     //! ownershipParent(), which reports "not attached to anything" as null.
     273              :     EngravingObject* parent() const;
     274              : 
     275              :     void setOwnershipParent(EngravingObject* p);
     276              :     //! The parent this object is attached to. Null while it is parked on the dummy,
     277              :     //! i.e. not attached to anything.
     278              :     EngravingObject* ownershipParent() const;
     279              :     void moveToDummy();
     280              : 
     281       570735 :     const EngravingObjectList& children() const { return m_children; }
     282              : 
     283              :     EngravingItemList childrenItems(bool all = false) const;
     284              :     std::vector<EngravingItem*> getChildren(bool includeInvisible = true) const;
     285            0 :     virtual void scanElements(std::function<void(EngravingItem*)>) {}
     286              : 
     287              :     // context
     288              :     virtual void setScore(Score* s);
     289              :     Score* score() const;
     290              :     MasterScore* masterScore() const;
     291              :     bool onSameScore(const EngravingObject* other) const;
     292              :     bool isInScoreTree() const;
     293              :     const MStyle& style() const;
     294              : 
     295      2022290 :     virtual EngravingObject* propertyDelegate(Pid) const { return nullptr; }
     296              :     virtual PropertyValue getProperty(Pid) const = 0;
     297              :     virtual bool setProperty(Pid, const PropertyValue&) = 0;
     298              :     virtual PropertyValue propertyDefault(Pid) const;
     299              :     virtual void resetProperty(Pid id);
     300            0 :     virtual bool sizeIsSpatiumDependent() const { return true; }
     301            2 :     virtual bool offsetIsSpatiumDependent() const { return true; }
     302              : 
     303              :     virtual void reset();                       // reset all properties & position to default
     304              : 
     305              :     virtual void initElementStyle(const ElementStyle*);
     306        85283 :     virtual const ElementStyle* styledProperties() const { return m_elementStyle; }
     307              : 
     308            0 :     virtual PropertyFlags* propertyFlagsList() const { return m_propertyFlagsList; }
     309              :     virtual PropertyFlags propertyFlags(Pid) const;
     310              :     bool isStyled(Pid pid) const;
     311              :     PropertyValue styleValue(Pid, Sid) const;
     312              : 
     313              :     virtual void setPropertyFlags(Pid, PropertyFlags);
     314              : 
     315              :     virtual Sid getPropertyStyle(Pid) const;
     316              : 
     317              :     virtual void styleChanged();
     318              : 
     319              :     virtual void undoChangeProperty(Pid id, const PropertyValue&, PropertyFlags ps);
     320              :     void undoChangeProperty(Pid id, const PropertyValue&);
     321              :     void undoResetProperty(Pid id);
     322              : 
     323              :     void undoPushProperty(Pid);
     324              : 
     325              :     std::list<EngravingObject*> linkList() const;
     326              : 
     327              :     void linkTo(EngravingObject*);
     328              :     void unlink();
     329              :     bool isLinked(EngravingObject* se = nullptr) const;
     330              : 
     331              :     virtual void undoUnlink();
     332       373495 :     LinkedObjects* links() const { return m_links; }
     333              :     void setLinks(LinkedObjects* le);
     334              : 
     335              : protected:
     336              :     virtual int getPropertyFlagsIdx(Pid id) const;
     337              : 
     338              :     //! NOTE For compatibility reasons, hope, we will remove the need for this method.
     339            1 :     void hack_setType(const ElementType& t) { m_type = t; }
     340              : 
     341              :     void addChild(EngravingObject* o);
     342              :     void removeChild(EngravingObject* o);
     343              : 
     344              :     const ElementStyle* m_elementStyle { &EMPTY_STYLE };
     345              :     PropertyFlags* m_propertyFlagsList = nullptr;
     346              :     LinkedObjects* m_links = nullptr;
     347              :     Score* m_score = nullptr;
     348              : 
     349              : private:
     350              :     static ElementStyle const EMPTY_STYLE;
     351              : 
     352              :     void doSetParent(EngravingObject* p);
     353              :     void doSetScore(Score* sc);
     354              : 
     355              :     ElementType m_type = ElementType::INVALID;
     356              : 
     357              :     EngravingObject* m_parent = nullptr;
     358              :     EngravingObjectList m_children;
     359              : 
     360              : public:
     361              : 
     362         5654 :     virtual std::list<EngravingObject*> linkListForPropertyPropagation() const { return linkList(); }
     363              : 
     364              :     //---------------------------------------------------
     365              :     // check type
     366              :     //
     367              :     // Example for ChordRest:
     368              :     //
     369              :     //    bool             isChordRest()
     370              :     //---------------------------------------------------
     371              : 
     372              : #define CONVERT(a, b) \
     373              :     bool is##a() const { return type() == ElementType::b; \
     374              :     }
     375              : 
     376      4983296 :     CONVERT(Note,          NOTE)
     377     17344936 :     CONVERT(Rest,          REST)
     378      4630872 :     CONVERT(MMRest,        MMREST)
     379            0 :     CONVERT(DeadSlapped,   DEAD_SLAPPED)
     380     20554408 :     CONVERT(Chord,         CHORD)
     381       729324 :     CONVERT(BarLine,       BAR_LINE)
     382      9570495 :     CONVERT(Articulation,  ARTICULATION)
     383      9457291 :     CONVERT(Ornament,      ORNAMENT)
     384      9414864 :     CONVERT(Fermata,       FERMATA)
     385        14146 :     CONVERT(Marker,        MARKER)
     386      1116153 :     CONVERT(Clef,          CLEF)
     387       119718 :     CONVERT(KeySig,        KEYSIG)
     388       281844 :     CONVERT(TimeSig,       TIMESIG)
     389     62425657 :     CONVERT(Measure,       MEASURE)
     390        16499 :     CONVERT(TempoText,     TEMPO_TEXT)
     391         1226 :     CONVERT(Breath,        BREATH)
     392     19531823 :     CONVERT(HBox,          HBOX)
     393     19603964 :     CONVERT(VBox,          VBOX)
     394     19348384 :     CONVERT(TBox,          TBOX)
     395     19324227 :     CONVERT(FBox,          FBOX)
     396       145814 :     CONVERT(Glissando,     GLISSANDO)
     397        73284 :     CONVERT(GlissandoSegment,     GLISSANDO_SEGMENT)
     398       181859 :     CONVERT(GuitarBend,    GUITAR_BEND)
     399        52456 :     CONVERT(GuitarBendSegment, GUITAR_BEND_SEGMENT)
     400       119384 :     CONVERT(GuitarBendHold, GUITAR_BEND_HOLD)
     401        45481 :     CONVERT(GuitarBendHoldSegment, GUITAR_BEND_HOLD_SEGMENT)
     402              :     CONVERT(GuitarBendText, GUITAR_BEND_TEXT)
     403           28 :     CONVERT(SystemDivider, SYSTEM_DIVIDER)
     404        14918 :     CONVERT(RehearsalMark, REHEARSAL_MARK)
     405        11728 :     CONVERT(TripletFeel, TRIPLET_FEEL)
     406       931010 :     CONVERT(Harmony,       HARMONY)
     407       163590 :     CONVERT(Volta,         VOLTA)
     408        12137 :     CONVERT(Jump,          JUMP)
     409       169338 :     CONVERT(Ottava,        OTTAVA)
     410        23015 :     CONVERT(LayoutBreak,   LAYOUT_BREAK)
     411            0 :     CONVERT(StaffVisibilityIndicator, STAFF_VISIBILITY_INDICATOR)
     412         4353 :     CONVERT(SystemLockIndicator, SYSTEM_LOCK_INDICATOR)
     413     21534728 :     CONVERT(Segment,       SEGMENT)
     414       566228 :     CONVERT(System,        SYSTEM)
     415      1594781 :     CONVERT(Lyrics,        LYRICS)
     416       813083 :     CONVERT(Stem,          STEM)
     417        62802 :     CONVERT(Beam,          BEAM)
     418         2564 :     CONVERT(Hook,          HOOK)
     419         5595 :     CONVERT(StemSlash,     STEM_SLASH)
     420        11472 :     CONVERT(LaissezVibSegment,    LAISSEZ_VIB_SEGMENT)
     421        36503 :     CONVERT(LaissezVib,    LAISSEZ_VIB)
     422          340 :     CONVERT(PartialTieSegment,    PARTIAL_TIE_SEGMENT)
     423        39493 :     CONVERT(PartialTie,    PARTIAL_TIE)
     424            1 :     CONVERT(Spacer,        SPACER)
     425       984676 :     CONVERT(StaffLines,    STAFF_LINES)
     426          357 :     CONVERT(Ambitus,       AMBITUS)
     427         2887 :     CONVERT(Bracket,       BRACKET)
     428         9879 :     CONVERT(InstrumentChange, INSTRUMENT_CHANGE)
     429           18 :     CONVERT(StaffTypeChange, STAFFTYPE_CHANGE)
     430       192168 :     CONVERT(Hairpin,       HAIRPIN)
     431       282240 :     CONVERT(HairpinSegment, HAIRPIN_SEGMENT)
     432         8939 :     CONVERT(Bend,          BEND)
     433         1627 :     CONVERT(TremoloBar,    TREMOLOBAR)
     434      4129303 :     CONVERT(MeasureRepeat, MEASURE_REPEAT)
     435        81382 :     CONVERT(Tuplet,        TUPLET)
     436         8410 :     CONVERT(NoteDot,       NOTEDOT)
     437       122452 :     CONVERT(Dynamic,       DYNAMIC)
     438        10415 :     CONVERT(Expression,    EXPRESSION)
     439       268548 :     CONVERT(InstrumentName, INSTRUMENT_NAME)
     440      4186107 :     CONVERT(Accidental,    ACCIDENTAL)
     441       167045 :     CONVERT(TextLine,      TEXTLINE)
     442       267484 :     CONVERT(TextLineSegment,      TEXTLINE_SEGMENT)
     443       161422 :     CONVERT(Pedal,         PEDAL)
     444       272597 :     CONVERT(PedalSegment,  PEDAL_SEGMENT)
     445       275226 :     CONVERT(OttavaSegment, OTTAVA_SEGMENT)
     446      4225134 :     CONVERT(LedgerLine,    LEDGER_LINE)
     447         2348 :     CONVERT(ActionIcon,    ACTION_ICON)
     448       263659 :     CONVERT(VoltaSegment,  VOLTA_SEGMENT)
     449       153649 :     CONVERT(NoteLine,      NOTELINE)
     450       253796 :     CONVERT(NoteLineSegment,      NOTELINE_SEGMENT)
     451       157955 :     CONVERT(Trill,         TRILL)
     452        57969 :     CONVERT(TrillSegment,  TRILL_SEGMENT)
     453       169128 :     CONVERT(LetRing,       LET_RING)
     454       268074 :     CONVERT(LetRingSegment, LET_RING_SEGMENT)
     455       167735 :     CONVERT(GradualTempoChange, GRADUAL_TEMPO_CHANGE)
     456       273431 :     CONVERT(GradualTempoChangeSegment, GRADUAL_TEMPO_CHANGE_SEGMENT)
     457       137833 :     CONVERT(Vibrato,       VIBRATO)
     458       163021 :     CONVERT(PalmMute,      PALM_MUTE)
     459       265099 :     CONVERT(PalmMuteSegment, PALM_MUTE_SEGMENT)
     460       161110 :     CONVERT(WhammyBar,      WHAMMY_BAR)
     461       267289 :     CONVERT(WhammyBarSegment, WHAMMY_BAR_SEGMENT)
     462       160583 :     CONVERT(Rasgueado,      RASGUEADO)
     463       259053 :     CONVERT(RasgueadoSegment, RASGUEADO_SEGMENT)
     464       160256 :     CONVERT(HarmonicMark,      HARMONIC_MARK)
     465       260155 :     CONVERT(HarmonicMarkSegment, HARMONIC_MARK_SEGMENT)
     466       160844 :     CONVERT(PickScrape,      PICK_SCRAPE)
     467       259072 :     CONVERT(PickScrapeSegment, PICK_SCRAPE_SEGMENT)
     468        58168 :     CONVERT(VibratoSegment,  VIBRATO_SEGMENT)
     469        14679 :     CONVERT(Symbol,        SYMBOL)
     470         6439 :     CONVERT(FSymbol,       FSYMBOL)
     471       304617 :     CONVERT(Fingering,     FINGERING)
     472            0 :     CONVERT(NoteHead,      NOTEHEAD)
     473         1732 :     CONVERT(PartialLyricsLine,    PARTIAL_LYRICSLINE)
     474          977 :     CONVERT(PartialLyricsLineSegment, PARTIAL_LYRICSLINE_SEGMENT)
     475        10017 :     CONVERT(FiguredBass,   FIGURED_BASS)
     476              :     CONVERT(FiguredBassItem, FIGURED_BASS_ITEM)
     477            5 :     CONVERT(StaffState,    STAFF_STATE)
     478       615597 :     CONVERT(Arpeggio,      ARPEGGIO)
     479       616985 :     CONVERT(ChordBracket,  CHORD_BRACKET)
     480          745 :     CONVERT(Image,         IMAGE)
     481      2645389 :     CONVERT(ChordLine,     CHORDLINE)
     482      2798158 :     CONVERT(FretDiagram,   FRET_DIAGRAM)
     483        11952 :     CONVERT(HarpPedalDiagram, HARP_DIAGRAM)
     484         1135 :     CONVERT(Page,          PAGE)
     485            0 :     CONVERT(PageLockIndicator, PAGE_LOCK_INDICATOR)
     486       590079 :     CONVERT(Text,          TEXT)
     487        22077 :     CONVERT(MeasureNumber, MEASURE_NUMBER)
     488            0 :     CONVERT(MMRestRange,   MMREST_RANGE)
     489        16586 :     CONVERT(StaffText,     STAFF_TEXT)
     490         6312 :     CONVERT(StaveSharingLabel, STAVE_SHARING_LABEL)
     491        12699 :     CONVERT(SystemText,    SYSTEM_TEXT)
     492           75 :     CONVERT(SoundFlag,     SOUND_FLAG)
     493         1530 :     CONVERT(PlayCountText, PLAY_COUNT_TEXT)
     494        17220 :     CONVERT(PlayTechAnnotation, PLAYTECH_ANNOTATION)
     495         8047 :     CONVERT(Capo,          CAPO)
     496       234462 :     CONVERT(BracketItem,   BRACKET_ITEM)
     497      2525568 :     CONVERT(Score,         SCORE)
     498        28533 :     CONVERT(Staff,         STAFF)
     499           10 :     CONVERT(Part,          PART)
     500       419759 :     CONVERT(SharedPart,    SHARED_PART)
     501            0 :     CONVERT(BagpipeEmbellishment, BAGPIPE_EMBELLISHMENT)
     502              :     CONVERT(Lasso,         LASSO)
     503         1673 :     CONVERT(Sticking,      STICKING)
     504         6762 :     CONVERT(GraceNotesGroup, GRACE_NOTES_GROUP)
     505        16341 :     CONVERT(StringTunings, STRING_TUNINGS)
     506         4875 :     CONVERT(TimeTickAnchor, TIME_TICK_ANCHOR)
     507     18127536 :     CONVERT(Parenthesis, PARENTHESIS)
     508            0 :     CONVERT(ShadowNote, SHADOW_NOTE)
     509        10777 :     CONVERT(HammerOnPullOff, HAMMER_ON_PULL_OFF)
     510         3445 :     CONVERT(HammerOnPullOffSegment, HAMMER_ON_PULL_OFF_SEGMENT)
     511          499 :     CONVERT(HammerOnPullOffText, HAMMER_ON_PULL_OFF_TEXT)
     512      9434121 :     CONVERT(Tapping, TAPPING)
     513         1922 :     CONVERT(TappingHalfSlur, TAPPING_HALF_SLUR)
     514        13461 :     CONVERT(TappingHalfSlurSegment, TAPPING_HALF_SLUR_SEGMENT)
     515              : #undef CONVERT
     516              : 
     517        24273 :     virtual bool isEngravingItem() const { return false; }   // overridden in element.h
     518      7218186 :     bool isRestFamily() const { return isRest() || isMMRest() || isMeasureRepeat(); }
     519      5603867 :     bool isChordRest() const { return isRestFamily() || isChord(); }
     520         7399 :     bool isDurationElement() const { return isChordRest() || isTuplet(); }
     521         1453 :     bool isSlurTie() const { return isSlur() || isTie(); }
     522         9967 :     bool isSlurTieSegment() const { return isSlurSegment() || isTieSegment(); }
     523              :     bool isSLineSegment() const;
     524     19416206 :     bool isBox() const { return isVBox() || isHBox() || isTBox() || isFBox(); }
     525       156380 :     bool isVBoxBase() const { return isVBox() || isTBox() || isFBox(); }
     526     19574633 :     bool isMeasureBase() const { return isMeasure() || isBox(); }
     527              :     bool isTextBase() const;
     528       267444 :     bool isTextLineBaseSegment() const
     529              :     {
     530       267444 :         return isHairpinSegment()
     531       262201 :                || isLetRingSegment()
     532       261860 :                || isGradualTempoChangeSegment()
     533       261609 :                || isTextLineSegment()
     534       260972 :                || isOttavaSegment()
     535       259226 :                || isPalmMuteSegment()
     536       259072 :                || isPickScrapeSegment()
     537       259050 :                || isWhammyBarSegment()
     538       259050 :                || isRasgueadoSegment()
     539       259006 :                || isHarmonicMarkSegment()
     540       258832 :                || isPedalSegment()
     541       257544 :                || isVoltaSegment()
     542       529645 :                || isNoteLineSegment();
     543              :     }
     544              : 
     545       661816 :     bool isSlur() const
     546              :     {
     547       661816 :         return type() == ElementType::SLUR || type() == ElementType::HAMMER_ON_PULL_OFF || type() == ElementType::TAPPING_HALF_SLUR;
     548              :     }
     549              : 
     550        62820 :     bool isSlurSegment() const
     551              :     {
     552       113731 :         return type() == ElementType::SLUR_SEGMENT || type() == ElementType::HAMMER_ON_PULL_OFF_SEGMENT
     553       113731 :                || type() == ElementType::TAPPING_HALF_SLUR_SEGMENT;
     554              :     }
     555              : 
     556        67414 :     bool isLineSegment() const
     557              :     {
     558        67414 :         return isGlissandoSegment()
     559        63174 :                || isLyricsLineSegment()
     560        61857 :                || isTextLineBaseSegment()
     561        51809 :                || isTrillSegment()
     562        51154 :                || isVibratoSegment()
     563        50984 :                || isGuitarBendSegment()
     564       130588 :                || isGuitarBendHoldSegment()
     565              :         ;
     566              :     }
     567              : 
     568        53936 :     bool isTieSegment() const
     569              :     {
     570        86492 :         return type() == ElementType::TIE_SEGMENT || type() == ElementType::LAISSEZ_VIB_SEGMENT
     571        86492 :                || type() == ElementType::PARTIAL_TIE_SEGMENT;
     572              :     }
     573              : 
     574       532730 :     bool isTie() const
     575              :     {
     576       532730 :         return type() == ElementType::TIE || type() == ElementType::LAISSEZ_VIB || type() == ElementType::PARTIAL_TIE;
     577              :     }
     578              : 
     579        59280 :     bool isSpannerSegment() const
     580              :     {
     581        59280 :         return isLineSegment() || isTextLineBaseSegment() || isSlurSegment() || isTieSegment();
     582              :     }
     583              : 
     584            7 :     bool isBSymbol() const { return isImage() || isSymbol(); }
     585       188911 :     bool isTextLineBase() const
     586              :     {
     587       188911 :         return isHairpin()
     588       168712 :                || isLetRing()
     589       167642 :                || isGradualTempoChange()
     590       166518 :                || isTextLine()
     591       165160 :                || isOttava()
     592       161611 :                || isPalmMute()
     593       160844 :                || isPickScrape()
     594       160800 :                || isWhammyBar()
     595       160580 :                || isRasgueado()
     596       160253 :                || isHarmonicMark()
     597       159567 :                || isPedal()
     598       156160 :                || isVolta()
     599       357623 :                || isNoteLine();
     600              :     }
     601              : 
     602       171820 :     bool isLyricsLine() const { return type() == ElementType::LYRICSLINE || type() == ElementType::PARTIAL_LYRICSLINE; }
     603              : 
     604       527213 :     bool isLyricsLineSegment() const
     605              :     {
     606       527213 :         return type() == ElementType::LYRICSLINE_SEGMENT || type() == ElementType::PARTIAL_LYRICSLINE_SEGMENT;
     607              :     }
     608              : 
     609       177188 :     bool isSLine() const
     610              :     {
     611       177188 :         return isTextLineBase() || isTrill() || isGlissando() || isVibrato() || isGuitarBend() || isGuitarBendHold();
     612              :     }
     613              : 
     614       593261 :     bool isSpanner() const
     615              :     {
     616       593261 :         return isSlur() || isTie() || isLyricsLine() || isSLine();
     617              :     }
     618              : 
     619         8382 :     bool isStaffTextBase() const
     620              :     {
     621        14215 :         return isStaffText() || isStaveSharingLabel() || isSystemText() || isTripletFeel() || isPlayTechAnnotation() || isCapo()
     622        14215 :                || isStringTunings();
     623              :     }
     624              : 
     625      9570409 :     bool isArticulationFamily() const
     626              :     {
     627      9570409 :         return isArticulation() || isOrnament() || isTapping();
     628              :     }
     629              : 
     630      9515731 :     bool isArticulationOrFermata() const
     631              :     {
     632      9515731 :         return isArticulationFamily() || isFermata();
     633              :     }
     634              : 
     635            0 :     bool isIndicatorIcon() const { return isSystemLockIndicator() || isPageLockIndicator() || isStaffVisibilityIndicator(); }
     636              : };
     637              : 
     638              : template<typename ... ParentTypes>
     639              : template<typename T>
     640        73033 : T* DummyParentOr<ParentTypes...>::as() const
     641              : {
     642        73033 :     return m_parent && !m_parent->isType(ElementType::DUMMY) ? static_cast<T*>(m_parent) : nullptr;
     643              : }
     644              : 
     645              : //---------------------------------------------------
     646              : // safe casting of EngravingObject
     647              : //
     648              : // Example for ChordRest:
     649              : //
     650              : //    ChordRest* toChordRest(EngravingItem* e)
     651              : //---------------------------------------------------
     652              : 
     653       432920 : static inline Rest* toRest(EngravingObject* e)
     654              : {
     655       432920 :     assert(!e || e->isRestFamily());
     656       432920 :     return (Rest*)e;
     657              : }
     658              : 
     659      1167187 : static inline const Rest* toRest(const EngravingObject* e)
     660              : {
     661      1167187 :     assert(!e || e->isRestFamily());
     662      1167187 :     return (const Rest*)e;
     663              : }
     664              : 
     665         1784 : static inline Articulation* toArticulation(EngravingObject* e)
     666              : {
     667         1784 :     assert(!e || e->isArticulationFamily());
     668         1784 :     return (Articulation*)e;
     669              : }
     670              : 
     671        14288 : static inline const Articulation* toArticulation(const EngravingObject* e)
     672              : {
     673        14288 :     assert(!e || e->isArticulationFamily());
     674        14288 :     return (const Articulation*)e;
     675              : }
     676              : 
     677           97 : static inline Arpeggio* toArpeggio(EngravingObject* e)
     678              : {
     679           97 :     assert(!e || e->isArpeggio() || e->isChordBracket());
     680           97 :     return (Arpeggio*)e;
     681              : }
     682              : 
     683          594 : static inline const Arpeggio* toArpeggio(const EngravingObject* e)
     684              : {
     685          594 :     assert(!e || e->isArpeggio() || e->isChordBracket());
     686          594 :     return (const Arpeggio*)e;
     687              : }
     688              : 
     689              : #define CONVERT(a)  \
     690              :     static inline a* to##a(EngravingObject * e) { assert(!e || e->is##a()); return (a*)e; } \
     691              :     static inline const a* to##a(const EngravingObject * e) { assert(!e || e->is##a()); return (const a*)e; }
     692              : 
     693      8433505 : CONVERT(EngravingItem)
     694      2245530 : CONVERT(Note)
     695      7557968 : CONVERT(Chord)
     696       515770 : CONVERT(BarLine)
     697         1989 : CONVERT(Ornament)
     698       112794 : CONVERT(Fermata)
     699         1274 : CONVERT(Marker)
     700       195755 : CONVERT(Clef)
     701        79603 : CONVERT(KeySig)
     702       155946 : CONVERT(TimeSig)
     703     26858768 : CONVERT(Measure)
     704       257245 : CONVERT(MeasureBase)
     705         6154 : CONVERT(DurationElement)
     706     11245804 : CONVERT(ChordRest)
     707         1374 : CONVERT(TempoText)
     708          158 : CONVERT(Breath)
     709        41721 : CONVERT(Box)
     710          974 : CONVERT(HBox)
     711          176 : CONVERT(VBox)
     712           30 : CONVERT(TBox)
     713           38 : CONVERT(FBox)
     714       489079 : CONVERT(Spanner)
     715        20439 : CONVERT(SpannerSegment)
     716          935 : CONVERT(Glissando)
     717              : CONVERT(GlissandoSegment)
     718        27650 : CONVERT(GuitarBend)
     719         1430 : CONVERT(GuitarBendSegment)
     720           18 : CONVERT(GuitarBendHold)
     721            6 : CONVERT(GuitarBendHoldSegment)
     722              : CONVERT(GuitarBendText)
     723           28 : CONVERT(SystemDivider)
     724         1342 : CONVERT(RehearsalMark)
     725            0 : CONVERT(Bend)
     726              : CONVERT(TripletFeel)
     727         6018 : CONVERT(Harmony)
     728          486 : CONVERT(Jump)
     729          217 : CONVERT(StaffText)
     730           18 : CONVERT(StaveSharingLabel);
     731         2193 : CONVERT(StaffTextBase)
     732        27835 : CONVERT(TextBase)
     733         2220 : CONVERT(TextLineBase)
     734            0 : CONVERT(TextLineBaseSegment)
     735          719 : CONVERT(PlayCountText)
     736           56 : CONVERT(PlayTechAnnotation)
     737           24 : CONVERT(Capo)
     738          436 : CONVERT(Ottava)
     739         4909 : CONVERT(LayoutBreak)
     740            0 : CONVERT(IndicatorIcon)
     741            0 : CONVERT(StaffVisibilityIndicator)
     742            0 : CONVERT(SystemLockIndicator)
     743      9288510 : CONVERT(Segment)
     744       260366 : CONVERT(System)
     745        93201 : CONVERT(Lyrics)
     746        73893 : CONVERT(Stem)
     747          704 : CONVERT(Beam)
     748         1697 : CONVERT(Hook)
     749         5595 : CONVERT(StemSlash)
     750            4 : CONVERT(SLine)
     751         8134 : CONVERT(LineSegment)
     752        24562 : CONVERT(Slur)
     753         3621 : CONVERT(SlurSegment)
     754         5397 : CONVERT(Tie)
     755         5201 : CONVERT(TieSegment)
     756         1453 : CONVERT(SlurTie)
     757         4271 : CONVERT(SlurTieSegment)
     758          182 : CONVERT(LaissezVibSegment)
     759          340 : CONVERT(PartialTieSegment)
     760            1 : CONVERT(Spacer)
     761            0 : CONVERT(StaffLines)
     762            0 : CONVERT(Ambitus)
     763         2816 : CONVERT(Bracket)
     764          181 : CONVERT(InstrumentChange)
     765           18 : CONVERT(StaffTypeChange)
     766         2652 : CONVERT(Text)
     767         2336 : CONVERT(MeasureNumber)
     768            0 : CONVERT(MMRestRange)
     769          733 : CONVERT(Hairpin)
     770          983 : CONVERT(HairpinSegment)
     771            7 : CONVERT(TremoloBar)
     772         2485 : CONVERT(MeasureRepeat)
     773          545 : CONVERT(MMRest)
     774         5816 : CONVERT(Tuplet)
     775          859 : CONVERT(NoteDot)
     776         5967 : CONVERT(Dynamic)
     777           86 : CONVERT(Expression)
     778       106272 : CONVERT(InstrumentName)
     779        29053 : CONVERT(Accidental)
     780           29 : CONVERT(TextLine)
     781            0 : CONVERT(TextLineSegment)
     782          115 : CONVERT(Pedal)
     783            0 : CONVERT(PedalSegment)
     784            0 : CONVERT(OttavaSegment)
     785              : CONVERT(LedgerLine)
     786            0 : CONVERT(ActionIcon)
     787         1496 : CONVERT(Volta)
     788          243 : CONVERT(VoltaSegment)
     789            4 : CONVERT(NoteLine)
     790              : CONVERT(NoteLineSegment)
     791          608 : CONVERT(Trill)
     792          232 : CONVERT(TrillSegment)
     793           19 : CONVERT(LetRing)
     794            0 : CONVERT(LetRingSegment)
     795           19 : CONVERT(GradualTempoChange)
     796            4 : CONVERT(GradualTempoChangeSegment)
     797           62 : CONVERT(Vibrato)
     798            0 : CONVERT(VibratoSegment)
     799           16 : CONVERT(PalmMute)
     800            0 : CONVERT(PalmMuteSegment)
     801            0 : CONVERT(WhammyBar)
     802            0 : CONVERT(WhammyBarSegment)
     803            0 : CONVERT(Rasgueado)
     804              : CONVERT(RasgueadoSegment)
     805            0 : CONVERT(HarmonicMark)
     806              : CONVERT(HarmonicMarkSegment)
     807            0 : CONVERT(PickScrape)
     808              : CONVERT(PickScrapeSegment)
     809            0 : CONVERT(Symbol)
     810            0 : CONVERT(FSymbol)
     811            7 : CONVERT(BSymbol)
     812         2504 : CONVERT(Fingering)
     813            0 : CONVERT(NoteHead)
     814         5410 : CONVERT(LyricsLine)
     815          929 : CONVERT(LyricsLineSegment)
     816          270 : CONVERT(FiguredBass)
     817              : CONVERT(FiguredBassItem)
     818            0 : CONVERT(StaffState)
     819            0 : CONVERT(ChordBracket)
     820            0 : CONVERT(Image)
     821          399 : CONVERT(ChordLine)
     822         4437 : CONVERT(FretDiagram)
     823          671 : CONVERT(HarpPedalDiagram)
     824          687 : CONVERT(Page)
     825            0 : CONVERT(PageLockIndicator)
     826          136 : CONVERT(SystemText)
     827          198 : CONVERT(BracketItem)
     828        11296 : CONVERT(Staff)
     829           10 : CONVERT(Part)
     830         1224 : CONVERT(SharedPart)
     831              : CONVERT(Lasso)
     832            0 : CONVERT(BagpipeEmbellishment)
     833          155 : CONVERT(Sticking)
     834         3381 : CONVERT(GraceNotesGroup)
     835            0 : CONVERT(DeadSlapped)
     836           19 : CONVERT(StringTunings)
     837            0 : CONVERT(SoundFlag)
     838          500 : CONVERT(TimeTickAnchor)
     839          344 : CONVERT(LaissezVib)
     840          941 : CONVERT(PartialTie)
     841           55 : CONVERT(PartialLyricsLine)
     842              : CONVERT(PartialLyricsLineSegment)
     843           65 : CONVERT(Parenthesis)
     844              : CONVERT(ShadowNote)
     845          183 : CONVERT(HammerOnPullOff)
     846          302 : CONVERT(HammerOnPullOffSegment)
     847            0 : CONVERT(HammerOnPullOffText)
     848          568 : CONVERT(Tapping)
     849           32 : CONVERT(TappingHalfSlur)
     850           72 : CONVERT(TappingHalfSlurSegment)
     851              : #undef CONVERT
     852              : }
        

Generated by: LCOV version 2.0-1