GSoC: Week 3

Posted 7 years ago

Achievements/Goals

I was able to fix most of the issues out here for the new excerpts creation implementation. Main changes have been the _tracks (a QMap for better storage usage and speed) as an attribute of every excerpt and the _excerpt for scores and staves of an excerpt. These attributes make it quite easy to check which tracks of the main score are mapped to which track in the excerpt. They make it also easy to check whether the excerpt consists of completely filled staves, that means every stave is filled and connected to all four voices of it’s source stave.
To keep this track mapping after a save operation it has to be exported. This was achieved by creating a new XML tag:
Tracklist sTrack=”s” dstTrack =”d"

This is only saved if the excerpt does have a not completely filled stave, so in fact if the excerpt is created with the new tool. Otherwise there won’t be a tag for the track mapping of the excerpt. If there is no such tag the excerpt is interpreted to behave like it was created with the 2.0.3 excerptsdialog and fills _tracks according to the number of staves as proposed last week, so every voice of the source is mapped to a voice of the destination.
In some places there had to be done more checking on the actual track. For example if you are adding a note in the the masterScore it isn’t enough to just update every excerpt you first have to check if the source track is mapped to something in the excerpt. Here was a problem, that the QMap gives back on a call like _tracks.value(srcTrack) the value 0. But for us this value is already assigned to voice 1 of top staff. But there is a way to easily give the method value() (and the method key() which is the other way round) a default value, which was -1 in our case.

So in the undoAddElement and undoAddCR implementation we first check whether we are in an excerpt then map the track to the corresponding track of the mainScore and if we are already in the mainScore use the actual track. This track is used to determine the destination track in the excerpts, so we can do this quite simple by just using trackList(sTrack, -1) and check if it’s -1 and if not we already have the destination track.

A big problem was to add an instrument in the middle of the mainScore, because it breaks the track mapping, the advantage of the QMap method is that we can use simple arithmetic to calculate the new mapping for every instrument. Another in the end easy to solve problem was the exchangevoices tool which would have made changes to the excerpts because suddenly there could have be a voice 3 where before just was a voice 1. So we decided to change the behavior in case of an excerpt. If one of the voices which should swap isn’t mapped to a track, we do nothing but change the the mapping, so all notes will remain in the excerpt and are linked to the correct voice in the mainScore. If we have an excerpt and want to exchange with a voice which isn’t in the excerpt, we do nothing at all.
There has also been a problem with multimeasure rests, but this was easily resolved by asking for the parent of a measure. If the measure is in a mm rest it doesn’t have a parent and we wouldn’t find one if we refer to it, so better don’t do it and anyway, if we would have made some changes to this it wouldn’t make sense.

The last big problems have been the tests, most of them have been fixed by implementing things correctly, but some are still referred to the gaps implementation of last week, so they have been fixed after some additional work. The tests which are creating excerpts for themselves have been updated to do this correctly with the new implementation.

Outlook

For the next week, I’ll wait for some feedback on the actual implementation and start parallel to this with a new excerptsdialog in which you can select the voices you want directly. For more information on how I’m going to do this look at my forum post here.

My actual PR.

Until next week,
Felix