From 5049d4c8a05d3f9b72f4c7e048e94b753713beda Mon Sep 17 00:00:00 2001 From: Sébastien Dailly Date: Sat, 27 Sep 2014 12:13:38 +0200 Subject: Added navigation tree management --- qml/python/transformations.py | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'qml/python/transformations.py') diff --git a/qml/python/transformations.py b/qml/python/transformations.py index 3bb9383..40aafc0 100644 --- a/qml/python/transformations.py +++ b/qml/python/transformations.py @@ -123,3 +123,32 @@ class Symmetry(object): "RIGHT": self.board.side["LEFT" if self.x_flip else "RIGHT"], "BOTTOM":self.board.side["TOP" if self.y_flip else "BOTTOM"] } + +class ToIndex(object): + """" Transform each point position in point index. + """ + + def __init__(self, board): + self.board = board + + def is_valid(self): + """ This transformation is always valid. + """ + return True; + + def apply_points(self, coord, name = None): + """ + """ + x_size = min(19, self.board.max_x - self.board.min_x + 1) + x, y = coord + return (x - self.board.min_x) + (y - self.board.min_y) * x_size + + def get_new_size(self): + """ The size is not changed. + """ + return self.board.min_x, self.board.min_y, self.board.max_x, self.board.max_y + + def get_new_side(self): + """ There is no changes on the sides. + """ + return self.board.side -- cgit v1.2.3