/// Send a signal to tie a parameter. void LocalParameterEditor::setTie() { auto tie = setTieDialog(m_tie); if (!tie.isEmpty()) { m_tie = tie; emit setTie(m_index, m_tie); } setEditorState(); }
/// Send a signal to tie a parameter. void LocalParameterEditor::setTie() { QInputDialog input; input.setWindowTitle("Set a tie."); input.setTextValue(m_tie); if (input.exec() == QDialog::Accepted) { auto tie = input.textValue(); emit setTie(m_index, tie); } }
MemoryOneModeNetwork::MemoryOneModeNetwork( std::vector<std::vector<double> > graph, bool directed, bool reflexive){ int size = graph.size(); init(size, directed, reflexive); for (int i = 0; i < graph.size(); i++){ for (int j = 0; j < graph[i].size(); j++){ if (graph[i][j] != 0){ setTie(i,j,graph[i][j]); } } } }
/// Filter events in the line editor to emulate a shortcut (F to fix/unfix). bool LocalParameterEditor::eventFilter(QObject *, QEvent *evn) { if (evn->type() == QEvent::KeyPress) { auto keyEvent = static_cast<QKeyEvent *>(evn); if (keyEvent->key() == Qt::Key_F && keyEvent->modifiers() == Qt::ControlModifier && m_tie.isEmpty()) { fixParameter(); return true; } if (m_tie.isEmpty()) { m_value = m_editor->text(); } else { m_tie = m_editor->text(); emit setTie(m_index, m_tie); } } return false; }
int setResult(char tok, char(*Team)[20], int a, int b)//set Win,lose,Tie for no violation rule { if (Team[a][b] != 0||Team[b][a]!=0)return 0; if (a == b) { Team[a][b] = 'X'; return 0; } if (tok == 'w') { setWL(Team, a, b); } else if (tok == 'l') { setWL(Team, b, a); } else { setTie(Team, a, b); } return 1; }
/// Constructor /// @param parent :: Parent widget. /// @param index :: Index of the spectrum which parameter is edited. /// @param fixed :: Is the parameter fixed initially? /// @param tie :: Parameter's current tie (or empty string). LocalParameterEditor::LocalParameterEditor(QWidget *parent, int index, bool fixed, QString tie): QWidget(parent), m_index(index),m_fixed(fixed), m_tie(tie) { auto layout = new QHBoxLayout(this); layout->setMargin(0); layout->setSpacing(0); layout->setContentsMargins(0,0,0,0); m_editor = new QLineEdit(parent); m_editor->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding); auto validator = new QDoubleValidator(this); validator->setDecimals(16); m_editor->setValidator(validator); m_editor->setToolTip("Edit local parameter value. Press F to fix/unfix it."); auto button = new QPushButton("&Set"); button->setSizePolicy(QSizePolicy::Minimum,QSizePolicy::Expanding); this->setFocusPolicy(Qt::NoFocus); layout->addWidget(m_editor); layout->addWidget(button); layout->setStretch(0,1); layout->setStretch(1,0); this->setFocusProxy(m_editor); this->setFocusPolicy(Qt::StrongFocus); auto setMenu = new QMenu(this); QAction *action = new QAction("Set to all",this); action->setToolTip("Set all parameters to this value"); connect(action,SIGNAL(activated()),this,SLOT(setAll())); setMenu->addAction(action); setMenu->addSeparator(); m_fixAction = new QAction(m_fixed? "Unfix" : "Fix", this); m_fixAction->setToolTip("Fix value of this parameter"); connect(m_fixAction,SIGNAL(activated()),this,SLOT(fixParameter())); setMenu->addAction(m_fixAction); action = new QAction("Fix all",this); action->setToolTip("Fix all parameters."); connect(action,SIGNAL(activated()),this,SLOT(fixAll())); setMenu->addAction(action); action = new QAction("Unfix all",this); action->setToolTip("Unfix all parameters."); connect(action,SIGNAL(activated()),this,SLOT(unfixAll())); setMenu->addAction(action); setMenu->addSeparator(); action = new QAction("Set tie",this); action->setToolTip("Set a tie for this parameter."); connect(action,SIGNAL(activated()),this,SLOT(setTie())); setMenu->addAction(action); action = new QAction("Remove tie",this); action->setToolTip("Remove the tie for this parameter."); connect(action,SIGNAL(activated()),this,SLOT(removeTie())); setMenu->addAction(action); action = new QAction("Set tie to all",this); action->setToolTip("Set this tie for all parameters."); connect(action,SIGNAL(activated()),this,SLOT(setTieAll())); setMenu->addAction(action); action = new QAction("Remove all ties",this); action->setToolTip("Remove ties for all parameters."); connect(action,SIGNAL(activated()),this,SLOT(removeAllTies())); setMenu->addAction(action); button->setMenu(setMenu); m_editor->installEventFilter(this); }
/// Send a signal to remove a tie. void LocalParameterEditor::removeTie() { emit setTie(m_index, ""); }
bool MemoryOneModeNetwork::removeTie(int i, int j) { return setTie(i, j, 0.0); }
bool MemoryOneModeNetwork::addTie(int i, int j) { return setTie(i, j, 1.0); }
bool NPmxExport::writeTrack(NVoice *voice, int staff_nr, int voice_nr, int voice_count, int measpsystem, bool first, const char *endOfLine, int *barpos) { NMusElement *elem; QString *lyrics; int total = 0; int total_per_system = 0; int part, countLyricsLines; #ifdef THIS_IS_WRONG bool base_shifted; #endif int numMeasures = 0; NStaff *actual_staff; NChord *chord; NNote *note; NRest *rest; NKeySig *ksig; NClef *clef; badmeasure *bad; property_type kind; int count, i = 0; char lastDynSym = 0; int dynEndPos = 0; int lastbarpos = *barpos; int elempos; #define OUTSIDE_BEAM 0 #define IN_BEAM_UP 1 #define IN_BEAM_DOWN 2 int beamstatus = OUTSIDE_BEAM; int hline; QString specialChar; QString *s; property_type grace_status; bool inGraceGroup = false; bool nested, toomany; QString graceString; NText *textElem; char pos; elem = voice->getCurrentPosition(); if (elem == 0) return false; elempos = elem->getXpos(); actual_staff = voice->getStaff(); if (pendingTimeSig_ && first) { specialChar.sprintf("m%d/%d/%d/%d ", pendingTimeSig_->getNumerator(), pendingTimeSig_->getDenominator(), pendingTimeSig_->getNumerator(), pendingTimeSig_->getDenominator()); countof128th_ = pendingTimeSig_->numOf128th(); pendingTimeSig_ = 0; handleSpecialChar(posOfpendingTimeSig_, &specialChar, voice_count, false); } if (pendingKeySig_ && first) { if (pendingKeySig_->isRegular(&kind, &count)) { if (kind == PROP_CROSS) { specialChar.sprintf("K+0+%d ", count); } else { specialChar.sprintf("K+0-%d ", count); } handleSpecialChar(posOfpendingKeySig_, &specialChar, voice_count, false); } pendingKeySig_ = 0; } if (pendingEndSpecialEnd_ && first) { specialChar = QString("Vx "); handleSpecialChar(posOfpendingSpecialEnd_, &specialChar, voice_count, false); pendingEndSpecialEnd_ = false; } if (pendingSpecialEnd_ && first) { if (pendingSpecialEnd_ == 1) { specialChar.sprintf("V1 "); } else { specialChar.sprintf("V2x "); } handleSpecialChar(posOfpendingSpecialEnd_, &specialChar, voice_count, false); if (pendingSpecialEnd_ == 2) openSpecialEnding_ = 1; pendingSpecialEnd_ = 0; } do { if (voice_count > 1 && voice_nr == voice_count - 1) { checkSpecialChar(elem->getXpos()); } elempos = elem->getXpos(); switch (elem->getType()) { case T_CHORD: chord = (NChord *) elem; part = elem->getSubType(); if (!(chord->hasProperty( PROP_GRACE ) )) { inGraceGroup = false; if (chord->hasProperty( PROP_TUPLET ) ) { total += chord->getPlaytime() * part / chord->getNumNotes(); } else { total += part; } } switch (chord->properties() & DOT_MASK ) { case 1: total += part / 2; break; case 2: total += 3 * part / 4; break; } if (total > MULTIPLICATOR*countof128th_ && voice_nr == 0) { total = 0; bad = new badmeasure(PMX_ERR_BAD_NOTE_COUNT, staff_nr, barNr_+numMeasures, total / 3, countof128th_); badlist_.append(bad); } if (va_descr_[staff_nr-1].trill_nr >= 0 && chord->getBbox()->right() > va_descr_[staff_nr-1].endpos) { *pmxout_ << "\\Toctfin" << va_descr_[staff_nr-1].trill_nr << "\\ "; vaPool_ &= (~(1 << va_descr_[staff_nr-1].trill_nr)); va_descr_[staff_nr-1].trill_nr = -1; } if (chord->va_ != 0) { hline = voice->findBorderLineInVa(chord); s = chord->computeTeXVa(hline, &vaPool_, &(actual_staff->actualClef_), &(va_descr_[staff_nr-1]), &nested, &toomany); if (nested) { bad = new badmeasure(PMX_ERR_NESTED_VAS, staff_nr, barNr_+numMeasures, 3 /* dummy */, 3 /* dummy */); badlist_.append(bad); } if (toomany) { bad = new badmeasure(PMX_ERR_TOO_MANY_VAS, staff_nr, barNr_+numMeasures, 3 /* dummy */, 3 /* dummy */); badlist_.append(bad); } if (s) { *pmxout_ << *s << "\\ "; delete s; } } if (pmxOpts_.keepBeams) { if ((chord->hasProperty( PROP_BEAMED ) ) && beamstatus == OUTSIDE_BEAM) { *pmxout_ << '['; if (chord->hasProperty( PROP_STEM_UP ) ) { beamstatus = IN_BEAM_UP; *pmxout_ << "u "; } else { beamstatus = IN_BEAM_DOWN; *pmxout_ << "l "; } } } if (!pmxOpts_.mLyr) { countLyricsLines = chord->countOfLyricsLines(); for (i = countLyricsLines-1; i >= 0; i--) { lyrics = chord->getLyrics(i); if (lyrics) { *pmxout_ << " \\zcharnote{" << -8 - (int) ((actual_staff->staff_props_.lyricsdist - DEFAULT_LYRICSDIST ) * PMX_FAC) -i*4 << "}{"<< lyrics2TeX(lyrics) << "}\\relax\\ "; } else { *pmxout_ << " \\zcharnote{}\\relax\\ "; } } } if (!inGraceGroup && chord->hasProperty( PROP_GRACE ) ) { graceString = voice->determineGraceKind(&grace_status); inGraceGroup = true; if (grace_status == WARN_MIXED_GRACES) { bad = new badmeasure(PMX_WARN_MIXED_GRACES, i+1, 0, 3 /*dummy */, 128 /*dummy */); badlist_.append(bad); } else if (grace_status == GRACE_PMX_ERROR) { bad = new badmeasure(PMX_ERR_GRACES, i+1, 0, 3 /*dummy */, 128 /*dummy */); badlist_.append(bad); } *pmxout_ << graceString; } if (beamstatus == IN_BEAM_UP) { note = chord->getNoteList()->last(); } else { note = chord->getNoteList()->first(); } pitchOut(&(actual_staff->actualKeysig_), note, elem->getSubType(), &(actual_staff->actualClef_), chord, staff_nr, barNr_+numMeasures); if (!drum_problem_written_ && (note->properties & BODY_MASK)) { drum_problem_written_ = true; bad = new badmeasure(PMX_ERR_DRUM_STAFF, staff_nr, barNr_+numMeasures, total / 3, countof128th_); badlist_.append(bad); } switch (chord->properties() & DOT_MASK ) { case 1: *pmxout_ << "d"; break; case 2: *pmxout_ << "dd"; break; } if ((chord->hasProperty( PROP_TUPLET ) ) && elem->getSubType() != tupletBase_) *pmxout_ << 'D'; #ifdef THIS_IS_WRONG base_shifted = note->properties & PROP_SHIFTED; #endif *pmxout_ << ' '; if (chord->hasProperty( PROP_STACC ) ) { *pmxout_ << "ou "; } if (chord->hasProperty( PROP_SFORZ ) ) { *pmxout_ << "o^ "; } if (chord->hasProperty( PROP_PORTA ) ) { *pmxout_ << "o_ "; } if (chord->hasProperty( PROP_SFZND ) ) { *pmxout_ << "o> "; } if (chord->hasProperty( PROP_FERMT ) ) { *pmxout_ << "of "; } if (chord->hasProperty( PROP_ARPEGG ) ) { *pmxout_ << "? "; } if (chord->trill_ < 0) { *pmxout_ << "oTt" << voice->findNoteCountTillTrillEnd(chord) << ' '; } else if (chord->trill_ > 0) { *pmxout_ << "oTt" << voice->findNoteCountTillTrillEnd(chord) << ' '; } if (chord->dynamic_) { *pmxout_ << 'D' << (chord->dynamicAlign_ ? '<' : '>') << ' '; dynEndPos = chord->getDynamicEnd(); lastDynSym = (chord->dynamicAlign_ ? '>' : '<'); } else if (lastDynSym && chord->getBbox()->right() > dynEndPos) { *pmxout_ << 'D' << lastDynSym << ' '; lastDynSym = 0; dynEndPos = 0; } setTie(note, staff_nr, barNr_+numMeasures); setSlur(chord, staff_nr, barNr_+numMeasures); if (beamstatus == IN_BEAM_UP) { note = chord->getNoteList()->prev(); } else { note = chord->getNoteList()->next(); } while (note) { *pmxout_ << "z"; pitchOut(&(actual_staff->actualKeysig_), note, -1, &(actual_staff->actualClef_), chord, staff_nr, barNr_+numMeasures); if (!drum_problem_written_ && (note->properties & BODY_MASK)) { drum_problem_written_ = true; bad = new badmeasure(PMX_ERR_DRUM_STAFF, staff_nr, barNr_+numMeasures, total / 3, countof128th_); badlist_.append(bad); } #ifdef THIS_IS_WRONG if (base_shifted) { if (!(note->properties & PROP_SHIFTED)) *pmxout_ << "r"; } else { if (note->properties & PROP_SHIFTED) *pmxout_ << "r"; } #endif *pmxout_ << ' '; setTie(note, staff_nr, barNr_+numMeasures); if (beamstatus == IN_BEAM_UP) { note = chord->getNoteList()->prev(); } else { note = chord->getNoteList()->next(); } } if (chord->hasProperty( PROP_ARPEGG ) ) { *pmxout_ << "? "; } if (pmxOpts_.keepBeams) { if (beamstatus != OUTSIDE_BEAM && chord->lastBeamed()) { beamstatus = OUTSIDE_BEAM; *pmxout_ << " ] "; } } break; case T_REST: rest = elem->rest(); inGraceGroup = false; part = elem->getSubType(); if (part == MULTIREST) { total += MULTIPLICATOR*countof128th_; } else { if (rest->hasProperty( PROP_TUPLET ) ) { total += rest->getPlaytime() * part / rest->getNumNotes(); } else { total += part; } } switch (rest->properties() & DOT_MASK ) { case 1: total += part / 2; break; case 2: total += 3 * part / 4; break; } if (total > MULTIPLICATOR*countof128th_ && voice_nr == 0) { total = 0; bad = new badmeasure(PMX_ERR_BAD_NOTE_COUNT, staff_nr, barNr_+numMeasures, total / 3, countof128th_); badlist_.append(bad); } *pmxout_ << 'r'; if (rest->hasProperty( PROP_HIDDEN ) ) *pmxout_ << 'b'; if (rest->hasProperty( PROP_TUPLET ) ) { if (rest->isFirstInTuplet()) { inspectTuplet(rest, staff_nr, barNr_+numMeasures); *pmxout_ << computePMXTupletLength(rest->getPlaytime()*tupletBase_, staff_nr, barNr_+numMeasures); lastLength_ = rest->getPlaytime()*tupletBase_; } } else if (part == MULTIREST) { if (staffsToExport_ > 1) { bad = new badmeasure(PMX_ERR_MULTIREST, staff_nr, barNr_+numMeasures, total / 3, countof128th_); badlist_.append(bad); } lastLength_ = 1111; /* invalidate */ *pmxout_ << 'm' << rest->getMultiRestLength(); } else if (lastLength_ != elem->getSubType()) { *pmxout_ << computePMXLength(elem->getSubType()); lastLength_ = elem->getSubType(); } switch (rest->properties() & DOT_MASK) { case 1: *pmxout_ << "d"; break; case 2: *pmxout_ << "dd"; break; } if (rest->hasProperty( PROP_TUPLET ) ) { if (rest->isFirstInTuplet()) *pmxout_ << "x" << (int) (rest->getNumNotes()); if (elem->getSubType() != tupletBase_) *pmxout_ << 'D'; } *pmxout_ << ' '; break; case T_SIGN: inGraceGroup = false; switch (elem->getSubType ()) { case END_BAR: case SIMPLE_BAR: if (total != MULTIPLICATOR*countof128th_ && barNr_+numMeasures > 1 && voice_nr == 0 ) { bad = new badmeasure(PMX_ERR_BAD_NOTE_COUNT, staff_nr, barNr_+numMeasures, total / 3, countof128th_); badlist_.append(bad); } total_per_system += total; total = 0; numMeasures++; lastTone_ = 1000; if (barNr_+numMeasures > 1 && testContextChange(voice_nr, voice, first)) { if (first) barNr_ -= measpsystem - numMeasures; *pmxout_ << endOfLine; *barpos = elem->getXpos(); elem = voice->getNextPosition(); return true; } if (numMeasures >= measpsystem || voice->isLast()) { *barpos = elem->getXpos(); elem = voice->getNextPosition(); *pmxout_ << endOfLine; return true; } specialChar = QString("| "); handleSpecialChar(elempos, &specialChar, voice_count, true); break; case DOUBLE_BAR: case REPEAT_OPEN: case REPEAT_CLOSE: case REPEAT_OPEN_CLOSE: if (total != MULTIPLICATOR*countof128th_ && barNr_+numMeasures > 1 && voice_nr == 0) { bad = new badmeasure(PMX_ERR_BAD_NOTE_COUNT, staff_nr, barNr_+numMeasures, total / 3, countof128th_); badlist_.append(bad); } total_per_system += total; total = 0; numMeasures++; lastTone_ = 1000; if (first) { specialChar = QString("R"); switch (elem->getSubType ()) { case REPEAT_OPEN: specialChar += "l "; break; case REPEAT_CLOSE: specialChar += "r "; break; case REPEAT_OPEN_CLOSE: specialChar += "lr "; break; case DOUBLE_BAR: specialChar += "d "; break; } handleSpecialChar(elempos, &specialChar, voice_count, false); } if (barNr_+numMeasures > 1 && testContextChange(voice_nr, voice, first)) { *barpos = elem->getXpos(); elem = voice->getNextPosition(); if (first) barNr_ -= measpsystem - numMeasures; *pmxout_ << endOfLine; return true; } if (!(numMeasures >= measpsystem || voice->isLast())) { specialChar = QString("| "); handleSpecialChar(elempos, &specialChar, voice_count, true); } if (numMeasures >= measpsystem || voice->isLast()) { *barpos = elem->getXpos(); elem = voice->getNextPosition(); *pmxout_ << endOfLine; return true; } break; case SEGNO: if (staff_nr != staffsToExport_ || voice_nr != 0) break; *pmxout_ << "og "; break; case CODA: *pmxout_ << "\\hsk\\coda " << actual_staff->actualClef_.line2TexTab_[12+LINE_OVERFLOW] <<"\\hsk\\ "; break; case DAL_SEGNO: *pmxout_ << "\\Uptext{D.S.}\\sk\\sk\\ "; break; case DAL_SEGNO_AL_FINE: *pmxout_ << "\\Uptext{D.S. al Fine}\\sk\\sk\\ "; break; case DAL_SEGNO_AL_CODA: *pmxout_ << "\\Uptext{D.S. al Coda}\\sk\\sk\\ "; break; case FINE: *pmxout_ << "\\Uptext{Fine}\\sk\\sk\\ "; break; case RITARDANDO: *pmxout_ << "\\Uptext{ritard.}\\ "; break; case ACCELERANDO: *pmxout_ << "\\Uptext{accel.}\\ "; break; } break; case T_CLEF: inGraceGroup = false; clef = (NClef *) elem; actual_staff->actualClef_.change(clef); if (barNr_ < 2) break; switch (clef->getSubType()) { case BASS_CLEF: specialChar = QString("Cb "); break; case SOPRANO_CLEF: specialChar = QString("Cs "); break; case ALTO_CLEF: specialChar = QString("Ca "); break; case TENOR_CLEF: specialChar = QString("Cn "); break; case DRUM_CLEF: if (!drum_problem_written_) { drum_problem_written_ = true; bad = new badmeasure(PMX_ERR_DRUM_STAFF, i+1, 0, 3 /*dummy */, 128 /*dummy */); badlist_.append(bad); } case DRUM_BASS_CLEF: if (!drum_problem_written_) { drum_problem_written_ = true; bad = new badmeasure(PMX_ERR_DRUM_STAFF, i+1, 0, 3 /*dummy */, 128 /*dummy */); badlist_.append(bad); } default: specialChar = QString("Ct "); break; } handleSpecialChar(elempos, &specialChar, voice_count, false); break; case T_KEYSIG: if (barNr_ < 2) break; ksig = (NKeySig *) elem; if (ksig->isRegular(&kind, &count)) { if (kind == PROP_CROSS) { specialChar.sprintf("K+0+%d ", count); } else { specialChar.sprintf("K+0-%d ", count); } handleSpecialChar(posOfpendingKeySig_, &specialChar, voice_count, false); } break; case T_TEXT: textElem = (NText *) elem; if (textElem->getSubType() == TEXT_UPTEXT) { pos = actual_staff->actualClef_.line2TexTab_[11+LINE_OVERFLOW]; } else { pos = actual_staff->actualClef_.line2TexTab_[-3+LINE_OVERFLOW]; } *pmxout_ << "\\zcharnote{" << pos << "}{\\bf " << textElem->getText() << "}\\relax\\ "; break; } elem = voice->getNextPosition(); } while (elem && elem->getXpos() < lastbarpos); if (voice_nr == 0) { *barpos = (1 << 30); /* infinity */ #ifdef THIS_DOES_NOT_WORK append_hidden_rests(measpsystem, total_per_system); #endif } #ifdef THIS_DOES_NOT_WORK else { append_hidden_rests(measpsystem, total); } #endif if (numMeasures < measpsystem) *pmxout_ << endOfLine; return true; }
/// Send a signal to remove a tie. void LocalParameterEditor::removeTie() { m_tie = ""; emit setTie(m_index, ""); setEditorState(); }