Skip to content

Commit

Permalink
Merge pull request rism-digital#3565 from rism-digital/develop-facsimile
Browse files Browse the repository at this point in the history
Initial refactoring for making the use of facsimile more generic
  • Loading branch information
lpugin committed Jan 10, 2024
2 parents 6baff71 + 3a03a72 commit 7fc8198
Show file tree
Hide file tree
Showing 34 changed files with 694 additions and 115 deletions.
16 changes: 16 additions & 0 deletions Verovio.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -800,6 +800,12 @@
4DE96E3B21C4373200CB85BE /* bracketspan.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4DE96E3A21C4373200CB85BE /* bracketspan.cpp */; };
4DE96E3C21C4373200CB85BE /* bracketspan.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4DE96E3A21C4373200CB85BE /* bracketspan.cpp */; };
4DE96E3D21C4373200CB85BE /* bracketspan.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4DE96E3A21C4373200CB85BE /* bracketspan.cpp */; };
4DEBE6E12B36E78900B67DFB /* facsimilefunctor.h in Headers */ = {isa = PBXBuildFile; fileRef = 4DEBE6E02B36E78900B67DFB /* facsimilefunctor.h */; };
4DEBE6E22B36E78900B67DFB /* facsimilefunctor.h in Headers */ = {isa = PBXBuildFile; fileRef = 4DEBE6E02B36E78900B67DFB /* facsimilefunctor.h */; settings = {ATTRIBUTES = (Public, ); }; };
4DEBE6E42B36E79600B67DFB /* facsimilefunctor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4DEBE6E32B36E79600B67DFB /* facsimilefunctor.cpp */; };
4DEBE6E52B36E79600B67DFB /* facsimilefunctor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4DEBE6E32B36E79600B67DFB /* facsimilefunctor.cpp */; };
4DEBE6E62B36E9B300B67DFB /* facsimilefunctor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4DEBE6E32B36E79600B67DFB /* facsimilefunctor.cpp */; };
4DEBE6E72B36E9B400B67DFB /* facsimilefunctor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4DEBE6E32B36E79600B67DFB /* facsimilefunctor.cpp */; };
4DEC4D5A21C800A000D1D273 /* abbr.h in Headers */ = {isa = PBXBuildFile; fileRef = 4DEC4D5921C8009600D1D273 /* abbr.h */; };
4DEC4D7A21C8048700D1D273 /* abbr.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4DEC4D7921C8048700D1D273 /* abbr.cpp */; };
4DEC4D7B21C8048700D1D273 /* abbr.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4DEC4D7921C8048700D1D273 /* abbr.cpp */; };
Expand Down Expand Up @@ -2014,6 +2020,8 @@
4DE644F41EDBEA01002FBE6C /* breath.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = breath.cpp; path = src/breath.cpp; sourceTree = "<group>"; };
4DE96E3821C4370E00CB85BE /* bracketspan.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = bracketspan.h; path = include/vrv/bracketspan.h; sourceTree = "<group>"; };
4DE96E3A21C4373200CB85BE /* bracketspan.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = bracketspan.cpp; path = src/bracketspan.cpp; sourceTree = "<group>"; };
4DEBE6E02B36E78900B67DFB /* facsimilefunctor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = facsimilefunctor.h; path = include/vrv/facsimilefunctor.h; sourceTree = "<group>"; };
4DEBE6E32B36E79600B67DFB /* facsimilefunctor.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = facsimilefunctor.cpp; path = src/facsimilefunctor.cpp; sourceTree = "<group>"; };
4DEC4D5921C8009600D1D273 /* abbr.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = abbr.h; path = include/vrv/abbr.h; sourceTree = "<group>"; };
4DEC4D7921C8048700D1D273 /* abbr.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = abbr.cpp; path = src/abbr.cpp; sourceTree = "<group>"; };
4DEC4D7D21C804C500D1D273 /* add.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = add.cpp; path = src/add.cpp; sourceTree = "<group>"; };
Expand Down Expand Up @@ -3012,6 +3020,8 @@
E7265E6D29DC6FD200D11F41 /* castofffunctor.h */,
E763EF4129E939FB0029E56D /* convertfunctor.cpp */,
E763EF3E29E939C00029E56D /* convertfunctor.h */,
4DEBE6E32B36E79600B67DFB /* facsimilefunctor.cpp */,
4DEBE6E02B36E78900B67DFB /* facsimilefunctor.h */,
E74A806028BC9111005274E7 /* findfunctor.cpp */,
E74A806528BC97D5005274E7 /* findfunctor.h */,
E722106528F856C4002CD6E9 /* findlayerelementsfunctor.cpp */,
Expand Down Expand Up @@ -3384,6 +3394,7 @@
40DA9C3720905CEB006BED92 /* ioabc.h in Headers */,
4DB3D8CD1F83D11100B5FC2B /* harm.h in Headers */,
40D45EC2204EEAFB009C1EC9 /* instrdef.h in Headers */,
4DEBE6E12B36E78900B67DFB /* facsimilefunctor.h in Headers */,
4D94E0E22995411100F49F89 /* meibasic.h in Headers */,
BD2E4D9B2875882200B04350 /* stem.h in Headers */,
4DACC9EA2990F29A00B55913 /* attmodule.h in Headers */,
Expand Down Expand Up @@ -3441,6 +3452,7 @@
E7908EA0298582090004C1F9 /* alignfunctor.h in Headers */,
BB4C4B9822A932E5001F6AF0 /* durationinterface.h in Headers */,
BB4C4BB722A932F6001F6AF0 /* jsonxx.h in Headers */,
4DEBE6E22B36E78900B67DFB /* facsimilefunctor.h in Headers */,
BB4C4B1622A932C8001F6AF0 /* systemelement.h in Headers */,
BB4C4AC622A932B6001F6AF0 /* measure.h in Headers */,
E741AD00299A3D3500854426 /* calcslurdirectionfunctor.h in Headers */,
Expand Down Expand Up @@ -3926,6 +3938,7 @@
E7F39C6229A62B430055DBE0 /* adjustclefchangesfunctor.cpp in Sources */,
E79320682991454000D80975 /* calcstemfunctor.cpp in Sources */,
4DED4F18294733140073E504 /* altsyminterface.cpp in Sources */,
4DEBE6E72B36E9B400B67DFB /* facsimilefunctor.cpp in Sources */,
4DEF8A6521B7AAF90093A76B /* f.cpp in Sources */,
4D2073F922A3BCE000E0765F /* tabdursym.cpp in Sources */,
4D16940B1E3A44F300569BF4 /* keysig.cpp in Sources */,
Expand Down Expand Up @@ -4206,6 +4219,7 @@
8F086EF1188539540037FD8E /* keysig.cpp in Sources */,
E74A806C28BC98B2005274E7 /* functorinterface.cpp in Sources */,
E7870357299CF06D00156DC4 /* adjustarpegfunctor.cpp in Sources */,
4DEBE6E62B36E9B300B67DFB /* facsimilefunctor.cpp in Sources */,
4DEC4D9E21C81E9400D1D273 /* orig.cpp in Sources */,
4DDBBB5D1C7AE45900054AFF /* hairpin.cpp in Sources */,
4D43C30C1A9BB22A00EA28F3 /* view_mensural.cpp in Sources */,
Expand Down Expand Up @@ -4489,6 +4503,7 @@
4DB3D8D51F83D12B00B5FC2B /* tempo.cpp in Sources */,
4DEC4DA021C81E9400D1D273 /* orig.cpp in Sources */,
E7F39C6329A62B440055DBE0 /* adjustclefchangesfunctor.cpp in Sources */,
4DEBE6E42B36E79600B67DFB /* facsimilefunctor.cpp in Sources */,
E79320692991454000D80975 /* calcstemfunctor.cpp in Sources */,
8F3DD33E18854B2E0051330C /* beam.cpp in Sources */,
4DED4F19294733140073E504 /* altsyminterface.cpp in Sources */,
Expand Down Expand Up @@ -4771,6 +4786,7 @@
E793206A2991454100D80975 /* calcstemfunctor.cpp in Sources */,
BB4C4AD722A932B6001F6AF0 /* staff.cpp in Sources */,
4DED4F1A294733140073E504 /* altsyminterface.cpp in Sources */,
4DEBE6E52B36E79600B67DFB /* facsimilefunctor.cpp in Sources */,
BB4C4B9F22A932E5001F6AF0 /* positioninterface.cpp in Sources */,
BB4C4B5322A932D7001F6AF0 /* halfmrpt.cpp in Sources */,
BB4C4B8722A932DF001F6AF0 /* num.cpp in Sources */,
Expand Down
18 changes: 17 additions & 1 deletion include/vrv/doc.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,6 @@ class Doc : public Object {

/**
* Getter and setter for the DocType.
* The setter resets the document.
*/
///@{
DocType GetType() const { return m_type; }
Expand Down Expand Up @@ -373,6 +372,18 @@ class Doc : public Object {
*/
void ConvertMarkupDoc(bool permanent = true);

/**
* Sync the coordinate provided trought <facsimile> to m_drawingFacsX/Y.
* Call the SyncToFacsimile functor.
*/
void SyncFromFacsimileDoc();

/**
* Sync the coordinate provided in rendering to a <facsimile>.
* The document must have encoded layout and the option --break encoded must have enabled.
*/
void SyncToFacsimileDoc();

/**
* Transpose the content of the doc.
*/
Expand All @@ -390,6 +401,11 @@ class Doc : public Object {
*/
Page *SetDrawingPage(int pageIdx);

/**
* Update the drawing page sizes when a page is set as drawing page.
*/
void UpdatePageDrawingSizes();

/**
* Reset drawing page to NULL.
* This might be necessary if we have replaced a page in the document.
Expand Down
1 change: 0 additions & 1 deletion include/vrv/durationinterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

namespace vrv {

class FunctorParams;
class Mensur;
class Object;

Expand Down
136 changes: 136 additions & 0 deletions include/vrv/facsimilefunctor.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
/////////////////////////////////////////////////////////////////////////////
// Name: facsimilefunctor.h
// Author: Laurent Pugin
// Created: 2023
// Copyright (c) Authors and others. All rights reserved.
/////////////////////////////////////////////////////////////////////////////

#ifndef __VRV_FACSIMILEFUNCTOR_H__
#define __VRV_FACSIMILEFUNCTOR_H__

#include "functor.h"
#include "view.h"

namespace vrv {

class LayerElement;
class Measure;
class Page;
class Pb;
class Sb;
class Staff;
class Surface;
class System;

//----------------------------------------------------------------------------
// SyncFromFacsimileFunctor
//----------------------------------------------------------------------------

/**
* This class sync the layout encoded in the facsimile to m_Abs members
*/
class SyncFromFacsimileFunctor : public Functor {
public:
/**
* @name Constructors, destructors
*/
///@{
SyncFromFacsimileFunctor(Doc *doc);
virtual ~SyncFromFacsimileFunctor() = default;
///@}

/*
* Abstract base implementation
*/
bool ImplementsEndInterface() const override { return false; }

/*
* Functor interface
*/
///@{
FunctorCode VisitLayerElement(LayerElement *layerElement) override;
FunctorCode VisitMeasure(Measure *measure) override;
FunctorCode VisitPage(Page *page) override;
FunctorCode VisitPb(Pb *pb) override;
FunctorCode VisitSb(Sb *sb) override;
FunctorCode VisitStaff(Staff *staff) override;
FunctorCode VisitSystem(System *system) override;
///@}

protected:
//
private:
//
public:
//
private:
/** The doc */
Doc *m_doc;
//
View m_view;
//
Page *m_currentPage;
System *m_currentSystem;
};

//----------------------------------------------------------------------------
// SyncToFacsimileFunctor
//----------------------------------------------------------------------------

/**
* This class sync the layout calculated to the facsimile
*/
class SyncToFacsimileFunctor : public Functor {
public:
/**
* @name Constructors, destructors
*/
///@{
SyncToFacsimileFunctor(Doc *doc);
virtual ~SyncToFacsimileFunctor() = default;
///@}

/*
* Abstract base implementation
*/
bool ImplementsEndInterface() const override { return false; }

/*
* Functor interface
*/
///@{
FunctorCode VisitLayerElement(LayerElement *layerElement) override;
FunctorCode VisitMeasure(Measure *measure) override;
FunctorCode VisitPage(Page *page) override;
FunctorCode VisitPb(Pb *pb) override;
FunctorCode VisitSb(Sb *sb) override;
FunctorCode VisitStaff(Staff *staff) override;
FunctorCode VisitSystem(System *system) override;
///@}

protected:
//
private:
/** Create zone if not exist */
Zone *GetZone(FacsimileInterface *interface, std::string type);

public:
//
private:
/** The doc */
Doc *m_doc;
//
View m_view;
/** The surface we are going to add / update zone */
Surface *m_surface;
//
Page *m_currentPage;
System *m_currentSystem;
//
int m_pageMarginTop;
int m_pageMarginLeft;
};

} // namespace vrv

#endif // __VRV_FACSIMILEFUNCTOR_H__
24 changes: 21 additions & 3 deletions include/vrv/facsimileinterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,11 @@
#include "interface.h"

namespace vrv {
class FunctorParams;
class View;

class Facsimile;
class PrepareFacsimileFunctor;
class ResetDataFunctor;
class Surface;
class Zone;

//----------------------------------------------------------------------------
Expand Down Expand Up @@ -56,8 +59,23 @@ class FacsimileInterface : public Interface, public AttFacsimile {
const Zone *GetZone() const { return m_zone; }
///@}

//-----------------//
// Pseudo functors //
//-----------------//

/**
* We have functor code in the interface for avoiding code duplication in each implementation class.
* Since we are in an interface, we need to pass the object (implementation) to
* the pseudo functor method.
*/
///@{
FunctorCode InterfacePrepareFacsimile(PrepareFacsimileFunctor &functor, Object *object);
FunctorCode InterfaceResetData(ResetDataFunctor &functor, Object *object);
///@}

private:
Zone *m_zone = NULL;
Zone *m_zone;
Surface *m_surface;
};
} // namespace vrv
#endif
2 changes: 1 addition & 1 deletion include/vrv/layerelement.h
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ class LayerElement : public Object,

public:
/** Absolute position X. This is used for facsimile (transcription) encoding */
int m_xAbs;
int m_drawingFacsX;
/**
* This stores a pointer to the cross-staff (if any) and the appropriate layer
* See PrepareCrossStaffFunctor
Expand Down
17 changes: 15 additions & 2 deletions include/vrv/measure.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "atts_cmn.h"
#include "atts_shared.h"
#include "barline.h"
#include "facsimileinterface.h"
#include "horizontalaligner.h"
#include "object.h"

Expand All @@ -34,6 +35,7 @@ class TimestampAttr;
* For internally simplication of processing, unmeasured music is contained in one single measure object
*/
class Measure : public Object,
public FacsimileInterface,
public AttBarring,
public AttCoordX1,
public AttCoordX2,
Expand Down Expand Up @@ -63,6 +65,17 @@ class Measure : public Object,
*/
void CloneReset() override;

/**
* @name Getter to interfaces
*/
///@{
FacsimileInterface *GetFacsimileInterface() override { return vrv_cast<FacsimileInterface *>(this); }
const FacsimileInterface *GetFacsimileInterface() const override
{
return vrv_cast<const FacsimileInterface *>(this);
}
///@}

/**
* Return true if measured music (otherwise we have fake measures)
*/
Expand Down Expand Up @@ -358,8 +371,8 @@ class Measure : public Object,
* This is the left and right position of the measure.
*/
///@{
int m_xAbs;
int m_xAbs2;
int m_drawingFacsX1;
int m_drawingFacsX2;
///@}

/**
Expand Down
1 change: 0 additions & 1 deletion include/vrv/object.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ class EditorialElement;
class Output;
class Filters;
class Functor;
class FunctorParams;
class Functor;
class ConstFunctor;
class LinkingInterface;
Expand Down
13 changes: 12 additions & 1 deletion include/vrv/pb.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#define __VRV_PB_H__

#include "atts_shared.h"
#include "facsimileinterface.h"
#include "systemelement.h"

namespace vrv {
Expand All @@ -21,7 +22,7 @@ namespace vrv {
* This class represents a MEI pb in score-based MEI.
* In page-based MEI, it remains as is as. Actual pages are represented by Page objects.
*/
class Pb : public SystemElement, public AttNNumberLike {
class Pb : public SystemElement, public FacsimileInterface, public AttNNumberLike {
public:
/**
* @name Constructors, destructors, and other standard methods
Expand All @@ -35,6 +36,16 @@ class Pb : public SystemElement, public AttNNumberLike {
std::string GetClassName() const override { return "Pb"; }
///@}

/**
* @name Getter to interfaces
*/
///@{
FacsimileInterface *GetFacsimileInterface() override { return vrv_cast<FacsimileInterface *>(this); }
const FacsimileInterface *GetFacsimileInterface() const override
{
return vrv_cast<const FacsimileInterface *>(this);
}

//----------//
// Functors //
//----------//
Expand Down
Loading

0 comments on commit 7fc8198

Please sign in to comment.