Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorgaphor@gmail.com <gaphor@gmail.com@a8418922-720d-0410-834f-a69b97ada669>2009-01-10 20:43:49 (GMT)
committer gaphor@gmail.com <gaphor@gmail.com@a8418922-720d-0410-834f-a69b97ada669>2009-01-10 20:43:49 (GMT)
commitb57dbddfad018c0982e533260057b4ec3e1bf0fe (patch)
tree7bfceac5b3f74ffafecd803901f4174ae63a820b
parentfdfc2f8f60ba9aa3299fcde7ba4cc7cf5028460c (diff)
removed hackish behaviur from Item.normalize. Added extra solver invocation to ensure validity of constraints after normalization.
git-svn-id: http://svn.devjavu.com/gaphor/gaphas/trunk@2591 a8418922-720d-0410-834f-a69b97ada669
-rwxr-xr-xdemo.py4
-rw-r--r--gaphas/canvas.py22
-rw-r--r--gaphas/item.py8
3 files changed, 23 insertions, 11 deletions
diff --git a/demo.py b/demo.py
index 8b5e7dc..62382c3 100755
--- a/demo.py
+++ b/demo.py
@@ -203,8 +203,8 @@ def create_window(canvas, title, zoom=1.0):
print 'Undo: invoking', event
saveapply(*event)
# Visualize each event:
- while gtk.events_pending():
- gtk.main_iteration()
+ #while gtk.events_pending():
+ # gtk.main_iteration()
b.connect('clicked', on_clicked)
v.add(b)
diff --git a/gaphas/canvas.py b/gaphas/canvas.py
index 8ba2be5..c8d2814 100644
--- a/gaphas/canvas.py
+++ b/gaphas/canvas.py
@@ -421,6 +421,13 @@ class Canvas(object):
import traceback
traceback.print_exc()
+ def _extend_dirty_items(self, dirty_items):
+ # item's can be marked dirty due to external constraints solving
+ if self._dirty_items:
+ dirty_items.extend(self._dirty_items)
+ self._dirty_items.clear()
+
+ dirty_items = self.sort(set(dirty_items), reverse=True)
@nonrecursive
def update_now(self):
@@ -433,6 +440,7 @@ class Canvas(object):
self._dirty_index = False
sort = self.sort
+ extend_dirty_items = self._extend_dirty_items
# perform update requests for parents of dirty items
dirty_items = self._dirty_items
@@ -461,11 +469,7 @@ class Canvas(object):
assert not self._dirty_matrix_items, 'No matrices may have been marked dirty (%s)' % (self._dirty_matrix_items,)
# item's can be marked dirty due to external constraints solving
- if self._dirty_items:
- dirty_items.extend(self._dirty_items)
- self._dirty_items.clear()
-
- dirty_items = sort(set(dirty_items), reverse=True)
+ extend_dirty_items(dirty_items)
assert not self._dirty_items, 'No items may have been marked dirty (%s)' % (self._dirty_items,)
@@ -476,6 +480,14 @@ class Canvas(object):
# recalculate matrices of normalized items
dirty_matrix_items.update(self.update_matrices(normalized_items))
+ # ensure constraints are still true after normalization
+ self._solver.solve()
+
+ # item's can be marked dirty due to normalization and solving
+ extend_dirty_items(dirty_items)
+
+ assert not self._dirty_items, 'No items may have been marked dirty (%s)' % (self._dirty_items,)
+
self._post_update_items(dirty_items, cr)
except Exception, e:
diff --git a/gaphas/item.py b/gaphas/item.py
index d31569b..63c66ab 100644
--- a/gaphas/item.py
+++ b/gaphas/item.py
@@ -166,15 +166,15 @@ class Item(object):
if handles:
x, y = map(float, handles[0].pos)
if x:
- self.matrix._matrix.translate(x, 0)
+ self.matrix.translate(x, 0)
updated = True
for h in handles:
- h.x._value -= x
+ h.x -= x
if y:
- self.matrix._matrix.translate(0, y)
+ self.matrix.translate(0, y)
updated = True
for h in handles:
- h.y._value -= y
+ h.y -= y
return updated