def crop(self, rect: Rectangle): ''' The function "crop" return list containing graph if all nodes of graph located in given rectangle and an empty list otherwise :param rect: Rectangle class object :return: list containing GraphNodes class object or empty list ''' is_all_nodes_inside = all(rect.contains_point_location(node.location) for node in self._nodes.values()) return [self] if is_all_nodes_inside else []
def crop(self, rect: Rectangle): for i, keypoint in enumerate(self.points): if not rect.contains_point_location(keypoint.location): # Keypoints is complex object and all nodes are important. Crop element - crop all return [] return [deepcopy(self)]
def crop(self, rect: Rectangle): is_all_nodes_inside = all( rect.contains_point_location(node.location) for node in self._nodes.values()) return [self] if is_all_nodes_inside else []