original_docstring: Check if a button was clicked
docstring: Check if a button was clicked
docstring_tokens: Check if a button was clicked
code: def add_target_to_the_room(self, on, pressed, x_new, y_new):
  
          """Check if a button was clicked"""
          self.GUI_option.check_list(self.button_create_map_target_type.list)
          self.GUI_option.check_list(self.button_create_map_2.list)
          self.GUI_option.check_list(self.button_target_scale_plus_moins.list)
          self.GUI_option.check_list(self.button_target_vx_plus_moins.list)
          self.GUI_option.check_list(self.button_target_vy_plus_moins.list)
          self.GUI_option.check_list(self.button_target_size_plus_moins.list)
  
          """Draw button on the screen"""
          self.button_create_map_target_type.draw(self.screen)
          self.button_create_map_2.draw(self.screen)
          self.button_target_scale_plus_moins.draw(self.screen)
          self.button_target_vx_plus_moins.draw(self.screen)
          self.button_target_vy_plus_moins.draw(self.screen)
          self.button_target_size_plus_moins.draw(self.screen)
  
          """Check buttons"""
          self.target_scale = self.check_plus_or_minus_button(self.button_target_scale_plus_moins,
                                                              self.button_target_scale_plus_moins_name, self.target_scale,
                                                              0.02)
  
          self.vx_default = self.check_plus_or_minus_button(self.button_target_vx_plus_moins,
                                                            self.button_target_vx_plus_moins_name,
                                                            self.vx_default, 0.2)
          self.vy_default = self.check_plus_or_minus_button(self.button_target_vy_plus_moins,
                                                            self.button_target_vy_plus_moins_name,
                                                            self.vy_default, 0.2)
          self.size_default = self.check_plus_or_minus_button(self.button_target_size_plus_moins,
                                                              self.button_target_size_plus_moins_name,
                                                              self.size_default, self.target_scale)
  
          "draw values on the screen"
          x=225
          label = self.font.render("%.02f" % self.target_scale, 10, WHITE)
          self.screen.blit(label, (x, 100))
          label = self.font.render("%.02f" % self.vx_default, 10, WHITE)
          self.screen.blit(label, (x, 125))
          label = self.font.render("%.02f" % self.vy_default, 10, WHITE)
          self.screen.blit(label, (x, 150))
          label = self.font.render("%.02f" % self.size_default, 10, WHITE)
          self.screen.blit(label, (x, 175))
  
          label = None
          if self.button_create_map_target_type.find_button_state(self.button_create_map_traget_type_name[0]):
              label = TargetType.UNKNOWN
          elif self.button_create_map_target_type.find_button_state(self.button_create_map_traget_type_name[1]):
              label = TargetType.SET_FIX
  
          "draw the target on the screen"
  
          if on and self.button_create_map_2.find_button_state(Button_name.OBJECT_ADD):
              target = Target(id=-1, xc = x_new, yc=y_new, vx =self.vx_default, vy = self.vy_default, ax = 0, ay= 0,
                              radius = self.size_default,type=label, color = None, trajectory_type=TargetMotion.LINEAR, trajectory= [(0, 0)],
                              t_add=[0],t_del=[1000])
              self.GUI_room.draw_one_target(target, self.new_room.coordinate_room)
  
          "Add the target in the room"
          if pressed:
              if self.button_create_map_2.find_button_state(Button_name.OBJECT_ADD):
                  self.new_room.add_create_Target(x_new, y_new, self.vx_default, self.vy_default, TargetMotion.LINEAR,
                                                  self.trajectory_target, label, self.size_default, [0], [1000])
  
              elif self.button_create_map_2.find_button_state(Button_name.OBJECT_DEL):
                  for target in self.new_room.information_simulation.target_list:
                      if math.fabs(x_new - target.xc) < 0.2 and math.fabs(y_new - target.yc) < 0.2:
                          self.new_room.information_simulation.target_list.remove(target)
