5
5
* @brief Contains the function definitions needed for manual moves feature.
6
6
*
7
7
* 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.
9
9
* If the placer accepts the move, the user can accept or reject the move with respect to the delta cost,
10
10
* delta timing and delta bounding box cost displayed on the UI. The manual move feature interacts with placement through
11
11
* 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) {
42
42
43
43
GtkWidget* x_position_entry = gtk_entry_new ();
44
44
GtkWidget* y_position_entry = gtk_entry_new ();
45
+ GtkWidget* layer_position_entry = gtk_entry_new ();
45
46
GtkWidget* subtile_position_entry = gtk_entry_new ();
46
47
GtkWidget* block_label = gtk_label_new (" Block ID/Block Name:" );
47
48
GtkWidget* to_label = gtk_label_new (" To Location:" );
48
49
GtkWidget* x = gtk_label_new (" x:" );
49
50
GtkWidget* y = gtk_label_new (" y:" );
51
+ GtkWidget* layer = gtk_label_new (" layer:" );
50
52
GtkWidget* subtile = gtk_label_new (" Subtile:" );
51
53
52
54
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) {
59
61
gtk_grid_attach ((GtkGrid*)grid, x_position_entry, 2 , 1 , 1 , 1 );
60
62
gtk_grid_attach ((GtkGrid*)grid, y, 1 , 2 , 1 , 1 );
61
63
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
65
69
66
70
// Set margins
67
71
gtk_widget_set_margin_bottom (grid, 20 );
@@ -88,6 +92,7 @@ void calculate_cost_callback(GtkWidget* /*widget*/, GtkWidget* grid) {
88
92
int block_id = -1 ;
89
93
int x_location = -1 ;
90
94
int y_location = -1 ;
95
+ int layer_location = -1 ;
91
96
int subtile_location = -1 ;
92
97
bool valid_input = true ;
93
98
@@ -108,26 +113,28 @@ void calculate_cost_callback(GtkWidget* /*widget*/, GtkWidget* grid) {
108
113
109
114
GtkWidget* x_position_entry = gtk_grid_get_child_at ((GtkGrid*)grid, 2 , 1 );
110
115
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 );
112
118
113
119
x_location = std::atoi (gtk_entry_get_text ((GtkEntry*)x_position_entry));
114
120
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));
115
122
subtile_location = std::atoi (gtk_entry_get_text ((GtkEntry*)subtile_position_entry));
116
123
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 ()) {
118
125
invalid_breakpoint_entry_window (" Not all fields are complete" );
119
126
valid_input = false ;
120
127
}
121
128
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);
124
130
valid_input = is_manual_move_legal (ClusterBlockId (block_id), to);
125
131
126
132
if (valid_input) {
127
133
draw_state->manual_moves_state .manual_move_info .valid_input = true ;
128
134
draw_state->manual_moves_state .manual_move_info .blockID = block_id;
129
135
draw_state->manual_moves_state .manual_move_info .x_pos = x_location;
130
136
draw_state->manual_moves_state .manual_move_info .y_pos = y_location;
137
+ draw_state->manual_moves_state .manual_move_info .layer = layer_location;
131
138
draw_state->manual_moves_state .manual_move_info .subtile = subtile_location;
132
139
draw_state->manual_moves_state .manual_move_info .to_location = to;
133
140
0 commit comments