本文整理汇总了C++中EventSelection::addEvent方法的典型用法代码示例。如果您正苦于以下问题:C++ EventSelection::addEvent方法的具体用法?C++ EventSelection::addEvent怎么用?C++ EventSelection::addEvent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EventSelection
的用法示例。
在下文中一共展示了EventSelection::addEvent方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: EventSelection
// Select exactly the beat-defining events, including any extra notes
// this command inserted.
// @author Tom Breton (Tehom)
EventSelection *
SelectAddEvenNotesCommand::getSubsequentSelection()
{
RG_DEBUG << "SelectAddEvenNotesCommand::getSubsequentSelection" << endl;
EventSelection *selection = new EventSelection(getSegment());
RG_DEBUG << (int)m_beatEventVector.size()
<< "elements in m_beatEventVector"
<< endl;
// Add the beat events we found to the selection
for (BeatEventVector::iterator i = m_beatEventVector.begin();
i != m_beatEventVector.end();
++i) {
BeatEvent &beatEvent = *i;
// Skip ties
selection->addEvent(beatEvent.m_event, false);
}
// Also add any events that we made.
RG_DEBUG << (int)m_eventsAdded.size()
<< "elements in redoEvents"
<< endl;
for (EventVector::const_iterator i = m_eventsAdded.begin();
i != m_eventsAdded.end();
++i) {
Event *e = *i;
// Skip ties
selection->addEvent(e, false);
}
return selection;
}
示例2: EventSelection
EventSelection *
SymbolInsertionCommand::getSubsequentSelection()
{
EventSelection *selection = new EventSelection(getSegment());
selection->addEvent(getLastInsertedEvent());
return selection;
}
示例3: controllerName
void
PitchBendSequenceDialog::accept()
{
/* The user has finished the dialog, other than aborting. */
// We don't enable "OK" if the interval isn't sensible, so
// something's badly wrong if this test fails.
Q_ASSERT_X(m_startTime < m_endTime, "accept",
"got a zero or negative time interval");
/* Save current settings. They'll be the defaults next time. */
saveSettings();
// TRANSLATORS: The arg value will be either a controller name or
// Pitchbend, so the resulting text is like "Pitchbend Sequence",
// "Expression Sequence", etc.
QString controllerName(m_control.getName().data());
QString commandName(tr("%1 Sequence").arg(controllerName));
MacroCommand *macro = new MacroCommand(commandName);
if (getReplaceMode() != OnlyAdd) {
// Selection initially contains no event, and we add all the
// relevant ones.
EventSelection *selection = new EventSelection(*m_segment);
for (Segment::const_iterator i = m_segment->findTime(m_startTime);
i != m_segment->findTime(m_endTime);
++i) {
Event *e = *i;
if (m_control.matches(e)) {
selection->addEvent(e, false);
}
}
// EraseCommand takes ownership of "selection".
macro->addCommand(new EraseCommand(*selection));
}
if (getReplaceMode() != OnlyErase) {
if ((getRampMode() == Linear) &&
(getStepSizeCalculation() == StepSizeByCount)) {
addLinearCountedEvents(macro);
} else {
addStepwiseEvents(macro);
}
}
CommandHistory::getInstance()->addCommand(macro);
QDialog::accept();
}
示例4: EventSelection
void
MatrixResizer::handleLeftButtonPress(const MatrixMouseEvent *e)
{
MATRIX_DEBUG << "MatrixResizer::handleLeftButtonPress() : el = "
<< e->element << endl;
if (!e->element) return;
m_currentViewSegment = e->viewSegment;
m_currentElement = e->element;
// Add this element and allow movement
//
EventSelection* selection = m_scene->getSelection();
Event *event = m_currentElement->event();
if (selection) {
EventSelection *newSelection;
if ((e->modifiers & Qt::ShiftModifier) ||
selection->contains(event)) {
newSelection = new EventSelection(*selection);
} else {
newSelection = new EventSelection(m_currentViewSegment->getSegment());
}
newSelection->addEvent(event);
m_scene->setSelection(newSelection, true);
// m_mParentView->canvas()->update();
} else {
m_scene->setSingleSelectedEvent(m_currentViewSegment,
m_currentElement,
true);
// m_mParentView->canvas()->update();
}
}
示例5: EventSelection
void
MatrixMover::handleLeftButtonPress(const MatrixMouseEvent *e)
{
MATRIX_DEBUG << "MatrixMover::handleLeftButtonPress() : snapped time = " << e->snappedLeftTime << ", el = " << e->element << endl;
if (!e->element) return;
// Check the scene's current segment (apparently not necessarily the same
// segment referred to by the scene's current view segment) for this event;
// return if not found, indicating that this event is from some other,
// non-active segment.
//
// I think notation just makes whatever segment active when you click an
// event outside the active segment, and I think that's what this code
// attempted to do too. I couldn't get that to work at all. This is better
// than being able to click on non-active elements to create new events by
// accident, and will probably fly. Especially since the multi-segment
// matrix is new, and we're defining the terms of how it works.
Segment *segment = m_scene->getCurrentSegment();
if (!segment) return;
bool found = false;
for (Segment::iterator i = segment->begin(); i != segment->end(); ++i) {
if ((*i) == e->element->event()) found = true;
}
if (!found) {
MATRIX_DEBUG << "Clicked element not owned by active segment. Returning..." << endl;
return;
}
m_currentViewSegment = e->viewSegment;
m_currentElement = e->element;
m_clickSnappedLeftTime = e->snappedLeftTime;
m_quickCopy = (e->modifiers & Qt::ControlModifier);
if (!m_duplicateElements.empty()) {
for (size_t i = 0; i < m_duplicateElements.size(); ++i) {
delete m_duplicateElements[i]->event();
delete m_duplicateElements[i];
}
m_duplicateElements.clear();
}
// Add this element and allow movement
//
EventSelection* selection = m_scene->getSelection();
Event *event = m_currentElement->event();
if (selection) {
EventSelection *newSelection;
if ((e->modifiers & Qt::ShiftModifier) ||
selection->contains(event)) {
newSelection = new EventSelection(*selection);
} else {
newSelection = new EventSelection(m_currentViewSegment->getSegment());
}
// if the selection already contains the event, remove it from the
// selection if shift is pressed
if (selection->contains(event)) {
if (e->modifiers & Qt::ShiftModifier) {
newSelection->removeEvent(event);
}
} else {
newSelection->addEvent(event);
}
m_scene->setSelection(newSelection, true);
selection = newSelection;
} else {
m_scene->setSingleSelectedEvent(m_currentViewSegment,
m_currentElement, true);
}
long velocity = m_widget->getCurrentVelocity();
event->get<Int>(BaseProperties::VELOCITY, velocity);
long pitchOffset = m_currentViewSegment->getSegment().getTranspose();
long pitch = 60;
event->get<Int>(BaseProperties::PITCH, pitch);
// We used to m_scene->playNote() here, but the new concert pitch matrix was
// playing chords the first time I clicked a note. Investigation with
// KMidiMon revealed two notes firing nearly simultaneously, and with
// segments of 0 transpose, they were simply identical to each other. One
// of them came from here, and this was the one sounding at the wrong pitch
// in transposed segments. I've simply removed it with no apparent ill side
// effects, and a problem solved super cheap.
m_lastPlayedPitch = pitch;
if (m_quickCopy && selection) {
for (EventSelection::eventcontainer::iterator i =
selection->getSegmentEvents().begin();
i != selection->getSegmentEvents().end(); ++i) {
MatrixElement *duplicate = new MatrixElement
//.........这里部分代码省略.........
示例6: tr
//.........这里部分代码省略.........
m_currentElement->event()->get<Int>(BaseProperties::VELOCITY, velocity);
m_scene->playNote(m_currentViewSegment->getSegment(), newPitch + (pitchOffset * -1), velocity);
m_lastPlayedPitch = newPitch;
}
QString commandLabel;
if (m_quickCopy) {
if (selection->getAddedEvents() < 2) {
commandLabel = tr("Copy and Move Event");
} else {
commandLabel = tr("Copy and Move Events");
}
} else {
if (selection->getAddedEvents() < 2) {
commandLabel = tr("Move Event");
} else {
commandLabel = tr("Move Events");
}
}
MacroCommand *macro = new MacroCommand(commandLabel);
EventSelection::eventcontainer::iterator it =
selection->getSegmentEvents().begin();
Segment &segment = m_currentViewSegment->getSegment();
EventSelection *newSelection = new EventSelection(segment);
timeT normalizeStart = selection->getStartTime();
timeT normalizeEnd = selection->getEndTime();
if (m_quickCopy) {
for (size_t i = 0; i < m_duplicateElements.size(); ++i) {
timeT time = m_duplicateElements[i]->getViewAbsoluteTime();
timeT endTime = time + m_duplicateElements[i]->getViewDuration();
if (time < normalizeStart) normalizeStart = time;
if (endTime > normalizeEnd) normalizeEnd = endTime;
macro->addCommand(new MatrixInsertionCommand
(segment, time, endTime,
m_duplicateElements[i]->event()));
delete m_duplicateElements[i]->event();
delete m_duplicateElements[i];
}
m_duplicateElements.clear();
m_quickCopy = false;
}
for (; it != selection->getSegmentEvents().end(); ++it) {
timeT newTime = (*it)->getAbsoluteTime() + diffTime;
int newPitch = 60;
if ((*it)->has(PITCH)) {
newPitch = (*it)->get<Int>(PITCH) + diffPitch;
}
Event *newEvent = 0;
if (newTime < segment.getStartTime()) {
newTime = segment.getStartTime();
}
if (newTime + (*it)->getDuration() >= segment.getEndMarkerTime()) {
timeT limit = getSnapGrid()->snapTime
(segment.getEndMarkerTime() - 1, SnapGrid::SnapLeft);
if (newTime > limit) newTime = limit;
timeT newDuration = std::min
((*it)->getDuration(), segment.getEndMarkerTime() - newTime);
newEvent = new Event(**it, newTime, newDuration);
} else {
newEvent = new Event(**it, newTime);
}
newEvent->set<Int>(BaseProperties::PITCH, newPitch);
macro->addCommand(new MatrixModifyCommand(segment,
(*it),
newEvent,
true,
false));
newSelection->addEvent(newEvent);
}
normalizeStart = std::min(normalizeStart, newSelection->getStartTime());
normalizeEnd = std::max(normalizeEnd, newSelection->getEndTime());
macro->addCommand(new NormalizeRestsCommand(segment,
normalizeStart,
normalizeEnd));
m_scene->setSelection(0, false);
CommandHistory::getInstance()->addCommand(macro);
m_scene->setSelection(newSelection, false);
// m_mParentView->canvas()->update();
m_currentElement = 0;
setBasicContextHelp();
}
示例7: tr
void
MatrixResizer::handleMouseRelease(const MatrixMouseEvent *e)
{
if (!e || !m_currentElement || !m_currentViewSegment) return;
// snap in the closest direction
timeT snapTime = e->snappedLeftTime;
if (e->snappedRightTime - e->time < e->time - e->snappedLeftTime) {
snapTime = e->snappedRightTime;
}
timeT newDuration = snapTime - m_currentElement->getViewAbsoluteTime();
timeT durationDiff = newDuration - m_currentElement->getViewDuration();
EventSelection *selection = m_scene->getSelection();
if (!selection || selection->getAddedEvents() == 0) return;
QString commandLabel = tr("Resize Event");
if (selection->getAddedEvents() > 1) commandLabel = tr("Resize Events");
MacroCommand *macro = new MacroCommand(commandLabel);
EventSelection::eventcontainer::iterator it =
selection->getSegmentEvents().begin();
Segment &segment = m_currentViewSegment->getSegment();
EventSelection *newSelection = new EventSelection(segment);
timeT normalizeStart = selection->getStartTime();
timeT normalizeEnd = selection->getEndTime();
for (; it != selection->getSegmentEvents().end(); ++it) {
timeT t = (*it)->getAbsoluteTime();
timeT d = (*it)->getDuration();
MATRIX_DEBUG << "MatrixResizer::handleMouseRelease - "
<< "Time = " << t
<< ", Duration = " << d << endl;
d = d + durationDiff;
if (d < 0) {
t = t + d;
d = -d;
} else if (d == 0) {
d = getSnapGrid()->getSnapTime(t);
}
if (t + d > segment.getEndMarkerTime()) {
d = segment.getEndMarkerTime() - t;
if (d <= 0) {
d = segment.getEndMarkerTime();
t = d - getSnapGrid()->getSnapTime(t);
}
}
Event *newEvent = new Event(**it, t, d);
macro->addCommand(new MatrixModifyCommand(segment,
*it,
newEvent,
false,
false));
newSelection->addEvent(newEvent);
}
normalizeStart = std::min(normalizeStart, newSelection->getStartTime());
normalizeEnd = std::max(normalizeEnd, newSelection->getEndTime());
macro->addCommand(new NormalizeRestsCommand(segment,
normalizeStart,
normalizeEnd));
m_scene->setSelection(0, false);
CommandHistory::getInstance()->addCommand(macro);
m_scene->setSelection(newSelection, false);
// m_mParentView->update();
m_currentElement = 0;
setBasicContextHelp();
}