// modifySegment just deals with the effects on the segment that // selection was in, the trigger segment is managed separately by // m_paster. void CutToTriggerSegmentCommand::modifySegment(void) { using namespace BaseProperties; // This is only possible the first time, before selection's // contents evaporate due to the erasing. This requires that we // use bruteForceRedo = true. EraseCommand::eraseInSegment(m_selection); /* Adapted from InsertTriggerNoteCommand */ const TriggerSegmentId id = m_paster.getTriggerSegmentId(); // Insert via a model event, so as to apply the note style. // This is a subset of the work done by NoteInsertionCommand Event *e = new Event(Note::EventType, m_time, m_duration); // Set the properties that every tied note has. // makeThisNoteViable will give these to every tied note. e->set<Int>(PITCH, m_paster.getBasePitch()); e->set<Int>(VELOCITY, m_paster.getBaseVelocity()); e->set<Bool>(TRIGGER_EXPAND, true); if (m_noteStyle != NoteStyleFactory::DefaultStyle) { e->set<String>(NotationProperties::NOTE_STYLE, qstrtostr(m_noteStyle)); } Segment &s(getSegment()); Segment::iterator i = s.insert(e); SegmentNotationHelper(s).makeThisNoteViable(i); s.normalizeRests(m_time, m_time + m_duration); // Now set the properties that only the trigger note has. e->set<Int>(TRIGGER_SEGMENT_ID, id); e->set<Bool>(TRIGGER_SEGMENT_RETUNE, m_retune); e->set<String>(TRIGGER_SEGMENT_ADJUST_TIMES, m_timeAdjust); if (m_mark != Marks::NoMark) { Marks::addMark(*e, m_mark, true); } // Update references to this new ornament TriggerSegmentRec *rec = s.getComposition()->getTriggerSegmentRec(id); if (rec) { rec->updateReferences(); } }
void InsertTriggerNoteCommand::modifySegment() { // Insert via a model event, so as to apply the note style. // This is a subset of the work done by NoteInsertionCommand Event *e = new Event(Note::EventType, m_time, m_duration); // Could e->set<Int>(PITCH, m_pitch); e->set<Int>(VELOCITY, m_velocity); e->set<Bool>(TRIGGER_EXPAND, true); if (m_noteStyle != NoteStyleFactory::DefaultStyle) { e->set<String>(NotationProperties::NOTE_STYLE, qstrtostr(m_noteStyle)); } Segment &s(getSegment()); Segment::iterator i = s.insert(e); SegmentNotationHelper(s).makeThisNoteViable(i); s.normalizeRests(m_time, m_time + m_duration); // Add these properties only after the note is possibly // split-and-tied. e->set<Int>(TRIGGER_SEGMENT_ID, m_id); e->set<Bool>(TRIGGER_SEGMENT_RETUNE, m_retune); e->set<String>(TRIGGER_SEGMENT_ADJUST_TIMES, m_timeAdjust); if (m_mark != Marks::NoMark) { Marks::addMark(*e, m_mark, true); } TriggerSegmentRec *rec = s.getComposition()->getTriggerSegmentRec(m_id); if (rec) rec->updateReferences(); }