diff options
Diffstat (limited to 'volumeproblem.py')
-rw-r--r-- | volumeproblem.py | 32 |
1 files changed, 19 insertions, 13 deletions
diff --git a/volumeproblem.py b/volumeproblem.py index 7b9858a..b5a5318 100644 --- a/volumeproblem.py +++ b/volumeproblem.py @@ -294,7 +294,7 @@ class VolumeProblem(Problem): def check_problem_solved(self): #print "Volume Problem: check_problem_solved called" - + if self.shape1.pos.approx_equal(self.under_faucet_position, tolerance=100): #print " first volume is under the faucet" if not self.shape1.full and not self.shape2.full: @@ -304,7 +304,8 @@ class VolumeProblem(Problem): self.shape1.contains_water = True self.shape1.full = True self.shape1.water_height = self.shape1.height - self.shape1.fill_to_given_volume(self.shape1.volume) + self.shape1.filling_from_faucet = True + self.shape1.fill_to_given_volume(self.shape1.volume) elif self.shape2.pos.approx_equal(self.under_faucet_position, tolerance=100): #print " second volume is under the faucet" if not self.shape1.full and not self.shape2.full: @@ -314,6 +315,7 @@ class VolumeProblem(Problem): self.shape2.contains_water = True self.shape2.full = True self.shape2.water_height = self.shape2.height + self.shape2.filling_from_faucet = True self.shape2.fill_to_given_volume(self.shape2.volume) if self.shape1.pos.approx_equal(self.shape2.pos, tolerance=150): @@ -340,15 +342,13 @@ class VolumeProblem(Problem): #print " volume2 =", self.shape2.water_volume if self.shape2.pos.x > 250: - self.shape1.pos = Vector(self.shape2.pos.x - 250, self.shape2.pos.y) + self.shape1.move(Vector(self.shape2.pos.x - 250, self.shape2.pos.y)) else: - self.shape1.pos = Vector(self.shape2.pos.x + 250, self.shape2.pos.y) + self.shape1.move(Vector(self.shape2.pos.x + 250, self.shape2.pos.y)) #self.shape1.calculate_bounds() #self.shape2.calculate_bounds() - self.place_objects_in_final_positions() - return True elif self.shape2.full and not self.shape1.full: @@ -374,12 +374,10 @@ class VolumeProblem(Problem): #print " After: volume2 =", self.shape2.water_volume #print " volume1 =", self.shape1.water_volume - #if self.shape1.pos.x > 250: - # self.shape2.pos = Vector(self.shape1.pos.x - 250, self.shape1.pos.y) - #else: - # self.shape2.pos = Vector(self.shape1.pos.x + 250, self.shape1.pos.y) - - self.place_objects_in_final_positions() + if self.shape1.pos.x > 250: + self.shape2.move(Vector(self.shape1.pos.x - 250, self.shape1.pos.y)) + else: + self.shape2.move(Vector(self.shape1.pos.x + 250, self.shape1.pos.y)) return True @@ -388,8 +386,16 @@ class VolumeProblem(Problem): def finish_problem_stage1(self): #print "VolumeProblem: finish_problem_stage1 called" - pass + self.place_objects_in_final_positions() + self.shape1.calculate_bounds() + self.shape2.calculate_bounds() + # Make ShapeObjects inactive. + self.shape1.selected = False + self.shape1.draggable = False + self.shape2.selected = False + self.shape2.draggable = False + def place_objects_in_final_positions(self): #print "VolumeProblem: place_objects_in_final_positions called" |