Ejemplo n.º 1
0
auto add_setProperty(OSSIA::Node& n, const std::string& name, Callback cb)
{
    constexpr const auto t = Ossia::convert::MatchingType<T>::val;
    std::shared_ptr<OSSIA::Node> node = *n.emplace(
                                            n.children().end(),
                                            name,
                                            t,
                                            OSSIA::AccessMode::SET);

    return make_setProperty<T>(node, node->getAddress(), cb);
}
Ejemplo n.º 2
0
        MetadataNamePropertyWrapper(
                OSSIA::Node& parent,
                ModelMetadata& arg_metadata,
                QObject* context
                ):
            metadata{arg_metadata}
        {
            node = *parent.emplace(
                       parent.children().end(),
                       arg_metadata.name().toStdString());

            /*
            m_callbackIt =
                    node->addCallback(
                        [=] (const OSSIA::Node& node, const std::string& name, OSSIA::NodeChange t) {
                if(t == OSSIA::NodeChange::RENAMED)
                {
                    auto str = QString::fromStdString(node.getName());
                    if(str != metadata.name())
                        metadata.setName(str);
                }
            });
            */

            auto setNameFun = [=] (const QString& newName_qstring) {
                auto newName = newName_qstring.toStdString();
                auto curName = node->getName();

                if(curName != newName)
                {
                    node->setName(newName);
                    auto real_newName = node->getName();

                    if(real_newName != newName)
                    {
                        metadata.setName(QString::fromStdString(real_newName));
                    }
                }
            };

            QObject::connect(
                        &metadata, &ModelMetadata::nameChanged,
                        context, setNameFun,
                        Qt::QueuedConnection);

            setNameFun(metadata.name());
        }
Ejemplo n.º 3
0
OSSIA::Node *createNodeFromPath(const QStringList &path, OSSIA::Device *dev)
{
    using namespace OSSIA;
    // Find the relevant node to add in the device
    OSSIA::Node* node = dev;
    for(int i = 0; i < path.size(); i++)
    {
        const auto& children = node->children();
        auto it = boost::range::find_if(
                      children,
                      [&] (const auto& ossia_node) { return ossia_node->getName() == path[i].toStdString(); });
        if(it == children.end())
        {
            // We have to start adding sub-nodes from here.
            OSSIA::Node* parentnode = node;
            for(int k = i; k < path.size(); k++)
            {
                auto newNodeIt = parentnode->emplace(parentnode->children().begin(), path[k].toStdString());
                if(k == path.size() - 1)
                {
                    node = newNodeIt->get();
                }
                else
                {
                    parentnode = newNodeIt->get();
                }
            }

            break;
        }
        else
        {
            node = it->get();
        }
    }

    return node;
}