Пример #1
0
def plot_grid(file, obj_list):

    # Print a comment
    write_comment(file, "Grid", 5)

    min_v = 0
    max_v = max(grid.x)
    min_h = 0
    max_h = max(grid.y)

    # Plot grid

    # Plot vertical lines
    for i in range(len(grid.x)):
        plot_line(file, grid.x[i], min_h, grid.x[i], max_h, Const.COLOR_GRID,
                  500)

    # Plot horizontal lines
    for j in range(len(grid.y)):
        plot_line(file, min_v, grid.y[j], max_v, grid.y[j], Const.COLOR_GRID,
                  500)

    # Plot coordinates of each spot in grid
    for i in range(len(grid.x) - 1):
        for j in range(len(grid.y) - 1):
            plot_text(file, "Right",                     \
                      grid.x[i+1]-0.5, grid.y[j]+0.5,  \
                      "({}, {})".format(i, j),         \
                      Const.FONT_NORMAL, Const.COLOR_GRID, 500)
Пример #2
0
def plot_use_text_list(file, object):

    for i in range(object.N_Uses()):
        plot_text(file, "Left",                                          \
                  object.x0 + Const.UNIT_BOX_HEIGHT*0.333,               \
                  object.y0 + Const.UNIT_BOX_HEIGHT*object.N_Types()     \
                            + Const.UNIT_BOX_HEIGHT*(i+1)                \
                            + Const.UNIT_BOX_HEIGHT*0.75,                \
                  object.uses[i], Const.FONT_NORMAL, "Black", 10)
Пример #3
0
def plot_type_text_list(file, object):

  if object.N_Types() != 0:
    for i in range(object.N_Types()):
      plot_text(file, "Left",                                    \
                object.x0 + Const.UNIT_BOX_HEIGHT*0.333,         \
                object.y0 + Const.UNIT_BOX_HEIGHT*(i+1)          \
                          + Const.UNIT_BOX_HEIGHT*0.75,          \
                object.types[i], Const.FONT_HEADER, "Black", 10)
Пример #4
0
def plot_var_text_list(file, object):

    if not object.vars_hidden:
        for i in range(object.H_Vars()):
            plot_text(file, "Left",                                         \
                      object.x0 + Const.UNIT_BOX_HEIGHT*0.333,              \
                      object.y0 + Const.UNIT_BOX_HEIGHT*object.N_Types()    \
                                + Const.UNIT_BOX_HEIGHT*object.N_Uses()     \
                                + Const.UNIT_BOX_HEIGHT*(i+1)               \
                                + Const.UNIT_BOX_HEIGHT*0.75,               \
                      object.vars[i], Const.FONT_NORMAL, "Black", 10)
Пример #5
0
def plot_legend(file, obj_list, x0, y0):

    # Print a comment
    write_comment(file, "Legend", 5)

    p = ""  # path
    u = []  # use
    v = []  # var
    m = []  # methods
    c = []  # calls
    mobject = Module("       Module       ", p, u, v, m, c, [])
    mobject.x0 = x0
    mobject.y0 = y0
    sobject = Subroutine("     Subroutine     ", p, u, v, m, c, [])
    sobject.x0 = x0
    sobject.y0 = y0 + Const.UNIT_BOX_HEIGHT
    fobject = Function("      Function      ", p, u, v, m, c, [], "")
    fobject.x0 = x0
    fobject.y0 = y0 + Const.UNIT_BOX_HEIGHT * 2
    pobject = Program("      Program       ", p, u, v, m, c, [])
    pobject.x0 = x0
    pobject.y0 = y0 + Const.UNIT_BOX_HEIGHT * 3
    text_height = Const.UNIT_BOX_HEIGHT
    text_width = find_width(sobject)

    # Boxes
    plot_object_name(file, mobject)
    plot_object_name(file, sobject)
    plot_object_name(file, fobject)
    plot_object_name(file, pobject)

    # Splines
    plot_spline_legend(file,                                           \
                       x0,  y0+Const.UNIT_BOX_HEIGHT*5.5, text_width,  \
                       "Continuous")
    plot_spline_legend(file,                                           \
                       x0, y0+Const.UNIT_BOX_HEIGHT*7.0, text_width,   \
                       "Dashed")
    plot_text(file, "Center",                   \
              x0 + text_width*0.5,              \
              y0 + Const.UNIT_BOX_HEIGHT*4.5    \
                 + Const.UNIT_BOX_HEIGHT*0.75,  \
              " Use statements ", Const.FONT_HEADER, "Black", 10)
    plot_text(file, "Center",                   \
              x0 + text_width*0.5,              \
              y0 + Const.UNIT_BOX_HEIGHT*6.0    \
                 + Const.UNIT_BOX_HEIGHT*0.75,  \
              " Call statements ", Const.FONT_HEADER, "Black", 10)
Пример #6
0
def plot_object_name(file, object):

    box_width = find_width(object)

    # Plot module framing box first
    plot_title_frame(file, object, box_width, Const.UNIT_BOX_HEIGHT)

    # Plot name
    full_name = " " + object.name
    if object.Type() == "Function":
        full_name = " " + object.fun_type + " " + object.name

    plot_text(file, "Center",                          \
              object.x0 + box_width*0.5,               \
              object.y0 + Const.UNIT_BOX_HEIGHT*0.75,  \
              full_name, Const.FONT_HEADER, "Black", 10)