Exemplo n.º 1
0
/** \brief Returns a page corresponding to a time position.

	It finds the musical element which time position is immediately before or equal to
	the input time position. Then it returns the page of that musical element.

	getPageForTimePos() always try to return a page, while getPageNum() only returns
	a page when the input time position match the time position of an existing
	musical element.

	TODO: Check if the page keeps track of both its start timepos and end timepos,
			therefore we could directly jump from one page to another


	\bug The last system of a page point to the next page instead of its parent page.

*/
GRPage * GRVoice::getPageForTimePos( int num, int denom ) const
{
    GRPage * outPage = 0;
    TYPE_TIMEPOSITION inTime ( num, denom );
    GuidoPos pos = First();

    // - Find the event which best match the input date
    GREvent * bestEv = 0;
    while (pos)
    {
        GRNotationElement * el = GetNext(pos);
        GREvent * ev = GREvent::cast(el);
        if( ev )
        {
            const TYPE_TIMEPOSITION & currTime = ev->getRelativeTimePosition();
            if( currTime <= inTime )
                bestEv = ev;
            else
                break;	// (JB) I suppose that all next elements have a greater time pos.
        }
    }

    // - Get the page corresponding to the event found

    if( bestEv )
    {
        GRStaff * staff = bestEv->getGRStaff();
        GRSystem * sys = staff->getGRSystem();
        outPage = sys->getGRPage();
    }

    return outPage;
}
Exemplo n.º 2
0
GRPage * GRVoice::getPageNum(int num,int denom)
{
    // I have to travers the voice and find the element
    // at the position num/denom. Then I have to find the
    // pagenumber of that element.

    const TYPE_TIMEPOSITION tpsearch ( num,denom );
    GuidoPos pos = First();
    while (pos)
    {
        GRNotationElement * el = GetNext(pos);
        GREvent * ev = GREvent::cast(el);
        if (ev)
        {
            if (ev->getRelativeTimePosition() == tpsearch)
            {
                GRStaff * stf = ev->getGRStaff();
                GRSystem * sys = stf->getGRSystem();
                GRPage * page = sys->getGRPage();
                return page;
            }
            else if (ev->getRelativeTimePosition() > tpsearch)
                return NULL;
        }
    }
    return NULL;
}
Exemplo n.º 3
0
//____________________________________________________________________________________
char * GRSingleNote::getGGSInfo( int infotype ) const
{
	// now we find out, where the next spring is ....
	// our sprid is set ....
	const GRSpring * prevspring = mGrStaff->getGRSystem()->getGRSpring(mSpringID - 1);
	const GRSpring * nextspring = mGrStaff->getGRSystem()->getGRSpring(mSpringID + 1);

	const GRSpring * myspring   = mGrStaff->getGRSystem()->getGRSpring(mSpringID);

	int left = (int)myspring->posx;
	int right = (int)myspring->posx;

	if (prevspring)	left = (int)prevspring->posx;
	if (nextspring)	right = (int)nextspring->posx;

	char * buf = new char[100];

	GRSystem * cursystem = mGrStaff->getGRSystem();

#ifdef VC2005
	snprintf(buf, 100, 100, "%d,%d,%d,%d,%ld,%d,%ld,%d\n",
		(int)cursystem->getGRPage()->getMarginLeft(),
		(int)cursystem->getPosition().x,
		(int)mPosition.x,
		(int)myspring->posx,
		(long int)prevspring,
		(int)left,
		(long int)nextspring,	// <- !!! pointer to int !!!
		(int)right);
#else
	snprintf(buf, 100, "%d,%d,%d,%d,%ld,%d,%ld,%d\n",
		(int)cursystem->getGRPage()->getMarginLeft(),
		(int)cursystem->getPosition().x,
		(int)mPosition.x,
		(int)myspring->posx,
		(long int)prevspring,
		(int)left,
		(long int)nextspring,	// <- !!! pointer to int !!!
		(int)right);
#endif
	return buf;
}