Example #1
0
 def shortestPathXY(start, end, vh_set, grid_type, scale_factor,
                    part_radius):
     # TODO[NF]:  Docstring
     assert part_radius == DEFAULT_RADIUS
     x_y_path = []
     coordinate_path = ShortestPathHelper.shortestPathAStar(
         start=start,
         end=end,
         vh_set=vh_set,
         part_radius=part_radius,
         grid_type=grid_type,
         scale_factor=scale_factor)
     for node in coordinate_path:
         row = -node[0]
         column = node[1]
         if grid_type is GridEnum.HONEYCOMB:
             parity = 0 if HoneycombDnaPart.isEvenParity(
                 row=row, column=column) else 1
             node_pos = HoneycombDnaPart.latticeCoordToModelXY(
                 radius=part_radius, row=row, column=column)
         else:
             parity = None
             node_pos = SquareDnaPart.latticeCoordToModelXY(
                 radius=part_radius, row=row, column=column)
         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.latticeCoordToModelXY(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
Example #3
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.views['slice'].root_item
    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.latticeCoordToModelXY(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