ExcitationThread::ExcitationThread(QObject* parent, const QString& aWrkDir, const ExcitationInfo& aCfg, QWidget* aFeedback) : QThread(parent) { this->wrkDir = aWrkDir; this->cfg = aCfg; this->feedback = aFeedback; connect(this, SIGNAL(showStatus(const QString&)), this->feedback, SLOT(showStatus(const QString&))); connect(this, SIGNAL(showStatus(const QString&, int)), this->feedback, SLOT(showStatus(const QString&, int))); connect(this, SIGNAL(showCritical(const QString&)), this->feedback, SLOT(showCritical(const QString&))); connect(this, SIGNAL(generated()), this->feedback, SLOT(generated())); }
void Password::generate(const SecureByteArray &masterPassword) { Q_D(Password); const SecureByteArray &pwd = d->domainSettings.domainName.toUtf8() + d->domainSettings.userName.toUtf8() + masterPassword; d->pbkdf2.generate(pwd, QByteArray::fromBase64(d->domainSettings.salt_base64.toUtf8()), d->domainSettings.iterations, QCryptographicHash::Sha512); const int nChars = d->domainSettings.usedCharacters.count(); if (nChars > 0) { d->key.clear(); const QString strModulus = QString("%1").arg(nChars); BigInt::Rossi v(d->pbkdf2.hexKey().toStdString(), BigInt::HEX_DIGIT); const BigInt::Rossi Modulus(strModulus.toStdString(), BigInt::DEC_DIGIT); static const BigInt::Rossi Zero(0); int n = d->domainSettings.length; while (v > Zero && n-- > 0) { const BigInt::Rossi &mod = v % Modulus; d->key += d->domainSettings.usedCharacters.at(mod.toUlong()); v = v / Modulus; } emit generated(); } }
void agg_configuration::generate(const aggregate_type typ, const field_num field, simple_tuple_list& cont) { vm::tuple* generated(do_generate(typ, field)); /* cout << "Generated from "; if(generated) cout << *generated; cout << endl; vals.dump(cout); cout << endl; */ changed = false; if(corresponds == NULL) { // new if(generated != NULL) cont.push_back(simple_tuple::create_new(generated)); } else if (generated == NULL) { if(corresponds != NULL) cont.push_back(simple_tuple::remove_new(corresponds)); } else { if(!(*corresponds == *generated)) { cont.push_back(simple_tuple::remove_new(corresponds)); cont.push_back(simple_tuple::create_new(generated)); } } corresponds = generated; }
void Rest::draw(QPainter* painter) const { if ( (staff() && staff()->isTabStaff() // in tab staff, do not draw rests is rests are off OR if dur. symbols are on && (!staff()->staffType()->showRests() || staff()->staffType()->genDurations())) || generated()) return; qreal _spatium = spatium(); painter->setPen(curColor()); if (parent() && measure() && measure()->isMMRest()) { //only on voice 1 if ((track() % VOICES) != 0) return; Measure* m = measure(); int n = m->mmRestCount(); qreal pw = _spatium * .7; QPen pen(painter->pen()); pen.setWidthF(pw); painter->setPen(pen); qreal w = _mmWidth; qreal y = 0.0; qreal x1 = 0.0; qreal x2 = w; pw *= .5; painter->drawLine(QLineF(x1 + pw, y, x2 - pw, y)); // draw vertical lines: pen.setWidthF(_spatium * .2); painter->setPen(pen); painter->drawLine(QLineF(x1, y-_spatium, x1, y+_spatium)); painter->drawLine(QLineF(x2, y-_spatium, x2, y+_spatium)); painter->setFont(score()->scoreFont()->font()); QFontMetricsF fm(score()->scoreFont()->font()); QString s = toTimeSigString(QString("%1").arg(n)); y = -_spatium * 1.5 - staff()->height() *.5; qreal x = center(x1, x2); x -= symBbox(s).width() * .5; drawSymbols(s, painter, QPointF(x, y)); } else { drawSymbol(_sym, painter); int dots = durationType().dots(); if (dots) { qreal y = dotline * _spatium * .5; for (int i = 1; i <= dots; ++i) { qreal x = symWidth(_sym) + point(score()->styleS(StyleIdx::dotNoteDistance)) * i; drawSymbol(SymId::augmentationDot, painter, QPointF(x, y)); } } } }
void Rest::draw(QPainter* painter) const { if ( (staff() && staff()->isTabStaff() // in tab staff, do not draw rests is rests are off OR if dur. symbols are on && ( !((StaffTypeTablature*)staff()->staffType())->showRests() || ((StaffTypeTablature*)staff()->staffType())->genDurations()) ) || generated()) return; qreal _spatium = spatium(); painter->setPen(curColor()); if (parent() && measure() && measure()->multiMeasure()) { Measure* m = measure(); int n = m->multiMeasure(); qreal pw = _spatium * .7; QPen pen(painter->pen()); pen.setWidthF(pw); painter->setPen(pen); qreal w = _mmWidth; qreal y = _spatium; qreal x1 = 0.0; qreal x2 = w; pw *= .5; painter->drawLine(QLineF(x1 + pw, y, x2 - pw, y)); // draw vertical lines: pen.setWidthF(_spatium * .2); painter->setPen(pen); painter->drawLine(QLineF(x1, y-_spatium, x1, y+_spatium)); painter->drawLine(QLineF(x2, y-_spatium, x2, y+_spatium)); QFont font(fontId2font(0)); painter->setFont(font); QFontMetricsF fm(font); y = -_spatium * .5 - fm.ascent(); painter->drawText(QRectF(center(x1, x2), y, .0, .0), Qt::AlignHCenter|Qt::TextDontClip, QString("%1").arg(n)); } else { qreal mag = magS(); symbols[score()->symIdx()][_sym].draw(painter, mag); int dots = durationType().dots(); if (dots) { qreal y = dotline * _spatium * .5; for (int i = 1; i <= dots; ++i) { qreal x = symbols[score()->symIdx()][_sym].width(mag) + point(score()->styleS(ST_dotNoteDistance)) * i; symbols[score()->symIdx()][dotSym].draw(painter, mag, QPointF(x, y)); } } } }
void QScxmlcGenerator::finishProcess() { parseIssues(m_process.readAllStandardError()); setCompileTime(QDateTime::currentDateTime()); foreach (const Utils::FileName &target, targets()) { QFile generated(m_tmpdir.path() + QLatin1Char('/') + target.fileName()); if (!generated.open(QIODevice::ReadOnly)) continue; setContent(target, generated.readAll()); }
void TranslationHandler::onMultipleGenerationFinished(bool ok) { Request *req = m_pendingRequests.take(sender()); if (ok && req) { QMultiMap<Type,QString> words; QWebElement table = req->webFrame()->findFirstElement("table"); QWebElementCollection items = table.findAll("li"); foreach (const QWebElement &item, items) words.insert(Any, item.toPlainText()); emit generated(words); } else {
void TestWritingBinaryFormat() { //Read as ascii TrianglesMeshReader<2,2> reader("mesh/test/data/mixed_dimension_meshes/2D_0_to_1mm_200_elements"); //Write as binary TrianglesMeshWriter<2,2> writer_from_reader("TestMixedDimensionMesh", "CableMeshBinary", false); writer_from_reader.SetWriteFilesAsBinary(); writer_from_reader.WriteFilesUsingMeshReader(reader); PetscTools::Barrier(); //Read created binary file into a mesh std::string results_dir = OutputFileHandler::GetChasteTestOutputDirectory() + "TestMixedDimensionMesh/"; TrianglesMeshReader<2,2> binary_reader(results_dir + "CableMeshBinary"); MixedDimensionMesh<2,2> binary_mesh(DistributedTetrahedralMeshPartitionType::DUMB); binary_mesh.ConstructFromMeshReader(binary_reader); //Read original file into a mesh std::string mesh_base("mesh/test/data/mixed_dimension_meshes/2D_0_to_1mm_200_elements"); TrianglesMeshReader<2,2> original_reader(mesh_base); MixedDimensionMesh<2,2> original_mesh(DistributedTetrahedralMeshPartitionType::DUMB); original_mesh.ConstructFromMeshReader(original_reader); //Compare to original TS_ASSERT_EQUALS(binary_mesh.GetNumNodes(), original_mesh.GetNumNodes()); TS_ASSERT_EQUALS(binary_mesh.GetNumElements(), original_mesh.GetNumElements()); TS_ASSERT_EQUALS(binary_mesh.GetNumCableElements(), original_mesh.GetNumCableElements()); MixedDimensionMesh<2,2>::CableElementIterator original_iter = original_mesh.GetCableElementIteratorBegin(); for (MixedDimensionMesh<2,2>::CableElementIterator binary_iter = binary_mesh.GetCableElementIteratorBegin(); binary_iter != binary_mesh.GetCableElementIteratorEnd(); ++binary_iter) { TS_ASSERT_EQUALS((*binary_iter)->GetNumNodes(), (*original_iter)->GetNumNodes()); TS_ASSERT_EQUALS((*binary_iter)->GetNodeGlobalIndex(0u), (*original_iter)->GetNodeGlobalIndex(0u)); TS_ASSERT_EQUALS((*binary_iter)->GetNodeGlobalIndex(1u), (*original_iter)->GetNodeGlobalIndex(1u)); TS_ASSERT_DELTA((*binary_iter)->GetAttribute(), (*original_iter)->GetAttribute(), 1e-12); ++original_iter; } //Write a binary from the original mesh TrianglesMeshWriter<2,2> writer_from_mesh("TestMixedDimensionMesh", "CableMeshBinaryFromMesh", false); writer_from_mesh.SetWriteFilesAsBinary(); writer_from_mesh.WriteFilesUsingMesh(original_mesh); //Compare the binary written from the reader to the binary written from the mesh FileFinder generated(results_dir + "/CableMeshBinary.cable"); FileFinder reference(results_dir + "/CableMeshBinaryFromMesh.cable"); FileComparison comparer(generated,reference); TS_ASSERT(comparer.CompareFiles()); }
std::vector<TrackProjection> generateRandomTrackProjections(int N) { std::default_random_engine generator; std::normal_distribution<double> distribution(5.0,2.0); std::vector<TrackProjection> generated(N); for (TrackProjection& track : generated) { track.x0 = distribution(generator); track.dx = distribution(generator); } return std::move(generated); }
void ExcitationThread::run() { emit showStatus("Generating excitation..."); try { Excitation::generate( this->wrkDir, this->cfg); emit generated(); } catch(QLE e) { emit showCritical(e.msg); emit showStatus("Excitation generating failed!", 2000); return; } emit showStatus("Excitation and inverse filter are generated!", 2000); }
void TestWritingCableFilesUsingMeshReader() throw(Exception) { std::string mesh_base("mesh/test/data/mixed_dimension_meshes/2D_0_to_1mm_200_elements"); TrianglesMeshReader<2,2> reader(mesh_base); TrianglesMeshWriter<2,2> mesh_writer("TestMixedDimensionMesh", "CableMeshFromReader"); mesh_writer.WriteFilesUsingMeshReader(reader); PetscTools::Barrier("TestWritingCableFilesUsingMeshReader"); FileFinder generated("TestMixedDimensionMesh/CableMeshFromReader.cable",RelativeTo::ChasteTestOutput); FileFinder reference("mesh/test/data/mixed_dimension_meshes/2D_0_to_1mm_200_elements.cable", RelativeTo::ChasteSourceRoot); FileComparison comparer(generated,reference); TS_ASSERT(comparer.CompareFiles()); }
std::vector<Hit> generateRandomHits(int N) { std::default_random_engine generator; std::normal_distribution<double> distribution(5.0,2.0); std::vector<Hit> generated(N); for (Hit& hit : generated) { hit.x = distribution(generator); hit.y = distribution(generator); hit.z = distribution(generator); } return std::move(generated); }
void TestWritingCableFiles() throw(Exception) { std::string mesh_base("mesh/test/data/mixed_dimension_meshes/2D_0_to_1mm_200_elements"); TrianglesMeshReader<2,2> reader(mesh_base); MixedDimensionMesh<2,2> mesh(DistributedTetrahedralMeshPartitionType::DUMB); mesh.ConstructFromMeshReader(reader); TrianglesMeshWriter<2,2> mesh_writer("TestMixedDimensionMesh", "CableMesh", true); mesh_writer.WriteFilesUsingMesh(mesh); FileFinder generated("TestMixedDimensionMesh/CableMesh.cable",RelativeTo::ChasteTestOutput); FileFinder reference("mesh/test/data/mixed_dimension_meshes/2D_0_to_1mm_200_elements.cable", RelativeTo::ChasteSourceRoot); FileComparison comparer(generated,reference); TS_ASSERT(comparer.CompareFiles()); }
bool KeySig::setProperty(P_ID propertyId, const QVariant& v) { switch(propertyId) { case P_ID::SHOW_COURTESY: if (generated()) return false; setShowCourtesy(v.toBool()); break; default: if (!Element::setProperty(propertyId, v)) return false; break; } score()->setLayoutAll(true); setGenerated(false); return true; }
void Rest::draw(Painter* painter) const { if (staff()->useTablature() || generated()) return; qreal _spatium = spatium(); Measure* m = measure(); if (m && m->multiMeasure()) { int n = m->multiMeasure(); qreal pw = _spatium * .7; painter->setLineWidth(pw); qreal w = _mmWidth; qreal y = _spatium; qreal x1 = 0.0; qreal x2 = w; pw *= .5; painter->drawLine(x1 + pw, y, x2 - pw, y); // draw vertical lines: painter->setLineWidth(_spatium * .2); painter->drawLine(x1, y-_spatium, x1, y+_spatium); painter->drawLine(x2, y-_spatium, x2, y+_spatium); QFont font = symbols[score()->symIdx()][allabreveSym].font(); painter->setFont(font); QFontMetricsF fm(font); y = -_spatium * .5 - fm.ascent(); painter->drawTextHCentered(center(x1, x2), y, QString("%1").arg(n)); } else { qreal mag = magS(); symbols[score()->symIdx()][_sym].draw(painter, mag); int dots = durationType().dots(); if (dots) { qreal y = dotline * _spatium * .5; for (int i = 1; i <= dots; ++i) { qreal x = symbols[score()->symIdx()][_sym].width(mag) + point(score()->styleS(ST_dotNoteDistance)) * i; symbols[score()->symIdx()][dotSym].draw(painter, mag, x, y); } } } }
void ReflectanceModelDockWidget::generateBrdf() { std::cout << "[ReflectanceModelDockWidget::generateBrdf]" << std::endl; osg::Timer_t startTick = osg::Timer::instance()->tick(); QString name = ui_->reflectanceModelComboBox->currentText(); lb::ReflectanceModel* model = reflectanceModels_[name.toLocal8Bit().data()]; QColor color = colors_.at(ui_->reflectanceModelComboBox->currentIndex()); lb::Brdf* brdf = initializeBrdf(model->isIsotropic()); lb::setupBrdf(*model, brdf, qt_osg_util::qtToLb(color)); osg::Timer_t endTick = osg::Timer::instance()->tick(); double delta = osg::Timer::instance()->delta_s(startTick, endTick); std::cout << "[ReflectanceModelDockWidget::generateBrdf] " << delta << "(s)" << std::endl; emit generated(brdf, lb::BRDF_DATA); }
bool TimeSig::setProperty(P_ID propertyId, const QVariant& v) { switch (propertyId) { case P_ID::SHOW_COURTESY: if (generated()) return false; setShowCourtesySig(v.toBool()); break; case P_ID::NUMERATOR_STRING: setNumeratorString(v.toString()); break; case P_ID::DENOMINATOR_STRING: setDenominatorString(v.toString()); break; case P_ID::GROUPS: setGroups(v.value<Groups>()); break; case P_ID::TIMESIG: setSig(v.value<Fraction>()); break; case P_ID::TIMESIG_GLOBAL: setGlobalSig(v.value<Fraction>()); break; case P_ID::TIMESIG_STRETCH: setStretch(v.value<Fraction>()); break; case P_ID::TIMESIG_TYPE: _timeSigType = (TimeSigType)(v.toInt()); break; case P_ID::SCALE: _scale = v.toSizeF(); break; default: if (!Element::setProperty(propertyId, v)) return false; break; } score()->setLayoutAll(); // TODO setGenerated(false); return true; }
void Clef::layout() { // determine current number of lines and line distance int lines; qreal lineDist; Segment* clefSeg = segment(); // check clef visibility and type compatibility if (clefSeg && staff()) { StaffType* staffType = staff()->staffType(); bool show = staffType->genClef(); // check staff type allows clef display int tick = clefSeg->tick(); // check clef is compatible with staff type group: if (ClefInfo::staffGroup(clefType()) != staffType->group()) { if (tick > 0 && !generated()) // if clef is not generated, hide it show = false; else // if generated, replace with initial clef type // TODO : instead of initial staff clef (which is assumed to be compatible) // use the last compatible clef previously found in staff _clefTypes = staff()->clefType(0); } // if clef not to show or not compatible with staff group if (!show) { setbbox(QRectF()); qDebug("Clef::layout(): invisible clef at tick %d(%d) staff %d", segment()->tick(), segment()->tick()/1920, staffIdx()); return; } lines = staffType->lines(); // init values from staff type lineDist = staffType->lineDistance().val(); } else { lines = 5; lineDist = 1.0; } qreal _spatium = spatium(); qreal yoff = 0.0; if (clefType() != ClefType::INVALID && clefType() != ClefType::MAX) { symId = ClefInfo::symId(clefType()); yoff = lineDist * (lines - ClefInfo::line(clefType())); } switch (clefType()) { case ClefType::C_19C: // 19th C clef is like a G clef yoff = lineDist * 1.5; break; case ClefType::TAB: // TAB clef // on tablature, position clef at half the number of spaces * line distance yoff = lineDist * (lines - 1) * .5; break; case ClefType::TAB4: // TAB clef 4 strings // on tablature, position clef at half the number of spaces * line distance yoff = lineDist * (lines - 1) * .5; break; case ClefType::TAB_SERIF: // TAB clef alternate style // on tablature, position clef at half the number of spaces * line distance yoff = lineDist * (lines - 1) * .5; break; case ClefType::TAB4_SERIF: // TAB clef alternate style // on tablature, position clef at half the number of spaces * line distance yoff = lineDist * (lines - 1) * .5; break; case ClefType::PERC: // percussion clefs yoff = lineDist * (lines - 1) * 0.5; break; case ClefType::PERC2: yoff = lineDist * (lines - 1) * 0.5; break; case ClefType::INVALID: case ClefType::MAX: qDebug("Clef::layout: invalid type"); return; default: break; } // clefs are right aligned to Segment QRectF r(symBbox(symId)); // setPos(-r.right(), yoff * _spatium); setPos(0.0, yoff * _spatium); setbbox(r); }
void Clef::layout() { // determine current number of lines and line distance int lines = 5; // assume resonable defaults qreal lineDist = 1.0; Staff* stf = staff(); StaffType* staffType = nullptr; Segment* clefSeg = static_cast<Segment*>(parent()); // check clef visibility and type compatibility if (clefSeg && stf && stf->staffType()) { bool bHide; // check staff type allows clef display staffType = staff()->staffType(); #if 0 // <<<<<<< HEAD if (!staffType->genClef()) { // if no clef, set empty bbox and do nothing qDeleteAll(elements); elements.clear(); setbbox(QRectF()); return; } // tablatures: if (staffType->group() == StaffGroup::TAB) { // if current clef type not compatible with tablature, // set tab clef according to score style if (ClefInfo::staffGroup(clefType()) != StaffGroup::TAB) setClefType( ClefType(score()->styleI(StyleIdx::tabClef)) ); #else bHide = !staffType->genClef(); // check clef is compatible with staff type group int tick = clefSeg->tick(); if (ClefInfo::staffGroup(clefType()) != staffType->group()) { if (tick > 0 && !generated()) // if clef is not generated, hide it bHide = true; else // if generated, replace with initial clef type // TODO : instead of initial staff clef (which is assumed to be compatible) // use the last compatible clef previously found in staff _clefTypes = stf->clefTypeList(0); #endif // >>>>>>> 38c666fa91f5bdaaa6d9ca0645c437c799be8c79 } // // courtesy clef // bool showClef = true; #if 0 // <<<<<<< HEAD Segment* clefSeg = static_cast<Segment*>(parent()); if (clefSeg) { int tick = clefSeg->tick(); // only if there is a clef change if (stf->clef(tick) != stf->clef(tick-1)) { // locate clef at the begining of next measure, if any Clef* clefNext = nullptr; Segment* clefSegNext = nullptr; Measure* meas = static_cast<Measure*>(clefSeg->parent()); Measure* measNext = meas->nextMeasure(); if (measNext) { clefSegNext = measNext->findSegment(SegmentType::Clef, tick); if (clefSegNext) clefNext = static_cast<Clef*>(clefSegNext->element(track())); } // show this clef if: it is not a courtesy clef (no next clef or not at the end of the measure) showClef = !clefNext || (clefSeg->tick() != meas->tick() + meas->ticks()) // if courtesy clef: show if score has courtesy clefs on || ( score()->styleB(StyleIdx::genCourtesyClef) // AND measure is not at the end of a repeat or of a section && !( (meas->repeatFlags() & Repeat::END) || meas->sectionBreak() ) // AND this clef has courtesy clef turned on && showCourtesy() ); if (!showClef) { // if no clef, set empty bbox and do nothing qDeleteAll(elements); elements.clear(); setbbox(QRectF()); return; } #else // only if there is a clef change if (!bHide && tick > 0 && stf->clef(tick) != stf->clef(tick-1)) { // locate clef at the begining of next measure, if any Clef* clefNext = nullptr; Segment* clefSegNext = nullptr; Measure* meas = static_cast<Measure*>(clefSeg->parent()); Measure* measNext = meas->nextMeasure(); if (measNext) { clefSegNext = measNext->findSegment(SegmentType::Clef, tick); if (clefSegNext) clefNext = static_cast<Clef*>(clefSegNext->element(track())); #endif // >>>>>>> 38c666fa91f5bdaaa6d9ca0645c437c799be8c79 } // show this clef if: it is not a courtesy clef (no next clef or not at the end of the measure) showClef = !clefNext || (clefSeg->tick() != meas->tick() + meas->ticks()) // if courtesy clef: show if score has courtesy clefs on || ( score()->styleB(StyleIdx::genCourtesyClef) // AND measure is not at the end of a repeat or of a section && !( (meas->repeatFlags() & Repeat::END) || meas->sectionBreak() ) // AND this clef has courtesy clef turned on && showCourtesy() ); bHide |= !showClef; } // if clef not to show or not compatible with staff group if (bHide) { qDeleteAll(elements); // set empty bbox and do nothing elements.clear(); setbbox(QRectF()); return; } lines = staffType->lines(); // init values from staff type lineDist = staffType->lineDistance().val(); } // if nothing changed since last layout, do nothing //DEBUG if (curClefType == clefType() && curLines == lines && curLineDist == lineDist) // return; // if something has changed, cache new values and re-layout curClefType = clefType(); curLines = lines; curLineDist = lineDist; layout1(); } //--------------------------------------------------------- // layout1 //--------------------------------------------------------- void Clef::layout1() { qreal smag = mag(); qreal _spatium = spatium(); // qreal msp = score()->spatium() * smag; qreal yoff = 0.0; qDeleteAll(elements); elements.clear(); Symbol* symbol = new Symbol(score()); switch (curClefType) { case ClefType::G: // G clef on 2nd line symbol->setSym(SymId::gClef); yoff = 3.0 * curLineDist; break; case ClefType::G1: // G clef 8va on 2nd line symbol->setSym(SymId::gClef8va); yoff = 3.0 * curLineDist; break; case ClefType::G2: // G clef 15ma on 2nd line symbol->setSym(SymId::gClef15ma); yoff = 3.0 * curLineDist; break; case ClefType::G3: // G clef 8vb on 2nd line symbol->setSym(SymId::gClef8vb); yoff = 3.0 * curLineDist; break; case ClefType::F: // F clef on penultimate line symbol->setSym(SymId::fClef); yoff = 1.0 * curLineDist; break; case ClefType::F8: // F clef 8va bassa on penultimate line symbol->setSym(SymId::fClef8vb); yoff = 1.0 * curLineDist; break; case ClefType::F15: // F clef 15ma bassa on penultimate line symbol->setSym(SymId::fClef15mb); yoff = 1.0 * curLineDist; break; case ClefType::F_B: // baritone clef symbol->setSym(SymId::fClef); yoff = 2.0 * curLineDist; break; case ClefType::F_C: // subbass clef symbol->setSym(SymId::fClef); yoff = 0.0; break; case ClefType::C1: // C clef in 1st line symbol->setSym(SymId::cClef); yoff = 4.0 * curLineDist; break; case ClefType::C2: // C clef on 2nd line symbol->setSym(SymId::cClef); yoff = 3.0 * curLineDist; break; case ClefType::C3: // C clef in 3rd line symbol->setSym(SymId::cClef); yoff = 2.0 * curLineDist; break; case ClefType::C4: // C clef on 4th line symbol->setSym(SymId::cClef); yoff = 1.0 * curLineDist; break; case ClefType::C5: // C clef on 5th line symbol->setSym(SymId::cClef); yoff = 0.0; break; case ClefType::TAB: // TAB clef symbol->setSym(SymId::sixStringTabClef); // on tablature, position clef at half the number of spaces * line distance yoff = curLineDist * (curLines - 1) * .5; break; case ClefType::TAB2: // TAB clef alternate style symbol->setSym(SymId::sixStringTabClefSerif); // on tablature, position clef at half the number of spaces * line distance yoff = curLineDist * (curLines - 1) * .5; break; case ClefType::PERC: // percussion clefs case ClefType::PERC2: // no longer supported: fall back to same glyph as PERC symbol->setSym(SymId::unpitchedPercussionClef1); yoff = curLineDist * (curLines - 1) * 0.5; break; case ClefType::G4: // G clef in 1st line symbol->setSym(SymId::gClef); yoff = 4.0 * curLineDist; break; case ClefType::F_8VA: // F clef 8va on penultimate line symbol->setSym(SymId::fClef8va); yoff = 1.0 * curLineDist; break; case ClefType::F_15MA: // F clef 15ma on penultimate line symbol->setSym(SymId::fClef15ma); yoff = 1.0 * curLineDist; break; case ClefType::INVALID: case ClefType::MAX: return; } symbol->setMag(smag); symbol->layout(); addElement(symbol, .0, yoff * _spatium); setbbox(QRectF()); for (auto i = elements.begin(); i != elements.end(); ++i) { Element* e = *i; e->setColor(curColor()); addbbox(e->bbox().translated(e->pos())); e->setSelected(selected()); } } //--------------------------------------------------------- // draw //--------------------------------------------------------- void Clef::draw(QPainter* painter) const { if (staff() && !staff()->staffType()->genClef()) return; QColor color(curColor()); foreach(Element* e, elements) { e->setColor(color); QPointF pt(e->pos()); painter->translate(pt); e->draw(painter); painter->translate(-pt); } }
void Clef::layout() { // determine current number of lines and line distance int lines; qreal lineDist; Segment* clefSeg = segment(); qDeleteAll(elements); elements.clear(); // check clef visibility and type compatibility if (clefSeg && staff()) { StaffType* staffType = staff()->staffType(); bool show = staffType->genClef(); // check staff type allows clef display int tick = clefSeg->tick(); // check clef is compatible with staff type group: if (ClefInfo::staffGroup(clefType()) != staffType->group()) { if (tick > 0 && !generated()) // if clef is not generated, hide it show = false; else // if generated, replace with initial clef type // TODO : instead of initial staff clef (which is assumed to be compatible) // use the last compatible clef previously found in staff _clefTypes = staff()->clefType(0); } // if clef not to show or not compatible with staff group if (!show) { setbbox(QRectF()); qDebug("Clef::layout(): invisible clef at tick %d(%d) staff %d", segment()->tick(), segment()->tick()/1920, staffIdx()); return; } lines = staffType->lines(); // init values from staff type lineDist = staffType->lineDistance().val(); } else { lines = 5; lineDist = 1.0; } qreal _spatium = spatium(); qreal yoff = 0.0; Symbol* symbol = new Symbol(score()); switch (clefType()) { case ClefType::G: // G clef on 2nd line symbol->setSym(SymId::gClef); yoff = 3.0 * lineDist; break; case ClefType::G1: // G clef 8va on 2nd line symbol->setSym(SymId::gClef8va); yoff = 3.0 * lineDist; break; case ClefType::G2: // G clef 15ma on 2nd line symbol->setSym(SymId::gClef15ma); yoff = 3.0 * lineDist; break; case ClefType::G3: // G clef 8vb on 2nd line symbol->setSym(SymId::gClef8vb); yoff = 3.0 * lineDist; break; case ClefType::G3_O: // double G clef 8vb on 2nd line symbol->setSym(SymId::gClef8vbOld); yoff = 3.0 * lineDist; break; case ClefType::F: // F clef on penultimate line symbol->setSym(SymId::fClef); yoff = 1.0 * lineDist; break; case ClefType::F8: // F clef 8va bassa on penultimate line symbol->setSym(SymId::fClef8vb); yoff = 1.0 * lineDist; break; case ClefType::F15: // F clef 15ma bassa on penultimate line symbol->setSym(SymId::fClef15mb); yoff = 1.0 * lineDist; break; case ClefType::F_B: // baritone clef symbol->setSym(SymId::fClef); yoff = 2.0 * lineDist; break; case ClefType::F_C: // subbass clef symbol->setSym(SymId::fClef); yoff = 0.0; break; case ClefType::C1: // C clef in 1st line symbol->setSym(SymId::cClef); yoff = 4.0 * lineDist; break; case ClefType::C2: // C clef on 2nd line symbol->setSym(SymId::cClef); yoff = 3.0 * lineDist; break; case ClefType::C3: // C clef in 3rd line symbol->setSym(SymId::cClef); yoff = 2.0 * lineDist; break; case ClefType::C4: // C clef on 4th line symbol->setSym(SymId::cClef); yoff = 1.0 * lineDist; break; case ClefType::C5: // C clef on 5th line symbol->setSym(SymId::cClef); yoff = 0.0; break; case ClefType::TAB: // TAB clef symbol->setSym(SymId::sixStringTabClef); // on tablature, position clef at half the number of spaces * line distance yoff = lineDist * (lines - 1) * .5; break; case ClefType::TAB2: // TAB clef alternate style symbol->setSym(SymId::sixStringTabClefSerif); // on tablature, position clef at half the number of spaces * line distance yoff = lineDist * (lines - 1) * .5; break; case ClefType::PERC: // percussion clefs symbol->setSym(SymId::unpitchedPercussionClef1); yoff = lineDist * (lines - 1) * 0.5; break; case ClefType::PERC2: symbol->setSym(SymId::unpitchedPercussionClef2); yoff = lineDist * (lines - 1) * 0.5; break; case ClefType::G4: // G clef in 1st line symbol->setSym(SymId::gClef); yoff = 4.0 * lineDist; break; case ClefType::F_8VA: // F clef 8va on penultimate line symbol->setSym(SymId::fClef8va); yoff = 1.0 * lineDist; break; case ClefType::F_15MA: // F clef 15ma on penultimate line symbol->setSym(SymId::fClef15ma); yoff = 1.0 * lineDist; break; case ClefType::G5: // G clef on 2nd line symbol->setSym(SymId::gClef8vbParens); yoff = 3.0 * lineDist; break; case ClefType::INVALID: case ClefType::MAX: qDebug("Clef::layout: invalid type"); return; } addElement(symbol, .0, yoff * _spatium); QRectF r; for (Element* e : elements) { r |= e->bbox().translated(e->pos()); e->setSelected(selected()); } // clefs are right aligned to Segment QPointF off(-r.right(), 0); for (Element* e : elements) e->move(off); r.translate(off); setbbox(r); setPos(QPointF()); }
ViAcoustidIdentifier::ViAcoustidIdentifier() : ViSongIdentifier() { QObject::connect(&mFingerprinter, SIGNAL(generated()), this, SLOT(sendRequest())); }
void Clef::layout() { setPos(QPoint()); // determine current number of lines and line distance int lines = 5; // assume resonable defaults qreal lineDist = 1.0; Staff* stf = staff(); StaffType* staffType = nullptr; Segment* clefSeg = static_cast<Segment*>(parent()); // check clef visibility and type compatibility if (clefSeg && stf && stf->staffType()) { bool bHide; // check staff type allows clef display staffType = stf->staffType(); bHide = !staffType->genClef(); // check clef is compatible with staff type group int tick = clefSeg->tick(); if (ClefInfo::staffGroup(clefType()) != staffType->group()) { if (tick > 0 && !generated()) // if clef is not generated, hide it bHide = true; else // if generated, replace with initial clef type // TODO : instead of initial staff clef (which is assumed to be compatible) // use the last compatible clef previously found in staff _clefTypes = stf->clefType(0); } // // courtesy clef // bool showClef = true; // only if there is a clef change if (!bHide && tick > 0 ) { Measure* meas = clefSeg->measure(); // courtesy clef: end of last measure measure of system bool courtesy = clefSeg->tick() == meas->endTick() && meas->system() && (meas == meas->system()->lastMeasure() || meas->system()->measures().indexOf(meas) == -1); showClef = // show this clef if: // it is not a courtesy clef !courtesy // or, if courtesy clef: show if score has courtesy clefs on || ( score()->styleB(StyleIdx::genCourtesyClef) // AND measure is not at the end of a repeat or of a section && !( (meas->repeatFlags() & Repeat::END) || meas->isFinalMeasureOfSection() ) // AND this clef has courtesy clef turned on && showCourtesy() ); bHide |= !showClef; } // if clef not to show or not compatible with staff group if (bHide) { qDeleteAll(elements); // set empty bbox and do nothing elements.clear(); setbbox(QRectF()); return; } lines = staffType->lines(); // init values from staff type #if 0 // with fewer than 5 lines, keep clef toward top of staff (ignore line spacing) if (!stf->isPitchedStaff() || lines >= 5) #endif lineDist = staffType->lineDistance().val(); } // if nothing changed since last layout, do nothing //DEBUG if (curClefType == clefType() && curLines == lines && curLineDist == lineDist) // return; // if something has changed, cache new values and re-layout curClefType = clefType(); curLines = lines; curLineDist = lineDist; layout1(); }
void Rest::draw(QPainter* painter) const { if ( (staff() && staff()->isTabStaff() // in tab staff, do not draw rests is rests are off OR if dur. symbols are on && ( !((StaffTypeTablature*)staff()->staffType())->showRests() || ((StaffTypeTablature*)staff()->staffType())->genDurations()) ) || generated()) return; qreal _spatium = spatium(); painter->setPen(curColor()); if (parent() && measure() && measure()->multiMeasure()) { Measure* m = measure(); int n = m->multiMeasure(); qreal pw = _spatium * .7; QPen pen(painter->pen()); pen.setWidthF(pw); painter->setPen(pen); qreal w = _mmWidth; qreal y = 0.0; qreal x1 = 0.0; qreal x2 = w; pw *= .5; painter->drawLine(QLineF(x1 + pw, y, x2 - pw, y)); // draw vertical lines: pen.setWidthF(_spatium * .2); painter->setPen(pen); painter->drawLine(QLineF(x1, y-_spatium, x1, y+_spatium)); painter->drawLine(QLineF(x2, y-_spatium, x2, y+_spatium)); #ifdef USE_GLYPHS QRawFont rfont = fontId2RawFont(0); rfont.setPixelSize(20.0 * spatium()/(PPI * SPATIUM20)); QGlyphRun glyphs; QVector<quint32> idx = rfont.glyphIndexesForString(QString("%1").arg(n)); glyphs.setGlyphIndexes(idx); QVector<QPointF> adv = rfont.advancesForGlyphIndexes(idx); adv.insert(0, QPointF()); glyphs.setPositions(adv); glyphs.setRawFont(rfont); QRectF r = glyphs.boundingRect(); y = -_spatium * .5; painter->drawGlyphRun(QPointF((x2 - x1) * .5 + x1 - r.width() * .5, y), glyphs); #else QFont font = fontId2font(0); font.setPixelSize(lrint(20.0 * spatium()/(PPI * SPATIUM20))); painter->setFont(font); QFontMetricsF fm(font); // y = -_spatium * .5 - (staff()->height()*.5) - fm.ascent(); y = -_spatium * .5 - fm.ascent(); painter->drawText(QRectF(center(x1, x2), y, .0, .0), Qt::AlignHCenter|Qt::TextDontClip, QString("%1").arg(n)); #endif } else { qreal mag = magS(); symbols[score()->symIdx()][_sym].draw(painter, mag); int dots = durationType().dots(); if (dots) { qreal y = dotline * _spatium * .5; for (int i = 1; i <= dots; ++i) { qreal x = symbols[score()->symIdx()][_sym].width(mag) + point(score()->styleS(ST_dotNoteDistance)) * i; symbols[score()->symIdx()][dotSym].draw(painter, mag, QPointF(x, y)); } } } }