Skip to content

Commit

Permalink
Merged remaining ui changes into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
nluzod committed Jul 15, 2013
1 parent 22a7935 commit 8cbe4c5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 28 deletions.
26 changes: 5 additions & 21 deletions display/tactical/tactical.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,6 @@ def update(self):

# Display targets
for target in self.data_proc.targets:

# Skip invalid targets
#if not target.valid:
#continue

self.displayTarget(target)

zone_distances = self.data_proc.tca.image_processors[0].scm.getCalibrationDistances()
Expand All @@ -59,36 +54,31 @@ def update(self):
target.left_alert = False

if distance((0, 0), target.pos) >= zone_distances[1] and target.left_alert == False:
self.data_proc.tca.ui.displayAlert("Target has left the ALERT zone!!!")
self.data_proc.tca.ui.logAlert("Target has left the ALERT zone!!!")
self.data_proc.tca.ui.displayAlert("Target %i has left the ALERT zone!!!" % (target.id_value))
self.data_proc.tca.ui.logAlert("Target %i has left the ALERT zone!!!" % (target.id_value))
target.left_alert = True
target.left_safe = True
elif distance((0, 0), target.pos) >= zone_distances[0] and target.left_safe == False:
self.data_proc.tca.ui.displayAlert("Target has entered the ALERT zone!!!")
self.data_proc.tca.ui.logAlert("Target has entered the ALERT zone!!!")
self.data_proc.tca.ui.displayAlert("Target %i has entered the ALERT zone!!!" % (target.id_value))
self.data_proc.tca.ui.logAlert("Target %i has entered the ALERT zone!!!" % (target.id_value))
target.left_safe = True

def displayTarget(self, target):
# Remap target position
target_pos = self.remapPosition(target.pos)
#logging.debug("Mapped pos: (%d, %d)" % (target_pos[0], target_pos[1]))
target_pos_points = self.getBoundingBox(0.25, pos=target_pos)
#id_pos = [target_pos[0] + TacticalDisplay.PADDING + TacticalDisplay.LABEL_OFFSET[0],
# target_pos[1] + TacticalDisplay.PADDING + TacticalDisplay.LABEL_OFFSET[1]]
#id_value = "Child 1"
label_pos = [
target_pos[0] + TacticalDisplay.PADDING - TacticalDisplay.LABEL_OFFSET[0],
target_pos[1] + TacticalDisplay.PADDING - TacticalDisplay.LABEL_OFFSET[1]]
label_text = "(%.2f, %.2f)" % (target.pos[0], target.pos[1])
label_text = "%i:(%.2f, %.2f)" % (target.id_value,target.pos[0], target.pos[1])


# Display target and track
if target not in self.tgtTracks:
# Create target icon
tgtTrack = TargetTrack(target)
tgtTrack.icon = self.canvas.create_oval(target_pos_points, fill="#AA66CC", outline="black", width=3)
# Create target ID
#tgtTrack.id = tk.Label(self.canvas, text="Child #", bg="white", anchor='center')
# Create label
tgtTrack.label = tk.Label(self.canvas, text=label_text, bg='white', anchor='s')
# Add label_toggle
Expand Down Expand Up @@ -125,17 +115,14 @@ def displayTarget(self, target):

# Update target label
tgtTrack.label.config(text=label_text)
#tgtTrack.id.config(text=id_value)

# Toggle visibility
if tgtTrack.display_label:
tgtTrack.label.place(x=label_pos[0], y=label_pos[1])
#tgtTrack.id.place(x=id_pos[0], y=label_pos[1])
else:
tgtTrack.label.place_forget()

tgtTrack.label_pos = label_pos
#tgtTrack.id_pos = id_pos

# Draw prediction line and label
if tgtTrack.target.predLineIntersect:
Expand Down Expand Up @@ -261,9 +248,6 @@ def __init__(self, target):
self.display_label = True
self.icon_prediction = None
self.label_prediction = None
#self.id = None
#self.id_pos = None
#self.display_id = True

def removeDisplayObjects(self, canvas):
canvas.delete(self.icon)
Expand Down
11 changes: 4 additions & 7 deletions processors/data/target.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,12 @@ class Target(object):
PREDICTION_RADIUS = 12
SAFE_RADIUS = 5
TURN_THRESHOLD_DEGREES = 4
ID = 0

def __init__(self, pos, config=None, ttm=None):
self.pos = pos
self.id_value = Target.ID
Target.ID += 1
self.ttm = ttm
self.kalman = None
self.prediction = None
Expand Down Expand Up @@ -51,12 +54,6 @@ def __init__(self, pos, config=None, ttm=None):
zone_distances = self.ttm.data_processor.tca.image_processors[0].scm.getCalibrationDistances()
Target.PREDICTION_RADIUS = zone_distances[2]
Target.SAFE_RADIUS = zone_distances[1]
# if config.get('calibration', 'zone_size') == 'NORMAL':
# Target.PREDICTION_RADIUS = DISTANCES_NORMAL[2]
# Target.SAFE_RADIUS = DISTANCES_NORMAL[1]
# elif config.get('calibration', 'zone_size') == 'SMALL':
# Target.PREDICTION_RADIUS = DISTANCES_SMALL[2]
# Target.SAFE_RADIUS = DISTANCES_SMALL[1]

def update(self, pos):

Expand Down Expand Up @@ -179,7 +176,7 @@ def VerifyValidity(pos):

#This function computes the distance between two points
def distance(p1, p2):
return math.sqrt((p2[0] - p1[0])**2 + (p2[1] - p1[1])**2)
return math.sqrt((p2[0] - p1[0])**2 + (p2[1] - p1[1])**2)

def angle_diff(a, b):
# given two cartesian points on a circle
Expand Down

0 comments on commit 8cbe4c5

Please sign in to comment.