GSoC: Week 2

Posted 7 years ago

Achievements/Goals

Last week I finished working on the new gaps implementation and finished it in time. I made some final changes including renaming the trulyInvisible attribute to simply gap. By now there are still some issues with gaps but in general it seems to work properly. After I was confident the PR I created will get merged I started working on the new excerptsdialog.

My aim for the last and the next week is to get a working implementation for the New all button which creates a single excerpt for every voice of a staff and which maps the voices to voice one in the excerpt.

Implementation Details

So in every excerpt there is a voice 1 which contains the elements linked to the main score but maybe has them in a different track as the occur in the main score.
How do I do this?

First of all I added two new attributes:
- _tracks as an attribute of an excerpt
- _excerpt as an attribute of a staff

_tracks

This int-QList stores the mapping of the voices which occur in the excerpt. It always has the length of the maximum of tracks which can occur in the main score so it is possible to get the destination track by checking the value at the position of the track in the main score.

An example:

You have one staff with two voices and want to create two excerpts. The first should contain voice one and the second voice two. By creating the excerpt the tracks list is initialized, every voice which shouldn't show up in the excerpt gets the value -1 and the voices which should show up get the values of the according track in the excerpt. They are mapped thus you have the first occurring voice mapped to voice one the next to voice two and so on.
So our QList will have the following items:

_tracks[0] = 0
_tracks[1] = -1
_tracks[2] = -1
_tracks[3] = -1

for the first excerpt and

_tracks[0] = -1
_tracks[1] = 0
_tracks[2] = -1
_tracks[3] = -1

for the second.

This makes working with mapped voices a lot easier and speeds it up a lot. Calculating the mapped voices every time won't make much sense and it is much easier to read. A remaining problem is the import and export:
We can't import this attribute by now. One possibility would be to check after importing an excerpt which voices are occurring and check where they are linked to an create a map using this information, but the import is implemented recursive, so we would have to check every time we are importing an element if it is linked get the excerpt check the voices... I think this will slow down the process a lot, so my idea is to add a XML tag which gives us the links directly. For downwards compatibility _tracks should be automatically configured to map every voice to the same track if there is no such XML tag. But if there is a tag everything should be set to -1 except for the given track links of course.

_excerpt

This gives us the related excerpt for a staff. It makes working with linked staffs in the excerpts much easier, because you can easily check whether the actual staff is a staff of an excerpt or if it is in the main score (then it would be a nullptr). The second advantage is that you can get _tracks straightforward via the _excerpt.

Things that I'll have to do now is using the implementation of _tracks and _excerpt in the code and don't miss a place in code to map them correctly and to implement the XML export for the track list.

Until next week,
Felix