@@ -70,9 +70,7 @@ const std::vector<ezgl::color> kelly_max_contrast_colors = {
7070 ezgl::color (43 , 61 , 38 ) // olive green
7171};
7272
73- /* Draws the blocks placed on the proper clbs. Occupied blocks are darker colours *
74- * while empty ones are lighter colours and have a dashed border. */
75- void drawplace (ezgl::renderer* g) {
73+ void draw_place (ezgl::renderer* g) {
7674 t_draw_state* draw_state = get_draw_state_vars ();
7775 t_draw_coords* draw_coords = get_draw_coords_vars ();
7876 const DeviceContext& device_ctx = g_vpr_ctx.device ();
@@ -84,96 +82,89 @@ void drawplace(ezgl::renderer* g) {
8482
8583 g->set_line_width (0 );
8684 for (int layer_num = 0 ; layer_num < total_num_layers; layer_num++) {
87- if (draw_state->draw_layer_display [layer_num].visible ) {
88- for (int i = 0 ; i < (int )grid.width (); i++) {
89- for (int j = 0 ; j < (int )grid.height (); j++) {
90- if (!grid.is_root_location ({i, j, layer_num})) {
91- continue ;
92- }
85+ if (!draw_state->draw_layer_display [layer_num].visible ) {
86+ continue ;
87+ }
88+ // The transparency level for the current layer being drawn (0-255)
89+ const int transparency_factor = draw_state->draw_layer_display [layer_num].alpha ;
9390
94- // Only the first block of a group should control drawing
95- const t_physical_tile_type_ptr type = grid.get_physical_type ({i, j, layer_num});
91+ for (int i = 0 ; i < (int )grid.width (); i++) {
92+ for (int j = 0 ; j < (int )grid.height (); j++) {
93+ if (!grid.is_root_location ({i, j, layer_num})) {
94+ continue ;
95+ }
9696
97- // The transparency level for the current layer being drawn (0-255)
98- // 0 - opaque, 255 - transparent
99- int transparency_factor = draw_state->draw_layer_display [layer_num].alpha ;
97+ // Only the first block of a group should control drawing
98+ const t_physical_tile_type_ptr type = grid.get_physical_type ({i, j, layer_num});
10099
101- int num_sub_tiles = type->capacity ;
102- /* Don't draw if tile capacity is zero. eg-> corners. */
103- if (num_sub_tiles == 0 ) {
104- continue ;
105- }
100+ int num_sub_tiles = type->capacity ;
101+ // Don't draw if tile capacity is zero. eg-> corners.
102+ if (num_sub_tiles == 0 ) {
103+ continue ;
104+ }
106105
107- for (int k = 0 ; k < num_sub_tiles; ++k) {
108- /* Look at the tile at start of large block */
109- ClusterBlockId bnum = grid_blocks.block_at_location ({i, j, k, layer_num});
110- /* Fill background for the clb. Do not fill if "show_blk_internal"
111- * is toggled.
112- */
113-
114- // Determine the block color and logical type
115- ezgl::color block_color;
116- t_logical_block_type_ptr logical_block_type = nullptr ;
117-
118- // flag whether the current location is highlighted with a special color or not
119- bool current_loc_is_highlighted = false ;
120-
121- if (placer_breakpoint_reached ()) {
122- t_pl_loc curr_loc;
123- curr_loc.x = i;
124- curr_loc.y = j;
125- curr_loc.layer = layer_num;
126- current_loc_is_highlighted = highlight_loc_with_specific_color (curr_loc,
127- block_color);
128- }
129- // No color specified at this location; use the block color.
130- if (!current_loc_is_highlighted) {
131- if (bnum) {
132- block_color = draw_state->block_color (bnum);
133- } else {
134- block_color = get_block_type_color (type);
135- block_color = lighten_color (block_color,
136- EMPTY_BLOCK_LIGHTEN_FACTOR);
137- }
106+ for (int k = 0 ; k < num_sub_tiles; ++k) {
107+ // Look at the tile at start of large block
108+ ClusterBlockId bnum = grid_blocks.block_at_location ({i, j, k, layer_num});
109+ // Fill background for the clb. Do not fill if "show_blk_internal" is toggled.
110+
111+ // Determine the block color and logical type
112+ ezgl::color block_color;
113+ t_logical_block_type_ptr logical_block_type = nullptr ;
114+ // flag whether the current location is highlighted with a special color or not
115+ bool current_loc_is_highlighted = false ;
116+
117+ if (placer_breakpoint_reached ()) {
118+ t_pl_loc curr_loc;
119+ curr_loc.x = i;
120+ curr_loc.y = j;
121+ curr_loc.layer = layer_num;
122+ current_loc_is_highlighted = highlight_loc_with_specific_color (curr_loc, block_color);
123+ }
124+ // No color specified at this location; use the block color.
125+ if (!current_loc_is_highlighted) {
126+ if (bnum) {
127+ block_color = draw_state->block_color (bnum);
128+ } else {
129+ block_color = get_block_type_color (type);
130+ block_color = lighten_color (block_color, EMPTY_BLOCK_LIGHTEN_FACTOR);
138131 }
132+ }
139133
140- logical_block_type = pick_logical_type (type);
141- g->set_color (block_color, transparency_factor);
134+ logical_block_type = pick_logical_type (type);
135+ g->set_color (block_color, transparency_factor);
142136
143- /* Get coords of current sub_tile */
144- ezgl::rectangle abs_clb_bbox = draw_coords->get_absolute_clb_bbox (layer_num,
145- i,
146- j,
147- k,
148- logical_block_type);
149- ezgl::point2d center = abs_clb_bbox.center ();
137+ // Get coords of current sub_tile
138+ ezgl::rectangle abs_clb_bbox = draw_coords->get_absolute_clb_bbox (layer_num,
139+ i,
140+ j,
141+ k,
142+ logical_block_type);
143+ ezgl::point2d center = abs_clb_bbox.center ();
150144
151- g->fill_rectangle (abs_clb_bbox);
145+ g->fill_rectangle (abs_clb_bbox);
152146
153- g->set_color (ezgl::BLACK, transparency_factor);
147+ g->set_color (ezgl::BLACK, transparency_factor);
154148
155- g->set_line_dash ((bnum == ClusterBlockId::INVALID ()) ? ezgl::line_dash::asymmetric_5_3 : ezgl::line_dash::none);
156- if (draw_state->draw_block_outlines ) {
157- g->draw_rectangle (abs_clb_bbox);
158- }
149+ g->set_line_dash ((bnum == ClusterBlockId::INVALID ()) ? ezgl::line_dash::asymmetric_5_3 : ezgl::line_dash::none);
150+ if (draw_state->draw_block_outlines ) {
151+ g->draw_rectangle (abs_clb_bbox);
152+ }
159153
160- if (draw_state->draw_block_text ) {
161- /* Draw text if the space has parts of the netlist */
162- if (bnum) {
163- std::string name = cluster_ctx.clb_nlist .block_name (bnum) + vtr::string_fmt (" (#%zu)" , size_t (bnum));
164-
165- g->draw_text (center, name.c_str (), abs_clb_bbox.width (),
166- abs_clb_bbox.height ());
167- }
168- /* Draw text for block type so that user knows what block */
169- if (grid.is_root_location ({i, j, layer_num})) {
170- std::string block_type_loc = type->name ;
171- block_type_loc += vtr::string_fmt (" (%d,%d)" , i, j);
172-
173- g->draw_text (center - ezgl::point2d (0 , abs_clb_bbox.height () / 4 ),
174- block_type_loc.c_str (), abs_clb_bbox.width (), abs_clb_bbox.height ());
175- }
154+ if (draw_state->draw_block_text ) {
155+ // Draw text if the space has parts of the netlist
156+ if (bnum) {
157+ std::string name = cluster_ctx.clb_nlist .block_name (bnum) + vtr::string_fmt (" (#%zu)" , size_t (bnum));
158+
159+ g->draw_text (center, name.c_str (), abs_clb_bbox.width (), abs_clb_bbox.height ());
176160 }
161+
162+ // Draw text for block type so that user knows what block
163+ std::string block_type_loc = type->name ;
164+ block_type_loc += vtr::string_fmt (" (%d,%d)" , i, j);
165+
166+ g->draw_text (center - ezgl::point2d (0 , abs_clb_bbox.height () / 4 ),
167+ block_type_loc.c_str (), abs_clb_bbox.width (), abs_clb_bbox.height ());
177168 }
178169 }
179170 }
0 commit comments