Skip to content

Commit

Permalink
Merge pull request #3791 from rism-digital/develop-generic-layer-elem…
Browse files Browse the repository at this point in the history
…ents

Implementation for generic layer elements
  • Loading branch information
lpugin authored Sep 19, 2024
2 parents 28fe939 + a47f7a7 commit 28e162a
Show file tree
Hide file tree
Showing 10 changed files with 237 additions and 0 deletions.
16 changes: 16 additions & 0 deletions Verovio.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,12 @@
4D64137E2035F68600BB630E /* mdiv.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4D64137D2035F68600BB630E /* mdiv.cpp */; };
4D64137F2035F68600BB630E /* mdiv.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4D64137D2035F68600BB630E /* mdiv.cpp */; };
4D6413802035F68600BB630E /* mdiv.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4D64137D2035F68600BB630E /* mdiv.cpp */; };
4D64793F2C9C0F1C00CD9539 /* genericlayerelement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4D64793E2C9C0F1C00CD9539 /* genericlayerelement.cpp */; };
4D6479412C9C0F4200CD9539 /* genericlayerelement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4D64793E2C9C0F1C00CD9539 /* genericlayerelement.cpp */; };
4D6479422C9C0F4300CD9539 /* genericlayerelement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4D64793E2C9C0F1C00CD9539 /* genericlayerelement.cpp */; };
4D6479432C9C0F4400CD9539 /* genericlayerelement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4D64793E2C9C0F1C00CD9539 /* genericlayerelement.cpp */; };
4D6479442C9C0F4700CD9539 /* genericlayerelement.h in Headers */ = {isa = PBXBuildFile; fileRef = 4D6479402C9C0F2D00CD9539 /* genericlayerelement.h */; };
4D6479452C9C0F4800CD9539 /* genericlayerelement.h in Headers */ = {isa = PBXBuildFile; fileRef = 4D6479402C9C0F2D00CD9539 /* genericlayerelement.h */; settings = {ATTRIBUTES = (Public, ); }; };
4D674B3F255F40AC008AEF4C /* plica.h in Headers */ = {isa = PBXBuildFile; fileRef = 4D674B3E255F40AC008AEF4C /* plica.h */; };
4D674B40255F40AC008AEF4C /* plica.h in Headers */ = {isa = PBXBuildFile; fileRef = 4D674B3E255F40AC008AEF4C /* plica.h */; settings = {ATTRIBUTES = (Public, ); }; };
4D674B46255F40B7008AEF4C /* plica.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4D674B45255F40B7008AEF4C /* plica.cpp */; };
Expand Down Expand Up @@ -1871,6 +1877,8 @@
4D6413772035F58200BB630E /* pages.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = pages.cpp; path = src/pages.cpp; sourceTree = "<group>"; };
4D64137B2035F67C00BB630E /* mdiv.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = mdiv.h; path = include/vrv/mdiv.h; sourceTree = "<group>"; };
4D64137D2035F68600BB630E /* mdiv.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = mdiv.cpp; path = src/mdiv.cpp; sourceTree = "<group>"; };
4D64793E2C9C0F1C00CD9539 /* genericlayerelement.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = genericlayerelement.cpp; path = src/genericlayerelement.cpp; sourceTree = "<group>"; };
4D6479402C9C0F2D00CD9539 /* genericlayerelement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = genericlayerelement.h; path = include/vrv/genericlayerelement.h; sourceTree = "<group>"; };
4D674B3E255F40AC008AEF4C /* plica.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = plica.h; path = include/vrv/plica.h; sourceTree = "<group>"; };
4D674B45255F40B7008AEF4C /* plica.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = plica.cpp; path = src/plica.cpp; sourceTree = "<group>"; };
4D6DF9F420E1071E00C12BBD /* subst.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = subst.cpp; path = src/subst.cpp; sourceTree = "<group>"; };
Expand Down Expand Up @@ -2983,6 +2991,8 @@
4DEEDE621E617C880087E8BC /* elementpart.h */,
409B3DD81F2D1C2A0098A265 /* ftrem.cpp */,
409B3DD71F2D1C0C0098A265 /* ftrem.h */,
4D64793E2C9C0F1C00CD9539 /* genericlayerelement.cpp */,
4D6479402C9C0F2D00CD9539 /* genericlayerelement.h */,
400FEDD2206FA743000D3233 /* gracegrp.cpp */,
400FEDD1206FA742000D3233 /* gracegrp.h */,
4D1BD1B421908D6B000D35B2 /* halfmrpt.cpp */,
Expand Down Expand Up @@ -3338,6 +3348,7 @@
4DB3D8FB1F83D1F700B5FC2B /* floatingobject.h in Headers */,
4D49924F2926B4E9007E3431 /* toolkitdef.h in Headers */,
4D94721D20CA701000C780C8 /* linkinginterface.h in Headers */,
4D6479442C9C0F4700CD9539 /* genericlayerelement.h in Headers */,
403BEFF7206C00F800D022D5 /* multirpt.h in Headers */,
4DC12A751F73FF92000440E9 /* runningelement.h in Headers */,
4DB3D8DD1F83D14B00B5FC2B /* artic.h in Headers */,
Expand Down Expand Up @@ -3496,6 +3507,7 @@
BB4C4B9C22A932E5001F6AF0 /* pitchinterface.h in Headers */,
4DACC9E92990F29A00B55913 /* atts_fingering.h in Headers */,
BB4C4A9422A9328F001F6AF0 /* doc.h in Headers */,
4D6479452C9C0F4800CD9539 /* genericlayerelement.h in Headers */,
BB4C4A9922A9328F001F6AF0 /* horizontalaligner.h in Headers */,
BB4C4AAE22A932A6001F6AF0 /* iobase.h in Headers */,
BB4C4BAA22A932EB001F6AF0 /* view.h in Headers */,
Expand Down Expand Up @@ -4155,6 +4167,7 @@
E7BCFFBA281298620012513D /* resources.cpp in Sources */,
40D45EC3204EEAFE009C1EC9 /* instrdef.cpp in Sources */,
4DACC9ED2990F29A00B55913 /* atts_shared.cpp in Sources */,
4D6479412C9C0F4200CD9539 /* genericlayerelement.cpp in Sources */,
4D16943D1E3A44F300569BF4 /* view_element.cpp in Sources */,
4DACC9AB2990F29A00B55913 /* attmodule.cpp in Sources */,
4D16943E1E3A44F300569BF4 /* view_graph.cpp in Sources */,
Expand Down Expand Up @@ -4431,6 +4444,7 @@
8F086F0A188539540037FD8E /* view_page.cpp in Sources */,
E7876F2029C0A702002147DC /* adjusttupletsxfunctor.cpp in Sources */,
E79C87C3269440570098FE85 /* lv.cpp in Sources */,
4D64793F2C9C0F1C00CD9539 /* genericlayerelement.cpp in Sources */,
4D7AFDC72A5554A100835ED1 /* divline.cpp in Sources */,
4DEC4DA621C81ED400D1D273 /* reg.cpp in Sources */,
8F086F0B188539540037FD8E /* view_tuplet.cpp in Sources */,
Expand Down Expand Up @@ -4732,6 +4746,7 @@
4DB3D8F31F83D1C600B5FC2B /* scoredefinterface.cpp in Sources */,
4D2461DD246BE2E8002BBCCD /* expansionmap.cpp in Sources */,
E7BCFFB5281297980012513D /* resources.cpp in Sources */,
4D6479422C9C0F4300CD9539 /* genericlayerelement.cpp in Sources */,
4DACC9EE2990F29A00B55913 /* atts_shared.cpp in Sources */,
8F3DD32018854AFB0051330C /* devicecontext.cpp in Sources */,
4DACC9AC2990F29A00B55913 /* attmodule.cpp in Sources */,
Expand Down Expand Up @@ -5021,6 +5036,7 @@
BB4C4AB722A932A6001F6AF0 /* iomusxml.cpp in Sources */,
4DACC9EF2990F29A00B55913 /* atts_shared.cpp in Sources */,
BB4C4BC322A9330D001F6AF0 /* pugixml.cpp in Sources */,
4D6479432C9C0F4400CD9539 /* genericlayerelement.cpp in Sources */,
4DACC9AD2990F29A00B55913 /* attmodule.cpp in Sources */,
4D2E758B22BC2B5B004C51F0 /* tabgrp.cpp in Sources */,
4D2E758D22BC2B5B004C51F0 /* tabdursym.cpp in Sources */,
Expand Down
5 changes: 5 additions & 0 deletions include/vrv/functorinterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ class Fig;
class Flag;
class FloatingObject;
class FTrem;
class GenericLayerElement;
class Gliss;
class GraceAligner;
class GraceGrp;
Expand Down Expand Up @@ -361,6 +362,8 @@ class FunctorInterface {
virtual FunctorCode VisitFlagEnd(Flag *flag);
virtual FunctorCode VisitFTrem(FTrem *fTrem);
virtual FunctorCode VisitFTremEnd(FTrem *fTrem);
virtual FunctorCode VisitGenericLayerElement(GenericLayerElement *genericLayerElement);
virtual FunctorCode VisitGenericLayerElementEnd(GenericLayerElement *genericLayerElement);
virtual FunctorCode VisitGraceGrp(GraceGrp *graceGrp);
virtual FunctorCode VisitGraceGrpEnd(GraceGrp *graceGrp);
virtual FunctorCode VisitHalfmRpt(HalfmRpt *halfmRpt);
Expand Down Expand Up @@ -718,6 +721,8 @@ class ConstFunctorInterface {
virtual FunctorCode VisitFlagEnd(const Flag *flag);
virtual FunctorCode VisitFTrem(const FTrem *fTrem);
virtual FunctorCode VisitFTremEnd(const FTrem *fTrem);
virtual FunctorCode VisitGenericLayerElement(const GenericLayerElement *genericLayerElement);
virtual FunctorCode VisitGenericLayerElementEnd(const GenericLayerElement *genericLayerElement);
virtual FunctorCode VisitGraceGrp(const GraceGrp *graceGrp);
virtual FunctorCode VisitGraceGrpEnd(const GraceGrp *graceGrp);
virtual FunctorCode VisitHalfmRpt(const HalfmRpt *halfmRpt);
Expand Down
69 changes: 69 additions & 0 deletions include/vrv/genericlayerelement.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
/////////////////////////////////////////////////////////////////////////////
// Name: genericlayerelement.h
// Author: Laurent Pugin
// Created: 2024
// Copyright (c) Authors and others. All rights reserved.
/////////////////////////////////////////////////////////////////////////////

#ifndef __VRV_GENERICLAYERELEMENT_H__
#define __VRV_GENERICLAYERELEMENT_H__

#include "layerelement.h"

namespace vrv {

//----------------------------------------------------------------------------
// GenericLayerElement
//----------------------------------------------------------------------------

/**
* This class holds generic elements existing within MEI <layer> but not supported by Verovio
*/
class GenericLayerElement : public LayerElement {
public:
/**
* @name Constructors, destructors, reset and class name methods
* Reset method resets all attribute classes
*/
///@{
GenericLayerElement();
GenericLayerElement(const std::string &name);
virtual ~GenericLayerElement();
Object *Clone() const override { return new GenericLayerElement(*this); }
void Reset() override;
std::string GetClassName() const override { return m_className; }
///@}

/**
* Return the MEI element original name
*/
std::string GetMEIName() const { return m_meiName; }

//----------//
// Functors //
//----------//

/**
* Interface for class functor visitation
*/
///@{
FunctorCode Accept(Functor &functor) override;
FunctorCode Accept(ConstFunctor &functor) const override;
FunctorCode AcceptEnd(Functor &functor) override;
FunctorCode AcceptEnd(ConstFunctor &functor) const override;
///@}

private:
/** The class name */
std::string m_className;
/** The MEI element name */
std::string m_meiName;

public:
//
private:
};

} // namespace vrv

#endif
3 changes: 3 additions & 0 deletions include/vrv/iomei.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ class Fing;
class Fermata;
class FloatingElement;
class FTrem;
class GenericLayerElement;
class Gliss;
class GraceGrp;
class Graphic;
Expand Down Expand Up @@ -395,6 +396,7 @@ class MEIOutput : public Output {
void WriteDivLine(pugi::xml_node currentNode, DivLine *divLine);
void WriteDot(pugi::xml_node currentNode, Dot *dot);
void WriteFTrem(pugi::xml_node currentNode, FTrem *fTrem);
void WriteGenericLayerElement(pugi::xml_node currentNode, GenericLayerElement *element);
void WriteGraceGrp(pugi::xml_node currentNode, GraceGrp *graceGrp);
void WriteHalfmRpt(pugi::xml_node currentNode, HalfmRpt *halfmRpt);
void WriteKeyAccid(pugi::xml_node currentNode, KeyAccid *keyAccid);
Expand Down Expand Up @@ -708,6 +710,7 @@ class MEIInput : public Input {
bool ReadDivLine(Object *parent, pugi::xml_node divLine);
bool ReadDot(Object *parent, pugi::xml_node dot);
bool ReadFTrem(Object *parent, pugi::xml_node fTrem);
bool ReadGenericLayerElement(Object *parent, pugi::xml_node element);
bool ReadGraceGrp(Object *parent, pugi::xml_node graceGrp);
bool ReadHalfmRpt(Object *parent, pugi::xml_node halfmRpt);
bool ReadKeyAccid(Object *parent, pugi::xml_node keyAccid);
Expand Down
2 changes: 2 additions & 0 deletions include/vrv/view.h
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,8 @@ class View {
void DrawDots(DeviceContext *dc, LayerElement *element, Layer *layer, Staff *staff, Measure *measure);
void DrawDurationElement(DeviceContext *dc, LayerElement *element, Layer *layer, Staff *staff, Measure *measure);
void DrawFlag(DeviceContext *dc, LayerElement *element, Layer *layer, Staff *staff, Measure *measure);
void DrawGenericLayerElement(
DeviceContext *dc, LayerElement *element, Layer *layer, Staff *staff, Measure *measure);
void DrawGraceGrp(DeviceContext *dc, LayerElement *element, Layer *layer, Staff *staff, Measure *measure);
void DrawHalfmRpt(DeviceContext *dc, LayerElement *element, Layer *layer, Staff *staff, Measure *measure);
void DrawKeySig(DeviceContext *dc, LayerElement *element, Layer *layer, Staff *staff, Measure *measure);
Expand Down
1 change: 1 addition & 0 deletions include/vrv/vrvdef.h
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,7 @@ enum ClassId : uint16_t {
DOTS,
FLAG,
FTREM,
GENERIC_ELEMENT,
GRACEGRP,
HALFMRPT,
KEYSIG,
Expand Down
21 changes: 21 additions & 0 deletions src/functorinterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
#include "fig.h"
#include "fing.h"
#include "ftrem.h"
#include "genericlayerelement.h"
#include "gliss.h"
#include "gracegrp.h"
#include "grpsym.h"
Expand Down Expand Up @@ -895,6 +896,16 @@ FunctorCode FunctorInterface::VisitGraceGrpEnd(GraceGrp *graceGrp)
return this->VisitLayerElementEnd(graceGrp);
}

FunctorCode FunctorInterface::VisitGenericLayerElement(GenericLayerElement *genericLayerElement)
{
return this->VisitLayerElement(genericLayerElement);
}

FunctorCode FunctorInterface::VisitGenericLayerElementEnd(GenericLayerElement *genericLayerElement)
{
return this->VisitLayerElementEnd(genericLayerElement);
}

FunctorCode FunctorInterface::VisitHalfmRpt(HalfmRpt *halfmRpt)
{
return this->VisitLayerElement(halfmRpt);
Expand Down Expand Up @@ -2179,6 +2190,16 @@ FunctorCode ConstFunctorInterface::VisitGraceGrpEnd(const GraceGrp *graceGrp)
return this->VisitLayerElementEnd(graceGrp);
}

FunctorCode ConstFunctorInterface::VisitGenericLayerElement(const GenericLayerElement *genericLayerElement)
{
return this->VisitLayerElement(genericLayerElement);
}

FunctorCode ConstFunctorInterface::VisitGenericLayerElementEnd(const GenericLayerElement *genericLayerElement)
{
return this->VisitLayerElementEnd(genericLayerElement);
}

FunctorCode ConstFunctorInterface::VisitHalfmRpt(const HalfmRpt *halfmRpt)
{
return this->VisitLayerElement(halfmRpt);
Expand Down
73 changes: 73 additions & 0 deletions src/genericlayerelement.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
/////////////////////////////////////////////////////////////////////////////
// Name: genericlayerelement.cpp
// Author: Laurent Pugin
// Created: 2024
// Copyright (c) Authors and others. All rights reserved.
/////////////////////////////////////////////////////////////////////////////

#include "genericlayerelement.h"
//----------------------------------------------------------------------------

#include <cassert>
#include <math.h>

//----------------------------------------------------------------------------

#include "functor.h"
#include "vrv.h"

namespace vrv {

//----------------------------------------------------------------------------
// Space
//----------------------------------------------------------------------------

// static const ClassRegistrar<GenericLayerElement> s_factory("generic", GENERIC_ELEMENT);

GenericLayerElement::GenericLayerElement() : LayerElement(GENERIC_ELEMENT, "generic-")
{
LogError("Creating generic element without name");
m_className = "[unspecified]";
this->Reset();
}

GenericLayerElement::GenericLayerElement(const std::string &name) : LayerElement(GENERIC_ELEMENT, name + "-")
{
m_meiName = name;
m_className = name;
std::transform(m_className.begin(), m_className.begin() + 1, m_className.begin(), ::toupper);
this->Reset();
}

GenericLayerElement::~GenericLayerElement() {}

void GenericLayerElement::Reset()
{
LayerElement::Reset();
}

//----------------------------------------------------------------------------
// Functors methods
//----------------------------------------------------------------------------

FunctorCode GenericLayerElement::Accept(Functor &functor)
{
return functor.VisitGenericLayerElement(this);
}

FunctorCode GenericLayerElement::Accept(ConstFunctor &functor) const
{
return functor.VisitGenericLayerElement(this);
}

FunctorCode GenericLayerElement::AcceptEnd(Functor &functor)
{
return functor.VisitGenericLayerElementEnd(this);
}

FunctorCode GenericLayerElement::AcceptEnd(ConstFunctor &functor) const
{
return functor.VisitGenericLayerElementEnd(this);
}

} // namespace vrv
Loading

0 comments on commit 28e162a

Please sign in to comment.