I just looked at collectPage(), and like Measure::layout2(), I wouldn't exactly call it straightforward :-) For me, right now, it's not worth entangling my code with a bunch of copying/pasting from either of those two functions. But it's good to know where to look in case I really do need to answer the question with precision. The scores that pass through this code of mine are all a single page that scrolls horizontally, like continuous view or a horizontal piano roll. The pages must be precisely sized anyway, and there are no footers or margins.

Thanks for the info.

--
Sideways

On 4/25/2016 12:58 AM, Werner Schweer wrote:
Maybe you should have a look at layout.cpp: Score::collectPage() . It calculates the visible height of systems to determine how many will
fit on a page.

Am 24.04.2016 um 19:28 schrieb Sideways Skullfinger:
This is a follow-up to my recent post about SysStaff:distanceUp/Down(). The relevant parts of that email thread are all below.

I am now doing the following to get each staff's height (I was already collecting the visibleStaves vector, now I'm using it to solve this requirement too):

/EXISTING //CODE TO COLLECT VISIBLE STAVES/
    QVector<int> visibleStaves;
    visibleStaves.resize(score->nstaves());
    int nVisible = 0;
    for (int i = 0; i < score->nstaves(); i++)
visibleStaves[i] = score->staff(i)->invisible() ? -1 : nVisible++;

/NEW //CODE TO GET STAFF TOP AND HEIGHT/
        const System* s = page->systems().value(0);
        const qreal top = s->staff(idxStaff)->y();
        const int idxVisible = (*pVisibleStaves)[idxStaff];
        qreal bot = -1;
        if (idxVisible < nVisible - 1) {
            for (int i = idxStaff + 1; i < pVisibleStaves->size(); i++) {
                if ((*pVisibleStaves)[i] > 0) {
                    bot = s->staff(i)->y();
                    break;
                }
            }
        }
        if (bot < 0)
            bot = page->height() - page->bm();

height = bot - top; It's SVG and the y-axis values increment top-to-bottom. The new code is inside a separate sub-routine, outside the scope of the visibleStaves declaration, so it has a pointer to visibleStaves.

It seems to be working well so far, though it's more complex than I would like. And using page->height() as the bottom of the last visible staff is not a real solution, it's simply something that poses no issues with for my specific SVG scores that use this code. Otherwise, determining the bottom-most visible staff's height does not seem straightforward. It would be nice to have a truly general-purpose solution to the question: *What is the full height of the bottom-most visible staff on a page?
*
Is there a straightforward way in the current master to answer that?

--
Sideways

On 4/22/2016 3:07 AM, Werner Schweer wrote:

                _distanceUp and _distanceDown are gone and will
                not come back. The staff distance is now
                calculated in System->layout2()
                and the system distance in Score->collectPage()
                which calls layoutPage().
                The distance between systems can be determined by
                looking at system->pos().y().
                SysStaff->_distanceUp/Down was used to collect
                information from layouting  elements like fret
                symbols etc. which might increase
                the staff distance. This is replaced by a more
                generic algorithm which uses the Shape of staves
                to determine the minimum distance without
                any collision.

                Am 21.04.2016 um 20:43 schrieb Sideways Skullfinger:
                I submitted this question to the list 5 days
                ago, and there has been no response, so I wanted
                to try again.  Is there a replacement for
                SysStaff::distanceUp() and distanceDown() in the
                latest master code?

                Thanks,

                Sideways

                On 4/16/2016 12:29 PM, Sideways Skullfinger wrote:

                2.0.3 source code here:
                
https://github.com/musescore/MuseScore/blob/2.0.3/libmscore/system.h#L48

                The 2.0.3 class SysStaff looks like this:

                class SysStaff {
                       QRectF _bbox;           ///< Bbox of StaffLines.
                       qreal _yOff;            ///< offset of top staff line 
within bbox
                       qreal _distanceUp;      ///< distance to previous staff
                       qreal _distanceDown;    ///< distance to next staff
                       bool _show;             ///< derived from Staff or false 
if empty
                ...

                The current master has removed these variables
                and commented-out lines where the public
                properties for these variables are called,
                sometimes with a "TODO" in the comment.

                I use SysStaff::distanceDown() and
                SysStaff::distanceUp() in my code, and now I
                have no substitute for it. What is the plan
                here? How should I be determining the distance
                between staves?

                I posted this same thing on the musescore
                forums here: https://musescore.org/en/node/106501

                Thanks,

                Sideways

------------------------------------------------------------------------------
Find and fix application performance issues faster with Applications Manager
Applications Manager provides deep performance insights into multiple tiers of
your business applications. It resolves application problems quickly and
reduces your MTTR. Get your free trial!
https://ad.doubleclick.net/ddm/clk/302982198;130105516;z
_______________________________________________
Mscore-developer mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mscore-developer

Reply via email to