Exemplo n.º 1
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;
    }
}
Exemplo n.º 2
0
/** Adds a slice to the current slice-height we are friends 
	of GRSystemSlice so we can directly access the staves.
*/
void GRSliceHeight::AddSystemSlice( const GRSystemSlice * slc, bool doboundingrect )
{
	if (slc == 0) return;
	int j;
	int first = 1;

	float laststaffposy = 0;
	float lastvectposy = 0;
	float staffposy = 0;
	float vectposy = 0;
	float cury = 0;

	for (j=slc->mStaffs->GetMinimum();j<=slc->mStaffs->GetMaximum();++j)
	{		
		GRStaff * tmpstaff = slc->mStaffs->Get(j);		
		if (tmpstaff)
		{
			vectposy = mHVector.Get(j);
			float newvectposy = vectposy;
			if (!doboundingrect)
			{
				staffposy = tmpstaff->getPosition().y;
				if (first)
				{
					// The first one just saves the part
					// below ... the upper bounding rectangle
					// is not concerned.
					first = 0;
				}
				else
				{
					if (staffposy - laststaffposy > vectposy - lastvectposy)
					{
						newvectposy = lastvectposy + staffposy - laststaffposy;
						mHVector.Set(j,float(newvectposy));
					}
				}
				
				laststaffposy = staffposy;
				lastvectposy = newvectposy;
			}
			else
			{
				// we do the bounding-rectangle thing ...
				// this is actually not needed here : the bounding box update is
				// already computed by GRSystemSlice::Finish
//				tmpstaff->updateBoundingBox();
				// the boundingBoxPreview method has been temporary use here to test code restructuration
//				tmpstaff->boundingBoxPreview();
				const NVRect & myrect = tmpstaff->getBoundingBox();
				if (!first)
				{
					if (cury - myrect.top > vectposy)
						mHVector.Set(j, float(cury - myrect.top));
					
					cury += myrect.Height();
				}
				else 
				{
					first = 0;
					cury = myrect.bottom;
				}
			}

			if (j == slc->mStaffs->GetMaximum())
			{
				float tmpbr = tmpstaff->getBoundingBox().bottom;
				if (tmpbr > boundingRectBottom)
					boundingRectBottom = tmpbr;

			}
			if (j == slc->mStaffs->GetMinimum())
			{
				float tmpbr = tmpstaff->getBoundingBox().top;
				if (tmpbr < boundingRectTop)
					boundingRectTop = tmpbr;
			}
		}
	}

	if (doboundingrect)
	{
		// it might be that the slice is a beginning slice
		// that has not yet set the staff positions,
		// in this case we have to set the minimum height

		float tmpheight = float(slc->getBoundingBox().Height());
		if (getHeight() < tmpheight)
		{
			minHeight = tmpheight;
		}
	}
}