void QLCFixtureDef_Test::copy() { QLCFixtureDef* fd = new QLCFixtureDef(); fd->setManufacturer("Martin"); fd->setModel("MAC600"); fd->setType("Moving Head"); QLCChannel* ch = new QLCChannel(); ch->setName("TestChannel"); fd->addChannel(ch); QLCFixtureMode* mode = new QLCFixtureMode(fd); mode->setName("TestMode"); fd->addMode(mode); mode->insertChannel(ch, 0); QLCFixtureDef* copy = new QLCFixtureDef(fd); QVERIFY(copy->manufacturer() == "Martin"); QVERIFY(copy->model() == "MAC600"); QVERIFY(copy->type() == "Moving Head"); /* Verify that modes and channels get copied and that the channels in the copied mode are from the copied fixtureDef and not the one that the copy is taken FROM. */ QVERIFY(copy->channels().at(0)->name() == "TestChannel"); QVERIFY(copy->modes().at(0)->name() == "TestMode"); QVERIFY(copy->modes().at(0)->channels().size() == 1); QVERIFY(copy->modes().size() == 1); QVERIFY(copy->modes().at(0)->channel(0) != ch); QVERIFY(copy->modes().at(0)->channel(0) == copy->channels().at(0)); QVERIFY(copy->channels().at(0)->name() == "TestChannel"); QVERIFY(copy->modes().at(0)->channel(0)->name() == "TestChannel"); delete fd; delete copy; }
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; }
QLCFixtureDef *Fixture::genericRGBPanelDef(int columns, Components components) { QLCFixtureDef *def = new QLCFixtureDef(); def->setManufacturer(KXMLFixtureGeneric); def->setModel(KXMLFixtureRGBPanel); def->setType("LED Bar"); def->setAuthor("QLC+"); for (int i = 0; i < columns; i++) { QLCChannel* red = new QLCChannel(); red->setName(QString("Red %1").arg(i + 1)); red->setGroup(QLCChannel::Intensity); red->setColour(QLCChannel::Red); QLCChannel* green = new QLCChannel(); green->setName(QString("Green %1").arg(i + 1)); green->setGroup(QLCChannel::Intensity); green->setColour(QLCChannel::Green); QLCChannel* blue = new QLCChannel(); blue->setName(QString("Blue %1").arg(i + 1)); blue->setGroup(QLCChannel::Intensity); blue->setColour(QLCChannel::Blue); if (components == BGR) { def->addChannel(blue); def->addChannel(green); def->addChannel(red); } else if (components == RGBW) { QLCChannel* white = new QLCChannel(); white->setName(QString("White %1").arg(i + 1)); white->setGroup(QLCChannel::Intensity); white->setColour(QLCChannel::White); def->addChannel(red); def->addChannel(green); def->addChannel(blue); def->addChannel(white); } else if (components == RGBWW) { QLCChannel* white = new QLCChannel(); white->setName(QString("Warm White %1").arg(i + 1)); white->setGroup(QLCChannel::Intensity); white->setColour(QLCChannel::White); QLCChannel* white2 = new QLCChannel(); white2->setName(QString("Cold White %1").arg(i + 1)); white2->setGroup(QLCChannel::Intensity); white2->setColour(QLCChannel::White); def->addChannel(red); def->addChannel(green); def->addChannel(blue); def->addChannel(white); def->addChannel(white2); } else { def->addChannel(red); def->addChannel(green); def->addChannel(blue); } } return def; }