55 * @brief Contains the function definitions needed for manual moves feature.
66 *
77 * Includes the graphics/gtk function for manual moves. The Manual Move Generator class is defined manual_move_generator.h/cpp.
8- * The manual move feature allows the user to select a move by choosing the block to move, x position, y position, subtile position.
8+ * The manual move feature allows the user to select a move by choosing the block to move, x position, y position, layer_position, subtile position.
99 * If the placer accepts the move, the user can accept or reject the move with respect to the delta cost,
1010 * delta timing and delta bounding box cost displayed on the UI. The manual move feature interacts with placement through
1111 * the ManualMoveGenerator class in the manual_move_generator.cpp/h files and in the place.cpp file by checking
@@ -42,11 +42,13 @@ void draw_manual_moves_window(const std::string& block_id) {
4242
4343 GtkWidget* x_position_entry = gtk_entry_new ();
4444 GtkWidget* y_position_entry = gtk_entry_new ();
45+ GtkWidget* layer_position_entry = gtk_entry_new ();
4546 GtkWidget* subtile_position_entry = gtk_entry_new ();
4647 GtkWidget* block_label = gtk_label_new (" Block ID/Block Name:" );
4748 GtkWidget* to_label = gtk_label_new (" To Location:" );
4849 GtkWidget* x = gtk_label_new (" x:" );
4950 GtkWidget* y = gtk_label_new (" y:" );
51+ GtkWidget* layer = gtk_label_new (" layer:" );
5052 GtkWidget* subtile = gtk_label_new (" Subtile:" );
5153
5254 GtkWidget* calculate_cost_button = gtk_button_new_with_label (" Calculate Costs" );
@@ -59,9 +61,11 @@ void draw_manual_moves_window(const std::string& block_id) {
5961 gtk_grid_attach ((GtkGrid*)grid, x_position_entry, 2 , 1 , 1 , 1 );
6062 gtk_grid_attach ((GtkGrid*)grid, y, 1 , 2 , 1 , 1 );
6163 gtk_grid_attach ((GtkGrid*)grid, y_position_entry, 2 , 2 , 1 , 1 );
62- gtk_grid_attach ((GtkGrid*)grid, subtile, 1 , 3 , 1 , 1 );
63- gtk_grid_attach ((GtkGrid*)grid, subtile_position_entry, 2 , 3 , 1 , 1 );
64- gtk_grid_attach ((GtkGrid*)grid, calculate_cost_button, 0 , 4 , 3 , 1 ); // spans three columns
64+ gtk_grid_attach ((GtkGrid*)grid, layer, 1 , 3 , 1 , 1 );
65+ gtk_grid_attach ((GtkGrid*)grid, layer_position_entry, 2 , 3 , 1 , 1 );
66+ gtk_grid_attach ((GtkGrid*)grid, subtile, 1 , 4 , 1 , 1 );
67+ gtk_grid_attach ((GtkGrid*)grid, subtile_position_entry, 2 , 4 , 1 , 1 );
68+ gtk_grid_attach ((GtkGrid*)grid, calculate_cost_button, 0 , 5 , 3 , 1 ); // spans three columns
6569
6670 // Set margins
6771 gtk_widget_set_margin_bottom (grid, 20 );
@@ -88,6 +92,7 @@ void calculate_cost_callback(GtkWidget* /*widget*/, GtkWidget* grid) {
8892 int block_id = -1 ;
8993 int x_location = -1 ;
9094 int y_location = -1 ;
95+ int layer_location = -1 ;
9196 int subtile_location = -1 ;
9297 bool valid_input = true ;
9398
@@ -108,26 +113,28 @@ void calculate_cost_callback(GtkWidget* /*widget*/, GtkWidget* grid) {
108113
109114 GtkWidget* x_position_entry = gtk_grid_get_child_at ((GtkGrid*)grid, 2 , 1 );
110115 GtkWidget* y_position_entry = gtk_grid_get_child_at ((GtkGrid*)grid, 2 , 2 );
111- GtkWidget* subtile_position_entry = gtk_grid_get_child_at ((GtkGrid*)grid, 2 , 3 );
116+ GtkWidget* layer_position_entry = gtk_grid_get_child_at ((GtkGrid*)grid, 2 , 3 );
117+ GtkWidget* subtile_position_entry = gtk_grid_get_child_at ((GtkGrid*)grid, 2 , 4 );
112118
113119 x_location = std::atoi (gtk_entry_get_text ((GtkEntry*)x_position_entry));
114120 y_location = std::atoi (gtk_entry_get_text ((GtkEntry*)y_position_entry));
121+ layer_location = std::atoi (gtk_entry_get_text ((GtkEntry*)layer_position_entry));
115122 subtile_location = std::atoi (gtk_entry_get_text ((GtkEntry*)subtile_position_entry));
116123
117- if (std::string (gtk_entry_get_text ((GtkEntry*)block_entry)).empty () || std::string (gtk_entry_get_text ((GtkEntry*)x_position_entry)).empty () || std::string (gtk_entry_get_text ((GtkEntry*)y_position_entry)).empty () || std::string (gtk_entry_get_text ((GtkEntry*)subtile_position_entry)).empty ()) {
124+ if (std::string (gtk_entry_get_text ((GtkEntry*)block_entry)).empty () || std::string (gtk_entry_get_text ((GtkEntry*)x_position_entry)).empty () || std::string (gtk_entry_get_text ((GtkEntry*)y_position_entry)).empty () || std::string (gtk_entry_get_text ((GtkEntry*)layer_position_entry)). empty () || std::string ( gtk_entry_get_text ((GtkEntry*) subtile_position_entry)).empty ()) {
118125 invalid_breakpoint_entry_window (" Not all fields are complete" );
119126 valid_input = false ;
120127 }
121128
122- // TODO: When graphic is updated to support 3D, this will need to be updated
123- t_pl_loc to = t_pl_loc (x_location, y_location, subtile_location, 0 );
129+ t_pl_loc to = t_pl_loc (x_location, y_location, subtile_location, layer_location);
124130 valid_input = is_manual_move_legal (ClusterBlockId (block_id), to);
125131
126132 if (valid_input) {
127133 draw_state->manual_moves_state .manual_move_info .valid_input = true ;
128134 draw_state->manual_moves_state .manual_move_info .blockID = block_id;
129135 draw_state->manual_moves_state .manual_move_info .x_pos = x_location;
130136 draw_state->manual_moves_state .manual_move_info .y_pos = y_location;
137+ draw_state->manual_moves_state .manual_move_info .layer = layer_location;
131138 draw_state->manual_moves_state .manual_move_info .subtile = subtile_location;
132139 draw_state->manual_moves_state .manual_move_info .to_location = to;
133140
0 commit comments