1414 HORIZONTAL ,
1515 PERSO ,
1616 VERTICAL ,
17+ USED ,
1718)
1819
1920
@@ -156,7 +157,7 @@ def draw_matrix_points(self, scale=1): # used to debug the matrix
156157 radius = 2 * scale # Adjust size as needed
157158 self .canvas .create_oval (x - radius , y - radius , x + radius , y + radius , fill = color , outline = "" )
158159
159- def draw_blank_board_model (self , x_origin : int = 50 , y_origin : int = 10 ):
160+ def draw_blank_board_model (self , x_origin : int = 50 , y_origin : int = 10 , battery_pos_wire_end = None , battery_neg_wire_end = None ):
160161 """
161162 Draws a blank breadboard model on the canvas.
162163 """
@@ -223,3 +224,24 @@ def draw_blank_board_model(self, x_origin: int = 50, y_origin: int = 10):
223224 (self .sketcher .go_xy , 1 , {"line" : 0 , "column" : 0 , "id_origin" : "circTest" }),
224225 ]
225226 self .sketcher .circuit (x_origin , y_origin , scale = self .sketcher .scale_factor , model = blank_board_model )
227+
228+ battery_x = x_origin + 1200 # Adjust as needed for proper positioning
229+ battery_y = y_origin + 300 # Adjust as needed for proper positioning
230+
231+ # Reset all matrix elements' states to FREE
232+ for key in self .sketcher .matrix :
233+ self .sketcher .matrix [key ]['state' ] = FREE
234+
235+ self .sketcher .draw_battery (
236+ battery_x ,
237+ battery_y ,
238+ pos_wire_end = battery_pos_wire_end ,
239+ neg_wire_end = battery_neg_wire_end ,
240+ )
241+ if battery_pos_wire_end :
242+ allowed_positions = self .sketcher .get_power_line_last_pins ()
243+ nearest_point , nearest_point_coord = self .sketcher .find_nearest_allowed_grid_point (battery_pos_wire_end [0 ], battery_pos_wire_end [1 ], allowed_positions )
244+ col , line = nearest_point_coord
245+ self .sketcher .matrix [f'{ col } ,{ line } ' ]['state' ] = USED
246+
247+
0 commit comments