Skip to content

Commit 5d64b8c

Browse files
committed
vpr: Fix drawing of lowest sub-block level
Previously this was incorrectly skipped. Also fixes range on GUI selector.
1 parent 5fc282c commit 5d64b8c

File tree

2 files changed

+26
-56
lines changed

2 files changed

+26
-56
lines changed

vpr/src/draw/buttons.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ void button_for_toggle_blk_internal() {
5959
t_draw_state* draw_state = get_draw_state_vars();
6060

6161
//spin box for toggle_blk_internal, set the range and increment step
62-
GtkWidget* toggle_blk_internal_widget = gtk_spin_button_new_with_range(0., (double)draw_state->max_sub_blk_lvl, 1.);
62+
GtkWidget* toggle_blk_internal_widget = gtk_spin_button_new_with_range(0., (double)(draw_state->max_sub_blk_lvl - 1), 1.);
6363
GtkWidget* toggle_blk_internal_label = gtk_label_new("Toggle Block Internal:");
6464
gtk_widget_set_name(toggle_blk_internal_widget, "toggle_blk_internal");
6565

vpr/src/draw/intra_logic_block.cpp

Lines changed: 25 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@
4040
static void draw_internal_load_coords(int type_descrip_index, t_pb_graph_node* pb_graph_node, float parent_width, float parent_height);
4141
static int draw_internal_find_max_lvl(const t_pb_type& pb_type);
4242
static void draw_internal_calc_coords(int type_descrip_index, t_pb_graph_node* pb_graph_node, int num_pb_types, int type_index, int num_pb, int pb_index, float parent_width, float parent_height, float* blk_width, float* blk_height);
43-
static bool is_top_lvl_block_highlighted(const ClusterBlockId blk_id);
4443
std::vector<AtomBlockId> collect_pb_atoms(const t_pb* pb);
4544
void collect_pb_atoms_recurr(const t_pb* pb, std::vector<AtomBlockId>& atoms);
4645
t_pb* highlight_sub_block_helper(const ClusterBlockId clb_index, t_pb* pb, const ezgl::point2d& local_pt, int max_depth);
@@ -141,6 +140,7 @@ void draw_internal_init_blk() {
141140
draw_state->max_sub_blk_lvl = std::max(draw_internal_find_max_lvl(*type.pb_type),
142141
draw_state->max_sub_blk_lvl);
143142
}
143+
//draw_state->max_sub_blk_lvl -= 1;
144144
}
145145

