Exemplo n.º 1
0
void RGBMatrix::calculateColorDelta()
{
    m_crDelta = 0;
    m_cgDelta = 0;
    m_cbDelta = 0;

    if (m_endColor.isValid())
    {
        if (doc() == NULL)
            return;

        FixtureGroup* grp = doc()->fixtureGroup(fixtureGroup());
        QMutexLocker algorithmLocker(&m_algorithmMutex);
        if (grp != NULL && m_algorithm != NULL)
        {
            if (m_algorithm->rgbMapStepCount(grp->size()) > 1)
            {
                m_crDelta = (m_endColor.red() - m_startColor.red()) / (m_algorithm->rgbMapStepCount(grp->size()) - 1);
                m_cgDelta = (m_endColor.green() - m_startColor.green()) / (m_algorithm->rgbMapStepCount(grp->size()) - 1);
                m_cbDelta = (m_endColor.blue() - m_startColor.blue()) / (m_algorithm->rgbMapStepCount(grp->size()) - 1);
            }
        }
    }
}
Exemplo n.º 2
0
bool RGBMatrix::saveXML(QDomDocument* doc, QDomElement* wksp_root)
{
    QDomElement root;
    QDomElement tag;
    QDomText text;
    QString str;

    Q_ASSERT(doc != NULL);
    Q_ASSERT(wksp_root != NULL);

    /* Function tag */
    root = doc->createElement(KXMLQLCFunction);
    wksp_root->appendChild(root);

    /* Common attributes */
    saveXMLCommon(&root);

    /* Speeds */
    saveXMLSpeed(doc, &root);

    /* Direction */
    saveXMLDirection(doc, &root);

    /* Run order */
    saveXMLRunOrder(doc, &root);

    /* Algorithm */
    if (m_algorithm != NULL)
        m_algorithm->saveXML(doc, &root);

    /* Dimmer Control */
    tag = doc->createElement(KXMLQLCRGBMatrixDimmerControl);
    root.appendChild(tag);
    text = doc->createTextNode(QString::number(dimmerControl()));
    tag.appendChild(text);

    /* Start Color */
    tag = doc->createElement(KXMLQLCRGBMatrixStartColor);
    root.appendChild(tag);
    text = doc->createTextNode(QString::number(startColor().rgb()));
    tag.appendChild(text);

    /* End Color */
    if (endColor().isValid())
    {
        tag = doc->createElement(KXMLQLCRGBMatrixEndColor);
        root.appendChild(tag);
        text = doc->createTextNode(QString::number(endColor().rgb()));
        tag.appendChild(text);
    }

    /* Fixture Group */
    tag = doc->createElement(KXMLQLCRGBMatrixFixtureGroup);
    root.appendChild(tag);
    text = doc->createTextNode(QString::number(fixtureGroup()));
    tag.appendChild(text);

    /* Properties */
    QHashIterator<QString, QString> it(m_properties);
    while(it.hasNext())
    {
        it.next();
        tag = doc->createElement(KXMLQLCRGBMatrixProperty);
        tag.setAttribute(KXMLQLCRGBMatrixPropertyName, it.key());
        tag.setAttribute(KXMLQLCRGBMatrixPropertyValue, it.value());
        root.appendChild(tag);
    }

    return true;
}