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" 
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;
@@ -488,22 +510,43 @@ void init_draw_coords(float clb_width, const BlkLocRegistry& blk_loc_registry) {
488510    // Margin beyond edge of the drawn device to extend the visible world
489511    // Setting this to > 0.0 means 'Zoom Fit' leave some fraction of white
490512    // space around the device edges
513+ #else 
514+     (void )clb_width;
515+     (void )blk_loc_registry;
516+ #endif  /*  NO_GRAPHICS */ 
517+ }
518+ 
519+ #ifndef  NO_GRAPHICS
520+ 
521+ void  set_initial_world () {
491522    constexpr  float  VISIBLE_MARGIN = 0.01 ;
523+     t_draw_coords* draw_coords = get_draw_coords_vars ();
524+     const  DeviceContext& device_ctx = g_vpr_ctx.device ();
492525
493526    float  draw_width = draw_coords->tile_x [grid.width () - 1 ] + draw_coords->get_tile_width ();
494527    float  draw_height = draw_coords->tile_y [grid.height () - 1 ] + draw_coords->get_tile_width ();
495528
496529    initial_world = ezgl::rectangle (
497530        {-VISIBLE_MARGIN * draw_width, -VISIBLE_MARGIN * draw_height},
498531        {(1 . + VISIBLE_MARGIN) * draw_width, (1 . + VISIBLE_MARGIN)
499-                                                  * draw_height});
500- #else 
501-     (void )clb_width;
502-     (void )blk_loc_registry;
503- #endif  /*  NO_GRAPHICS */ 
532+                                                  * draw_height});    
504533}
505534
506- #ifndef  NO_GRAPHICS
535+ void  set_initial_world_ap () {
536+     constexpr  float  VISIBLE_MARGIN = 0 .01f ;
537+     const  DeviceContext& device_ctx = g_vpr_ctx.device ();
538+ 
539+     const  size_t  grid_w = device_ctx.grid .width ();
540+     const  size_t  grid_h = device_ctx.grid .height ();
541+ 
542+ 
543+     float  draw_width = static_cast <float >(grid_w);
544+     float  draw_height = static_cast <float >(grid_h);
545+ 
546+     initial_world = ezgl::rectangle (
547+         {-VISIBLE_MARGIN * draw_width, -VISIBLE_MARGIN * draw_height},
548+         {(1 .f  + VISIBLE_MARGIN) * draw_width, (1 .f  + VISIBLE_MARGIN) * draw_height});
549+ }
507550
508551int  get_track_num (int  inode, const  vtr::OffsetMatrix<int >& chanx_track, const  vtr::OffsetMatrix<int >& chany_track) {
509552    /*  Returns the track number of this routing resource node.   */ 
@@ -629,6 +672,11 @@ void act_on_mouse_press(ezgl::application* app, GdkEventButton* event, double x,
629672             * fanins and fanouts are highlighted when you click on a block      * 
630673             * attached to them.                                                 */  
631674
675+             if  (get_draw_state_vars ()->pic_on_screen  == e_pic_type::ANALYTICAL_PLACEMENT) {
676+                 //  No selection in analytical placement mode yet
677+                 return ;
678+             }
679+ 
632680            /*  Control + mouse click to select multiple nets. */ 
633681            if  (!(event->state  & GDK_CONTROL_MASK))
634682                deselect_all ();
0 commit comments