Beispiel #1
0
QLCFixtureMode *Fixture::genericDimmerMode(QLCFixtureDef *def, int channels)
{
    Q_ASSERT(def != NULL);
    QLCFixtureMode *mode = new QLCFixtureMode(def);

    mode->setName(QString("%1 Channel").arg(channels));
    QList<QLCChannel *>chList = def->channels();
    for (int i = 0; i < chList.count(); i++)
    {
        QLCChannel *ch = chList.at(i);
        mode->insertChannel(ch, i);
        QLCFixtureHead head;
        head.addChannel(i);
        mode->insertHead(-1, head);
    }

    QLCPhysical physical;
    physical.setWidth(300 * channels);
    physical.setHeight(300);
    physical.setDepth(300);

    mode->setPhysical(physical);
    def->addMode(mode);

    return mode;
}
Beispiel #2
0
QLCFixtureMode *Fixture::genericRGBPanelMode(QLCFixtureDef *def, Components components, quint32 width, quint32 height)
{
    Q_ASSERT(def != NULL);
    QLCFixtureMode *mode = new QLCFixtureMode(def);
    int compNum = 3;
    if (components == BGR)
    {
        mode->setName("BGR");
    }
    else if (components == RGBW)
    {
        mode->setName("RGBW");
        compNum = 4;
    }
    else if (components == RGBWW)
    {
        mode->setName("RGBWW");
        compNum = 5;
    }
    else
        mode->setName("RGB");

    QList<QLCChannel *>channels = def->channels();
    for (int i = 0; i < channels.count(); i++)
    {
        QLCChannel *ch = channels.at(i);
        mode->insertChannel(ch, i);
        if (i%compNum == 0)
        {
            QLCFixtureHead head;
            head.addChannel(i);
            head.addChannel(i+1);
            head.addChannel(i+2);
            if (components == RGBW)
                head.addChannel(i+3);
            else if (components == RGBWW)
            {
                head.addChannel(i+3);
                head.addChannel(i+4);
            }
            mode->insertHead(-1, head);
        }
    }
    QLCPhysical physical;
    physical.setWidth(width);
    physical.setHeight(height);
    physical.setDepth(height);

    mode->setPhysical(physical);

    return mode;
}
Beispiel #3
0
void Fixture::setFixtureDefinition(const QLCFixtureDef* fixtureDef,
                                   const QLCFixtureMode* fixtureMode)
{
    if (fixtureDef != NULL && fixtureMode != NULL)
    {
        m_fixtureDef = fixtureDef;
        m_fixtureMode = fixtureMode;

        // If there are no head entries in the mode, create one that contains
        // all channels. This const_cast is a bit heretic, but it's easier this
        // way, than to change everything def & mode related non-const, which would
        // be worse than one constness violation here.
        QLCFixtureMode* mode = const_cast<QLCFixtureMode*> (fixtureMode);
        if (mode->heads().size() == 0)
        {
            QLCFixtureHead head;
            for (int i = 0; i < mode->channels().size(); i++)
                head.addChannel(i);
            mode->insertHead(-1, head);
        }

        // Cache all head channels
        mode->cacheHeads();

        if (m_genericChannel != NULL)
            delete m_genericChannel;
        m_genericChannel = NULL;
    }
    else
    {
        m_fixtureDef = NULL;
        m_fixtureMode = NULL;
        createGenericChannel();
    }

    emit changed(m_id);
}
Beispiel #4
0
void QLCFixtureMode_Test::copy()
{
    QLCFixtureMode* mode = new QLCFixtureMode(m_fixtureDef);
    mode->setName("Test Mode");

    mode->insertChannel(m_ch1, 0);
    mode->insertChannel(m_ch2, 1);
    mode->insertChannel(m_ch3, 2);
    mode->insertChannel(m_ch4, 3);

    QLCFixtureHead head;
    head.addChannel(0);
    head.addChannel(1);
    head.addChannel(2);
    mode->insertHead(-1, head);

    /* Create a copy of the mode to the same fixtureDef as the original */
    QLCFixtureMode* copy = new QLCFixtureMode(m_fixtureDef, mode);
    QVERIFY(copy != NULL);

    QVERIFY(copy->name() == "Test Mode");
    QVERIFY(copy->channels().size() == 4);
    QVERIFY(copy->channel(0) == m_ch1);
    QVERIFY(copy->channel(1) == m_ch2);
    QVERIFY(copy->channel(2) == m_ch3);
    QVERIFY(copy->channel(3) == m_ch4);
    QCOMPARE(copy->heads().size(), 1);
    QVERIFY(copy->heads().at(0).channels().contains(0) == true);
    QVERIFY(copy->heads().at(0).channels().contains(1) == true);
    QVERIFY(copy->heads().at(0).channels().contains(2) == true);
    delete copy;
    copy = NULL;

    /* Create another fixture def with some channels matching, some not */
    QLCFixtureDef* anotherDef = new QLCFixtureDef();
    QLCChannel* ch1 = new QLCChannel();
    ch1->setName("Channel 1"); // Should match
    anotherDef->addChannel(ch1);

    QLCChannel* ch2 = new QLCChannel();
    ch2->setName("Channel 2, not the same name"); // Shouldn't match
    anotherDef->addChannel(ch2);

    QLCChannel* ch3 = new QLCChannel();
    ch3->setName("Channel 3, still not the same name"); // Shouldn't match
    anotherDef->addChannel(ch3);

    QLCChannel* ch4 = new QLCChannel();
    ch4->setName("Channel 4"); // Should match
    anotherDef->addChannel(ch4);

    QLCChannel* ch5 = new QLCChannel();
    ch5->setName("Channel 5"); // Shouldn't match since original has 4 chans
    anotherDef->addChannel(ch5);

    /* Create a copy of the mode to the other fixtureDef */
    copy = new QLCFixtureMode(anotherDef, mode);

    QVERIFY(copy->name() == "Test Mode");
    QVERIFY(copy->channels().size() == 2);

    QVERIFY(copy->channel(0)->name() == "Channel 1");
    QVERIFY(copy->channel(0) == ch1);

    QVERIFY(copy->channel(1)->name() == "Channel 4");
    QVERIFY(copy->channel(1) == ch4);

    delete copy;
    delete anotherDef;
}
Beispiel #5
0
void QLCFixtureMode_Test::heads()
{
    QLCFixtureMode* mode = new QLCFixtureMode(m_fixtureDef);

    QLCFixtureHead head;
    head.addChannel(0);
    head.addChannel(10);
    head.addChannel(20);
    mode->insertHead(-1, head);
    QCOMPARE(mode->heads().size(), 1);
    QVERIFY(mode->m_heads[0].m_channels.contains(0) == true);
    QVERIFY(mode->m_heads[0].m_channels.contains(10) == true);
    QVERIFY(mode->m_heads[0].m_channels.contains(20) == true);

    QLCFixtureHead head2;
    head2.addChannel(1);
    head2.addChannel(2);
    mode->insertHead(10, head2);
    QCOMPARE(mode->heads().size(), 2);
    QVERIFY(mode->m_heads[0].m_channels.contains(0) == true);
    QVERIFY(mode->m_heads[0].m_channels.contains(10) == true);
    QVERIFY(mode->m_heads[0].m_channels.contains(20) == true);
    QVERIFY(mode->m_heads[1].m_channels.contains(0) == false);
    QVERIFY(mode->m_heads[1].m_channels.contains(1) == true);
    QVERIFY(mode->m_heads[1].m_channels.contains(2) == true);

    QLCFixtureHead head3;
    head3.addChannel(3);
    head3.addChannel(4);
    mode->insertHead(1, head3);
    QCOMPARE(mode->heads().size(), 3);
    QVERIFY(mode->m_heads[0].m_channels.contains(0) == true);
    QVERIFY(mode->m_heads[0].m_channels.contains(10) == true);
    QVERIFY(mode->m_heads[0].m_channels.contains(20) == true);
    QVERIFY(mode->m_heads[1].m_channels.contains(3) == true);
    QVERIFY(mode->m_heads[1].m_channels.contains(4) == true);
    QVERIFY(mode->m_heads[2].m_channels.contains(1) == true);
    QVERIFY(mode->m_heads[2].m_channels.contains(2) == true);

    QLCFixtureHead head4;
    head4.addChannel(15);
    head4.addChannel(16);
    mode->replaceHead(4, head4);
    QCOMPARE(mode->heads().size(), 3);
    QVERIFY(mode->m_heads[0].m_channels.contains(0) == true);
    QVERIFY(mode->m_heads[0].m_channels.contains(10) == true);
    QVERIFY(mode->m_heads[0].m_channels.contains(20) == true);
    QVERIFY(mode->m_heads[1].m_channels.contains(3) == true);
    QVERIFY(mode->m_heads[1].m_channels.contains(4) == true);
    QVERIFY(mode->m_heads[2].m_channels.contains(1) == true);
    QVERIFY(mode->m_heads[2].m_channels.contains(2) == true);

    mode->replaceHead(2, head4);
    QCOMPARE(mode->heads().size(), 3);
    QVERIFY(mode->m_heads[0].m_channels.contains(0) == true);
    QVERIFY(mode->m_heads[0].m_channels.contains(10) == true);
    QVERIFY(mode->m_heads[0].m_channels.contains(20) == true);
    QVERIFY(mode->m_heads[1].m_channels.contains(3) == true);
    QVERIFY(mode->m_heads[1].m_channels.contains(4) == true);
    QVERIFY(mode->m_heads[2].m_channels.contains(15) == true);
    QVERIFY(mode->m_heads[2].m_channels.contains(16) == true);

    mode->removeHead(15);
    QCOMPARE(mode->heads().size(), 3);

    mode->removeHead(1);
    QCOMPARE(mode->heads().size(), 2);
    QVERIFY(mode->m_heads[0].m_channels.contains(0) == true);
    QVERIFY(mode->m_heads[0].m_channels.contains(10) == true);
    QVERIFY(mode->m_heads[0].m_channels.contains(20) == true);
    QVERIFY(mode->m_heads[1].m_channels.contains(15) == true);
    QVERIFY(mode->m_heads[1].m_channels.contains(16) == true);

    mode->removeHead(0);
    QCOMPARE(mode->heads().size(), 1);
    QVERIFY(mode->m_heads[0].m_channels.contains(15) == true);
    QVERIFY(mode->m_heads[0].m_channels.contains(16) == true);

    mode->removeHead(0);
    QCOMPARE(mode->heads().size(), 0);

    delete mode;
}