bool MuseScore::importPdf(Score* score, const QString& path) { Omr* omr = new Omr(path, score); if (!omr->readPdf()) { delete omr; return false; } score->setOmr(omr); qreal sp = omr->spatiumMM(); if (sp == 0.0) sp = 1.5; score->setSpatium(sp * DPMM); score->style()->set(StyleVal(ST_pageFillLimit, 1.0)); score->style()->set(StyleVal(ST_lastSystemFillLimit, 0.0)); score->style()->set(StyleVal(ST_staffLowerBorder, 0.0)); score->style()->set(StyleVal(ST_measureSpacing, 1.0)); PageFormat pF(*score->pageFormat()); pF.setEvenLeftMargin(5.0 * DPMM / DPI); pF.setEvenTopMargin(0); pF.setEvenBottomMargin(0); pF.setOddLeftMargin(5.0 * DPMM / DPI); pF.setOddTopMargin(0); pF.setOddBottomMargin(0); score->setPageFormat(pF); score->style()->set(StyleVal(ST_systemDistance, Spatium(omr->systemDistance()))); score->style()->set(StyleVal(ST_akkoladeDistance, Spatium(omr->staffDistance()))); Part* part = new Part(score); Staff* staff = new Staff(score, part, 0); part->staves()->push_back(staff); score->staves().insert(0, staff); staff = new Staff(score, part, 1); part->staves()->push_back(staff); score->staves().insert(1, staff); part->staves()->front()->setBarLineSpan(part->nstaves()); score->insertPart(part, 0); TDuration d(TDuration::V_MEASURE); Measure* measure = 0; int tick = 0; foreach(const OmrPage* omrPage, omr->pages()) { int nsystems = omrPage->systems().size(); int n = nsystems == 0 ? 1 : nsystems; for (int k = 0; k < n; ++k) { int numMeasures = 1; if (k < nsystems) { const OmrSystem& omrSystem = omrPage->systems().at(k); numMeasures = omrSystem.barLines.size() - 1; if (numMeasures < 1) numMeasures = 1; else if (numMeasures > 50) // sanity check numMeasures = 50; } for (int i = 0; i < numMeasures; ++i) { measure = new Measure(score); measure->setTick(tick); Rest* rest = new Rest(score, d); rest->setDuration(Fraction(4,4)); rest->setTrack(0); Segment* s = measure->getSegment(SegChordRest, tick); s->add(rest); rest = new Rest(score, d); rest->setDuration(Fraction(4,4)); rest->setTrack(4); s->add(rest); score->measures()->add(measure); tick += MScore::division * 4; } if (k < (nsystems-1)) { LayoutBreak* b = new LayoutBreak(score); b->setSubtype(LAYOUT_BREAK_LINE); measure->add(b); } } if (measure) { LayoutBreak* b = new LayoutBreak(score); b->setSubtype(LAYOUT_BREAK_PAGE); measure->add(b); } } //---create bracket score->staff(0)->setBracket(0, BRACKET_AKKOLADE); score->staff(0)->setBracketSpan(0, 2); //---create clefs measure = score->firstMeasure(); if (measure) { Clef* clef = new Clef(score); clef->setClefType(CLEF_G); clef->setTrack(0); Segment* segment = measure->getSegment(SegClef, 0); segment->add(clef); clef = new Clef(score); clef->setClefType(CLEF_F); clef->setTrack(4); segment->add(clef); } score->setShowOmr(true); omr->page(0)->readHeader(score); score->rebuildMidiMapping(); return true; }