Ejemplo n.º 1
0
    # generate Ladybug objects for the graphic
    lb_meshes = [to_mesh3d(mesh) for mesh in _mesh]
    lb_mesh = Mesh3D.join_meshes(lb_meshes)
    graphic = GraphicContainer(values,
                               lb_mesh.min,
                               lb_mesh.max,
                               legend_par_,
                               data_type=header.data_type,
                               unit=header.unit)

    # set titles and set default colors and color ranges
    if graphic.legend_parameters.are_colors_default:
        graphic.legend_parameters.colors = colors_from_data_type(
            header.data_type)
    if isinstance(header.data_type, TemperatureDelta) and graphic.legend.is_min_default \
            and graphic.legend.is_max_default:
        graphic.legend_parameters.min = -5
        graphic.legend_parameters.max = 5
    graphic.legend_parameters.title = header.unit
    global_title = '{}\n{}'.format(header.data_type.name, time_text)
    title = text_objects(global_title, graphic.lower_title_location,
                         graphic.legend_parameters.text_height * 1.5,
                         graphic.legend_parameters.font)

    # draw rhino objects
    lb_mesh.colors = graphic.value_colors
    mesh = from_mesh3d(lb_mesh)
    legend = legend_objects(graphic.legend)
    colors = [color_to_color(col) for col in lb_mesh.colors]
Ejemplo n.º 2
0
            22 - Black to White
            23 - Blue, Green, Red
            24 - Multicolored 2
            25 - Multicolored 3
    
    Returns:
        colors: A series of colors to be plugged into the "LB Legend Parameters"
            component.
"""

ghenv.Component.Name = 'LB Color Range'
ghenv.Component.NickName = 'ColRange'
ghenv.Component.Message = '1.0.0'
ghenv.Component.Category = 'Ladybug'
ghenv.Component.SubCategory = '4 :: Extra'
ghenv.Component.AdditionalHelpFromDocStrings = '1'

try:
    from ladybug.color import Colorset
except ImportError as e:
    raise ImportError('\nFailed to import ladybug:\n\t{}'.format(e))

try:
    from ladybug_rhino.color import color_to_color
except ImportError as e:
    raise ImportError('\nFailed to import ladybug_rhino:\n\t{}'.format(e))

_index_ = _index_ or 0
cs = Colorset()
colors = [color_to_color(col) for col in cs[_index_]]
                                              month_chart.y_axis_label_points1)
    ]
    labels = label1 + label2

    # process the second y axis if it exists
    if month_chart.y_axis_title_text2 is not None:
        y2_txt = month_chart.y_axis_title_text2 if len(
            y_axis_title_) <= 1 else y_axis_title_[1]
        y_title2 = text_objects(y2_txt, month_chart.y_axis_title_location2,
                                txt_hgt, font)
        y_title = [y_title, y_title2]
        label3 = [
            text_objects(txt, Plane(o=Point3D(pt.x, pt.y, z_val)), txt_hgt,
                         font, 0, 3) for txt, pt in
            zip(month_chart.y_axis_labels2, month_chart.y_axis_label_points2)
        ]
        labels = labels + label3

    # if there are colored lines, then process them to be output from the component
    if month_chart.time_interval == 'MonthlyPerHour':
        cols = [color_to_color(col) for col in month_chart.colors]
        col_lines, month_count = [], len(data_lines) / len(_data)
        for i, pline in enumerate(data_lines):
            col_line = ColoredPolyline(pline)
            col_line.color = cols[int(i / month_count)]
            col_line.thickness = 3
            col_lines.append(col_line)
        # CWM: I don't know why we have to re-schedule the solution but this is the
        # only way I found to get the colored polylines to appear (redraw did not work).
        schedule_solution(ghenv.Component, 2)
Ejemplo n.º 4
0
if all_required_inputs(ghenv.Component):
    # extract any faces from input Rooms or Models
    faces = []
    for hb_obj in _hb_objs:
        if isinstance(hb_obj, Model):
            for room in hb_obj.rooms:
                faces.extend(room.faces)
                faces.extend(room.shades)
            faces.extend(hb_obj.orphaned_faces)
            faces.extend(hb_obj.orphaned_apertures)
            faces.extend(hb_obj.orphaned_doors)
            faces.extend(hb_obj.orphaned_shades)
        elif isinstance(hb_obj, Room):
            faces.extend(hb_obj.faces)
            faces.extend(hb_obj.shades)
        else:
            faces.append(hb_obj)

    # create the ColorFace visualization object and output geometry
    color_obj = ColorFace(faces, _attribute, legend_par_)
    graphic = color_obj.graphic_container
    mesh = [from_face3ds_to_colored_mesh([fc], col) for fc, col in
            zip(color_obj.flat_geometry, graphic.value_colors)]
    wire_frame = []
    for face in color_obj.flat_faces:
        wire_frame.extend(from_face3d_to_wireframe(face.geometry))
    legend = legend_objects(graphic.legend)
    values = color_obj.attributes
    colors = [color_to_color(col) for col in graphic.value_colors]
Ejemplo n.º 5
0
except ImportError as e:
    raise ImportError('\nFailed to import ladybug:\n\t{}'.format(e))

try:
    from ladybug_rhino.togeometry import to_plane
    from ladybug_rhino.fromobjects import legend_objects
    from ladybug_rhino.color import color_to_color
    from ladybug_rhino.grasshopper import all_required_inputs
except ImportError as e:
    raise ImportError('\nFailed to import ladybug_rhino:\n\t{}'.format(e))


if all_required_inputs(ghenv.Component):
    # set default values
    legend_par_ = legend_par_.duplicate() if legend_par_ is not None else \
        LegendParameters()
    if _base_plane_:
        legend_par_.base_plane = to_plane(_base_plane_)
    legend_par_.title = title_

    # create the legend
    legend = Legend(_values, legend_par_)

    # separate all of the outputs from this component
    rhino_objs = legend_objects(legend)
    mesh = rhino_objs[0]
    title_obj = rhino_objs[1]
    label_objs = rhino_objs[2:]
    label_text = legend.segment_text
    colors = [color_to_color(col) for col in legend.value_colors]