diff --git a/include/vrv/att.h b/include/vrv/att.h index 5e9c8fb17ca..716e8e26d0d 100644 --- a/include/vrv/att.h +++ b/include/vrv/att.h @@ -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; }; diff --git a/include/vrv/att_comparison.h b/include/vrv/att_comparison.h index 369a71cc183..d7c681da207 100644 --- a/include/vrv/att_comparison.h +++ b/include/vrv/att_comparison.h @@ -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(object); if (!element) { return false; diff --git a/include/vrv/doc.h b/include/vrv/doc.h index bf4df7e162e..464edf986e6 100644 --- a/include/vrv/doc.h +++ b/include/vrv/doc.h @@ -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 ); ///@} diff --git a/include/vrv/iomei.h b/include/vrv/iomei.h index 48a8fa5e167..611562419bf 100644 --- a/include/vrv/iomei.h +++ b/include/vrv/iomei.h @@ -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 ( or - * 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 ); @@ -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 ); ///@} /** @@ -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 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 ); ///@} /** @@ -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 ); ///@} @@ -366,6 +368,11 @@ class MeiInput: public FileInputStream * This should be moved to the Object::PrepareDrawing functor */ std::vector m_openTies; + + /** + * Check if an element is allowed within a given parent + */ + bool IsAllowed( std::string element, Object *filterParent ); }; } // namespace vrv diff --git a/include/vrv/layerelement.h b/include/vrv/layerelement.h index 4e04bec3934..3ff5151bb87 100644 --- a/include/vrv/layerelement.h +++ b/include/vrv/layerelement.h @@ -96,6 +96,8 @@ class LayerElement: public DocObject bool IsRest(); bool IsTie(); bool IsTuplet(); + bool IsSyl(); + bool IsVerse(); bool IsGraceNote(); ///@} diff --git a/include/vrv/note.h b/include/vrv/note.h index b0bb437e1a5..b0f501065a7 100755 --- a/include/vrv/note.h +++ b/include/vrv/note.h @@ -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 diff --git a/include/vrv/object.h b/include/vrv/object.h index 23587361fd9..632ca9bf0cc 100644 --- a/include/vrv/object.h +++ b/include/vrv/object.h @@ -33,7 +33,7 @@ typedef std::list ListOfObjects; typedef std::vector ArrayPtrVoid; -typedef std::map MapOfTypeN; +typedef std::vector ArrayOfAttComparisons; /** * Generic int map recursive sturcutre for storing hierachy of values @@ -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 // @@ -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; }; diff --git a/include/vrv/syl.h b/include/vrv/syl.h index 5ce736765cb..f13b6fc6e2e 100644 --- a/include/vrv/syl.h +++ b/include/vrv/syl.h @@ -10,7 +10,7 @@ #define __VRV_SYL_H__ #include "atts_shared.h" -#include "object.h" +#include "layerelement.h" namespace vrv { @@ -18,7 +18,7 @@ namespace vrv { // Syl //---------------------------------------------------------------------------- -class Syl: public DocObject, +class Syl: public LayerElement, public AttSylLog { public: diff --git a/include/vrv/verse.h b/include/vrv/verse.h index c86f7b1dfba..d4a37397885 100644 --- a/include/vrv/verse.h +++ b/include/vrv/verse.h @@ -10,7 +10,7 @@ #define __VRV_VERSE_H__ #include "atts_shared.h" -#include "object.h" +#include "layerelement.h" namespace vrv { @@ -20,7 +20,7 @@ class Syl; // Verse //---------------------------------------------------------------------------- -class Verse: public DocObject, +class Verse: public LayerElement, public AttCommon { public: @@ -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 // @@ -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 ); diff --git a/include/vrv/view.h b/include/vrv/view.h index a5171bce1b7..16d5ca1fbb4 100644 --- a/include/vrv/view.h +++ b/include/vrv/view.h @@ -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 ); ///@} /** @@ -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 diff --git a/include/vrv/vrvdef.h b/include/vrv/vrvdef.h index d32b6ea62c2..c5b4292d6f9 100644 --- a/include/vrv/vrvdef.h +++ b/include/vrv/vrvdef.h @@ -23,7 +23,7 @@ namespace vrv { #define VERSION_MAJOR 0 #define VERSION_MINOR 9 -#define VERSION_REVISION 4 +#define VERSION_REVISION 5 #define is_in(x,a,b) (((x) >= std::min((a),(b))) && ((x) <= std::max((a),(b)))) @@ -84,6 +84,8 @@ enum EditorMode { #define MIN_TIE_HEIGHT 12 #define MIN_TIE_THICKNESS 6 +#define MARGIN_DENOMINATOR 10 + //---------------------------------------------------------------------------- // Default scaling (%) and spacing (units) values //---------------------------------------------------------------------------- @@ -100,6 +102,24 @@ enum EditorMode { #define MIN_SPACING_SYSTEM 0 #define MAX_SPACING_SYSTEM 12 +//---------------------------------------------------------------------------- +// Maximum number of levels between parent and children for optimizing search +//---------------------------------------------------------------------------- + +/** All values set to -1 (no limit) since this has not major incidence **/ + +/** Define the maximum levels between a beam and its notes **/ +#define MAX_BEAM_DEPTH -1 + +/** Define the maximum levels between a tuplet and its notes **/ +#define MAX_TUPLET_DEPTH -1 + +/** Define the maximum levels of staffGrp within a scoreDef **/ +#define MAX_STAFFGRP_DEPTH -1 + +/** Define the maximum levels between a note and its syls **/ +#define MAX_NOTE_DEPTH -1 + //---------------------------------------------------------------------------- // Durations //---------------------------------------------------------------------------- diff --git a/src/att.cpp b/src/att.cpp index 651442d2c35..8721884034d 100644 --- a/src/att.cpp +++ b/src/att.cpp @@ -722,7 +722,15 @@ data_WORDPOS Att::StrToWordPos(std::string value) // AttComparison //---------------------------------------------------------------------------- -bool AttComparison::operator() (Object *object) +bool AttComparison::operator()(Object *object) +{ + if (typeid(*object) == *m_elementType) { + return true; + } + return false; +} + +bool AttComparison::MatchesType(Object *object) { if (typeid(*object) == *m_elementType) { return true; diff --git a/src/doc.cpp b/src/doc.cpp index 87e1bef13ae..a011bae89fd 100644 --- a/src/doc.cpp +++ b/src/doc.cpp @@ -15,6 +15,7 @@ //---------------------------------------------------------------------------- +#include "att_comparison.h" #include "glyph.h" #include "keysig.h" #include "layer.h" @@ -98,24 +99,29 @@ void Doc::PrepareDrawing() this->Process( &prepareDrawing, params ); // The tree is used to process each staff/layer/verse separatly - // For this, we use a MapOfTypeN that looks for each object if it is of the type + // For this, we use a array of AttCommmonNComparison that looks for each object if it is of the type // and with @n specified IntTree_t::iterator staves; IntTree_t::iterator layers; IntTree_t::iterator verses; + std::vector filters; for (staves = tree.child.begin(); staves != tree.child.end(); ++staves) { for (layers = staves->second.child.begin(); layers != staves->second.child.end(); ++layers) { for (verses= layers->second.child.begin(); verses != layers->second.child.end(); ++verses) { //std::cout << staves->first << " => " << layers->first << " => " << verses->first << '\n'; - MapOfTypeN map; - map[ &typeid(Staff) ] = staves->first; - map[ &typeid(Layer) ] = layers->first; - map[ &typeid(Verse) ] = verses->first; + filters.clear(); + // Create ad comparison object for each type / @n + AttCommonNComparison matchStaff( &typeid(Staff), staves->first ); + AttCommonNComparison matchLayer( &typeid(Layer), layers->first ); + AttCommonNComparison matchVerse( &typeid(Verse), verses->first ); + filters.push_back( &matchStaff ); + filters.push_back( &matchLayer ); + filters.push_back( &matchVerse ); ArrayPtrVoid paramsLyrics; Functor prepareLyrics( &Object::PrepareLyrics ); - this->Process( &prepareLyrics, paramsLyrics, NULL, &map ); + this->Process( &prepareLyrics, paramsLyrics, NULL, &filters ); } } } @@ -125,18 +131,22 @@ void Doc::PrepareDrawing() StaffN_LayerN_VerseN_t::iterator staves; LayerN_VerserN_t::iterator layers; VerseN_t::iterator verses; + std::vector filters; for (staves = staffLayerVerseTree.begin(); staves != staffLayerVerseTree.end(); ++staves) { for (layers = staves->second.begin(); layers != staves->second.end(); ++layers) { for (verses= layers->second.begin(); verses != layers->second.end(); ++verses) { std::cout << staves->first << " => " << layers->first << " => " << verses->first << '\n'; - MapOfTypeN map; - map[ &typeid(Staff) ] = staves->first; - map[ &typeid(Layer) ] = layers->first; - map[ &typeid(Verse) ] = verses->first; - + filters.clear(); + AttCommonNComparison matchStaff( &typeid(Staff), staves->first ); + AttCommonNComparison matchLayer( &typeid(Layer), layers->first ); + AttCommonNComparison matchVerse( &typeid(Verse), verses->first ); + filters.push_back( &matchStaff ); + filters.push_back( &matchLayer ); + filters.push_back( &matchVerse ); + ArrayPtrVoid paramsLyrics; Functor prepareLyrics( &Object::PrepareLyrics ); - this->Process( &prepareLyrics, paramsLyrics, NULL, &map ); + this->Process( &prepareLyrics, paramsLyrics, NULL, &filters ); } } } @@ -258,21 +268,13 @@ int Doc::GetPageCount( ) return GetChildCount() ; } -/* + short Doc::GetLeftMargin( const std::type_info *elementType ) { - if (&typeid(Note) == elementType) - return 5; - return 0; -} -*/ - -short Doc::GetLeftMargin( const Object *object ) -{ - const std::type_info *elementType = &typeid(*object); - //if (typeid(Note) == *elementType) return 10; + if (typeid(Barline) == *elementType) return 5; else if (typeid(Clef) == *elementType) return -20; + //else if (typeid(Note) == *elementType) return 10; return 0; } diff --git a/src/durationinterface.cpp b/src/durationinterface.cpp index f1a06a57592..6779ef7221d 100644 --- a/src/durationinterface.cpp +++ b/src/durationinterface.cpp @@ -22,11 +22,6 @@ namespace vrv { -/** - * Define the maximum levels between a beam and its notes - */ -#define MAX_BEAM_DEPTH 5 - //---------------------------------------------------------------------------- // DurationInterface diff --git a/src/iomei.cpp b/src/iomei.cpp index fe4eef25fea..fa6f1d3fb9b 100644 --- a/src/iomei.cpp +++ b/src/iomei.cpp @@ -663,6 +663,36 @@ bool MeiInput::ImportString( const std::string mei ) return false; } } + +bool MeiInput::IsAllowed(std::string element, vrv::Object *filterParent) +{ + if (!filterParent) { + return true; + } + + const std::type_info *elementType = &typeid(*filterParent); + if ( element == "app" ) { + return true; + } + else if (*elementType == typeid(Note)) + { + //if ( element == "accid" ) return true; + //else + if ( element == "syl" ) return true; + else if ( element == "verse" ) return true; + else return false; + } + else if (*elementType == typeid(Verse)) + { + if ( element == "syl" ) return true; + else return false; + } + else + { + LogDebug("Unknow filter for '%s'", filterParent->GetClassName().c_str()); + return true; + } +} @@ -1152,55 +1182,69 @@ bool MeiInput::ReadMeiLayer( Object *parent, pugi::xml_node layer ) return ReadMeiLayerChildren( vrvLayer, layer ); } -bool MeiInput::ReadMeiLayerChildren( Object *parent, pugi::xml_node parentNode ) +bool MeiInput::ReadMeiLayerChildren( Object *parent, pugi::xml_node parentNode, Object *filter ) { bool success = true; pugi::xml_node xmlElement; - for( xmlElement = parentNode.first_child( ); xmlElement; xmlElement = xmlElement.next_sibling( ) ){ - if (!success) break; - if ( std::string( xmlElement.name() ) == "accid" ) { + std::string elementName; + for( xmlElement = parentNode.first_child( ); xmlElement; xmlElement = xmlElement.next_sibling( ) ) { + if (!success) { + break; + } + elementName = std::string( xmlElement.name() ); + if ( !IsAllowed( elementName, filter ) ) { + LogDebug("Element <%s> within %s ignored", xmlElement.name(), filter->GetClassName().c_str() ); + continue; + } + else if ( elementName == "accid" ) { success = ReadMeiAccid( parent, xmlElement ); } - else if ( std::string( xmlElement.name() ) == "app" ) { - success = ReadMeiApp( parent, xmlElement, EDITORIAL_LAYER); + else if ( elementName == "app" ) { + success = ReadMeiApp( parent, xmlElement, EDITORIAL_LAYER, filter); } - else if ( std::string( xmlElement.name() ) == "barLine" ) { + else if ( elementName == "barLine" ) { success = ReadMeiBarline( parent, xmlElement ); } - else if ( std::string( xmlElement.name() ) == "beam" ) { + else if ( elementName == "beam" ) { success = ReadMeiBeam( parent, xmlElement); } - else if ( std::string( xmlElement.name() ) == "clef" ) { + else if ( elementName == "clef" ) { success = ReadMeiClef( parent, xmlElement); } - else if ( std::string( xmlElement.name() ) == "custos" ) { + else if ( elementName == "custos" ) { success = ReadMeiCustos( parent, xmlElement ); } - else if ( std::string( xmlElement.name() ) == "dot" ) { + else if ( elementName == "dot" ) { success = ReadMeiDot( parent, xmlElement ); } - else if ( std::string( xmlElement.name() ) == "mensur" ) { + else if ( elementName == "mensur" ) { success = ReadMeiMensur( parent, xmlElement ); } - else if ( std::string( xmlElement.name() ) == "meterSig" ) { + else if ( elementName == "meterSig" ) { success = ReadMeiMeterSig( parent, xmlElement ); } - else if ( std::string( xmlElement.name() ) == "note" ) { + else if ( elementName == "note" ) { success = ReadMeiNote( parent, xmlElement ); } - else if ( std::string( xmlElement.name() ) == "rest" ) { + else if ( elementName == "rest" ) { success = ReadMeiRest( parent, xmlElement ); } - else if ( std::string( xmlElement.name() ) == "mRest" ) { + else if ( elementName == "mRest" ) { success = ReadMeiMRest( parent, xmlElement ); } - else if ( std::string( xmlElement.name() ) == "multiRest" ) { + else if ( elementName == "multiRest" ) { success = ReadMeiMultiRest( parent, xmlElement ); } - else if ( std::string( xmlElement.name() ) == "tuplet" ) { + else if ( elementName == "syl" ) { + success = ReadMeiSyl( parent, xmlElement ); + } + else if ( elementName == "tuplet" ) { success = ReadMeiTuplet( parent, xmlElement ); } - else if ( std::string( xmlElement.name() ) == "chord" ) { + else if ( elementName == "verse" ) { + success = ReadMeiVerse( parent, xmlElement ); + } + else if ( elementName == "chord" ) { // We just read the first note for now pugi::xml_node note = xmlElement.child("note"); if ( note ) { @@ -1386,17 +1430,15 @@ bool MeiInput::ReadMeiNote( Object *parent, pugi::xml_node note ) } } + // We can drop this once we allow and child pugi::xml_node current; for( current = note.first_child( ); current; current = current.next_sibling( ) ) { if ( std::string( current.name() ) == "accid" ) { ReadAccidAsAttr( vrvNote, current ); } - if ( std::string( current.name() ) == "verse" ) { - ReadVerse( vrvNote, current ); - } } - - return true; + + return ReadMeiLayerChildren(vrvNote, note, vrvNote); } @@ -1412,6 +1454,17 @@ bool MeiInput::ReadMeiRest( Object *parent, pugi::xml_node rest ) return true; } +bool MeiInput::ReadMeiSyl( Object *parent, pugi::xml_node syl) +{ + Syl *vrvSyl = new Syl(); + ReadLayerElement(syl, vrvSyl); + + vrvSyl->ReadSylLog( syl ); + ReadText( syl, vrvSyl ); + + AddLayerElement(parent, vrvSyl); + return true; +} bool MeiInput::ReadMeiTuplet( Object *parent, pugi::xml_node tuplet ) { @@ -1423,43 +1476,25 @@ bool MeiInput::ReadMeiTuplet( Object *parent, pugi::xml_node tuplet ) AddLayerElement(parent, vrvTuplet); - ReadMeiLayerChildren( vrvTuplet, tuplet); + bool success = ReadMeiLayerChildren(vrvTuplet, tuplet); if ( vrvTuplet->GetNoteCount() == 1 ) { LogWarning(" with only one note"); } - return true; + return success; } - -bool MeiInput::ReadVerse( Note *vrvNote, pugi::xml_node verse) + +bool MeiInput::ReadMeiVerse(Object *parent, pugi::xml_node verse) { Verse *vrvVerse = new Verse(); - SetMeiUuid( verse , vrvVerse ); + ReadLayerElement(verse, vrvVerse); vrvVerse->ReadCommon(verse); - pugi::xml_node current; - for( current = verse.first_child( ); current; current = current.next_sibling( ) ) { - if ( std::string( current.name() ) == "syl" ) { - ReadSyl( vrvVerse, current ); - } - } - - vrvNote->AddVerse( vrvVerse ); - return true; -} - -bool MeiInput::ReadSyl( Verse *vrvVerse, pugi::xml_node syl) -{ - Syl *vrvSyl = new Syl(); - SetMeiUuid( syl , vrvSyl ); - - vrvSyl->ReadSylLog( syl ); - ReadText( syl, vrvSyl ); + AddLayerElement(parent, vrvVerse); - vrvVerse->AddSyl( vrvSyl ); - return true; + return ReadMeiLayerChildren(vrvVerse, verse, vrvVerse); } bool MeiInput::ReadDurationInterface(pugi::xml_node element, DurationInterface *interface) @@ -1521,7 +1556,7 @@ bool MeiInput::ReadEditorialElement( pugi::xml_node element, EditorialElement *o return true; } -bool MeiInput::ReadMeiApp( Object *parent, pugi::xml_node app, EditorialLevel level ) +bool MeiInput::ReadMeiApp( Object *parent, pugi::xml_node app, EditorialLevel level, Object *filter ) { if (!m_hasScoreDef) { LogError(" before any is not supported"); @@ -1554,11 +1589,11 @@ bool MeiInput::ReadMeiApp( Object *parent, pugi::xml_node app, EditorialLevel le ReadEditorialElement( app, vrvApp ); parent->AddEditorialElement(vrvApp); - return ReadMeiAppChildren( vrvApp, selectedLemOrRdg, level ); + return ReadMeiAppChildren( vrvApp, selectedLemOrRdg, level, filter ); } -bool MeiInput::ReadMeiAppChildren( App *app, pugi::xml_node lemOrRdg, EditorialLevel level ) +bool MeiInput::ReadMeiAppChildren( App *app, pugi::xml_node lemOrRdg, EditorialLevel level, Object *filter ) { EditorialElement *vrvLemOrRdg; if ( std::string( lemOrRdg.name() ) == "lem" ) { @@ -1587,7 +1622,7 @@ bool MeiInput::ReadMeiAppChildren( App *app, pugi::xml_node lemOrRdg, EditorialL return ReadMeiStaffChildren(vrvLemOrRdg, lemOrRdg); } else if (level == EDITORIAL_LAYER) { - return ReadMeiLayerChildren(vrvLemOrRdg, lemOrRdg); + return ReadMeiLayerChildren(vrvLemOrRdg, lemOrRdg, filter); } else { return false; @@ -1682,12 +1717,18 @@ void MeiInput::AddLayerElement( Object *parent, LayerElement *element ) else if ( dynamic_cast( parent ) ) { dynamic_cast( parent )->AddElement( element ); } + else if ( dynamic_cast( parent ) ) { + dynamic_cast( parent )->AddElement( element ); + } else if ( dynamic_cast( parent ) ) { dynamic_cast( parent )->AddElement( element ); } else if ( dynamic_cast( parent ) ) { dynamic_cast( parent )->AddElement( element ); } + else if ( dynamic_cast( parent ) ) { + dynamic_cast( parent )->AddElement( element ); + } else { LogWarning("'%s' not supported within '%s'", element->GetClassName().c_str(), parent->GetClassName().c_str() ); delete element; diff --git a/src/layerelement.cpp b/src/layerelement.cpp index eca82959ad9..6bb5c432fba 100644 --- a/src/layerelement.cpp +++ b/src/layerelement.cpp @@ -31,19 +31,15 @@ #include "multirest.h" #include "note.h" #include "rest.h" +#include "syl.h" #include "tie.h" #include "tuplet.h" +#include "verse.h" #include "vrv.h" #include "vrvdef.h" namespace vrv { -/** - * Define the maximum levels between a tuplet and its notes - */ -#define MAX_TUPLET_DEPTH 3 - - //---------------------------------------------------------------------------- // LayerElement //---------------------------------------------------------------------------- @@ -235,6 +231,11 @@ bool LayerElement::IsRest() return (dynamic_cast(this)); } +bool LayerElement::IsSyl() +{ + return (dynamic_cast(this)); +} + bool LayerElement::IsTie() { return (dynamic_cast(this)); @@ -244,6 +245,11 @@ bool LayerElement::IsTuplet() { return (dynamic_cast(this)); } + +bool LayerElement::IsVerse() +{ + return (dynamic_cast(this)); +} void LayerElement::AdjustPname( int *pname, int *oct ) { @@ -345,7 +351,7 @@ int LayerElement::AlignHorizontally( ArrayPtrVoid params ) else if ( this->IsGraceNote() ) { type = ALIGNMENT_GRACENOTE; } - else if ( this->IsBeam() || this->IsTuplet() ) { + else if ( this->IsBeam() || this->IsTuplet() || this->IsVerse() || this->IsSyl() ) { type = ALIGNMENT_CONTAINER; } diff --git a/src/note.cpp b/src/note.cpp index 55597bade5f..524de1e2820 100644 --- a/src/note.cpp +++ b/src/note.cpp @@ -16,6 +16,7 @@ //---------------------------------------------------------------------------- #include "doc.h" +#include "editorial.h" #include "slur.h" #include "tie.h" #include "verse.h" @@ -106,10 +107,11 @@ bool Note::operator==( Object& other ) return true; } -void Note::AddVerse(Verse *child) -{ - child->SetParent( this ); - m_children.push_back(child); +void Note::AddElement(vrv::LayerElement *element) +{ + assert( dynamic_cast(element) || dynamic_cast(element) ); + element->SetParent( this ); + m_children.push_back(element); Modify(); } diff --git a/src/object.cpp b/src/object.cpp index c31ec0feb9b..3e3e7c15714 100644 --- a/src/object.cpp +++ b/src/object.cpp @@ -496,7 +496,7 @@ bool Object::GetSameAs( std::string *id, std::string *filename, int idx ) return false; } -void Object::Process(Functor *functor, ArrayPtrVoid params, Functor *endFunctor, MapOfTypeN *mapOfTypeN, int deepness ) +void Object::Process(Functor *functor, ArrayPtrVoid params, Functor *endFunctor, ArrayOfAttComparisons *filters, int deepness ) { if (functor->m_returnCode == FUNCTOR_STOP) { return; @@ -511,9 +511,11 @@ void Object::Process(Functor *functor, ArrayPtrVoid params, Functor *endFunctor, } else if (dynamic_cast(this)) { + // since editorial object do not count, we re-increase the deepness limit deepness++; } if (deepness == 0) { + // any need to change the functor m_returnCode? return; } deepness--; @@ -521,26 +523,34 @@ void Object::Process(Functor *functor, ArrayPtrVoid params, Functor *endFunctor, ArrayOfObjects::iterator iter; for (iter = this->m_children.begin(); iter != m_children.end(); ++iter) { - // The MapOfTypeN is used to filter according to a type and an @n - // For example, to process only staff @n="x" and @layer="y" - if ( mapOfTypeN ) { - MapOfTypeN::iterator typeN = mapOfTypeN->find( &typeid(**iter) ); - if(typeN != mapOfTypeN->end()) { - AttCommon *child = dynamic_cast(*iter); - // The filtered type must be of AttCommon because GetN called - assert( child ); - if (child->GetN() != typeN->second) { - // skip it - continue; + if ( filters && !filters->empty() ) { + bool hasAttComparison = false; + // first we look if there is a comparison object for the object type (e.g., a Staff) + ArrayOfAttComparisons::iterator attComparisonIter; + for (attComparisonIter = filters->begin(); attComparisonIter != filters->end(); attComparisonIter++) { + // if yes, we will use it (*attComparisonIter) for evaluating if the object matches + // the attribute (see below) + if ((*attComparisonIter)->GetType() == &typeid(**iter)) { + hasAttComparison = true; + break; } - else { - // process this one and quit - (*iter)->Process( functor, params, endFunctor, mapOfTypeN, deepness ); + } + if (hasAttComparison) { + // use the operator of the AttComparison object to evaluate the attribute + if ((**attComparisonIter)(*iter)) { + // the attribute value matches, process the object + //LogDebug("%s ", (*iter)->GetClassName().c_str() ); + (*iter)->Process( functor, params, endFunctor, filters, deepness); break; } + else { + // the attribute value does not match, skip this child + continue; + } } } - (*iter)->Process( functor, params, endFunctor, mapOfTypeN, deepness ); + // we will end here if there is no filter at all or for the current child type + (*iter)->Process( functor, params, endFunctor, filters, deepness ); } if ( endFunctor ) { @@ -1061,13 +1071,13 @@ int Object::SetBoundingBoxXShift( ArrayPtrVoid params ) return FUNCTOR_CONTINUE; } - //(*min_pos) += doc->GetLeftMargin(current) * doc->m_drawingUnit / 10; + //(*min_pos) += doc->GetLeftMargin(current) * doc->m_drawingUnit / MARGIN_DENOMINATOR; // the negative offset it the part of the bounding box that overflows on the left // |____x_____| // ---- = negative offset //int negative_offset = current->GetAlignment()->GetXRel() - current->m_contentBB_x1; - int negative_offset = - (current->m_contentBB_x1) + (doc->GetLeftMargin(current) * doc->m_drawingUnit / 10); + int negative_offset = - (current->m_contentBB_x1) + (doc->GetLeftMargin(&typeid(*current)) * doc->m_drawingUnit / MARGIN_DENOMINATOR); // this will probably never happen if ( negative_offset < 0 ) { @@ -1087,8 +1097,8 @@ int Object::SetBoundingBoxXShift( ArrayPtrVoid params ) //LogDebug("%s min_pos %d; negative offset %d; drawXRel %d; overlap %d; m_drawingX %d", current->GetClassName().c_str(), (*min_pos), negative_offset, current->GetAlignment()->GetXRel(), overlap, current->GetDrawingX() ); // the next minimal position if given by the right side of the bounding box + the spacing of the element - (*min_pos) = current->GetAlignment()->GetXRel() + current->m_contentBB_x2 + doc->GetRightMargin(&typeid(*current)) * doc->m_drawingUnit / DEFINITON_FACTOR; - current->GetAlignment()->SetMaxWidth( current->m_contentBB_x2 + doc->GetRightMargin(&typeid(*current)) * doc->m_drawingUnit / DEFINITON_FACTOR ); + (*min_pos) = current->GetAlignment()->GetXRel() + current->m_contentBB_x2 + doc->GetRightMargin(&typeid(*current)) * doc->m_drawingUnit / MARGIN_DENOMINATOR; + current->GetAlignment()->SetMaxWidth( current->m_contentBB_x2 + doc->GetRightMargin(&typeid(*current)) * doc->m_drawingUnit / MARGIN_DENOMINATOR ); return FUNCTOR_CONTINUE; } diff --git a/src/scoredef.cpp b/src/scoredef.cpp index 6f5761b05d3..7029d675ab4 100644 --- a/src/scoredef.cpp +++ b/src/scoredef.cpp @@ -25,11 +25,6 @@ namespace vrv { -/** - * Define the maximum levels of staffGrp within a scoreDef - */ -#define MAX_STAFFGRP_DEPTH 5 - //---------------------------------------------------------------------------- // ScoreOrStaffDefAttrInterface //---------------------------------------------------------------------------- diff --git a/src/syl.cpp b/src/syl.cpp index 05f08bc2b2a..a391ba7a209 100644 --- a/src/syl.cpp +++ b/src/syl.cpp @@ -17,7 +17,7 @@ namespace vrv { //---------------------------------------------------------------------------- Syl::Syl(): - DocObject("syl-"), + LayerElement("syl-"), AttSylLog() { Reset(); @@ -29,7 +29,7 @@ Syl::~Syl() void Syl::Reset() { - DocObject::Reset(); + LayerElement::Reset(); ResetSylLog(); } diff --git a/src/verse.cpp b/src/verse.cpp index 8ebfd6752ea..50c248f9130 100644 --- a/src/verse.cpp +++ b/src/verse.cpp @@ -16,6 +16,7 @@ //---------------------------------------------------------------------------- #include "aligner.h" +#include "editorial.h" #include "layer.h" #include "staff.h" #include "syl.h" @@ -28,7 +29,7 @@ namespace vrv { //---------------------------------------------------------------------------- Verse::Verse(): - DocObject("verse-"), + LayerElement("verse-"), AttCommon() { Reset(); @@ -40,14 +41,15 @@ Verse::~Verse() void Verse::Reset() { - DocObject::Reset(); + LayerElement::Reset(); ResetCommon(); } -void Verse::AddSyl(Syl *syl) { - - syl->SetParent( this ); - m_children.push_back(syl); +void Verse::AddElement(vrv::LayerElement *element) +{ + assert( dynamic_cast(element) || dynamic_cast(element) ); + element->SetParent( this ); + m_children.push_back(element); Modify(); } @@ -97,7 +99,7 @@ int Verse::PrepareLyrics( ArrayPtrVoid params ) Syl *syl = dynamic_cast( this->GetFirst( &typeid(Syl) ) ); if (syl) { - //std::cout << UTF16to8( syl->GetText().c_str() ) << std::endl; + std::cout << UTF16to8( syl->GetText().c_str() ) << std::endl; } return FUNCTOR_CONTINUE; } diff --git a/src/view_beam.cpp b/src/view_beam.cpp index 88058600201..08420693c21 100755 --- a/src/view_beam.cpp +++ b/src/view_beam.cpp @@ -74,7 +74,7 @@ double dA, dB; /* This need to be put into a beam class */ -void View::DrawBeam( DeviceContext *dc, Layer *layer, Beam *beam, Staff *staff ) +void View::DrawBeamPostponed( DeviceContext *dc, Layer *layer, Beam *beam, Staff *staff ) { LayerElement *chk; static struct fb { @@ -181,7 +181,7 @@ void View::DrawBeam( DeviceContext *dc, Layer *layer, Beam *beam, Staff *staff fb.mrq_port = chk->_shport; }***/ - (crd+ct)->a = chk->GetDrawingX() - m_doc->m_env.m_stemWidth / 2; /* enregistrement des coord. */ + (crd+ct)->a = chk->GetDrawingX(); // - m_doc->m_env.m_stemWidth / 2; /* enregistrement des coord. */ (crd+ct)->vlr = k; if (chk->IsNote() && ((Note*)chk)->GetBreaksec() && ct) /* enregistr. des ruptures de beaming; des la 2e note;(autrement idiot)*/ diff --git a/src/view_element.cpp b/src/view_element.cpp index 0941d309260..1172ded66de 100644 --- a/src/view_element.cpp +++ b/src/view_element.cpp @@ -81,31 +81,31 @@ void View::DrawElement( DeviceContext *dc, LayerElement *element, Layer *layer, } if (dynamic_cast(element)) { - DrawAccid(dc, element, layer, staff); + DrawAccid(dc, element, layer, staff, measure); } else if (dynamic_cast(element)) { - DrawBarline(dc, element, layer, staff); + DrawBarline(dc, element, layer, staff, measure); } else if (dynamic_cast(element)) { - DrawBeamElement(dc, element, layer, staff, measure); + DrawBeam(dc, element, layer, staff, measure); } else if (dynamic_cast(element)) { - DrawClef(dc, element, layer, staff); + DrawClef(dc, element, layer, staff, measure); } else if (dynamic_cast(element)) { - DrawCustos(dc, element, layer, staff); + DrawCustos(dc, element, layer, staff, measure); } else if (dynamic_cast(element)) { - DrawDot(dc, element, layer, staff); + DrawDot(dc, element, layer, staff, measure); } else if (dynamic_cast(element)) { - DrawKeySig(dc, element, layer, staff); + DrawKeySig(dc, element, layer, staff, measure); } else if (dynamic_cast(element)) { - DrawMensur(dc, element, layer, staff); + DrawMensur(dc, element, layer, staff, measure); } else if (dynamic_cast(element)) { - DrawMeterSig(dc, element, layer, staff); + DrawMeterSig(dc, element, layer, staff, measure); } else if (dynamic_cast(element)) { DrawMRest(dc, element, layer, staff, measure); @@ -114,25 +114,31 @@ void View::DrawElement( DeviceContext *dc, LayerElement *element, Layer *layer, DrawMultiRest(dc, element, layer, staff, measure); } else if (dynamic_cast(element)) { - DrawDurationElement(dc, element, layer, staff); + DrawDurationElement(dc, element, layer, staff, measure); } else if (dynamic_cast(element)) { - DrawDurationElement(dc, element, layer, staff); + DrawDurationElement(dc, element, layer, staff, measure); } - else if (dynamic_cast(element)) { + else if (dynamic_cast(element)) { DrawTie(dc, element, layer, staff, measure); } - else if (dynamic_cast(element)) { + else if (dynamic_cast(element)) { + DrawSyl(dc, element, layer, staff, measure); + } + else if (dynamic_cast(element)) { DrawTie(dc, element, layer, staff, measure); } else if (dynamic_cast(element)) { - DrawTupletElement(dc, element, layer, staff, measure); + DrawTuplet(dc, element, layer, staff, measure); + } + else if (dynamic_cast(element)) { + DrawVerse(dc, element, layer, staff, measure); } m_currentColour = previousColor; } -void View::DrawDurationElement( DeviceContext *dc, LayerElement *element, Layer *layer, Staff *staff ) +void View::DrawDurationElement( DeviceContext *dc, LayerElement *element, Layer *layer, Staff *staff, Measure *measure ) { assert(layer); // Pointer to layer cannot be NULL" assert(staff); // Pointer to staff cannot be NULL" @@ -149,7 +155,7 @@ void View::DrawDurationElement( DeviceContext *dc, LayerElement *element, Layer element->SetDrawingY( element->GetDrawingY() + CalculatePitchPosY( staff, note->GetPname(), layer->GetClefOffset( element ), oct ) ); dc->StartGraphic( element, "", element->GetUuid() ); - DrawNote(dc, element, layer, staff); + DrawNote(dc, element, layer, staff, measure); dc->EndGraphic(element, this ); } else if (dynamic_cast(element)) { @@ -163,14 +169,14 @@ void View::DrawDurationElement( DeviceContext *dc, LayerElement *element, Layer element->SetDrawingY( element->GetDrawingY() + CalculatePitchPosY( staff, rest->GetPloc(), layer->GetClefOffset( element ), oct) ); dc->StartGraphic( element, "", element->GetUuid() ); - DrawRest( dc, element, layer, staff ); + DrawRest( dc, element, layer, staff, measure ); dc->EndGraphic(element, this ); } return; } -void View::DrawBeamElement(DeviceContext *dc, LayerElement *element, Layer *layer, Staff *staff, Measure *measure) { +void View::DrawBeam(DeviceContext *dc, LayerElement *element, Layer *layer, Staff *staff, Measure *measure) { assert(layer); // Pointer to layer cannot be NULL" assert(staff); // Pointer to staff cannot be NULL" @@ -179,12 +185,7 @@ void View::DrawBeamElement(DeviceContext *dc, LayerElement *element, Layer *laye dc->StartGraphic( element, "", element->GetUuid() ); - for (unsigned int i = 0; i < beam->m_children.size(); i++) { - if ( dynamic_cast(beam->m_children[i]) ) { - LayerElement *element = dynamic_cast(beam->m_children[i]); - DrawElement(dc, element, layer, staff, measure); - } - } + DrawLayerChildren(dc, beam, layer, staff, measure); // Add to the list of postponed element layer->AddToDrawingList( beam ); @@ -192,7 +193,7 @@ void View::DrawBeamElement(DeviceContext *dc, LayerElement *element, Layer *laye dc->EndGraphic(element, this ); } -void View::DrawTupletElement(DeviceContext *dc, LayerElement *element, Layer *layer, Staff *staff, Measure *measure) { +void View::DrawTuplet(DeviceContext *dc, LayerElement *element, Layer *layer, Staff *staff, Measure *measure) { assert(layer); // Pointer to layer cannot be NULL" assert(staff); // Pointer to staff cannot be NULL" @@ -202,12 +203,7 @@ void View::DrawTupletElement(DeviceContext *dc, LayerElement *element, Layer *la dc->StartGraphic( element, "", element->GetUuid() ); // Draw the inner elements - for (unsigned int i = 0; i < tuplet->m_children.size(); i++) { - if ( dynamic_cast(tuplet->m_children[i]) ) { - LayerElement *element = dynamic_cast(tuplet->m_children[i]); - DrawElement(dc, element, layer, staff, measure); - } - } + DrawLayerChildren(dc, tuplet, layer, staff, measure); // Add to the list of postponed element layer->AddToDrawingList( tuplet ); @@ -222,7 +218,7 @@ void View::DrawTupletElement(DeviceContext *dc, LayerElement *element, Layer *la // queue: le ptr *testchord extern peut garder le x et l'y. -void View::DrawNote ( DeviceContext *dc, LayerElement *element, Layer *layer, Staff *staff) +void View::DrawNote ( DeviceContext *dc, LayerElement *element, Layer *layer, Staff *staff, Measure *measure ) { assert(layer); // Pointer to layer cannot be NULL" assert(staff); // Pointer to staff cannot be NULL" @@ -234,114 +230,90 @@ void View::DrawNote ( DeviceContext *dc, LayerElement *element, Layer *layer, St // Get the immadiate parent of the note // to see if beamed or not - Object *note_parent = note->GetFirstParent(&typeid(Beam)); + Beam *beam_parent = dynamic_cast(note->GetFirstParent(&typeid(Beam))); // This note is beamed and cue sized - if (note_parent != NULL) { + if (beam_parent != NULL) { if (note->m_cueSize == true) { // Get the Parent of the parent // we want to see if we are in a group of // beamed cue notes - Beam *b = dynamic_cast(note_parent); - if (b->GetListIndex(note) > -1) { + if (beam_parent->GetListIndex(note) > -1) { inBeam = true; } - } else { + } + else { // the note is just in a beam inBeam = true; } } int staffSize = staff->staffSize; - - // int horphyspoint=h_pnt; - //int b = element->m_drawingY; + int y1 = element->GetDrawingY(); + int x1, x2, y2; + int baseStem, totalFlagStemHeight, flagStemHeight, nbFlags; + int drawingDur; + int staffY = staff->GetDrawingY(); wchar_t fontNo; - int i, valdec, ledge, queueCentre; - int x1, x2, y2, espac7, decval, vertical; - int formval = 0; // pour permettre dessiner colorations avec dÇcalage de val - int rayon, milieu = 0; + int i, ledge; + int verticalCenter = 0; int xn = element->GetDrawingX(), xl = element->GetDrawingX(); - int bby = staff->GetDrawingY(); // bby= y sommet portee - int ynn = element->GetDrawingY(); //static int ynn_chrd; //val=note->m_dur; - formval = ((note->GetColored()==BOOLEAN_true) && note->GetDur() > DUR_1) ? (note->GetDur()+1) : note->GetDur(); - queueCentre = 0; + drawingDur = ((note->GetColored()==BOOLEAN_true) && note->GetDur() > DUR_1) ? (note->GetDur()+1) : note->GetDur(); + int radius = m_doc->m_drawingNoteRadius[staffSize][note->m_cueSize]; - rayon = m_doc->m_drawingNoteRadius[staffSize][note->m_cueSize]; - - if (note->GetDur() > DUR_1 || (note->GetDur() == DUR_1 && staff->notAnc)) // annuler provisoirement la modif. des lignes addit. + if (note->GetDur() > DUR_1 || (note->GetDur() == DUR_1 && staff->notAnc)) { // annuler provisoirement la modif. des lignes addit. ledge = m_doc->m_drawingLedgerLine[staffSize][note->m_cueSize]; - else - { - ledge= m_doc->m_drawingLedgerLine[staffSize][2]; - rayon += rayon/3; + + } + else { + ledge= m_doc->m_drawingLedgerLine[staffSize][note->m_cueSize]; + radius += radius/3; } - x1 = xn-rayon; // position d'appel du caractäre et de la queue gauche + x1 = xn-radius; // position d'appel du caractäre et de la queue gauche xl = xn; - // permettre d'inverser le cotÇ de la tete de note avec flag lat - /*if (this->lat && !this->chord) - { if (this->queue) - { x1 = xn + rayon; - xl = xn + rayon * 2; - } - else - { x1 = xn - rayon * 3; - xl = xn - rayon * 2; - } - }*/ // ax2 - not support of lat - - if (note->GetDur() == DUR_LG || note->GetDur() == DUR_BR || ((note->GetLig()!=LIGATURE_NONE) && note->GetDur() == DUR_1)) // dessin carrees - { - DrawLigature ( dc, ynn, element, layer, staff); + // Long, breve and ligatures + if (note->GetDur() == DUR_LG || note->GetDur() == DUR_BR || ((note->GetLig()!=LIGATURE_NONE) && note->GetDur() == DUR_1)) { + DrawLigature ( dc, y1, element, layer, staff); } - else if (note->GetDur()==DUR_1) - { - if (note->GetColored()==BOOLEAN_true) // && !note->m_ligObliqua) // in WG, use of obliq for coloration? + // Whole notes + else if (note->GetDur()==DUR_1) { + if (note->GetColored()==BOOLEAN_true) fontNo = SMUFL_E0FA_noteheadWholeFilled; else fontNo = SMUFL_E0A2_noteheadWhole; - DrawSmuflCode( dc, x1, ynn, fontNo, staff->staffSize, note->m_cueSize ); - decval = ynn; + DrawSmuflCode( dc, x1, y1, fontNo, staff->staffSize, note->m_cueSize ); + totalFlagStemHeight = y1; } - else - { - if ((note->GetColored()==BOOLEAN_true) || formval == DUR_2) + // Other values + else { + if ((note->GetColored()==BOOLEAN_true) || drawingDur == DUR_2) { fontNo = SMUFL_E0A3_noteheadHalf; - else + } + else { fontNo = SMUFL_E0A4_noteheadBlack; + } - DrawSmuflCode( dc,x1, ynn, fontNo, staff->staffSize, note->m_cueSize ); - - milieu = bby - m_doc->m_drawingInterl[staffSize]*2; + DrawSmuflCode( dc, x1, y1, fontNo, staff->staffSize, note->m_cueSize ); -// test ligne mediane pour direction queues: notation mesuree, milieu queue haut - if (staff->notAnc) - milieu += m_doc->m_drawingHalfInterl[staffSize]; + verticalCenter = staffY - m_doc->m_drawingInterl[staffSize]*2; //if (note->m_chord) { /*** && this == testchord)***/ // ynn_chrd = ynn; //} - if (inBeam && formval > DUR_4) - { + if (inBeam && drawingDur > DUR_4) { // no stem } - //else if (note->m_headshape != SANSQUEUE && (!note->m_chord || (note->m_chord==CHORD_TERMINAL))) { - else { - /*if (note->m_chord==CHORD_TERMINAL) { - up = testchord->obj.not.haste; - xn = testchord->m_drawingX; - } - else */ - + else { + // Set the drawing stem direction if ( note->HasStemDir() ) { note->m_drawingStemDir = note->GetStemDir(); } @@ -349,195 +321,104 @@ void View::DrawNote ( DeviceContext *dc, LayerElement *element, Layer *layer, St note->m_drawingStemDir = layer->GetDrawingStemDir(); } else { - note->m_drawingStemDir = (ynn >= milieu) ? STEMDIRECTION_down : STEMDIRECTION_up; + note->m_drawingStemDir = (y1 >= verticalCenter) ? STEMDIRECTION_down : STEMDIRECTION_up; } - espac7 = note->m_cueSize ? ( m_doc->m_drawingHalfInterl[staffSize]*5) : ( m_doc->m_drawingHalfInterl[staffSize]*7); - vertical = note->m_cueSize ? m_doc->m_drawingHalfInterl[staffSize] : m_doc->m_drawingInterl[staffSize]; - decval = vertical * (valdec = formval-DUR_8); + baseStem = note->m_cueSize ? ( m_doc->m_drawingHalfInterl[staffSize]*5) : ( m_doc->m_drawingHalfInterl[staffSize]*7); + flagStemHeight = note->m_cueSize ? m_doc->m_drawingHalfInterl[staffSize] : m_doc->m_drawingInterl[staffSize]; + nbFlags = drawingDur - DUR_8; + totalFlagStemHeight = flagStemHeight * (nbFlags * 2 - 1) / 2; - /***if (this->existDebord) // queue longueur manuelle - traiteQueue (&espac7, this);***/ - - // diminuer le rayon de la moitie de l'epaisseur du trait de queue - rayon -= (m_doc->m_env.m_stemWidth) / 2; - - if (note->m_drawingStemDir == STEMDIRECTION_down) { // si queue vers le bas (a gauche) - espac7 = -espac7; - decval = -decval; - rayon = -rayon; + if (note->m_drawingStemDir == STEMDIRECTION_down) { + // flip all lengths + baseStem = -baseStem; + totalFlagStemHeight = -totalFlagStemHeight; + radius = -radius; } - y2 = ((formval>DUR_8) ? (ynn + espac7 + decval) : (ynn + espac7)); - - /*if ((note->m_chord==CHORD_INITIAL) || (note->m_chord==CHORD_MEDIAL)) { - ynn = ynn_chrd; - }*/ + // If we have flags, add them to the height + y2 = ((drawingDur>DUR_8) ? (y1 + baseStem + totalFlagStemHeight) : (y1 + baseStem)); + x2 = xn + radius; + + if ((note->m_drawingStemDir == STEMDIRECTION_up) && (y2 < verticalCenter) ) { + y2 = verticalCenter; + } + else if ((note->m_drawingStemDir == STEMDIRECTION_down) && (y2 > verticalCenter) ) { + y2 = verticalCenter; + } + + // shorten the stem at its connection with the note head + int stemY1 = (note->m_drawingStemDir == STEMDIRECTION_up) ? y1 + m_doc->m_drawingHalfInterl[staffSize] / 4 : y1 - m_doc->m_drawingHalfInterl[staffSize] / 4; + int stemY2 = y2; + if (drawingDur > DUR_4) { + // if we have flags, shorten the stem to make sure we have a nice overlap with the flag glyph + stemY2 = (note->m_drawingStemDir == STEMDIRECTION_up) ? y2 - m_doc->m_drawingHalfInterl[staffSize] : y2 + m_doc->m_drawingHalfInterl[staffSize]; + } - /***if (this->q_auto) - { this->queue = (up > 0); - if ( (y2 >= milieu && ynn > milieu) || (y2 <= milieu && ynn < milieu) ) - // note et queue du meme cote par rapport au centre de la portee - { y2 = milieu; - queueCentre = 1; - } - }***/ - - if (staff->notAnc) - rayon = 0; - x2 = xn + rayon; - - if (note->m_drawingStemDir == STEMDIRECTION_up) - { - if (formval > DUR_8 && !queueCentre) - // Le 24 Septembre 1993. Correction esthetique pour rapprocher tailles - // des DUR_8 et DUR_16 (longeur de queues trop inegales). - y2 -= m_doc->m_drawingHalfInterl[staffSize]; - decval = y2; - if (staff->notAnc) - DrawVerticalLine ( dc,y2,(int)(ynn + m_doc->m_drawingHalfInterl[staffSize]),x2, m_doc->m_env.m_stemWidth );//queue en descendant - else - DrawVerticalLine ( dc,y2,(int)(ynn+ m_doc->m_drawingHalfInterl[staffSize]/4),x2 - (m_doc->m_env.m_stemWidth / 2), m_doc->m_env.m_stemWidth );//queue en descendant + // draw the stems and the flags + if (note->m_drawingStemDir == STEMDIRECTION_up) { + DrawFullRectangle( dc, x2 - m_doc->m_env.m_stemWidth, stemY1, x2, stemY2); element->m_drawingStemStart.x = element->m_drawingStemEnd.x = x2 - (m_doc->m_env.m_stemWidth / 2); + element->m_drawingStemStart.y = y1; element->m_drawingStemEnd.y = y2; - element->m_drawingStemStart.y = (int)(ynn+ m_doc->m_drawingHalfInterl[staffSize]/4); element->m_drawingStemDir = true; - if (formval > DUR_4) - { - y2 += m_doc->m_env.m_stemWidth / 2; // ENZO correction empirique... - DrawSmuflCode( dc,x2,y2,SMUFL_E240_flag8thUp, staff->staffSize, note->m_cueSize ); - for (i=0; i < valdec; i++) - DrawSmuflCode( dc,x2,y2-=vertical,SMUFL_E240_flag8thUp, staff->staffSize, note->m_cueSize ); + if (drawingDur > DUR_4) { + DrawSmuflCode( dc, x2 - m_doc->m_env.m_stemWidth, y2, SMUFL_E240_flag8thUp, staff->staffSize, note->m_cueSize ); + for (i=0; i < nbFlags; i++) + DrawSmuflCode( dc, x2 - m_doc->m_env.m_stemWidth, y2 - (i + 1) * flagStemHeight, SMUFL_E240_flag8thUp, staff->staffSize, note->m_cueSize ); } } - else - { - if (formval > DUR_8 && !queueCentre) - // Le 24 Septembre 1993. Correction esthetique pour rapprocher tailles - // des DUR_8 et DUR_16 (longeur de queues trop inegales). - y2 += m_doc->m_drawingHalfInterl[staffSize]; - decval = y2; - - if (staff->notAnc) - DrawVerticalLine ( dc,y2,ynn- m_doc->m_drawingHalfInterl[staffSize],x2 - (m_doc->m_env.m_stemWidth / 2), m_doc->m_env.m_stemWidth );//queue en descendant - else - DrawVerticalLine ( dc,y2,(int)(ynn- m_doc->m_drawingHalfInterl[staffSize]/4),x2 - (m_doc->m_env.m_stemWidth / 2), m_doc->m_env.m_stemWidth ); // queue en montant + else { + DrawFullRectangle( dc, x2, stemY1, x2 + m_doc->m_env.m_stemWidth, stemY2); element->m_drawingStemStart.x = element->m_drawingStemEnd.x = x2 - (m_doc->m_env.m_stemWidth / 2); - element->m_drawingStemStart.y = (int)(ynn- m_doc->m_drawingHalfInterl[staffSize]/4); + element->m_drawingStemStart.y = y1; element->m_drawingStemEnd.y = y2; element->m_drawingStemDir = false; - if (formval > DUR_4) - { - y2 -= m_doc->m_env.m_stemWidth / 2; // ENZO correction empirique... - DrawSmuflCode( dc,x2,y2,SMUFL_E241_flag8thDown , staff->staffSize, note->m_cueSize ); - for (i=0; i < valdec; i++) - DrawSmuflCode( dc,x2,y2+=vertical,SMUFL_E241_flag8thDown, staff->staffSize, + if (drawingDur > DUR_4) { + DrawSmuflCode( dc, x2 , y2, SMUFL_E241_flag8thDown , staff->staffSize, note->m_cueSize ); + for (i=0; i < nbFlags; i++) + DrawSmuflCode( dc, x2, y2 + (i + 1) * flagStemHeight, SMUFL_E241_flag8thDown, staff->staffSize, note->m_cueSize ); } } - if (note->m_cueSize && note->m_acciaccatura) + if (note->m_cueSize && note->m_acciaccatura) { DrawAcciaccaturaSlash(dc, element); - } // fin de dessin queues et crochets + } + } } - DrawLedgerLines( dc, ynn, bby, xl, ledge, staffSize); + DrawLedgerLines( dc, y1, staffY, xl, ledge, staffSize ); - if (note->GetAccid() != ACCIDENTAL_EXPLICIT_NONE) // && !this->accInvis) // ax2 no support invisible accidental yet - { - //if (note->m_chord) - // {}/***x1 = x_acc_chrd (this,0);***/ - //else - x1 -= 1.5 * m_doc->m_drawingAccidWidth[staffSize][note->m_cueSize]; + if (note->GetAccid() != ACCIDENTAL_EXPLICIT_NONE) { + x1 -= 1.5 * m_doc->m_drawingAccidWidth[staffSize][note->m_cueSize]; Accid accid; accid.SetOloc(note->GetOct()); accid.SetPloc(note->GetPname()); accid.SetAccid(note->GetAccid()); + accid.m_cueSize = note->m_cueSize; accid.SetDrawingX( x1 ); - accid.SetDrawingY( staff->GetDrawingY() ); - DrawAccid( dc, &accid, layer, staff, element ); // ax2 + accid.SetDrawingY( y1 ); + DrawAccid( dc, &accid, layer, staff, measure ); // ax2 } - if (0) //if (note->m_chord) - { - /***x2 = testchord->m_drawingX + m_doc->m_drawingStep2; - if (this->haste) - { if (this->lat || (this->ptr_fe && this->ptr_fe->type==NOTE && this->ptr_fe->obj.not.lat) - || (this->ptr_pe && element->m_drawingX==this->ptr_pe->m_drawingX && this->ptr_pe->type==NOTE && this->ptr_pe->obj.not.lat - && this->dec_y - this->ptr_pe->dec_y < m_doc->m_drawingInterl[staffSize] - && 0 != ((int)b % (int)m_doc->m_drawingInterl[staffSize])) - ) - x2 += m_doc->m_drawingNoteRadius[staffSize][dimin] * 2; - }*/// + + if (0) { } - else - { if (note->GetDur() < DUR_2 || (note->GetDur() > DUR_8 && !inBeam && (note->m_drawingStemDir == STEMDIRECTION_up))) + else { + if (note->GetDur() < DUR_2 || (note->GetDur() > DUR_8 && !inBeam && (note->m_drawingStemDir == STEMDIRECTION_up))) x2 = xn + m_doc->m_drawingUnit*7/2; else x2 = xn + m_doc->m_drawingUnit*5/2; - - //if (this->lat) // ax2 - no support of note head flip - // x2 += rayon*2; } - if (note->GetDots()) // && (!this->pointInvisible)) // ax2 - no support of invisible dots yet - { - DrawDots( dc, x2, ynn, note->GetDots(), staff ); + if (note->GetDots()) { + DrawDots( dc, x2, y1, note->GetDots(), staff ); } -/* - if (this->stacc && (!this->rel || !this->queue_lig)) - { - if (!this->chord || ((!this->queue_lig && this == testchord) || (this->queue_lig && this->fchord ))) - { - if (val > DUR_BR) - { if (!this->queue_lig) - { if ((this->queue && !this->chord) || (this->chord && this->haste)) - { b -= m_doc->m_drawingInterl[staffSize]; - decval = -m_doc->m_drawingInterl[staffSize]; - } - else - { b += m_doc->m_drawingInterl[staffSize]; - decval = 0; - } - - } - else // tous les cas inversÇs par queue_lig - { b = decval-staff->m_drawingY; - - if ((!this->queue && !this->chord) || (this->chord && !this->haste)) - { b -= m_doc->m_drawingInterl[staffSize]; - decval = -1; - if (val <= DUR_1) - decval = -m_doc->m_drawingInterl[staffSize]; - - } - else - { b += m_doc->m_drawingHalfInterl[staffSize]; - decval = 0; - if (val <= DUR_1) - b += m_doc->m_drawingHalfInterl[staffSize]; - } - } - - } - else - return; - putStacc (hdc,xn,b,decval,this->typStac); - } - } -*/ - - //temp debug code -// m_currentColour = wxCYAN; -// DrawFullRectangle(dc, element->m_drawingX - 3, ynn - 3, element->m_drawingX + 3, ynn + 3); -// LogDebug("xrel: %d, ynn: %d", element->m_drawingX, ynn); -// m_currentColour = wxBLACK; - //temp debug code - // Add the ties to the postponed drawing list if ( note->GetTieAttrInitial() ) { @@ -574,10 +455,8 @@ void View::DrawNote ( DeviceContext *dc, LayerElement *element, Layer *layer, St layer->AddToDrawingList( note->GetSlurAttrTerminal() ); } - Verse *verse = NULL; - for ( verse = dynamic_cast( note->GetFirst( &typeid(Verse) ) ); verse; verse = dynamic_cast (note->GetNext() ) ) { - DrawVerse(dc, verse, note, layer, staff ); - } + // This will draw lyrics, accid, etc. + DrawLayerChildren(dc, note, layer, staff, measure); if (note->GetFermata() != PLACE_NONE) { DrawFermata(dc, element, staff); @@ -591,7 +470,7 @@ void View::DrawNote ( DeviceContext *dc, LayerElement *element, Layer *layer, St } -void View::DrawRest ( DeviceContext *dc, LayerElement *element, Layer *layer, Staff *staff ) +void View::DrawRest ( DeviceContext *dc, LayerElement *element, Layer *layer, Staff *staff, Measure *measure ) { assert(layer); // Pointer to layer cannot be NULL assert(staff); // Pointer to staff cannot be NULL @@ -599,7 +478,7 @@ void View::DrawRest ( DeviceContext *dc, LayerElement *element, Layer *layer, St Rest *rest = dynamic_cast(element); - int formval = rest->GetDur(); + int drawingDur = rest->GetDur(); int x = element->GetDrawingX(); int y = element->GetDrawingY(); @@ -608,18 +487,18 @@ void View::DrawRest ( DeviceContext *dc, LayerElement *element, Layer *layer, St element->m_drawingStemEnd.y = element->GetDrawingY(); element->m_drawingStemStart.y = element->GetDrawingY(); - if (formval > DUR_2) + if (drawingDur > DUR_2) { x -= m_doc->m_drawingNoteRadius[staff->staffSize][rest->m_cueSize]; } - switch (formval) + switch (drawingDur) { case DUR_LG: DrawLongRest ( dc, x, y, staff); break; case DUR_BR: DrawBreveRest( dc, x, y, staff); break; case DUR_1: - case DUR_2: DrawWholeRest ( dc, x, y, formval, rest->GetDots(), rest->m_cueSize, staff); break; - default: DrawQuarterRest( dc, x, y, formval, rest->GetDots(), rest->m_cueSize, staff); + case DUR_2: DrawWholeRest ( dc, x, y, drawingDur, rest->GetDots(), rest->m_cueSize, staff); break; + default: DrawQuarterRest( dc, x, y, drawingDur, rest->GetDots(), rest->m_cueSize, staff); } if(rest->GetFermata() != PLACE_NONE) { @@ -924,7 +803,7 @@ void View::DrawLigature ( DeviceContext *dc, int y, LayerElement *element, Layer int xn, x1, x2, y1, y2, y3, y4; // int yy2, y5; // unused - int milieu, up, epaisseur; + int verticalCenter, up, epaisseur; epaisseur = std::max (2, m_doc->m_drawingBeamWidth[staff->staffSize]/2); xn = element->GetDrawingX(); @@ -963,7 +842,7 @@ void View::DrawLigature ( DeviceContext *dc, int y, LayerElement *element, Layer /* else // traitement des obliques { - if (!View::s_drawingLigObliqua) // 1e passage: ligne verticale initiale + if (!View::s_drawingLigObliqua) // 1e passage: ligne flagStemHeighte initiale { DrawVerticalLine (dc,y3,y4,x1, m_doc->m_env.m_stemWidth ); View::s_drawingLigObliqua = true; @@ -971,7 +850,7 @@ void View::DrawLigature ( DeviceContext *dc, int y, LayerElement *element, Layer // if (val == DUR_1) // queue gauche haut si DUR_1 // queue_lig = ON; } - else // 2e passage: lignes obl. et verticale finale + else // 2e passage: lignes obl. et flagStemHeighte finale { x1 -= m_doc->m_drawingBrevisWidth[staff->staffSize]*2; // avance auto @@ -985,7 +864,7 @@ void View::DrawLigature ( DeviceContext *dc, int y, LayerElement *element, Layer { DrawObliqueLine ( dc, x1, y1, x2, yy2, 5); DrawObliqueLine ( dc, x1, y5, x2, y2, -5); } - DrawVerticalLine ( dc,y3,y4,x2,m_doc->m_env.m_stemWidth); //cloture verticale + DrawVerticalLine ( dc,y3,y4,x2,m_doc->m_env.m_stemWidth); //cloture flagStemHeighte View::s_drawingLigObliqua = false; // queue_lig = OFF; //desamorce alg.queue DUR_BR @@ -995,10 +874,10 @@ void View::DrawLigature ( DeviceContext *dc, int y, LayerElement *element, Layer if (note->m_lig) // memoriser positions d'une note a l'autre; relier notes par barres { - *(View::s_drawingLigX+1) = x2; *(View::s_drawingLigY+1) = y; // relie notes ligaturees par barres verticales + *(View::s_drawingLigX+1) = x2; *(View::s_drawingLigY+1) = y; // relie notes ligaturees par barres flagStemHeightes //if (in(x1,(*View::s_drawingLigX)-2,(*View::s_drawingLigX)+2) || (this->fligat && this->lat && !Note1::marq_obl)) - // les dernieres conditions pour permettre ligature verticale ancienne - // DrawVerticalLine (dc, *ligat_y, y1, (this->fligat && this->lat) ? x2: x1, m_doc->m_parameters.m_stemWidth); // ax2 - drawing vertical lines missing + // les dernieres conditions pour permettre ligature flagStemHeighte ancienne + // DrawVerticalLine (dc, *ligat_y, y1, (this->fligat && this->lat) ? x2: x1, m_doc->m_parameters.m_stemWidth); // ax2 - drawing flagStemHeight lines missing *View::s_drawingLigX = *(View::s_drawingLigX + 1); *View::s_drawingLigY = *(View::s_drawingLigY + 1); } @@ -1025,9 +904,9 @@ void View::DrawLigature ( DeviceContext *dc, int y, LayerElement *element, Layer else if (note->m_dur == DUR_LG) // DUR_LG isolee: queue comme notes normales */ { - milieu = staff->GetDrawingY() - m_doc->m_drawingInterl[staff->staffSize]*2; + verticalCenter = staff->GetDrawingY() - m_doc->m_drawingInterl[staff->staffSize]*2; // ENZ - up = (y < milieu) ? ON : OFF; + up = (y < verticalCenter) ? ON : OFF; // ENZ if ( note->m_drawingStemDir != STEMDIRECTION_NONE ) { if ( note->m_drawingStemDir == STEMDIRECTION_up) { @@ -1053,7 +932,7 @@ void View::DrawLigature ( DeviceContext *dc, int y, LayerElement *element, Layer return; } -void View::DrawBarline( DeviceContext *dc, LayerElement *element, Layer *layer, Staff *staff ) +void View::DrawBarline( DeviceContext *dc, LayerElement *element, Layer *layer, Staff *staff, Measure *measure ) { assert(layer); // Pointer to layer cannot be NULL" assert(staff); // Pointer to staff cannot be NULL" @@ -1079,7 +958,7 @@ void View::DrawBarline( DeviceContext *dc, LayerElement *element, Layer *layer, dc->EndGraphic(element, this ); //RZ } -void View::DrawClef( DeviceContext *dc, LayerElement *element, Layer *layer, Staff *staff ) +void View::DrawClef( DeviceContext *dc, LayerElement *element, Layer *layer, Staff *staff, Measure *measure ) { assert(layer); // Pointer to layer cannot be NULL" assert(staff); // Pointer to staff cannot be NULL" @@ -1161,7 +1040,7 @@ void View::DrawClef( DeviceContext *dc, LayerElement *element, Layer *layer, Sta dc->EndGraphic(element, this ); //RZ } -void View::DrawMensur( DeviceContext *dc, LayerElement *element, Layer *layer, Staff *staff ) +void View::DrawMensur( DeviceContext *dc, LayerElement *element, Layer *layer, Staff *staff, Measure *measure ) { assert(layer); // Pointer to layer cannot be NULL" assert(staff); // Pointer to staff cannot be NULL" @@ -1336,7 +1215,7 @@ void View::DrawMensurFigures( DeviceContext *dc, int x, int y, int num, int numB } -void View::DrawMeterSig( DeviceContext *dc, LayerElement *element, Layer *layer, Staff *staff ) +void View::DrawMeterSig( DeviceContext *dc, LayerElement *element, Layer *layer, Staff *staff, Measure *measure ) { assert(layer); // Pointer to layer cannot be NULL" assert(staff); // Pointer to staff cannot be NULL" @@ -1367,7 +1246,7 @@ void View::DrawMeterSig( DeviceContext *dc, LayerElement *element, Layer *layer, } -void View::DrawAccid( DeviceContext *dc, LayerElement *element, Layer *layer, Staff *staff, LayerElement *parent ) +void View::DrawAccid( DeviceContext *dc, LayerElement *element, Layer *layer, Staff *staff, Measure *measure ) { assert(layer); // Pointer to layer cannot be NULL" assert(staff); // Pointer to staff cannot be NULL" @@ -1375,14 +1254,12 @@ void View::DrawAccid( DeviceContext *dc, LayerElement *element, Layer *layer, St Accid *accid = dynamic_cast(element); dc->StartGraphic( element, "", element->GetUuid() ); - - // This is used when we add dynamically an element (eg. accidentals before notes) - // So we can get the clef without adding the new elem in the list - LayerElement *list_elem = element; - if (parent) list_elem = parent; - int oct = accid->GetOloc() - 4; - element->SetDrawingY( element->GetDrawingY() + CalculatePitchPosY( staff, accid->GetPloc(), layer->GetClefOffset( list_elem ), oct) ); + // Parent will be NULL if we are drawing a note @accid (see DrawNote) - the y value is already set + if ( accid->m_parent ) { + int oct = accid->GetOloc() - 4; + element->SetDrawingY( element->GetDrawingY() + CalculatePitchPosY( staff, accid->GetPloc(), layer->GetClefOffset( accid ), oct) ); + } int x = element->GetDrawingX(); int y = element->GetDrawingY(); @@ -1422,15 +1299,13 @@ void View::DrawAccid( DeviceContext *dc, LayerElement *element, Layer *layer, St case ACCIDENTAL_EXPLICIT_fu : symc= SMUFL_E267_accidentalNaturalFlat; break; // Same default : break; } - DrawSmuflCode ( dc, x, y, symc, staff->staffSize, accid->m_cueSize ); + DrawSmuflCode ( dc, x, y, symc, staff->staffSize, accid->m_cueSize ); - dc->EndGraphic(element, this ); - } -void View::DrawCustos( DeviceContext *dc, LayerElement *element, Layer *layer, Staff *staff ) +void View::DrawCustos( DeviceContext *dc, LayerElement *element, Layer *layer, Staff *staff, Measure *measure ) { assert(layer); // Pointer to layer cannot be NULL" assert(staff); // Pointer to staff cannot be NULL" @@ -1454,7 +1329,7 @@ void View::DrawCustos( DeviceContext *dc, LayerElement *element, Layer *layer, S } -void View::DrawDot( DeviceContext *dc, LayerElement *element, Layer *layer, Staff *staff ) +void View::DrawDot( DeviceContext *dc, LayerElement *element, Layer *layer, Staff *staff, Measure *measure ) { assert(layer); // Pointer to layer cannot be NULL" assert(staff); // Pointer to staff cannot be NULL" @@ -1475,11 +1350,25 @@ void View::DrawDot( DeviceContext *dc, LayerElement *element, Layer *layer, Staf } -void View::DrawSyl( DeviceContext *dc, Syl *syl, int verseNb, LayerElement *element, Layer *layer, Staff *staff ) +void View::DrawSyl( DeviceContext *dc, LayerElement *element, Layer *layer, Staff *staff, Measure *measure ) { + Syl *syl = dynamic_cast(element); + + int verseNb = 1; + Verse *verse = dynamic_cast( element->GetFirstParent( &typeid(Verse), MAX_NOTE_DEPTH ) ); + if ( verse ) { + verseNb = std::max(verse->GetN(), 1); + } + + Note *note = dynamic_cast( element->GetFirstParent( &typeid(Note), MAX_NOTE_DEPTH ) ); + if ( !note ) { + LogDebug("Syl parent note could not be found"); + return; + } + // to be updated - int x = element->GetDrawingX() - m_doc->m_drawingUnit * 2; - int y = element->GetDrawingY(); + int x = note->GetDrawingX() - m_doc->m_drawingUnit * 2; + int y = note->GetDrawingY(); if (staff->GetAlignment() ) { y = staff->GetDrawingY() + staff->GetAlignment()->GetMaxHeight() - verseNb * m_doc->m_drawingUnit * 4; } @@ -1489,15 +1378,15 @@ void View::DrawSyl( DeviceContext *dc, Syl *syl, int verseNb, LayerElement *elem } -void View::DrawVerse( DeviceContext *dc, Verse *verse, LayerElement *element, Layer *layer, Staff *staff ) +void View::DrawVerse( DeviceContext *dc, LayerElement *element, Layer *layer, Staff *staff, Measure *measure ) { - if (verse->GetChildCount( &typeid(Syl) ) ) { - DrawSyl(dc, dynamic_cast( verse->GetFirst( &typeid(Syl) ) ), std::max(verse->GetN(), 1), element, layer, staff ); - } + Verse *verse = dynamic_cast(element); + + DrawLayerChildren(dc, verse, layer, staff, measure); } -void View::DrawKeySig( DeviceContext *dc, LayerElement *element, Layer *layer, Staff *staff ) +void View::DrawKeySig( DeviceContext *dc, LayerElement *element, Layer *layer, Staff *staff, Measure *measure ) { assert(layer); // Pointer to layer cannot be NULL" assert(staff); // Pointer to staff cannot be NULL" @@ -1764,44 +1653,3 @@ void View::DrawTrill(DeviceContext *dc, LayerElement *element, Staff *staff) { } // namespace vrv -/* - * Lyric code not refactored in ax2 - -void Note1::DeleteLyricFromNote( Symbol1 *lyric ) -{ - for ( int i = 0; i < (int)this->m_lyrics.GetCount(); i++ ){ - Symbol1 *tmp = &this->m_lyrics[i]; - if ( lyric == tmp ){ - this->m_lyrics.RemoveAt( i ); - break; - } - } -} - -Symbol1 *Note1::GetFirstLyric( ) -{ - if ( this->m_lyrics.GetCount() == 0 ) - return NULL; - else - return &this->m_lyrics[0]; -} - -Symbol1 *Note1::GetLastLyric( ) -{ - int num = this->m_lyrics.GetCount(); - if ( num == 0 ) - return NULL; - else - return &this->m_lyrics[num-1]; -} - -Symbol1 *Note1::GetLyricNo( int no ) -{ - int num = this->m_lyrics.GetCount(); - if ( (no < 0) || (num <= no) ) - return NULL; - else - return &this->m_lyrics[no]; -} - -*/ diff --git a/src/view_page.cpp b/src/view_page.cpp index 562dd08829c..3779feb57d2 100644 --- a/src/view_page.cpp +++ b/src/view_page.cpp @@ -88,10 +88,6 @@ void View::DrawSystem( DeviceContext *dc, System *system ) { assert( system ); // other asserted before - Measure *measure = NULL; - ScoreDef *scoreDef = NULL; - EditorialElement *editorialElement = NULL; - dc->StartGraphic( system, "", system->GetUuid() ); @@ -107,33 +103,14 @@ void View::DrawSystem( DeviceContext *dc, System *system ) system->SetDrawingY( system->m_yAbs ); } - Object* current; - for (current = system->GetFirst( ); current; current = system->GetNext( ) ) - { - measure = dynamic_cast(current); - scoreDef = dynamic_cast(current); - editorialElement = dynamic_cast(current); - if (measure) { - DrawMeasure( dc , measure, system ); - } - else if (editorialElement) { - DrawEditorialElement( dc , editorialElement, system ); - } - // scoreDef are not drawn directly, but anything else should not be possible - else if (scoreDef) { - m_drawingScoreDef.Replace(scoreDef); - } - else { - assert(false); - } - } + DrawSystemChildren(dc, system, system); // We draw the groups after the staves because we use the m_drawingY member of the staves // that needs to be intialized. // Warning: we assume for now the scoreDef occuring in the system will not change the staffGrps content // and @symbol values, otherwise results will be unexpected... // First get the first measure of the system - measure = dynamic_cast(system->FindChildByType( &typeid(Measure) ) ); + Measure *measure = dynamic_cast(system->FindChildByType( &typeid(Measure) ) ); if ( measure ) { // NULL for the Barline parameters indicates that we are drawing the scoreDef DrawScoreDef( dc, &m_drawingScoreDef, measure, system->GetDrawingX(), NULL ); @@ -592,9 +569,6 @@ void View::DrawMeasure( DeviceContext *dc, Measure *measure, System *system ) { assert( dc ); // DC cannot be NULL - Staff *staff = NULL; - EditorialElement *editorialElement = NULL; - // This is a special case where we do not draw (SVG, Bounding boxes, etc.) the measure if un-measured music if ( measure->IsMeasuredMusic()) { dc->StartGraphic( measure, "", measure->GetUuid() ); @@ -613,21 +587,7 @@ void View::DrawMeasure( DeviceContext *dc, Measure *measure, System *system ) measure->SetDrawingX( measure->m_xAbs ); } - Object* current; - for (current = measure->GetFirst( ); current; current = measure->GetNext( ) ) - { - staff = dynamic_cast(current); - editorialElement = dynamic_cast(current); - if (staff) { - DrawStaff( dc, staff, measure, system ); - } - else if (editorialElement) { - DrawEditorialElement( dc , editorialElement, measure, system ); - } - else { - assert(false); - } - } + DrawMeasureChildren(dc, measure, measure, system); if ( measure->GetLeftBarlineType() != BARRENDITION_NONE) { DrawScoreDef( dc, &m_drawingScoreDef, measure, measure->GetDrawingX(), measure->GetLeftBarline() ); @@ -700,9 +660,6 @@ void View::DrawStaff( DeviceContext *dc, Staff *staff, Measure *measure, System { assert( dc ); // DC cannot be NULL - Layer *layer = NULL; - EditorialElement *editorialElement = NULL; - dc->StartGraphic( staff, "", staff->GetUuid()); // Here we set the appropriate y value to be used for drawing @@ -723,22 +680,8 @@ void View::DrawStaff( DeviceContext *dc, Staff *staff, Measure *measure, System DrawStaffLines( dc, staff, measure, system ); - Object* current; - for (current = staff->GetFirst( ); current; current = staff->GetNext( ) ) - { - layer = dynamic_cast(current); - editorialElement = dynamic_cast(current); - if (layer) { - DrawLayer( dc, layer, staff, measure ); - } - else if (editorialElement) { - DrawEditorialElement( dc , editorialElement, staff, measure ); - } - else { - assert(false); - } - } - + DrawStaffChildren(dc, staff, staff, measure); + dc->EndGraphic( staff, this ); } @@ -861,15 +804,13 @@ MusPoint CalcPositionAfterRotation( MusPoint point , float rot_alpha, MusPoint c void View::DrawLayer( DeviceContext *dc, Layer *layer, Staff *staff, Measure *measure) { assert( dc ); // DC cannot be NULL - - LayerElement *element = NULL; - EditorialElement *editorialElement = NULL; dc->StartGraphic( layer, "", layer->GetUuid()); // first we need to clear the drawing list of postponed elements layer->ResetDrawingList(); + // the draw the scoreDef when required if (layer->GetDrawingClef()) { DrawElement(dc, layer->GetDrawingClef(), layer, staff, measure); } @@ -883,21 +824,7 @@ void View::DrawLayer( DeviceContext *dc, Layer *layer, Staff *staff, Measure *me DrawElement(dc, layer->GetDrawingMeterSig(), layer, staff, measure); } - Object* current; - for (current = layer->GetFirst( ); current; current = layer->GetNext( ) ) - { - element = dynamic_cast(current); - editorialElement = dynamic_cast(current); - if (element) { - DrawElement( dc, element, layer, staff, measure ); - } - else if (editorialElement) { - DrawEditorialElement( dc , editorialElement, layer, staff, measure ); - } - else { - assert(false); - } - } + DrawLayerChildren(dc, layer, layer, staff, measure); // first draw the beams DrawLayerList(dc, layer, staff, measure, &typeid(Beam) ); @@ -908,9 +835,7 @@ void View::DrawLayer( DeviceContext *dc, Layer *layer, Staff *staff, Measure *me // then slurs DrawLayerList(dc, layer, staff, measure, &typeid(Slur) ); - dc->EndGraphic( layer, this ); - } @@ -931,13 +856,13 @@ void View::DrawLayerList( DeviceContext *dc, Layer *layer, Staff *staff, Measure if ( (typeid(*element) == *elementType) && (*elementType == typeid(Beam) ) ) { Beam *beam = dynamic_cast(element); dc->ResumeGraphic(beam, beam->GetUuid()); - DrawBeam( dc, layer, beam, staff ); + DrawBeamPostponed( dc, layer, beam, staff ); dc->EndResumedGraphic(beam, this); } else if ( (typeid(*element) == *elementType) && (*elementType == typeid(Tuplet) ) ) { Tuplet *tuplet = dynamic_cast(element); dc->ResumeGraphic(tuplet, tuplet->GetUuid()); - DrawTuplet( dc, tuplet, layer, staff ); + DrawTupletPostponed( dc, tuplet, layer, staff ); dc->EndResumedGraphic(tuplet, this); } else if ( (typeid(*element) == *elementType) && (*elementType == typeid(Tie) ) ) { @@ -951,25 +876,18 @@ void View::DrawLayerList( DeviceContext *dc, Layer *layer, Staff *staff, Measure } } - //---------------------------------------------------------------------------- -// View - Editorial +// View - Children //---------------------------------------------------------------------------- -void View::DrawEditorialElement( DeviceContext *dc, EditorialElement *element, System *system ) +void View::DrawSystemChildren( DeviceContext *dc, Object *parent, System *system ) { - if ( dynamic_cast(element) ) { - assert( dynamic_cast(element)->GetLevel() == EDITORIAL_SYSTEM ); - } - - dc->StartGraphic( element, "", element->GetUuid()); - Measure *measure = NULL; ScoreDef *scoreDef = NULL; EditorialElement *editorialElement = NULL; Object* current; - for (current = element->GetFirst( ); current; current = element->GetNext( ) ) + for (current = parent->GetFirst( ); current; current = parent->GetNext( ) ) { measure = dynamic_cast(current); scoreDef = dynamic_cast(current); @@ -978,7 +896,7 @@ void View::DrawEditorialElement( DeviceContext *dc, EditorialElement *element, S DrawMeasure( dc , measure, system ); } else if (editorialElement) { - DrawEditorialElement( dc , editorialElement, system ); + DrawSystemEditorialElement( dc , editorialElement, system ); } // scoreDef are not drawn directly, but anything else should not be possible else if (scoreDef) { @@ -988,23 +906,15 @@ void View::DrawEditorialElement( DeviceContext *dc, EditorialElement *element, S assert(false); } } - - dc->EndGraphic( element, this ); } -void View::DrawEditorialElement( DeviceContext *dc, EditorialElement *element, Measure *measure, System *system ) +void View::DrawMeasureChildren( DeviceContext *dc, Object *parent, Measure *measure, System *system ) { - if ( dynamic_cast(element) ) { - assert( dynamic_cast(element)->GetLevel() == EDITORIAL_MEASURE ); - } - - dc->StartGraphic( element, "", element->GetUuid()); - Staff *staff = NULL; EditorialElement *editorialElement = NULL; Object* current; - for (current = element->GetFirst( ); current; current = element->GetNext( ) ) + for (current = parent->GetFirst( ); current; current = parent->GetNext( ) ) { staff = dynamic_cast(current); editorialElement = dynamic_cast(current); @@ -1012,29 +922,21 @@ void View::DrawEditorialElement( DeviceContext *dc, EditorialElement *element, M DrawStaff( dc , staff, measure, system ); } else if (editorialElement) { - DrawEditorialElement( dc , editorialElement, measure, system ); + DrawMeasureEditorialElement( dc , editorialElement, measure, system ); } else { assert(false); } } - - dc->EndGraphic( element, this ); } - -void View::DrawEditorialElement( DeviceContext *dc, EditorialElement *element, Staff *staff, Measure *measure ) + +void View::DrawStaffChildren( DeviceContext *dc, Object *parent, Staff *staff, Measure *measure ) { - if ( dynamic_cast(element) ) { - assert( dynamic_cast(element)->GetLevel() == EDITORIAL_STAFF ); - } - - dc->StartGraphic( element, "", element->GetUuid()); - Layer *layer = NULL; EditorialElement *editorialElement = NULL; Object* current; - for (current = element->GetFirst( ); current; current = element->GetNext( ) ) + for (current = parent->GetFirst( ); current; current = parent->GetNext( ) ) { layer = dynamic_cast(current); editorialElement = dynamic_cast(current); @@ -1042,29 +944,21 @@ void View::DrawEditorialElement( DeviceContext *dc, EditorialElement *element, S DrawLayer( dc , layer, staff, measure ); } else if (editorialElement) { - DrawEditorialElement( dc , editorialElement, staff, measure ); + DrawStaffEditorialElement( dc , editorialElement, staff, measure ); } else { assert(false); } } - - dc->EndGraphic( element, this ); } -void View::DrawEditorialElement( DeviceContext *dc, EditorialElement *element, Layer *layer, Staff *staff, Measure *measure ) +void View::DrawLayerChildren( DeviceContext *dc, Object *parent, Layer *layer, Staff *staff, Measure *measure ) { - if ( dynamic_cast(element) ) { - assert( dynamic_cast(element)->GetLevel() == EDITORIAL_LAYER ); - } - - dc->StartGraphic( element, "", element->GetUuid()); - LayerElement *layerElement = NULL; EditorialElement *editorialElement = NULL; Object* current; - for (current = element->GetFirst( ); current; current = element->GetNext( ) ) + for (current = parent->GetFirst( ); current; current = parent->GetNext( ) ) { layerElement = dynamic_cast(current); editorialElement = dynamic_cast(current); @@ -1072,13 +966,60 @@ void View::DrawEditorialElement( DeviceContext *dc, EditorialElement *element, L DrawElement( dc, layerElement, layer, staff, measure ); } else if (editorialElement) { - DrawEditorialElement( dc , editorialElement, layer, staff, measure ); + DrawLayerEditorialElement( dc , editorialElement, layer, staff, measure ); } else { assert(false); } } +} + + +//---------------------------------------------------------------------------- +// View - Editorial +//---------------------------------------------------------------------------- + +void View::DrawSystemEditorialElement( DeviceContext *dc, EditorialElement *element, System *system ) +{ + if ( dynamic_cast(element) ) { + assert( dynamic_cast(element)->GetLevel() == EDITORIAL_SYSTEM ); + } + + dc->StartGraphic( element, "", element->GetUuid()); + DrawSystemChildren( dc, element, system); + dc->EndGraphic( element, this ); +} + +void View::DrawMeasureEditorialElement( DeviceContext *dc, EditorialElement *element, Measure *measure, System *system ) +{ + if ( dynamic_cast(element) ) { + assert( dynamic_cast(element)->GetLevel() == EDITORIAL_MEASURE ); + } + dc->StartGraphic( element, "", element->GetUuid()); + DrawMeasureChildren(dc, element, measure, system); + dc->EndGraphic( element, this ); +} + +void View::DrawStaffEditorialElement( DeviceContext *dc, EditorialElement *element, Staff *staff, Measure *measure ) +{ + if ( dynamic_cast(element) ) { + assert( dynamic_cast(element)->GetLevel() == EDITORIAL_STAFF ); + } + + dc->StartGraphic( element, "", element->GetUuid()); + DrawStaffChildren(dc, element, staff, measure); + dc->EndGraphic( element, this ); +} + +void View::DrawLayerEditorialElement( DeviceContext *dc, EditorialElement *element, Layer *layer, Staff *staff, Measure *measure ) +{ + if ( dynamic_cast(element) ) { + assert( dynamic_cast(element)->GetLevel() == EDITORIAL_LAYER ); + } + + dc->StartGraphic( element, "", element->GetUuid()); + DrawLayerChildren(dc, element, layer, staff, measure); dc->EndGraphic( element, this ); } diff --git a/src/view_tuplet.cpp b/src/view_tuplet.cpp index 360409c0384..ddc136bfc93 100644 --- a/src/view_tuplet.cpp +++ b/src/view_tuplet.cpp @@ -45,9 +45,8 @@ bool View::OneBeamInTuplet(Tuplet* tuplet) { ArrayOfObjects elems; // Are we contained in a beam? - if (dynamic_cast(tuplet->GetFirstParent(&typeid(Beam), 3)) && !tuplet->m_children.empty()) + if (dynamic_cast(tuplet->GetFirstParent(&typeid(Beam), MAX_BEAM_DEPTH)) && !tuplet->m_children.empty()) return true; - // No we contain a beam? Go on and search for it in the children for (unsigned int i = 0; i < tuplet->m_children.size(); i++) { @@ -252,7 +251,7 @@ bool View::GetTupletCoordinates(Tuplet* tuplet, Layer *layer, MusPoint* start, M } -void View::DrawTuplet( DeviceContext *dc, Tuplet *tuplet, Layer *layer, Staff *staff) +void View::DrawTupletPostponed( DeviceContext *dc, Tuplet *tuplet, Layer *layer, Staff *staff) { assert(layer); // Pointer to layer cannot be NULL" assert(staff); // Pointer to staff cannot be NULL"