void test_restriccion() { Rest rojo("rojo"); Rest amarillo("Amarillo"); Rest verde("VERDE"); Rest res1((rojo.OR(amarillo)).AND(verde.NOT())); // Rest res1("(rojo | Amarillo) & !VERDE"); Conj<Caracteristica> carac; carac.Agregar("Amarillo"); // ASSERT(res1 -> Verifica(carac)); ASSERT(res1.Verifica(carac)); Rest coso("Coso"); Rest noCoso(coso.NOT()); Rest res2 = res1.AND(noCoso); carac.Agregar("Coso"); ASSERT(res1.Verifica(carac)); ASSERT(!res2.Verifica(carac)); Conj<Caracteristica> carac2; carac2.Agregar("Coso"); Rest siCoso = noCoso.NOT(); ASSERT(siCoso.Verifica(carac2)); }
void TrackList::append(Element* e) { if (e->isDurationElement()) { Fraction d = static_cast<DurationElement*>(e)->duration(); _duration += d; bool accumulateRest = e->type() == Element::REST && !isEmpty() && back()->type() == Element::REST; Segment* s = accumulateRest ? static_cast<Rest*>(e)->segment() : 0; if (s && !s->score()->isSpannerStartEnd(s->tick(), e->track())) { // akkumulate rests Rest* rest = static_cast<Rest*>(back()); Fraction d = rest->duration(); d += static_cast<Rest*>(e)->duration(); rest->setDuration(d); } else { Element* element = e->clone(); QList<Element*>::append(element); if (e->type() == Element::TUPLET) { Tuplet* srcTuplet = static_cast<Tuplet*>(e); Tuplet* dstTuplet = static_cast<Tuplet*>(element); foreach(const DurationElement* de, srcTuplet->elements()) dstTuplet->add(de->clone()); } else {
void View::DrawMensuralRest(DeviceContext *dc, LayerElement *element, Layer *layer, Staff *staff, Measure *measure) { assert(dc); assert(element); assert(layer); assert(staff); assert(measure); wchar_t charCode; Rest *rest = dynamic_cast<Rest *>(element); assert(rest); bool drawingCueSize = rest->IsCueSize(); int drawingDur = rest->GetActualDur(); int x = element->GetDrawingX(); int y = element->GetDrawingY(); switch (drawingDur) { case DUR_MX: charCode = SMUFL_E9F0_mensuralRestMaxima; break; case DUR_LG: charCode = SMUFL_E9F2_mensuralRestLongaImperfecta; break; case DUR_BR: charCode = SMUFL_E9F3_mensuralRestBrevis; break; case DUR_1: charCode = SMUFL_E9F4_mensuralRestSemibrevis; break; case DUR_2: charCode = SMUFL_E9F5_mensuralRestMinima; break; case DUR_4: charCode = SMUFL_E9F6_mensuralRestSemiminima; break; case DUR_8: charCode = SMUFL_E9F7_mensuralRestFusa; break; case DUR_16: charCode = SMUFL_E9F8_mensuralRestSemifusa; break; default: charCode = 0; // This should never happen } DrawSmuflCode(dc, x, y, charCode, staff->m_drawingStaffSize, drawingCueSize); }
void InspectorRest::setElement(Element* e) { Rest* rest = static_cast<Rest*>(e); Segment* segment = rest->segment(); iElement->setElement(rest); iSegment->setElement(segment); small->setChecked(rest->small()); }
void InspectorRest::setElement() { Rest* rest = toRest(inspector->element()); int dots = rest->dots(); dot1->setEnabled(dots > 0); dot2->setEnabled(dots > 1); dot3->setEnabled(dots > 2); dot4->setEnabled(dots > 3); tuplet->setEnabled(rest->tuplet()); InspectorElementBase::setElement(); }
void InspectorRest::dotClicked(int n) { Rest* rest = toRest(inspector->element()); if (rest == 0) return; if (rest->dots() > n) { NoteDot* dot = rest->dot(n); dot->score()->select(dot); dot->score()->update(); inspector->update(); } }
void InspectorRest::tupletClicked() { Rest* rest = toRest(inspector->element()); if (rest == 0) return; Tuplet* tuplet = rest->tuplet(); if (tuplet) { rest->score()->select(tuplet); rest->score()->update(); inspector->update(); } }
void InspectorRest::apply() { Rest* rest = static_cast<Rest*>(inspector->element()); Score* score = rest->score(); score->startCmd(); iElement->apply(); iSegment->apply(); bool val = small->isChecked(); if (val != rest->small()) score->undoChangeProperty(rest, P_SMALL, val); score->setLayoutAll(true); score->endCmd(); mscore->endCmd(); }
void Lilypond::addRest() { createMeasure(); Segment* segment = new Segment(measure); segment->setSubtype(SegChordRest); segment->setTick(tick); segment->setParent(measure); measure->add(segment); Rest* rest = new Rest(score); rest->setTrack(staff->idx() * VOICES); rest->setParent(segment); Duration d; d.setVal(curLen); rest->setDurationType(d); segment->add(rest); tick += curLen; }
void InputState::update(Element* e) { if (e == 0) return; if (e && e->type() == Element::Type::CHORD) e = static_cast<Chord*>(e)->upNote(); setDrumNote(-1); if (e->type() == Element::Type::NOTE) { Note* note = static_cast<Note*>(e); Chord* chord = note->chord(); setDuration(chord->durationType()); setRest(false); setTrack(note->track()); setNoteType(note->noteType()); setBeamMode(chord->beamMode()); } else if (e->type() == Element::Type::REST) { Rest* rest = static_cast<Rest*>(e); if (rest->durationType().type() == TDuration::DurationType::V_MEASURE) setDuration(TDuration::DurationType::V_QUARTER); else setDuration(rest->durationType()); setRest(true); setTrack(rest->track()); setBeamMode(rest->beamMode()); setNoteType(NoteType::NORMAL); } if (e->type() == Element::Type::NOTE || e->type() == Element::Type::REST) { const Instrument* instr = e->part()->instrument(); if (instr->useDrumset()) { if (e->type() == Element::Type::NOTE) setDrumNote(static_cast<Note*>(e)->pitch()); else setDrumNote(-1); } } }
void MTrack::fillGapWithRests(Score* score, int voice, const Fraction &startChordTickFrac, const Fraction &restLength, int track) { Fraction startChordTick = startChordTickFrac; Fraction restLen = restLength; while (restLen > 0) { Fraction len = restLen; Measure* measure = score->tick2measure(startChordTick.ticks()); if (startChordTick >= Fraction::fromTicks(measure->tick() + measure->ticks())) { qDebug("tick2measure: %d end of score?", startChordTick.ticks()); startChordTick += restLen; restLen = Fraction(0); break; } len = splitDurationOnBarBoundary(len, startChordTick, measure); if (len >= Fraction::fromTicks(measure->ticks())) { // rest to the whole measure len = Fraction::fromTicks(measure->ticks()); if (voice == 0) { TDuration duration(TDuration::V_MEASURE); Rest* rest = new Rest(score, duration); rest->setDuration(measure->len()); rest->setTrack(track); Segment* s = measure->getSegment(rest, startChordTick.ticks()); s->add(rest); } restLen -= len; startChordTick += len; } else { auto dl = toDurationList(measure, voice, startChordTick, len, Meter::DurationType::REST); if (dl.isEmpty()) { qDebug("cannot create duration list for len %d", len.ticks()); restLen = Fraction(0); // fake break; } for (const auto &durationPair: dl) { const TDuration &duration = durationPair.second; const Fraction &tupletRatio = durationPair.first; len = duration.fraction() / tupletRatio; Rest* rest = new Rest(score, duration); rest->setDuration(duration.fraction()); rest->setTrack(track); Segment* s = measure->getSegment(Segment::SegChordRest, startChordTick.ticks()); s->add(rest); addElementToTuplet(voice, startChordTick, len, rest); restLen -= len; startChordTick += len; } } } }
void fillGapsWithRests(Score* score, int ctick, int restLen, int track) { bool useDots = preferences.midiImportOperations.currentTrackOperations().useDots; while (restLen > 0) { int len = restLen; Measure* measure = score->tick2measure(ctick); if (ctick >= measure->tick() + measure->ticks()) { qDebug("tick2measure: %d end of score?", ctick); ctick += restLen; restLen = 0; break; } // split rest on measure boundary if ((ctick + len) > measure->tick() + measure->ticks()) len = measure->tick() + measure->ticks() - ctick; if (len >= measure->ticks()) { len = measure->ticks(); TDuration d(TDuration::V_MEASURE); Rest* rest = new Rest(score, d); rest->setDuration(measure->len()); rest->setTrack(track); Segment* s = measure->getSegment(rest, ctick); s->add(rest); restLen -= len; ctick += len; } else { QList<TDuration> dl = Meter::toDurationList(ctick - measure->tick(), ctick + len - measure->tick(), measure->timesig(), Meter::DurationType::REST, useDots); if (dl.isEmpty()) { qDebug("cannot create duration list for len %d", len); restLen = 0; // fake break; } foreach (TDuration d, dl) { Rest* rest = new Rest(score, d); rest->setDuration(d.fraction()); rest->setTrack(track); Segment* s = measure->getSegment(Segment::SegChordRest, ctick); s->add(rest); restLen -= d.ticks(); ctick += d.ticks(); } } }
Staff* CScribeToNeoScribeXML::Scribe2MEIXMLStaff(const CScribeReaderVisitable& scribe_data, const scribe_part& partit, StaffGrp* staffgrp, const int i) { std::string staffnum("s"); staffnum += std::to_string(i); //autogenerate staff ids //finish score definitions //add staff definition for current part //NB. look to alternatively embedding these in staffs StaffDef* staffdef = new StaffDef; //define staff from data staffgrp->addChild(staffdef); staffdef->addAttribute("id", staffnum); staffdef->addAttribute("lines", std::to_string(partit.initial_staff_data.staff_lines)); staffdef->addAttribute("label", CScribeCodes::voice_labels[partit.voice_type].c_str()); //define clef from data Clef* clef = new Clef; staffdef->addChild(clef); scribe_clef loc_clef; loc_clef.clef_line = partit.initial_staff_data.clef_line; loc_clef.clef = partit.initial_staff_data.clef; //convert scribe-based clef position to mei //int mei_clef_line = ((loc_clef.clef_line + 1)/2) - 1; = incorrect int mei_clef_line = 1 + (loc_clef.clef_line-3)/2; //4-line staves are numbered 3, 5, 7, 9 in scribe //if (partit->staff_lines<=4) mei_clef_line -= (5 - partit->staff_lines); clef->addAttribute("line", std::to_string(mei_clef_line)); //these need to be set for each staff/part clef->addAttribute("shape", std::string(&(partit.initial_staff_data.clef),1).c_str()); //the first event in stored memory should be the initial clef Staff* staff = new Staff; staff->addAttribute("id", staffnum); staff->addAttribute("source", partit.abbrev_ms); //folio on which part appears Pb* pb = new Pb; //new ELEMENT? staff->addChild(pb); pb->addAttribute("n", partit.folios); //first staff on which part appears Sb* sb = new Sb; sb->addAttribute("n", "0"); //set to "0" since this isn't encoded in scribe; data will need to be enhanced later staff->addChild(sb); coloration_type current_color = coloration_type::full_black; // this needs to be better handled with a default coloration in a part for (std::vector<scribe_row>::const_iterator rowit = partit.rows.begin(); rowit!=partit.rows.end(); rowit++) { if (rowit->is_comment) { //check it this is the correct way to handle a comment MeiCommentNode* comment = new MeiCommentNode; comment->setValue(rowit->comment); staff->addChild(comment); //NB. syl can have a type (eg. initial) attribute and also encode color as <rend> child element } else { //syllable container (holds syllables, notes, neumes, and ligatures) Syllable* syllable = new Syllable; //neumes.h staff->addChild(syllable); //add actual syllable if present if (!rowit->syllable.empty()) { Syl* syl = new Syl; syl->setValue(rowit->syllable); syllable->addChild(syl); } //extract events - notes, rests ligatures, uneumes and/or ligatures for (std::vector<scribe_event>::const_iterator eventit = rowit->events.begin(); eventit!=rowit->events.end(); eventit++ ) { current_color = eventit->local_coloration; //use temp TiXML pointer which is either syllable, uneume/ineume or ligature - add notes to this, but make sure that uneume/inueme/ligature pointer is preinserted into syllable //handle events for each row code_t event_type = scribe_data.GetCodes()->get_code_type(eventit->code);//codes->get_code_type(eventit->code); //foster parent will change roles according to child elements that need to be added MeiElement* foster = syllable; switch (event_type) { case code_t::ineume: { #ifdef IGNOREGAPS Ineume* ineume = new Ineume; //ineume->addAttribute("name", scribe_data.GetCodes()->code_to_name(eventit->code)); foster->addChild(ineume); foster = ineume; #else //this needs work, hence excluded if (!eventit->preceding_gap || foster->getChildren().empty()) { Ineume* ineume = new Ineume; //ineume->addAttribute("name", scribe_data.GetCodes()->code_to_name(eventit->code)); foster->addChild(ineume); foster = ineume; } else { MeiElement* lastNeume = foster->getChildren().back(); if (lastNeume->getName() == "ineume") { Ineume* newNeume = new Ineume(*dynamic_cast<Ineume*>(lastNeume)); /*for (std::vector<MeiElement*>::const_iterator child = lastNeume->getChildren().begin(); child!=lastNeume->getChildren().end(); child++ ) { MeiElement* clone = new MeiElement(**child); newNeume->addChild(clone); }*/ foster->removeChild(lastNeume); foster->addChild(newNeume); //delete lastNeume; foster = newNeume; } else foster = lastNeume; } #endif goto do_note; break; } case code_t::uneume: { Uneume* uneume = new Uneume; uneume->addAttribute("name", scribe_data.GetCodes()->code_to_name(eventit->code)); foster->addChild(uneume); foster = uneume; goto do_note; break; } case code_t::ligature: { Ligature* ligature = new Ligature; //mensural.h ligature->addAttribute("name", scribe_data.GetCodes()->code_to_name(eventit->code)); foster->addChild(ligature); foster = ligature; if (current_color!=coloration_type::full_black) { switch (current_color) { case full_red: ligature->addAttribute("color", "red"); break; case void_red: ligature->addAttribute("color", "red"); ligature->addAttribute("void", "true"); //this seems a sensible solution for this problem and a suitable additional attribute to the MEI description break; case void_black: ligature->addAttribute("void", "true"); //** break; case full_blue: ligature->addAttribute("color", "blue"); break; default: break; } } //goto do_note; //break; } case code_t::note: do_note: { for (auto i = eventit->pitch_num.begin(); i!=eventit->pitch_num.end(); i++) { int note_count = 1; MeiElement* temp_foster = foster; //handle note attributes according to type if ( foster->getName()=="ineume" ) { Uneume* temp_uneume = new Uneume; //handle ineumes //find uneume names temp_uneume->addAttribute("name", CScribeReaderVisitable::get_ineume_part(eventit->code, i - eventit->pitch_num.begin(), note_count)); foster->addChild(temp_uneume); temp_foster = temp_uneume; //allow notes to be children of uneume } else if ((eventit->code=="B" || eventit->code=="V" || eventit->code=="L") && eventit->pitch_num.size()>1 && scribe_data.GetType()==chant && i!=eventit->pitch_num.begin()) //codes like virga and punctum may be followed by several pitch numbers, indicating a sequence of simple neumes { Uneume* temp_uneume = new Uneume; temp_uneume->addAttribute("name", scribe_data.GetCodes()->code_to_name(eventit->code)); foster->getParent()->addChild(temp_uneume); //link to syllable element, not uneume! temp_foster = temp_uneume; } //also handle ligatures auto j = 0; //insert note or notes for unneumes in ineumes for (; j < note_count ; j++) { //convert note location to pitch name // need to handle dots as element rather than attribute? char pitch_name = loc_clef.get_pitch_name(*i); int octave = loc_clef.get_octave(*i); Note* note = new Note; if (foster->getName()=="syllable") { note->addAttribute("dur", scribe_data.GetCodes()->code_to_name(eventit->code)); } else if (foster->getName()=="ligature") { note->addAttribute("dur", scribe_data.get_ligature_part(eventit->code, j)); } note->addAttribute("pname", std::string(&pitch_name,1)); note->addAttribute("oct", std::to_string(octave)); int note_loc = *i - 3; //3 is bottom line in Scribe, 0 in MEI note->addAttribute("loc", std::to_string( note_loc )); if (current_color!=coloration_type::full_black) { switch (current_color) { case full_red: note->addAttribute("color", "red"); break; case void_red: note->addAttribute("color", "red"); note->addAttribute("void", "true"); //this seems a sensible solution for this problem and a suitable additional attribute to the MEI description break; case void_black: note->addAttribute("void", "true"); //** break; case full_blue: note->addAttribute("color", "blue"); break; default: break; } } temp_foster->addChild(note); } i+=j-1; } } break; //dot needs to be handled as a unique element in our extended definition /*Stinson, 7 July 2013: Further notes on DOT The code has two arguments: the first is the substantive position on the staff; the second refines that position up or down and is capable of five variants: 0 = exactly on the line or exactly in the middle of the space between the lines; -1 = 0.1 of the space between the lines below (or for +, above) the space or line; -2= 0.2 of the space below the normal position for that line or space; -3 = 0.3 below the normal position; -4 = 0.4 below the normal position. Only values between 0 and 4 are permitted as the second argument as 5 would be the equivalent of having the dot on the next numbered line or space, e.g. '7 -5', if it were permitted, would be the same as '6 0'.*/ case code_t::dot: { Dot* dot = new Dot; char pitch_name = loc_clef.get_pitch_name(eventit->pitch_num[0]); int octave = loc_clef.get_octave(eventit->pitch_num[0]); dot->addAttribute("ploc", std::string(&pitch_name,1)); dot->addAttribute("oloc", std::to_string(octave)); /*vo: records the vertical adjustment of a feature's programmatically-determined location in terms of staff interline distance; that is, in units of 1/2 the distance between adjacent staff lines. (MEI2013)*/ //only set for non-defult positions if (eventit->pitch_num[1]!=0) { float v_pos = eventit->pitch_num[1]/10.0*2; dot->addAttribute("vo", to_string_with_precision(v_pos,1)); } foster->addChild(dot); } break; case code_t::rest: { Rest* rest = new Rest; foster->addChild(rest); switch (*(eventit->code.c_str())) { //rests of type 'R' has two associated pitch numbers from which we might infer the type case generic_rest: { int end = eventit->pitch_num[0]; int start = eventit->pitch_num[1]; int rest_type = start-end; switch (rest_type) { case minim_rest: rest->addAttribute("type", "minima"); break; case semibreve_rest: rest->addAttribute("type", "semibrevis"); break; case breve_rest: rest->addAttribute("type", "brevis"); break; case long_rest: rest->addAttribute("type", "longa imperfecta"); break; case perf_long_rest: rest->addAttribute("type", "long perfecta"); break; default: break; } char ploc = loc_clef.get_pitch_name(start); rest->addAttribute("ploc", std::string(&ploc,1)); rest->addAttribute("oloc", std::to_string(loc_clef.get_octave(start))); break; //also process 'RSM', semiminim rest } //case semiminim_rest: //rest->SetAttribute("type", "semiminim"); // break; default: rest->addAttribute("type", scribe_data.GetCodes()->code_to_name(eventit->code)); if (!eventit->pitch_num.empty()) { char pitch_name = loc_clef.get_pitch_name(eventit->pitch_num[0]); int octave = loc_clef.get_octave(eventit->pitch_num[0]); rest->addAttribute("ploc", std::string(&pitch_name,1)); rest->addAttribute("oloc", std::to_string(octave)); } break; } } break; // non-standard mensuration signs case code_t::mensuration: { Mensur* mensuration_sign = new Mensur; foster->addChild(mensuration_sign); if (eventit->code == "MO" || eventit->code == "MC" || eventit->code == "MO." || eventit->code == "MC.") { char the_sign = eventit->code[1]; mensuration_sign->addAttribute("sign", std::string(&the_sign,1)); if (eventit->code.size()==3 && eventit->code[2]=='.') { mensuration_sign->addAttribute("dot", "true"); } //also able to set attribute 'orient' to reversed for reversed signs; and slash attribute for cut signs } if (eventit->code == ".D." || eventit->code == ".Q." || eventit->code == ".SI." || eventit->code == ".P." || eventit->code == ".N." || eventit->code == ".O." || eventit->code == ".I.") //also .SG.? { //these are wholly new to the MEI schema; the whole dot-letter-dot sign is encoded mensuration_sign->addAttribute("sign", eventit->code); } break; } case code_t::barline: { BarLine* barline = new BarLine; foster->addChild(barline); if (eventit->code == "QBAR") { barline->addAttribute("rend", "quarter"); //non-standard data type for rend. } if (eventit->code == "HBAR") { barline->addAttribute("rend", "half"); } if (eventit->code == "WBAR") { barline->addAttribute("rend", "single"); } if (eventit->code == "DBAR") { barline->addAttribute("rend", "dbl"); } //modern bar editorial - ignore? if (eventit->code == "MBAR") { barline->addAttribute("barplace", "takt"); barline->addAttribute("taktplace", std::string(9,1)); } //also able to see rend attribute break; } case code_t::clef: { //NB. old clefchange element superceded; clefGrp used for simultaneous clefs loc_clef.clef_line = *(eventit->pitch_num.begin()); loc_clef.clef = *(eventit->code.c_str()); Clef* clef = new Clef; clef->addAttribute("line", std::to_string( ((loc_clef.clef_line + 1)/2) - 1)); clef->addAttribute("shape", std::string(&(loc_clef.clef),1).c_str()); foster->addChild(clef); break; } //The MEI accidental names are not used: diesis, b-rotundum and b-quadratum are. Other variants may be added. All ms accidentials in Scribe (as they should be in NeoScribe) are independent elements case code_t::accidental: { Accid* accid = new Accid; accid->addAttribute("accidental", scribe_data.GetCodes()->code_to_name(eventit->code)); if (!eventit->pitch_num.empty()) { char ploc = loc_clef.get_pitch_name(eventit->pitch_num[0]); int oloc = loc_clef.get_octave(eventit->pitch_num[0]); accid->addAttribute("ploc", std::string(&ploc,1)); accid->addAttribute("oloc", std::to_string(oloc)); } foster->addChild(accid); break; } case code_t::other: //lucunae default: break; } } } } return staff; }
void ScoreView::createElementPropertyMenu(Element* e, QMenu* popup) { if (e->type() == BAR_LINE) { genPropertyMenu1(e, popup); } else if (e->type() == ARTICULATION) { genPropertyMenu1(e, popup); popup->addAction(tr("Articulation Properties..."))->setData("a-props"); } else if (e->type() == BEAM) { popup->addAction(getAction("flip")); } else if (e->type() == STEM) { popup->addAction(getAction("flip")); } else if (e->type() == HOOK) { popup->addAction(getAction("flip")); } else if (e->type() == BEND) { genPropertyMenu1(e, popup); popup->addAction(tr("Bend Properties..."))->setData("b-props"); } else if (e->type() == TREMOLOBAR) { genPropertyMenu1(e, popup); popup->addAction(tr("TremoloBar Properties..."))->setData("tr-props"); } else if (e->type() == HBOX) { QMenu* textMenu = popup->addMenu(tr("Add")); textMenu->addAction(getAction("frame-text")); textMenu->addAction(getAction("picture")); popup->addAction(tr("Frame Properties..."))->setData("f-props"); } else if (e->type() == VBOX) { QMenu* textMenu = popup->addMenu(tr("Add")); textMenu->addAction(getAction("frame-text")); textMenu->addAction(getAction("title-text")); textMenu->addAction(getAction("subtitle-text")); textMenu->addAction(getAction("composer-text")); textMenu->addAction(getAction("poet-text")); textMenu->addAction(getAction("insert-hbox")); textMenu->addAction(getAction("picture")); popup->addAction(tr("Frame Properties..."))->setData("f-props"); } else if (e->type() == TBOX) { popup->addAction(tr("Frame Properties..."))->setData("f-props"); } else if (e->type() == TUPLET) { genPropertyMenu1(e, popup); popup->addAction(tr("Tuplet Properties..."))->setData("tuplet-props"); } else if (e->type() == VOLTA_SEGMENT) { genPropertyMenu1(e, popup); popup->addAction(tr("Volta Properties..."))->setData("v-props"); } else if (e->type() == TIMESIG) { genPropertyMenu1(e, popup); TimeSig* ts = static_cast<TimeSig*>(e); int _track = ts->track(); // if the time sig. is not generated (= not courtesy) and is in track 0 // add the specific menu item QAction* a; if (!ts->generated() && !_track) { a = popup->addAction(ts->showCourtesySig() ? QT_TRANSLATE_NOOP("TimeSig", "Hide Courtesy Time Signature") : QT_TRANSLATE_NOOP("TimeSig", "Show Courtesy Time Signature") ); a->setData("ts-courtesy"); } popup->addSeparator(); popup->addAction(tr("Time Signature Properties..."))->setData("ts-props"); } else if (e->type() == ACCIDENTAL) { Accidental* acc = static_cast<Accidental*>(e); genPropertyMenu1(e, popup); QAction* a = popup->addAction(QT_TRANSLATE_NOOP("Properties", "small")); a->setCheckable(true); a->setChecked(acc->small()); a->setData("smallAcc"); } else if (e->type() == CLEF) { genPropertyMenu1(e, popup); // if the clef is not generated (= not courtesy) add the specific menu item if (!e->generated()) { QAction* a = popup->addAction(static_cast<Clef*>(e)->showCourtesy() ? QT_TRANSLATE_NOOP("Clef", "Hide courtesy clef") : QT_TRANSLATE_NOOP("Clef", "Show courtesy clef") ); a->setData("clef-courtesy"); } } else if (e->type() == DYNAMIC) { popup->addSeparator(); if (e->visible()) popup->addAction(tr("Set Invisible"))->setData("invisible"); else popup->addAction(tr("Set Visible"))->setData("invisible"); popup->addAction(tr("MIDI Properties..."))->setData("d-dynamics"); popup->addAction(tr("Text Properties..."))->setData("d-props"); } else if (e->type() == TEXTLINE_SEGMENT || e->type() == OTTAVA_SEGMENT) { if (e->visible()) popup->addAction(tr("Set Invisible"))->setData("invisible"); else popup->addAction(tr("Set Visible"))->setData("invisible"); popup->addAction(tr("Line Properties..."))->setData("l-props"); } else if (e->type() == STAFF_TEXT) { genPropertyMenuText(e, popup); popup->addAction(tr("Staff Text Properties..."))->setData("st-props"); } else if (e->type() == TEXT || e->type() == FINGERING || e->type() == LYRICS) { genPropertyMenuText(e, popup); } else if (e->type() == TEMPO_TEXT) { genPropertyMenu1(e, popup); popup->addAction(tr("Tempo Properties..."))->setData("tempo-props"); popup->addAction(tr("Text Properties..."))->setData("text-props"); } else if (e->type() == KEYSIG) { genPropertyMenu1(e, popup); KeySig* ks = static_cast<KeySig*>(e); if (!e->generated()) { QAction* a = popup->addAction(ks->showCourtesy() ? QT_TRANSLATE_NOOP("KeySig", "Hide Courtesy Key Signature") : QT_TRANSLATE_NOOP("KeySig", "Show Courtesy Key Signature") ); a->setData("key-courtesy"); a = popup->addAction(ks->showNaturals() ? QT_TRANSLATE_NOOP("KeySig", "Hide Naturals") : QT_TRANSLATE_NOOP("KeySig", "Show Naturals") ); a->setData("key-naturals"); } } else if (e->type() == STAFF_STATE && static_cast<StaffState*>(e)->subtype() == STAFF_STATE_INSTRUMENT) { popup->addAction(tr("Change Instrument Properties..."))->setData("ss-props"); } else if (e->type() == SLUR_SEGMENT) { genPropertyMenu1(e, popup); popup->addAction(tr("Edit Mode"))->setData("edit"); popup->addAction(tr("Slur Properties..."))->setData("slur-props"); } else if (e->type() == REST) { Rest* rest = static_cast<Rest*>(e); genPropertyMenu1(e, popup); if (rest->tuplet()) { popup->addSeparator(); QMenu* menuTuplet = popup->addMenu(tr("Tuplet...")); menuTuplet->addAction(tr("Tuplet Properties..."))->setData("tuplet-props"); menuTuplet->addAction(tr("Delete Tuplet"))->setData("tupletDelete"); } } else if (e->type() == NOTE) { Note* note = static_cast<Note*>(e); QAction* b = popup->actions()[0]; QAction* a = popup->insertSeparator(b); a->setText(tr("Staff")); a = new QAction(tr("Staff Properties..."), 0); a->setData("staff-props"); popup->insertAction(b, a); a = popup->insertSeparator(b); a->setText(tr("Measure")); a = new QAction(tr("Measure Properties..."), 0); a->setData("measure-props"); popup->insertAction(b, a); genPropertyMenu1(e, popup); popup->addSeparator(); popup->addAction(tr("Style..."))->setData("style"); if (note->chord()->tuplet()) { QMenu* menuTuplet = popup->addMenu(tr("Tuplet...")); menuTuplet->addAction(tr("Tuplet Properties..."))->setData("tuplet-props"); menuTuplet->addAction(tr("Delete Tuplet"))->setData("tupletDelete"); } popup->addAction(tr("Chord Articulation..."))->setData("articulation"); } else if (e->type() == MARKER) { genPropertyMenu1(e, popup); popup->addAction(tr("Marker Properties..."))->setData("marker-props"); } else if (e->type() == JUMP) { genPropertyMenu1(e, popup); popup->addAction(tr("Jump Properties..."))->setData("jump-props"); } else if (e->type() == LAYOUT_BREAK && static_cast<LayoutBreak*>(e)->subtype() == LAYOUT_BREAK_SECTION) { popup->addAction(tr("Section Break Properties..."))->setData("break-props"); } else if (e->type() == INSTRUMENT_CHANGE) { genPropertyMenu1(e, popup); popup->addAction(tr("Change Instrument..."))->setData("ch-instr"); } else if (e->type() == FRET_DIAGRAM) { if (e->visible()) popup->addAction(tr("Set Invisible"))->setData("invisible"); else popup->addAction(tr("Set Visible"))->setData("invisible"); popup->addAction(tr("Color..."))->setData("color"); popup->addAction(tr("Fret Diagram Properties..."))->setData("fret-props"); } else if (e->type() == GLISSANDO) { genPropertyMenu1(e, popup); popup->addAction(tr("Glissando Properties..."))->setData("gliss-props"); } else if (e->type() == HAIRPIN_SEGMENT) { QAction* a = popup->addSeparator(); a->setText(tr("Dynamics")); if (e->visible()) a = popup->addAction(tr("Set Invisible")); else a = popup->addAction(tr("Set Visible")); a->setData("invisible"); popup->addAction(tr("Hairpin Properties..."))->setData("hp-props"); } else if (e->type() == HARMONY) { genPropertyMenu1(e, popup); popup->addSeparator(); popup->addAction(tr("Harmony Properties..."))->setData("ha-props"); popup->addAction(tr("Text Properties..."))->setData("text-props"); } else if (e->type() == INSTRUMENT_NAME) { popup->addAction(tr("Staff Properties..."))->setData("staff-props"); } else genPropertyMenu1(e, popup); }
void InspectorRest::setElement() { Rest* rest = toRest(inspector->element()); tuplet->setEnabled(rest->tuplet()); InspectorElementBase::setElement(); }
int main () { // Twilio REST API version const string API_VERSION = "2010-04-01"; // Twilio AccountSid and AuthToken const string ACCOUNT_SID = "SID"; const string ACCOUNT_TOKEN = "TOKEN"; // Outgoing Caller ID previously validated with Twilio const string CALLER_ID = "NNNNNNNNNN"; string response; vector<Var> vars; try { // Twilio REST Rest t (ACCOUNT_SID, ACCOUNT_TOKEN); // get completed calls XML vars.push_back(Var("Status", "Completed")); response = t.request("/" + API_VERSION + "/Accounts/" + ACCOUNT_SID + "/Calls", "GET", vars); cout << response << endl; // make a call vars.clear(); vars.push_back(Var("To", "xxx-xxx-xxxx")); vars.push_back(Var("From", "xxx-xxx-xxxx")); vars.push_back(Var("Url", "http://xxxx")); response = t.request("/" + API_VERSION + "/Accounts/" + ACCOUNT_SID + "/Calls", "POST", vars); cout << response << endl; // send SMS vars.clear(); vars.push_back(Var("To", "xxx-xxx-xxxx")); vars.push_back(Var("From", "xxx-xxx-xxxx")); vars.push_back(Var("Body", "Hello, how are you?")); response = t.request("/" + API_VERSION + "/Accounts/" + ACCOUNT_SID + "/SMS/Messages", "POST", vars); cout << response << endl; // TwiML reponse // Say, Dial and Play TwiMLResponse response; Say say ("Hello, how are you?"); say.setLoop(5); say.setVoice("woman"); response.append(say); cout << response.toXML() << endl; // Gather, redirect TwiMLResponse response2; Gather gather; gather.setNumDigits(10); Say say2 ("Press 1"); Redirect redirect; gather.append(say2); response2.append(gather); response2.append(redirect); cout << response2.toXML() << endl; // Twilio Utils Utils u (ACCOUNT_SID, ACCOUNT_TOKEN); // validate request signature vars.clear(); vars.push_back(Var("Status", "Completed")); bool v = u.validateRequest("x1P+eKchQZzgVQO3Yad/PgKSM1k=", "/" + API_VERSION + "/Accounts/" + ACCOUNT_SID + "/Calls", vars); cout << "request valid:" << v << endl; } catch(char const* str) { cout << "Exception raised: " << str << endl; } return 0; }
void PaeInput::parseNote(NoteObject note) { LayerElement *element; if (note.rest) { Rest *rest = new Rest(); rest->SetDots( note.dots ); rest->SetDur(note.duration); if (note.fermata) { rest->SetFermata(PLACE_above); // always above for now } element = rest; } else { Note *mnote = new Note(); mnote->SetPname(note.pitch); mnote->SetOct(note.octave); mnote->SetAccid(note.accidental); mnote->SetDots( note.dots ); mnote->SetDur(note.duration); if (note.fermata) { mnote->SetFermata(PLACE_above); // always above for now } if (note.trill == true) mnote->m_embellishment = EMB_TRILL; if (m_last_tied_note != NULL) { mnote->SetTie(TIE_t); m_last_tied_note = NULL; } if (note.tie) { if (mnote->GetTie()==TIE_t) mnote->SetTie(TIE_m); else mnote->SetTie(TIE_i); m_last_tied_note = mnote; } element = mnote; } // Does this note have a clef change? push it before everyting else if (note.clef) addLayerElement(note.clef); // Same thing for time changes // You can find this sometimes if (note.meter) addLayerElement(note.meter); // Handle key change. Evil if done in a beam if (note.key) addLayerElement(note.key); // Acciaccaturas are similar but do not get beamed (do they) // this case is simpler. NOTE a note can not be acciacctura AND appoggiatura // Acciaccatura rests do not exist if (note.acciaccatura && (element->Is() == NOTE) ) { Note *note = dynamic_cast<Note*>(element); assert( note ); note->SetDur(DURATION_8); note->SetGrace(GRACE_acc); note->SetStemDir(STEMDIRECTION_up); } if ( (note.appoggiatura > 0) && (element->Is() == NOTE) ) { Note *note = dynamic_cast<Note*>(element); assert( note ); note->SetGrace(GRACE_unacc); note->SetStemDir(STEMDIRECTION_up); } if (note.beam == BEAM_INITIAL) { pushContainer(new Beam()); } // we have a tuplet, the tuplet_note is > 0 // which means we are counting a tuplet if (note.tuplet_note > 0 && note.tuplet_notes == note.tuplet_note) { // first elem in tuplet Tuplet *newTuplet = new Tuplet(); newTuplet->SetNum(note.tuplet_notes); newTuplet->SetNumbase(note.tuplet_notes); pushContainer(newTuplet); } // Add the note to the current container addLayerElement(element); // the last note counts always '1' // insert the tuplet elem // and reset the tuplet counter if (note.tuplet_note == 1) popContainer(); if (note.beam == BEAM_TERMINAL) popContainer(); }
Score::FileError Score::read114(XmlReader& e) { if (parentScore()) setMscVersion(parentScore()->mscVersion()); for (unsigned int i = 0; i < sizeof(style114)/sizeof(*style114); ++i) style()->set(style114[i].idx, style114[i].val); // old text style defaults TextStyle ts = style()->textStyle("Chord Symbol"); ts.setYoff(-4.0); style()->setTextStyle(ts); TempoMap tm; while (e.readNextStartElement()) { e.setTrack(-1); const QStringRef& tag(e.name()); if (tag == "Staff") readStaff(e); else if (tag == "KeySig") { // not supported KeySig* ks = new KeySig(this); ks->read(e); // customKeysigs.append(ks); delete ks; } else if (tag == "siglist") _sigmap->read(e, _fileDivision); else if (tag == "programVersion") { _mscoreVersion = e.readElementText(); parseVersion(_mscoreVersion); } else if (tag == "programRevision") _mscoreRevision = e.readInt(); else if (tag == "Mag" || tag == "MagIdx" || tag == "xoff" || tag == "Symbols" || tag == "cursorTrack" || tag == "yoff") e.skipCurrentElement(); // obsolete else if (tag == "tempolist") { // store the tempo list to create invisible tempo text later qreal tempo = e.attribute("fix","2.0").toDouble(); tm.setRelTempo(tempo); while (e.readNextStartElement()) { if (e.name() == "tempo") { int tick = e.attribute("tick").toInt(); double tmp = e.readElementText().toDouble(); tick = (tick * MScore::division + _fileDivision/2) / _fileDivision; auto pos = tm.find(tick); if (pos != tm.end()) tm.erase(pos); tm.setTempo(tick, tmp); } else if (e.name() == "relTempo") e.readElementText(); else e.unknown(); } } else if (tag == "playMode") _playMode = PlayMode(e.readInt()); else if (tag == "SyntiSettings") _synthesizerState.read(e); else if (tag == "Spatium") _style.setSpatium (e.readDouble() * MScore::DPMM); else if (tag == "Division") _fileDivision = e.readInt(); else if (tag == "showInvisible") _showInvisible = e.readInt(); else if (tag == "showFrames") _showFrames = e.readInt(); else if (tag == "showMargins") _showPageborders = e.readInt(); else if (tag == "Style") { qreal sp = _style.spatium(); _style.load(e); // adjust this now so chords render properly on read // other style adjustments can wait until reading is finished if (style(StyleIdx::useGermanNoteNames).toBool()) style()->set(StyleIdx::useStandardNoteNames, false); if (_layoutMode == LayoutMode::FLOAT) { // style should not change spatium in // float mode _style.setSpatium(sp); } } else if (tag == "TextStyle") { TextStyle s; s.read(e); qreal spMM = _style.spatium() / MScore::DPMM; if (s.frameWidthMM() != 0.0) s.setFrameWidth(Spatium(s.frameWidthMM() / spMM)); if (s.paddingWidthMM() != 0.0) s.setPaddingWidth(Spatium(s.paddingWidthMM() / spMM)); \ // convert 1.2 text styles s.setName(convertOldTextStyleNames(s.name())); if (s.name() == "Lyrics Odd Lines" || s.name() == "Lyrics Even Lines") s.setAlign((s.align() & ~ Align(AlignmentFlags::VMASK)) | AlignmentFlags::BASELINE); _style.setTextStyle(s); } else if (tag == "page-layout") { if (_layoutMode != LayoutMode::FLOAT && _layoutMode != LayoutMode::SYSTEM) { PageFormat pf; pf.copy(*pageFormat()); pf.read(e, this); setPageFormat(pf); } else e.skipCurrentElement(); } else if (tag == "copyright" || tag == "rights") { Text* text = new Text(this); text->read(e); text->layout(); setMetaTag("copyright", text->plainText()); delete text; } else if (tag == "movement-number") setMetaTag("movementNumber", e.readElementText()); else if (tag == "movement-title") setMetaTag("movementTitle", e.readElementText()); else if (tag == "work-number") setMetaTag("workNumber", e.readElementText()); else if (tag == "work-title") setMetaTag("workTitle", e.readElementText()); else if (tag == "source") setMetaTag("source", e.readElementText()); else if (tag == "metaTag") { QString name = e.attribute("name"); setMetaTag(name, e.readElementText()); } else if (tag == "Part") { Part* part = new Part(this); part->read114(e); _parts.push_back(part); } else if (tag == "Slur") { Slur* slur = new Slur(this); slur->read(e); addSpanner(slur); } else if ((tag == "HairPin") || (tag == "Ottava") || (tag == "TextLine") || (tag == "Volta") || (tag == "Trill") || (tag == "Pedal")) { Spanner* s = static_cast<Spanner*>(Element::name2Element(tag, this)); s->read(e); if (s->track() == -1) s->setTrack(e.track()); else e.setTrack(s->track()); // update current track if (s->tick() == -1) s->setTick(e.tick()); else e.initTick(s->tick()); // update current tick if (s->track2() == -1) s->setTrack2(s->track()); if (s->ticks() == 0) { delete s; qDebug("zero spanner %s ticks: %d", s->name(), s->ticks()); } else { addSpanner(s); } } else if (tag == "Excerpt") { if (MScore::noExcerpts) e.skipCurrentElement(); else { Excerpt* ex = new Excerpt(this); ex->read(e); _excerpts.append(ex); } } else if (tag == "Beam") { Beam* beam = new Beam(this); beam->read(e); beam->setParent(0); // _beams.append(beam); } else if (tag == "name") setName(e.readElementText()); else e.unknown(); } if (e.error() != XmlStreamReader::NoError) return FileError::FILE_BAD_FORMAT; int n = nstaves(); for (int idx = 0; idx < n; ++idx) { Staff* s = _staves[idx]; int track = idx * VOICES; // check barLineSpan if (s->barLineSpan() > (n - idx)) { qDebug("read114: invalid bar line span %d (max %d)", s->barLineSpan(), n - idx); s->setBarLineSpan(n - idx); } for (auto i : e.clefs(idx)) { int tick = i.first; ClefType clefId = i.second; Measure* m = tick2measure(tick); if (!m) continue; if ((tick == m->tick()) && m->prevMeasure()) m = m->prevMeasure(); Segment* seg = m->getSegment(Segment::Type::Clef, tick); if (seg->element(track)) static_cast<Clef*>(seg->element(track))->setGenerated(false); else { Clef* clef = new Clef(this); clef->setClefType(clefId); clef->setTrack(track); clef->setParent(seg); clef->setGenerated(false); seg->add(clef); } } // create missing KeySig KeyList* km = s->keyList(); for (auto i = km->begin(); i != km->end(); ++i) { int tick = i->first; if (tick < 0) { qDebug("read114: Key tick %d", tick); continue; } if (tick == 0 && i->second.key() == Key::C) continue; Measure* m = tick2measure(tick); if (!m) //empty score break; Segment* seg = m->getSegment(Segment::Type::KeySig, tick); if (seg->element(track)) static_cast<KeySig*>(seg->element(track))->setGenerated(false); else { KeySigEvent ke = i->second; KeySig* ks = new KeySig(this); ks->setKeySigEvent(ke); ks->setParent(seg); ks->setTrack(track); ks->setGenerated(false); seg->add(ks); } } } for (std::pair<int,Spanner*> p : spanner()) { Spanner* s = p.second; if (s->type() != Element::Type::SLUR) { if (s->type() == Element::Type::VOLTA) { Volta* volta = static_cast<Volta*>(s); volta->setAnchor(Spanner::Anchor::MEASURE); } } if (s->type() == Element::Type::OTTAVA || s->type() == Element::Type::PEDAL || s->type() == Element::Type::TRILL || s->type() == Element::Type::TEXTLINE) { qreal yo = 0; if (s->type() == Element::Type::OTTAVA) { // fix ottava position yo = styleS(StyleIdx::ottavaY).val() * spatium(); if (s->placement() == Element::Placement::BELOW) yo = -yo + s->staff()->height(); } else if (s->type() == Element::Type::PEDAL) { yo = styleS(StyleIdx::pedalY).val() * spatium(); } else if (s->type() == Element::Type::TRILL) { yo = styleS(StyleIdx::trillY).val() * spatium(); } else if (s->type() == Element::Type::TEXTLINE) { yo = -5.0 * spatium(); } if (!s->spannerSegments().isEmpty()) { for (SpannerSegment* seg : s->spannerSegments()) { if (!seg->userOff().isNull()) seg->setUserYoffset(seg->userOff().y() - yo); } } else { s->setUserYoffset(-yo); } } } connectTies(); // // remove "middle beam" flags from first ChordRest in // measure // for (Measure* m = firstMeasure(); m; m = m->nextMeasure()) { int tracks = nstaves() * VOICES; bool first = true; for (int track = 0; track < tracks; ++track) { for (Segment* s = m->first(); s; s = s->next()) { if (s->segmentType() != Segment::Type::ChordRest) continue; ChordRest* cr = static_cast<ChordRest*>(s->element(track)); if (cr) { if(cr->type() == Element::Type::REST) { Rest* r = static_cast<Rest*>(cr); if (!r->userOff().isNull()) { int lineOffset = r->computeLineOffset(); qreal lineDist = r->staff() ? r->staff()->staffType()->lineDistance().val() : 1.0; r->rUserYoffset() -= (lineOffset * .5 * lineDist * r->spatium()); } } if(!first) { switch(cr->beamMode()) { case Beam::Mode::AUTO: case Beam::Mode::BEGIN: case Beam::Mode::END: case Beam::Mode::NONE: break; case Beam::Mode::MID: case Beam::Mode::BEGIN32: case Beam::Mode::BEGIN64: cr->setBeamMode(Beam::Mode::BEGIN); break; case Beam::Mode::INVALID: if (cr->type() == Element::Type::CHORD) cr->setBeamMode(Beam::Mode::AUTO); else cr->setBeamMode(Beam::Mode::NONE); break; } first = false; } } } } } for (MeasureBase* mb = _measures.first(); mb; mb = mb->next()) { if (mb->type() == Element::Type::VBOX) { Box* b = static_cast<Box*>(mb); qreal y = point(styleS(StyleIdx::staffUpperBorder)); b->setBottomGap(y); } } _fileDivision = MScore::division; // // sanity check for barLineSpan and update ottavas // foreach(Staff* staff, _staves) { int barLineSpan = staff->barLineSpan(); int idx = staffIdx(staff); int n = nstaves(); if (idx + barLineSpan > n) { qDebug("bad span: idx %d span %d staves %d", idx, barLineSpan, n); staff->setBarLineSpan(n - idx); } staff->updateOttava(); }
int LayerElement::SetDrawingXY( ArrayPtrVoid *params ) { // param 0: a pointer doc // param 1: a pointer to the current system (unused) // param 2: a pointer to the current measure // param 3: a pointer to the current staff // param 4: a pointer to the current layer // param 5: a pointer to the view // param 6: a bool indicating if we are processing layer elements or not Doc *doc = static_cast<Doc*>((*params).at(0)); Measure **currentMeasure = static_cast<Measure**>((*params).at(2)); Staff **currentStaff = static_cast<Staff**>((*params).at(3)); Layer **currentLayer = static_cast<Layer**>((*params).at(4)); View *view = static_cast<View*>((*params).at(5)); bool *processLayerElements = static_cast<bool*>((*params).at(6)); // First pass, only set the X position if ((*processLayerElements)==false) { // Here we set the appropriate x value to be used for drawing // With Raw documents, we use m_drawingXRel that is calculated by the layout algorithm // With Transcription documents, we use the m_xAbs if ( this->m_xAbs == VRV_UNSET ) { assert( doc->GetType() == Raw ); this->SetDrawingX( this->GetXRel() + (*currentMeasure)->GetDrawingX() ); // Grace notes, also take into account the GraceAlignment Note *note = dynamic_cast<Note*>(this); if (note && note->HasGraceAlignment() ) { this->SetDrawingX( this->GetDrawingX() - note->GetAlignment()->GetGraceAligner()->GetWidth() + note->GetGraceAlignment()->GetXRel() ); } } else { assert( doc->GetType() == Transcription ); this->SetDrawingX( this->m_xAbs ); } return FUNCTOR_CONTINUE; } LayerElement *layerElementY = this; // Look for cross-staff situations // If we have one, make is available in m_crossStaff DurationInterface *durElement = dynamic_cast<DurationInterface*>(this); if ( durElement && durElement->HasStaff()) { AttCommonNComparison comparisonFirst( STAFF, durElement->GetStaff() ); m_crossStaff = dynamic_cast<Staff*>((*currentMeasure)->FindChildByAttComparison(&comparisonFirst, 1)); if (m_crossStaff) { if (m_crossStaff == (*currentStaff)) LogWarning("The cross staff reference '%d' for element '%s' seems to be identical to the parent staff", durElement->GetStaff(), this->GetUuid().c_str()); // Now try to get the corresponding layer - for now look for the same layer @n int layerN = (*currentLayer)->GetN(); // When we will have allowed @layer in <note>, we will have to do: // int layerN = durElement->HasLayer() ? durElement->GetLayer() : (*currentLayer)->GetN(); AttCommonNComparison comparisonFirstLayer( LAYER, layerN ); m_crossLayer = dynamic_cast<Layer*>(m_crossStaff->FindChildByAttComparison(&comparisonFirstLayer, 1)); if (m_crossLayer) { // Now we need to yet the element at the same position in the cross-staff layer of getting the right clef layerElementY = m_crossLayer->GetAtPos( this->GetDrawingX() ); } else { LogWarning("Could not get the layer with cross-staff reference '%d' for element '%s'", durElement->GetStaff(), this->GetUuid().c_str()); } } else { LogWarning("Could not get the cross staff reference '%d' for element '%s'", durElement->GetStaff(), this->GetUuid().c_str()); } // If we have a @layer we probably also want to change the layer element (for getting the right clef if different) } else { m_crossStaff = NULL; m_crossLayer = NULL; } Staff *staffY = m_crossStaff ? m_crossStaff : (*currentStaff); Layer *layerY = m_crossLayer ? m_crossLayer : (*currentLayer); // Here we set the appropriate Y value to be used for drawing if ( this->m_xAbs == VRV_UNSET ) { assert( doc->GetType() == Raw ); this->SetDrawingY( staffY->GetDrawingY() ); } else { assert( doc->GetType() == Transcription ); this->SetDrawingY( staffY->GetDrawingY() ); } // Finally, adjust Y for notes and rests if (this->Is() == NOTE) { Note *note = dynamic_cast<Note*>(this); assert( note ); this->SetDrawingY( this->GetDrawingY() + view->CalculatePitchPosY( staffY, note->GetPname(), layerY->GetClefOffset( layerElementY ), note->GetOct() ) ); } else if (this->Is() == REST) { Rest *rest = dynamic_cast<Rest*>(this); assert( rest ); // Automatically calculate rest position, if so requested if (rest->GetPloc() == PITCHNAME_NONE) { this->SetDrawingY( this->GetDrawingY() + view->CalculateRestPosY( staffY, rest->GetActualDur()) ); } else { this->SetDrawingY( this->GetDrawingY() + view->CalculatePitchPosY( staffY, rest->GetPloc(), layerY->GetClefOffset( layerElementY ), rest->GetOloc()) ); } } return FUNCTOR_CONTINUE; }
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; }