Skip to content

Commit

Permalink
Merge commit '0f4c9b7645036563dcdebb0f0a28b79e035a4954'
Browse files Browse the repository at this point in the history
Conflicts:
	src/view_element.cpp
  • Loading branch information
lpugin committed Jan 9, 2015
2 parents 6af9898 + 0f4c9b7 commit 1cff063
Show file tree
Hide file tree
Showing 25 changed files with 574 additions and 653 deletions.
4 changes: 4 additions & 0 deletions include/vrv/att.h
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,10 @@ class AttComparison

virtual bool operator() (Object *object);

const std::type_info *GetType() { return m_elementType; };

bool MatchesType( Object *object );

protected:
const std::type_info *m_elementType;
};
Expand Down
6 changes: 3 additions & 3 deletions include/vrv/att_comparison.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ class AttCommonNComparison: public AttComparison
m_n = n;
};

void SetN( int n ) { m_n = n; }

virtual bool operator() (Object *object)
{
if (typeid(*object) != *m_elementType) {
return false;
}
if (!MatchesType(object)) return false;
AttCommon *element = dynamic_cast<AttCommon*>(object);
if (!element) {
return false;
Expand Down
4 changes: 3 additions & 1 deletion include/vrv/doc.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,12 @@ class Doc: public Object

/**
* @name Getters for the object margins (left and right)
* The margin are given in x / MARGIN_DENOMINATOR * UNIT
* With MARGIN_DENOMINATOR == 10, a margin of 25 is 2.5 UNIT
* These should eventually be set at parameters.
*/
///@{
short GetLeftMargin( const Object *object );
short GetLeftMargin( const std::type_info *elementType );
short GetRightMargin( const std::type_info *elementType );
///@}

Expand Down
19 changes: 13 additions & 6 deletions include/vrv/iomei.h
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,8 @@ class MeiInput: public FileInputStream
* For each container (page, system, measure, staff and layer) there is one method for
* reading the element and one method for reading it children. The method for reading
* the children can also be called when reading EditorialElement objects (<lem> or <rdg>
* for example.
* for example. The filter object is optionnal and can be set for filtering the allowed
* children (see MeiInput::IsAllowed)
*/
///@{
bool ReadMeiPage( pugi::xml_node page );
Expand All @@ -239,7 +240,7 @@ class MeiInput: public FileInputStream
bool ReadMeiStaff( Object *parent, pugi::xml_node staff );
bool ReadMeiStaffChildren( Object *parent, pugi::xml_node parentNode );
bool ReadMeiLayer( Object *parent, pugi::xml_node layer );
bool ReadMeiLayerChildren( Object *parent, pugi::xml_node parentNode );
bool ReadMeiLayerChildren( Object *parent, pugi::xml_node parentNode, Object *filter = NULL );
///@}

/**
Expand All @@ -258,16 +259,19 @@ class MeiInput: public FileInputStream
bool ReadMeiMultiRest( Object *parent, pugi::xml_node multiRest );
bool ReadMeiNote( Object *parent, pugi::xml_node note );
bool ReadMeiRest( Object *parent, pugi::xml_node rest );
bool ReadMeiSyl( Object *parent, pugi::xml_node syl );
bool ReadMeiTuplet( Object *parent, pugi::xml_node tuplet );
bool ReadMeiVerse( Object *parent, pugi::xml_node verse );
///@}

/**
* @name Methods for reading critical apparatus.
* Only one child of <app> is loaded
* The filter is propagated (if any)
*/
///@{
bool ReadMeiApp( Object *parent, pugi::xml_node app, EditorialLevel level );
bool ReadMeiAppChildren( App *app, pugi::xml_node lemOrRdg, EditorialLevel level );
bool ReadMeiApp( Object *parent, pugi::xml_node app, EditorialLevel level, Object *filter = NULL );
bool ReadMeiAppChildren( App *app, pugi::xml_node lemOrRdg, EditorialLevel level, Object *filter = NULL );
///@}

/**
Expand All @@ -286,8 +290,6 @@ class MeiInput: public FileInputStream
*/
///@{
bool ReadAccidAsAttr( Note *note, pugi::xml_node verse );
bool ReadVerse( Note *note, pugi::xml_node verse );
bool ReadSyl( Verse *verse, pugi::xml_node syl );
bool ReadTupletSpanAsTuplet( Measure *measure, pugi::xml_node tupletSpan );
bool ReadSlurAsSlurAttr( Measure *measure, pugi::xml_node slur );
///@}
Expand Down Expand Up @@ -366,6 +368,11 @@ class MeiInput: public FileInputStream
* This should be moved to the Object::PrepareDrawing functor
*/
std::vector<Note*> m_openTies;

/**
* Check if an element is allowed within a given parent
*/
bool IsAllowed( std::string element, Object *filterParent );
};

} // namespace vrv
Expand Down
2 changes: 2 additions & 0 deletions include/vrv/layerelement.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ class LayerElement: public DocObject
bool IsRest();
bool IsTie();
bool IsTuplet();
bool IsSyl();
bool IsVerse();
bool IsGraceNote();
///@}

Expand Down
5 changes: 3 additions & 2 deletions include/vrv/note.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,10 @@ class Note: public LayerElement, public DurationInterface, public PitchInterface
virtual bool operator==(Object& other);

/**
* Add verse to a note.
* Add an element (a verse or an accid) to a note.
* Only Verse and Accid elements will be actually added to the note.
*/
void AddVerse(Verse *child);
void AddElement(LayerElement *element);

/**
* @name Setters and getters for tie attributes
Expand Down
17 changes: 10 additions & 7 deletions include/vrv/object.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ typedef std::list<Object*> ListOfObjects;

typedef std::vector<void*> ArrayPtrVoid;

typedef std::map<const std::type_info*, int> MapOfTypeN;
typedef std::vector<AttComparison*> ArrayOfAttComparisons;

/**
* Generic int map recursive sturcutre for storing hierachy of values
Expand Down Expand Up @@ -288,12 +288,15 @@ class Object
* Main method that processes functors.
* For each object, it will call the functor.
* Depending on the code returned by the functor, it will also process it for all children.
* The last parameter MapOfTypeN makes is possible to process object of a type given a key in the map
* with value @n. They must be of type AttCommon. This is very powerfull for operation on parts, e.g.,
* for extracting one single staff, or layer.
* Deepness allow to specify how many child levels should be processed. -1 means no limit; EditorialLevel objects do not count.
* The ArrayOfAttComparisons filter parameter makes is possible to process only objects of a
* type that match the attribute value given in the AttComparison object.
* This is a generic way for parsing the tree, e.g., for extracting one single staff, or layer.
* Deepness allow to specify how many child levels should be processed -10000 means no
* limit (EditorialElement objects do not count).
*/
virtual void Process( Functor *functor, ArrayPtrVoid params, Functor *endFunctor = NULL, MapOfTypeN *map = NULL, int deepness = -1 );
virtual void Process( Functor *functor, ArrayPtrVoid params, Functor *endFunctor = NULL,
ArrayOfAttComparisons * filters = NULL, int deepness = -10000 );


//----------//
// Functors //
Expand Down Expand Up @@ -471,7 +474,7 @@ class Object

/**
* Functor for setting wordpos and connector ends
* The functor is process by staff/layer/verse using a MapOfTypeN.
* The functor is process by staff/layer/verse using an ArrayOfAttComparisons filter.
* not param
*/
virtual int PrepareLyrics( ArrayPtrVoid params ) { return FUNCTOR_CONTINUE; };
Expand Down
4 changes: 2 additions & 2 deletions include/vrv/syl.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@
#define __VRV_SYL_H__

#include "atts_shared.h"
#include "object.h"
#include "layerelement.h"

namespace vrv {

//----------------------------------------------------------------------------
// Syl
//----------------------------------------------------------------------------

class Syl: public DocObject,
class Syl: public LayerElement,
public AttSylLog
{
public:
Expand Down
11 changes: 6 additions & 5 deletions include/vrv/verse.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#define __VRV_VERSE_H__

#include "atts_shared.h"
#include "object.h"
#include "layerelement.h"

namespace vrv {

Expand All @@ -20,7 +20,7 @@ class Syl;
// Verse
//----------------------------------------------------------------------------

class Verse: public DocObject,
class Verse: public LayerElement,
public AttCommon
{
public:
Expand All @@ -36,9 +36,10 @@ class Verse: public DocObject,
///@}

/**
* Add syl to a verse.
* Add an element (a syl) to a verse.
* Only Syl elements will be actually added to the verse.
*/
void AddSyl(Syl *syl);
void AddElement(LayerElement *element);

//----------//
// Functors //
Expand All @@ -58,7 +59,7 @@ class Verse: public DocObject,

/**
* Functor for setting wordpos and connector ends
* The functor is process by staff/layer/verse using a MapOfTypeN
* The functor is process by staff/layer/verse using an ArrayOfAttComparisons filter
* See PrepareDarwing
*/
virtual int PrepareLyrics( ArrayPtrVoid params );
Expand Down
102 changes: 67 additions & 35 deletions include/vrv/view.h
Original file line number Diff line number Diff line change
Expand Up @@ -144,18 +144,29 @@ class View
///@}

/**
* @name Methods for drawing App and EditorialElement
* @name Methods for drawing children
* Defined in view_page.cpp
* For each method, we have a parent Object, that can be either the same as the next paremeter,
* or an intermediate node in the hierarchy. For example, we can draw the system children from the
* system itself (in that case, parent will be the same as system) or from an editorial element
* occuring in between.
*/
///@{
/** System level **/
void DrawEditorialElement( DeviceContext *dc, EditorialElement *element, System *system );
/** Measure level **/
void DrawEditorialElement( DeviceContext *dc, EditorialElement *element, Measure *measure, System *system );
/** Staff level **/
void DrawEditorialElement( DeviceContext *dc, EditorialElement *element, Staff *staff, Measure *measure );
/** Layer level **/
void DrawEditorialElement( DeviceContext *dc, EditorialElement *element, Layer *layer, Staff *staff, Measure *measure );
void DrawSystemChildren( DeviceContext *dc, Object *parent, System *system );
void DrawMeasureChildren( DeviceContext *dc, Object *parent, Measure *measure, System *system );
void DrawStaffChildren( DeviceContext *dc, Object *parent, Staff *staff, Measure *measure );
void DrawLayerChildren( DeviceContext *dc, Object *parent, Layer *layer, Staff *staff, Measure *measure );
///@}

/**
* @name Methods for drawing EditorialElement object at different levels
* Defined in view_page.cpp
*/
///@{
void DrawSystemEditorialElement( DeviceContext *dc, EditorialElement *element, System *system );
void DrawMeasureEditorialElement( DeviceContext *dc, EditorialElement *element, Measure *measure, System *system );
void DrawStaffEditorialElement( DeviceContext *dc, EditorialElement *element, Staff *staff, Measure *measure );
void DrawLayerEditorialElement( DeviceContext *dc, EditorialElement *element, Layer *layer, Staff *staff, Measure *measure );
///@}

/**
Expand All @@ -169,65 +180,86 @@ class View
///@}

/**
* @name Methods for drawing LayerElement containing other elements.
* This is the case of Beam, Tuplet, Chords, etc.
* @name Top level method for drawing LayerElement.
* This can be called recursively for elements containing other elements.
* This the case for Note, Beam, Tuplet, Chords, etc.
* Defined in view_element.cpp
*/
///@{
void DrawElement( DeviceContext *dc, LayerElement *element, Layer *layer, Staff *staff, Measure *measure );
void DrawBeamElement(DeviceContext *dc, LayerElement *element, Layer *layer, Staff *staff, Measure *measure );
void DrawTupletElement( DeviceContext *dc, LayerElement *element, Layer *layer, Staff *staff, Measure *measure );
///@}

/**
* @name Methods for drawing LayerElement child classes.
* They are base drawing methods that are called directly from DrawElement
* Because some elements draw their children recursively (e.g., Note) they must all
* have the same parameters
* Defined in view_element.cpp
*/
///@{
void DrawAccid( DeviceContext *dc, LayerElement *element, Layer *layer, Staff *staff, Measure *measure );
void DrawBeam(DeviceContext *dc, LayerElement *element, Layer *layer, Staff *staff, Measure *measure );
void DrawBarline( DeviceContext *dc, LayerElement *element, Layer *layer, Staff *staff, Measure *measure );
void DrawClef( DeviceContext *dc, LayerElement *element, Layer *layer, Staff *staff, Measure *measure );
void DrawCustos( DeviceContext *dc, LayerElement *element, Layer *layer, Staff *staff, Measure *measure );
void DrawDot( DeviceContext *dc, LayerElement *element, Layer *layer, Staff *staff, Measure *measure );
void DrawDurationElement( DeviceContext *dc, LayerElement *element, Layer *layer, Staff *staff, Measure *measure );
void DrawKeySig( DeviceContext *dc, LayerElement *element, Layer *layer, Staff *staff, Measure *measure );
void DrawMensur( DeviceContext *dc, LayerElement *element, Layer *layer, Staff *staff, Measure *measure );
void DrawMeterSig( DeviceContext *dc, LayerElement *element, Layer *layer, Staff *staff, Measure *measure );
void DrawMRest( DeviceContext *dc, LayerElement *element, Layer *layer, Staff *staff, Measure *measure );
void DrawMultiRest( DeviceContext *dc, LayerElement *element, Layer *layer, Staff *staff, Measure *measure );
void DrawNote( DeviceContext *dc, LayerElement *element, Layer *layer, Staff *staff, Measure *measure );
void DrawRest( DeviceContext *dc, LayerElement *element, Layer *layer, Staff *staff, Measure *measure );
void DrawSyl( DeviceContext *dc, LayerElement *element, Layer *layer, Staff *staff, Measure *measure );
void DrawTie( DeviceContext *dc, LayerElement *element, Layer *layer, Staff *staff, Measure *measure );
void DrawTuplet( DeviceContext *dc, LayerElement *element, Layer *layer, Staff *staff, Measure *measure );
void DrawVerse( DeviceContext *dc, LayerElement *element, Layer *layer, Staff *staff, Measure *measure );
///@}

/**
* @name Methods for drawing parts of LayerElement child classes.
* They are sub-drawing methods that are called from the base drawing methods above.
* The parameter set can be different from a base drawing method since no recursive call is expected
* Defined in view_element.cpp
*/
///@{
void DrawAcciaccaturaSlash(DeviceContext *dc, LayerElement *element);
void DrawAccid( DeviceContext *dc, LayerElement *element, Layer *layer, Staff *staff, LayerElement *parent = NULL );
void DrawBarline( DeviceContext *dc, LayerElement *element, Layer *layer, Staff *staff );
void DrawBreveRest ( DeviceContext *dc, int x, int y, Staff *staff);
void DrawClef( DeviceContext *dc, LayerElement *element, Layer *layer, Staff *staff );
void DrawCustos( DeviceContext *dc, LayerElement *element, Layer *layer, Staff *staff );
void DrawDot( DeviceContext *dc, LayerElement *element, Layer *layer, Staff *staff );
void DrawBreveRest ( DeviceContext *dc, int x, int y, Staff *staff );
void DrawDots ( DeviceContext *dc, int x, int y, unsigned char dots, Staff *staff );
void DrawDurationElement( DeviceContext *dc, LayerElement *element, Layer *layer, Staff *staff );
void DrawFermata(DeviceContext *dc, LayerElement *element, Staff *staff);
void DrawKeySig( DeviceContext *dc, LayerElement *element, Layer *layer, Staff *staff );
void DrawLigature( DeviceContext *dc, int y, LayerElement *element, Layer *layer, Staff *staff );
void DrawLedgerLines( DeviceContext *dc, int y_n, int y_p, int xn, unsigned int smaller, int staffSize);
void DrawLongRest ( DeviceContext *dc, int x, int y, Staff *staff);
void DrawMensur( DeviceContext *dc, LayerElement *element, Layer *layer, Staff *staff );
void DrawMensurCircle( DeviceContext *dc, int x, int yy, Staff *staff );
void DrawMensurDot( DeviceContext *dc, int x, int yy, Staff *staff );
void DrawMensurFigures( DeviceContext *dc, int x, int y, int num, int numBase, Staff *staff);
void DrawMensurFigures( DeviceContext *dc, int x, int y, int num, int numBase, Staff *staff);
void DrawMensurHalfCircle( DeviceContext *dc, int x, int yy, Staff *staff );
void DrawMensurReversedHalfCircle( DeviceContext *dc, int x, int yy, Staff *staff );
void DrawMensurReversedHalfCircle( DeviceContext *dc, int x, int yy, Staff *staff );
void DrawMensurSlash( DeviceContext *dc, int x, int yy, Staff *staff );
void DrawMeterSig( DeviceContext *dc, LayerElement *element, Layer *layer, Staff *staff );
void DrawMRest( DeviceContext *dc, LayerElement *element, Layer *layer, Staff *staff, Measure *measure );
void DrawMultiRest( DeviceContext *dc, LayerElement *element, Layer *layer, Staff *staff, Measure *measure );
void DrawNote( DeviceContext *dc, LayerElement *element, Layer *layer, Staff *staff );
void DrawQuarterRest ( DeviceContext *dc, int x, int y, int valeur, unsigned char dots, unsigned int smaller, Staff *staff);
void DrawRest( DeviceContext *dc, LayerElement *element, Layer *layer, Staff *staff );
void DrawSyl( DeviceContext *dc, Syl *syl, int verseNb, LayerElement *element, Layer *layer, Staff *staff);
void DrawTie( DeviceContext *dc, LayerElement *element, Layer *layer, Staff *staff, Measure *measure );
void DrawTrill(DeviceContext *dc, LayerElement *element, Staff *staff);
void DrawTuplet( DeviceContext *dc, Tuplet *tuplet, Layer *layer, Staff *staff);
void DrawVerse( DeviceContext *dc, Verse *verse, LayerElement *element, Layer *layer, Staff *staff);
void DrawTrill(DeviceContext *dc, LayerElement *element, Staff *staff );
void DrawWholeRest ( DeviceContext *dc, int x, int y, int valeur, unsigned char dots, unsigned int smaller, Staff *staff);
void CalculateLigaturePosX ( LayerElement *element, Layer *layer, Staff *staff);
///@}

/**
* @name Method for drawing Beam.
* Called from the the layer postponed drawing list.
* Wolfgang legacy code to be redesigned.
* Defined in view_beam.cpp
*/
///@{
void DrawBeam( DeviceContext *dc, Layer *layer, Beam *beam, Staff *staff );
void DrawBeamPostponed( DeviceContext *dc, Layer *layer, Beam *beam, Staff *staff );
///@}

/**
* @name Method for drawing Beam.
* Called from the the layer postponed drawing list.
* Defined in view_tuplet.cpp
*/
///@{
void DrawTupletPostponed( DeviceContext *dc, Tuplet *tuplet, Layer *layer, Staff *staff );

/**
* @name Low level drawing methods
Expand Down
Loading

0 comments on commit 1cff063

Please sign in to comment.