Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpmoxhay <pmoxhay@earthlink.net>2009-06-06 00:06:19 (GMT)
committer pmoxhay <pmoxhay@earthlink.net>2009-06-06 00:06:19 (GMT)
commit97883fcc589d7b84e7a995c45cfb03f180410c7a (patch)
treebf86259474d504dac0d7c06ccdbf3dd73279af48
parent09db6111e8610c4d3aa7440751641eb2bb7890da (diff)
Fixed some issues with amount comparisons.
-rw-r--r--TODO2
-rw-r--r--amountobject.py6
-rw-r--r--amountproblem.py49
-rw-r--r--compare3lesson.py2
-rw-r--r--groupobject.py119
5 files changed, 43 insertions, 135 deletions
diff --git a/TODO b/TODO
index bcb363c..4c13c1a 100644
--- a/TODO
+++ b/TODO
@@ -22,6 +22,6 @@ Compare3 Lesson
- Fix behavior of line segments (drops getting rejected).
- Volume comparison: fit into answer box.
+ Amount comparison: fit into answer box (maybe make wider and reposition).
-+ Amount comparison: refine appearance of object groups.
+- Amount comparison: refine appearance of object groups.
- Amount comparison: refine appearance of model (make pagelike).
diff --git a/amountobject.py b/amountobject.py
index dfe8f0c..9e5c5f5 100644
--- a/amountobject.py
+++ b/amountobject.py
@@ -39,7 +39,11 @@ class AmountObject(MovableObject):
self.container = container
+ self.amount_scale = 1.0
+
def draw(self, cr):
+ cr.scale(self.amount_scale, self.amount_scale)
+
if self.shape == 'circle':
self.draw_circle(cr, self.color)
elif self.shape == 'square':
@@ -48,7 +52,7 @@ class AmountObject(MovableObject):
self.draw_triangle(cr, self.color)
def get_bounds(self):
- return self.pos + Vector(-50, -50), self.pos + Vector(50, 50)
+ return (self.pos + Vector(-50, -50)).scaled(self.amount_scale), (self.pos + Vector(50, 50)).scaled(self.amount_scale)
def draw_shape(self, cr):
# Draw the fill.
diff --git a/amountproblem.py b/amountproblem.py
index bea98cd..20143d7 100644
--- a/amountproblem.py
+++ b/amountproblem.py
@@ -96,7 +96,7 @@ class AmountProblem(Problem):
# Uncomment to place the upper shape in a pair.
#self.shape1_in_pair = True
- #problem_number = 1
+ #self.problem_number = 6
#print "problem_number =", problem_number
if self.problem_number == 0:
@@ -288,7 +288,7 @@ class AmountProblem(Problem):
return new_vectors
def place_objects_in_final_positions(self):
- #print "place_objects_in_final_positions called"
+ #print "AmountProblem: place_objects_in_final_positions called"
x_initial = 100
i = 0
for o in self.container.objects:
@@ -302,25 +302,35 @@ class AmountProblem(Problem):
o.selected = False
o.selectable = False
o.draggable = False
- i += 1
+ i += 1
+ #print "There were ", i ,"GroupObjects placed into final position."
j = 0
for o in self.container.objects:
if isinstance(o, AmountObject):
if self.shape1_in_pair:
- o.scale = 0.65
- o.pos = Vector(x_initial + i * 250 + 75 + j * 250, 450 + 225)
+ #print "Got to (1)"
+ o.amount_scale = 0.65
+ #o.pos = Vector(x_initial + i * 250 + 75 + j * 250, 450 + 225)
+ o.move(Vector(x_initial + i * 250 + 75 + j * 250, 450 + 225))
else:
- o.scale = 0.65
+ #print "Got to (2)"
+ o.amount_scale = 0.65
#o.move(Vector(x_initial + i * 150 + 125 + j * 150, 450 + 225))
if self.n_shape1 > self.n_shape2:
- o.pos = Vector(x_initial + i * 150 + 75 + j * 150, 350 + 225)
+ #print "self.n_shape1 > self.n_shape2"
+ #o.pos = Vector(x_initial + i * 150 + 75 + j * 150, 350 + 225)
+
+ o.move(Vector(x_initial + i * 150 + 75 + j * 150, 350 + 225))
else:
- o.pos = Vector(x_initial + i * 150 + 75 + j * 150, 450 + 225)
+ #print "self.n_shape1 < self.n_shape2"
+ #o.pos = Vector(x_initial + i * 150 + 75 + j * 150, 450 + 225)
+ o.move(Vector(x_initial + i * 150 + 75 + j * 150, 450 + 225))
o.selected = False
o.selectable = False
o.draggable = False
- j += 1
+ j += 1
+ #print "There were ", j ,"AmountObjects placed into final position."
def finish_problem_stage1(self):
#print "AmountProblem: finish_problem_stage1 called"
@@ -360,12 +370,20 @@ class AmountProblem(Problem):
#print "Amount Problem: check_problem_solved adding a group"
#print " New x =", (self.shape1[i].pos.x + self.shape2[j].pos.x)/2
#print " New y =", (self.shape1[i].pos.y + self.shape2[j].pos.y)/2
+
+ #self.group_object = GroupObject( Vector((self.shape1[i].pos.x + self.shape2[j].pos.x)/2 - 50, \
+ # (self.shape1[i].pos.y + self.shape2[j].pos.y)/2 - 100), \
+ # Vector(125, 200), self.shape1[i].color, self.shape1_name, \
+ # self.shape2[j].color, self.shape2_name, False, self.container)
+
self.group_object = GroupObject( Vector((self.shape1[i].pos.x + self.shape2[j].pos.x)/2 - 50, \
- (self.shape1[i].pos.y + self.shape2[j].pos.y)/2 - 100), \
+ 300), \
Vector(125, 200), self.shape1[i].color, self.shape1_name, \
self.shape2[j].color, self.shape2_name, False, self.container)
+
+
self.group_object.selectable = True
- #self.group_object.selected = True
+
self.container.moons_visible = False
self.amount_letter1.symbol_visible = False
@@ -414,12 +432,17 @@ class AmountProblem(Problem):
Vector.approx_equal(self.shape1[i].pos, self.shape2[j].pos, 100) and \
Vector.approx_equal(self.shape1[k].pos, self.shape2[j].pos, 100):
+ #self.group_object = GroupObject( Vector((self.shape1[i].pos.x + self.shape2[j].pos.x)/2 - 50, \
+ # (self.shape1[i].pos.y + self.shape2[j].pos.y)/2 - 100), \
+ # Vector(125, 200), self.shape1[i].color, self.shape1_name, \
+ # self.shape2[j].color, self.shape2_name, True, self.container)
+
self.group_object = GroupObject( Vector((self.shape1[i].pos.x + self.shape2[j].pos.x)/2 - 50, \
- (self.shape1[i].pos.y + self.shape2[j].pos.y)/2 - 100), \
+ 300), \
Vector(125, 200), self.shape1[i].color, self.shape1_name, \
self.shape2[j].color, self.shape2_name, True, self.container)
+
self.group_object.selectable = True
- #self.group_object.selected = True
self.container.moons_visible = False
self.amount_letter1.symbol_visible = False
diff --git a/compare3lesson.py b/compare3lesson.py
index 0fbbe13..1a661b2 100644
--- a/compare3lesson.py
+++ b/compare3lesson.py
@@ -168,7 +168,7 @@ class Compare3Lesson(ObjectArea):
#print "self.recently_used = ", self.recently_used
# Uncomment this to choose a particular problem type.
- #self.problem_type = 'volume'
+ #self.problem_type = 'amount'
if self.problem_type == 'length':
self.problem = LengthProblem(self, self.color_scheme, (self.alphabetical_letter1, self.alphabetical_letter2) )
diff --git a/groupobject.py b/groupobject.py
index 97b3cc6..2670cb0 100644
--- a/groupobject.py
+++ b/groupobject.py
@@ -24,14 +24,12 @@ OVAL_SVG = rsvg.Handle('oval.svg')
from movableobject import MovableObject
-
# Class containing various standard colors. Each color is a 3 element tuple.
class Color:
BLUE = (0.25, 0.25, 0.75)
GREEN = (0.25, 0.75, 0.25)
RED = (0.75, 0.25, 0.25)
-
class GroupObject(MovableObject):
"""Draggable group of discrete shapes."""
@@ -124,49 +122,6 @@ class GroupObject(MovableObject):
cr.restore()
def draw_moon(self, cr, pos, scale):
- #MOON = [ Vector(0, 0),
- # Vector(1, -8),
- # Vector(4, -15),
- # Vector(10, -22),
- # Vector(14, -25),
- # Vector(21, -29),
- # Vector(29, -32),
- # Vector(24, -29),
- # Vector(19, -25),
- # Vector(15, -22),
- # Vector(10, -15),
- # Vector(6, -8),
- # Vector(5, 0),
- # Vector(6, 8),
- # Vector(10, 15),
- # Vector(15, 22),
- # Vector(19, 25),
- # Vector(24, 29),
- # Vector(29, 32),
- # Vector(21, 29),
- # Vector(14, 25),
- # Vector(10, 22),
- # Vector(4, 15),
- # Vector(1, 8),
- # Vector(0, 0) ]
- #
- #self.scale = scale
- #
- #cr.save()
- #
- #cr.move_to(self.pos.x + pos.x + self.scale.x * MOON[0].x, self.pos.y + pos.y + self.scale.y * MOON[0].y)
- #
- #for i in range (1, len(MOON)):
- # cr.line_to(self.pos.x + pos.x + self.scale.x * MOON[i].x, self.pos.y + pos.y + self.scale.y * MOON[i].y)
- #
- #cr.close_path()
- #
- #cr.set_source_rgb(0, 0, 0)
- #
- #cr.fill()
- #
- #cr.restore()
-
cr.save()
cr.translate(self.pos.x - 20, self.pos.y + 62)
cr.scale(0.7, 0.7)
@@ -174,42 +129,6 @@ class GroupObject(MovableObject):
cr.restore()
def draw_oval(self, cr, pos, scale):
- #OVAL = [ Vector(0, 36),
- # Vector(2, 27),
- # Vector(5, 18),
- # Vector(11, 9),
- # Vector(24, 1),
- # Vector(98, 1),
- # Vector(111, 9),
- # Vector(116, 18),
- # Vector(119, 27),
- # Vector(121, 36),
- # Vector(119, 45),
- # Vector(116, 54),
- # Vector(111, 63),
- # Vector(98, 72),
- # Vector(24, 72),
- # Vector(11, 63),
- # Vector(5, 54),
- # Vector(2, 45),
- # Vector(0, 36) ]
- #
- #self.scale = scale
- #
- #cr.save()
- #cr.set_source_rgb(0, 0, 0)
- #cr.set_line_width(2.0)
- #
- #cr.move_to(self.pos.x + pos.x + self.scale.x * OVAL[0].x, self.pos.y + pos.y + self.scale.y * OVAL[0].y)
- #
- #for i in range (1, len(OVAL)):
- # cr.line_to(self.pos.x + pos.x + self.scale.x * OVAL[i].x, self.pos.y + pos.y + self.scale.y * OVAL[i].y)
- #
- #cr.close_path()
- #cr.stroke()
- #
- #cr.restore()
-
cr.save()
cr.translate(self.pos.x + 16, self.pos.y)
cr.scale(1.42, 1.24)
@@ -297,22 +216,6 @@ class GroupObject(MovableObject):
rounded = 20
cr.save()
-
- # Make the path of rounded rectangle.
- #cr.move_to(pos.x + rounded, pos.y)
- #cr.line_to(pos.x + w - rounded, pos.y)
- #cr.arc(pos.x + w - rounded, pos.y + rounded, rounded, -math.pi/2, 0)
- #cr.line_to(pos.x + w, pos.y + h - rounded)
- #cr.arc(pos.x + w - rounded, pos.y + h - rounded, rounded, 0, math.pi/2)
- #cr.line_to(pos.x + rounded, pos.y + h)
- #cr.arc(pos.x + rounded, pos .y + h - rounded, rounded, math.pi/2, math.pi)
- #cr.line_to(pos.x, pos.y + rounded)
- #cr.arc(pos.x + rounded, pos.y + rounded, rounded, math.pi, 3 * math.pi/2)
- #cr.close_path()
-
- # Fill in the shape.
- #cr.set_source_rgb(0.78, 0.70, 0.60)
- #cr.fill()
# Make the path of rounded rectangle.
cr.move_to(pos.x + rounded, pos.y)
@@ -334,25 +237,3 @@ class GroupObject(MovableObject):
cr.stroke()
cr.restore()
-
- #Polygon ovalPolygon = new Polygon(new int[] {0, 2, 5, 11, 24, 107 - 9,
- # 120 - 9,
- # 125 - 9, 128 - 9, 130 - 9,
- # 128 - 9, 125 - 9, 120 - 9, 107 - 9, 24,
- # 11,
- # 5, 2},
- # new int[] {36, 27, 18, 9, 1, 1, 9,
- # 18, 27, 36, 45, 54, 63, 72, 72, 63, 54,
- # 45}, 18);
- #
- #Polygon moonPolygon = new Polygon(new int[] {0, 1, 4, 10, 14,
- # 21, 29, 24, 19, 15,
- # 10, 6, 5, 6, 10,
- # 15, 19, 24, 29, 21,
- # 14, 10, 4, 1},
- # new int[] {0, -8, -15, -22, -25,
- # -29, -32, -29, -25, -22,
- # -15, -8, 0, 8, 15,
- # 22, 25, 29, 32, 29,
- # 25, 22, 15, 8}, 24);
- #