Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWade Brainerd <wadetb@gmail.com>2009-12-31 02:14:17 (GMT)
committer Wade Brainerd <wadetb@gmail.com>2009-12-31 02:14:17 (GMT)
commit074df304379db5bd4d733d1a7af3ddd7723d9b05 (patch)
tree25ff3a35e871088ceee699f9ae460863d9e6aa90
parentefc9bf97c82b53d8acd3445bcbac83266a0d4b87 (diff)
Take scale into account when redrawing objects.
Rewrite VolumeObject.get_bounds.
-rw-r--r--objectarea.py11
-rw-r--r--volumeobject.py16
2 files changed, 13 insertions, 14 deletions
diff --git a/objectarea.py b/objectarea.py
index 0b53fad..17c5ac0 100644
--- a/objectarea.py
+++ b/objectarea.py
@@ -87,8 +87,7 @@ class Object:
def queue_draw(self):
"""Called whenever the object needs to be redrawn on screen."""
if self.container:
- bounds = self.get_bounds()
- self.container.queue_draw_area(int(bounds[0].x), int(bounds[0].y), int(bounds[1].x), int(bounds[1].y))
+ self.container.queue_draw_bounds(self.get_bounds())
def move(self, pos):
self.queue_draw()
@@ -187,6 +186,13 @@ class ObjectArea(gtk.Layout):
except:
pass
+ def queue_draw_bounds(self, bounds):
+ x1 = int(bounds[0].x * self.scale_ratio)
+ y1 = int(bounds[0].y * self.scale_ratio)
+ x2 = int(bounds[1].x * self.scale_ratio)
+ y2 = int(bounds[1].y * self.scale_ratio)
+ self.queue_draw_area(x1, y1, (x2-x1)+1, (y2-y1)+1)
+
def clear_selection(self):
if self.selected_object:
self.selected_object.selected = False
@@ -377,6 +383,7 @@ class ObjectArea(gtk.Layout):
pass
def expose_cb(self, widget, event):
+ # Track changes to the window size.
bounds = self.get_allocation()
if bounds.width != self.bounds.width or bounds.height != self.bounds.height:
self.resize_cb()
diff --git a/volumeobject.py b/volumeobject.py
index de86f5d..37879c6 100644
--- a/volumeobject.py
+++ b/volumeobject.py
@@ -332,18 +332,10 @@ class VolumeObject(MovableObject):
cr.restore()
def calculate_bounds(self):
- # Get the current width and height of the bounding rectangle.
- self.bounds_min = Vector(float('inf'), float('inf'))
- self.bounds_max = Vector(float('-inf'), float('-inf'))
- for p in self.points:
- p = self.transform_point(p)
- p = p.scaled(self.scale)
- self.bounds_min = self.bounds_min.min(p)
- self.bounds_max = self.bounds_max.max(p)
-
- # Adjust the bounds to show the ellipses.
- self.bounds_min -= Vector(2, 2 + self.upper_radius/4.)
- self.bounds_max += Vector(2, 2 + self.lower_radius/4.)
+ r = max(self.upper_radius, self.lower_radius)
+ halfsize = Vector(r + 2, self.height/2 + r/2 + 2) * self.scale
+ self.bounds_min = self.pos * self.scale - halfsize
+ self.bounds_max = self.pos * self.scale + halfsize
# Include the stream when animating.
if self.filling_from_faucet: