void FunctionWizard::accept() { PaletteGenerator pal(m_doc, fixtures()); if (m_coloursCheck->isChecked() == true) pal.createColours(); if (m_goboCheck->isChecked() == true) pal.createGobos(); if (m_shutterCheck->isChecked() == true) pal.createShutters(); if (m_intensityCheck->isChecked() == true) { QList <Scene*> sceneList; // Random chaser sceneList = IntensityGenerator::randomScenes(fixtures(), m_doc, QDateTime::currentDateTime().toTime_t()); if (sceneList.size() > 0) { int i = 0; Chaser* chaser = new Chaser(m_doc); chaser->setName(tr("Random Multi")); m_doc->addFunction(chaser); foreach (Scene* scene, sceneList) { scene->setName(tr("Random Step %1").arg(++i)); m_doc->addFunction(scene); chaser->addStep(scene->id()); }
void VCCueList_Test::functionRemoved() { QWidget w; VCCueList cl(&w, m_doc); Chaser* c = createChaser(m_doc); cl.setChaser(c->id()); // Chaser members are removed from list m_doc->deleteFunction(c->steps().first().fid); QCOMPARE(cl.m_tree->topLevelItemCount(), 4); // deferred changes arrive afetr 100ms QTest::qWait(150); QCOMPARE(cl.m_tree->topLevelItemCount(), 3); QCOMPARE(cl.m_tree->topLevelItem(0)->text(0), QString("1")); QCOMPARE(cl.m_tree->topLevelItem(1)->text(0), QString("2")); QCOMPARE(cl.m_tree->topLevelItem(2)->text(0), QString("3")); QCOMPARE(cl.m_tree->topLevelItem(0)->text(1), QString("Second")); QCOMPARE(cl.m_tree->topLevelItem(1)->text(1), QString("Third")); QCOMPARE(cl.m_tree->topLevelItem(2)->text(1), QString("Fourth")); // Chaser is removed completely m_doc->deleteFunction(c->id()); QCOMPARE(cl.m_tree->topLevelItemCount(), 0); QCOMPARE(cl.chaserID(), Function::invalidId()); }
static Chaser* createChaser(Doc* doc) { Fixture* fxi = new Fixture(doc); fxi->setChannels(1); doc->addFixture(fxi); Scene* s1 = new Scene(doc); s1->setName("First"); s1->setValue(fxi->id(), 0, 255); doc->addFunction(s1); Scene* s2 = new Scene(doc); s2->setName("Second"); s2->setValue(fxi->id(), 0, 127); doc->addFunction(s2); Scene* s3 = new Scene(doc); s3->setName("Third"); s3->setValue(fxi->id(), 0, 64); doc->addFunction(s3); Scene* s4 = new Scene(doc); s4->setName("Fourth"); s4->setValue(fxi->id(), 0, 32); doc->addFunction(s4); Chaser* c = new Chaser(doc); c->addStep(ChaserStep(s1->id())); c->addStep(ChaserStep(s2->id())); c->addStep(ChaserStep(s3->id())); c->addStep(ChaserStep(s4->id())); doc->addFunction(c); return c; }
bool IntensityGenerator::createRandomChaser() { if (m_random.size() == 0) return false; // Abort if doc can't fit the chaser and its members if (m_doc->functionsFree() < quint32(m_random.size() + 1)) return false; // Abort immediately if doc won't take all sequence steps QListIterator <Scene*> it(m_random); while (it.hasNext() == true) { if (m_doc->addFunction(it.next()) == false) return false; } // Create the random chaser Chaser* chaser = new Chaser(m_doc); chaser->setName("Intensity - Random"); if (m_doc->addFunction(chaser) == false) { // Abort if doc won't accept the chaser delete chaser; return false; } else { for (int i = 0; i < m_random.size(); i++) chaser->addStep(m_random[i]->id()); return true; } }
void VCCueList_Test::keyboardNextPrevious() { QWidget w; VCCueList cl(&w, m_doc); Chaser* c = createChaser(m_doc); c->setDuration(Function::infiniteSpeed()); cl.setChaser(c->id()); cl.setNextKeySequence(QKeySequence(keySequenceB)); cl.setPreviousKeySequence(QKeySequence(keySequenceA)); cl.setPlaybackKeySequence(QKeySequence(keySequenceD)); // Switch mode m_doc->setMode(Doc::Operate); MasterTimer* timer = m_doc->masterTimer(); // Next keyboard key cl.slotKeyPressed(QKeySequence(keySequenceB)); timer->timerTick(); //QCOMPARE(cl.m_runner->currentStepIndex(), 0); QCOMPARE(cl.m_tree->indexOfTopLevelItem(cl.m_tree->currentItem()), 0); // Next keyboard key cl.slotKeyPressed(QKeySequence(keySequenceB)); timer->timerTick(); //QCOMPARE(cl.m_runner->currentStepIndex(), 1); QCOMPARE(cl.m_tree->indexOfTopLevelItem(cl.m_tree->currentItem()), 1); // Unrecognized keyboard key cl.slotKeyPressed(QKeySequence(QKeySequence::SelectAll)); timer->timerTick(); //QCOMPARE(cl.m_runner->currentStepIndex(), 1); QCOMPARE(cl.m_tree->indexOfTopLevelItem(cl.m_tree->currentItem()), 1); // Previous keyboard key cl.slotKeyPressed(QKeySequence(keySequenceA)); timer->timerTick(); //QCOMPARE(cl.m_runner->currentStepIndex(), 0); QCOMPARE(cl.m_tree->indexOfTopLevelItem(cl.m_tree->currentItem()), 0); // Previous keyboard key cl.slotKeyPressed(QKeySequence(keySequenceA)); timer->timerTick(); //QCOMPARE(cl.m_runner->currentStepIndex(), 3); QCOMPARE(cl.m_tree->indexOfTopLevelItem(cl.m_tree->currentItem()), 3); // Next keyboard key cl.slotKeyPressed(QKeySequence(keySequenceB)); timer->timerTick(); //QCOMPARE(cl.m_runner->currentStepIndex(), 0); QCOMPARE(cl.m_tree->indexOfTopLevelItem(cl.m_tree->currentItem()), 0); // Playback cl.slotKeyPressed(QKeySequence(keySequenceD)); timer->timerTick(); //QVERIFY(cl.m_runner == NULL); QCOMPARE(cl.m_tree->indexOfTopLevelItem(cl.m_tree->currentItem()), 0); }
void Chaser_Test::createCopy() { Doc doc(this); Chaser* c1 = new Chaser(m_doc); c1->setName("First"); c1->setFadeInSpeed(42); c1->setFadeOutSpeed(69); c1->setDuration(1337); c1->setDirection(Chaser::Backward); c1->setRunOrder(Chaser::SingleShot); c1->addStep(ChaserStep(20)); c1->addStep(ChaserStep(30)); c1->addStep(ChaserStep(40)); doc.addFunction(c1); QVERIFY(c1->id() != Function::invalidId()); Function* f = c1->createCopy(&doc); QVERIFY(f != NULL); QVERIFY(f != c1); QVERIFY(f->id() != c1->id()); Chaser* copy = qobject_cast<Chaser*> (f); QVERIFY(copy != NULL); QVERIFY(copy->fadeInSpeed() == 42); QVERIFY(copy->fadeOutSpeed() == 69); QVERIFY(copy->duration() == 1337); QVERIFY(copy->direction() == Chaser::Backward); QVERIFY(copy->runOrder() == Chaser::SingleShot); QVERIFY(copy->steps().size() == 3); QVERIFY(copy->steps().at(0) == ChaserStep(20)); QVERIFY(copy->steps().at(1) == ChaserStep(30)); QVERIFY(copy->steps().at(2) == ChaserStep(40)); }
Function* FunctionManager::copyFunction(t_function_id fid) { Function* newFunction = NULL; QString msg; Function* function = _app->doc()->function(fid); Q_ASSERT(function != NULL); switch(function->type()) { case Function::Scene: { newFunction = _app->doc()->newFunction(Function::Scene); Scene* scene = static_cast<Scene*> (newFunction); scene->copyFrom(static_cast<Scene*> (function)); scene->setName("Copy of " + function->name()); } break; case Function::Chaser: { newFunction = _app->doc()->newFunction(Function::Chaser); Chaser* chaser = static_cast<Chaser*> (newFunction); chaser->copyFrom(static_cast<Chaser*> (function)); chaser->setName("Copy of " + function->name()); } break; case Function::Collection: { newFunction = _app->doc()->newFunction(Function::Collection); Collection* fc = static_cast<Collection*> (newFunction); fc->copyFrom(static_cast<Collection*> (function)); fc->setName("Copy of " + function->name()); } break; case Function::EFX: { newFunction = _app->doc()->newFunction(Function::EFX); EFX* efx = static_cast<EFX*> (newFunction); efx->copyFrom(static_cast<EFX*> (function)); efx->setName("Copy of " + function->name()); } break; default: newFunction = NULL; break; } return newFunction; }
void Chaser_Test::tap() { Scene* s1 = new Scene(m_doc); m_doc->addFunction(s1); Scene* s2 = new Scene(m_doc); m_doc->addFunction(s2); Scene* s3 = new Scene(m_doc); m_doc->addFunction(s3); Scene* s4 = new Scene(m_doc); m_doc->addFunction(s4); Chaser* c = new Chaser(m_doc); c->addStep(s1->id()); c->addStep(s2->id()); c->addStep(s3->id()); c->addStep(s4->id()); m_doc->addFunction(c); c->preRun(m_doc->masterTimer()); QVERIFY(c->m_runner != NULL); QCOMPARE(c->duration(), uint(0)); c->write(m_doc->masterTimer(), QList<Universe*>()); QCOMPARE(c->m_runner->m_next, false); c->tap(); QTest::qWait(MasterTimer::tick()); c->tap(); QCOMPARE(c->m_runner->m_next, true); }
void Chaser_Test::postRun() { Chaser* c = new Chaser(m_doc); m_doc->addFunction(c); UniverseArray ua(512); MasterTimerStub timer(m_doc, ua); c->preRun(&timer); QCOMPARE(c->isRunning(), true); // The chaser has no steps so ChaserRunner::postrun() shouldn't do much c->postRun(&timer, &ua); QCOMPARE(c->isRunning(), false); // Make sure Function::postRun() is called }
void Chaser_Test::postRun() { Chaser* c = new Chaser(m_doc); m_doc->addFunction(c); QList<Universe*> ua; ua.append(new Universe(0, new GrandMaster())); MasterTimerStub timer(m_doc, ua); c->preRun(&timer); QCOMPARE(c->isRunning(), true); // The chaser has no steps so ChaserRunner::postrun() shouldn't do much c->postRun(&timer, ua); QCOMPARE(c->isRunning(), false); // Make sure Function::postRun() is called }
void Chaser_Test::preRun() { Chaser* c = new Chaser(m_doc); m_doc->addFunction(c); UniverseArray ua(512); MasterTimerStub timer(m_doc, ua); c->m_stop = true; c->preRun(&timer); QVERIFY(c->m_runner != NULL); QCOMPARE(c->isRunning(), true); // Make sure Function::preRun() is called QCOMPARE(c->m_runner->m_elapsed, uint(0)); // Make sure ChaserRunner::reset() is called c->postRun(&timer, &ua); }
/***************************************************************************** * Sorting *****************************************************************************/ bool Chaser::operator<(const Chaser& chs) const { if (m_startTime < chs.getStartTime()) return true; else return false; }
void DeviceManagerView::copyFunction(Function* function, Device* device) { switch(function->type()) { case Function::Scene: { Scene* scene = static_cast<Scene*> (_app->doc()->newFunction(Function::Scene)); scene->copyFrom(static_cast<Scene*> (function), device->id()); } break; case Function::Chaser: { Chaser* chaser = static_cast<Chaser*> (_app->doc()->newFunction(Function::Chaser)); chaser->copyFrom(static_cast<Chaser*> (function)); assert(device == NULL); } break; case Function::Collection: { FunctionCollection* fc = static_cast<FunctionCollection*> (_app->doc()->newFunction(Function::Collection)); fc->copyFrom(static_cast<FunctionCollection*> (function)); assert(device == NULL); } break; case Function::Sequence: { Sequence* sequence = static_cast<Sequence*> (_app->doc()->newFunction(Function::Sequence)); sequence->copyFrom(static_cast<Sequence*> (function), device->id()); } break; default: break; } }
void Chaser_Test::preRun() { Chaser* c = new Chaser(m_doc); m_doc->addFunction(c); QList<Universe*> ua; ua.append(new Universe(0, new GrandMaster())); MasterTimerStub timer(m_doc, ua); c->m_stop = true; c->preRun(&timer); QVERIFY(c->m_runner != NULL); QCOMPARE(c->isRunning(), true); // Make sure Function::preRun() is called QCOMPARE(c->m_runner->m_elapsed, uint(0)); // Make sure ChaserRunner::reset() is called c->postRun(&timer, ua); }
void Doc_Test::addFunction() { Doc doc(this, m_fixtureDefCache); QVERIFY(doc.m_functionAllocation == 0); Scene* s = new Scene(&doc); QVERIFY(s->id() == Function::invalidId()); QVERIFY(doc.addFunction(s) == true); QVERIFY(s->id() == 0); QVERIFY(doc.m_functionAllocation == 1); QVERIFY(doc.isModified() == true); doc.resetModified(); Chaser* c = new Chaser(&doc); QVERIFY(c->id() == Function::invalidId()); QVERIFY(doc.addFunction(c) == true); QVERIFY(c->id() == 1); QVERIFY(doc.m_functionAllocation == 2); QVERIFY(doc.isModified() == true); doc.resetModified(); Collection* o = new Collection(&doc); QVERIFY(o->id() == Function::invalidId()); QVERIFY(doc.addFunction(o, 0) == false); QVERIFY(doc.isModified() == false); QVERIFY(o->id() == Function::invalidId()); QVERIFY(doc.m_functionAllocation == 2); QVERIFY(doc.addFunction(o, 2) == true); QVERIFY(o->id() == 2); QVERIFY(doc.m_functionAllocation == 3); QVERIFY(doc.isModified() == true); doc.resetModified(); EFX* e = new EFX(&doc); QVERIFY(e->id() == Function::invalidId()); QVERIFY(doc.addFunction(e, KFunctionArraySize) == false); QVERIFY(e->id() == Function::invalidId()); QVERIFY(doc.addFunction(e) == true); QVERIFY(e->id() == 3); QVERIFY(doc.m_functionAllocation == 4); QVERIFY(doc.isModified() == true); }
void Chaser_Test::tap() { Doc* doc = new Doc(this, m_cache); Fixture* fxi = new Fixture(doc); fxi->setAddress(0); fxi->setUniverse(0); fxi->setChannels(2); doc->addFixture(fxi); Scene* s1 = new Scene(doc); s1->setName("Scene1"); s1->setValue(fxi->id(), 0, UCHAR_MAX); s1->setValue(fxi->id(), 1, UCHAR_MAX); doc->addFunction(s1); Chaser* c = new Chaser(doc); c->setName("Chaser"); c->setRunOrder(Chaser::PingPong); c->setDirection(Chaser::Backward); c->addStep(s1->id()); QVERIFY(c->m_tapped == false); c->slotBusTapped(Bus::defaultFade()); QVERIFY(c->m_tapped == false); c->slotBusTapped(Bus::defaultHold()); QVERIFY(c->m_tapped == true); delete doc; }
void Chaser_Test::createCopy() { Doc doc(this, m_cache); Chaser* c1 = new Chaser(m_doc); c1->setName("First"); c1->setBus(15); c1->setDirection(Chaser::Backward); c1->setRunOrder(Chaser::SingleShot); c1->addStep(20); c1->addStep(30); c1->addStep(40); doc.addFunction(c1); QVERIFY(c1->id() != Function::invalidId()); Function* f = c1->createCopy(&doc); QVERIFY(f != NULL); QVERIFY(f != c1); QVERIFY(f->id() != c1->id()); Chaser* copy = qobject_cast<Chaser*> (f); QVERIFY(copy != NULL); QVERIFY(copy->busID() == 15); QVERIFY(copy->direction() == Chaser::Backward); QVERIFY(copy->runOrder() == Chaser::SingleShot); QVERIFY(copy->steps().size() == 3); QVERIFY(copy->steps().at(0) == 20); QVERIFY(copy->steps().at(1) == 30); QVERIFY(copy->steps().at(2) == 40); }
void VCCueList::addFunctions(QVariantList idsList, int insertIndex) { if (idsList.isEmpty()) return; if (isEditing()) { Chaser *ch = chaser(); if (ch == NULL) return; if (insertIndex == -1) insertIndex = ch->stepsCount(); for (QVariant vID : idsList) // C++11 { quint32 fid = vID.toUInt(); ChaserStep step(fid); if (ch->durationMode() == Chaser::PerStep) { Function *func = m_doc->function(fid); if (func == NULL) continue; step.duration = func->totalDuration(); if (step.duration == 0) step.duration = 1000; step.hold = step.duration; } Tardis::instance()->enqueueAction(Tardis::ChaserAddStep, ch->id(), QVariant(), insertIndex); ch->addStep(step, insertIndex++); } ChaserEditor::updateStepsList(m_doc, chaser(), m_stepsList); emit stepsListChanged(); } else { Function *f = m_doc->function(idsList.first().toUInt()); if (f == NULL || f->type() != Function::ChaserType) return; setChaserID(f->id()); } }
void Doc_Test::addFunction() { QVERIFY(m_doc->functions().size() == 0); Scene* s = new Scene(m_doc); QVERIFY(s->id() == Function::invalidId()); QVERIFY(m_doc->addFunction(s) == true); QVERIFY(s->id() == 0); QVERIFY(m_doc->functions().size() == 1); QVERIFY(m_doc->isModified() == true); m_doc->resetModified(); Chaser* c = new Chaser(m_doc); QVERIFY(c->id() == Function::invalidId()); QVERIFY(m_doc->addFunction(c) == true); QVERIFY(c->id() == 1); QVERIFY(m_doc->functions().size() == 2); QVERIFY(m_doc->isModified() == true); m_doc->resetModified(); Collection* o = new Collection(m_doc); QVERIFY(o->id() == Function::invalidId()); QVERIFY(m_doc->addFunction(o, 0) == false); QVERIFY(m_doc->isModified() == false); QVERIFY(o->id() == Function::invalidId()); QVERIFY(m_doc->functions().size() == 2); QVERIFY(m_doc->addFunction(o, 2) == true); QVERIFY(o->id() == 2); QVERIFY(m_doc->functions().size() == 3); QVERIFY(m_doc->isModified() == true); m_doc->resetModified(); EFX* e = new EFX(m_doc); QVERIFY(e->id() == Function::invalidId()); QVERIFY(m_doc->addFunction(e, 1) == false); QVERIFY(e->id() == Function::invalidId()); QVERIFY(m_doc->addFunction(e) == true); QVERIFY(e->id() == 3); QVERIFY(m_doc->functions().size() == 4); QVERIFY(m_doc->isModified() == true); }
void VCCueList_Test::modeChange() { QWidget w; VCFrame parent(&w, m_doc); VCCueList cl(&parent, m_doc); Chaser* c = createChaser(m_doc); cl.setChaser(c->id()); m_doc->setMode(Doc::Operate); // QCOMPARE(m_doc->masterTimer()->m_dmxSourceList.size(), 1); // QCOMPARE(m_doc->masterTimer()->m_dmxSourceList[0], &cl); // QVERIFY(cl.m_runner == NULL); QVERIFY(cl.m_tree->isEnabled() == true); // cl.createRunner(); m_doc->setMode(Doc::Design); QCOMPARE(m_doc->masterTimer()->m_dmxSourceList.size(), 0); // QVERIFY(cl.m_runner == NULL); QVERIFY(cl.m_tree->isEnabled() == false); }
bool IntensityGenerator::createSequenceChaser(bool forward) { // Create a sequence chaser Chaser* chaser = new Chaser(m_doc); if (forward == true) { chaser->setName("Intensity - Sequence Forward"); chaser->setDirection(Function::Forward); } else { chaser->setName("Intensity - Sequence Backward"); chaser->setDirection(Function::Backward); } if (m_doc->addFunction(chaser) == false) { // Abort if doc won't accept the chaser delete chaser; return false; } else { for (int i = 0; i < m_sequence.size(); i++) chaser->addStep(m_sequence[i]->id()); return true; } }
bool IntensityGenerator::createOddEvenChaser() { if (m_odd == NULL || m_even == NULL) return false; // Abort if doc can't fit the chaser and its two members if (m_doc->functionsFree() < 3) return false; // Create the chaser only if both steps contain something if (m_odd->values().size() != 0 && m_even->values().size() != 0) { // Abort if doc won't take the scenes if (m_doc->addFunction(m_odd) == false) return false; if (m_doc->addFunction(m_even) == false) return false; Chaser* chaser = new Chaser(m_doc); chaser->setName("Intensity - Even/Odd"); chaser->addStep(m_odd->id()); chaser->addStep(m_even->id()); // Abort if doc won't take the chaser if (m_doc->addFunction(chaser) == false) { delete chaser; return false; } else { return true; } } else { return false; } }
void VCCueList_Test::copy() { // Input sources are tested by VCWidget tests. No point testing here. QWidget w; VCFrame parent(&w, m_doc); VCCueList cl(&parent, m_doc); Chaser* c = createChaser(m_doc); cl.setChaser(c->id()); cl.setCaption("Wheeee"); cl.setNextKeySequence(QKeySequence(keySequenceB)); cl.setPreviousKeySequence(QKeySequence(keySequenceA)); cl.setPlaybackKeySequence(QKeySequence(keySequenceC)); VCCueList* cl2 = qobject_cast<VCCueList*> (cl.createCopy(&parent)); QVERIFY(cl2 != NULL); QCOMPARE(cl2->caption(), QString("Wheeee")); QCOMPARE(cl2->nextKeySequence(), QKeySequence(keySequenceB)); QCOMPARE(cl2->previousKeySequence(), QKeySequence(keySequenceA)); QCOMPARE(cl2->playbackKeySequence(), QKeySequence(keySequenceC)); QCOMPARE(cl2->chaserID(), c->id()); QCOMPARE(cl2->m_tree->topLevelItemCount(), 4); VCCueList cl3(&parent, m_doc); cl3.copyFrom(NULL); QCOMPARE(cl3.m_tree->topLevelItemCount(), 0); QCOMPARE(cl3.caption(), tr("Cue list")); cl.copyFrom(&cl3); QCOMPARE(cl.caption(), cl3.caption()); QCOMPARE(cl.chaserID(), Function::invalidId()); QCOMPARE(cl.m_tree->topLevelItemCount(), 0); QCOMPARE(cl.nextKeySequence(), QKeySequence()); QCOMPARE(cl.previousKeySequence(), QKeySequence()); QCOMPARE(cl.playbackKeySequence(), QKeySequence()); delete cl2; }
void VCCueList_Test::chaser() { QWidget w; VCCueList cl(&w, m_doc); Chaser* c = createChaser(m_doc); // Try to put a non-chaser as the chaser cl.setChaser(c->steps().first().fid); QCOMPARE(cl.chaserID(), Function::invalidId()); QCOMPARE(cl.m_tree->topLevelItemCount(), 0); // Put a real chaser as the chaser cl.setChaser(c->id()); QCOMPARE(cl.chaserID(), c->id()); QCOMPARE(cl.m_tree->topLevelItemCount(), 4); QCOMPARE(cl.m_tree->topLevelItem(0)->text(0), QString("1")); QCOMPARE(cl.m_tree->topLevelItem(1)->text(0), QString("2")); QCOMPARE(cl.m_tree->topLevelItem(2)->text(0), QString("3")); QCOMPARE(cl.m_tree->topLevelItem(3)->text(0), QString("4")); QCOMPARE(cl.m_tree->topLevelItem(0)->text(1), QString("First")); QCOMPARE(cl.m_tree->topLevelItem(1)->text(1), QString("Second")); QCOMPARE(cl.m_tree->topLevelItem(2)->text(1), QString("Third")); QCOMPARE(cl.m_tree->topLevelItem(3)->text(1), QString("Fourth")); }
void game(Screen& scr, Player& pl1, Player& pl2, Chaser& ch1, Chaser& ch2, Environment& env) { if(!pl1.isDead()) { pl1.movement(); pl1.colWithField(); pl1.gravity(); ch1.movement(pl1); if(ch1.colWithPlayer(pl1) || ch2.colWithPlayer(pl1)) pl1.killPlayer(); } if(!pl2.isDead()) { pl2.movement(); pl2.colWithField(); pl2.gravity(); ch2.movement(pl2); if(ch1.colWithPlayer(pl2) || ch2.colWithPlayer(pl2)) pl2.killPlayer(); } if(pl1.colWithGoal(env) || pl2.colWithGoal(env)) env.spawn(); scr.sClear(); scr.sDrawBackground(); scr.sDraw(env.drawGoal()); scr.sDraw(ch1.getShape()); scr.sDraw(ch2.getShape()); if(!pl1.isDead()) scr.sDraw(pl1.getShape()); if(!pl2.isDead()) scr.sDraw(pl2.getShape()); scr.sDisplay(); }
void Chaser_Test::armMissingFunction() { Doc* doc = new Doc(this, m_cache); Fixture* fxi = new Fixture(doc); fxi->setName("Test Fixture"); fxi->setAddress(0); fxi->setUniverse(0); fxi->setChannels(2); doc->addFixture(fxi); Scene* s1 = new Scene(doc); s1->setName("Scene1"); s1->setValue(fxi->id(), 0, UCHAR_MAX); s1->setValue(fxi->id(), 1, UCHAR_MAX); doc->addFunction(s1); Scene* s2 = new Scene(doc); s2->setName("Scene2"); s2->setValue(fxi->id(), 0, 0); s2->setValue(fxi->id(), 1, 0); doc->addFunction(s2); Chaser* c = new Chaser(doc); c->setName("Chaser"); c->addStep(s1->id()); c->addStep(123); // Nonexistent function c->addStep(s2->id()); c->addStep(55); // Nonexistent function QVERIFY(c->steps().size() == 4); c->arm(); QVERIFY(c->steps().size() == 2); // Nonexistent functions are removed delete doc; }
void Chaser_Test::adjustIntensity() { Chaser* c = new Chaser(m_doc); m_doc->addFunction(c); UniverseArray ua(512); MasterTimerStub timer(m_doc, ua); c->preRun(&timer); c->adjustAttribute(0.5, Function::Intensity); QCOMPARE(c->m_runner->m_intensity, qreal(0.5)); c->adjustAttribute(0.8, Function::Intensity); QCOMPARE(c->m_runner->m_intensity, qreal(0.8)); c->adjustAttribute(1.5, Function::Intensity); QCOMPARE(c->m_runner->m_intensity, qreal(1.0)); c->adjustAttribute(-0.1, Function::Intensity); QCOMPARE(c->m_runner->m_intensity, qreal(0.0)); c->postRun(&timer, &ua); // Mustn't crash after postRun c->adjustAttribute(1.0, Function::Intensity); }
void Chaser_Test::adjustIntensity() { Chaser* c = new Chaser(m_doc); m_doc->addFunction(c); QList<Universe*> ua; ua.append(new Universe(0, new GrandMaster())); MasterTimerStub timer(m_doc, ua); c->preRun(&timer); c->adjustAttribute(0.5, Function::Intensity); QCOMPARE(c->m_runner->m_intensity, qreal(0.5)); c->adjustAttribute(0.8, Function::Intensity); QCOMPARE(c->m_runner->m_intensity, qreal(0.8)); c->adjustAttribute(1.5, Function::Intensity); QCOMPARE(c->m_runner->m_intensity, qreal(1.0)); c->adjustAttribute(-0.1, Function::Intensity); QCOMPARE(c->m_runner->m_intensity, qreal(0.0)); c->postRun(&timer, ua); // Mustn't crash after postRun c->adjustAttribute(1.0, Function::Intensity); }
void Chaser_Test::armSuccess() { Doc* doc = new Doc(this, m_cache); Fixture* fxi = new Fixture(doc); fxi->setName("Test Fixture"); fxi->setAddress(0); fxi->setUniverse(0); fxi->setChannels(2); doc->addFixture(fxi); Scene* s1 = new Scene(doc); s1->setName("Scene1"); s1->setValue(fxi->id(), 0, UCHAR_MAX); s1->setValue(fxi->id(), 1, UCHAR_MAX); doc->addFunction(s1); QVERIFY(s1->id() != Function::invalidId()); Scene* s2 = new Scene(doc); s2->setName("Scene2"); s2->setValue(fxi->id(), 0, 0); s2->setValue(fxi->id(), 1, 0); doc->addFunction(s2); QVERIFY(s2->id() != Function::invalidId()); Chaser* c = new Chaser(doc); c->setName("Chaser"); c->addStep(s1->id()); c->addStep(s2->id()); QVERIFY(c->steps().size() == 2); c->arm(); QVERIFY(c->steps().size() == 2); delete doc; }
void Chaser_Test::write() { Fixture* fxi = new Fixture(m_doc); fxi->setAddress(0); fxi->setUniverse(0); fxi->setChannels(1); m_doc->addFixture(fxi); Chaser* c = new Chaser(m_doc); c->setDuration(MasterTimer::tick() * 10); m_doc->addFunction(c); Scene* s1 = new Scene(m_doc); s1->setValue(fxi->id(), 0, 255); m_doc->addFunction(s1); c->addStep(s1->id()); Scene* s2 = new Scene(m_doc); s2->setValue(fxi->id(), 0, 127); m_doc->addFunction(s2); c->addStep(s2->id()); MasterTimer timer(m_doc); QVERIFY(c->isRunning() == false); QVERIFY(c->stopped() == true); c->start(&timer); timer.timerTick(); for (uint i = MasterTimer::tick(); i < c->duration(); i += MasterTimer::tick()) { timer.timerTick(); QVERIFY(c->isRunning() == true); QVERIFY(c->stopped() == false); QVERIFY(s1->isRunning() == true); QVERIFY(s2->isRunning() == false); } for (uint i = 0; i < c->duration(); i += MasterTimer::tick()) { timer.timerTick(); QVERIFY(c->isRunning() == true); QVERIFY(c->stopped() == false); QVERIFY(s1->isRunning() == false); QVERIFY(s2->isRunning() == true); } }