Ejemplo n.º 1
0
def figure_simple_display(ai_figure, ai_overlay_figure=[], ai_parameter_info=""):
  """ Display the figure with red lines in the Tkinter Two_Canvas GUI
      If you want a finer control on the way outlines are displayed (color, width, overlay), you need to work at the outline level (not figure level)
  """
  print("Figure simple display with Tkinter")
  # convert all outlines in format-B
  # graphic layer
  graphic_figure = []
  i = 0
  for i_outline in ai_figure:
    if(cnc_outline.check_outline_format(i_outline)==2):
      print("WARN441: Warning, the outline {:d} must be converted in format-B with ideal_outline()!".format(i))
      graphic_figure.append(cnc_outline.ideal_outline(i_outline, "figure_simple_display"))
    else:
      graphic_figure.append(i_outline)
    i += 1
  # overlay layer
  overlay_figure = []
  i = 0
  for i_outline in ai_overlay_figure:
    if(cnc_outline.check_outline_format(i_outline)==2):
      print("WARN442: Warning, the overlay outline {:d} must be converted in format-B with ideal_outline()!".format(i))
      overlay_figure.append(cnc_outline.ideal_outline(i_outline, "figure_simple_display_overlay"))
    else:
      overlay_figure.append(i_outline)
    i += 1
  # start GUI
  tk_root = Tkinter.Tk()
  fsd_canvas = Two_Canvas(tk_root)
  # callback function for display_backend
  def sub_fsd_canvas_graphics(ai_rotation_direction, ai_angle_position):
    # angle position
    l_angle_position = float(ai_angle_position)/100
    #
    r_canvas_graphics = []
    for ol in overlay_figure:
      rotated_ol = cnc_outline.outline_rotate(ol, 0, 0, l_angle_position) # rotation of center (0,0) and angle l_angle_position
      r_canvas_graphics.append(('overlay_lines', outline_arc_line(rotated_ol, 'tkinter'), 'orange', 2))
    for ol in graphic_figure:
      rotated_ol = cnc_outline.outline_rotate(ol, 0, 0, l_angle_position) # rotation of center (0,0) and angle l_angle_position
      r_canvas_graphics.append(('graphic_lines', outline_arc_line(rotated_ol, 'tkinter'), 'red', 1))
    return(r_canvas_graphics)
  # end of callback function
  fsd_canvas.add_canvas_graphic_function(sub_fsd_canvas_graphics)
  fsd_canvas.add_parameter_info(ai_parameter_info)
  tk_root.mainloop()
  del (tk_root, fsd_canvas)
  time.sleep(1.0)
  return(0)
Ejemplo n.º 2
0
def ideal_figure(ai_figure, ai_error_msg_id):
    """ apply the ideal_outline function to all outlines of the input figure
  """
    r_figure = []
    for i in range(len(ai_figure)):
        # print("dbg145:", ai_figure[i])
        if cnc_outline.check_outline_format(ai_figure[i]) == 2:
            r_figure.append(cnc_outline.ideal_outline(ai_figure[i], "{:s}.ol{:d}".format(ai_error_msg_id, i)))
        else:  # circle of format-B
            r_figure.append(ai_figure[i])
    return r_figure
Ejemplo n.º 3
0
def ideal_figure(ai_figure, ai_error_msg_id):
    """ apply the ideal_outline function to all outlines of the input figure
  """
    r_figure = []
    for i in range(len(ai_figure)):
        #print("dbg145:", ai_figure[i])
        if (cnc_outline.check_outline_format(ai_figure[i]) == 2):
            r_figure.append(
                cnc_outline.ideal_outline(
                    ai_figure[i], "{:s}.ol{:d}".format(ai_error_msg_id, i)))
        else:  # circle of format-B
            r_figure.append(ai_figure[i])
    return (r_figure)
Ejemplo n.º 4
0
def figure_simple_display(ai_figure,
                          ai_overlay_figure=[],
                          ai_parameter_info=""):
    """ Display the figure with red lines in the Tkinter Two_Canvas GUI
      If you want a finer control on the way outlines are displayed (color, width, overlay), you need to work at the outline level (not figure level)
  """
    print("Figure simple display with Tkinter")
    # convert all outlines in format-B
    # graphic layer
    graphic_figure = []
    i = 0
    for i_outline in ai_figure:
        if (cnc_outline.check_outline_format(i_outline) == 2):
            print(
                "WARN441: Warning, the outline {:d} must be converted in format-B with ideal_outline()!"
                .format(i))
            graphic_figure.append(
                cnc_outline.ideal_outline(i_outline, "figure_simple_display"))
        else:
            graphic_figure.append(i_outline)
        i += 1
    # overlay layer
    overlay_figure = []
    i = 0
    for i_outline in ai_overlay_figure:
        if (cnc_outline.check_outline_format(i_outline) == 2):
            print(
                "WARN442: Warning, the overlay outline {:d} must be converted in format-B with ideal_outline()!"
                .format(i))
            overlay_figure.append(
                cnc_outline.ideal_outline(i_outline,
                                          "figure_simple_display_overlay"))
        else:
            overlay_figure.append(i_outline)
        i += 1
    # start GUI
    tk_root = Tkinter.Tk()
    fsd_canvas = Two_Canvas(tk_root)

    # callback function for display_backend
    def sub_fsd_canvas_graphics(ai_rotation_direction, ai_angle_position):
        # angle position
        l_angle_position = float(ai_angle_position) / 100
        #
        r_canvas_graphics = []
        for ol in overlay_figure:
            rotated_ol = cnc_outline.outline_rotate(
                ol, 0, 0, l_angle_position
            )  # rotation of center (0,0) and angle l_angle_position
            r_canvas_graphics.append(
                ('overlay_lines', outline_arc_line(rotated_ol,
                                                   'tkinter'), 'orange', 2))
        for ol in graphic_figure:
            rotated_ol = cnc_outline.outline_rotate(
                ol, 0, 0, l_angle_position
            )  # rotation of center (0,0) and angle l_angle_position
            r_canvas_graphics.append(
                ('graphic_lines', outline_arc_line(rotated_ol,
                                                   'tkinter'), 'red', 1))
        return (r_canvas_graphics)

    # end of callback function
    fsd_canvas.add_canvas_graphic_function(sub_fsd_canvas_graphics)
    fsd_canvas.add_parameter_info(ai_parameter_info)
    tk_root.mainloop()
    del (tk_root, fsd_canvas)
    time.sleep(1.0)
    return (0)