@@ -78,21 +78,13 @@ static float get_router_expansion_cost(const t_rr_node_route_inf& node_inf,
78
78
static void draw_router_expansion_costs (ezgl::renderer* g);
79
79
80
80
static void draw_main_canvas (ezgl::renderer* g);
81
- static void default_setup (ezgl::application* app);
82
- static void initial_setup_NO_PICTURE_to_PLACEMENT (ezgl::application* app,
83
- bool is_new_window);
84
- static void initial_setup_NO_PICTURE_to_PLACEMENT_with_crit_path (
85
- ezgl::application* app,
86
- bool is_new_window);
87
- static void initial_setup_PLACEMENT_to_ROUTING (ezgl::application* app,
88
- bool is_new_window);
89
- static void initial_setup_ROUTING_to_PLACEMENT (ezgl::application* app,
90
- bool is_new_window);
91
- static void initial_setup_NO_PICTURE_to_ROUTING (ezgl::application* app,
92
- bool is_new_window);
93
- static void initial_setup_NO_PICTURE_to_ROUTING_with_crit_path (
94
- ezgl::application* app,
95
- bool is_new_window);
81
+
82
+ /* *
83
+ * @brief Generalized callback function to setup the UI when the stage changes.
84
+ */
85
+ static void on_stage_change_setup (ezgl::application* app, bool is_new_window);
86
+
87
+
96
88
static void setup_default_ezgl_callbacks (ezgl::application* app);
97
89
static void set_force_pause (GtkWidget* /* widget*/ , gint /* response_id*/ , gpointer /* data*/ );
98
90
static void set_block_outline (GtkWidget* widget, gint /* response_id*/ , gpointer /* data*/ );
@@ -254,108 +246,40 @@ static void draw_main_canvas(ezgl::renderer* g) {
254
246
}
255
247
}
256
248
257
- /* *
258
- * @brief Default setup function, connects signals/sets up ui created in main.ui file
259
- *
260
- * To minimize code repetition, this function sets up all buttons that ALWAYS get set up.
261
- * If you want to add to the initial setup functions, and your new setup function will always be called,
262
- * please put it here instead of writing it 5 independent times. Thanks!
263
- * @param app ezgl application
264
- */
265
- static void default_setup (ezgl::application* app) {
266
- basic_button_setup (app);
267
- net_button_setup (app);
268
- block_button_setup (app);
269
- search_setup (app);
270
- view_button_setup (app);
271
- }
272
249
273
- // Initial Setup functions run default setup if they are a new window. Then, they will run
274
- // the specific hiding/showing functions that separate them from the other init. setup functions
250
+ static void on_stage_change_setup (ezgl::application* app, bool is_new_window) {
251
+
252
+ // default setup for new window
253
+ if (is_new_window) {
254
+ basic_button_setup (app);
255
+ net_button_setup (app);
256
+ block_button_setup (app);
257
+ search_setup (app);
258
+ routing_button_setup (app);
259
+ view_button_setup (app);
260
+ crit_path_button_setup (app);
261
+ }
275
262
276
- /* function below initializes the interface window with a set of buttons and links
277
- * signals to corresponding functions for situation where the window is opened from
278
- * NO_PICTURE_to_PLACEMENT */
279
- static void initial_setup_NO_PICTURE_to_PLACEMENT (ezgl::application* app,
280
- bool is_new_window) {
281
- if (is_new_window)
282
- default_setup (app);
263
+ t_draw_state* draw_state = get_draw_state_vars ();
283
264
284
- // Hiding unused functionality
285
- hide_widget (" RoutingMenuButton" , app);
286
- }
265
+ if (draw_state->pic_on_screen == PLACEMENT) {
266
+ hide_widget (" RoutingMenuButton" , app);
287
267
288
- /* function below initializes the interface window with a set of buttons and links
289
- * signals to corresponding functions for situation where the window is opened from
290
- * NO_PICTURE_to_PLACEMENT_with_crit_path */
291
- static void initial_setup_NO_PICTURE_to_PLACEMENT_with_crit_path (
292
- ezgl::application* app,
293
- bool is_new_window) {
294
- if (is_new_window)
295
- default_setup (app);
296
-
297
- // Showing given functionality
298
- crit_path_button_setup (app);
299
- /* Routing hasn't been done yet, so hide the display options that show routing
300
- * as they don't make sense and would crash if clicked on */
301
- hide_crit_path_routing (app, true );
302
- // Hiding unused routing menu
303
- hide_widget (" RoutingMenuButton" , app);
304
- }
268
+ draw_state->save_graphics_file_base = " vpr_placement" ;
305
269
306
- /* function below initializes the interface window with a set of buttons and links
307
- * signals to corresponding functions for situation where the window is opened from
308
- * PLACEMENT_to_ROUTING */
309
- static void initial_setup_PLACEMENT_to_ROUTING (ezgl::application* app,
310
- bool is_new_window) {
311
- if (is_new_window)
312
- default_setup (app);
313
-
314
- routing_button_setup (app);
315
- crit_path_button_setup (app);
316
- hide_crit_path_routing (app, false );
317
- }
270
+ } else if (draw_state->pic_on_screen == ROUTING) {
271
+ show_widget (" RoutingMenuButton" , app);
318
272
319
- /* function below initializes the interface window with a set of buttons and links
320
- * signals to corresponding functions for situation where the window is opened from
321
- * ROUTING_to_PLACEMENT */
322
- static void initial_setup_ROUTING_to_PLACEMENT (ezgl::application* app,
323
- bool is_new_window) {
324
- if (is_new_window)
325
- default_setup (app);
326
-
327
- // Hiding unused functionality
328
- hide_widget (" RoutingMenuButton" , app);
329
- crit_path_button_setup (app);
330
- hide_crit_path_routing (app, false );
331
- }
273
+ draw_state->save_graphics_file_base = " vpr_routing" ;
332
274
333
- /* function below initializes the interface window with a set of buttons and links
334
- * signals to corresponding functions for situation where the window is opened from
335
- * NO_PICTURE_to_ROUTING */
336
- static void initial_setup_NO_PICTURE_to_ROUTING (ezgl::application* app,
337
- bool is_new_window) {
338
- if (is_new_window)
339
- default_setup (app);
340
-
341
- routing_button_setup (app);
342
- crit_path_button_setup (app);
343
- hide_crit_path_routing (app, false );
344
- }
275
+ }
276
+
277
+ // show/hide critical path routing UI elements
278
+ hide_crit_path_routing (app);
345
279
346
- /* function below initializes the interface window with a set of buttons and links
347
- * signals to corresponding functions for situation where the window is opened from
348
- * NO_PICTURE_to_ROUTING_with_crit_path */
349
- static void initial_setup_NO_PICTURE_to_ROUTING_with_crit_path (
350
- ezgl::application* app,
351
- bool is_new_window) {
352
- if (is_new_window)
353
- default_setup (app);
354
-
355
- routing_button_setup (app);
356
- crit_path_button_setup (app);
357
- hide_crit_path_routing (app, false );
280
+ hide_draw_routing (app);
358
281
}
282
+
359
283
#endif // NO_GRAPHICS
360
284
361
285
void update_screen (ScreenUpdatePriority priority, const char * msg, enum pic_type pic_on_screen_val, std::shared_ptr<const SetupTimingInfo> setup_timing_info) {
@@ -378,49 +302,14 @@ void update_screen(ScreenUpdatePriority priority, const char* msg, enum pic_type
378
302
if (draw_state->pic_on_screen != pic_on_screen_val) { // State changed
379
303
380
304
if (draw_state->pic_on_screen == NO_PICTURE) {
381
- // Only add the canvas the first time we open graphics
305
+ // Only add the canvas the first time we open graphics
382
306
application.add_canvas (" MainCanvas" , draw_main_canvas,
383
307
initial_world);
384
308
}
385
309
386
310
draw_state->setup_timing_info = setup_timing_info;
387
-
388
- if (pic_on_screen_val == PLACEMENT
389
- && draw_state->pic_on_screen == NO_PICTURE) {
390
- if (setup_timing_info) {
391
- init_setup = initial_setup_NO_PICTURE_to_PLACEMENT_with_crit_path;
392
- } else {
393
- init_setup = initial_setup_NO_PICTURE_to_PLACEMENT;
394
- }
395
- draw_state->save_graphics_file_base = " vpr_placement" ;
396
-
397
- } else if (pic_on_screen_val == ROUTING
398
- && draw_state->pic_on_screen == PLACEMENT) {
399
- // Routing, opening after placement
400
- init_setup = initial_setup_PLACEMENT_to_ROUTING;
401
- draw_state->save_graphics_file_base = " vpr_routing" ;
402
-
403
- } else if (pic_on_screen_val == PLACEMENT
404
- && draw_state->pic_on_screen == ROUTING) {
405
- init_setup = initial_setup_ROUTING_to_PLACEMENT;
406
- draw_state->save_graphics_file_base = " vpr_placement" ;
407
-
408
- } else if (pic_on_screen_val == ROUTING
409
- && draw_state->pic_on_screen == NO_PICTURE) {
410
- // Routing opening first
411
- if (setup_timing_info) {
412
- init_setup = initial_setup_NO_PICTURE_to_ROUTING_with_crit_path;
413
- } else {
414
- init_setup = initial_setup_NO_PICTURE_to_ROUTING;
415
- }
416
- draw_state->save_graphics_file_base = " vpr_routing" ;
417
- }
418
-
419
311
draw_state->pic_on_screen = pic_on_screen_val;
420
-
421
- } else {
422
- // No change (e.g. paused)
423
- init_setup = nullptr ;
312
+ init_setup = on_stage_change_setup;
424
313
}
425
314
426
315
bool state_change = (init_setup != nullptr );
0 commit comments