graph
parent
d9aeb32d86
commit
c49e42194d
|
@ -7,5 +7,6 @@
|
||||||
<mapping directory="$PROJECT_DIR$/lib/BLT-With-Graphics-Template/libraries/BLT/libraries/parallel-hashmap" vcs="Git" />
|
<mapping directory="$PROJECT_DIR$/lib/BLT-With-Graphics-Template/libraries/BLT/libraries/parallel-hashmap" vcs="Git" />
|
||||||
<mapping directory="$PROJECT_DIR$/lib/BLT-With-Graphics-Template/libraries/imgui" vcs="Git" />
|
<mapping directory="$PROJECT_DIR$/lib/BLT-With-Graphics-Template/libraries/imgui" vcs="Git" />
|
||||||
<mapping directory="$PROJECT_DIR$/lib/BLT-With-Graphics-Template/libraries/openal-soft" vcs="Git" />
|
<mapping directory="$PROJECT_DIR$/lib/BLT-With-Graphics-Template/libraries/openal-soft" vcs="Git" />
|
||||||
|
<mapping directory="$PROJECT_DIR$/lib/json" vcs="Git" />
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
|
@ -1,5 +1,5 @@
|
||||||
cmake_minimum_required(VERSION 3.25)
|
cmake_minimum_required(VERSION 3.25)
|
||||||
project(graphs VERSION 0.1.4)
|
project(graphs VERSION 0.1.5)
|
||||||
|
|
||||||
option(ENABLE_ADDRSAN "Enable the address sanitizer" OFF)
|
option(ENABLE_ADDRSAN "Enable the address sanitizer" OFF)
|
||||||
option(ENABLE_UBSAN "Enable the ub sanitizer" OFF)
|
option(ENABLE_UBSAN "Enable the ub sanitizer" OFF)
|
||||||
|
|
|
@ -28,6 +28,7 @@ struct node
|
||||||
{
|
{
|
||||||
float repulsiveness = 24.0f;
|
float repulsiveness = 24.0f;
|
||||||
std::string name = "unnamed";
|
std::string name = "unnamed";
|
||||||
|
std::string description;
|
||||||
std::string texture = conf::DEFAULT_IMAGE;
|
std::string texture = conf::DEFAULT_IMAGE;
|
||||||
|
|
||||||
blt::gfx::point2d_t point;
|
blt::gfx::point2d_t point;
|
||||||
|
@ -65,6 +66,7 @@ struct edge
|
||||||
float ideal_spring_length = conf::DEFAULT_SPRING_LENGTH;
|
float ideal_spring_length = conf::DEFAULT_SPRING_LENGTH;
|
||||||
float thickness = conf::DEFAULT_THICKNESS;
|
float thickness = conf::DEFAULT_THICKNESS;
|
||||||
blt::color4 color = conf::EDGE_COLOR;
|
blt::color4 color = conf::EDGE_COLOR;
|
||||||
|
std::string description;
|
||||||
|
|
||||||
edge(blt::u64 i1, blt::u64 i2): i1(i1), i2(i2)
|
edge(blt::u64 i1, blt::u64 i2): i1(i1), i2(i2)
|
||||||
{
|
{
|
||||||
|
|
|
@ -80,13 +80,22 @@ std::optional<loader_t> loader_t::load_for(engine_t& engine, const blt::gfx::win
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data.contains("connections"))
|
if (data.contains("edges"))
|
||||||
{
|
{
|
||||||
for (const auto& edge : data["edges"])
|
for (const auto& edge : data["edges"])
|
||||||
|
{
|
||||||
|
std::string index1;
|
||||||
|
std::string index2;
|
||||||
|
if (edge.is_array())
|
||||||
|
{
|
||||||
|
index1 = edge[0].get<std::string>();
|
||||||
|
index2 = edge[1].get<std::string>();
|
||||||
|
} else
|
||||||
{
|
{
|
||||||
auto& nodes = edge["nodes"];
|
auto& nodes = edge["nodes"];
|
||||||
auto index1 = nodes[0].get<std::string>();
|
index1 = nodes[0].get<std::string>();
|
||||||
auto index2 = nodes[1].get<std::string>();
|
index2 = nodes[1].get<std::string>();
|
||||||
|
}
|
||||||
auto ideal_length = load_with_default(edge, "length", conf::DEFAULT_SPRING_LENGTH);
|
auto ideal_length = load_with_default(edge, "length", conf::DEFAULT_SPRING_LENGTH);
|
||||||
auto thickness = load_with_default(edge, "thickness", conf::DEFAULT_THICKNESS);
|
auto thickness = load_with_default(edge, "thickness", conf::DEFAULT_THICKNESS);
|
||||||
|
|
||||||
|
@ -98,6 +107,32 @@ std::optional<loader_t> loader_t::load_for(engine_t& engine, const blt::gfx::win
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (data.contains("descriptions"))
|
||||||
|
{
|
||||||
|
for (const auto& desc : data["descriptions"])
|
||||||
|
{
|
||||||
|
if (auto node = graph.names_to_node.find(desc["name"].get<std::string>()); node != graph.names_to_node.end())
|
||||||
|
graph.nodes[node->second].description = desc["description"];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (data.contains("relationships"))
|
||||||
|
{
|
||||||
|
for (const auto& desc : data["relationships"])
|
||||||
|
{
|
||||||
|
auto nodes = desc["nodes"];
|
||||||
|
auto n1 = graph.names_to_node[nodes[0].get<std::string>()];
|
||||||
|
auto n2 = graph.names_to_node[nodes[2].get<std::string>()];
|
||||||
|
if (auto node = graph.edges.find({n1, n2}); node != graph.edges.end())
|
||||||
|
{
|
||||||
|
edge e = *node;
|
||||||
|
e.description = desc["description"];
|
||||||
|
graph.edges.erase({n1, n2});
|
||||||
|
graph.edges.insert(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return loader;
|
return loader;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue