Example #1
0
static void RemoveProcessBeforeState(
    StateModel& statemodel,
    const Process::ProcessModel& proc)
{
  ProcessStateDataInterface* state = proc.endStateData();
  if (!state)
    return;

  auto it
      = ossia::find_if(statemodel.previousProcesses(), [&](const auto& elt) {
          return state == &elt.process();
        });

  updateTreeWithRemovedProcess(
      statemodel.messages().rootNode(), proc.id(), ProcessPosition::Previous);
  statemodel.sig_statesUpdated();

  // TODO debug the need for this check
  if (it != statemodel.previousProcesses().end())
    statemodel.previousProcesses().erase(it);
}
Example #2
0
static void AddProcessBeforeState(
    StateModel& statemodel,
    const Process::ProcessModel& proc)
{
  // TODO this should be fused with the notion of State Process.
  ProcessStateDataInterface* state = proc.endStateData();
  if (!state)
    return;

  auto prev_proc_fun = [&](const State::MessageList& ml) {
    // TODO have some collapsing between all the processes of a state
    // NOTE how to prevent these states from being played
    // twice ? mark them ?
    // TODO which one should be sent ? the ones
    // from the process ?
    auto& messages = statemodel.messages();

    for (const ProcessStateWrapper& next_proc :
         statemodel.followingProcesses())
    {
      next_proc.process().setMessages(ml, messages.rootNode());
    }

    updateTreeWithMessageList(
        messages.rootNode(), ml, proc.id(), ProcessPosition::Previous);
    statemodel.sig_statesUpdated();
  };

  statemodel.previousProcesses().emplace_back(state);
  auto& wrapper = statemodel.previousProcesses().back();
  QObject::connect(
      state,
      &ProcessStateDataInterface::messagesChanged,
      &wrapper,
      prev_proc_fun);

  prev_proc_fun(state->messages());
}