Skip to content

Commit

Permalink
Draw nodes above edges in graph view (#8738)
Browse files Browse the repository at this point in the history
### Related

* Closes #8737 

### What

This changes the drawing order of graph nodes and edges so that nodes
are always on top:

| Before | After |
|--------| ------|
| <img width="401" alt="image"
src="https://github.com/user-attachments/assets/fb65125d-e87b-4106-bb8a-02041394b528"
/> | <img width="401" alt="image"
src="https://github.com/user-attachments/assets/d4eaf199-369f-410b-b3e2-06f29966408a"
/> |
  • Loading branch information
grtlr authored Jan 21, 2025
1 parent 67f93c1 commit 81b5e8d
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions crates/viewer/re_view_graph/src/ui/draw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,13 @@ pub fn draw_graph(
// For now we compute the entity rectangles on the fly.
let mut current_rect = egui::Rect::NOTHING;

for (_, geometries) in layout.edges() {
for geometry in geometries {
let response = draw_edge(ui, geometry, geometry.target_arrow);
current_rect = current_rect.union(response.rect);
}
}

for node in graph.nodes() {
let center = layout.get_node(&node.id()).unwrap_or(Rect::ZERO).center();

Expand Down Expand Up @@ -391,13 +398,6 @@ pub fn draw_graph(
current_rect = current_rect.union(response.rect);
}

for (_, geometries) in layout.edges() {
for geometry in geometries {
let response = draw_edge(ui, geometry, geometry.target_arrow);
current_rect = current_rect.union(response.rect);
}
}

// We only show entity rects if there are multiple entities.
// For now, these entity rects are not part of the layout, but rather tracked on the fly.
if layout.num_entities() > 1 {
Expand Down

0 comments on commit 81b5e8d

Please sign in to comment.