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
def showCreateHint(self, coord, next_idnums=(0, 1), show_hint=True, color=None): point_item = self.points_dict.get(coord, None) if point_item is None: return if show_hint is False: point_item.showCreateHint(show_hint=False) if point_item: row, column = coord if self.grid_type is GridType.HONEYCOMB: parity = 0 if HoneycombDnaPart.isOddParity( row=row, column=column) else 1 elif self.grid_type is GridType.SQUARE: parity = 0 if SquareDnaPart.isEvenParity(row=row, column=column) else 1 else: return id_num = next_idnums[1] if parity else next_idnums[0] point_item.showCreateHint(id_num=id_num, show_hint=show_hint, color=color) return parity == 1
def _getCoordinateParity(self, row, column): if self.griditem.grid_type is GridType.HONEYCOMB: return 0 if HoneycombDnaPart.isOddParity(row=row, column=column) else 1 elif self.griditem.grid_type is GridType.SQUARE: return 0 if SquareDnaPart.isEvenParity(row=row, column=column) else 1 else: return None