quint32 RGBMatrix::totalDuration() { QMutexLocker algorithmLocker(&m_algorithmMutex); if (m_algorithm == NULL) return 0; FixtureGroup* grp = doc()->fixtureGroup(fixtureGroup()); if (grp == NULL) return 0; qDebug () << "Algorithm steps:" << m_algorithm->rgbMapStepCount(grp->size()); return m_algorithm->rgbMapStepCount(grp->size()) * duration(); }
quint32 RGBMatrix::totalDuration() { if (m_fixtureGroupID == FixtureGroup::invalidId() || m_algorithm == NULL) return 0; FixtureGroup* grp = doc()->fixtureGroup(fixtureGroup()); if (grp != NULL) { qDebug () << "Algorithm steps:" << m_algorithm->rgbMapStepCount(grp->size()); return m_algorithm->rgbMapStepCount(grp->size()) * duration(); } return 0; }
void RGBMatrix::calculateColorDelta() { m_crDelta = 0; m_cgDelta = 0; m_cbDelta = 0; m_stepCount = 0; if (m_endColor.isValid()) { if (doc() == NULL) return; FixtureGroup* grp = doc()->fixtureGroup(fixtureGroup()); QMutexLocker algorithmLocker(&m_algorithmMutex); if (grp != NULL && m_algorithm != NULL) { m_stepCount = m_algorithm->rgbMapStepCount(grp->size()) - 1; if (m_stepCount > 0) { m_crDelta = m_endColor.red() - m_startColor.red(); m_cgDelta = m_endColor.green() - m_startColor.green(); m_cbDelta = m_endColor.blue() - m_startColor.blue(); } } } }
QList <RGBMap> RGBMatrix::previewMaps() { QList <RGBMap> steps; if (m_algorithm == NULL) return steps; FixtureGroup* grp = doc()->fixtureGroup(fixtureGroup()); if (grp != NULL) { int stepCount = m_algorithm->rgbMapStepCount(grp->size()); for (int i = 0; i < stepCount; i++) steps << m_algorithm->rgbMap(grp->size(), m_stepColor.rgb(), i); } return steps; }
void RGBMatrix::tap() { if (stopped() == false) { FixtureGroup* grp = doc()->fixtureGroup(fixtureGroup()); // Filter out taps that are too close to each other if (grp != NULL && uint(m_roundTime->elapsed()) >= (duration() / 4)) roundCheck(grp->size()); } }
void RGBMatrix::write(MasterTimer* timer, QList<Universe *> universes) { Q_UNUSED(timer); Q_UNUSED(universes); FixtureGroup* grp = doc()->fixtureGroup(fixtureGroup()); if (grp == NULL) { // No fixture group to control stop(); return; } // No time to do anything. if (duration() == 0) return; // Invalid/nonexistent script { QMutexLocker algorithmLocker(&m_algorithmMutex); if (m_algorithm == NULL || m_algorithm->apiVersion() == 0) return; // Get new map every time when elapsed is reset to zero if (elapsed() == 0) { qDebug() << "RGBMatrix stepColor:" << QString::number(m_stepColor.rgb(), 16); RGBMap map = m_algorithm->rgbMap(grp->size(), m_stepColor.rgb(), m_step); updateMapChannels(map, grp); } } // Run the generic fader that takes care of fading in/out individual channels m_fader->write(universes); // Increment elapsed time incrementElapsed(); // Check if we need to change direction, stop completely or go to next step if (elapsed() >= duration()) roundCheck(grp->size()); }
RGBMap RGBMatrix::previewMap(int step) { RGBMap map; QMutexLocker algorithmLocker(&m_algorithmMutex); if (m_algorithm == NULL) return map; FixtureGroup* grp = doc()->fixtureGroup(fixtureGroup()); if (grp != NULL) { map = m_algorithm->rgbMap(grp->size(), m_stepColor.rgb(), step); } return map; }
int RGBMatrix::stepsCount() { QMutexLocker algorithmLocker(&m_algorithmMutex); if (m_algorithm == NULL) return 0; FixtureGroup* grp = doc()->fixtureGroup(fixtureGroup()); if (grp != NULL) return m_algorithm->rgbMapStepCount(grp->size()); return 0; }
void RGBMatrix::setTotalDuration(quint32 msec) { if (m_fixtureGroupID == FixtureGroup::invalidId() || m_algorithm == NULL) return; FixtureGroup* grp = doc()->fixtureGroup(fixtureGroup()); if (grp != NULL) { int steps = m_algorithm->rgbMapStepCount(grp->size()); setDuration(msec / steps); } }
void RGBMatrix::preRun(MasterTimer* timer) { Q_UNUSED(timer); FixtureGroup* grp = doc()->fixtureGroup(fixtureGroup()); { QMutexLocker algorithmLocker(&m_algorithmMutex); if (grp != NULL && m_algorithm != NULL) { Q_ASSERT(m_fader == NULL); m_fader = new GenericFader(doc()); m_fader->adjustIntensity(getAttributeValue(Intensity)); // Copy direction from parent class direction m_direction = direction(); if (m_direction == Forward) { m_step = 0; m_stepColor = m_startColor.rgb(); } else { m_step = m_algorithm->rgbMapStepCount(grp->size()) - 1; if (m_endColor.isValid()) { m_stepColor = m_endColor.rgb(); } else { m_stepColor = m_startColor.rgb(); } } calculateColorDelta(); if (m_algorithm->type() == RGBAlgorithm::Script) { RGBScript *script = static_cast<RGBScript*> (m_algorithm); QHashIterator<QString, QString> it(m_properties); while(it.hasNext()) { it.next(); script->setProperty(it.key(), it.value()); } } } } m_roundTime->start(); Function::preRun(timer); }
void RGBMatrix::setTotalDuration(quint32 msec) { QMutexLocker algorithmLocker(&m_algorithmMutex); if (m_algorithm == NULL) return; FixtureGroup* grp = doc()->fixtureGroup(fixtureGroup()); if (grp == NULL) return; int steps = m_algorithm->rgbMapStepCount(grp->size()); setDuration(msec / steps); }
void RGBMatrix::preRun(MasterTimer* timer) { Q_UNUSED(timer); FixtureGroup* grp = doc()->fixtureGroup(fixtureGroup()); { QMutexLocker algorithmLocker(&m_algorithmMutex); if (grp != NULL && m_algorithm != NULL) { m_direction = direction(); Q_ASSERT(m_fader == NULL); m_fader = new GenericFader(doc()); m_fader->adjustIntensity(getAttributeValue(Intensity)); if (m_direction == Forward) { m_step = 0; m_stepColor = m_startColor.rgb(); } else { m_step = m_algorithm->rgbMapStepCount(grp->size()) - 1; if (m_endColor.isValid()) { m_stepColor = m_endColor.rgb(); } else { m_stepColor = m_startColor.rgb(); } } calculateColorDelta(); } } m_roundTime->start(); Function::preRun(timer); }
bool RGBMatrixEditor::createPreviewItems() { m_previewHash.clear(); m_scene->clear(); FixtureGroup* grp = m_doc->fixtureGroup(m_matrix->fixtureGroup()); if (grp == NULL) { QGraphicsTextItem* text = new QGraphicsTextItem(tr("No fixture group to control")); text->setDefaultTextColor(Qt::white); m_scene->addItem(text); return false; } m_previewDirection = m_matrix->direction(); if (m_previewDirection == Function::Forward) { m_matrix->setStepColor(m_matrix->startColor()); } else { if (m_matrix->endColor().isValid()) m_matrix->setStepColor(m_matrix->endColor()); else m_matrix->setStepColor(m_matrix->startColor()); } m_matrix->calculateColorDelta(); m_previewMaps = m_matrix->previewMaps(); if ((m_previewDirection == Function::Forward) || m_previewMaps.isEmpty()) { m_previewStep = 0; } else { m_previewStep = m_previewMaps.size() - 1; } RGBMap map; if (m_previewStep < m_previewMaps.size()) map = m_previewMaps[m_previewStep]; if (map.isEmpty()) return false; for (int x = 0; x < grp->size().width(); x++) { for (int y = 0; y < grp->size().height(); y++) { QLCPoint pt(x, y); if (grp->headHash().contains(pt) == true) { RGBItem* item = new RGBItem; item->setRect(x * RECT_SIZE + RECT_PADDING + ITEM_PADDING, y * RECT_SIZE + RECT_PADDING + ITEM_PADDING, ITEM_SIZE - (2 * ITEM_PADDING), ITEM_SIZE - (2 * ITEM_PADDING)); item->setColor(map[y][x]); item->draw(0); m_scene->addItem(item); m_previewHash[pt] = item; } } } return true; }