59 Scenario::Command::CommandFactoryName(),
LoadPreset,
"Load a preset")
64 , m_old{obj.savePreset()}
65 , m_new{std::move(newval)}
72 load(m_path.find(ctx), m_old);
77 load(m_path.find(ctx), m_new);
82 const auto before = portSignature(proc);
84 if(!portSignature(proc).keeps(before))
87 qWarning() <<
"Loading a preset changed the ports of" << proc.prettyName()
88 <<
": its presetChangesPorts() must say so";
89 SCORE_SOFT_ASSERT(
false);
95 stream << m_path << m_old << m_new;
99 stream >> m_path >> m_old >> m_new;
119 , m_old{model.savePreset()}
120 , m_new{std::move(newval)}
125 for(
auto& port : model.inlets())
126 m_oldInlets.emplace_back(
128 for(
auto& port : model.outlets())
129 m_oldOutlets.emplace_back(
136 auto& cmt = m_path.find(ctx);
139 Dataflow::removeCables(m_oldCables, ctx);
142 cmt.loadPreset(m_old);
146 SCORE_ASSERT(m_oldInlets.size() == cmt.inlets().size());
147 SCORE_ASSERT(m_oldOutlets.size() == cmt.outlets().size());
150 for(std::size_t i = 0; i < m_oldInlets.size(); i++)
152 cmt.inlets()[i]->loadData(m_oldInlets[i].data);
154 for(std::size_t i = 0; i < m_oldOutlets.size(); i++)
156 cmt.outlets()[i]->loadData(m_oldOutlets[i].data);
160 auto cables = Dataflow::restoreCablesWithoutTouchingPorts(m_oldCables, ctx);
161 Dataflow::reattachCablesToPorts(cables, ctx);
163 cmt.outletsChanged();
164 Dataflow::notifyAddedCables(cables, ctx);
169 Dataflow::removeCables(m_oldCables, ctx);
171 auto& cmt = m_path.find(ctx);
172 std::vector<int> inletIds, outletIds;
173 inletIds.reserve(cmt.inlets().size());
174 outletIds.reserve(cmt.outlets().size());
175 for(
auto* port : cmt.inlets())
176 inletIds.push_back(port->id().val());
177 for(
auto* port : cmt.outlets())
178 outletIds.push_back(port->id().val());
179 cmt.loadPreset(m_new);
183 auto cables = Dataflow::reloadPortsInNewProcess(
184 m_oldInlets, m_oldOutlets, m_oldCables, cmt, Process::PortLoadDataFlags{}, ctx,
185 inletIds, outletIds);
188 cmt.outletsChanged();
189 Dataflow::notifyAddedCables(cables, ctx);
194 stream << m_path << m_old << m_new << m_oldInlets << m_oldOutlets << m_oldCables;
198 stream >> m_path >> m_old >> m_new >> m_oldInlets >> m_oldOutlets >> m_oldCables;
205 std::vector<Dataflow::SavedPort> m_oldInlets, m_oldOutlets;
207 Dataflow::SerializedCables m_oldCables;
Definition DocumentContext.hpp:18