Esempio n. 1
0
        void makeSnapshot()
        {
            using namespace Command;
            if(m_parentSM.editionSettings().sequence())
                return;

            if(this->createdStates.empty())
                return;

            if(!this->createdConstraints.empty())
            {
                const auto& cst = m_parentSM.model().constraints.at(this->createdConstraints.last());
                if(!cst.processes.empty())
                {
                    // In case of the presence of a sequence, we
                    // only use the sequence's namespace, hence we don't need to make a snapshot at the end..
                    return;
                }
            }

            auto& device_explorer = this->m_parentSM.context().context.template plugin<Explorer::DeviceDocumentPlugin>().explorer;

            State::MessageList messages = getSelectionSnapshot(device_explorer);
            if(messages.empty())
                return;

            m_dispatcher.submitCommand(new AddMessagesToState{
                                           m_parentSM.model().states.at(this->createdStates.last()).messages(),
                                           messages});
        }
Esempio n. 2
0
        void dropEvent(QDropEvent* ev) override
        {
            auto mime = ev->mimeData();

            if(mime->formats().contains(iscore::mime::messagelist()))
            {
                Mime<State::MessageList>::Deserializer des{*mime};
                State::MessageList ml = des.deserialize();
                if(ml.size() > 0)
                {
                    this->setText(ml[0].address.toString());
                }
            }
        }
Esempio n. 3
0
void AddressEditWidget::dropEvent(QDropEvent* ev)
{
    auto mime = ev->mimeData();

    if(mime->formats().contains(iscore::mime::messagelist()))
    {
        Mime<State::MessageList>::Deserializer des{*mime};
        State::MessageList ml = des.deserialize();
        if(ml.size() > 0)
        {
            setAddress(ml[0].address);
        }
    }
}
Esempio n. 4
0
//method called when a drag is initiated
QMimeData*
DeviceExplorerModel::mimeData(const QModelIndexList& indexes) const
{
    QMimeData* mimeData = new QMimeData;

    auto uniqueNodes = uniqueSelectedNodes(indexes);

    // Now we request an update to the device explorer.
    m_devicePlugin.updateProxy.refreshRemoteValues(uniqueNodes.parents);

    // The "MessagesList" part.
    State::MessageList messages;
    for(const auto& node : uniqueNodes.parents)
    {
        Device::parametersList(*node, messages);
    }
    for(const auto& node : uniqueNodes.messages)
    {
        messages += Device::message(*node);
    }

    if(!messages.empty())
    {
        Mime<State::MessageList>::Serializer s{*mimeData};
        s.serialize(messages);
    }

    // The "Nodes" part.
    // TODO The mime data should also transmit the root address for
    // each node in this case. For now it's useless.
    {
        Mime<Device::NodeList>::Serializer s{*mimeData};
        s.serialize(uniqueNodes.parents + uniqueNodes.messages);
    }

    if(messages.empty() && uniqueNodes.parents.empty() && uniqueNodes.messages.empty())
    {
        delete mimeData;
        return nullptr;
    }

    return mimeData;
}
static void rec_updateTree(
        Process::MessageNode& node,
        State::MessageList& lst,
        const Id<Process::ProcessModel>& proc,
        ProcessPosition pos)
{
    // If the message is in the tree, we add the process value.
    int n = lst.size();
    nodeInsertAction(node, lst, proc, pos);
    if(lst.size() == n) // No nodes were added / updated
    {
        nodePruneAction(node, proc, pos);
    }

    for(auto& child : node)
    {
        rec_updateTree(child, lst, proc, pos);
    }

    cleanupNode(node);
}
static void nodeInsertAction(
        Process::MessageNode& node,
        State::MessageList& msg,
        const Id<Process::ProcessModel>& proc,
        ProcessPosition pos
        )
{
    auto it = msg.begin();
    auto end = msg.end();
    while(it != end)
    {
        const auto& mess = *it;
        if(match(node, mess))
        {
            switch(pos)
            {
                case ProcessPosition::Previous:
                {
                    updateNode(node.values.previousProcessValues, mess.value, proc);
                    break;
                }
                case ProcessPosition::Following:
                {
                    updateNode(node.values.followingProcessValues, mess.value, proc);
                    break;
                }
                default:
                    ISCORE_ABORT;
                    break;
            }

            it = msg.erase(it);
        }
        else
        {
            ++it;
        }
    }
}
Esempio n. 7
0
void parametersList(const Node& n, State::MessageList& ml)
{
  if (n.is<AddressSettings>())
  {
    const auto& stgs = n.get<AddressSettings>();

    if (stgs.ioType == ossia::access_mode::BI)
    {
      ml.push_back(message(n));
    }
  }

  for (const auto& child : n.children())
  {
    parametersList(child, ml);
  }
}