From 946ff294235265a75fa17c189b8c33d33e4c6f4c Mon Sep 17 00:00:00 2001 From: Soheil Shahrouz Date: Wed, 8 Oct 2025 12:02:54 -0400 Subject: [PATCH] draw nodes on top of edges --- vpr/src/draw/draw_mux.cpp | 5 ++--- vpr/src/draw/draw_rr.cpp | 21 +++++++++++++++------ 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/vpr/src/draw/draw_mux.cpp b/vpr/src/draw/draw_mux.cpp index 806391f42bf..517c39c921a 100644 --- a/vpr/src/draw/draw_mux.cpp +++ b/vpr/src/draw/draw_mux.cpp @@ -78,11 +78,10 @@ ezgl::rectangle draw_mux(ezgl::point2d origin, e_side orientation, float height, */ void draw_mux_with_size(ezgl::point2d origin, e_side orientation, float height, int size, int transparency_factor, ezgl::renderer* g) { g->set_color(ezgl::YELLOW, transparency_factor); - auto bounds = draw_mux(origin, orientation, height, g); + ezgl::rectangle bounds = draw_mux(origin, orientation, height, g); g->set_color(ezgl::BLACK, transparency_factor); - g->draw_text(bounds.center(), std::to_string(size), bounds.width(), - bounds.height()); + g->draw_text(bounds.center(), std::to_string(size), bounds.width(), bounds.height()); } #endif diff --git a/vpr/src/draw/draw_rr.cpp b/vpr/src/draw/draw_rr.cpp index a955543a340..1d5e53bbeee 100644 --- a/vpr/src/draw/draw_rr.cpp +++ b/vpr/src/draw/draw_rr.cpp @@ -51,23 +51,32 @@ void draw_rr(ezgl::renderer* g) { g->set_line_dash(ezgl::line_dash::none); + // Node colors by types + // colors for Source, Sink, IPIN, OPIN, CHANX, CHANY, MUX, CHANZ + constexpr vtr::array node_colors{DEFAULT_RR_NODE_COLOR, + DEFAULT_RR_NODE_COLOR, + ezgl::PURPLE, + ezgl::PINK, + DEFAULT_RR_NODE_COLOR, + DEFAULT_RR_NODE_COLOR, + DEFAULT_RR_NODE_COLOR, + DEFAULT_RR_NODE_COLOR}; + + // Draw edges first, then nodes, so that nodes (and their muxes) are rendered on top of edges. for (const RRNodeId inode : device_ctx.rr_graph.nodes()) { + draw_rr_edges(inode, g); + } + for (const RRNodeId inode : device_ctx.rr_graph.nodes()) { e_rr_type node_type = rr_graph.node_type(inode); bool inter_cluster_node = is_inter_cluster_node(rr_graph, inode); bool node_highlighted = draw_state->draw_rr_node[inode].node_highlighted; - // Node colors by types - // colors for Source, Sink, IPIN, OPIN, CHANX, CHANY, MUX, CHANZ - constexpr vtr::array node_colors{DEFAULT_RR_NODE_COLOR, DEFAULT_RR_NODE_COLOR, ezgl::PURPLE, ezgl::PINK, DEFAULT_RR_NODE_COLOR, DEFAULT_RR_NODE_COLOR, DEFAULT_RR_NODE_COLOR, DEFAULT_RR_NODE_COLOR}; - // Apply color to the node if it is not highlighted if (!node_highlighted) { draw_state->draw_rr_node[inode].color = node_colors.at(node_type); } - draw_rr_edges(inode, g); - if (!node_highlighted) { // Draw channel nodes if enabled if ((node_type == e_rr_type::CHANX || node_type == e_rr_type::CHANY) && !draw_state->draw_channel_nodes) {