Exemple #1
0
void Component::recompute()
{
  const Execution::Context& s = this->system();
  auto g = process().spline();
  s.executionQueue.enqueue(
      [proc = std::dynamic_pointer_cast<spline>(OSSIAProcess().node), g] {
        proc->set_spline(g);
      });
}
Exemple #2
0
void ConstraintElement::on_processAdded(
        const Process::ProcessModel& iscore_proc) // TODO ProcessExecutionView
{
    // The DocumentPlugin creates the elements in the processes.
    // TODO maybe have an execution_view template on processes, that
    // gives correct const / non_const access ?
    auto proc = const_cast<Process::ProcessModel*>(&iscore_proc);
    auto fac = m_ctx.processes.factory(*proc, m_ctx.sys, m_ctx.doc);
    if(fac)
    {
        auto plug = fac->make(*this, *proc, m_ctx, getStrongId(iscore_proc.components), this);
        if(plug)
        {
            auto id = iscore_proc.id();
            std::unique_ptr<ProcessWrapper> wp;
            if(proc->useParentDuration())
            {
                wp = std::make_unique<BasicProcessWrapper>(
                            m_ossia_constraint,
                            plug->OSSIAProcess(),
                            iscore::convert::time(plug->iscoreProcess().duration()),
                            m_iscore_constraint.looping() );
            }
            else
            {
                wp = std::make_unique<LoopingProcessWrapper>(
                            m_ossia_constraint,
                            plug->OSSIAProcess(),
                            iscore::convert::time(plug->iscoreProcess().duration()),
                            m_iscore_constraint.looping()) ;
            }
            m_processes.insert(
                        std::make_pair(
                            id,
                            OSSIAProcess(plug, std::move(wp))));
        }
    }
}
void OSSIAConstraintElement::on_processAdded(
        const Process& iscore_proc) // TODO ProcessExecutionView
{
    // The DocumentPlugin creates the elements in the processes.
    // TODO maybe have an execution_view template on processes, that
    // gives correct const / non_const access ?
    auto proc = const_cast<Process*>(&iscore_proc);
    OSSIAProcessElement* plug{};
    if(auto scenar = dynamic_cast<ScenarioModel*>(proc))
    {
        plug = new OSSIAScenarioElement{*this, *scenar, proc};
    }
    else if(auto autom = dynamic_cast<AutomationModel*>(proc))
    {
        plug = new OSSIAAutomationElement{*this, *autom, proc};
    }
#if defined(ISCORE_PLUGIN_MAPPING)
    else if(auto mapping = dynamic_cast<MappingModel*>(proc))
    {
        plug = new OSSIAMappingElement{*this, *mapping, proc};
    }
#endif
    else if(auto generic = dynamic_cast<OSSIAProcessModel*>(proc))
    {
        plug = new OSSIAProcessModelElement{*this, *generic, proc};
    }

    if(plug)
    {
        auto id = iscore_proc.id();
        m_processes.insert(std::make_pair(id,
                            OSSIAProcess(plug,
                             std::make_unique<ProcessWrapper>(
                                 m_ossia_constraint,
                                 plug->OSSIAProcess(),
                                 iscore::convert::time(plug->iscoreProcess().duration()),
                                 m_iscore_constraint.looping()
                             )
                            )
                           ));

        // i-score scenario has ownership, hence
        // we have to remove it from the array if deleted
        connect(plug, &QObject::destroyed, this,
                [=] (QObject*) {
            // The OSSIA::Process removal is in each process dtor
            m_processes.erase(id);
        }, Qt::DirectConnection);

        // Processes might change (for instance automation needs to be recreated
        // at each address change) so we do this little dance.
        connect(plug, &OSSIAProcessElement::changed,
                this, [=] (
                    const std::shared_ptr<OSSIA::TimeProcess>& a1,
                    const std::shared_ptr<OSSIA::TimeProcess>& a2) {
            m_processes.at(id).wrapper->changed(a1, a2);
        });

        connect(&plug->iscoreProcess(), &Process::durationChanged,
                this, [=] () {
            auto& the_proc = m_processes.at(id);
            the_proc.wrapper->setDuration(iscore::convert::time(the_proc.element->iscoreProcess().duration()));
        });
    }
}