annotate pyink/consistency.py @ 1532:4a92b639a1cd

Clear selection set when switching current scene. To clear selection set after switching away from current to another scene. It avoids Inkscape select on nodes they are not saw after switching.
author Thinker K.F. Li <thinker@codemud.net>
date Fri, 30 Sep 2011 12:31:33 +0800
parents 0b5ee9c90af7
children
rev   line source
1253
07e0cb1e051d Add class consistency_checker for domview_ui.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
1 import dom_event
07e0cb1e051d Add class consistency_checker for domview_ui.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
2 from data_monitor import data_monitor
1265
ca301f6abef7 Support undo for insert key frame/rm keyframe. We will refresh all layers and scenes since it is not feasible to collect these changes and update the layers and scenes. We may scan two level only in the future to improve the performance.
wycc
parents: 1262
diff changeset
3 import traceback
1277
4686f3131f2a Leave a blank between import statements at head
Thinker K.F. Li <thinker@codemud.net>
parents: 1268
diff changeset
4
1253
07e0cb1e051d Add class consistency_checker for domview_ui.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
5 ## \brief Check consistency of a DOM-tree associated with a domview_ui.
07e0cb1e051d Add class consistency_checker for domview_ui.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
6 #
07e0cb1e051d Add class consistency_checker for domview_ui.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
7 # This is a co-worker of \ref domview_ui to check DOM-tree and make
07e0cb1e051d Add class consistency_checker for domview_ui.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
8 # sure consistency of scenes, scene groups in the DOM-tree. It also
07e0cb1e051d Add class consistency_checker for domview_ui.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
9 # updates layer list of \ref domview_ui to reflect last changes of the
07e0cb1e051d Add class consistency_checker for domview_ui.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
10 # DOM-tree.
07e0cb1e051d Add class consistency_checker for domview_ui.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
11 #
07e0cb1e051d Add class consistency_checker for domview_ui.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
12 # Since it is a consistency checker, it must well understanding
07e0cb1e051d Add class consistency_checker for domview_ui.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
13 # structure that expected by domview_ui. So, this class is highly
07e0cb1e051d Add class consistency_checker for domview_ui.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
14 # closed to the internal of \ref domview_ui. It is separated from
07e0cb1e051d Add class consistency_checker for domview_ui.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
15 # domview_ui for collecting related logic and functions in a place to
07e0cb1e051d Add class consistency_checker for domview_ui.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
16 # set up a clear boundary from the functions provided by \ref
07e0cb1e051d Add class consistency_checker for domview_ui.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
17 # domview_ui.
07e0cb1e051d Add class consistency_checker for domview_ui.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
18 #
07e0cb1e051d Add class consistency_checker for domview_ui.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
19 # This class is expected to access private variables of \ref
07e0cb1e051d Add class consistency_checker for domview_ui.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
20 # domview_ui. But, use public interface of domview_ui if possible.
07e0cb1e051d Add class consistency_checker for domview_ui.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
21 #
07e0cb1e051d Add class consistency_checker for domview_ui.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
22 # This class is also monitored by \ref data_monitor to monitor the
07e0cb1e051d Add class consistency_checker for domview_ui.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
23 # accessing to domview_ui.
07e0cb1e051d Add class consistency_checker for domview_ui.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
24 #
07e0cb1e051d Add class consistency_checker for domview_ui.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
25 class consistency_checker(object):
07e0cb1e051d Add class consistency_checker for domview_ui.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
26 __metaclass__ = data_monitor
07e0cb1e051d Add class consistency_checker for domview_ui.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
27
07e0cb1e051d Add class consistency_checker for domview_ui.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
28 def __init__(self, domview_ui):
1279
1b03b6d9a915 Rename _domview to _domviewui to reduce confusion.
wycc
parents: 1277
diff changeset
29 self._domviewui = domview_ui
1b03b6d9a915 Rename _domview to _domviewui to reduce confusion.
wycc
parents: 1277
diff changeset
30 self._locker = self._domviewui
1253
07e0cb1e051d Add class consistency_checker for domview_ui.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
31 self._doc = None
07e0cb1e051d Add class consistency_checker for domview_ui.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
32 self._root = None
07e0cb1e051d Add class consistency_checker for domview_ui.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
33 pass
07e0cb1e051d Add class consistency_checker for domview_ui.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
34
07e0cb1e051d Add class consistency_checker for domview_ui.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
35 def _start_check(self):
07e0cb1e051d Add class consistency_checker for domview_ui.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
36 doc = self._doc
07e0cb1e051d Add class consistency_checker for domview_ui.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
37 dom_event.addEventListener(doc, 'DOMNodeInserted',
07e0cb1e051d Add class consistency_checker for domview_ui.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
38 self.do_insert_node, None)
07e0cb1e051d Add class consistency_checker for domview_ui.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
39 dom_event.addEventListener(doc, 'DOMNodeRemoved',
07e0cb1e051d Add class consistency_checker for domview_ui.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
40 self.do_remove_node, None)
07e0cb1e051d Add class consistency_checker for domview_ui.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
41 dom_event.addEventListener(doc, 'DOMAttrModified',
07e0cb1e051d Add class consistency_checker for domview_ui.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
42 self.do_attr_modified, None)
07e0cb1e051d Add class consistency_checker for domview_ui.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
43 pass
07e0cb1e051d Add class consistency_checker for domview_ui.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
44
07e0cb1e051d Add class consistency_checker for domview_ui.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
45 ## \brief Handle a new document.
07e0cb1e051d Add class consistency_checker for domview_ui.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
46 #
07e0cb1e051d Add class consistency_checker for domview_ui.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
47 # This method is called by domview_ui.handle_doc_root().
07e0cb1e051d Add class consistency_checker for domview_ui.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
48 #
07e0cb1e051d Add class consistency_checker for domview_ui.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
49 def handle_doc_root(self, doc, root):
07e0cb1e051d Add class consistency_checker for domview_ui.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
50 self._doc = doc
07e0cb1e051d Add class consistency_checker for domview_ui.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
51 self._root = root
07e0cb1e051d Add class consistency_checker for domview_ui.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
52
07e0cb1e051d Add class consistency_checker for domview_ui.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
53 self._start_check()
07e0cb1e051d Add class consistency_checker for domview_ui.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
54 pass
07e0cb1e051d Add class consistency_checker for domview_ui.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
55
1262
2f861eea1214 Make domview_ui manages scenes and layers found by checker
Thinker K.F. Li <thinker@codemud.net>
parents: 1261
diff changeset
56 def _insert_node_recursive(self, node, child):
2f861eea1214 Make domview_ui manages scenes and layers found by checker
Thinker K.F. Li <thinker@codemud.net>
parents: 1261
diff changeset
57 child_name = child.name()
2f861eea1214 Make domview_ui manages scenes and layers found by checker
Thinker K.F. Li <thinker@codemud.net>
parents: 1261
diff changeset
58
2f861eea1214 Make domview_ui manages scenes and layers found by checker
Thinker K.F. Li <thinker@codemud.net>
parents: 1261
diff changeset
59 if child_name == 'ns0:scene':
2f861eea1214 Make domview_ui manages scenes and layers found by checker
Thinker K.F. Li <thinker@codemud.net>
parents: 1261
diff changeset
60 scene_group_id = child.getAttribute('ref')
2f861eea1214 Make domview_ui manages scenes and layers found by checker
Thinker K.F. Li <thinker@codemud.net>
parents: 1261
diff changeset
61 try:
1279
1b03b6d9a915 Rename _domview to _domviewui to reduce confusion.
wycc
parents: 1277
diff changeset
62 scene_group = self._domviewui.get_node(scene_group_id)
1262
2f861eea1214 Make domview_ui manages scenes and layers found by checker
Thinker K.F. Li <thinker@codemud.net>
parents: 1261
diff changeset
63 except KeyError: # can not find associated scene group.
2f861eea1214 Make domview_ui manages scenes and layers found by checker
Thinker K.F. Li <thinker@codemud.net>
parents: 1261
diff changeset
64 pass
2f861eea1214 Make domview_ui manages scenes and layers found by checker
Thinker K.F. Li <thinker@codemud.net>
parents: 1261
diff changeset
65 else:
1279
1b03b6d9a915 Rename _domview to _domviewui to reduce confusion.
wycc
parents: 1277
diff changeset
66 self._domviewui.manage_scene_node(child, scene_group)
1262
2f861eea1214 Make domview_ui manages scenes and layers found by checker
Thinker K.F. Li <thinker@codemud.net>
parents: 1261
diff changeset
67 pass
2f861eea1214 Make domview_ui manages scenes and layers found by checker
Thinker K.F. Li <thinker@codemud.net>
parents: 1261
diff changeset
68 elif child_name == 'svg:g':
2f861eea1214 Make domview_ui manages scenes and layers found by checker
Thinker K.F. Li <thinker@codemud.net>
parents: 1261
diff changeset
69 if node.name() == 'svg:svg':
1279
1b03b6d9a915 Rename _domview to _domviewui to reduce confusion.
wycc
parents: 1277
diff changeset
70 self._domviewui.manage_layer_group(child)
1262
2f861eea1214 Make domview_ui manages scenes and layers found by checker
Thinker K.F. Li <thinker@codemud.net>
parents: 1261
diff changeset
71 pass
2f861eea1214 Make domview_ui manages scenes and layers found by checker
Thinker K.F. Li <thinker@codemud.net>
parents: 1261
diff changeset
72 pass
1335
194c7a831083 Consistent checking for components and timelines
Thinker K.F. Li <thinker@codemud.net>
parents: 1281
diff changeset
73 elif child_name == 'ns0:scenes':
194c7a831083 Consistent checking for components and timelines
Thinker K.F. Li <thinker@codemud.net>
parents: 1281
diff changeset
74 self._domviewui.refresh_timelines()
194c7a831083 Consistent checking for components and timelines
Thinker K.F. Li <thinker@codemud.net>
parents: 1281
diff changeset
75 return
1262
2f861eea1214 Make domview_ui manages scenes and layers found by checker
Thinker K.F. Li <thinker@codemud.net>
parents: 1261
diff changeset
76
2f861eea1214 Make domview_ui manages scenes and layers found by checker
Thinker K.F. Li <thinker@codemud.net>
parents: 1261
diff changeset
77 for cchild in child.childList():
2f861eea1214 Make domview_ui manages scenes and layers found by checker
Thinker K.F. Li <thinker@codemud.net>
parents: 1261
diff changeset
78 self._remove_node_recursive(child, cchild)
2f861eea1214 Make domview_ui manages scenes and layers found by checker
Thinker K.F. Li <thinker@codemud.net>
parents: 1261
diff changeset
79 pass
2f861eea1214 Make domview_ui manages scenes and layers found by checker
Thinker K.F. Li <thinker@codemud.net>
parents: 1261
diff changeset
80 pass
2f861eea1214 Make domview_ui manages scenes and layers found by checker
Thinker K.F. Li <thinker@codemud.net>
parents: 1261
diff changeset
81
1257
027cd060d9ba Remove the key frame if associated scene node or scene group being removed.
Thinker K.F. Li <thinker@codemud.net>
parents: 1253
diff changeset
82 def _remove_node_recursive(self, node, child):
027cd060d9ba Remove the key frame if associated scene node or scene group being removed.
Thinker K.F. Li <thinker@codemud.net>
parents: 1253
diff changeset
83 for cchild in child.childList():
027cd060d9ba Remove the key frame if associated scene node or scene group being removed.
Thinker K.F. Li <thinker@codemud.net>
parents: 1253
diff changeset
84 self._remove_node_recursive(child, cchild)
027cd060d9ba Remove the key frame if associated scene node or scene group being removed.
Thinker K.F. Li <thinker@codemud.net>
parents: 1253
diff changeset
85 pass
027cd060d9ba Remove the key frame if associated scene node or scene group being removed.
Thinker K.F. Li <thinker@codemud.net>
parents: 1253
diff changeset
86
027cd060d9ba Remove the key frame if associated scene node or scene group being removed.
Thinker K.F. Li <thinker@codemud.net>
parents: 1253
diff changeset
87 child_name = child.name()
1336
0b5ee9c90af7 Update components and timelines list for async changes on DOM
Thinker K.F. Li <thinker@codemud.net>
parents: 1335
diff changeset
88 if child_name not in ('ns0:scenes', 'ns0:scene', 'svg:g'):
1257
027cd060d9ba Remove the key frame if associated scene node or scene group being removed.
Thinker K.F. Li <thinker@codemud.net>
parents: 1253
diff changeset
89 return
027cd060d9ba Remove the key frame if associated scene node or scene group being removed.
Thinker K.F. Li <thinker@codemud.net>
parents: 1253
diff changeset
90
027cd060d9ba Remove the key frame if associated scene node or scene group being removed.
Thinker K.F. Li <thinker@codemud.net>
parents: 1253
diff changeset
91 #
027cd060d9ba Remove the key frame if associated scene node or scene group being removed.
Thinker K.F. Li <thinker@codemud.net>
parents: 1253
diff changeset
92 # Remove the key frame assocated with a removed scene node or
027cd060d9ba Remove the key frame if associated scene node or scene group being removed.
Thinker K.F. Li <thinker@codemud.net>
parents: 1253
diff changeset
93 # scene group if we can find the key frame.
027cd060d9ba Remove the key frame if associated scene node or scene group being removed.
Thinker K.F. Li <thinker@codemud.net>
parents: 1253
diff changeset
94 #
027cd060d9ba Remove the key frame if associated scene node or scene group being removed.
Thinker K.F. Li <thinker@codemud.net>
parents: 1253
diff changeset
95 if child_name == 'ns0:scene':
027cd060d9ba Remove the key frame if associated scene node or scene group being removed.
Thinker K.F. Li <thinker@codemud.net>
parents: 1253
diff changeset
96 try:
027cd060d9ba Remove the key frame if associated scene node or scene group being removed.
Thinker K.F. Li <thinker@codemud.net>
parents: 1253
diff changeset
97 group_id = child.getAttribute('ref')
027cd060d9ba Remove the key frame if associated scene node or scene group being removed.
Thinker K.F. Li <thinker@codemud.net>
parents: 1253
diff changeset
98 except:
027cd060d9ba Remove the key frame if associated scene node or scene group being removed.
Thinker K.F. Li <thinker@codemud.net>
parents: 1253
diff changeset
99 return
027cd060d9ba Remove the key frame if associated scene node or scene group being removed.
Thinker K.F. Li <thinker@codemud.net>
parents: 1253
diff changeset
100 elif child_name == 'svg:g':
027cd060d9ba Remove the key frame if associated scene node or scene group being removed.
Thinker K.F. Li <thinker@codemud.net>
parents: 1253
diff changeset
101 try:
027cd060d9ba Remove the key frame if associated scene node or scene group being removed.
Thinker K.F. Li <thinker@codemud.net>
parents: 1253
diff changeset
102 group_id = child.getAttribute('id')
027cd060d9ba Remove the key frame if associated scene node or scene group being removed.
Thinker K.F. Li <thinker@codemud.net>
parents: 1253
diff changeset
103 except:
027cd060d9ba Remove the key frame if associated scene node or scene group being removed.
Thinker K.F. Li <thinker@codemud.net>
parents: 1253
diff changeset
104 return
027cd060d9ba Remove the key frame if associated scene node or scene group being removed.
Thinker K.F. Li <thinker@codemud.net>
parents: 1253
diff changeset
105 pass
1335
194c7a831083 Consistent checking for components and timelines
Thinker K.F. Li <thinker@codemud.net>
parents: 1281
diff changeset
106 elif child_name == 'ns0:scenes':
194c7a831083 Consistent checking for components and timelines
Thinker K.F. Li <thinker@codemud.net>
parents: 1281
diff changeset
107 self._domviewui.refresh_timelines()
194c7a831083 Consistent checking for components and timelines
Thinker K.F. Li <thinker@codemud.net>
parents: 1281
diff changeset
108 return
1257
027cd060d9ba Remove the key frame if associated scene node or scene group being removed.
Thinker K.F. Li <thinker@codemud.net>
parents: 1253
diff changeset
109
027cd060d9ba Remove the key frame if associated scene node or scene group being removed.
Thinker K.F. Li <thinker@codemud.net>
parents: 1253
diff changeset
110 try:
027cd060d9ba Remove the key frame if associated scene node or scene group being removed.
Thinker K.F. Li <thinker@codemud.net>
parents: 1253
diff changeset
111 layer_idx, (start, end, tween_type) = \
1279
1b03b6d9a915 Rename _domview to _domviewui to reduce confusion.
wycc
parents: 1277
diff changeset
112 self._domviewui.find_key_from_group(group_id)
1257
027cd060d9ba Remove the key frame if associated scene node or scene group being removed.
Thinker K.F. Li <thinker@codemud.net>
parents: 1253
diff changeset
113 except ValueError:
027cd060d9ba Remove the key frame if associated scene node or scene group being removed.
Thinker K.F. Li <thinker@codemud.net>
parents: 1253
diff changeset
114 pass
027cd060d9ba Remove the key frame if associated scene node or scene group being removed.
Thinker K.F. Li <thinker@codemud.net>
parents: 1253
diff changeset
115 else: # We have found the key frame.
1279
1b03b6d9a915 Rename _domview to _domviewui to reduce confusion.
wycc
parents: 1277
diff changeset
116 self._domviewui.unmark_key(layer_idx, start)
1261
6177f5d0ef01 Remove the layer when a layer group being removed.
Thinker K.F. Li <thinker@codemud.net>
parents: 1257
diff changeset
117 return
6177f5d0ef01 Remove the layer when a layer group being removed.
Thinker K.F. Li <thinker@codemud.net>
parents: 1257
diff changeset
118
6177f5d0ef01 Remove the layer when a layer group being removed.
Thinker K.F. Li <thinker@codemud.net>
parents: 1257
diff changeset
119 #
6177f5d0ef01 Remove the layer when a layer group being removed.
Thinker K.F. Li <thinker@codemud.net>
parents: 1257
diff changeset
120 # Remove layers
6177f5d0ef01 Remove the layer when a layer group being removed.
Thinker K.F. Li <thinker@codemud.net>
parents: 1257
diff changeset
121 #
6177f5d0ef01 Remove the layer when a layer group being removed.
Thinker K.F. Li <thinker@codemud.net>
parents: 1257
diff changeset
122 if child_name == 'svg:g':
6177f5d0ef01 Remove the layer when a layer group being removed.
Thinker K.F. Li <thinker@codemud.net>
parents: 1257
diff changeset
123 try:
1279
1b03b6d9a915 Rename _domview to _domviewui to reduce confusion.
wycc
parents: 1277
diff changeset
124 layer_idx = self._domviewui.find_layer_from_group(group_id)
1261
6177f5d0ef01 Remove the layer when a layer group being removed.
Thinker K.F. Li <thinker@codemud.net>
parents: 1257
diff changeset
125 except ValueError:
6177f5d0ef01 Remove the layer when a layer group being removed.
Thinker K.F. Li <thinker@codemud.net>
parents: 1257
diff changeset
126 pass
6177f5d0ef01 Remove the layer when a layer group being removed.
Thinker K.F. Li <thinker@codemud.net>
parents: 1257
diff changeset
127 else: # It is a layer group
1279
1b03b6d9a915 Rename _domview to _domviewui to reduce confusion.
wycc
parents: 1277
diff changeset
128 self._domviewui.rm_layer(layer_idx)
1261
6177f5d0ef01 Remove the layer when a layer group being removed.
Thinker K.F. Li <thinker@codemud.net>
parents: 1257
diff changeset
129 pass
1257
027cd060d9ba Remove the key frame if associated scene node or scene group being removed.
Thinker K.F. Li <thinker@codemud.net>
parents: 1253
diff changeset
130 pass
027cd060d9ba Remove the key frame if associated scene node or scene group being removed.
Thinker K.F. Li <thinker@codemud.net>
parents: 1253
diff changeset
131 pass
027cd060d9ba Remove the key frame if associated scene node or scene group being removed.
Thinker K.F. Li <thinker@codemud.net>
parents: 1253
diff changeset
132
1253
07e0cb1e051d Add class consistency_checker for domview_ui.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
133 def do_insert_node(self, node, child):
1262
2f861eea1214 Make domview_ui manages scenes and layers found by checker
Thinker K.F. Li <thinker@codemud.net>
parents: 1261
diff changeset
134 self._insert_node_recursive(node, child)
1253
07e0cb1e051d Add class consistency_checker for domview_ui.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
135 pass
07e0cb1e051d Add class consistency_checker for domview_ui.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
136
07e0cb1e051d Add class consistency_checker for domview_ui.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
137 def do_remove_node(self, node, child):
1257
027cd060d9ba Remove the key frame if associated scene node or scene group being removed.
Thinker K.F. Li <thinker@codemud.net>
parents: 1253
diff changeset
138 self._remove_node_recursive(node, child)
1253
07e0cb1e051d Add class consistency_checker for domview_ui.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
139 pass
07e0cb1e051d Add class consistency_checker for domview_ui.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
140
07e0cb1e051d Add class consistency_checker for domview_ui.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
141 def do_attr_modified(self, node, name, old_value, new_value):
1280
434f588fcde4 Handle the change of attribute 'start' and 'end'. We do reset here. However, we should be able to optimize it latter to update the scenes directly.
wycc
parents: 1279
diff changeset
142 if node.name() == 'ns0:scene':
434f588fcde4 Handle the change of attribute 'start' and 'end'. We do reset here. However, we should be able to optimize it latter to update the scenes directly.
wycc
parents: 1279
diff changeset
143 if name == 'ref':
434f588fcde4 Handle the change of attribute 'start' and 'end'. We do reset here. However, we should be able to optimize it latter to update the scenes directly.
wycc
parents: 1279
diff changeset
144 try:
434f588fcde4 Handle the change of attribute 'start' and 'end'. We do reset here. However, we should be able to optimize it latter to update the scenes directly.
wycc
parents: 1279
diff changeset
145 if new_value:
434f588fcde4 Handle the change of attribute 'start' and 'end'. We do reset here. However, we should be able to optimize it latter to update the scenes directly.
wycc
parents: 1279
diff changeset
146 raise ValueError('The new_value is not empty')
434f588fcde4 Handle the change of attribute 'start' and 'end'. We do reset here. However, we should be able to optimize it latter to update the scenes directly.
wycc
parents: 1279
diff changeset
147 self._domviewui.reset()
434f588fcde4 Handle the change of attribute 'start' and 'end'. We do reset here. However, we should be able to optimize it latter to update the scenes directly.
wycc
parents: 1279
diff changeset
148 except:
434f588fcde4 Handle the change of attribute 'start' and 'end'. We do reset here. However, we should be able to optimize it latter to update the scenes directly.
wycc
parents: 1279
diff changeset
149 traceback.print_exc()
434f588fcde4 Handle the change of attribute 'start' and 'end'. We do reset here. However, we should be able to optimize it latter to update the scenes directly.
wycc
parents: 1279
diff changeset
150 pass
1265
ca301f6abef7 Support undo for insert key frame/rm keyframe. We will refresh all layers and scenes since it is not feasible to collect these changes and update the layers and scenes. We may scan two level only in the future to improve the performance.
wycc
parents: 1262
diff changeset
151 pass
1280
434f588fcde4 Handle the change of attribute 'start' and 'end'. We do reset here. However, we should be able to optimize it latter to update the scenes directly.
wycc
parents: 1279
diff changeset
152 elif name == 'end' or name == 'start':
434f588fcde4 Handle the change of attribute 'start' and 'end'. We do reset here. However, we should be able to optimize it latter to update the scenes directly.
wycc
parents: 1279
diff changeset
153 self._domviewui.reset()
434f588fcde4 Handle the change of attribute 'start' and 'end'. We do reset here. However, we should be able to optimize it latter to update the scenes directly.
wycc
parents: 1279
diff changeset
154 pass
1281
e12472f8eef3 Handle type attribute to implemen the tween type change action undo.
wycc
parents: 1280
diff changeset
155 elif name == 'type':
e12472f8eef3 Handle type attribute to implemen the tween type change action undo.
wycc
parents: 1280
diff changeset
156 self._domviewui.reset()
e12472f8eef3 Handle type attribute to implemen the tween type change action undo.
wycc
parents: 1280
diff changeset
157 pass
e12472f8eef3 Handle type attribute to implemen the tween type change action undo.
wycc
parents: 1280
diff changeset
158 pass
1335
194c7a831083 Consistent checking for components and timelines
Thinker K.F. Li <thinker@codemud.net>
parents: 1281
diff changeset
159 elif node.name() == 'ns0:scenes' and name == 'name':
194c7a831083 Consistent checking for components and timelines
Thinker K.F. Li <thinker@codemud.net>
parents: 1281
diff changeset
160 self._domviewui.refresh_timelines()
194c7a831083 Consistent checking for components and timelines
Thinker K.F. Li <thinker@codemud.net>
parents: 1281
diff changeset
161 pass
1253
07e0cb1e051d Add class consistency_checker for domview_ui.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
162 pass
07e0cb1e051d Add class consistency_checker for domview_ui.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff changeset
163 pass