2020#include " physical_types.h"
2121
2222#include " move_utils.h"
23+ #include " vpr_types.h"
2324
2425#ifndef NO_GRAPHICS
2526
@@ -174,63 +175,65 @@ static void draw_main_canvas(ezgl::renderer* g) {
174175 t_draw_state* draw_state = get_draw_state_vars ();
175176
176177 g->set_font_size (14 );
178+ if (draw_state->pic_on_screen != ANALYTICAL_PLACEMENT) {
179+ draw_block_pin_util ();
180+ drawplace (g);
181+ draw_internal_draw_subblk (g);
177182
178- draw_block_pin_util ();
179- drawplace (g);
180- draw_internal_draw_subblk (g);
183+ if (draw_state->pic_on_screen == ROUTING) { // ROUTING on screen
181184
182- if (draw_state-> pic_on_screen == ROUTING) { // ROUTING on screen
185+ draw_rr (g);
183186
184- draw_rr (g);
187+ if (draw_state->show_nets && draw_state->draw_nets == DRAW_ROUTED_NETS) {
188+ draw_route (ALL_NETS, g);
185189
186- if (draw_state->show_nets && draw_state->draw_nets == DRAW_ROUTED_NETS) {
187- draw_route (ALL_NETS, g);
188-
189- if (draw_state->highlight_fan_in_fan_out ) {
190- draw_route (HIGHLIGHTED, g);
190+ if (draw_state->highlight_fan_in_fan_out ) {
191+ draw_route (HIGHLIGHTED, g);
192+ }
191193 }
192- }
193194
194- draw_congestion (g);
195+ draw_congestion (g);
195196
196- draw_routing_costs (g);
197+ draw_routing_costs (g);
197198
198- draw_router_expansion_costs (g);
199+ draw_router_expansion_costs (g);
199200
200- draw_routing_util (g);
201+ draw_routing_util (g);
201202
202- draw_routing_bb (g);
203- }
203+ draw_routing_bb (g);
204+ }
204205
205- draw_placement_macros (g);
206+ draw_placement_macros (g);
206207
207208#ifndef NO_SERVER
208- if (g_vpr_ctx.server ().gate_io .is_running ()) {
209- const ServerContext& server_ctx = g_vpr_ctx.server (); // shortcut
210- draw_crit_path_elements (server_ctx.crit_paths , server_ctx.crit_path_element_indexes , server_ctx.draw_crit_path_contour , g);
211- } else {
212- draw_crit_path (g);
213- }
209+ if (g_vpr_ctx.server ().gate_io .is_running ()) {
210+ const ServerContext& server_ctx = g_vpr_ctx.server (); // shortcut
211+ draw_crit_path_elements (server_ctx.crit_paths , server_ctx.crit_path_element_indexes , server_ctx.draw_crit_path_contour , g);
212+ } else {
213+ draw_crit_path (g);
214+ }
214215#else
215- draw_crit_path (g);
216+ draw_crit_path (g);
216217#endif /* NO_SERVER */
217218
218- draw_logical_connections (g);
219+ draw_logical_connections (g);
219220
220- draw_selected_pb_flylines (g);
221+ draw_selected_pb_flylines (g);
221222
222- draw_noc (g);
223+ draw_noc (g);
223224
224- if (draw_state->draw_partitions ) {
225- highlight_all_regions (g);
226- draw_constrained_atoms (g);
227- }
225+ if (draw_state->draw_partitions ) {
226+ highlight_all_regions (g);
227+ draw_constrained_atoms (g);
228+ }
228229
229- if (draw_state->color_map ) {
230- draw_color_map_legend (*draw_state->color_map , g);
231- draw_state->color_map .reset (); // Free color map in preparation for next redraw
230+ if (draw_state->color_map ) {
231+ draw_color_map_legend (*draw_state->color_map , g);
232+ draw_state->color_map .reset (); // Free color map in preparation for next redraw
233+ }
234+ } else {
235+ draw_analytical_place (g);
232236 }
233-
234237 if (draw_state->auto_proceed ) {
235238 // Automatically exit the event loop, so user's don't need to manually click proceed
236239
@@ -302,16 +305,28 @@ void update_screen(ScreenUpdatePriority priority, const char* msg, enum pic_type
302305
303306 state_change = true ;
304307
308+ if (pic_on_screen_val == ANALYTICAL_PLACEMENT) {
309+ set_initial_world_ap ();
310+ } else {
311+ set_initial_world ();
312+ }
313+
305314 if (draw_state->pic_on_screen == NO_PICTURE) {
306315 // Only add the canvas the first time we open graphics
307- application.add_canvas (" MainCanvas" , draw_main_canvas,
308- initial_world);
316+ application.add_canvas (" MainCanvas" , draw_main_canvas, initial_world);
317+ } else {
318+ // TODO: will this ever be null?
319+ auto canvas = application.get_canvas (application.get_main_canvas_id ());
320+ if (canvas != nullptr ) {
321+ canvas->get_camera ().set_world (initial_world);
322+ }
309323 }
310324
311325 draw_state->setup_timing_info = setup_timing_info;
312326 draw_state->pic_on_screen = pic_on_screen_val;
313327 }
314328
329+ // What is this? Always true!
315330 bool should_pause = int (priority) >= draw_state->gr_automode ;
316331
317332 // If there was a state change, we must call ezgl::application::run() to update the buttons.
@@ -481,7 +496,16 @@ void init_draw_coords(float clb_width, const BlkLocRegistry& blk_loc_registry) {
481496 // Margin beyond edge of the drawn device to extend the visible world
482497 // Setting this to > 0.0 means 'Zoom Fit' leave some fraction of white
483498 // space around the device edges
499+ #else
500+ (void )clb_width;
501+ (void )blk_loc_registry;
502+ #endif /* NO_GRAPHICS */
503+ }
504+
505+ void set_initial_world () {
484506 constexpr float VISIBLE_MARGIN = 0.01 ;
507+ t_draw_coords* draw_coords = get_draw_coords_vars ();
508+ const DeviceContext& device_ctx = g_vpr_ctx.device ();
485509
486510 float draw_width = draw_coords->tile_x [device_ctx.grid .width () - 1 ]
487511 + draw_coords->get_tile_width ();
@@ -491,11 +515,11 @@ void init_draw_coords(float clb_width, const BlkLocRegistry& blk_loc_registry) {
491515 initial_world = ezgl::rectangle (
492516 {-VISIBLE_MARGIN * draw_width, -VISIBLE_MARGIN * draw_height},
493517 {(1 . + VISIBLE_MARGIN) * draw_width, (1 . + VISIBLE_MARGIN)
494- * draw_height});
495- # else
496- ( void )clb_width;
497- ( void )blk_loc_registry;
498- # endif /* NO_GRAPHICS */
518+ * draw_height});
519+ }
520+
521+ void set_initial_world_ap () {
522+ initial_world = ezgl::rectangle ({- 1 , - 1 }, { 1 , 1 });
499523}
500524
501525#ifndef NO_GRAPHICS
0 commit comments