1818#include " draw.h"
1919
2020#include " draw_interposer.h"
21+ #include " draw_types.h"
2122#include " timing_info.h"
2223#include " physical_types.h"
2324
2425#include " move_utils.h"
26+ #include " vpr_types.h"
2527
2628#ifndef NO_GRAPHICS
2729
@@ -176,65 +178,71 @@ static void draw_main_canvas(ezgl::renderer* g) {
176178 t_draw_state* draw_state = get_draw_state_vars ();
177179
178180 g->set_font_size (14 );
181+ if (draw_state->pic_on_screen != e_pic_type::ANALYTICAL_PLACEMENT) {
182+ draw_block_pin_util ();
183+ drawplace (g);
184+ draw_internal_draw_subblk (g);
179185
180- draw_interposer_cuts (g);
186+ draw_interposer_cuts (g);
181187
182- draw_block_pin_util ();
183- drawplace (g);
184- draw_internal_draw_subblk (g);
188+ draw_block_pin_util ();
189+ drawplace (g);
190+ draw_internal_draw_subblk (g);
185191
186- if (draw_state->pic_on_screen == e_pic_type::ROUTING) { // ROUTING on screen
192+ if (draw_state->pic_on_screen == e_pic_type::ROUTING) { // ROUTING on screen
187193
188- draw_rr (g);
194+ draw_rr (g);
189195
190- if (draw_state->show_nets && draw_state->draw_nets == DRAW_ROUTED_NETS) {
191- draw_route (ALL_NETS, g);
196+ if (draw_state->show_nets && draw_state->draw_nets == DRAW_ROUTED_NETS) {
197+ draw_route (ALL_NETS, g);
192198
193- if (draw_state->highlight_fan_in_fan_out ) {
194- draw_route (HIGHLIGHTED, g);
199+ if (draw_state->highlight_fan_in_fan_out ) {
200+ draw_route (HIGHLIGHTED, g);
201+ }
195202 }
196- }
197203
198- draw_congestion (g);
204+ draw_congestion (g);
199205
200- draw_routing_costs (g);
206+ draw_routing_costs (g);
201207
202- draw_router_expansion_costs (g);
208+ draw_router_expansion_costs (g);
203209
204- draw_routing_util (g);
210+ draw_routing_util (g);
205211
206- draw_routing_bb (g);
207- }
212+ draw_routing_bb (g);
213+ }
208214
209- draw_placement_macros (g);
215+ draw_placement_macros (g);
210216
211217#ifndef NO_SERVER
212- if (g_vpr_ctx.server ().gate_io .is_running ()) {
213- const ServerContext& server_ctx = g_vpr_ctx.server (); // shortcut
214- draw_crit_path_elements (server_ctx.crit_paths , server_ctx.crit_path_element_indexes , server_ctx.draw_crit_path_contour , g);
215- } else {
216- draw_crit_path (g);
217- }
218+ if (g_vpr_ctx.server ().gate_io .is_running ()) {
219+ const ServerContext& server_ctx = g_vpr_ctx.server (); // shortcut
220+ draw_crit_path_elements (server_ctx.crit_paths , server_ctx.crit_path_element_indexes , server_ctx.draw_crit_path_contour , g);
221+ } else {
222+ draw_crit_path (g);
223+ }
218224#else
219- draw_crit_path (g);
225+ draw_crit_path (g);
220226#endif /* NO_SERVER */
221227
222- draw_logical_connections (g);
228+ draw_logical_connections (g);
223229
224- draw_selected_pb_flylines (g);
230+ draw_selected_pb_flylines (g);
225231
226- draw_noc (g);
232+ draw_noc (g);
227233
228- if (draw_state->draw_partitions ) {
229- highlight_all_regions (g);
230- draw_constrained_atoms (g);
231- }
234+ if (draw_state->draw_partitions ) {
235+ highlight_all_regions (g);
236+ draw_constrained_atoms (g);
237+ }
232238
233- if (draw_state->color_map ) {
234- draw_color_map_legend (*draw_state->color_map , g);
235- draw_state->color_map .reset (); // Free color map in preparation for next redraw
239+ if (draw_state->color_map ) {
240+ draw_color_map_legend (*draw_state->color_map , g);
241+ draw_state->color_map .reset (); // Free color map in preparation for next redraw
242+ }
243+ } else {
244+ draw_analytical_place (g);
236245 }
237-
238246 if (draw_state->auto_proceed ) {
239247 // Automatically exit the event loop, so user's don't need to manually click proceed
240248
@@ -290,7 +298,7 @@ void update_screen(ScreenUpdatePriority priority,
290298 * value controls whether or not the Proceed button must be clicked to *
291299 * continue. Saves the pic_on_screen_val to allow pan and zoom redraws. */
292300 t_draw_state* draw_state = get_draw_state_vars ();
293-
301+
294302 strcpy (draw_state->default_message , msg);
295303
296304 if (!draw_state->show_graphics )
@@ -306,9 +314,23 @@ void update_screen(ScreenUpdatePriority priority,
306314
307315 state_change = true ;
308316
317+ if (draw_state->show_graphics ) {
318+ if (pic_on_screen_val == e_pic_type::ANALYTICAL_PLACEMENT) {
319+ set_initial_world_ap ();
320+ } else {
321+ set_initial_world ();
322+ }
323+ }
324+
309325 if (draw_state->pic_on_screen == e_pic_type::NO_PICTURE) {
310326 // Only add the canvas the first time we open graphics
311327 application.add_canvas (" MainCanvas" , draw_main_canvas, initial_world);
328+ } else {
329+ // TODO: will this ever be null?
330+ auto canvas = application.get_canvas (application.get_main_canvas_id ());
331+ if (canvas != nullptr ) {
332+ canvas->get_camera ().set_world (initial_world);
333+ }
312334 }
313335
314336 draw_state->setup_timing_info = setup_timing_info;
@@ -492,7 +514,7 @@ void init_draw_coords(float clb_width, const BlkLocRegistry& blk_loc_registry) {
492514 constexpr float VISIBLE_MARGIN = 0.01 ;
493515
494516 float draw_width = draw_coords->tile_x [grid.width () - 1 ] + draw_coords->get_tile_width ();
495- float draw_height = draw_coords->tile_y [grid.height () - 1 ] + draw_coords->get_tile_width ();
517+ float draw_height = draw_coords->tile_y [grid.height () - 1 ] + draw_coords->get_tile_height ();
496518
497519 initial_world = ezgl::rectangle (
498520 {-VISIBLE_MARGIN * draw_width, -VISIBLE_MARGIN * draw_height},
@@ -506,6 +528,36 @@ void init_draw_coords(float clb_width, const BlkLocRegistry& blk_loc_registry) {
506528
507529#ifndef NO_GRAPHICS
508530
531+ void set_initial_world () {
532+ constexpr float VISIBLE_MARGIN = 0.01 ;
533+ t_draw_coords* draw_coords = get_draw_coords_vars ();
534+ const DeviceContext& device_ctx = g_vpr_ctx.device ();
535+
536+ float draw_width = draw_coords->tile_x [device_ctx.grid .width () - 1 ] + draw_coords->get_tile_width ();
537+ float draw_height = draw_coords->tile_y [device_ctx.grid .height () - 1 ] + draw_coords->get_tile_width ();
538+
539+ initial_world = ezgl::rectangle (
540+ {-VISIBLE_MARGIN * draw_width, -VISIBLE_MARGIN * draw_height},
541+ {(1 . + VISIBLE_MARGIN) * draw_width, (1 . + VISIBLE_MARGIN)
542+ * draw_height});
543+ }
544+
545+ void set_initial_world_ap () {
546+ constexpr float VISIBLE_MARGIN = 0 .01f ;
547+ const DeviceContext& device_ctx = g_vpr_ctx.device ();
548+
549+ const size_t grid_w = device_ctx.grid .width ();
550+ const size_t grid_h = device_ctx.grid .height ();
551+
552+
553+ float draw_width = static_cast <float >(grid_w);
554+ float draw_height = static_cast <float >(grid_h);
555+
556+ initial_world = ezgl::rectangle (
557+ {-VISIBLE_MARGIN * draw_width, -VISIBLE_MARGIN * draw_height},
558+ {(1 .f + VISIBLE_MARGIN) * draw_width, (1 .f + VISIBLE_MARGIN) * draw_height});
559+ }
560+
509561int get_track_num (int inode, const vtr::OffsetMatrix<int >& chanx_track, const vtr::OffsetMatrix<int >& chany_track) {
510562 /* Returns the track number of this routing resource node. */
511563 e_rr_type rr_type;
@@ -628,6 +680,11 @@ void act_on_mouse_press(ezgl::application* app, GdkEventButton* event, double x,
628680 * fanins and fanouts are highlighted when you click on a block *
629681 * attached to them. */
630682
683+ if (get_draw_state_vars ()->pic_on_screen == e_pic_type::ANALYTICAL_PLACEMENT) {
684+ // No selection in analytical placement mode yet
685+ return ;
686+ }
687+
631688 /* Control + mouse click to select multiple nets. */
632689 if (!(event->state & GDK_CONTROL_MASK))
633690 deselect_all ();
0 commit comments