Help with adaption of SVG export
Hello,
For a project I need to extend the SVG export with additional information. My goal is to extend the "class=" label in the SVG for certain classes. An example would be: class="Note, Pitch:77, Duration:Quarter" or class="Rest, Duration: Half"
After a while I managed to compile MuseScore-2.1 myself, but I have no experience in Programming C++.
My startingpoint is the function getClass in svggenerator.cpp:
static QString getClass(const Ms::Element *e)
{
Ms::ElementType eType;
QString eName;
// Add element type as "class"
if (e == NULL)
return eName; // e should never be null, this is extra-cautious
eType = e->type();
eName = e->name(eType);
// Future sub-typing code goes here
##pseudo code by myself
if eName == "Note":
actNote = e as Note // I have no idea how to do this cast in C++
actPitch = actNote.pitch
actDuration = actNote.duration
if eName == "Rest":
actRest = e as Rest
actDuration = actRest.duration
##
return eName ##add pitch and duration to eName.;
}
I added a bit of pseudo code to illustrate what I want to do. Can someone help me and show me how I can access the Pitch of an element if the element is actually a Note aswell as it's duration?
I am deeply thankful for all help since I unfortunately have not enough time to get all the necessary C++ experience.
Comments
See also https://musescore.org/en/node/185321
If anyone will ever need this functionality too:
I managed to achieve my goal by simply using the accessibleInfo() function on certain elements.