Example #1
0
    def shortestPathXY(start, end, neighbor_map, vh_set, point_map, grid_type,
                       scale_factor, radius):
        # TODO[NF]:  Docstring
        x_y_path = []
        coordinate_path = ShortestPathHelper.shortestPathAStar(
            start=start,
            end=end,
            neighbor_map=neighbor_map,
            vh_set=vh_set,
            point_map=point_map)
        for node in coordinate_path:
            row = -node[0]
            column = node[1]
            if grid_type is GridType.HONEYCOMB:
                parity = 0 if HoneycombDnaPart.isOddParity(
                    row=row, column=column) else 1
                node_pos = HoneycombDnaPart.latticeCoordToPositionXY(
                    radius=radius,
                    row=row,
                    column=column,
                    scale_factor=scale_factor)
            else:
                parity = None
                node_pos = SquareDnaPart.latticeCoordToPositionXY(
                    radius=radius,
                    row=row,
                    column=column,
                    scale_factor=scale_factor)
            x_y_path.append((node_pos[0], node_pos[1], parity))

        return x_y_path
Example #2
0
def testCreateVirtualHelixGui(cnapp):
    """Create some VHs"""
    # Create a new Honeycomb part
    toolbar = cnapp.window.main_toolbar
    action_new_honeycomb = toolbar.widgetForAction(cnapp.window.action_new_dnapart_honeycomb)
    QTest.mouseClick(action_new_honeycomb, Qt.LeftButton, delay=DELAY)

    slicerootitem = cnapp.window.slice_root
    assert len(slicerootitem.instance_items) == 1
    slice_part_item = list(slicerootitem.instance_items.values())[0]
    QTest.keyClick(cnapp.window, Qt.Key_H, delay=DELAY)
    QTest.keyClick(cnapp.window, Qt.Key_C, delay=DELAY)
    cnapp.processEvents()

    cmd_count = 1  # already added the part
    for row in range(-2, 2):
        for col in range(-2, 2):
            # print(row, col)
            x, y = HoneycombDnaPart.latticeCoordToPositionXY(RADIUS, row, col)
            pt = QPointF(x, y)
            cnapp.graphicsItemClick(slice_part_item, Qt.LeftButton, pos=pt, delay=DELAY)
            cmd_count += 1
    cnapp.processEvents()

    vh_count = len(cnapp.document.activePart().getidNums())

    # undo and redo all
    for i in range(cmd_count):
        cnapp.document.undoStack().undo()
    cnapp.processEvents()
    for i in range(cmd_count):
        cnapp.document.undoStack().redo()
    cnapp.processEvents()

    part = list(cnapp.document.children())[0]
    vh_count_after_redo = len(part.getidNums())

    assert vh_count == vh_count_after_redo