MUSX Document Model
Loading...
Searching...
No Matches
Tie.h
1/*
2 * Copyright (C) 2025, Robert Patterson
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a copy
5 * of this software and associated documentation files (the "Software"), to deal
6 * in the Software without restriction, including without limitation the rights
7 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 * copies of the Software, and to permit persons to whom the Software is
9 * furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20 * THE SOFTWARE.
21 */
22#pragma once
23
24#include <optional>
25#include <utility>
26
27#include "musx/dom/Details.h"
28#include "musx/dom/EnumClasses.h"
29
30namespace musx {
31namespace dom {
32class NoteInfoPtr;
33}
34namespace util {
35
38class Tie
39{
40public:
46 [[nodiscard]]
47 static dom::CurveContourDirection calcDefaultDirection(const dom::NoteInfoPtr& noteInfo, bool forTieEnd);
48
54 [[nodiscard]]
55 static dom::CurveContourDirection calcEffectiveDirection(const dom::NoteInfoPtr& noteInfo, bool forTieEnd);
56
61 [[nodiscard]]
62 static std::optional<std::pair<dom::TieConnectStyleType, dom::TieConnectStyleType>> calcConnectStyleTypes(
63 const dom::NoteInfoPtr& noteInfo, bool forTieEnd);
64
68 [[nodiscard]]
70
77 [[nodiscard]]
78 static std::optional<dom::details::TieAlterBase::ConnectionType> calcConnectionType(
79 const dom::NoteInfoPtr& noteInfo, bool forTieEnd, bool forEndPoint, bool forPageView = false);
80
81private:
94 [[nodiscard]]
95 static std::optional<dom::TieConnectStyleType> calcConnectStyleTypeAtEndPoint(
96 const dom::NoteInfoPtr& noteInfo, bool forTieEnd, dom::CurveContourDirection direction, bool stemUp,
97 const dom::NoteInfoPtr& tieAlterContext, bool forEndPoint,
98 std::optional<size_t> noteIndexOverride = std::nullopt, std::optional<size_t> noteCountOverride = std::nullopt,
99 std::optional<bool> upStemSecondOverride = std::nullopt, std::optional<bool> downStemSecondOverride = std::nullopt);
100};
101
102} // namespace util
103} // namespace musx
Wraps an EntryInfo instance and a note index.
Definition Entries.h:1553
Static class containing utilites for ties.
Definition Tie.h:39
static std::optional< dom::details::TieAlterBase::ConnectionType > calcConnectionType(const dom::NoteInfoPtr &noteInfo, bool forTieEnd, bool forEndPoint, bool forPageView=false)
Calculates the default connection type for a tie endpoint.
Definition Tie.cpp:610
static std::optional< std::pair< dom::TieConnectStyleType, dom::TieConnectStyleType > > calcConnectStyleTypes(const dom::NoteInfoPtr &noteInfo, bool forTieEnd)
Calculates the connect style types for both endpoints of a tie.
Definition Tie.cpp:474
static bool calcIsOuterConnectStyle(dom::TieConnectStyleType type)
Returns true if the connect style is an outer placement.
Definition Tie.cpp:605
static dom::CurveContourDirection calcEffectiveDirection(const dom::NoteInfoPtr &noteInfo, bool forTieEnd)
Calculates the effective tie direction taking into account overrides and special rules.
Definition Tie.cpp:375
static dom::CurveContourDirection calcDefaultDirection(const dom::NoteInfoPtr &noteInfo, bool forTieEnd)
Calculates the default tie direction for the specified note.
Definition Tie.cpp:250
CurveContourDirection
Curve contour direction for ties and slurs.
Definition EnumClasses.h:62
TieConnectStyleType
Enumeration for tie connect style types.
Definition EnumClasses.h:176
object model for musx file (enigmaxml)
Definition BaseClasses.h:36