Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/rism-ch/verovio
Browse files Browse the repository at this point in the history
  • Loading branch information
xhero committed Mar 25, 2014
2 parents 872b011 + 35c784e commit a26e61d
Show file tree
Hide file tree
Showing 13 changed files with 180 additions and 13 deletions.
18 changes: 18 additions & 0 deletions Verovio.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
4D22C42518891FC300D0831F /* pugiconfig.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 4D22C42218891FB900D0831F /* pugiconfig.hpp */; };
4D22C4271889214C00D0831F /* pugixml.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4D22C41F18891D6D00D0831F /* pugixml.cpp */; };
4D7D8A3B1886E35B00D78B62 /* main.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4D7D8A3A1886E35B00D78B62 /* main.cpp */; };
4D97921418E1CFB0000F8D57 /* attributes.h in Headers */ = {isa = PBXBuildFile; fileRef = 4D97921318E1CFB0000F8D57 /* attributes.h */; };
4D97921618E1CFD1000F8D57 /* attributes.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4D97921518E1CFD1000F8D57 /* attributes.cpp */; };
4D97921718E1CFD1000F8D57 /* attributes.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4D97921518E1CFD1000F8D57 /* attributes.cpp */; };
8F086EE2188539540037FD8E /* aligner.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8F086EB6188539540037FD8E /* aligner.cpp */; };
8F086EE3188539540037FD8E /* app.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8F086EB7188539540037FD8E /* app.cpp */; };
8F086EE4188539540037FD8E /* barline.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8F086EB8188539540037FD8E /* barline.cpp */; };
Expand Down Expand Up @@ -162,6 +165,8 @@
4D22C42318891FB900D0831F /* pugixml.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = pugixml.hpp; path = include/vrv/pugixml.hpp; sourceTree = "<group>"; };
4D2E09B118A92371001EEEB8 /* emscripten_main.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = emscripten_main.cpp; path = emscripten/emscripten_main.cpp; sourceTree = SOURCE_ROOT; };
4D7D8A3A1886E35B00D78B62 /* main.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = main.cpp; path = ../tools/main.cpp; sourceTree = "<group>"; };
4D97921318E1CFB0000F8D57 /* attributes.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = attributes.h; path = include/vrv/attributes.h; sourceTree = "<group>"; };
4D97921518E1CFD1000F8D57 /* attributes.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = attributes.cpp; path = src/attributes.cpp; sourceTree = "<group>"; };
8F086EA9188534680037FD8E /* Verovio */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = Verovio; sourceTree = BUILT_PRODUCTS_DIR; };
8F086EB6188539540037FD8E /* aligner.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = aligner.cpp; path = src/aligner.cpp; sourceTree = "<group>"; };
8F086EB7188539540037FD8E /* app.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = app.cpp; path = src/app.cpp; sourceTree = "<group>"; };
Expand Down Expand Up @@ -286,6 +291,15 @@
path = tinyxml;
sourceTree = "<group>";
};
4D97921218E1CF8D000F8D57 /* attributes */ = {
isa = PBXGroup;
children = (
4D97921518E1CFD1000F8D57 /* attributes.cpp */,
4D97921318E1CFB0000F8D57 /* attributes.h */,
);
name = attributes;
sourceTree = "<group>";
};
8F086E9E188534680037FD8E = {
isa = PBXGroup;
children = (
Expand All @@ -308,6 +322,7 @@
8F086F351885397A0037FD8E /* source */ = {
isa = PBXGroup;
children = (
4D97921218E1CF8D000F8D57 /* attributes */,
8F086F36188539B10037FD8E /* dc */,
8F086F37188539C50037FD8E /* io */,
8F086F38188539F00037FD8E /* containers */,
Expand Down Expand Up @@ -485,6 +500,7 @@
4D22C41C18890E9900D0831F /* mrest.h in Headers */,
4D22C42418891FC000D0831F /* pugixml.hpp in Headers */,
4D22C42518891FC300D0831F /* pugiconfig.hpp in Headers */,
4D97921418E1CFB0000F8D57 /* attributes.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -602,6 +618,7 @@
4D7D8A3B1886E35B00D78B62 /* main.cpp in Sources */,
4D22C41918890E6100D0831F /* mrest.cpp in Sources */,
4D22C42018891D6D00D0831F /* pugixml.cpp in Sources */,
4D97921618E1CFD1000F8D57 /* attributes.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -654,6 +671,7 @@
8F3DD32218854AFB0051330C /* svgdevicecontext.cpp in Sources */,
4D22C41A18890E6100D0831F /* mrest.cpp in Sources */,
4D22C4271889214C00D0831F /* pugixml.cpp in Sources */,
4D97921718E1CFD1000F8D57 /* attributes.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down
1 change: 1 addition & 0 deletions emscripten/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ python $EMCC --closure 1 -O2 \
$VEROVIO_ROOT/src/vrv.cpp \
$VEROVIO_ROOT/src/aligner.cpp \
$VEROVIO_ROOT/src/app.cpp \
$VEROVIO_ROOT/src/attributes.cpp \
$VEROVIO_ROOT/src/barline.cpp \
$VEROVIO_ROOT/src/measure.cpp \
$VEROVIO_ROOT/src/bboxdevicecontext.cpp \
Expand Down
Binary file modified images/page.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
62 changes: 62 additions & 0 deletions include/vrv/attributes.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/////////////////////////////////////////////////////////////////////////////
// Name: attributes.h
// Author: Laurent Pugin
// Created: 2014
// Copyright (c) Authors and others. All rights reserved.
/////////////////////////////////////////////////////////////////////////////


#ifndef __VRV_ATTRIBUTES_H__
#define __VRV_ATTRIBUTES_H__

#include <string>

namespace vrv {

//----------------------------------------------------------------------------
// Common
//----------------------------------------------------------------------------

/**
* This class is an interface for elements with the MEI att.common.
*/
class Common
{
public:
// constructors and destructors
Common();
virtual ~Common();

/** reset the attribute values */
void ClearAttCommon();

/**
* @name Setter and getter for the label
* This can be different from the index position in the parent measure.
*/
///@{
std::string GetLabel() const { return m_label; };
void SetLabel( std::string label ) { m_label = label; };
///@}

/**
* @name Setter and getter for the n .
* This can be different from the index position in the parent measure.
*/
///@{
int GetN() const { return m_n; };
void SetN( int n ) { m_n = n; };
///@}


protected:
/** Provides a label for the element */
std::string m_label;
/** Indicates a name or number */
int m_n;
};


} // namespace vrv

#endif
16 changes: 15 additions & 1 deletion include/vrv/iomei.h
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,14 @@ class MeiOutput: public FileOutputStream
* Write a sameAs attribute
* The method has to be called by classed that support it (e.g., LayerElement)
*/
void WriteSameAsAttr( pugi::xml_node meiElement, Object *element );
void WriteSameAsAttr( pugi::xml_node element, Object *object );

/**
* @name Read attribute classes
*/
///@{
void WriteAttCommon( pugi::xml_node element, Object *object );
///@}

/** @name Methods for converting members into MEI attributes. */
///@{
Expand Down Expand Up @@ -236,6 +243,13 @@ class MeiInput: public FileInputStream
LayerElement *ReadMeiApp( pugi::xml_node app );
bool ReadMeiRdg( pugi::xml_node rdg );

/**
* @name Read attribute classes
*/
///@{
void ReadAttCommon( pugi::xml_node element, Object *object );
///@}

/**
* Read a sameAs attribute
* The method has to be called by classed that support it (e.g., LayerElement)
Expand Down
3 changes: 2 additions & 1 deletion include/vrv/measure.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include "object.h"

#include "aligner.h"
#include "attributes.h"
#include "barline.h"

namespace vrv {
Expand All @@ -28,7 +29,7 @@ class Staff;
* It contains Layer objects.
* For internally simplication of processing, unmeasure music is contained in one single measure object
*/
class Measure: public DocObject
class Measure: public Common, public DocObject
{

public:
Expand Down
2 changes: 1 addition & 1 deletion include/vrv/view.h
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ class View
*/
///@{
bool GetTupletCoordinates(Tuplet* tuplet, Layer *layer, MusPoint* start, MusPoint* end, MusPoint *center);
std::string IntToObliqueFigures(unsigned int number);
std::string IntToObliqueFigures(unsigned short number);
bool OneBeamInTuplet(Tuplet* tuplet);
///@}

Expand Down
35 changes: 35 additions & 0 deletions src/attributes.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/////////////////////////////////////////////////////////////////////////////
// Name: attributes.cpp
// Author: Laurent Pugin
// Created: 2014
// Copyright (c) Authors and others. All rights reserved.
/////////////////////////////////////////////////////////////////////////////


#include "attributes.h"

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

#include "vrvdef.h"

namespace vrv {

//----------------------------------------------------------------------------
// Common
//----------------------------------------------------------------------------

Common::Common()
{
this->ClearAttCommon();
}

Common::~Common()
{
}

void Common::ClearAttCommon()
{
m_n = VRV_UNSET;
}

} // namespace vrv
36 changes: 32 additions & 4 deletions src/iomei.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

#include "vrv.h"
#include "app.h"
#include "attributes.h"
#include "barline.h"
#include "beam.h"
#include "clef.h"
Expand Down Expand Up @@ -225,7 +226,8 @@ bool MeiOutput::WriteMeasure( Measure *measure )

m_measure = m_system.append_child("measure");
m_measure.append_attribute( "xml:id" ) = UuidToMeiStr( measure ).c_str();
m_measure.append_attribute( "n" ) = StringFormat( "%d", measure->m_logMeasureNb ).c_str();
//m_measure.append_attribute( "n" ) = StringFormat( "%d", measure->m_logMeasureNb ).c_str();
WriteAttCommon( m_measure, measure );

return true;
}
Expand Down Expand Up @@ -493,13 +495,25 @@ bool MeiOutput::WriteLayerRdg( LayerRdg *rdg )
}


void MeiOutput::WriteSameAsAttr( pugi::xml_node meiElement, Object *element )
void MeiOutput::WriteSameAsAttr( pugi::xml_node element, Object *object )
{
if ( !element->m_sameAs.empty() ) {
meiElement.append_attribute( "sameas" ) = element->m_sameAs.c_str();
if ( !object->m_sameAs.empty() ) {
element.append_attribute( "sameas" ) = object->m_sameAs.c_str();
}
}

void MeiOutput::WriteAttCommon( pugi::xml_node element, Object *object )
{
Common *common = dynamic_cast<Common*>( object );
assert( common );
if ( !common->GetLabel().empty() ) {
element.append_attribute( "label" ) = common->GetLabel().c_str();
}
if ( common->GetN() != VRV_UNSET ) {
element.append_attribute( "n" ) = StringFormat("%d", common->GetN()).c_str();;
}
}

std::string MeiOutput::BoolToStr(bool value)
{
if (value) return "true";
Expand Down Expand Up @@ -1076,6 +1090,7 @@ bool MeiInput::ReadMeiMeasure( pugi::xml_node measure )
assert( m_measure );
assert( !m_staff );

ReadAttCommon( measure, m_measure );
if ( measure.attribute( "right" ) ) {
m_measure->GetRightBarline()->m_barlineType = StrToBarlineType( measure.attribute( "right" ).value() );
}
Expand Down Expand Up @@ -1554,6 +1569,19 @@ void MeiInput::ReadSameAsAttr( pugi::xml_node element, Object *object )
object->m_sameAs = element.attribute( "sameas" ).value();
}


void MeiInput::ReadAttCommon( pugi::xml_node element, Object *object )
{
Common *common = dynamic_cast<Common*>( object );
assert( common );
if ( element.attribute( "label" ) ) {
common->SetLabel( element.attribute( "label" ).value() );
}
if ( element.attribute( "n" ) ) {
common->SetN( atoi( element.attribute( "n" ).value() ) );
}
}


void MeiInput::AddLayerElement( LayerElement *element )
{
Expand Down
3 changes: 2 additions & 1 deletion src/measure.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ namespace vrv {
//----------------------------------------------------------------------------

Measure::Measure( bool measureMusic, int logMeasureNb ):
DocObject("measure-")
Common(), DocObject("measure-")
{
Clear( );
m_measuredMusic = measureMusic;
Expand All @@ -46,6 +46,7 @@ Measure::~Measure()

void Measure::Clear()
{
ClearAttCommon();
ClearChildren();
m_parent = NULL;
m_logMeasureNb = -1;
Expand Down
6 changes: 6 additions & 0 deletions src/view_page.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,12 @@ void View::DrawSystem( DeviceContext *dc, System *system )
if ( measure ) {
// NULL for the Barline parameters indicates that we are drawing the scoreDef
DrawScoreDef( dc, &m_drawingScoreDef, measure, system->GetDrawingX(), NULL );
// Draw mesure number if > 1
// This needs to be improved because we are now using (tuplet) oblique figures.
// We should also have a better way to specify if the number has to be displayed or not
if ( (measure->GetN() != VRV_UNSET) && (measure->GetN() != 1) ) {
dc->DrawText( IntToObliqueFigures( measure->GetN() ) , ToDeviceContextX(system->GetDrawingX()), ToDeviceContextY(system->GetDrawingY() - m_doc->m_drawingStaffSize[0] * 2 / 3) );
}
}

dc->EndGraphic(system, this );
Expand Down
10 changes: 5 additions & 5 deletions src/view_tuplet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,19 +35,19 @@ namespace vrv {
#define TUPLET_OFFSET 20
#define OBLIQUE_OFFSET 0x52 //move to oblique figures

std::string View::IntToObliqueFigures(unsigned int number) {
char buf[16];
std::string View::IntToObliqueFigures(unsigned short number) {
char buf[6];
unsigned int len;

memset(buf, 0x00, sizeof(buf));

// We do not convert more that FF values
if (number > 0xFF) number = 0xFF;
if (number > 0xFFFF) number = 0xFFFF;

sprintf(buf, "%i", number);

len = strlen(buf);
assert((sizeof(buf) - 1) > len ); // String conversion overflow
assert((sizeof(buf)) > len ); // String conversion overflow

for (unsigned int i = 0; i < strlen(buf); i++) {
buf[i] += OBLIQUE_OFFSET;
Expand Down Expand Up @@ -282,7 +282,7 @@ void View::DrawTuplet( DeviceContext *dc, Tuplet *tuplet, Layer *layer, Staff *s

int txt_lenght, txt_height;

std::string notes = IntToObliqueFigures((unsigned int)tuplet->GetNum());
std::string notes = IntToObliqueFigures((short int)tuplet->GetNum());

dc->GetTextExtent(notes, &txt_lenght, &txt_height);

Expand Down
1 change: 1 addition & 0 deletions tools/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ add_executable (verovio
main.cpp
../src/aligner.cpp
../src/app.cpp
../src/attributes.cpp
../src/barline.cpp
../src/bboxdevicecontext.cpp
../src/beam.cpp
Expand Down

0 comments on commit a26e61d

Please sign in to comment.