Skip to content

Commit

Permalink
Dynamic configuration of graph layout forces through blueprints (#8299)
Browse files Browse the repository at this point in the history
### Related

* Closes #8278

<!--
Include links to any related issues/PRs in a bulleted list, for example:
* Closes #1234
* Part of #1337
-->

### What

Title.

<!--
Make sure the PR title and labels are set to maximize their usefulness
for the CHANGELOG,
and our `git log`.

If you have noticed any breaking changes, include them in the migration
guide.

We track various metrics at <https://build.rerun.io>.

For maintainers:
* To run all checks from `main`, comment on the PR with `@rerun-bot
full-check`.
* To deploy documentation changes immediately after merging this PR, add
the `deploy docs` label.
-->

---------

Co-authored-by: Antoine Beyeler <antoine@rerun.io>
  • Loading branch information
grtlr and abey79 authored Dec 10, 2024
1 parent 6fdb8c7 commit 671b510
Show file tree
Hide file tree
Showing 80 changed files with 4,510 additions and 92 deletions.
6 changes: 3 additions & 3 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2455,9 +2455,9 @@ checksum = "0ce7134b9999ecaf8bcd65542e436736ef32ddca1b3e06094cb6ec5755203b80"

[[package]]
name = "fjadra"
version = "0.1.0"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ccc0416b27f53bba6c9bd564260f27d4784c5f430926eb16a519356be7d66bbc"
checksum = "d8d17b174735bd1464bc491c49570fc824466e9140617c371de9a6d86ebd33ec"

[[package]]
name = "flatbuffers"
Expand Down Expand Up @@ -5999,7 +5999,6 @@ dependencies = [
"bytemuck",
"clean-path",
"criterion",
"crossbeam",
"document-features",
"fixed",
"half",
Expand Down Expand Up @@ -6393,6 +6392,7 @@ dependencies = [
"re_data_ui",
"re_entity_db",
"re_format",
"re_log",
"re_log_types",
"re_query",
"re_renderer",
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ enumset = "1.0.12"
env_logger = { version = "0.10", default-features = false }
ffmpeg-sidecar = { version = "2.0.2", default-features = false }
fixed = { version = "1.28", default-features = false }
fjadra = "0.1"
fjadra = "0.2"
flatbuffers = "23.0"
futures-channel = "0.3"
futures-util = { version = "0.3", default-features = false }
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
namespace rerun.blueprint.archetypes;

/// Tries to move the center of mass of the graph to the origin.
struct ForceCenter (
"attr.rerun.scope": "blueprint"
) {
/// Whether the force is enabled.
enabled: rerun.blueprint.components.Enabled ("attr.rerun.component_optional", nullable, order: 100);

/// The strength of the force.
strength: rerun.blueprint.components.ForceStrength ("attr.rerun.component_optional", nullable, order: 200);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
namespace rerun.blueprint.archetypes;

/// Resolves collisions between the bounding spheres, according to the radius of the nodes.
struct ForceCollisionRadius (
"attr.rerun.scope": "blueprint"
) {
/// Whether the force is enabled.
enabled: rerun.blueprint.components.Enabled ("attr.rerun.component_optional", nullable, order: 100);

/// The strength of the force.
strength: rerun.blueprint.components.ForceStrength ("attr.rerun.component_optional", nullable, order: 200);

/// Specifies how often this force should be applied per iteration.
///
/// Increasing this parameter can lead to better results at the cost of longer computation time.
iterations: rerun.blueprint.components.ForceIterations ("attr.rerun.component_optional", nullable, order: 300);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
namespace rerun.blueprint.archetypes;

/// Aims to achieve a target distance between two nodes that are connected by an edge.
struct ForceLink (
"attr.rerun.scope": "blueprint"
) {
/// Whether the force is enabled.
enabled: rerun.blueprint.components.Enabled ("attr.rerun.component_optional", nullable, order: 100);

/// The target distance between two nodes.
distance: rerun.blueprint.components.ForceDistance ("attr.rerun.component_optional", nullable, order: 200);

/// Specifies how often this force should be applied per iteration.
///
/// Increasing this parameter can lead to better results at the cost of longer computation time.
iterations: rerun.blueprint.components.ForceIterations ("attr.rerun.component_optional", nullable, order: 300);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
namespace rerun.blueprint.archetypes;

/// A force between each pair of nodes that ressembles an electrical charge.
///
/// If `strength` is smaller than 0, it pushes nodes apart, if it is larger than 0 it pulls them together.
struct ForceManyBody (
"attr.rerun.scope": "blueprint"
) {
/// Whether the force is enabled.
enabled: rerun.blueprint.components.Enabled ("attr.rerun.component_optional", nullable, order: 100);

/// The strength of the force.
///
/// If `strength` is smaller than 0, it pushes nodes apart, if it is larger than 0 it pulls them together.
strength: rerun.blueprint.components.ForceStrength ("attr.rerun.component_optional", nullable, order: 200);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
namespace rerun.blueprint.archetypes;

/// Similar to gravity, this force pulls nodes towards a specific position.
struct ForcePosition (
"attr.rerun.scope": "blueprint"
) {
/// Whether the force is enabled.
enabled: rerun.blueprint.components.Enabled ("attr.rerun.component_optional", nullable, order: 100);

/// The strength of the force.
strength: rerun.blueprint.components.ForceStrength ("attr.rerun.component_optional", nullable, order: 200);

/// The position where the nodes should be pulled towards.
position: rerun.components.Position2D ("attr.rerun.component_optional", nullable, order: 300);
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
namespace rerun.blueprint.components;

// ---

/// Whether a procedure is enabled.
struct Enabled (
"attr.arrow.transparent",
"attr.rerun.scope": "blueprint",
"attr.python.aliases": "bool",
"attr.rust.derive": "Copy, Default, PartialEq, Eq, PartialOrd, Ord",
"attr.rust.repr": "transparent",
"attr.rust.tuple_struct"
) {
visible: rerun.datatypes.Bool (order: 100);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@

namespace rerun.blueprint.components;

/// The target distance between two nodes.
///
/// This is helpful to scale the layout, for example if long labels are involved.
struct ForceDistance (
"attr.arrow.transparent",
"attr.rust.derive": "Default, Copy, PartialEq",
"attr.rust.repr": "transparent",
"attr.rerun.scope": "blueprint"
) {
distance: rerun.datatypes.Float64 (order: 100);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@

namespace rerun.blueprint.components;

/// Specifies how often this force should be applied per iteration.
///
/// Increasing this parameter can lead to better results at the cost of longer computation time.
struct ForceIterations (
"attr.arrow.transparent",
"attr.rust.derive": "Default, Copy, PartialEq, Eq",
"attr.rust.repr": "transparent",
"attr.rerun.scope": "blueprint"
) {
distance: rerun.datatypes.UInt64 (order: 100);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@

namespace rerun.blueprint.components;

/// The strength of a given force.
///
/// Allows to assign different weights to the individual forces, prioritizing one over the other.
struct ForceStrength (
"attr.arrow.transparent",
"attr.rust.derive": "Default, Copy, PartialEq",
"attr.rust.repr": "transparent",
"attr.rerun.scope": "blueprint"
) {
distance: rerun.datatypes.Float64 (order: 100);
}
15 changes: 15 additions & 0 deletions crates/store/re_types/definitions/rerun/blueprint/views/graph.fbs
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,19 @@ table GraphView (
///
/// Somethings outside of these bounds may also be visible due to letterboxing.
visual_bounds: rerun.blueprint.archetypes.VisualBounds2D (order: 1000);

/// Allows to control the interaction between two nodes connected by an edge.
force_link: rerun.blueprint.archetypes.ForceLink (order: 2000);

/// A force between each pair of nodes that ressembles an electrical charge.
force_many_body: rerun.blueprint.archetypes.ForceManyBody (order: 3000);

/// Similar to gravity, this force pulls nodes towards a specific position.
force_position: rerun.blueprint.archetypes.ForcePosition (order: 4000);

/// Resolves collisions between the bounding spheres, according to the radius of the nodes.
force_collision_radius: rerun.blueprint.archetypes.ForceCollisionRadius (order: 5000);

/// Tries to move the center of mass of the graph to the origin.
force_center: rerun.blueprint.archetypes.ForceCenter (order: 6000);
}
5 changes: 5 additions & 0 deletions crates/store/re_types/src/blueprint/archetypes/.gitattributes

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 671b510

Please sign in to comment.