24#include "musx/util/Logger.h"
25#include "musx/util/Fraction.h"
27#include "BaseClasses.h"
28#include "CommonClasses.h"
367 bool valid() const noexcept {
return m_valid; }
372 template <
typename T>
377 data = std::move(*optData);
390 static std::optional<Undocumented>
parseUndocumented(
const std::vector<int>& data);
393 static std::optional<Bracket>
parseBracket(
const std::vector<int>& data);
396 static std::optional<CloneChar>
parseCloneChar(
const std::vector<int>& data);
399 static std::optional<CurveTo>
parseCurveTo(
const std::vector<int>& data);
402 static std::optional<DrawChar>
parseDrawChar(
const std::vector<int>& data);
405 static std::optional<Ellipse>
parseEllipse(
const std::vector<int>& data);
411 static std::optional<LineWidth>
parseLineWidth(
const std::vector<int>& data);
414 static std::optional<Rectangle>
parseRectangle(
const std::vector<int>& data);
417 static std::optional<RLineTo>
parseRLineTo(
const std::vector<int>& data);
420 static std::optional<RMoveTo>
parseRMoveTo(
const std::vector<int>& data);
423 static std::optional<SetArrowhead>
parseSetArrowhead(
const std::vector<int>& data);
426 static std::optional<SetDash>
parseSetDash(
const std::vector<int>& data);
432 static std::optional<SetGray>
parseSetGray(
const std::vector<int>& data);
435 static std::optional<Slur>
parseSlur(
const std::vector<int>& data);
438 static std::optional<StartGroup>
parseStartGroup(
const std::vector<int>& data);
441 static std::optional<StartObject>
parseStartObject(
const std::vector<int>& data);
444 static std::optional<VerticalMode>
parseVerticalMode(
const std::vector<int>& data);
455class ShapeData :
public OthersArray<int>
457 std::string_view xmlTag()
const override {
return XmlNodeName; }
462 constexpr static std::string_view XmlNodeName =
"shapeData";
463 static const xml::XmlElementArray<ShapeData>& xmlMappingArray();
466#ifndef DOXYGEN_SHOULD_IGNORE_THIS
467class ShapeDefTestAccessor;
470class ShapeInstructionList;
477class ShapeDef :
public OthersBase
483 friend class ShapeDefTestAccessor;
488 :
OthersBase(document, partId, shareMode, cmper)
510 Cmper instructionList;
516 {
return instructionList == 0; }
521 bool iterateInstructions(std::function<
bool(
const ShapeDefInstruction::Decoded&)> callback)
const;
526 std::optional<KnownShapeDefType> recognize()
const;
528 constexpr static std::string_view XmlNodeName =
"shapeDef";
529 static const xml::XmlElementArray<ShapeDef>& xmlMappingArray();
538class ShapeInstructionList :
public OthersBase
543 :
OthersBase(document, partId, shareMode, cmper)
558 std::vector<std::shared_ptr<InstructionInfo>> instructions;
560 constexpr static std::string_view XmlNodeName =
"shapeList";
ShareMode
Describes how this instance is shared between part and score.
Definition BaseClasses.h:91
Represents the default font settings for a particular element type.
Definition CommonClasses.h:126
OthersArray(const DocumentWeakPtr &document, Cmper partId, ShareMode shareMode, Cmper cmper)
Constructor function.
Definition BaseClasses.h:359
OthersBase(const DocumentWeakPtr &document, Cmper partId, ShareMode shareMode, Cmper cmper, std::optional< Inci > inci=std::nullopt)
Constructs an OthersBase object.
Definition BaseClasses.h:299
BracketStyle
Bracket types.
Definition Details.h:628
An instruction in the shape.
Definition ShapeDesigner.h:549
int numData
the number of data items consumed by this instruction (See ShapeData.)
Definition ShapeDesigner.h:552
static const xml::XmlElementArray< InstructionInfo > & xmlMappingArray()
Required for musx::factory::FieldPopulator.
ShapeDefInstructionType type
the type of instruction
Definition ShapeDesigner.h:553
KnownShapeDefType
Enumerates the shape types we can recognize semantically.
Definition ShapeDesigner.h:39
@ TenutoMark
A horizontal tenuto mark, typically used as an articulation symbol.
int32_t Efix
EFIX value (64 per EVPU, 64*288=18432 per inch)
Definition Fundamentals.h:60
int32_t Evpu
EVPU value (288 per inch)
Definition Fundamentals.h:57
uint16_t Cmper
Enigma "comperator" key type.
Definition Fundamentals.h:55
@ Blank
Blank clef (invisible, no symbol).
ShapeDefInstructionType
Defines the instruction types for Shape Designer shapes.
Definition ShapeDesigner.h:49
@ Undocumented
catch-all for possible undocumented instruction tags.
std::weak_ptr< Document > DocumentWeakPtr
Shared weak Document pointer.
Definition BaseClasses.h:57
std::vector< XmlElementDescriptor< T > > XmlElementArray
an array type for XmlElementDescriptor instances.
Definition XmlInterface.h:127
object model for musx file (enigmaxml)
Definition BaseClasses.h:36
Holds the parsed data for a Bracket instruction.
Definition ShapeDesigner.h:189
details::Bracket::BracketStyle bracketStyle
The style of bracket being created.
Definition ShapeDesigner.h:190
Holds the parsed data for a CloneChar instruction.
Definition ShapeDesigner.h:194
int baselineShift
Baseline shift in EMs (1/1000 of current point size).
Definition ShapeDesigner.h:198
int unused2
Unused/undocumented field at index 2.
Definition ShapeDesigner.h:197
char32_t codePoint
The 32-bit codepoint of the character to clone.
Definition ShapeDesigner.h:199
Evpu dy
The Y coordinate of the endpoint (currently ignored).
Definition ShapeDesigner.h:196
Evpu dx
The X coordinate of the endpoint (relative to current point).
Definition ShapeDesigner.h:195
Holds the parsed data for a CurveTo instruction.
Definition ShapeDesigner.h:203
Evpu c1dx
Relative X offset of the first control point.
Definition ShapeDesigner.h:204
Evpu c2dy
Relative Y offset of the second control point.
Definition ShapeDesigner.h:207
Evpu edy
Relative Y offset of the end point.
Definition ShapeDesigner.h:209
Evpu c2dx
Relative X offset of the second control point.
Definition ShapeDesigner.h:206
Evpu c1dy
Relative Y offset of the first control point.
Definition ShapeDesigner.h:205
Evpu edx
Relative X offset of the end point.
Definition ShapeDesigner.h:208
Contains the parsed instruction type with its data.
Definition ShapeDesigner.h:362
bool valid() const noexcept
Returns true is the data is valid.
Definition ShapeDesigner.h:367
void setPayload(std::optional< T > &&optData)
Sets the payload.
Definition ShapeDesigner.h:373
ShapeDefInstructionType type
Instruction type.
Definition ShapeDesigner.h:363
InstructionData data
Data for instruction.
Definition ShapeDesigner.h:364
Holds the parsed data for a DrawChar instruction.
Definition ShapeDesigner.h:213
char32_t codePoint
The 32-bit codepoint of the character to draw.
Definition ShapeDesigner.h:214
Holds the parsed data for an Ellipse instruction.
Definition ShapeDesigner.h:218
Evpu height
The height of the bounding rectangle.
Definition ShapeDesigner.h:220
Evpu width
The width of the bounding rectangle.
Definition ShapeDesigner.h:219
Holds the parsed data for an ExternalGraphic instruction.
Definition ShapeDesigner.h:224
Evpu height
The height of the placed graphic.
Definition ShapeDesigner.h:226
Cmper cmper
The cmper of the graphic. See others::PageGraphicAssign::graphicCmper for explanation.
Definition ShapeDesigner.h:227
Evpu width
The width of the placed graphic.
Definition ShapeDesigner.h:225
Holds the parsed data for a LineWidth instruction.
Definition ShapeDesigner.h:231
Efix efix
The line width in Efix units.
Definition ShapeDesigner.h:232
Holds the parsed data for an RLineTo instruction.
Definition ShapeDesigner.h:242
Evpu dx
The relative X coordinate delta in Evpu.
Definition ShapeDesigner.h:243
Evpu dy
The relative Y coordinate delta in Evpu.
Definition ShapeDesigner.h:244
Holds the parsed data for an RMoveTo instruction.
Definition ShapeDesigner.h:248
Evpu dx
The relative X coordinate delta in Evpu.
Definition ShapeDesigner.h:249
Evpu dy
The relative Y coordinate delta in Evpu.
Definition ShapeDesigner.h:250
Holds the parsed data for a Rectangle instruction.
Definition ShapeDesigner.h:236
Evpu height
The height of the rectangle.
Definition ShapeDesigner.h:238
Evpu width
The width of the rectangle.
Definition ShapeDesigner.h:237
Holds the parsed data for a SetArrowhead instruction.
Definition ShapeDesigner.h:254
int endFlags
Flags for the end arrowhead (built-in vs custom, etc.).
Definition ShapeDesigner.h:258
int startArrowId
Identifier of the start arrowhead.
Definition ShapeDesigner.h:255
int startFlags
Flags for the start arrowhead (built-in vs custom, etc.).
Definition ShapeDesigner.h:257
int endArrowId
Identifier of the end arrowhead.
Definition ShapeDesigner.h:256
Holds the parsed data for a SetDash instruction.
Definition ShapeDesigner.h:262
Efix dashLength
Length of each dash segment.
Definition ShapeDesigner.h:263
Efix spaceLength
Space between dashes.
Definition ShapeDesigner.h:264
Holds the parsed data for a SetFont instruction.
Definition ShapeDesigner.h:268
SetFont(const DocumentWeakPtr &document)
Constructor function.
Definition ShapeDesigner.h:270
FontInfo font
the parsed font
Definition ShapeDesigner.h:272
Holds the parsed data for a SetGray instruction.
Definition ShapeDesigner.h:276
int gray
Gray value between 0 (black) and 100 (white).
Definition ShapeDesigner.h:277
Holds the parsed data for a Slur instruction.
Definition ShapeDesigner.h:282
Evpu edx
Relative X offset of the end point.
Definition ShapeDesigner.h:287
Evpu c2dx
Relative X offset of the second control point.
Definition ShapeDesigner.h:285
Evpu c2dy
Relative Y offset of the second control point.
Definition ShapeDesigner.h:286
Evpu edy
Relative Y offset of the end point.
Definition ShapeDesigner.h:288
Evpu c1dy
Relative Y offset of the first control point.
Definition ShapeDesigner.h:284
Evpu c1dx
Relative X offset of the first control point.
Definition ShapeDesigner.h:283
Holds the parsed data for a StartGroup instruction.
Definition ShapeDesigner.h:308
Evpu bottom
Bottom of the bounding rectangle.
Definition ShapeDesigner.h:314
Evpu originY
Y coordinate of the origin point.
Definition ShapeDesigner.h:310
int unused10
Undocumented/unused field at index 10.
Definition ShapeDesigner.h:319
int scaleY
Y scale transform (scale ratio * 1000).
Definition ShapeDesigner.h:316
int rotation
Rotation transform.
Definition ShapeDesigner.h:317
Evpu top
Top of the bounding rectangle.
Definition ShapeDesigner.h:312
Evpu right
Right of the bounding rectangle.
Definition ShapeDesigner.h:313
int unused9
Undocumented/unused field at index 9.
Definition ShapeDesigner.h:318
int scaleX
X scale transform (scale ratio * 1000).
Definition ShapeDesigner.h:315
Evpu left
Left of the bounding rectangle.
Definition ShapeDesigner.h:311
Evpu originX
X coordinate of the origin point.
Definition ShapeDesigner.h:309
Holds the parsed data for a StartObject instruction.
Definition ShapeDesigner.h:292
Evpu left
Left of the bounding rectangle.
Definition ShapeDesigner.h:295
Evpu originY
Y coordinate of the origin point.
Definition ShapeDesigner.h:294
Evpu bottom
Bottom of the bounding rectangle.
Definition ShapeDesigner.h:298
int scaleY
Y scale transform (scale ratio * 1000).
Definition ShapeDesigner.h:300
int unused10
Undocumented/unused field at index 10.
Definition ShapeDesigner.h:303
int scaleX
X scale transform (scale ratio * 1000).
Definition ShapeDesigner.h:299
Evpu top
Top of the bounding rectangle.
Definition ShapeDesigner.h:296
int unused9
Undocumented/unused field at index 9.
Definition ShapeDesigner.h:302
Evpu originX
X coordinate of the origin point.
Definition ShapeDesigner.h:293
int rotation
Rotation transform.
Definition ShapeDesigner.h:301
Evpu right
Right of the bounding rectangle.
Definition ShapeDesigner.h:297
Holds the parsed data for an Undocumented instruction.
Definition ShapeDesigner.h:184
std::vector< int > data
Raw data items for the undocumented instruction.
Definition ShapeDesigner.h:185
Holds the parsed data for a VerticalMode instruction.
Definition ShapeDesigner.h:330
VerticalAlign mode
The pen vertical alignment mode.
Definition ShapeDesigner.h:331
Helper functions and structs for decoding instruction data vectors in others::ShapeDef.
Definition ShapeDesigner.h:181
static std::optional< SetFont > parseSetFont(const DocumentWeakPtr &document, const std::vector< int > &data)
Attempts to parse a SetFont instruction.
Definition ShapeDesigner.cpp:201
static std::optional< ExternalGraphic > parseExternalGraphic(const std::vector< int > &data)
Attempts to parse an ExternalGraphic instruction.
Definition ShapeDesigner.cpp:120
static std::optional< Slur > parseSlur(const std::vector< int > &data)
Attempts to parse a Slur instruction.
Definition ShapeDesigner.cpp:225
static std::optional< LineWidth > parseLineWidth(const std::vector< int > &data)
Attempts to parse a LineWidth instruction.
Definition ShapeDesigner.cpp:133
static std::optional< VerticalMode > parseVerticalMode(const std::vector< int > &data)
Attempts to parse a VerticalMode instruction.
Definition ShapeDesigner.cpp:280
static std::optional< SetGray > parseSetGray(const std::vector< int > &data)
Attempts to parse a SetGray instruction.
Definition ShapeDesigner.cpp:214
static std::optional< DrawChar > parseDrawChar(const std::vector< int > &data)
Attempts to parse a DrawChar instruction.
Definition ShapeDesigner.cpp:99
static std::optional< StartObject > parseStartObject(const std::vector< int > &data)
Attempts to parse a StartObject instruction.
Definition ShapeDesigner.cpp:259
VerticalAlign
Pen vertical alignment modes for the VerticalMode instruction.
Definition ShapeDesigner.h:323
@ Center
Draw line centered on the coordinates.
@ Right
Draw line on the "right" side of the coordinates.
@ Left
Draw line on the "left" side of the coordinates.
static std::optional< SetArrowhead > parseSetArrowhead(const std::vector< int > &data)
Attempts to parse a SetArrowhead instruction.
Definition ShapeDesigner.cpp:175
static std::optional< StartGroup > parseStartGroup(const std::vector< int > &data)
Attempts to parse a StartGroup instruction.
Definition ShapeDesigner.cpp:238
static std::optional< Rectangle > parseRectangle(const std::vector< int > &data)
Attempts to parse a Rectangle instruction.
Definition ShapeDesigner.cpp:142
static std::optional< RLineTo > parseRLineTo(const std::vector< int > &data)
Attempts to parse an RLineTo instruction.
Definition ShapeDesigner.cpp:154
static std::optional< RMoveTo > parseRMoveTo(const std::vector< int > &data)
Attempts to parse an RMoveTo instruction.
Definition ShapeDesigner.cpp:163
static std::optional< Ellipse > parseEllipse(const std::vector< int > &data)
Attempts to parse an Ellipse instruction.
Definition ShapeDesigner.cpp:108
static std::optional< SetDash > parseSetDash(const std::vector< int > &data)
Attempts to parse a SetDash instruction.
Definition ShapeDesigner.cpp:189
std::variant< std::monostate, Undocumented, Bracket, CloneChar, CurveTo, DrawChar, Ellipse, ExternalGraphic, LineWidth, Rectangle, RLineTo, RMoveTo, SetArrowhead, SetDash, SetFont, SetGray, Slur, StartGroup, StartObject, VerticalMode > InstructionData
A variant for passing specific data per instruction type.
Definition ShapeDesigner.h:357
static std::optional< CloneChar > parseCloneChar(const std::vector< int > &data)
Attempts to parse a CloneChar instruction.
Definition ShapeDesigner.cpp:71
static std::optional< CurveTo > parseCurveTo(const std::vector< int > &data)
Attempts to parse a CurveTo instruction.
Definition ShapeDesigner.cpp:86
static std::optional< Undocumented > parseUndocumented(const std::vector< int > &data)
Attempts to parse an Undocumented instruction (raw passthrough).
Definition ShapeDesigner.cpp:37
static std::optional< Bracket > parseBracket(const std::vector< int > &data)
Attempts to parse a Bracket instruction.
Definition ShapeDesigner.cpp:44