code_tokens: def add_target_to_the_room ( self , on , pressed , x_new , y_new ) : self . GUI_option . check_list ( self . button_create_map_target_type . list ) self . GUI_option . check_list ( self . button_create_map_2 . list ) self . GUI_option . check_list ( self . button_target_scale_plus_moins . list ) self . GUI_option . check_list ( self . button_target_vx_plus_moins . list ) self . GUI_option . check_list ( self . button_target_vy_plus_moins . list ) self . GUI_option . check_list ( self . button_target_size_plus_moins . list ) """Draw button on the screen""" self . button_create_map_target_type . draw ( self . screen ) self . button_create_map_2 . draw ( self . screen ) self . button_target_scale_plus_moins . draw ( self . screen ) self . button_target_vx_plus_moins . draw ( self . screen ) self . button_target_vy_plus_moins . draw ( self . screen ) self . button_target_size_plus_moins . draw ( self . screen ) """Check buttons""" self . target_scale = self . check_plus_or_minus_button ( self . button_target_scale_plus_moins , self . button_target_scale_plus_moins_name , self . target_scale , 0.02 ) self . vx_default = self . check_plus_or_minus_button ( self . button_target_vx_plus_moins , self . button_target_vx_plus_moins_name , self . vx_default , 0.2 ) self . vy_default = self . check_plus_or_minus_button ( self . button_target_vy_plus_moins , self . button_target_vy_plus_moins_name , self . vy_default , 0.2 ) self . size_default = self . check_plus_or_minus_button ( self . button_target_size_plus_moins , self . button_target_size_plus_moins_name , self . size_default , self . target_scale ) "draw values on the screen" x = 225 label = self . font . render ( "%.02f" % self . target_scale , 10 , WHITE ) self . screen . blit ( label , ( x , 100 ) ) label = self . font . render ( "%.02f" % self . vx_default , 10 , WHITE ) self . screen . blit ( label , ( x , 125 ) ) label = self . font . render ( "%.02f" % self . vy_default , 10 , WHITE ) self . screen . blit ( label , ( x , 150 ) ) label = self . font . render ( "%.02f" % self . size_default , 10 , WHITE ) self . screen . blit ( label , ( x , 175 ) ) label = None if self . button_create_map_target_type . find_button_state ( self . button_create_map_traget_type_name [ 0 ] ) : label = TargetType . UNKNOWN elif self . button_create_map_target_type . find_button_state ( self . button_create_map_traget_type_name [ 1 ] ) : label = TargetType . SET_FIX "draw the target on the screen" if on and self . button_create_map_2 . find_button_state ( Button_name . OBJECT_ADD ) : target = Target ( id = - 1 , xc = x_new , yc = y_new , vx = self . vx_default , vy = self . vy_default , ax = 0 , ay = 0 , radius = self . size_default , type = label , color = None , trajectory_type = TargetMotion . LINEAR , trajectory = [ ( 0 , 0 ) ] , t_add = [ 0 ] , t_del = [ 1000 ] ) self . GUI_room . draw_one_target ( target , self . new_room . coordinate_room ) "Add the target in the room" if pressed : if self . button_create_map_2 . find_button_state ( Button_name . OBJECT_ADD ) : self . new_room . add_create_Target ( x_new , y_new , self . vx_default , self . vy_default , TargetMotion . LINEAR , self . trajectory_target , label , self . size_default , [ 0 ] , [ 1000 ] ) elif self . button_create_map_2 . find_button_state ( Button_name . OBJECT_DEL ) : for target in self . new_room . information_simulation . target_list : if math . fabs ( x_new - target . xc ) < 0.2 and math . fabs ( y_new - target . yc ) < 0.2 : self . new_room . information_simulation . target_list . remove ( target )
short_docstring: Check if a button was clicked
short_docstring_tokens: Check if a button was clicked
comment: """Check if a button was clicked"""$SEP$"""Draw button on the screen"""$SEP$"""Check buttons"""$SEP$"draw values on the screen"$SEP$"draw the target on the screen"$SEP$"Add the target in the room"