void Visitor<Reader<JSONObject>>::readFrom_impl( const Explorer::DeviceDocumentPlugin& plug) { // Childrens of the root node are the devices // We don't save their children if they don't have canSerialize(). m_obj["RootNode"] = QJsonObject{}; QJsonArray children; for(auto& node : plug.rootNode().children()) { QJsonObject this_node; ISCORE_ASSERT(node.is<Device::DeviceSettings>()); const Device::DeviceSettings& dev = node.get<Device::DeviceSettings>(); auto actual = plug.list().find(dev.name); ISCORE_ASSERT(actual != plug.list().devices().cend()); if((*actual)->capabilities().canSerialize) { this_node = toJsonObject(node); } else { this_node = toJsonObject(node.impl()); } children.push_back(std::move(this_node)); } m_obj["Children"] = children; }
auto removeNode(node_type::const_iterator node) { ISCORE_ASSERT(!node->is<InvisibleRootNodeTag>()); if(node->is<Device::AddressSettings>()) { node_type* parent = node->parent(); ISCORE_ASSERT(parent != &rootNode()); node_type* grandparent = parent->parent(); ISCORE_ASSERT(grandparent); int rowParent = grandparent->indexOfChild(parent); QModelIndex parentIndex = createIndex(rowParent, 0, parent); int row = parent->indexOfChild(&*node); beginRemoveRows(parentIndex, row, row); auto it = parent->erase(node); endRemoveRows(); return it; } else { ISCORE_ASSERT(node->is<Device::DeviceSettings>()); int row = rootNode().indexOfChild(&*node); beginRemoveRows(QModelIndex(), row, row); auto it = rootNode().erase(node); endRemoveRows(); return it; } }
void DeviceEditDialog::updateProtocolWidget() { ISCORE_ASSERT(m_protocolCBox); if(m_protocolWidget) { ISCORE_ASSERT(m_index < m_protocolCBox->count()); ISCORE_ASSERT(m_index < m_previousSettings.count()); m_previousSettings[m_index] = m_protocolWidget->getSettings(); delete m_protocolWidget; } m_index = m_protocolCBox->currentIndex(); auto protocol = m_protocolCBox->currentData().value<UuidKey<Device::ProtocolFactory>>(); m_protocolWidget = m_protocolList.get(protocol)->makeSettingsWidget(); if(m_protocolWidget) { m_gLayout->addWidget(m_protocolWidget, 2, 0, 1, 2); updateGeometry(); } }
void DeviceExplorerView::columnVisibilityChanged(bool shown) { QAction* a = qobject_cast<QAction*> (sender()); ISCORE_ASSERT(a); const int ind = m_actions.indexOf(a); ISCORE_ASSERT(ind != -1); setColumnHidden(ind, !shown); }
void AddressSettingsWidget::setCommonSettings(const iscore::AddressSettings & settings) { const int ioTypeIndex = m_ioTypeCBox->findData((int)settings.ioType); ISCORE_ASSERT(ioTypeIndex != -1); m_ioTypeCBox->setCurrentIndex(ioTypeIndex); const int clipModeIndex = m_clipModeCBox->findData((int)settings.clipMode); ISCORE_ASSERT(clipModeIndex != -1); m_clipModeCBox->setCurrentIndex(clipModeIndex); m_tagsEdit->addItems(settings.tags); }
void DeviceExplorerModel::updateAddress( Device::Node *node, const Device::AddressSettings &addressSettings) { ISCORE_ASSERT(node); ISCORE_ASSERT(node != &m_rootNode); node->set(addressSettings); emit dataChanged( modelIndexFromNode(*node, 0), modelIndexFromNode(*node, (int)Column::Count)); }
void InputComponent::makeStream(const Context& ctx) { const auto& inputs = process().inputs(); if(inputs.inputs.size() == 0) return; auto in = MakeInputSound(); ISCORE_ASSERT(in); auto sel = MakeSelectSound(in, (long*)inputs.inputs.data(), inputs.inputs.size()); ISCORE_ASSERT(sel); m_stream = MakeSend(sel); ISCORE_ASSERT(m_stream); }
bool DeviceExplorerModel::checkAddressEditable( Device::Node& parent, const Device::AddressSettings& before, const Device::AddressSettings& after) { ISCORE_ASSERT(!parent.is<InvisibleRootNodeTag>()); if(after.name.isEmpty()) return false; auto it = std::find_if( parent.begin(), parent.end(), [&] (const Device::Node& n) { return n.get<Device::AddressSettings>().name == after.name; }); if(it != parent.end()) { // We didn't change name, it's ok if(after.name == before.name) return true; else return false; } else { // Ok, no conflicts return true; } }
void NodeUpdateProxy::addAddress( const Device::NodePath& parentPath, const Device::AddressSettings& settings, int row) { auto parentnode = parentPath.toNode(&devModel.rootNode()); if(!parentnode) return; // Add in the device impl // Get the device node : // TODO row isn't managed here. const Device::Node& dev_node = devModel.rootNode().childAt(parentPath.at(0)); ISCORE_ASSERT(dev_node.template is<Device::DeviceSettings>()); // Make a full path Device::FullAddressSettings full = Device::FullAddressSettings::make<Device::FullAddressSettings::as_parent>( settings, Device::address(*parentnode)); // Add in the device implementation devModel .list() .device(dev_node.template get<Device::DeviceSettings>().name) .addAddress(full); // Add in the device explorer addLocalAddress(*parentnode, settings, row); }
void MovePointCommandObject::on_press() { // Save the start data. // Firts we take the exact position of the point we clicked. auto clickedCurvePoint_it = std::find_if( m_presenter->model().points().begin(), m_presenter->model().points().end(), [&] (PointModel* pt) { return pt->previous() == m_state->clickedPointId.previous && pt->following() == m_state->clickedPointId.following; }); ISCORE_ASSERT(clickedCurvePoint_it != m_presenter->model().points().end()); auto clickedCurvePoint = *clickedCurvePoint_it; m_originalPress = clickedCurvePoint->pos(); // Compute xmin, xmax // Look for the next and previous points for(PointModel* pt : m_presenter->model().points()) { auto pt_x = pt->pos().x(); if(pt == clickedCurvePoint) continue; if(pt_x >= m_xmin && pt_x < m_originalPress.x()) { m_xmin = pt_x; } if(pt_x <= m_xmax && pt_x > m_originalPress.x()) { m_xmax = pt_x; } } }
const double* ProcessModel::mix_ptr(const Routing & r) const { auto it = m_routings.find(r); ISCORE_ASSERT(it != m_routings.end()); return &(it->mix); }
void NodeUpdateProxy::removeNode( const Device::NodePath& parentPath, const Device::AddressSettings& settings) { Device::Node* parentnode = parentPath.toNode(&devModel.rootNode()); if(!parentnode) return; auto addr = Device::address(*parentnode); addr.path.append(settings.name); // Remove from the device implementation const auto& dev_node = devModel.rootNode().childAt(parentPath.at(0)); devModel.list().device( dev_node.template get<Device::DeviceSettings>().name) .removeNode(addr); // Remove from the device explorer auto it = std::find_if( parentnode->begin(), parentnode->end(), [&] (const Device::Node& n) { return n.get<Device::AddressSettings>().name == settings.name; }); ISCORE_ASSERT(it != parentnode->end()); if(deviceExplorer) { deviceExplorer->removeNode(it); } else { parentnode->erase(it); } }
double ProcessModel::mix(const Routing & r) const { auto it = m_routings.find(r); ISCORE_ASSERT(it != m_routings.end()); return it->mix; }
iscore::DeviceSettings MIDIProtocolSettingsWidget::getSettings() const { ISCORE_ASSERT(m_deviceCBox); ISCORE_ASSERT(m_inButton); iscore::DeviceSettings s; MIDISpecificSettings midi; s.name = m_deviceCBox->currentText(); midi.io = m_inButton->isChecked() ? MIDISpecificSettings::IO::In : MIDISpecificSettings::IO::Out; s.deviceSpecificSettings = QVariant::fromValue(midi); return s; }
void NodeUpdateProxy::addNode( const Device::NodePath& parentPath, const Device::Node& node, int row) { ISCORE_ASSERT(node.template is<Device::AddressSettings>()); rec_addNode(parentPath, node, row); }
void DeviceExplorerModel::addAddress( Device::Node* parentNode, const Device::AddressSettings& addressSettings, int row) { ISCORE_ASSERT(parentNode); ISCORE_ASSERT(parentNode != &m_rootNode); Device::Node* grandparent = parentNode->parent(); ISCORE_ASSERT(grandparent); int rowParent = grandparent->indexOfChild(parentNode); QModelIndex parentIndex = createIndex(rowParent, 0, parentNode); beginInsertRows(parentIndex, row, row); parentNode->emplace(parentNode->begin() + row, addressSettings, parentNode); endInsertRows(); }
const DimensionModel& SpaceModel::dimension(const QString& name) const { auto it = std::find_if(m_dimensions.begin(), m_dimensions.end(), [&] (const DimensionModel& dim) { return dim.name() == name; }); ISCORE_ASSERT(it != m_dimensions.end()); return *it; }
void DeviceEditDialog::setSettings(const Device::DeviceSettings &settings) { //auto proto = SingletonProtocolList::instance().get(settings.protocol); //if(proto) { const int index = m_protocolCBox->findData(QVariant::fromValue(settings.protocol)); ISCORE_ASSERT(index != -1); ISCORE_ASSERT(index < m_protocolCBox->count()); m_protocolCBox->setCurrentIndex(index); //will emit currentIndexChanged(int) & call slot m_protocolWidget->setSettings(settings); } //else { // ISCORE_TODO; // Make a default widget. } }
void DeviceExplorerModel::addNode( Device::Node* parentNode, Device::Node&& child, int row) { ISCORE_ASSERT(parentNode); ISCORE_ASSERT(parentNode != &m_rootNode); Device::Node* grandparent = parentNode->parent(); ISCORE_ASSERT(grandparent); int rowParent = grandparent->indexOfChild(parentNode); QModelIndex parentIndex = createIndex(rowParent, 0, parentNode); beginInsertRows(parentIndex, row, row); parentNode->emplace(parentNode->begin() + row, std::move(child)); endInsertRows(); }
Device::DeviceSettings MIDIProtocolSettingsWidget::getSettings() const { ISCORE_ASSERT(m_deviceCBox); ISCORE_ASSERT(m_inButton); // TODO *** Initialize with ProtocolFactory.defaultSettings(). Device::DeviceSettings s; MIDISpecificSettings midi; s.name = m_name->text(); midi.io = m_inButton->isChecked() ? MIDISpecificSettings::IO::In : MIDISpecificSettings::IO::Out; midi.endpoint = m_deviceCBox->currentText(); midi.port = m_deviceCBox->currentData().toInt(); s.deviceSpecificSettings = QVariant::fromValue(midi); return s; }
void ReturnComponent::makeStream(const Context& ctx) { // Find send auto send = process().send_ptr(); ISCORE_ASSERT(send); // Create stream from send m_stream = MakeSend( MakeReturn( iscore::component<SendComponent>(send->components()).getStream())); }
void DeviceExplorerView::setInitialColumnsSizes() { ISCORE_ASSERT(model()); header()->resizeSection((int)DeviceExplorerModel::Column::Name, 220); header()->resizeSection((int)DeviceExplorerModel::Column::Value, 50); header()->resizeSection((int)DeviceExplorerModel::Column::Get, 36); header()->resizeSection((int)DeviceExplorerModel::Column::Set, 36); header()->resizeSection((int)DeviceExplorerModel::Column::Min, 50); header()->resizeSection((int)DeviceExplorerModel::Column::Max, 50); }
void ProcessModel::updateRouting(const Routing & r) { auto it = m_routings.find(r); ISCORE_ASSERT(it != m_routings.end()); m_routings.modify(it, [&] (auto& obj) { obj.mix = r.mix; obj.enabled = r.enabled; }); emit routingChanged(r); }
bool DeviceExplorerModel::checkAddressInstantiatable( Device::Node& parent, const Device::AddressSettings& addr) { ISCORE_ASSERT(!parent.is<InvisibleRootNodeTag>()); if(addr.name.isEmpty()) return false; return std::none_of(parent.begin(), parent.end(), [&] (const Device::Node& n) { return n.get<Device::AddressSettings>().name == addr.name; }); }
Address Address::fromString(const QString &str) { if (!validateString( str)) return {"", {""} }; QStringList path = str.split("/"); ISCORE_ASSERT(path.size() > 0); auto device = path.first().remove(":"); path.removeFirst(); // Remove the device. if(path.first().isEmpty()) // case "device:/" { return {device, {}}; } return {device, path}; }
void AddStateProcessDialog::launchWindow() { bool ok = false; std::vector<std::pair<QString, UuidKey<Process::StateProcessFactory>>> sortedFactoryList; for(const auto& factory : m_factoryList) { sortedFactoryList.push_back( std::make_pair( factory.prettyName(), factory.concreteFactoryKey())); } std::sort(sortedFactoryList.begin(), sortedFactoryList.end(), [] (const auto& e1, const auto& e2) { return e1.first < e2.first; }); QStringList nameList; for(const auto& elt : sortedFactoryList) { nameList.append(elt.first); } auto process_name = QInputDialog::getItem( qApp->activeWindow(), tr("Choose a state process"), tr("Choose a state process"), nameList, 0, false, &ok); if(ok) { auto it = std::find_if(sortedFactoryList.begin(), sortedFactoryList.end(), [&] (const auto& elt) { return elt.first == process_name; }); ISCORE_ASSERT(it != sortedFactoryList.end()); emit okPressed(it->second); } }
QString TreeNode<State::ExprData>::toString() const { QString s; auto exprstr = static_cast<const State::ExprData&>(*this).toString(); if(m_children.empty()) // Relation { if(this->is<InvisibleRootNodeTag>()) { ; } else { s = "(" + exprstr + ")"; } } else if(m_children.size() == 1) // unop { if(this->is<InvisibleRootNodeTag>()) { s = m_children.at(0).toString(); } else { s = "(" + exprstr + " " + m_children.at(0).toString() + ")"; } } else // binop { ISCORE_ASSERT(m_children.size() == 2); int n = 0; int max_n = m_children.size() - 1; for(const auto& child : m_children) { s += child.toString() + " "; if(n < max_n) { s += exprstr + " "; n++; } } } return s; }
void NodeUpdateProxy::removeDevice(const Device::DeviceSettings& dev) { devModel.list().removeDevice(dev.name); const auto& rootNode = devModel.rootNode(); auto it = find_if(rootNode, [&] (const Device::Node& val) { return val.is<Device::DeviceSettings>() && val.get<Device::DeviceSettings>().name == dev.name; }); ISCORE_ASSERT(it != rootNode.end()); if(deviceExplorer) { deviceExplorer->removeNode(it); } else { devModel.rootNode().erase(it); } }
void NodeUpdateProxy::updateDevice( const QString &name, const Device::DeviceSettings& dev) { devModel.list().device(name).updateSettings(dev); if(deviceExplorer) { deviceExplorer->updateDevice(name, dev); } else { auto it = std::find_if(devModel.rootNode().begin(), devModel.rootNode().end(), [&] (const Device::Node& n) { return n.get<Device::DeviceSettings>().name == name; }); ISCORE_ASSERT(it != devModel.rootNode().end()); it->set(dev); } }
void DeviceEditDialog::initAvailableProtocols() { ISCORE_ASSERT(m_protocolCBox); //initialize previous settings m_previousSettings.clear(); for(const auto& prot : m_protocolList.list()) { m_protocolCBox->addItem( prot->prettyName(), QVariant::fromValue(prot->key<UuidKey<Device::ProtocolFactory>>())); m_previousSettings.append(prot->defaultSettings()); } m_index = m_protocolCBox->currentIndex(); }