Skip to content

Commit 054884c

Browse files
committed
reworked stage change ui setup functions and enabled show routing option only in routing stage
1 parent 44a2f9a commit 054884c

File tree

4 files changed

+76
-153
lines changed

4 files changed

+76
-153
lines changed

vpr/src/draw/draw.cpp

Lines changed: 34 additions & 145 deletions
Original file line numberDiff line numberDiff line change
@@ -78,21 +78,13 @@ static float get_router_expansion_cost(const t_rr_node_route_inf& node_inf,
7878
static void draw_router_expansion_costs(ezgl::renderer* g);
7979

8080
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+
9688
static void setup_default_ezgl_callbacks(ezgl::application* app);
9789
static void set_force_pause(GtkWidget* /*widget*/, gint /*response_id*/, gpointer /*data*/);
9890
static void set_block_outline(GtkWidget* widget, gint /*response_id*/, gpointer /*data*/);
@@ -254,108 +246,40 @@ static void draw_main_canvas(ezgl::renderer* g) {
254246
}
255247
}
256248

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-
}
272249

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+
}
275262

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();
283264

284-
//Hiding unused functionality
285-
hide_widget("RoutingMenuButton", app);
286-
}
265+
if (draw_state->pic_on_screen == PLACEMENT) {
266+
hide_widget("RoutingMenuButton", app);
287267

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";
305269

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);
318272

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";
332274

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);
345279

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);
358281
}
282+
359283
#endif //NO_GRAPHICS
360284

361285
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
378302
if (draw_state->pic_on_screen != pic_on_screen_val) { //State changed
379303

380304
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
382306
application.add_canvas("MainCanvas", draw_main_canvas,
383307
initial_world);
384308
}
385309

386310
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-
419311
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;
424313
}
425314

426315
bool state_change = (init_setup != nullptr);

vpr/src/draw/draw_basic.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1241,6 +1241,7 @@ void draw_routed_timing_edge_connection(tatum::NodeId src_tnode,
12411241

12421242
for (RRNodeId inode : routed_rr_nodes) {
12431243
draw_state->draw_rr_node[inode].color = color;
1244+
draw_state->draw_rr_node[inode].node_highlighted = true;
12441245
}
12451246

12461247
//draw_partial_route() takes care of layer visibility and cross-layer settings

vpr/src/draw/ui_setup.cpp

Lines changed: 35 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include "save_graphics.h"
1919
#include "search_bar.h"
2020
#include "ui_setup.h"
21+
#include "gtkcomboboxhelper.h"
2122

2223
#include "ezgl/application.hpp"
2324

@@ -65,7 +66,7 @@ void net_button_setup(ezgl::application* app) {
6566
GtkSwitch* toggle_nets_switch = GTK_SWITCH(app->get_object("ToggleNets"));
6667
g_signal_connect(toggle_nets_switch, "state-set", G_CALLBACK(toggle_show_nets_cbk), app);
6768

68-
//Toggle net signal connection
69+
// Manages net type
6970
GtkComboBoxText* toggle_nets = GTK_COMBO_BOX_TEXT(app->get_object("ToggleNetType"));
7071
g_signal_connect(toggle_nets, "changed", G_CALLBACK(toggle_draw_nets_cbk), app);
7172

@@ -261,16 +262,43 @@ void crit_path_button_setup(ezgl::application* app) {
261262
*
262263
* @param app ezgl app
263264
*/
264-
void hide_crit_path_routing(ezgl::application* app, bool hide) {
265+
void hide_crit_path_routing(ezgl::application* app) {
265266
GtkComboBoxText* toggle_crit_path = GTK_COMBO_BOX_TEXT(app->get_object("ToggleCritPath"));
266-
if (hide) {
267-
gtk_combo_box_text_remove(toggle_crit_path, 4);
268-
gtk_combo_box_text_remove(toggle_crit_path, 3);
267+
t_draw_state* draw_state = get_draw_state_vars();
268+
269+
int crit_path_item_index = get_item_index_by_text(toggle_crit_path, "Crit Path Routing");
270+
271+
// Enable the option to show critical path only when timing info is available
272+
if (!draw_state->setup_timing_info || draw_state->pic_on_screen != ROUTING) {
273+
if(crit_path_item_index != -1) {
274+
gtk_combo_box_text_remove(toggle_crit_path, crit_path_item_index);
275+
gtk_combo_box_text_remove(toggle_crit_path, crit_path_item_index + 1);
276+
}
269277
} else {
270-
gtk_combo_box_text_insert_text(toggle_crit_path, 3, "Crit Path Routing");
271-
gtk_combo_box_text_insert_text(toggle_crit_path, 4, "Crit Path Routing Delays");
278+
if(crit_path_item_index == -1){
279+
gtk_combo_box_text_insert_text(toggle_crit_path, 3, "Crit Path Routing");
280+
gtk_combo_box_text_insert_text(toggle_crit_path, 4, "Crit Path Routing Delays");
281+
}
272282
}
273283
}
284+
285+
void hide_draw_routing(ezgl::application* app) {
286+
t_draw_state* draw_state = get_draw_state_vars();
287+
GtkComboBoxText* toggle_nets = GTK_COMBO_BOX_TEXT(app->get_object("ToggleNetType"));
288+
289+
// Enable the option to draw routing only during the routing stage
290+
int route_item_index = get_item_index_by_text(toggle_nets, "Routing");
291+
if(draw_state->pic_on_screen == PLACEMENT){
292+
if (route_item_index != -1) {
293+
gtk_combo_box_text_remove(toggle_nets, route_item_index);
294+
}
295+
} else {
296+
if(route_item_index == -1){
297+
gtk_combo_box_text_append(toggle_nets, "2", "Routing");
298+
}
299+
}
300+
}
301+
274302
/*
275303
* @brief Hides the widget with the given name
276304
*

vpr/src/draw/ui_setup.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,12 @@ void crit_path_button_setup(ezgl::application* app);
7373
* @brief Hides or displays Critical Path routing / routing delay UI elements,
7474
* Use to ensure we don't show inactive buttons etc. when routing data doesn't exist
7575
*/
76-
void hide_crit_path_routing(ezgl::application* app, bool hide);
76+
void hide_crit_path_routing(ezgl::application* app);
77+
78+
/**
79+
* @brief Hides the option to draw routing when in placement stage, and shows it in routing stage.
80+
*/
81+
void hide_draw_routing(ezgl::application* app);
7782

7883
/**
7984
* @brief Loads block names into Gtk Structures to enable autocomplete

0 commit comments

Comments
 (0)