LCOV - code coverage report
Current view: top level - src/engraving/dom - mscore.h Coverage Total Hit
Test: filtered_coverage.info Lines: 75.0 % 20 15
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 "global/containers.h"
      26              : 
      27              : #include "engraving/types/types.h"
      28              : 
      29              : namespace mu::engraving {
      30              : static constexpr size_t VOICES = 4;
      31              : 
      32       335305 : inline constexpr track_idx_t staff2track(staff_idx_t staffIdx, voice_idx_t voiceIdx = 0)
      33              : {
      34       335305 :     return staffIdx != muse::nidx ? staffIdx * VOICES + voiceIdx : muse::nidx;
      35              : }
      36              : 
      37     37332178 : inline constexpr staff_idx_t track2staff(track_idx_t track)
      38              : {
      39     37332178 :     return track != muse::nidx ? track / VOICES : muse::nidx;
      40              : }
      41              : 
      42      2536976 : inline constexpr voice_idx_t track2voice(track_idx_t track)
      43              : {
      44      2536976 :     return track != muse::nidx ? track % VOICES : muse::nidx;
      45              : }
      46              : 
      47        11133 : inline constexpr track_idx_t trackZeroVoice(track_idx_t track)
      48              : {
      49        11133 :     return track != muse::nidx ? (track / VOICES) * VOICES : muse::nidx;
      50              : }
      51              : 
      52           13 : inline constexpr bool isUpVoice(voice_idx_t voiceIdx)
      53              : {
      54           13 :     return !(voiceIdx & 1);
      55              : }
      56              : 
      57              : inline constexpr bool isDownVoice(voice_idx_t voiceIdx)
      58              : {
      59              :     return voiceIdx & 1;
      60              : }
      61              : 
      62              : static constexpr int MAX_HEADERS = 3;
      63              : static constexpr int MAX_FOOTERS = 3;
      64              : 
      65              : // UNIVERSAL UNITS
      66              : static constexpr double INCH      = 25.4; // millimitres per inch
      67              : static constexpr double PPI       = 72.0; // typographical points per inch
      68              : 
      69              : // INTERNAL DRAWING UNITS
      70              : static constexpr double DPI = 1200;
      71              : static constexpr double DPMM = DPI / INCH;
      72              : 
      73              : static constexpr double UI_ICONS_DEFAULT_FONT_SIZE = 12.0;
      74              : 
      75              : static constexpr int MAX_STAVES = 4;
      76              : 
      77              : static constexpr char mimeSymbolFormat[]     = "application/musescore/symbol";
      78              : static constexpr char mimeSymbolListFormat[] = "application/musescore/symbollist";
      79              : static constexpr char mimeStaffListFormat[]  = "application/musescore/stafflist";
      80              : 
      81              : static constexpr int INVALID_STRING_INDEX = -1; // no ordinal for a physical string (0 = topmost in instrument)
      82              : static constexpr int INVALID_FRET_INDEX   = -1; // no ordinal for a fret
      83              : 
      84              : static constexpr muse::ID INVALID_ID = 0;
      85              : 
      86              : //---------------------------------------------------------
      87              : //   TransposeDirection
      88              : //---------------------------------------------------------
      89              : 
      90              : enum class TransposeDirection : char {
      91              :     UP, DOWN, CLOSEST, UNKNOWN
      92              : };
      93              : 
      94              : //---------------------------------------------------------
      95              : //   TransposeMode
      96              : //---------------------------------------------------------
      97              : 
      98              : enum class TransposeMode : char {
      99              :     TO_KEY, BY_INTERVAL, DIATONICALLY, UNKNOWN
     100              : };
     101              : 
     102              : //---------------------------------------------------------
     103              : //   SelectType
     104              : //---------------------------------------------------------
     105              : 
     106              : enum class SelectType : char {
     107              :     SINGLE, RANGE, ADD, REPLACE
     108              : };
     109              : 
     110              : //---------------------------------------------------------
     111              : //   OffsetType
     112              : //---------------------------------------------------------
     113              : 
     114              : enum class OffsetType : unsigned char {
     115              :     ABS,         ///< offset in point units
     116              :     SPATIUM      ///< offset in staff space units
     117              : };
     118              : 
     119              : //---------------------------------------------------------
     120              : //   MScoreError
     121              : //---------------------------------------------------------
     122              : 
     123              : enum class MsError : unsigned char {
     124              :     MS_NO_ERROR,
     125              :     NO_NOTE_SELECTED,
     126              :     NO_CHORD_REST_SELECTED,
     127              :     NO_LYRICS_SELECTED,
     128              :     NO_NOTE_REST_SELECTED,
     129              :     NO_FLIPPABLE_SELECTED,
     130              :     NO_MEASURE_SELECTED,
     131              :     NO_STAFF_SELECTED,
     132              :     NO_NOTE_FIGUREDBASS_SELECTED,
     133              :     NO_NOTE_REST_HARMONY_SELECTED,
     134              :     CANNOT_INSERT_TUPLET,
     135              :     CANNOT_SPLIT_TUPLET,
     136              :     CANNOT_SPLIT_MEASURE_FIRST_BEAT,
     137              :     CANNOT_SPLIT_MEASURE_TUPLET,
     138              :     INSUFFICIENT_MEASURES,
     139              :     CANNOT_SPLIT_MEASURE_REPEAT,
     140              :     CANNOT_SPLIT_MEASURE_TOO_SHORT,
     141              :     CANNOT_REMOVE_TIME_TUPLET,
     142              :     CANNOT_REMOVE_TIME_MEASURE_REPEAT,
     143              :     NO_DEST,
     144              :     SOURCE_PARTIAL_TUPLET,
     145              :     DEST_TUPLET,
     146              :     TUPLET_CROSSES_BAR,
     147              :     DEST_LOCAL_TIME_SIGNATURE,
     148              :     SOURCE_PARTIAL_TREMOLO,
     149              :     DEST_TREMOLO,
     150              :     NO_MIME,
     151              :     DEST_NO_CR,
     152              :     CANNOT_CHANGE_LOCAL_TIMESIG_MEASURE_NOT_EMPTY,
     153              :     CANNOT_CHANGE_LOCAL_TIMESIG_HAS_EXCERPTS,
     154              :     CORRUPTED_MEASURE,
     155              :     CANNOT_REMOVE_KEY_SIG,
     156              :     CANNOT_JOIN_MEASURE_STAFFTYPE_CHANGE,
     157              :     CANNOT_REPEAT_SELECTION,
     158              :     TRANSPOSE_NO_FRET_DIAGRAM,
     159              :     CANNOT_EXPLODE_IMPLODE_LOCAL_TIMESIG,
     160              :     NO_SPACE_FOR_TUPLET,
     161              :     TUPLET_NOTE_VALUE_TOO_SHORT,
     162              : };
     163              : 
     164              : /// \cond PLUGIN_API \private \endcond
     165              : struct MScoreError {
     166              :     MsError no;
     167              :     const char* group;
     168              :     const char* txt;
     169              : };
     170              : 
     171              : //---------------------------------------------------------
     172              : //   MScore
     173              : //    MuseScore application object
     174              : //---------------------------------------------------------
     175              : 
     176              : class MScore
     177              : {
     178              :     static int _hRaster, _vRaster;
     179              :     static bool _verticalOrientation;
     180              : 
     181              : public:
     182              : 
     183              :     static MsError _error;
     184              :     static bool _errorIsWarning;
     185              : 
     186              :     static void registerUiTypes();
     187              : 
     188            0 :     static double hRaster() { return _hRaster; }
     189            0 :     static double vRaster() { return _vRaster; }
     190            0 :     static void setHRaster(int val) { _hRaster = val; }
     191            0 :     static void setVRaster(int val) { _vRaster = val; }
     192           16 :     static void setNudgeStep(double val) { nudgeStep = val; }
     193           16 :     static void setNudgeStep10(double val) { nudgeStep10 = val; }
     194           16 :     static void setNudgeStep50(double val) { nudgeStep50 = val; }
     195              : 
     196          161 :     static bool verticalOrientation() { return _verticalOrientation; }
     197            0 :     static void setVerticalOrientation(bool val) { _verticalOrientation = val; }
     198              : 
     199              :     static bool warnPitchRange;
     200              :     static bool warnGuitarBends;
     201              :     static int pedalEventsMinTicks;
     202              : 
     203              :     static double nudgeStep;
     204              :     static double nudgeStep10;
     205              :     static double nudgeStep50;
     206              : 
     207              : // #ifndef NDEBUG
     208              :     static bool noHorizontalStretch;
     209              :     static bool noVerticalStretch;
     210              :     static bool useFallbackFont;
     211              : // #endif
     212              :     static bool debugMode;
     213              :     static bool testMode;
     214              :     static bool testWriteStyleToScore;
     215              : 
     216              :     static bool saveTemplateMode;
     217              :     static bool noGui;
     218              : 
     219              :     static bool noImages;
     220              : 
     221              :     static bool pdfPrinting;
     222              :     static bool svgPrinting;
     223              : 
     224              :     static double verticalPageGap;
     225              :     static double horizontalPageGapEven;
     226              :     static double horizontalPageGapOdd;
     227              : 
     228         1289 :     static void setError(MsError e, bool warning = false) { _error = e; _errorIsWarning = warning; }
     229              : 
     230              :     static std::string errorToString(MsError err);
     231              : };
     232              : } // namespace mu::engraving
        

Generated by: LCOV version 2.0-1