LCOV - code coverage report
Current view: top level - src/engraving/dom - harppedaldiagram.h Coverage Total Hit
Test: filtered_coverage.info Lines: 77.8 % 9 7
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) 2022 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 "textbase.h"
      26              : 
      27              : using namespace mu;
      28              : 
      29              : namespace mu::engraving {
      30              : enum class PedalPosition : unsigned char {
      31              :     FLAT,
      32              :     NATURAL,
      33              :     SHARP,
      34              : 
      35              :     UNSET                   // Only used in setDiagramText to represent the beginning of a score
      36              : };
      37              : 
      38              : // Use for indexes of _pedalState
      39              : enum HarpStringType : unsigned char {
      40              :     D, C, B, E, F, G, A
      41              : };
      42              : 
      43              : // Number of strings per octave on a harp
      44              : static constexpr int HARP_STRING_NO = 7;
      45              : 
      46              : class HarpPedalDiagram final : public TextBase
      47              : {
      48           36 :     OBJECT_ALLOCATOR(engraving, HarpPedalDiagram)
      49         1625 :     DECLARE_CLASSOF(ElementType::HARP_DIAGRAM)
      50              : 
      51              : public:
      52              :     HarpPedalDiagram(DummyParentOr<Segment> parent);
      53              :     HarpPedalDiagram(const HarpPedalDiagram& h);
      54              : 
      55            0 :     HarpPedalDiagram* clone() const override { return new HarpPedalDiagram(*this); }
      56              :     void setOwnershipParent(DummyParentOr<Segment> parent) { EngravingItem::setOwnershipParent(parent); }
      57            0 :     bool isEditable() const override { return false; }
      58              : 
      59           85 :     Segment* segment() const { return (Segment*)ownershipParent(); }
      60              :     Measure* measure() const { return (Measure*)ownershipParent()->ownershipParent(); }
      61              : 
      62              :     PropertyValue getProperty(Pid propertyId) const override;
      63              :     bool setProperty(Pid propertyId, const PropertyValue& v) override;
      64              :     PropertyValue propertyDefault(Pid id) const override;
      65              : 
      66              :     String accessibleInfo() const override;
      67              :     String screenReaderInfo() const override;
      68              : 
      69              :     void setIsDiagram(bool diagram);
      70          596 :     bool isDiagram() const { return m_isDiagram; }
      71              : 
      72          250 :     std::array<PedalPosition, HARP_STRING_NO> getPedalState() const { return m_pedalState; }
      73              :     void setPedalState(std::array<PedalPosition, HARP_STRING_NO> state);
      74              : 
      75              :     void setPedal(HarpStringType harpString, PedalPosition pedal);
      76              : 
      77              :     void setPlayableTpcs();
      78              : 
      79              :     String createDiagramText();
      80              :     void updateDiagramText();
      81              : 
      82              :     void undoChangePedalState(std::array<PedalPosition, HARP_STRING_NO> _pedalState);
      83              : 
      84              :     bool isTpcPlayable(int tpc);
      85            2 :     const std::set<int>& playableTpcs() const { return m_playableTpcs; }
      86              : 
      87           32 :     bool positionRelativeToNoteheadRest() const override { return true; }
      88              : 
      89              : private:
      90              : 
      91              :     std::array<PedalPosition, HARP_STRING_NO> m_pedalState;
      92              : 
      93              :     std::set<int> m_playableTpcs;
      94              : 
      95              :     bool m_isDiagram = true;
      96              : };
      97              : }
        

Generated by: LCOV version 2.0-1