MUSX Document Model
Loading...
Searching...
No Matches
SmartShape.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 "musx/util/Logger.h"
25#include "musx/util/Fraction.h"
26
27#include "BaseClasses.h"
28// do not add other dom class dependencies. Use Implementations.cpp for implementations that need total class access.
29
30namespace musx {
31namespace dom {
32
33class EntryInfoPtr;
34
35namespace others {
36
43class SmartShape : public OthersBase
44{
45public:
47 explicit SmartShape(const DocumentWeakPtr& document, Cmper partId, ShareMode shareMode, Cmper cmper)
48 : OthersBase(document, partId, shareMode, cmper) {}
49
53 class EndPoint : public Base
54 {
55 public:
57 explicit EndPoint(const DocumentWeakPtr& document)
58 : Base(document, SCORE_PARTID, ShareMode::All) {}
59
64
66 Edu calcEduPosition() const;
67
71
72 bool requireAllFields() const override { return false; }
74 };
75
79 class EndPointAdjustment : public Base
80 {
81 public:
83 explicit EndPointAdjustment(const DocumentWeakPtr& document)
84 : Base(document, SCORE_PARTID, ShareMode::All) {}
85
88 bool active{};
89
90 bool requireAllFields() const override { return false; }
92 };
93
97 class TerminationSeg : public Base
98 {
99 public:
101 explicit TerminationSeg(const DocumentWeakPtr& document)
102 : Base(document, SCORE_PARTID, ShareMode::All) {}
103
104 std::shared_ptr<EndPoint> endPoint;
105 std::shared_ptr<EndPointAdjustment> endPointAdj;
106 std::shared_ptr<EndPointAdjustment> breakAdj;
108
109 void integrityCheck() override
110 {
112 if (!endPoint) {
113 endPoint = std::make_shared<EndPoint>(getDocument());
114 }
115 if (!endPointAdj) {
116 endPointAdj = std::make_shared<EndPointAdjustment>(getDocument());
117 }
118 if (!breakAdj) {
119 breakAdj = std::make_shared<EndPointAdjustment>(getDocument());
120 }
121 }
122
123 bool requireAllFields() const override { return false; }
125 };
126
180
182 bool entryBased{};
183 std::shared_ptr<TerminationSeg> startTermSeg;
184 std::shared_ptr<TerminationSeg> endTermSeg;
185 bool hidden{};
189
195 bool calcAppliesTo(const EntryInfoPtr& entryInfo) const;
196
197 void integrityCheck() override
198 {
200 if (!startTermSeg) {
201 startTermSeg = std::make_shared<TerminationSeg>(getDocument());
202 }
203 if (!endTermSeg) {
204 endTermSeg = std::make_shared<TerminationSeg>(getDocument());
205 }
206 startTermSeg->integrityCheck();
207 endTermSeg->integrityCheck();
208 }
209
210 bool requireAllFields() const override { return false; }
211 constexpr static std::string_view XmlNodeName = "smartShape";
213};
214
227{
228public:
230 explicit SmartShapeMeasureAssign(const DocumentWeakPtr& document, Cmper partId, ShareMode shareMode, Cmper cmper, Inci inci)
231 : OthersBase(document, partId, shareMode, cmper, inci)
232 {
233 }
234
238
239 constexpr static std::string_view XmlNodeName = "smartShapeMeasMark";
241};
242
243} // namespace others
244
245namespace details {
246
263{
264public:
265
274 explicit CenterShape(const DocumentWeakPtr& document, Cmper partId, ShareMode shareMode, Cmper shapeNum, Cmper centerShapeNum)
275 : DetailsBase(document, partId, shareMode, shapeNum, centerShapeNum)
276 {}
277
278 std::shared_ptr<others::SmartShape::EndPointAdjustment> startBreakAdj;
279 std::shared_ptr<others::SmartShape::EndPointAdjustment> endBreakAdj;
280
281 void integrityCheck() override
282 {
283 if (!startBreakAdj) {
284 startBreakAdj = std::make_shared<others::SmartShape::EndPointAdjustment>(getDocument());
285 }
286 if (!endBreakAdj) {
287 endBreakAdj = std::make_shared<others::SmartShape::EndPointAdjustment>(getDocument());
288 }
289 }
290
291 bool requireAllFields() const override { return false; }
292 constexpr static std::string_view XmlNodeName = "centerShape";
294};
295
303{
304public:
306 explicit SmartShapeEntryAssign(const DocumentWeakPtr& document, Cmper partId, ShareMode shareMode, EntryNumber entnum, Inci inci)
307 : EntryDetailsBase(document, partId, shareMode, entnum, inci)
308 {
309 }
310
312
313 constexpr static std::string_view XmlNodeName = "smartShapeEntryMark";
315};
316
317} // namespace details
318
319} // namespace dom
320} // namespace musx
Base class to enforce polymorphism across all DOM classes.
Definition BaseClasses.h:64
DocumentPtr getDocument() const
Gets a reference to the Document.
Definition BaseClasses.h:89
virtual void integrityCheck()
Allows a class to determine if it has been properly contructed by the factory and fix issues that it ...
Definition BaseClasses.h:133
ShareMode
Describes how this instance is shared between part and score.
Definition BaseClasses.h:72
Base class for all "details" types.
Definition BaseClasses.h:295
Base class for all "details" types that use entnum rather than cmper and cmper.
Definition BaseClasses.h:336
Wraps a frame of shared_ptr<const EntryInfo> and an index for per entry access. This class manages ow...
Definition Entries.h:239
Base class for all "others" types.
Definition BaseClasses.h:220
Represents a center shape for a others::SmartShape that spans three or more measures.
Definition SmartShape.h:263
void integrityCheck() override
Allows a class to determine if it has been properly contructed by the factory and fix issues that it ...
Definition SmartShape.h:281
std::shared_ptr< others::SmartShape::EndPointAdjustment > startBreakAdj
Adjustment at the start break (xml: <startBreakAdj>)
Definition SmartShape.h:278
static constexpr std::string_view XmlNodeName
The XML node name for this type.
Definition SmartShape.h:292
std::shared_ptr< others::SmartShape::EndPointAdjustment > endBreakAdj
Adjustment at the end break (xml: <endBreakAdj>)
Definition SmartShape.h:279
bool requireAllFields() const override
ignore other fields because they are difficult to figure out
Definition SmartShape.h:291
CenterShape(const DocumentWeakPtr &document, Cmper partId, ShareMode shareMode, Cmper shapeNum, Cmper centerShapeNum)
Constructor.
Definition SmartShape.h:274
static const xml::XmlElementArray< CenterShape > & xmlMappingArray()
Required for musx::factory::FieldPopulator.
Assigns a smart shape to an entry.
Definition SmartShape.h:303
Cmper shapeNum
The Cmper of the others::SmartShape that is being assigned.
Definition SmartShape.h:311
SmartShapeEntryAssign(const DocumentWeakPtr &document, Cmper partId, ShareMode shareMode, EntryNumber entnum, Inci inci)
Constructor function.
Definition SmartShape.h:306
static const xml::XmlElementArray< SmartShapeEntryAssign > & xmlMappingArray()
Required for musx::factory::FieldPopulator.
static constexpr std::string_view XmlNodeName
The XML node name for this type.
Definition SmartShape.h:313
Assigns a smart shape or center shape to a measure.
Definition SmartShape.h:227
static const xml::XmlElementArray< SmartShapeMeasureAssign > & xmlMappingArray()
Required for musx::factory::FieldPopulator.
static constexpr std::string_view XmlNodeName
The XML node name for this type.
Definition SmartShape.h:239
SmartShapeMeasureAssign(const DocumentWeakPtr &document, Cmper partId, ShareMode shareMode, Cmper cmper, Inci inci)
Constructor function.
Definition SmartShape.h:230
Cmper shapeNum
The Cmper of the SmartShape that is being assigned.
Definition SmartShape.h:235
Cmper centerShapeNum
Definition SmartShape.h:236
Represents the endpoint adjustment of the smart shape.
Definition SmartShape.h:80
Evpu vertOffset
Vertical offset (xml node is <y>)
Definition SmartShape.h:87
EndPointAdjustment(const DocumentWeakPtr &document)
Constructor function.
Definition SmartShape.h:83
static const xml::XmlElementArray< EndPointAdjustment > & xmlMappingArray()
Required for musx::factory::FieldPopulator.
bool requireAllFields() const override
ignore other fields because they are difficult to figure out
Definition SmartShape.h:90
Evpu horzOffset
Horizontal offset (xml node is <x>)
Definition SmartShape.h:86
bool active
If true, this adjustment should be used when it is applicable (xml node is <on>)
Definition SmartShape.h:88
Represents an endpoint of the smart shape.
Definition SmartShape.h:54
static const xml::XmlElementArray< EndPoint > & xmlMappingArray()
Required for musx::factory::FieldPopulator.
Edu calcEduPosition() const
Calculates the edu position of the endpoint, based on whether it is an edu or an entry.
Definition Implementations.cpp:1886
EndPoint(const DocumentWeakPtr &document)
Constructor function.
Definition SmartShape.h:57
bool requireAllFields() const override
Specifies if the parser should alert (print or throw) when an unknown xml tag is found for this class...
Definition SmartShape.h:72
MeasCmper measId
Measure ID (xml node is <meas>)
Definition SmartShape.h:61
EntryInfoPtr calcAssociatedEntry() const
Calculates the entry associated with the endpoint.
Definition Implementations.cpp:1861
InstCmper staffId
Staff ID (xml node is <inst>)
Definition SmartShape.h:60
Edu eduPosition
Edu position of endpoint (xml node is <edu>)
Definition SmartShape.h:62
EntryNumber entryNumber
Entry number. Zero if the endpoint is not entry-attached. (xml node is <entryNum>)
Definition SmartShape.h:63
Represents the termination segment of the smart shape.
Definition SmartShape.h:98
void integrityCheck() override
Allows a class to determine if it has been properly contructed by the factory and fix issues that it ...
Definition SmartShape.h:109
static const xml::XmlElementArray< TerminationSeg > & xmlMappingArray()
Required for musx::factory::FieldPopulator.
std::shared_ptr< EndPoint > endPoint
Endpoint information (xml node is <endPt>)
Definition SmartShape.h:104
TerminationSeg(const DocumentWeakPtr &document)
Constructor function.
Definition SmartShape.h:101
std::shared_ptr< EndPointAdjustment > breakAdj
Definition SmartShape.h:106
std::shared_ptr< EndPointAdjustment > endPointAdj
Endpoint adjustment information (xml node is <endPtAdj>)
Definition SmartShape.h:105
bool requireAllFields() const override
ignore other fields because they are difficult to figure out
Definition SmartShape.h:123
Represents a Finale smart shape.
Definition SmartShape.h:44
SmartShape(const DocumentWeakPtr &document, Cmper partId, ShareMode shareMode, Cmper cmper)
Constructor function.
Definition SmartShape.h:47
Cmper lineStyleId
If non-zero, the custom line for this shape. Several ShapeType values use it. (xml node is <lineStyle...
Definition SmartShape.h:188
bool entryBased
Whether the shape is entry-based.
Definition SmartShape.h:182
NoteNumber startNoteId
If non-zero, the specific note with the entry that this shape starts from. (xml node is <startNoteID>...
Definition SmartShape.h:186
bool calcAppliesTo(const EntryInfoPtr &entryInfo) const
Calculates if the smart shape applies to the specified entry.
Definition Implementations.cpp:1895
std::shared_ptr< TerminationSeg > endTermSeg
End termination segment.
Definition SmartShape.h:184
NoteNumber endNoteId
If non-zero, the specific note with the entry that this shape ends on. (xml node is <endNoteID>)
Definition SmartShape.h:187
bool hidden
Inverse of "Show" option.
Definition SmartShape.h:185
ShapeType
All the smart shape types supported by Finale.
Definition SmartShape.h:136
@ TwoOctaveUp
Quindicesima (15ma) == 21.
@ DashLineDownLeft
Dashed line with downward left hook.
@ DashLineUpLeft
Dashed line with upward left hook. == 32.
@ CustomLine
User-created custom line with shape determined by lineStyleId. (xml value is "smartLine")
@ Crescendo
Crescendo hairpin. (xml value is "cresc")
@ SlurAuto
Slur with direction automatically determined.
@ DashSlurUp
Thin line dashed upward slur (tips point down).
@ Trill
Trill (includes "tr" symbol at the beginning). == 14.
@ DashLineUp
Dashed line with upward hook.
@ DashLineDownBoth
Dashed line with downward hooks on both ends. (xml value is "dashLineDown2")
@ SlurDown
Downward Slur (tips point up). This is the default and may not appear in the xml, but the text is in ...
@ WordExtension
Lyric word extension, used only with lyric assignments. (xml value is "wordExt")
@ TabSlide
Tab slide (a solid line that is often used as a note-attached glissando)
@ SolidLineDown
Solid line with downward right hook.
@ DashSlurDown
Thin line dashed downward slur (tips point up).
@ SolidLineDownBoth
Solid line with downward hooks on both ends. (xml value is "solidLineDown2")
@ DashContouSlurAuto
Contoured line dashed slur with direction automatically determined.
@ Glissando
Glissando (shape is determined by lineStyleId) == 25 (24 has no value)
@ SolidLineDownUp
Solid line with downward left hook and upward right hook.
@ SolidLineUp
Solid line with upward right hook.
@ Decrescendo
Decrescendo hairpin. (xml value is "decresc")
@ BendHat
Bend hat (solid up-down line with a corner in the middle)
@ Hyphen
Lyric hyphen, used only with lyric assignments.
@ DashLineUpDown
Dashed line with upward left hook and downward right hook.
@ DashContourSlurUp
Contoured line dashed upward slur (tips point down).
@ DashContourSlurDown
Contoured line dashed downward slur (tips point up).
@ SolidLineDownLeft
Solid line with downward left hook.
@ DashLineDown
Dashed line with downward hook. == 7.
@ DashLineUpBoth
Dashed line with upward hooks on both ends. (xml value is "dashLineUp2")
@ SolidLineUpBoth
Solid line with upward hooks on both ends. (xml value is "solidLineUp2")
@ DashSlurAuto
Thin line dashed slur with direction automatically determined.
@ SolidLineUpDown
Solid line with upward left hook and downward right hook.
@ TrillExtension
Trill extension: only the wavy line. (xml value is "trillExt")
@ SolidLineUpLeft
Solid line with upward left hook.
@ TwoOctaveDown
Quindicesima bassa (15ma bassa)
@ SlurUp
Upward Slur (tips point down).
@ DashLineDownUp
Dashed line with downward left hook and upward right hook.
static const xml::XmlElementArray< SmartShape > & xmlMappingArray()
Required for musx::factory::FieldPopulator.
static constexpr std::string_view XmlNodeName
XML node name.
Definition SmartShape.h:211
void integrityCheck() override
Allows a class to determine if it has been properly contructed by the factory and fix issues that it ...
Definition SmartShape.h:197
std::shared_ptr< TerminationSeg > startTermSeg
Start termination segment.
Definition SmartShape.h:183
bool requireAllFields() const override
ignore other fields because they are difficult to figure out
Definition SmartShape.h:210
ShapeType shapeType
Type of smart shape.
Definition SmartShape.h:181
int16_t MeasCmper
Enigma meas Cmper (may be negative when not applicable)
Definition Fundamentals.h:64
constexpr Cmper SCORE_PARTID
The part id of the score.
Definition Fundamentals.h:75
int16_t InstCmper
Enigma staff (inst) Cmper (may be negative when not applicable)
Definition Fundamentals.h:65
int16_t Inci
Enigma "incident" key type.
Definition Fundamentals.h:56
int32_t Evpu
EVPU value (288 per inch)
Definition Fundamentals.h:57
uint16_t Cmper
Enigma "comperator" key type.
Definition Fundamentals.h:55
int32_t Edu
"Enigma Durational Units" value (1024 per quarter note)
Definition Fundamentals.h:61
std::weak_ptr< Document > DocumentWeakPtr
Shared weak Document pointer.
Definition BaseClasses.h:57
int32_t EntryNumber
Entry identifier.
Definition Fundamentals.h:68
uint16_t NoteNumber
Note identifier.
Definition Fundamentals.h:69
std::vector< XmlElementDescriptor< T > > XmlElementArray
an array type for XmlElementDescriptor instances.
Definition XmlInterface.h:127
object model for musx file (enigmaxml)
Definition BaseClasses.h:32