Skip to content

Commit 6c43c20

Browse files
committed
adjusted text position
1 parent 885151a commit 6c43c20

File tree

1 file changed

+25
-12
lines changed

1 file changed

+25
-12
lines changed

vpr/src/draw/intra_logic_block.cpp

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@
3636

3737
/************************* Subroutines local to this file. *******************************/
3838

39-
static void draw_internal_load_coords(int type_descrip_index, t_pb_graph_node* pb_graph_node, float parent_width, float parent_height, float scale_factor);
39+
static void draw_internal_load_coords(int type_descrip_index, t_pb_graph_node* pb_graph_node, float parent_width, float parent_height);
4040
static int draw_internal_find_max_lvl(const t_pb_type& pb_type);
41-
static void draw_internal_calc_coords(int type_descrip_index, t_pb_graph_node* pb_graph_node, int num_block, int num_columns, int num_rows, float parent_width, float parent_height, float* blk_width, float* blk_height, float scale_factor);
41+
static void draw_internal_calc_coords(int type_descrip_index, t_pb_graph_node* pb_graph_node, int num_block, int num_columns, int num_rows, float parent_width, float parent_height, float* blk_width, float* blk_height);
4242
std::vector<AtomBlockId> collect_pb_atoms(const t_pb* pb);
4343
void collect_pb_atoms_recurr(const t_pb* pb, std::vector<AtomBlockId>& atoms);
4444
t_pb* highlight_sub_block_helper(const ClusterBlockId clb_index, t_pb* pb, const ezgl::point2d& local_pt, int max_depth);
@@ -130,7 +130,7 @@ void draw_internal_init_blk() {
130130

131131
clb_bbox = ezgl::rectangle(bot_left, top_right);
132132
draw_internal_load_coords(type_descriptor_index, pb_graph_head_node,
133-
clb_bbox.width(), clb_bbox.height(), std::max(clb_bbox.width(), clb_bbox.height()));
133+
clb_bbox.width(), clb_bbox.height());
134134

135135
/* Determine the max number of sub_block levels in the FPGA */
136136
draw_state->max_sub_blk_lvl = std::max(draw_internal_find_max_lvl(*type.pb_type),
@@ -218,7 +218,7 @@ static int draw_internal_find_max_lvl(const t_pb_type& pb_type) {
218218
* traverses through the pb_graph for a descriptor_type (given by type_descrip_index), and
219219
* calls helper function to compute bounding box values.
220220
*/
221-
static void draw_internal_load_coords(int type_descrip_index, t_pb_graph_node* pb_graph_node, float parent_width, float parent_height, float scale_factor) {
221+
static void draw_internal_load_coords(int type_descrip_index, t_pb_graph_node* pb_graph_node, float parent_width, float parent_height) {
222222
float blk_width = 0.;
223223
float blk_height = 0.;
224224

@@ -262,12 +262,12 @@ static void draw_internal_load_coords(int type_descrip_index, t_pb_graph_node* p
262262
&pb_graph_node->child_pb_graph_nodes[i][j][k],
263263
num_block, num_columns, num_rows,
264264
parent_width, parent_height,
265-
&blk_width, &blk_height, scale_factor);
265+
&blk_width, &blk_height);
266266

267267
/* Traverse to next level in the pb_graph */
268268
draw_internal_load_coords(type_descrip_index,
269269
&pb_graph_node->child_pb_graph_nodes[i][j][k],
270-
blk_width, blk_height, scale_factor);
270+
blk_width, blk_height);
271271
}
272272
}
273273
}
@@ -277,19 +277,27 @@ static void draw_internal_load_coords(int type_descrip_index, t_pb_graph_node* p
277277
* are relative to the left and bottom corner of the parent block.
278278
*/
279279
static void
280-
draw_internal_calc_coords(int type_descrip_index, t_pb_graph_node* pb_graph_node, int num_block, int num_columns, int num_rows, float parent_width, float parent_height, float* blk_width, float* blk_height, float scale_factor) {
280+
draw_internal_calc_coords(int type_descrip_index, t_pb_graph_node* pb_graph_node, int num_block, int num_columns, int num_rows, float parent_width, float parent_height, float* blk_width, float* blk_height) {
281281

282282
// get the bbox for this pb type
283283
ezgl::rectangle& pb_bbox = get_draw_coords_vars()->blk_info.at(type_descrip_index).get_pb_bbox_ref(*pb_graph_node);
284-
284+
285+
float tile_width = get_draw_coords_vars()->get_tile_width();
285286

286287
const float FRACTION_PARENT_PADDING = 0.005;
287288
const float FRACTION_CHILD_MARGIN = 0.003;
288289
const float FRACTION_TEXT_PADDING = 0.01;
289290
const int MIN_WIDTH_HEIGHT_RATIO = 2;
290291

291-
float abs_parent_padding = scale_factor * FRACTION_PARENT_PADDING;
292-
float abs_text_padding = scale_factor * FRACTION_TEXT_PADDING;
292+
float abs_parent_padding = tile_width * FRACTION_PARENT_PADDING;
293+
float abs_text_padding = tile_width * FRACTION_TEXT_PADDING;
294+
float abs_child_margin = tile_width * FRACTION_CHILD_MARGIN;
295+
296+
// add safety check to ensure that the dimensions will never be below zero
297+
if (parent_width <= 2* abs_parent_padding || parent_height <= 2 * abs_parent_padding - abs_text_padding) {
298+
abs_parent_padding = 0;
299+
abs_text_padding = 0;
300+
}
293301

294302
/* Draw all child-level blocks in just most of the space inside their parent block. */
295303
float parent_drawing_width = parent_width - 2* abs_parent_padding;
@@ -305,11 +313,16 @@ draw_internal_calc_coords(int type_descrip_index, t_pb_graph_node* pb_graph_node
305313
float child_width = parent_drawing_width / num_columns;
306314
float child_height = parent_drawing_height / num_rows;
307315

308-
float abs_child_margin = scale_factor * FRACTION_CHILD_MARGIN;
316+
// add safety check to ensure that the dimensions will never be below zero
317+
if(child_width <= abs_child_margin * 2 || child_height <= abs_child_margin * 2) {
318+
abs_child_margin = 0;
319+
}
320+
309321
/* The starting point to draw the physical block. */
310322
double left = child_width * x_index + abs_parent_padding + abs_child_margin;
311323
double bot = child_height * y_index + abs_parent_padding + abs_child_margin;
312324

325+
313326
child_width -= abs_child_margin * 2;
314327
child_height -= abs_child_margin * 2;
315328

@@ -404,7 +417,7 @@ static void draw_internal_pb(const ClusterBlockId clb_index, t_pb* pb, const ezg
404417
if (draw_state->draw_block_text) {
405418
g->draw_text(
406419
ezgl::point2d(abs_bbox.center_x(),
407-
abs_bbox.top() - (abs_bbox.height()) / 15.0),
420+
abs_bbox.top() - draw_coords->get_tile_height() * 0.01),
408421
pb_type->name,
409422
abs_bbox.width(),
410423
abs_bbox.height());

0 commit comments

Comments
 (0)