22 Scenario::Command::CommandFactoryName(),
LoadPreset,
"Load a preset")
27 , m_old{obj.savePreset()}
28 , m_new{std::move(newval)}
35 m_path.find(ctx).loadPreset(m_old);
40 m_path.find(ctx).loadPreset(m_new);
45 stream << m_path << m_old << m_new;
49 stream >> m_path >> m_old >> m_new;
69 , m_old{model.savePreset()}
70 , m_new{std::move(newval)}
75 for(
auto& port : model.inlets())
76 m_oldInlets.emplace_back(
78 for(
auto& port : model.outlets())
79 m_oldOutlets.emplace_back(
86 auto& cmt = m_path.find(ctx);
89 Dataflow::removeCables(m_oldCables, ctx);
92 cmt.loadPreset(m_old);
96 SCORE_ASSERT(m_oldInlets.size() == cmt.inlets().size());
97 SCORE_ASSERT(m_oldOutlets.size() == cmt.outlets().size());
100 for(std::size_t i = 0; i < m_oldInlets.size(); i++)
102 cmt.inlets()[i]->loadData(m_oldInlets[i].data);
104 for(std::size_t i = 0; i < m_oldOutlets.size(); i++)
106 cmt.outlets()[i]->loadData(m_oldOutlets[i].data);
110 auto cables = Dataflow::restoreCablesWithoutTouchingPorts(m_oldCables, ctx);
111 Dataflow::reattachCablesToPorts(cables, ctx);
113 cmt.outletsChanged();
114 Dataflow::notifyAddedCables(cables, ctx);
119 Dataflow::removeCables(m_oldCables, ctx);
121 auto& cmt = m_path.find(ctx);
122 std::vector<int> inletIds, outletIds;
123 inletIds.reserve(cmt.inlets().size());
124 outletIds.reserve(cmt.outlets().size());
125 for(
auto* port : cmt.inlets())
126 inletIds.push_back(port->id().val());
127 for(
auto* port : cmt.outlets())
128 outletIds.push_back(port->id().val());
129 cmt.loadPreset(m_new);
133 auto cables = Dataflow::reloadPortsInNewProcess(
134 m_oldInlets, m_oldOutlets, m_oldCables, cmt, Process::PortLoadDataFlags{}, ctx,
135 inletIds, outletIds);
138 cmt.outletsChanged();
139 Dataflow::notifyAddedCables(cables, ctx);
144 stream << m_path << m_old << m_new << m_oldInlets << m_oldOutlets << m_oldCables;
148 stream >> m_path >> m_old >> m_new >> m_oldInlets >> m_oldOutlets >> m_oldCables;
155 std::vector<Dataflow::SavedPort> m_oldInlets, m_oldOutlets;
157 Dataflow::SerializedCables m_oldCables;
Definition DocumentContext.hpp:18