示例#1
0
/** \brief Returns true if the system was added to the page false otherwise.
*/
bool GRPage::addSystem( GRSystem * inSystem, float * ioUsedSystemDistance )
{
	assert(inSystem->getGRPage() == this);
	GRSystem * lastSystem = mSystems.empty() ? 0 : mSystems.back(); // get the current last system
	const NVRect & newSystemBox = inSystem->getBoundingBox();
	
	NVPoint newPos;
	if( lastSystem ) {
		if (*ioUsedSystemDistance > 0) {
			newPos.y = lastSystem->getPosition().y + *ioUsedSystemDistance;
			*ioUsedSystemDistance = -1;
		}
		else {
			newPos.y = lastSystem->getPosition().y + lastSystem->getBoundingBox().bottom;
			// this should be handled by "springs" as well... and there should be a "minimum" distance...
			newPos.y -= newSystemBox.top;
			// the default distance ...
			// it is later distributed evenly between mSystems ...
			newPos.y += settings.systemsDistance;
		}
		m_totalsystemheight += newSystemBox.Height();
	}
	else // So this is the first system of the page
	{	
		newPos.y = - newSystemBox.top;
		m_totalsystemheight = newSystemBox.Height(); // TODO: bottom - newPos.y;
	}
	inSystem->setPosition( newPos );

	if( mSystems.empty())	mDebugPageDate = inSystem->mDebugSystemDate;
	mSystems.push_back( inSystem );
	updateBoundingBox();
	return true;
}
示例#2
0
/** \brief Draws the score page.
*/
void GRPage::OnDraw( VGDevice & hdc ) const
{	
// TODO: test if the element intersect with the clipping box
	GuidoPos pagepos = First();

	while (pagepos)
		GetNext(pagepos)->OnDraw(hdc);

	// - Convert from centimeter to logical.
	const float tstx = mLeftMargin;	// (JB) sign change
	const float tsty = mTopMargin;		// (JB) sign change

	// this resets the window-origin, so that left and top margins are correct ...
	// dont forget to set the clipping-rectangle!
	gClipRect.left -= tstx;
	gClipRect.top -= tsty;
	gClipRect.right -= tstx;
	gClipRect.bottom -= tsty;

	// The following sets the WindowOrigin so that
	// 0,0 is at the top left (including margins)
	//
	//  ---------------
	//  |    mt       |
	//  |  x-------   |
	//  |  |      | mr|
	//  |ml|      |   |
	//  |  --------   |
	//  |    mb       |
	//  |-------------|

	hdc.OffsetOrigin( tstx, tsty ); 

	GRSystem * theSystem;
	SystemPointerList::const_iterator ptr;
	for( ptr = mSystems.begin(); ptr != mSystems.end(); ++ ptr )
	{
		theSystem = *ptr;
		const NVPoint & pos = theSystem->getPosition();
		NVRect br (theSystem->getBoundingBox());
		br += pos;
			
		if( br.Collides( gClipRect ) == false )
			continue;

		gCurSystem = theSystem;
	    theSystem->OnDraw(hdc);
	}

	if (gBoundingBoxesMap & kPageBB)
		DrawBoundingBox( hdc, kPageBBColor);
	hdc.OffsetOrigin( -tstx, -tsty ); 
}
示例#3
0
// ----------------------------------------------------------------------------
void GRPage::trace(VGDevice & hdc) const
{
    NVRect r;
    cout << "Page trace - page " << r << " " << getPosition() << endl;
    cout << "    => page num systems : " << getSystems()->size() << endl;
    SystemPointerList::const_iterator ptr;
    for( ptr = getSystems()->begin(); ptr != getSystems()->end(); ++ptr ) {
        GRSystem * system = *ptr;
        r = system->getBoundingBox();
        r += system->getPosition();
        cout << "    system " << r << endl;
        SSliceList * slices = system->getSlices();

        if (slices) {
            GuidoPos pos = slices->GetHeadPosition();
            while (pos) {
                GRSystemSlice * ss = slices->GetNext(pos);
                r = ss->getBoundingBox();
                r += ss->getPosition();
                cout << "    slice " << r << endl;

                StaffVector * sv = ss->getStaves();           // get the staves list
                if (sv) {
                    for( int i = sv->GetMinimum(); i <= sv->GetMaximum(); ++i) {
                        GRStaff * staff = sv->Get(i);
                        if (staff) {
                            cout << "      - staff " << staff->getBoundingBox() << " " << staff->getPosition()  << endl;
/*                            NEPointerList * selts = staff->getElements();
                            if (selts) {
                                GuidoPos pos = selts->GetHeadPosition();
                                while (pos) {
                                    GRNotationElement * nelt = selts->GetNext(pos);
                                    if (nelt) {
                                        cout << *nelt;
                                        nelt->DrawBoundingBox (hdc, GColor(0, 0, 255));
                                    }
                                    else cout << "==> GRStaff notation element is NULL" << endl;
                                }
                            }
                            else cout << "==> GRStaff elements is NULL" << endl;
*/
                        }
                        else cout << "==> GRStaff is NULL" << endl;
                    }								
                }
                else cout << "==> StaffVector is NULL" << endl;
            }
        }
        else cout << "==> no slices in system" << endl;
    }
}
示例#4
0
/** \brief Distributes the systems of the page
	evenly .... but only, if the distance will be less than
	(10 * LSPACE) between mSystems 

	\bug does not take account of the page title .
*/
void GRPage::finishPage( bool islastpage )
{
	if (settings.systemsDistribution == kNeverDistrib) {
		SystemPointerList::iterator ptr;
		for( ptr = mSystems.begin(); ptr != mSystems.end(); ++ ptr )
			(*ptr)->FinishSystem();
		return;
	}

	const size_t systemCount = mSystems.size();
	float pagesizey = getInnerHeight();
	float dist = pagesizey - m_totalsystemheight;
	if (systemCount > 1)
		dist = dist / (float(systemCount - 1));

	if (dist > 0) {
		if ((settings.systemsDistribution == kAlwaysDistrib)
			|| (settings.systemsDistribution == kAutoDistrib) // DF added on Feb 13 2011 to force correct mapping
			|| settings.optimalPageFill
			|| (!islastpage) || (dist <= (0.1f * pagesizey)))
		{
			const float distribLimit =settings.systemsDistribLimit * pagesizey;
			if(( settings.systemsDistribution == kAutoDistrib ) && ( dist > distribLimit ))
			{
				// We are here because the distance between systems is too large
				if( false ) // islastpage )
				{
					return;
				}
				else {
					// this is auto ...
					dist = 0.075f * pagesizey; // Hardcoded
				}
			}

			// then we put the mSystems at these distances ...
			float cury = 0;
			for(SystemPointerList::iterator i = mSystems.begin(); i != mSystems.end(); i++ ) {
				GRSystem * system = *i;
				if (cury > 0) {
					NVPoint newpos;
					newpos.y = cury - system->getBoundingBox().top;
					system->setPosition( newpos );
					cury += system->getBoundingBox().Height();
				}
				else // So this is the first system. Just get its bottom.
				{
					cury += system->getPosition().y + system->getBoundingBox().bottom;
				}				
				cury += dist;
                system->FinishSystem();
			}
		}
	}
	else {
		SystemPointerList::iterator ptr;
		for( ptr = mSystems.begin(); ptr != mSystems.end(); ++ ptr )
			(*ptr)->FinishSystem();
	}
	// hack to get correct time position for the page [DF - May 26 2010]
	setRelativeTimePosition ( (*mSystems.begin())->getRelativeTimePosition() );
}