MUSX Document Model
Loading...
Searching...
No Matches
Graphics.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 "BaseClasses.h"
25#include "CommonClasses.h"
26#include "Others.h"
27 // do not add other dom class dependencies. Use .cpp files for implementations that need total class access.
28
29namespace musx {
30namespace dom {
31
32namespace others {
33
40class FileAlias : public OthersBase
41{
42public:
44 explicit FileAlias(const DocumentWeakPtr& document, Cmper partId, ShareMode shareMode, Cmper cmper)
45 : OthersBase(document, partId, shareMode, cmper) {}
46
47 size_t length{};
48 std::vector<std::uint8_t> aliasHandle{};
49
50 void integrityCheck(const std::shared_ptr<Base>& ptrToThis) override
51 {
53 if (length != aliasHandle.size()) {
54 MUSX_INTEGRITY_ERROR("Stated length does not match actual size of FileAlias " + std::to_string(getCmper()) + ".");
55 }
56 }
57
58 constexpr static std::string_view XmlNodeName = "fileAlias";
60};
61
69{
70public:
72 explicit FileDescription(const DocumentWeakPtr& document, Cmper partId, ShareMode shareMode, Cmper cmper)
73 : OthersBase(document, partId, shareMode, cmper) {}
74
77 enum class PathType
78 {
79 DosPath,
80 MacFsSpec,
81 MacAlias,
84 };
85
86 uint32_t version{};
87 int volRefNum{};
88 int dirId{};
91
92 constexpr static std::string_view XmlNodeName = "fileDesc";
94};
95
104class FilePath : public OthersBase
105{
106public:
108 explicit FilePath(const DocumentWeakPtr& document, Cmper partId, ShareMode shareMode, Cmper cmper)
109 : OthersBase(document, partId, shareMode, cmper) {}
110
111 std::string path;
112
113 constexpr static std::string_view XmlNodeName = "filePath";
115};
116
124{
125public:
127 explicit FileUrlBookmark(const DocumentWeakPtr& document, Cmper partId, ShareMode shareMode, Cmper cmper)
128 : OthersBase(document, partId, shareMode, cmper) {}
129
130 size_t length{};
131 std::vector<std::uint8_t> urlBookmarkData{};
132
133 void integrityCheck(const std::shared_ptr<Base>& ptrToThis) override
134 {
136 if (length != urlBookmarkData.size()) {
137 MUSX_INTEGRITY_ERROR("Stated length does not match actual size of FileUrlBookmark " + std::to_string(getCmper()) + ".");
138 }
139 }
140
141 constexpr static std::string_view XmlNodeName = "fileURLBookmark";
143};
144
160{
161public:
162
167 enum class PageAssignType
168 {
169 AllPages,
170 Even,
171 Odd,
172 One
173 };
174
179 enum class PositionFrom
180 {
181 Margins,
182 PageEdge
183 };
184
187
189 explicit PageGraphicAssign(const DocumentWeakPtr& document, Cmper partId, ShareMode shareMode, Cmper cmper, Inci inci)
190 : OthersBase(document, partId, shareMode, cmper, inci)
191 {
192 }
193
194 uint32_t version{};
201 bool hidden{};
205 bool fixedPerc{};
208 bool savedRecord{};
222
227 std::optional<PageCmper> calcStartPageNumber(Cmper forPartId) const;
228
233 std::optional<PageCmper> calcEndPageNumber(Cmper forPartId) const;
234
236 bool isMultiPage() const
237 { return getCmper() == 0 && startPage != endPage; }
238
241 { return isMultiPage() && endPage == 0; }
242
243 void integrityCheck(const std::shared_ptr<Base>& ptrToThis) override
244 {
245 this->OthersBase::integrityCheck(ptrToThis);
246 if (getCmper() != 0) {
247 if (startPage != getCmper() || endPage != getCmper()) {
248 MUSX_INTEGRITY_ERROR("PageGraphicAssign " + std::to_string(getCmper()) + " inci " + std::to_string(getInci().value_or(0)) +
249 " has startPage or endPage value that does not match.");
250 }
251 }
252 }
253
260 static MusxInstance<others::PageGraphicAssign> getForPageId(const DocumentPtr& document, Cmper partId, PageCmper pageId, Inci inci);
261
268
269 constexpr static std::string_view XmlNodeName = "pageGraphicAssign";
271};
272
282{
283public:
292 explicit ShapeGraphicAssign(const DocumentWeakPtr& document, Cmper partId, ShareMode shareMode, Cmper cmper, Inci inci)
293 : OthersBase(document, partId, shareMode, cmper, inci)
294 {
295 }
296
299
300 uint32_t version{};
308 bool fixedPerc{};
309 bool hidden{};
310 bool savedRecord{};
314
315 constexpr static std::string_view XmlNodeName = "shapeGraphicAssign";
317};
318
319} //namespace others
320
321namespace details {
322
335{
336public:
346 explicit MeasureGraphicAssign(const DocumentWeakPtr& document, Cmper partId, ShareMode shareMode, Cmper staffId, Cmper meas, Inci inci)
347 : DetailsBase(document, partId, shareMode, staffId, meas, inci)
348 {
349 }
350
351 uint32_t version{};
357 bool hidden{};
358 bool savedRecord{};
362
363 constexpr static std::string_view XmlNodeName = "measGraphicAssign";
365};
366
367} //namespace details
368
369} //namespace dom
370} //namespace musx
virtual void integrityCheck(const std::shared_ptr< Base > &ptrToThis)
Allows a class to determine if it has been properly contructed by the factory and fix issues that it ...
Definition BaseClasses.h:154
ShareMode
Describes how this instance is shared between part and score.
Definition BaseClasses.h:91
Base class for all "details" types.
Definition BaseClasses.h:407
Provides optional per-type extension methods for MusxInstanceList.
Definition MusxInstance.h:96
Base class for all "others" types.
Definition BaseClasses.h:283
std::optional< Inci > getInci() const
Gets the optional array index (inci).
Definition BaseClasses.h:335
Cmper getCmper() const
Gets the cmper key value.
Definition BaseClasses.h:328
Represents a graphic assignment anchored to a specific staff and measure.
Definition Graphics.h:335
Evpu left
Graphic left coordinate in Evpu.
Definition Graphics.h:352
Evpu height
Graphic height in Evpu.
Definition Graphics.h:355
MeasureGraphicAssign(const DocumentWeakPtr &document, Cmper partId, ShareMode shareMode, Cmper staffId, Cmper meas, Inci inci)
Constructor.
Definition Graphics.h:346
bool hidden
Indicates the graphic is hidden from print/displayed as hidden (xml node is <displayHidden>)
Definition Graphics.h:357
Evpu width
Graphic width in Evpu.
Definition Graphics.h:354
bool savedRecord
Indicates a stored/saved record. (Used internally by Finale when a graphic is created....
Definition Graphics.h:358
static constexpr std::string_view XmlNodeName
The XML node name for this type.
Definition Graphics.h:363
uint32_t version
Always 0x100, meaning perhaps "v1.0". (This was intended for tracking changes to the data format,...
Definition Graphics.h:351
Cmper graphicCmper
Graphic instance Cmper. (See others::PageGraphicAssign::graphicCmper for full explanation....
Definition Graphics.h:361
Evpu origWidth
Original (intrinsic) width in Evpu.
Definition Graphics.h:359
Evpu bottom
Graphic bottom coordinate in Evpu.
Definition Graphics.h:353
Cmper fDescId
The Cmper of the assigned others::FileDescription. (xml tag is <fDescID>)
Definition Graphics.h:356
Evpu origHeight
Original (intrinsic) height in Evpu.
Definition Graphics.h:360
static const xml::XmlElementArray< MeasureGraphicAssign > & xmlMappingArray()
Required for musx::factory::FieldPopulator.
HorizontalAlignment
Horizontal alignment options for page text positioning.
Definition Options.h:1495
VerticalAlignment
Vertical alignment options for page text positioning.
Definition Options.h:1506
Opaque storage for a platform-specific alias handle associated with a graphic.
Definition Graphics.h:41
FileAlias(const DocumentWeakPtr &document, Cmper partId, ShareMode shareMode, Cmper cmper)
Constructor.
Definition Graphics.h:44
void integrityCheck(const std::shared_ptr< Base > &ptrToThis) override
Allows a class to determine if it has been properly contructed by the factory and fix issues that it ...
Definition Graphics.h:50
static const xml::XmlElementArray< FileAlias > & xmlMappingArray()
Required for musx::factory::FieldPopulator.
size_t length
Declared byte length.
Definition Graphics.h:47
std::vector< std::uint8_t > aliasHandle
Opaque blob (decoded from hex text)
Definition Graphics.h:48
static constexpr std::string_view XmlNodeName
The XML node name for this type.
Definition Graphics.h:58
Describes the locator flavor Finale used for the associated file/graphic.
Definition Graphics.h:69
static const xml::XmlElementArray< FileDescription > & xmlMappingArray()
Required for musx::factory::FieldPopulator.
int dirId
Classic Mac OS directory ID, used with legacy MacFsSpec path. (xml node is <dirID>)
Definition Graphics.h:88
Cmper pathId
Cmper of FilePath? It is unknown if this value ever differs from the cmper of FileDescription....
Definition Graphics.h:90
PathType
Defines the possible path types.
Definition Graphics.h:78
@ MacUrlBookmark
Path is a Mac URL bookmark. (See FileUrlBookmark.)
@ MacAlias
Path is defined by mac alias. (See FileAlias.)
@ MacPosixPath
Path is a POSIX filepath.
int volRefNum
Classic Mac OS volume reference number, used with legacy MacFsSpec path.
Definition Graphics.h:87
FileDescription(const DocumentWeakPtr &document, Cmper partId, ShareMode shareMode, Cmper cmper)
Constructor.
Definition Graphics.h:72
PathType pathType
Path type. (Determines which of FileAlias and FileUrlBookmark to use as well as how to interpret File...
Definition Graphics.h:89
uint32_t version
Always 0x100, meaning perhaps "v1.0". (This was intended for tracking changes to the data format,...
Definition Graphics.h:86
static constexpr std::string_view XmlNodeName
The XML node name for this type.
Definition Graphics.h:92
Stores a human-readable path/leaf name recorded by Finale.
Definition Graphics.h:105
std::string path
Display/path string exactly as in XML. For MacAlias paths, this is only the source file name.
Definition Graphics.h:111
static const xml::XmlElementArray< FilePath > & xmlMappingArray()
Required for musx::factory::FieldPopulator.
FilePath(const DocumentWeakPtr &document, Cmper partId, ShareMode shareMode, Cmper cmper)
Constructor.
Definition Graphics.h:108
static constexpr std::string_view XmlNodeName
The XML node name for this type.
Definition Graphics.h:113
Opaque storage for a platform-specific URL/bookmark blob (e.g., macOS CFURL bookmark).
Definition Graphics.h:124
size_t length
Declared byte length.
Definition Graphics.h:130
static const xml::XmlElementArray< FileUrlBookmark > & xmlMappingArray()
Required for musx::factory::FieldPopulator.
FileUrlBookmark(const DocumentWeakPtr &document, Cmper partId, ShareMode shareMode, Cmper cmper)
Constructor.
Definition Graphics.h:127
void integrityCheck(const std::shared_ptr< Base > &ptrToThis) override
Allows a class to determine if it has been properly contructed by the factory and fix issues that it ...
Definition Graphics.h:133
static constexpr std::string_view XmlNodeName
The XML node name for this type.
Definition Graphics.h:141
std::vector< std::uint8_t > urlBookmarkData
Opaque blob decoded from hex text.
Definition Graphics.h:131
Represents a page graphic assignment with positioning and page-range properties.
Definition Graphics.h:160
Evpu rightPgLeft
Horizontal position for right pages.
Definition Graphics.h:216
HorizontalAlignment rightPgHAlign
Horizontal alignment on right pages.
Definition Graphics.h:211
void integrityCheck(const std::shared_ptr< Base > &ptrToThis) override
Allows a class to determine if it has been properly contructed by the factory and fix issues that it ...
Definition Graphics.h:243
bool savedRecord
Indicates a stored/saved record. (Used internally by Finale when a graphic is created....
Definition Graphics.h:208
bool isMultiPage() const
Returns true if this is a multi-page assignment.
Definition Graphics.h:236
PositionFrom rightPgPosFrom
Definition Graphics.h:213
bool fixedPerc
If true, preserve aspect ratio. This is a UI setting. Use width/origWidth and height/origHeight for a...
Definition Graphics.h:205
Evpu bottom
Vertical position from reference frame.
Definition Graphics.h:196
bool isMultiAssignedThruLastPage() const
Returns true if this is a multi-page assignment that is assigned to through last page,...
Definition Graphics.h:240
bool hidden
If true, the graphic does not display: inverse of "Show" context menu option. (xml tag is <displayHid...
Definition Graphics.h:201
PageGraphicAssign(const DocumentWeakPtr &document, Cmper partId, ShareMode shareMode, Cmper cmper, Inci inci)
Constructor.
Definition Graphics.h:189
Evpu origHeight
Intrinsic/original height of the graphic.
Definition Graphics.h:210
Cmper graphicCmper
Definition Graphics.h:218
Evpu left
Horizontal position from reference frame.
Definition Graphics.h:195
static MusxInstance< others::PageGraphicAssign > getForPageId(const DocumentPtr &document, Cmper partId, PageCmper pageId, Inci inci)
Returns a specific page graphic assignment for a given page number in a given part....
Definition Graphics.cpp:37
PositionFrom
Reference frame for positioning.
Definition Graphics.h:180
@ Margins
Position is relative to page margins.
@ PageEdge
Position is relative to page edge.
Evpu origWidth
Intrinsic/original width of the graphic.
Definition Graphics.h:209
uint32_t version
Always 0x100, meaning perhaps "v1.0". (This was intended for tracking changes to the data format,...
Definition Graphics.h:194
VerticalAlignment rightPgVAlign
Vertical alignment on right pages.
Definition Graphics.h:212
PageAssignType displayType
Whether the assignment appears on all/even/odd pages.
Definition Graphics.h:200
Cmper fDescId
The Cmper of the assigned FileDescription. (xml tag is <fDescID>)
Definition Graphics.h:199
static MusxInstanceList< others::PageGraphicAssign > getArrayForPageId(const DocumentPtr &document, Cmper partId, PageCmper pageId)
Returns all the page graphic assignments for a given page number in a given part. This allows the cal...
Definition Graphics.cpp:46
std::optional< PageCmper > calcStartPageNumber(Cmper forPartId) const
Return the starting page number, taking into account leading blank pages in all parts....
Definition Graphics.cpp:55
PageCmper startPage
First page assignment ID where the graphic appears when cmper==0.
Definition Graphics.h:206
std::optional< PageCmper > calcEndPageNumber(Cmper forPartId) const
Return the ending page number, taking into account leading blank pages in all parts This calculation ...
Definition Graphics.cpp:73
PageAssignType
Which pages a multipage assignment appears on.
Definition Graphics.h:168
Evpu rightPgBottom
Vertical position for right pages.
Definition Graphics.h:217
static constexpr std::string_view XmlNodeName
The XML node name for this type.
Definition Graphics.h:269
static const xml::XmlElementArray< PageGraphicAssign > & xmlMappingArray()
Required for musx::factory::FieldPopulator.
VerticalAlignment vAlign
Vertical alignment for left/all pages. (xml tag is <valign>)
Definition Graphics.h:203
Evpu width
Display width of the placed graphic.
Definition Graphics.h:197
HorizontalAlignment hAlign
Horizontal alignment for left/all pages. (xml tag is <halign>)
Definition Graphics.h:202
Evpu height
Display height of the placed graphic.
Definition Graphics.h:198
PositionFrom posFrom
Position reference for left/all pages.
Definition Graphics.h:204
PageCmper endPage
Last page assignment ID where the graphic appears when cmper==0.
Definition Graphics.h:207
bool rightPgFixedPerc
If true, preserve aspect ratio on right-pages (UI setting only). The Finale UI appears to sync this w...
Definition Graphics.h:215
Represents a graphic assignment anchored to a specific staff and measure.
Definition Graphics.h:282
Cmper graphicCmper
Graphic instance Cmper. (See others::PageGraphicAssign::graphicCmper for full explanation....
Definition Graphics.h:313
Cmper fDescId
The Cmper of the assigned others::FileDescription. (xml tag is <fDescID>)
Definition Graphics.h:305
bool fixedPerc
UI setting to preserve aspect ratio. It may be meaningless here, since there is no UI setting for sha...
Definition Graphics.h:308
VerticalAlignment vAlign
Vertical alignment the placed graphic: possibly always Top. (xml tag is <valign>)
Definition Graphics.h:307
Evpu origWidth
Original (intrinsic) width in Evpu.
Definition Graphics.h:311
ShapeGraphicAssign(const DocumentWeakPtr &document, Cmper partId, ShareMode shareMode, Cmper cmper, Inci inci)
Constructor.
Definition Graphics.h:292
Evpu width
Graphic width in Evpu.
Definition Graphics.h:303
Evpu bottom
Graphic bottom coordinate in Evpu.
Definition Graphics.h:302
uint32_t version
Always 0x100, meaning perhaps "v1.0". (This was intended for tracking changes to the data format,...
Definition Graphics.h:300
static constexpr std::string_view XmlNodeName
The XML node name for this type.
Definition Graphics.h:315
Evpu origHeight
Original (intrinsic) height in Evpu.
Definition Graphics.h:312
static const xml::XmlElementArray< ShapeGraphicAssign > & xmlMappingArray()
Required for musx::factory::FieldPopulator.
Evpu height
Graphic height in Evpu.
Definition Graphics.h:304
HorizontalAlignment hAlign
Horizontal alignment of the placed graphic: possibly always Left. (xml tag is <halign>)
Definition Graphics.h:306
bool hidden
Indicates the graphic is hidden from print/displayed as hidden: possibly always false for ShapeGraphi...
Definition Graphics.h:309
bool savedRecord
Indicates a stored/saved record. (Used internally by Finale when a graphic is created....
Definition Graphics.h:310
Evpu left
Graphic left coordinate in Evpu.
Definition Graphics.h:301
std::shared_ptr< const T > MusxInstance
Defines the type of a musx instance stored in a pool.
Definition MusxInstance.h:35
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
std::weak_ptr< Document > DocumentWeakPtr
Shared weak Document pointer.
Definition BaseClasses.h:57
std::shared_ptr< Document > DocumentPtr
Shared Document pointer.
Definition BaseClasses.h:55
int16_t PageCmper
Enigma page Cmper (may be negative when not applicable)
Definition Fundamentals.h:67
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