Permalink
Browse files

view_wx + modifications for view_wx

  • Loading branch information...
baudvix committed Jul 3, 2012
1 parent dc278e2 commit deff327fddcb84a0b8c48617d51e9a7d9fc77155
Showing with 369 additions and 20 deletions.
  1. +2 −0 mcc/control/server.py
  2. +17 −0 mcc/model/map.py
  3. +13 −20 mcc/model/robot.py
  4. +337 −0 mcc/view/view_wx.py
View
@@ -75,6 +75,8 @@ def nxt_calibrated(self, handle, nxt_handle, x_axis, y_axis, yaw):
self.update_position(robo, x_axis, y_axis, yaw, True)
#NOTE TO SELF: use thread if this is a blocker
robo.data = Interpolate(robo.data, [x_axis, y_axis])
#TODO: Interpolate robo.trace
#TODO: notify(redraw=true)
print '#%d NXT calibrated #%d (%d, %d, %d)' % (handle,
nxt_handle,
x_axis, y_axis,
View
@@ -37,6 +37,19 @@ def __init__(self, name):
self.__max_dodge_count = 0
# self._expand [top,right,bottom,left]
self._expand = [0, 0, 0, 0]
self._need_redraw = False
#PROPERTY --- need_redraw
def fget_need_redraw(self):
"""The need_redraw property getter"""
with self._lock:
return self._need_redraw
def fset_need_redraw(self, value):
"""The need_redraw property setter"""
with self._lock:
self._need_redraw = value
need_redraw = property(fget_need_redraw, fset_need_redraw)
#PROPERTY --- expand
def fget_expand(self):
@@ -156,24 +169,28 @@ def _add_map_section(self, offset_x, offset_y):
for _ in range(0, offset_x):
if tmp_map_section.right_grid is None:
self._expand[1] += 1
self._need_redraw = True
tmp_map_section.right_grid = MapSection()
tmp_map_section = tmp_map_section.right_grid
elif offset_x < 0:
for _ in range(0, offset_x, -1):
if tmp_map_section.left_grid is None:
self._expand[3] += 1
self._need_redraw = True
tmp_map_section.left_grid = MapSection()
tmp_map_section = tmp_map_section.left_grid
if offset_y > 0:
for _ in range(0, offset_y):
if tmp_map_section.top_grid is None:
self._expand[0] += 1
self._need_redraw = True
tmp_map_section.top_grid = MapSection()
tmp_map_section = tmp_map_section.top_grid
elif offset_y < 0:
for _ in range(0, offset_y, -1):
if tmp_map_section.bottom_grid is None:
self._expand[2] += 1
self._need_redraw = True
tmp_map_section.bottom_grid = MapSection()
tmp_map_section = tmp_map_section.bottom_grid
View
@@ -123,13 +123,11 @@ def put(self, position, data_type, time=None):
"""
with self._lock:
if time is None:
self._data.append(DataNXT(position, data_type,
DataNXT.DATA_NXT_NEW))
self._data.append(DataNXT(position, data_type))
if data_type == map.POINT_FREE or data_type == map.POINT_TARGET:
self._trace.append(TraceNXT(position))
else:
self._data.append(DataNXT(position, data_type,
DataNXT.DATA_NXT_NEW, time))
self._data.append(DataNXT(position, data_type, time))
if data_type == map.POINT_FREE or data_type == map.POINT_TARGET:
self._trace.append(TraceNXT(position, time))
@@ -202,6 +200,9 @@ class TraceNXT(object):
The precessed NXT information as a Que
"""
TRACE_NXT_NEW = 0
TRACE_NXT_USED = 1
def __init__(self, position, time=None):
"""
Constructor for a new Trace element
@@ -211,6 +212,7 @@ def __init__(self, position, time=None):
else:
self._time = time
self._position = position
self._state = TraceNXT.TRACE_NXT_NEW
#PROPERTY --- time
def fget_time(self):
@@ -232,17 +234,19 @@ def fset_position(self, value):
self._position = value
position = property(fget_position, fset_position)
def use(self):
if not self._state == TraceNXT.TRACE_NXT_NEW:
return None
self._state = TraceNXT.TRACE_NXT_USED
return self
class DataNXT(object):
"""
Model of the unprocessed data
"""
DATA_NXT_NEW = 0
DATA_NXT_CURRENT = 1
DATA_NXT_CALIBRATED = 2
def __init__(self, point_position, point_type, status, time=None):
def __init__(self, point_position, point_type, time=None):
"""
Constructor for a new data element
"""
@@ -252,7 +256,6 @@ def __init__(self, point_position, point_type, status, time=None):
self._time = time
self._position = point_position
self._point_type = point_type
self._status = status
#PROPERTY --- time
def fget_time(self):
@@ -283,13 +286,3 @@ def fset_type(self, value):
"""The type property setter."""
self._point_type = value
point_type = property(fget_type, fset_type)
#PROPERTY --- status
def fget_status(self):
"""The status property getter."""
return self._status
def fset_status(self, value):
"""The status property setter."""
self._status = value
status = property(fget_status, fset_status)
Oops, something went wrong.

0 comments on commit deff327

Please sign in to comment.