Example #1
0
def plot_var_list(file, object):

    box_width = find_width(object)

    # Plot variable framing box first
    plot_var_frame(file, box_width, object)

    # Plot text
    plot_var_text_list(file, object)
Example #2
0
def plot_meth_list(file, object):

    box_width = find_width(object)

    # Plot methods framing box first
    plot_meth_frame(file, box_width, object)

    # Plot text
    plot_meth_text_list(file, object)
Example #3
0
def plot_use_list(file, object):

    box_width = find_width(object)

    # Plot use statements framing box first
    plot_use_frame(file, box_width, object)

    # Plot text
    plot_use_text_list(file, object)
def plot_object_start_compound(file, object):

    box_width = find_width(object)
    box_height = find_height(object)

    file.write("6 %9d %9d %9d %9d\n" % (                                   \
       object.x0             * Const.XFIG_SCALE - Const.COMPOUND_MARGIN,   \
       object.y0             * Const.XFIG_SCALE - Const.COMPOUND_MARGIN,   \
      (object.x0+box_width)  * Const.XFIG_SCALE + Const.COMPOUND_MARGIN,   \
      (object.y0+box_height) * Const.XFIG_SCALE + Const.COMPOUND_MARGIN))
Example #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)
Example #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)
Example #7
0
def find_coordinates(obj_list, box_margins):

    print("Setting objects' coordinates ... ")

    # Grid coordinates
    n_row = 0
    n_col = 0
    for o in range(len(obj_list)):
        n_row = max(n_row, obj_list[o].row)
        n_col = max(n_col, obj_list[o].column)

    widths = [0] * (n_col + 1)
    heights = [0] * (n_row + 1)
    grid.x = [0] * (n_col + 2)
    grid.y = [0] * (n_row + 2)

    for o in range(len(obj_list)):
        row = obj_list[o].row
        col = obj_list[o].column
        widths[col]  = max(widths [col], find_width (obj_list[o])  \
                     + box_margins * 2.0)
        heights[row] = max(heights[row], find_height(obj_list[o])  \
                     + box_margins * 2.0)

    for o in range(len(obj_list)):
        row = obj_list[o].row
        col = obj_list[o].column
        grid.x[col] = sum(widths[0:col])
        grid.y[row] = sum(heights[0:row])
    grid.x[n_col + 1] = sum(widths)
    grid.y[n_row + 1] = sum(heights)

    # Find object coordinates
    for o in range(len(obj_list)):
        row = obj_list[o].row
        col = obj_list[o].column
        xc = (grid.x[col] + grid.x[col + 1]) * 0.5
        yc = (grid.y[row] + grid.y[row + 1]) * 0.5
        obj_list[o].x0 = xc - obj_list[o].w * 0.5
        obj_list[o].y0 = yc - obj_list[o].h * 0.5
        obj_list[o].x1 = xc + obj_list[o].w * 0.5
        obj_list[o].y1 = yc + obj_list[o].h * 0.5