Commit 24332ae3 authored by Gauthier Quesnel's avatar Gauthier Quesnel
Browse files

gui: add model load and save positions

This patch enables to load and save irt file with position (a couple of float)
for each model (closes: #42).
parent 390a4deb
Pipeline #34683 failed with stage
in 1 minute and 7 seconds
......@@ -2800,11 +2800,14 @@ editor::show_editor() noexcept
5, "Load file from %s: ", (const char*)path.u8string().c_str());
if (auto is = std::ifstream(path); is.is_open()) {
reader r(is);
auto ret = r(sim, srcs, [this](model_id id) {
auto ret = r(sim, srcs, [&r, this](model_id id) {
parent(id, undefined<cluster_id>());
ImNodes::SetNodeEditorSpacePos(
top.emplace_back(id), ImNodes::EditorContextGetPanning());
const auto index = get_index(id);
const auto new_id = top.emplace_back(id);
const auto pos = r.get_position(index);
ImNodes::SetNodeEditorSpacePos(new_id, ImVec2(pos.x, pos.y));
});
if (is_success(ret))
......@@ -2831,7 +2834,14 @@ editor::show_editor() noexcept
(const char*)path.u8string().c_str());
if (auto os = std::ofstream(path); os.is_open()) {
writer w(os);
auto ret = w(sim, srcs);
auto ret = w(sim, srcs, [](model_id mdl_id, float& x, float& y) {
const auto index = irt::get_index(mdl_id);
const auto pos = ImNodes::GetNodeEditorSpacePos(static_cast<int>(index));
x = pos.x;
y = pos.y;
});
if (is_success(ret))
log_w.log(5, "success\n");
else
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment