//-------------------------------------------------------------------- NVPoint GRBeam::initp0 (GRSystemStartEndStruct * sse, const GREvent * startEl, PosInfos& infos) { // -- Init point 0 (top left) GRBeamSaveStruct * st = (GRBeamSaveStruct *)sse->p; const ARBeam * arBeam = getARBeam(); GRStaff * refStaff; NVPoint offset; if (startEl) { st->p[0] = startEl->getStemStartPos(); if (arBeam && arBeam->isGuidoSpecBeam()) st->p[0].y = startEl->getPosition().y; refStaff = startEl->getGRStaff(); infos.stemdir = startEl->getStemDirection(); infos.currentSize = startEl->getSize(); } else { st->p[0] = sse->startElement->getPosition(); infos.currentSize = 1.0f; refStaff = sse->startElement->getGRStaff(); } offset = refStaff->getPosition(); if (tagtype == SYSTEMTAG) st->p[0] += offset; infos.currentLSPACE = refStaff->getStaffLSPACE(); st->p[1] = st->p[0]; // -- Adjust point 0 if (arBeam->dx1 && arBeam->dx1->TagIsSet()) st->p[0].x += (GCoord)(arBeam->dx1->getValue(infos.currentLSPACE)); else { // This depends on the direction, we do not know this yet (do we?) if (infos.oneNote) { double result; bool conversionOk = TagParameterFloat::convertValue(2.0f, result, "hs", infos.currentLSPACE); if (conversionOk) st->p[0].x -= (float)result * infos.currentSize; } } if (arBeam->dy1 && arBeam->dy1->TagIsSet()) st->p[0].y -= (arBeam->dy1->getValue(infos.currentLSPACE)); return offset; }
//-------------------------------------------------------------------- NVPoint GRBeam::initp2 (GRSystemStartEndStruct * sse, const GREvent * endEl, PosInfos& infos) { // -- Init point 2 (top right) GRBeamSaveStruct * st = (GRBeamSaveStruct *)sse->p; const ARBeam * arBeam = getARBeam(); GRStaff * refStaff; NVPoint offset; if (endEl) { st->p[2] = endEl->getStemEndPos(); // beam length adjustment - DF sept 15 2009 st->p[2].x += infos.currentLSPACE/10; if (arBeam && arBeam->isGuidoSpecBeam()) st->p[2].y = endEl->getPosition().y; refStaff = endEl->getGRStaff(); } else { st->p[2] = sse->endElement->getPosition(); refStaff = sse->startElement->getGRStaff(); } offset = refStaff->getPosition(); if (tagtype == SYSTEMTAG) st->p[2] += offset; infos.currentLSPACE = refStaff->getStaffLSPACE(); st->p[3] = st->p[2]; // -- Adjust point 2 if (arBeam->dx3) st->p[2].x += arBeam->dx3->getValue(infos.currentLSPACE); if (arBeam->dy3 && arBeam->dy3->TagIsSet()) st->p[2].y -= arBeam->dy3->getValue(infos.currentLSPACE); else { GCoord val = 0; if (arBeam->dy1 && arBeam->dy1->TagIsSet()) val = arBeam->dy1->getValue(infos.currentLSPACE); st->p[2].y -= val; } return offset; }
/** 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; } } }
// ---------------------------------------------------------------------------- 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; } }