コード例 #1
0
ファイル: p3_interactive.py プロジェクト: Brlgomez/CMPM146
def on_click(event):

    global source_point, destination_point, visited_boxes, path

    if source_point and destination_point:

        source_point = None
        destination_point = None
        visited_boxes = []
        path = []

    elif not source_point:

        source_point = event.y * SUBSAMPLE, event.x * SUBSAMPLE

    else:

        destination_point = event.y * SUBSAMPLE, event.x * SUBSAMPLE

        try:
            path, visited_boxes = p3_pathfinder.find_path(source_point, destination_point, mesh)
        except:
            destination_point = None
            traceback.print_exc()

    redraw()
コード例 #2
0
def on_click(event):

  global source_point, destination_point, visited_boxes, path

  if source_point and destination_point:

    source_point = None
    destination_point = None
    visited_boxes = [[]]
    path = []
    show_status("")
    label.pack()

  elif not source_point:

    source_point = event.y*SUBSAMPLE, event.x*SUBSAMPLE

  else:

    destination_point = event.y*SUBSAMPLE, event.x*SUBSAMPLE

    try:
      path, visited_boxes = p3_pathfinder.find_path(source_point, destination_point, mesh, algorithm, show_status) 
    except:
      destination_point = None
      traceback.print_exc()


  redraw()
コード例 #3
0
def on_click(event):

  global source_point, destination_point, visited_boxes, path

  if source_point and destination_point:

    source_point = None
    destination_point = None
    visited_boxes = []
    path = []

  elif not source_point:

    source_point = event.y*SUBSAMPLE, event.x*SUBSAMPLE
    #print source_point

  else:

    destination_point = event.y*SUBSAMPLE, event.x*SUBSAMPLE

    try:
      path, visited_boxes = p3_pathfinder.find_path(source_point, destination_point, mesh) 
    except:
      destination_point = None
      traceback.print_exc()


  redraw()
コード例 #4
0
def on_right_click(event):
  global source_point, destination_point, visited_boxes, path, algorithm
  swap = {"astar":"bistar", "bistar":"astar"}

  if source_point and destination_point:
    # Default to swapping out for A* if not using one of the two A* variants for comparison already
    algorithm = swap.get(algorithm, "astar")
    try:
      path, visited_boxes = p3_pathfinder.find_path(source_point, destination_point, mesh, algorithm, show_status)
      redraw()
    except:
      destination_point = None
      traceback.print_exc()