Skip to content

Commit

Permalink
Save node layout for PTML
Browse files Browse the repository at this point in the history
  • Loading branch information
gwaldron committed Feb 7, 2025
1 parent 3a30c85 commit 01caa6c
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 5 deletions.
15 changes: 12 additions & 3 deletions src/osgEarthImGui/NodeGraphGUI
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,11 @@ namespace osgEarth
{
auto nodeGraph = NodeGraph::fromConfig(doc->getConfig());
_proceduralModelLayer->setNodeGraph(nodeGraph);
auto state = nodeGraph->userConfig.value("imgui_state");
if (!state.empty())
{
ImNodes::LoadCurrentEditorStateFromIniString(state.c_str(), state.length());
}
}
}
}
Expand All @@ -79,7 +84,9 @@ namespace osgEarth

if (!f.result().empty())
{
Config config = _proceduralModelLayer->getNodeGraph()->getConfig();
auto graph = _proceduralModelLayer->getNodeGraph();
graph->userConfig.set("imgui_state", ImNodes::SaveCurrentEditorStateToIniString());
Config config = graph->getConfig();
std::ofstream out(f.result());
osg::ref_ptr<XmlDocument> xml = new XmlDocument(config);
xml->store(out);
Expand Down Expand Up @@ -310,6 +317,7 @@ namespace osgEarth
// Go ahead and do an update if we are turning on auto update
if (_autoUpdate)
{
//_proceduralModelLayer->dirty();
_proceduralModelLayer->dirtyNodeGraph();
}
}
Expand All @@ -318,7 +326,8 @@ namespace osgEarth
ImGui::SameLine();
if (ImGui::Button("Update"))
{
_proceduralModelLayer->dirtyNodeGraph();
_proceduralModelLayer->dirty();
//_proceduralModelLayer->dirtyNodeGraph();
}
}

Expand Down Expand Up @@ -803,7 +812,7 @@ namespace osgEarth
}
}

ImNodes::EndNodeEditor();
ImNodes::EndNodeEditor();

int start_attr, end_attr;
if (ImNodes::IsLinkCreated(&start_attr, &end_attr))
Expand Down
7 changes: 7 additions & 0 deletions src/osgEarthProcedural/NodeGraph
Original file line number Diff line number Diff line change
Expand Up @@ -2564,6 +2564,9 @@ namespace osgEarth
}
}
conf.set("links", linksConf);

conf.set("user_config", userConfig);

return conf;
}

Expand Down Expand Up @@ -2612,12 +2615,16 @@ namespace osgEarth
}
}

graph->userConfig = nodeGraphConf.child("user_config");

return graph;
}

std::vector< std::shared_ptr< NodeGraphOperation > > operations;

std::mutex _mutex;

Config userConfig;
};


Expand Down
3 changes: 1 addition & 2 deletions src/osgEarthProcedural/ProceduralTiledModelLayer
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ namespace osgEarth { namespace Procedural
{
META_LayerOptions(osgEarth, Options, TiledModelLayer::Options);
OE_OPTION(ProfileOptions, profile);
OE_OPTION(URI, url);
Config getConfig() const override;
void fromConfig(const Config& conf);
};
Expand Down Expand Up @@ -93,7 +94,6 @@ namespace osgEarth { namespace Procedural
}
}


void registerNode(NodeGraphNode* node)
{
std::lock_guard< std::mutex> lk(_nodesMutex);
Expand Down Expand Up @@ -125,7 +125,6 @@ namespace osgEarth { namespace Procedural

private:
osg::ref_ptr<const Profile> _profile;

std::shared_ptr< NodeGraph > _nodeGraph;
};
} }
4 changes: 4 additions & 0 deletions src/osgEarthProcedural/ProceduralTiledModelLayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ void ProceduralTiledModelLayer::Options::fromConfig(const Config& conf)
conf.get("min_level", minLevel());
conf.get("max_level", maxLevel());
conf.get("profile", profile());
conf.get("url", url());
}

Config
Expand All @@ -45,6 +46,7 @@ ProceduralTiledModelLayer::Options::getConfig() const
conf.set("min_level", minLevel());
conf.set("max_level", maxLevel());
conf.set("profile", profile());
conf.set("url", url());
return conf;
}

Expand Down Expand Up @@ -87,6 +89,8 @@ ProceduralTiledModelLayer::openImplementation()
if (parent.isError())
return parent;



_profile = Profile::create(*options().profile());

return Status::NoError;
Expand Down

0 comments on commit 01caa6c

Please sign in to comment.