Function::Function(QObject *parent) : QObject(parent) , m_id(Function::invalidId()) , m_type(Undefined) , m_path(QString()) , m_visible(true) , m_runOrder(Loop) , m_direction(Forward) , m_tempoType(Time) , m_overrideTempoType(Original) , m_beatResyncNeeded(false) , m_fadeInSpeed(0) , m_fadeOutSpeed(0) , m_duration(0) , m_overrideFadeInSpeed(defaultSpeed()) , m_overrideFadeOutSpeed(defaultSpeed()) , m_overrideDuration(defaultSpeed()) , m_flashing(false) , m_elapsed(0) , m_elapsedBeats(0) , m_stop(true) , m_running(false) , m_paused(false) , m_lastOverrideAttributeId(OVERRIDE_ATTRIBUTE_START_ID) , m_preserveAttributes(false) , m_blendMode(Universe::NormalBlend) { }
Function::Function(Doc* doc, Type t) : QObject(doc) , m_id(Function::invalidId()) , m_type(t) , m_path(QString()) , m_visible(true) , m_runOrder(Loop) , m_direction(Forward) , m_tempoType(Time) , m_overrideTempoType(Original) , m_beatResyncNeeded(false) , m_fadeInSpeed(0) , m_fadeOutSpeed(0) , m_duration(0) , m_overrideFadeInSpeed(defaultSpeed()) , m_overrideFadeOutSpeed(defaultSpeed()) , m_overrideDuration(defaultSpeed()) , m_flashing(false) , m_elapsed(0) , m_elapsedBeats(0) , m_stop(true) , m_running(false) , m_paused(false) , m_lastOverrideAttributeId(OVERRIDE_ATTRIBUTE_START_ID) , m_preserveAttributes(false) , m_blendMode(Universe::NormalBlend) { Q_ASSERT(doc != NULL); registerAttribute(tr("Intensity"), Multiply | Single); }
void Function::postRun(MasterTimer* timer, UniverseArray* universes) { Q_UNUSED(timer); Q_UNUSED(universes); m_stopMutex.lock(); resetElapsed(); resetIntensity(); m_stop = true; m_overrideFadeInSpeed = defaultSpeed(); m_overrideFadeOutSpeed = defaultSpeed(); m_overrideDuration = defaultSpeed(); m_functionStopped.wakeAll(); m_stopMutex.unlock(); m_running = false; emit stopped(m_id); }
Function::Function(Doc* doc, Type t) : QObject(doc) , m_id(Function::invalidId()) , m_type(t) , m_runOrder(Loop) , m_direction(Forward) , m_fadeInSpeed(0) , m_fadeOutSpeed(0) , m_duration(0) , m_overrideFadeInSpeed(defaultSpeed()) , m_overrideFadeOutSpeed(defaultSpeed()) , m_overrideDuration(defaultSpeed()) , m_flashing(false) , m_elapsed(0) , m_stop(true) , m_running(false) , m_startedAsChild(false) , m_intensity(1.0) { Q_ASSERT(doc != NULL); }
Function::Function(QObject *parent) : QObject(parent) , m_id(Function::invalidId()) , m_type(Undefined) , m_path(QString()) , m_runOrder(Loop) , m_direction(Forward) , m_fadeInSpeed(0) , m_fadeOutSpeed(0) , m_duration(0) , m_overrideFadeInSpeed(defaultSpeed()) , m_overrideFadeOutSpeed(defaultSpeed()) , m_overrideDuration(defaultSpeed()) , m_uiState() , m_flashing(false) , m_elapsed(0) , m_stop(true) , m_running(false) , m_startedAsChild(false) { }
void RGBMatrix::postRun(MasterTimer* timer, QList<Universe *> universes) { if (m_fader != NULL) { QHashIterator <FadeChannel,FadeChannel> it(m_fader->channels()); while (it.hasNext() == true) { it.next(); FadeChannel fc = it.value(); // fade out only intensity channels if (fc.group(doc()) != QLCChannel::Intensity) continue; bool canFade = true; Fixture *fixture = doc()->fixture(fc.fixture()); if (fixture != NULL) canFade = fixture->channelCanFade(fc.channel()); fc.setStart(fc.current(getAttributeValue(Intensity))); fc.setCurrent(fc.current(getAttributeValue(Intensity))); fc.setElapsed(0); fc.setReady(false); if (canFade == false) { fc.setFadeTime(0); fc.setTarget(fc.current(getAttributeValue(Intensity))); } else { if (overrideFadeOutSpeed() == defaultSpeed()) fc.setFadeTime(fadeOutSpeed()); else fc.setFadeTime(overrideFadeOutSpeed()); fc.setTarget(0); } timer->faderAdd(fc); } delete m_fader; m_fader = NULL; } { QMutexLocker algorithmLocker(&m_algorithmMutex); if (m_algorithm != NULL) m_algorithm->postRun(); } Function::postRun(timer, universes); }
Function::Function(Doc* doc, Type t) : QObject(doc) , m_id(Function::invalidId()) , m_type(t) , m_path(QString()) , m_runOrder(Loop) , m_direction(Forward) , m_fadeInSpeed(0) , m_fadeOutSpeed(0) , m_duration(0) , m_overrideFadeInSpeed(defaultSpeed()) , m_overrideFadeOutSpeed(defaultSpeed()) , m_overrideDuration(defaultSpeed()) , m_uiState() , m_flashing(false) , m_elapsed(0) , m_stop(true) , m_running(false) , m_startedAsChild(false) { Q_ASSERT(doc != NULL); registerAttribute(tr("Intensity")); }
void RGBMatrix::updateMapChannels(const RGBMap& map, const FixtureGroup* grp) { quint32 mdAssigned = QLCChannel::invalid(); quint32 mdFxi = Fixture::invalidId(); uint fadeTime = 0; if (overrideFadeInSpeed() == defaultSpeed()) fadeTime = fadeInSpeed(); else fadeTime = overrideFadeInSpeed(); // Create/modify fade channels for ALL pixels in the color map. for (int y = 0; y < map.size(); y++) { for (int x = 0; x < map[y].size(); x++) { QLCPoint pt(x, y); GroupHead grpHead(grp->head(pt)); Fixture* fxi = doc()->fixture(grpHead.fxi); if (fxi == NULL) continue; if (grpHead.fxi != mdFxi) { mdAssigned = QLCChannel::invalid(); mdFxi = grpHead.fxi; } QLCFixtureHead head = fxi->head(grpHead.head); QVector <quint32> rgb = head.rgbChannels(); QVector <quint32> cmy = head.cmyChannels(); if (rgb.size() == 3) { // RGB color mixing FadeChannel fc; fc.setFixture(doc(), grpHead.fxi); fc.setChannel(rgb.at(0)); fc.setTarget(qRed(map[y][x])); insertStartValues(fc, fadeTime); m_fader->add(fc); fc.setChannel(rgb.at(1)); fc.setTarget(qGreen(map[y][x])); insertStartValues(fc, fadeTime); m_fader->add(fc); fc.setChannel(rgb.at(2)); fc.setTarget(qBlue(map[y][x])); insertStartValues(fc, fadeTime); m_fader->add(fc); } else if (cmy.size() == 3) { // CMY color mixing QColor col(map[y][x]); FadeChannel fc; fc.setFixture(doc(), grpHead.fxi); fc.setChannel(cmy.at(0)); fc.setTarget(col.cyan()); insertStartValues(fc, fadeTime); m_fader->add(fc); fc.setChannel(cmy.at(1)); fc.setTarget(col.magenta()); insertStartValues(fc, fadeTime); m_fader->add(fc); fc.setChannel(cmy.at(2)); fc.setTarget(col.yellow()); insertStartValues(fc, fadeTime); m_fader->add(fc); } if (m_dimmerControl && head.masterIntensityChannel() != QLCChannel::invalid()) { //qDebug() << "RGBMatrix: found dimmer at" << head.masterIntensityChannel(); // Simple intensity (dimmer) channel QColor col(map[y][x]); FadeChannel fc; fc.setFixture(doc(), grpHead.fxi); fc.setChannel(head.masterIntensityChannel()); if (col.value() == 0 && mdAssigned != head.masterIntensityChannel()) fc.setTarget(0); else { fc.setTarget(255); if (mdAssigned == QLCChannel::invalid()) mdAssigned = head.masterIntensityChannel(); } insertStartValues(fc, fadeTime); m_fader->add(fc); } } } }
void RGBMatrix::updateMapChannels(const RGBMap& map, const FixtureGroup* grp) { uint fadeTime = (overrideFadeInSpeed() == defaultSpeed()) ? fadeInSpeed() : overrideFadeInSpeed(); // Create/modify fade channels for ALL pixels in the color map. for (int y = 0; y < map.size(); y++) { for (int x = 0; x < map[y].size(); x++) { QLCPoint pt(x, y); GroupHead grpHead(grp->head(pt)); Fixture* fxi = doc()->fixture(grpHead.fxi); if (fxi == NULL) continue; QLCFixtureHead head = fxi->head(grpHead.head); QVector <quint32> rgb = head.rgbChannels(); QVector <quint32> cmy = head.cmyChannels(); quint32 masterDim = fxi->masterIntensityChannel(); quint32 headDim = head.channelNumber(QLCChannel::Intensity, QLCChannel::MSB); // Collect all dimmers that affect current head: // They are the master dimmer (affects whole fixture) // and per-head dimmer. // // If there are no RGB or CMY channels, the least important* dimmer channel // is used to create grayscale image. // // The rest of the dimmer channels are set to full if dimmer control is // enabled and target color is > 0 (see // http://www.qlcplus.org/forum/viewtopic.php?f=29&t=11090) // // Note: If there is only one head, and only one dimmer channel, // make it a master dimmer in fixture definition. // // *least important - per head dimmer if present, // otherwise per fixture dimmer if present QVector <quint32> dim; if (masterDim != QLCChannel::invalid()) dim << masterDim; if (headDim != QLCChannel::invalid()) dim << headDim; uint col = map[y][x]; if (rgb.size() == 3) { // RGB color mixing { FadeChannel fc(doc(), grpHead.fxi, rgb.at(0)); fc.setTarget(qRed(col)); insertStartValues(fc, fadeTime); m_fader->add(fc); } { FadeChannel fc(doc(), grpHead.fxi, rgb.at(1)); fc.setTarget(qGreen(col)); insertStartValues(fc, fadeTime); m_fader->add(fc); } { FadeChannel fc(doc(), grpHead.fxi, rgb.at(2)); fc.setTarget(qBlue(col)); insertStartValues(fc, fadeTime); m_fader->add(fc); } } else if (cmy.size() == 3) { // CMY color mixing QColor cmyCol(col); { FadeChannel fc(doc(), grpHead.fxi, cmy.at(0)); fc.setTarget(cmyCol.cyan()); insertStartValues(fc, fadeTime); m_fader->add(fc); } { FadeChannel fc(doc(), grpHead.fxi, cmy.at(1)); fc.setTarget(cmyCol.magenta()); insertStartValues(fc, fadeTime); m_fader->add(fc); } { FadeChannel fc(doc(), grpHead.fxi, cmy.at(2)); fc.setTarget(cmyCol.yellow()); insertStartValues(fc, fadeTime); m_fader->add(fc); } } else if (!dim.empty()) { // Set dimmer to value of the color (e.g. for PARs) FadeChannel fc(doc(), grpHead.fxi, dim.last()); // the weights are taken from // https://en.wikipedia.org/wiki/YUV#SDTV_with_BT.601 fc.setTarget(0.299 * qRed(col) + 0.587 * qGreen(col) + 0.114 * qBlue(col)); insertStartValues(fc, fadeTime); m_fader->add(fc); dim.pop_back(); } if (m_dimmerControl) { // Set the rest of the dimmer channels to full on foreach(quint32 ch, dim) { FadeChannel fc(doc(), grpHead.fxi, ch); fc.setTarget(col == 0 ? 0 : 255); insertStartValues(fc, fadeTime); m_fader->add(fc); } } } }