-
Notifications
You must be signed in to change notification settings - Fork 186
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3896 from oerc-music/develop
Add initial support for <annot type="score"> (classes and round trip read/write)
- Loading branch information
Showing
9 changed files
with
267 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
///////////////////////////////////////////////////////////////////////////// | ||
// Name: annotscore.h | ||
// Author: David Lewis | ||
// Created: 2024 | ||
// Copyright (c) Authors and others. All rights reserved. | ||
///////////////////////////////////////////////////////////////////////////// | ||
|
||
#ifndef __VRV_ANNOTSCORE_H__ | ||
#define __VRV_ANNOTSCORE_H__ | ||
|
||
#include "atts_cmn.h" | ||
#include "atts_shared.h" | ||
#include "controlelement.h" | ||
#include "editorial.h" | ||
#include "timeinterface.h" | ||
|
||
namespace vrv { | ||
|
||
//---------------------------------------------------------------------------- | ||
// AnnotScore | ||
//---------------------------------------------------------------------------- | ||
|
||
/** | ||
* This class models the MEI <annot> element where @type is score. | ||
*/ | ||
class AnnotScore : public ControlElement, public TimeSpanningInterface, public AttPlist { | ||
public: | ||
/** | ||
* @name Constructors, destructors, and other standard methods | ||
* Reset method reset all attribute classes | ||
*/ | ||
///@{ | ||
AnnotScore(); | ||
virtual ~AnnotScore(); | ||
// Object *Clone() const override { return new AnnotScore(*this); } | ||
void Reset() override; | ||
std::string GetClassName() const override { return "AnnotScore"; } | ||
///@} | ||
|
||
/** | ||
* @name Getter to interfaces | ||
*/ | ||
///@{ | ||
TimePointInterface *GetTimePointInterface() override { return vrv_cast<TimePointInterface *>(this); } | ||
const TimePointInterface *GetTimePointInterface() const override | ||
{ | ||
return vrv_cast<const TimePointInterface *>(this); | ||
} | ||
TimeSpanningInterface *GetTimeSpanningInterface() override { return vrv_cast<TimeSpanningInterface *>(this); } | ||
const TimeSpanningInterface *GetTimeSpanningInterface() const override | ||
{ | ||
return vrv_cast<const TimeSpanningInterface *>(this); | ||
} | ||
|
||
/** | ||
* Add a text element to an annotation. | ||
* Only supported elements will be actually added to the child list. | ||
*/ | ||
bool IsSupportedChild(Object *object) override; | ||
|
||
///@} | ||
|
||
//----------// | ||
// 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; | ||
///@} | ||
|
||
protected: | ||
// | ||
private: | ||
// | ||
public: | ||
// | ||
private: | ||
}; | ||
|
||
} // namespace vrv | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
///////////////////////////////////////////////////////////////////////////// | ||
// Name: annotscore.cpp | ||
// Author: David Lewis | ||
// Created: 2024 | ||
// Copyright (c) Authors and others. All rights reserved. | ||
///////////////////////////////////////////////////////////////////////////// | ||
|
||
#include "annotscore.h" | ||
|
||
//---------------------------------------------------------------------------- | ||
|
||
#include <cassert> | ||
|
||
//---------------------------------------------------------------------------- | ||
|
||
#include "devicecontext.h" | ||
#include "doc.h" | ||
#include "functor.h" | ||
#include "text.h" | ||
#include "verticalaligner.h" | ||
#include "vrv.h" | ||
|
||
namespace vrv { | ||
|
||
//---------------------------------------------------------------------------- | ||
// AnnotScore | ||
//---------------------------------------------------------------------------- | ||
|
||
static const ClassRegistrar<AnnotScore> s_factory("annotScore", ANNOTSCORE); | ||
|
||
AnnotScore::AnnotScore() : ControlElement(ANNOTSCORE, "annotscore-"), AttPlist() | ||
{ | ||
this->RegisterInterface(TimeSpanningInterface::GetAttClasses(), TimeSpanningInterface::IsInterface()); | ||
this->RegisterAttClass(ATT_PLIST); | ||
|
||
this->Reset(); | ||
} | ||
|
||
AnnotScore::~AnnotScore() {} | ||
|
||
void AnnotScore::Reset() | ||
{ | ||
ControlElement::Reset(); | ||
this->ResetPlist(); | ||
TimeSpanningInterface::Reset(); | ||
} | ||
|
||
bool AnnotScore::IsSupportedChild(Object *child) | ||
{ | ||
if (child->IsTextElement()) { | ||
assert(dynamic_cast<TextElement *>(child)); | ||
} | ||
else if (child->Is(ANNOT)) { | ||
assert(dynamic_cast<AnnotScore *>(child)); | ||
} | ||
else { | ||
return false; | ||
} | ||
return true; | ||
} | ||
|
||
//---------------------------------------------------------------------------- | ||
// AnnotScore functor methods | ||
//---------------------------------------------------------------------------- | ||
|
||
FunctorCode AnnotScore::Accept(Functor &functor) | ||
{ | ||
return functor.VisitAnnotScore(this); | ||
} | ||
|
||
FunctorCode AnnotScore::Accept(ConstFunctor &functor) const | ||
{ | ||
return functor.VisitAnnotScore(this); | ||
} | ||
|
||
FunctorCode AnnotScore::AcceptEnd(Functor &functor) | ||
{ | ||
return functor.VisitAnnotScoreEnd(this); | ||
} | ||
|
||
FunctorCode AnnotScore::AcceptEnd(ConstFunctor &functor) const | ||
{ | ||
return functor.VisitAnnotScoreEnd(this); | ||
} | ||
|
||
} // namespace vrv |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.