Elements property on segment
Hello,
being rather new to MuseScore and in particular to writing plugins, I wanted a simple means to traverse a score along measures, segments and elements BasicMuse. According to segment.h
, "A segment holds all vertical aligned staff elements." Would it be not easily be possible to add a:
const std::vector<EngravingItem*>& elements() const
and make it available in the plugin API? Ideally, I would then like to filter as needed:
chords = segment.elements.filter(element => element.type === Muse.ElementType.CHORD);
and process the result.
BTW: segment.h
also says: "Segments are typed and contain only Elements of the same type.". Is there a reason why Segment
is not implemented as a generic class, e.g.:
template <typename T> class Segment : public EngravingItem { private: std::vector<T*> m_elements; // List to store elements of type T (derived from EngravingItem) public: const std::vector<EngravingItem*>& elements() const { return m_elements } };
And then, when needed instantiate a new Segment
for example.
Comments
For the future , you might get a quicker and more expert response on the special forum titled Plugins:
https://musescore.org/en/forum/443
In reply to For the future , you might… by DanielR
Thanks, I was not quite sure where to post; since I am asking for a C++ class field to be exposed as a public interface and then made available in the plugin, as a feature, I felt that here would be a better place. The Plugin form is more on writing plugins given a certain API.