/** * Main routine of the mapping agent. */ void *agent_routine(void *data) { agent_t *agent = (agent_t*) data; assert(agent != NULL); while (1) { int i; // wait threads synchro for (i = 0; i < agent->nb_threads; i++) { orcc_semaphore_wait(agent->sync->sem_monitor); } print_orcc_trace(ORCC_VL_VERBOSE_1, "Remap the actors..."); compute_workloads(agent->network); do_mapping(agent->network, agent->options, agent->mapping); apply_mapping(agent->mapping, agent->scheduler, agent->nb_threads); if(mapping_repetition == REMAP_ALWAYS) { reset_profiling(agent->network); resetMapping(); } else { need_remap = FALSE; fpsPrintInit_mapping(); } // wakeup all threads for (i = 0; i < agent->nb_threads; i++) { orcc_semaphore_set(agent->scheduler->schedulers[i]->sem_thread); } } return 0; }
// ofxLeapMotion //-------------------------------------------------------------- ofxLeapMotion::ofxLeapMotion() :swipeSpeed(0) ,swipeDurationSeconds(0) ,swipeDurationMicros(0) { reset(); resetMapping(); ourController = new Leap::Controller(); }
void InputDialog::store() { for (std::size_t i = 0; i < inputBoxPairs.size(); ++i) { if (inputBoxPairs[i]) { eventData[i * 2] = inputBoxPairs[i]->mainBox->getData(); eventData[i * 2 + 1] = inputBoxPairs[i]->altBox->getData(); } } resetMapping(); }
InputDialog::InputDialog(const std::vector<Button> &buttonInfos, const bool deleteButtonActions, QWidget *parent) : QDialog(parent), buttonInfos(buttonInfos), inputBoxPairs(buttonInfos.size(), 0), eventData(buttonInfos.size() * 2), deleteButtonActions(deleteButtonActions) { setWindowTitle(tr("Input Settings")); QVBoxLayout *mainLayout = new QVBoxLayout; QPushButton *const okButton = new QPushButton(tr("OK")); QPushButton *const cancelButton = new QPushButton(tr("Cancel")); { QTabWidget *const tabw = new QTabWidget; for (std::size_t i = 0; i < buttonInfos.size(); ++i) { if (!buttonInfos[i].label.isEmpty()) { inputBoxPairs[i] = new InputBoxPair(new InputBox, new InputBox); int j = tabw->count() - 1; while (j >= 0 && tabw->tabText(j) != buttonInfos[i].category) --j; if (j < 0) { QWidget *const w = new QWidget; QBoxLayout *const boxl = new QVBoxLayout; boxl->addLayout(new QGridLayout); boxl->setAlignment(Qt::AlignTop); w->setLayout(boxl); j = tabw->addTab(w, buttonInfos[i].category); } QGridLayout *const gLayout = (QGridLayout*) tabw->widget(j)->layout()->itemAt(0); gLayout->addWidget(new QLabel(buttonInfos[i].label + ":"), i, 0); gLayout->addWidget(inputBoxPairs[i]->mainBox, i, 1); gLayout->addWidget(inputBoxPairs[i]->altBox, i, 2); QPushButton *const clearButton = new QPushButton(tr("Clear")); gLayout->addWidget(clearButton, i, 3); connect(clearButton, SIGNAL(clicked()), inputBoxPairs[i], SLOT(clear())); } } for (int tabi = 0; tabi < tabw->count(); ++tabi) { QWidget *const w = tabw->widget(tabi); std::size_t i = 0; while (i < inputBoxPairs.size() && (!inputBoxPairs[i] || inputBoxPairs[i]->mainBox->parentWidget() != w)) ++i; while (i < inputBoxPairs.size()) { std::size_t j = i + 1; while (j < inputBoxPairs.size() && (!inputBoxPairs[j] || inputBoxPairs[j]->mainBox->parentWidget() != w)) ++j; if (j < inputBoxPairs.size()) { inputBoxPairs[i]->mainBox->setNextFocus(inputBoxPairs[j]->mainBox); inputBoxPairs[i]->altBox->setNextFocus(inputBoxPairs[j]->altBox); } else { inputBoxPairs[i]->mainBox->setNextFocus(okButton); inputBoxPairs[i]->altBox->setNextFocus(okButton); } i = j; } } mainLayout->addWidget(tabw); } QHBoxLayout *const hLayout = new QHBoxLayout; hLayout->addWidget(okButton); hLayout->addWidget(cancelButton); mainLayout->addLayout(hLayout); mainLayout->setAlignment(hLayout, Qt::AlignBottom | Qt::AlignRight); okButton->setDefault(true); setLayout(mainLayout); connect(okButton, SIGNAL(clicked()), this, SLOT(accept())); connect(cancelButton, SIGNAL(clicked()), this, SLOT(reject())); QSettings settings; settings.beginGroup("input"); for (std::size_t i = 0; i < buttonInfos.size(); ++i) { if (!buttonInfos[i].label.isEmpty()) { eventData[i * 2].id = settings.value(buttonInfos[i].category + buttonInfos[i].label + "Key1", buttonInfos[i].defaultKey).toUInt(); eventData[i * 2].value = settings.value(buttonInfos[i].category + buttonInfos[i].label + "Value1", buttonInfos[i].defaultKey == Qt::Key_unknown ? InputBox::NULL_VALUE : InputBox::KBD_VALUE).toInt(); eventData[i * 2 + 1].id = settings.value(buttonInfos[i].category + buttonInfos[i].label + "Key2", buttonInfos[i].defaultAltKey).toUInt(); eventData[i * 2 + 1].value = settings.value(buttonInfos[i].category + buttonInfos[i].label + "Value2", buttonInfos[i].defaultAltKey == Qt::Key_unknown ? InputBox::NULL_VALUE : InputBox::KBD_VALUE).toInt(); } else { eventData[i * 2].id = buttonInfos[i].defaultKey; eventData[i * 2].value = buttonInfos[i].defaultKey == Qt::Key_unknown ? InputBox::NULL_VALUE : InputBox::KBD_VALUE; eventData[i * 2 + 1].id = buttonInfos[i].defaultAltKey; eventData[i * 2 + 1].value = buttonInfos[i].defaultAltKey == Qt::Key_unknown ? InputBox::NULL_VALUE : InputBox::KBD_VALUE; } } settings.endGroup(); restore(); resetMapping(); }
InputDialog::InputDialog(auto_vector<Button> &buttons, QWidget *parent) : QDialog(parent) , buttons_(buttons) , inputBoxes_(buttons_.size() * 2) , fppBoxes_( buttons_.size() * 2) , config_( buttons_.size() * 2) { setWindowTitle(tr("Input Settings")); QVBoxLayout *const mainLayout = new QVBoxLayout(this); QTabWidget *const tabw = addWidget(mainLayout, new QTabWidget); QHBoxLayout *const okCancelLayout = addLayout(mainLayout, new QHBoxLayout, Qt::AlignBottom | Qt::AlignRight); QPushButton *const okButton = addWidget(okCancelLayout, new QPushButton(tr("OK"))); QPushButton *const cancelButton = addWidget(okCancelLayout, new QPushButton(tr("Cancel"))); okButton->setDefault(true); connect(okButton, SIGNAL(clicked()), this, SLOT(accept())); connect(cancelButton, SIGNAL(clicked()), this, SLOT(reject())); for (std::size_t i = 0; i < buttons_.size(); ++i) { QString const label = buttons_[i]->label(); if (!label.isEmpty()) { QString const category = buttons_[i]->category(); int j = tabw->count() - 1; while (j >= 0 && tabw->tabText(j) != category) --j; if (j < 0) { QWidget *const w = new QWidget; j = tabw->addTab(w, category); QBoxLayout *boxl = new QVBoxLayout(w); boxl->addLayout(new QGridLayout); boxl->setAlignment(Qt::AlignTop); } int const defaultFpp = buttons_[i]->defaultFpp(); QGridLayout *const gLayout = static_cast<QGridLayout *>(tabw->widget(j)->layout()->itemAt(0)); gLayout->addWidget(new QLabel(label + ':'), i, 0); if (defaultFpp) { QHBoxLayout *hLayout = addLayout(gLayout, new QHBoxLayout, i, 1); inputBoxes_[i * 2 ] = addWidget(hLayout, new InputBox); fppBoxes_[i * 2 ] = addFppBox(hLayout, defaultFpp); hLayout = addLayout(gLayout, new QHBoxLayout, i, 2); inputBoxes_[i * 2 + 1] = addWidget(hLayout, new InputBox); fppBoxes_[i * 2 + 1] = addFppBox(hLayout, defaultFpp); } else { inputBoxes_[i * 2 ] = addWidget(gLayout, new InputBox, i, 1); inputBoxes_[i * 2 + 1] = addWidget(gLayout, new InputBox, i, 2); } QPushButton *const clearButton = addWidget(gLayout, new QPushButton(tr("Clear")), i, 3); connect(clearButton, SIGNAL(clicked()), inputBoxes_[i * 2 + 1], SLOT(clear())); connect(inputBoxes_[i * 2 + 1], SIGNAL(redundantClear()), inputBoxes_[i * 2 ], SLOT(clear())); } } for (int tabi = 0; tabi < tabw->count(); ++tabi) { QWidget *const w = tabw->widget(tabi); std::size_t i = 0; while (i < inputBoxes_.size() && (!inputBoxes_[i] || inputBoxes_[i]->parentWidget() != w)) { i += 2; } while (i < inputBoxes_.size()) { std::size_t j = i + 2; while (j < inputBoxes_.size() && (!inputBoxes_[j] || inputBoxes_[j]->parentWidget() != w)) { j += 2; } if (j < inputBoxes_.size()) { inputBoxes_[i ]->setNextFocus(inputBoxes_[j ]); inputBoxes_[i + 1]->setNextFocus(inputBoxes_[j + 1]); } else { inputBoxes_[i ]->setNextFocus(okButton); inputBoxes_[i + 1]->setNextFocus(okButton); } i = j; } } QSettings settings; settings.beginGroup("input"); for (std::size_t i = 0; i < buttons_.size(); ++i) { int const defaultKey = buttons_[i]->defaultKey(); int const defaultAltKey = buttons_[i]->defaultAltKey(); int const defaultFpp = buttons_[i]->defaultFpp(); QString const label = buttons_[i]->label(); if (!label.isEmpty()) { QString const category = buttons_[i]->category(); config_[i * 2 ].event.id = settings.value(category + label + "Key1", defaultKey).toUInt(); config_[i * 2 ].event.value = settings.value(category + label + "Value1", defaultKey ? InputBox::value_null : InputBox::value_kbd).toInt(); config_[i * 2 ].fpp = defaultFpp ? settings.value(category + label + "Fpp1", defaultFpp).toInt() : 0; config_[i * 2 + 1].event.id = settings.value(category + label + "Key2", defaultAltKey).toUInt(); config_[i * 2 + 1].event.value = settings.value(category + label + "Value2", defaultAltKey ? InputBox::value_null : InputBox::value_kbd).toInt(); config_[i * 2 + 1].fpp = defaultFpp ? settings.value(category + label + "Fpp2", defaultFpp).toInt() : 0; } else { config_[i * 2 ].event.id = defaultKey; config_[i * 2 ].event.value = defaultKey ? InputBox::value_null : InputBox::value_kbd; config_[i * 2 ].fpp = defaultFpp; config_[i * 2 + 1].event.id = defaultAltKey; config_[i * 2 + 1].event.value = defaultAltKey ? InputBox::value_null : InputBox::value_kbd; config_[i * 2 + 1].fpp = defaultFpp; } } settings.endGroup(); restore(); resetMapping(); }