45
45
# include < X11/keysym.h>
46
46
# endif
47
47
48
- static void draw_internal_pb (const ClusterBlockId clb_index, t_pb* current_pb, const t_pb* pb_to_draw, const ezgl::rectangle& parent_bbox, const t_logical_block_type_ptr type, ezgl::color color, ezgl::renderer* g);
48
+ static void draw_internal_pb (const ClusterBlockId clb_index, t_pb* current_pb,
49
+ const t_pb* pb_to_draw, const ezgl::rectangle& parent_bbox,
50
+ const t_logical_block_type_ptr type, ezgl::color color,
51
+ ezgl::renderer* g);
49
52
50
53
const std::vector<ezgl::color> kelly_max_contrast_colors_no_black = {
51
54
// ezgl::color(242, 243, 244), //white: skip white since it doesn't contrast well with VPR's light background
@@ -83,63 +86,65 @@ static void highlight_partition(ezgl::renderer* g, int partitionID, int alpha) {
83
86
auto & floorplanning_ctx = g_vpr_ctx.floorplanning ();
84
87
auto constraints = floorplanning_ctx.constraints ;
85
88
t_draw_coords* draw_coords = get_draw_coords_vars ();
89
+ t_draw_state* draw_state = get_draw_state_vars ();
86
90
87
91
const auto & partition = constraints.get_partition ((PartitionId)partitionID);
88
92
const auto & partition_region = partition.get_part_region ();
89
93
const auto & regions = partition_region.get_regions ();
90
94
91
95
bool name_drawn = false ;
92
96
ezgl::color partition_color = kelly_max_contrast_colors_no_black[partitionID % (kelly_max_contrast_colors_no_black.size ())];
93
- g->set_color (partition_color, alpha);
94
97
95
- // The units of space in the constraints xml file will be refered to as "tile units"
96
- // The units of space that'll be used by ezgl to draw will be refered to as "on screen units"
98
+ // The units of space in the constraints xml file will be referred to as "tile units"
99
+ // The units of space that'll be used by ezgl to draw will be referred to as "on screen units"
97
100
98
101
// Find the coordinates of the region by retrieving from the xml file
99
102
// which tiles are at the corner of the region, then translate that to on
100
103
// the on screen units for ezgl to use.
101
104
102
105
for (int region = 0 ; (size_t )region < regions.size (); region++) {
103
106
const vtr::Rect <int >& reg_coord = regions[region].get_rect ();
104
- const auto [layer_begin, layer_end ] = regions[region].get_layer_range ();
107
+ const auto [layer_low, layer_high ] = regions[region].get_layer_range ();
105
108
106
- // TODO: 0 should be replaced with the actual z value of the region when graph is 3D
107
- ezgl::rectangle top_right = draw_coords->get_absolute_clb_bbox (layer_begin,
108
- reg_coord.xmax (),
109
- reg_coord.ymax (),
110
- 0 );
111
- ezgl::rectangle bottom_left = draw_coords->get_absolute_clb_bbox (layer_end,
112
- reg_coord.xmin (),
113
- reg_coord.ymin (),
114
- 0 );
109
+ for (int layer = layer_low; layer <= layer_high; layer++) {
110
+ if (!draw_state->draw_layer_display [layer].visible ) {
111
+ continue ;
112
+ }
115
113
116
- ezgl::rectangle on_screen_rect (bottom_left.bottom_left (), top_right.top_right ());
114
+ int alpha_layer_part = alpha * draw_state->draw_layer_display [layer].alpha / 255 ;
115
+ g->set_color (partition_color, alpha_layer_part);
117
116
118
- if (!name_drawn) {
119
- g->set_font_size (10 );
120
- const std::string& partition_name = partition.get_name ();
117
+ ezgl::rectangle top_right = draw_coords->get_absolute_clb_bbox (layer, reg_coord.xmax (), reg_coord.ymax (), 0 );
118
+ ezgl::rectangle bottom_left = draw_coords->get_absolute_clb_bbox (layer, reg_coord.xmin (), reg_coord.ymin (), 0 );
121
119
122
- g-> set_color (partition_color, 230 );
120
+ ezgl::rectangle on_screen_rect (bottom_left. bottom_left (), top_right. top_right () );
123
121
124
- g->draw_text (
125
- on_screen_rect.center (),
126
- partition_name,
127
- on_screen_rect.width () - 10 ,
128
- on_screen_rect.height () - 10 );
122
+ if (!name_drawn) {
123
+ g->set_font_size (10 );
124
+ const std::string& partition_name = partition.get_name ();
129
125
130
- name_drawn = true ;
126
+ g-> set_color (partition_color, 230 ) ;
131
127
132
- g->set_color (partition_color, alpha);
133
- }
128
+ g->draw_text (
129
+ on_screen_rect.center (),
130
+ partition_name,
131
+ on_screen_rect.width () - 10 ,
132
+ on_screen_rect.height () - 10 );
134
133
135
- g->fill_rectangle (on_screen_rect);
134
+ name_drawn = true ;
135
+
136
+ g->set_color (partition_color, alpha);
137
+ }
138
+
139
+ g->fill_rectangle (on_screen_rect);
140
+ }
136
141
}
137
142
}
138
143
139
144
// Iterates through all partitions and draws each region of each partition
140
145
void highlight_all_regions (ezgl::renderer* g) {
141
146
auto & floorplanning_ctx = g_vpr_ctx.floorplanning ();
142
- auto constraints = floorplanning_ctx.constraints ;
147
+ const auto & constraints = floorplanning_ctx.constraints ;
143
148
auto num_partitions = constraints.get_num_partitions ();
144
149
145
150
// keeps track of what alpha level each partition is
@@ -155,18 +160,18 @@ void highlight_all_regions(ezgl::renderer* g) {
155
160
}
156
161
}
157
162
158
- // Draws atoms that're constrained to a partition in the colour of their respective partition.
163
+ // Draws atoms that are constrained to a partition in the colour of their respective partition.
159
164
void draw_constrained_atoms (ezgl::renderer* g) {
160
165
auto & floorplanning_ctx = g_vpr_ctx.floorplanning ();
161
- auto constraints = floorplanning_ctx.constraints ;
162
- auto num_partitions = constraints.get_num_partitions ();
166
+ const auto & constraints = floorplanning_ctx.constraints ;
167
+ int num_partitions = constraints.get_num_partitions ();
163
168
auto & atom_ctx = g_vpr_ctx.atom ();
164
169
auto & cluster_ctx = g_vpr_ctx.clustering ();
165
170
166
171
for (int partitionID = 0 ; partitionID < num_partitions; partitionID++) {
167
172
auto atoms = constraints.get_part_atoms ((PartitionId)partitionID);
168
173
169
- for (const auto atom_id : atoms) {
174
+ for (const AtomBlockId atom_id : atoms) {
170
175
if (atom_ctx.lookup .atom_pb (atom_id) != nullptr ) {
171
176
const t_pb* pb = atom_ctx.lookup .atom_pb (atom_id);
172
177
auto color = kelly_max_contrast_colors_no_black[partitionID % (kelly_max_contrast_colors_no_black.size ())];
@@ -180,7 +185,12 @@ void draw_constrained_atoms(ezgl::renderer* g) {
180
185
}
181
186
182
187
// Recursive function to find where the constrained atom is and draws it
183
- static void draw_internal_pb (const ClusterBlockId clb_index, t_pb* current_pb, const t_pb* pb_to_draw, const ezgl::rectangle& parent_bbox, const t_logical_block_type_ptr type, ezgl::color color, ezgl::renderer* g) {
188
+ static void draw_internal_pb (const ClusterBlockId clb_index,
189
+ t_pb* current_pb,
190
+ const t_pb* pb_to_draw,
191
+ const ezgl::rectangle& parent_bbox,
192
+ const t_logical_block_type_ptr type,
193
+ ezgl::color color, ezgl::renderer* g) {
184
194
t_draw_coords* draw_coords = get_draw_coords_vars ();
185
195
t_draw_state* draw_state = get_draw_state_vars ();
186
196
@@ -300,8 +310,8 @@ void highlight_selected_partition(GtkWidget* widget) {
300
310
static GtkTreeModel* create_and_fill_model () {
301
311
auto & atom_ctx = g_vpr_ctx.atom ();
302
312
auto & floorplanning_ctx = g_vpr_ctx.floorplanning ();
303
- auto constraints = floorplanning_ctx.constraints ;
304
- auto num_partitions = constraints.get_num_partitions ();
313
+ const auto & constraints = floorplanning_ctx.constraints ;
314
+ int num_partitions = constraints.get_num_partitions ();
305
315
306
316
GtkTreeStore* store = gtk_tree_store_new (NUM_COLS, G_TYPE_STRING);
307
317
@@ -318,7 +328,7 @@ static GtkTreeModel* create_and_fill_model() {
318
328
COL_NAME, partition_name.c_str (),
319
329
-1 );
320
330
321
- for (auto const_atom : atoms) {
331
+ for (AtomBlockId const_atom : atoms) {
322
332
std::string atom_name = (atom_ctx.lookup .atom_pb (const_atom))->name ;
323
333
gtk_tree_store_append (store, &child_iter, &iter);
324
334
gtk_tree_store_set (store, &child_iter,
0 commit comments