146146
# ifndef NO_GRAPHICS
@@ -338,47 +338,33 @@ static void draw_internal_pb(const ClusterBlockId clb_index, t_pb* pb, const ezg
338338
if (pb_type->depth > draw_state->show_blk_internal) {
339339
return;
340340
}
341-
/// first draw box ///
342341

343-
if (pb_type->depth == 0) {
344-
if (!is_top_lvl_block_highlighted(clb_index)) {
345-
// if this is a top level pb, and only if it isn't selected (ie. a funny colour),
346-
// overwrite it. (but stil draw the text)
342+
/// first draw box ///
347343

348-
g->set_color(ezgl::WHITE);
349-
g->fill_rectangle(abs_bbox);
350-
g->set_color(ezgl::BLACK);
351-
g->set_line_dash(ezgl::line_dash::none);
352-
g->draw_rectangle(abs_bbox);
344+
if (pb->name != nullptr) {
345+
// If block is used, draw it in colour with solid border.
346+
g->set_line_dash(ezgl::line_dash::none);
347+
348+
// determine default background color
349+
if (sel_sub_info.is_selected(pb->pb_graph_node, clb_index)) {
350+
g->set_color(SELECTED_COLOR);
351+
} else if (sel_sub_info.is_sink_of_selected(pb->pb_graph_node, clb_index)) {
352+
g->set_color(DRIVES_IT_COLOR);
353+
} else if (sel_sub_info.is_source_of_selected(pb->pb_graph_node, clb_index)) {
354+
g->set_color(DRIVEN_BY_IT_COLOR);
355+
} else {
356+
g->set_color(draw_state->block_color[clb_index]);
353357
}
354358
} else {
355-
if (pb->name != nullptr) {
356-
// If block is used, draw it in colour with solid border.
357-
g->set_line_dash(ezgl::line_dash::none);
358-
359-
// determine default background color
360-
if (sel_sub_info.is_selected(pb->pb_graph_node, clb_index)) {
361-
g->set_color(SELECTED_COLOR);
362-
} else if (sel_sub_info.is_sink_of_selected(pb->pb_graph_node, clb_index)) {
363-
g->set_color(DRIVES_IT_COLOR);
364-
} else if (sel_sub_info.is_source_of_selected(pb->pb_graph_node, clb_index)) {
365-
g->set_color(DRIVEN_BY_IT_COLOR);
366-
} else if (pb_type->depth != draw_state->show_blk_internal && pb->child_pbs != nullptr) {
367-
g->set_color(ezgl::WHITE); // draw anything else that will have a child as white
368-
} else {
369-
g->set_color(draw_state->block_color[clb_index]);
370-
}
371-
} else {
372-
// If block is not used, draw as empty block (ie. white
373-
// background with dashed border).
359+
// If block is not used, draw as empty block (ie. white
360+
// background with dashed border).
374361

375-
g->set_line_dash(ezgl::line_dash::asymmetric_5_3);
376-
g->set_color(ezgl::WHITE);
377-
}
378-
g->fill_rectangle(abs_bbox);
379-
g->set_color(ezgl::BLACK);
380-
g->draw_rectangle(abs_bbox);
362+
g->set_line_dash(ezgl::line_dash::asymmetric_5_3);
363+
g->set_color(ezgl::WHITE);
381364
}
365+
g->fill_rectangle(abs_bbox);
366+
g->set_color(ezgl::BLACK);
367+
g->draw_rectangle(abs_bbox);
382368

383369
/// then draw text ///
384370

@@ -393,7 +379,7 @@ static void draw_internal_pb(const ClusterBlockId clb_index, t_pb* pb, const ezg
393379
int tot_len = type_len + name_len;
394380
char* blk_tag = (char*)vtr::malloc((tot_len + 8) * sizeof(char));
395381

396-
sprintf(blk_tag, "%s(%s)", pb_type->name, pb->name);
382+
sprintf(blk_tag, "%s (%s)", pb_type->name, pb->name);
397383

398384
g->draw_text(
399385
abs_bbox.center(),
@@ -444,10 +430,10 @@ static void draw_internal_pb(const ClusterBlockId clb_index, t_pb* pb, const ezg
444430

445431
t_pb_type* pb_child_type = child_pb->pb_graph_node->pb_type;
446432

447-
// don't go farther if 0 modes
448-
if (pb_child_type == nullptr || pb_child_type->num_modes == 0) {
433+
if (pb_child_type == nullptr) {
449434
continue;
450435
}
436+
451437
// now recurse
452438
draw_internal_pb(clb_index, child_pb, abs_bbox, type, g);
453439
}
@@ -662,22 +648,6 @@ void draw_one_logical_connection(const AtomPinId src_pin, const AtomPinId sink_p
662648
}
663649
# endif /* NO_GRAPHICS */
664650

665-
/* This function checks whether a top-level clb has been highlighted. It does
666-
* so by checking whether the color in this block is default color.
667-
*/
668-
static bool is_top_lvl_block_highlighted(const ClusterBlockId blk_id) {
669-
t_draw_state* draw_state;
670-
671-
/* Call accessor function to retrieve global variables. */
672-
draw_state = get_draw_state_vars();
673-
674-
if (draw_state->block_color[blk_id] == get_block_type_color(get_physical_tile_type(blk_id))) {
675-
return false;
676-
}
677-
678-
return true;
679-
}
680-
681651
int highlight_sub_block(const ezgl::point2d& point_in_clb, ClusterBlockId clb_index, t_pb* pb) {
682652
t_draw_state* draw_state = get_draw_state_vars();
683653

0 commit comments

Comments
 (0)