Mercurial > MadButterfly
annotate pyink/domview.py @ 1246:42c4874c8d1e
Move _duplicate_group to domview_ui.
- domview_ui.copy_key_group() replaces MBScene._duplicate_group().
author | Thinker K.F. Li <thinker@codemud.net> |
---|---|
date | Mon, 10 Jan 2011 19:44:15 +0800 |
parents | b241f9768833 |
children | 45e9566ea5c0 |
rev | line source |
---|---|
1243
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
1 import random |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
2 import pybInkscape |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
3 from tween import TweenObject |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
4 |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
5 class Layer: |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
6 def __init__(self, node): |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
7 self.scenes = [] |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
8 self.group = node |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
9 pass |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
10 pass |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
11 |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
12 class ObjectWatcher(pybInkscape.PYNodeObserver): |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
13 def __init__(self, obj, type, func, arg): |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
14 self.obj = obj |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
15 self.type = type |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
16 self.func = func |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
17 self.arg = arg |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
18 |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
19 def notifyChildAdded(self, node, child, prev): |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
20 if self.type == 'DOMNodeInserted': |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
21 self.func(node, child) |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
22 def notifyChildRemoved(self, node, child, prev): |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
23 if self.type == 'DOMNodeRemoved': |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
24 self.func(node, child) |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
25 def notifyChildOrderChanged(self,node,child,prev): |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
26 pass |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
27 def notifyContentChanged(self,node,old_content,new_content): |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
28 if self.type == 'DOMSubtreeModified': |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
29 self.func(node) |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
30 def notifyAttributeChanged(self,node, name, old_value, new_value): |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
31 if self.type == 'DOMAttrModified': |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
32 self.func(node, name, old_value, new_value) |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
33 |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
34 def addEventListener(obj, type, func, arg): |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
35 obs = ObjectWatcher(obj, type, func, arg) |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
36 obj.addSubtreeObserver(obs) |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
37 pass |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
38 |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
39 |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
40 ## \brief Monitor changes of DOM-tree. |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
41 # |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
42 # This class monitors DOM-tree to maintain _maxframe and maps for node ID to |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
43 # node and scene group ID to scene node. |
1244
b241f9768833
Remove MBScene_ from the prefix of class names.
Thinker K.F. Li <thinker@codemud.net>
parents:
1243
diff
changeset
|
44 class domview_monitor(object): |
1243
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
45 def __init__(self, *args, **kws): |
1244
b241f9768833
Remove MBScene_ from the prefix of class names.
Thinker K.F. Li <thinker@codemud.net>
parents:
1243
diff
changeset
|
46 super(domview_monitor, self).__init__() |
1243
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
47 |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
48 self._maxframe = 0 |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
49 self._id2node = {} # map ID to the node in the DOM tree. |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
50 self._group2scene = {} # map ID of a group to associated scene node. |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
51 pass |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
52 |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
53 def _start_monitor(self): |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
54 self._collect_node_ids() |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
55 self._collect_all_scenes() |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
56 |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
57 doc = self._doc |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
58 addEventListener(doc, 'DOMNodeInserted', self._on_insert_node, None) |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
59 addEventListener(doc, 'DOMNodeRemoved', self._on_remove_node, None) |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
60 addEventListener(doc, 'DOMAttrModified', self._on_attr_modified, None) |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
61 pass |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
62 |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
63 def _on_insert_node(self, node, child): |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
64 for cchild in child.childList(): |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
65 self._on_insert_node(child, cchild) |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
66 pass |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
67 |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
68 try: |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
69 child_id = child.getAttribute('id') |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
70 except: |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
71 pass |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
72 else: |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
73 if child_id not in self._id2node: |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
74 self._id2node[child_id] = child |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
75 pass |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
76 pass |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
77 |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
78 if child.name() == 'ns0:scene': |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
79 try: |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
80 ref = child.getAttribute('ref') |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
81 except: |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
82 pass |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
83 else: |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
84 if ref not in self._group2scene: |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
85 self._group2scene[ref] = child |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
86 pass |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
87 pass |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
88 |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
89 try: |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
90 start = child.getAttribute('start') |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
91 self._maxframe = max(int(start), self._maxframe) |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
92 except: |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
93 pass |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
94 try: |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
95 start = child.getAttribute('end') |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
96 self._maxframe = max(int(start), self._maxframe) |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
97 except: |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
98 pass |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
99 pass |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
100 pass |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
101 |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
102 def _find_maxframe(self, scenes_node): |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
103 maxframe = 0 |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
104 for child in scenes_node.childList(): |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
105 if child.name() != 'ns0:scene': |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
106 continue |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
107 |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
108 try: |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
109 start = child.getAttribute('start') |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
110 maxframe = max(int(start), maxframe) |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
111 except: |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
112 pass |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
113 try: |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
114 end = child.getAttribute('end') |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
115 maxframe = max(int(end), maxframe) |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
116 except: |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
117 pass |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
118 pass |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
119 return maxframe |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
120 |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
121 def _on_remove_node(self, node, child): |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
122 for cchild in child.childList(): |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
123 self._on_remove_node(child, cchild) |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
124 pass |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
125 |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
126 try: |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
127 child_id = child.getAttribute('id') |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
128 except: |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
129 pass |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
130 else: |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
131 if child_id not in self._id2node: |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
132 raise ValueError, \ |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
133 'remove a node that is never known (%s)' % (child_id) |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
134 del self._id2node[child_id] |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
135 pass |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
136 |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
137 if child.name() == 'ns0:scene': |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
138 try: |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
139 ref = child.getAttribute('ref') |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
140 except: |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
141 pass |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
142 else: |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
143 del self._group2scene[ref] |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
144 pass |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
145 |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
146 try: |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
147 if node.name() == 'ns0:scenes' and \ |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
148 (int(child.getAttribute('start')) == self._maxframe or |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
149 int(child.getAttribute('end')) == self._maxframe): |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
150 self._maxframe = self._find_maxframe(node) |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
151 pass |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
152 except: |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
153 pass |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
154 pass |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
155 pass |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
156 |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
157 def _on_attr_modified(self, node, name, old_value, new_value): |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
158 if name == 'id' and old_value != new_value: |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
159 if old_value and (old_value not in self._id2node): |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
160 raise ValueError, \ |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
161 'old ID value of passed node is invalid one (%s)' % \ |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
162 (old_value) |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
163 if (new_value in self._id2node): |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
164 raise ValueError, \ |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
165 'new ID value of passed node is invalid one (%s)' % \ |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
166 (new_value) |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
167 |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
168 if old_value: |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
169 del self._id2node[old_value] |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
170 pass |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
171 self._id2node[new_value] = node |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
172 pass |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
173 elif name == 'ref' and node.name() == 'ns0:scene': |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
174 if old_value == new_value: |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
175 return |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
176 if old_value: |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
177 node = self._group2scene[old_value] # use old node. Binding |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
178 # may generate a new |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
179 # wrapper. |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
180 del self._group2scene[old_value] |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
181 pass |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
182 if new_value: |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
183 self._group2scene[new_value] = node |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
184 pass |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
185 pass |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
186 elif (name in ('start', 'end')) and node.name() == 'ns0:scene': |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
187 self._maxframe = max(int(new_value), self._maxframe) |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
188 pass |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
189 pass |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
190 |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
191 ## \brief Collect ID of nodes in the document. |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
192 # |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
193 # It is used to implement a fast mapping from an ID to the respective node. |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
194 # |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
195 def _collect_node_ids(self): |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
196 self._id2node = {} |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
197 root = self._root |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
198 for n in root.childList(): |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
199 self._collect_node_ids_recursive(n) |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
200 pass |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
201 pass |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
202 |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
203 def _collect_node_ids_recursive(self, node): |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
204 try: |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
205 node_id = node.getAttribute('id') |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
206 except: |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
207 return |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
208 |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
209 self._id2node[node_id] = node |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
210 for n in node.childList(): |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
211 self._collect_node_ids_recursive(n) |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
212 pass |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
213 pass |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
214 |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
215 def _parse_one_scene(self, scene_node): |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
216 assert scene_node.name() == 'ns0:scene' |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
217 |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
218 start = int(scene_node.getAttribute("start")) |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
219 try: |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
220 end = int(scene_node.getAttribute("end")) |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
221 except: |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
222 end = start |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
223 pass |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
224 |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
225 try: |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
226 scene_type = scene_node.getAttribute('type') |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
227 if scene_type == None: |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
228 scene_type = 'normal' |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
229 pass |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
230 except: |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
231 scene_type = 'normal' |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
232 pass |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
233 |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
234 return start, end, scene_type |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
235 |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
236 def _parse_one_scenes(self, scenes_node): |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
237 try: |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
238 cur = int(n.getAttribute("current")) |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
239 except: |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
240 cur = 0 |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
241 pass |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
242 self.current = cur |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
243 |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
244 for scene_node in scenes_node.childList(): |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
245 if scene_node.name() != 'ns0:scene': |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
246 continue |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
247 |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
248 try: |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
249 start, end, scene_type = self._parse_one_scene(scene_node) |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
250 except: |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
251 continue |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
252 |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
253 group_id = scene_node.getAttribute("ref") |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
254 self._group2scene[group_id] = scene_node |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
255 pass |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
256 pass |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
257 |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
258 ## \brief Parse all scenes node in svg:metadata subtree. |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
259 # |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
260 def _collect_all_scenes(self): |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
261 root = self._root |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
262 for child in root.childList(): |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
263 if child.name() != 'svg:metadata': |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
264 continue |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
265 |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
266 metadata_node = child |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
267 for metachild in metadata_node.childList(): |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
268 if metachild.name() == 'ns0:scenes': |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
269 self._parse_one_scenes(metachild) |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
270 self._maxframe = self._find_maxframe(metachild) |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
271 pass |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
272 pass |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
273 pass |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
274 pass |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
275 |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
276 ## \brief Return the node with given ID. |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
277 # |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
278 def get_node(self, node_id): |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
279 return self._id2node[node_id] |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
280 |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
281 ## \brief Return a scene node corresponding to a scene group of given ID. |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
282 # |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
283 def get_scene(self, group_id): |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
284 return self._group2scene[group_id] |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
285 |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
286 def new_id(self): |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
287 while True: |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
288 candidate = 's%d' % int(random.random()*100000) |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
289 if candidate not in self._id2node: |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
290 return candidate |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
291 pass |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
292 pass |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
293 pass |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
294 |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
295 |
1246
42c4874c8d1e
Move _duplicate_group to domview_ui.
Thinker K.F. Li <thinker@codemud.net>
parents:
1244
diff
changeset
|
296 ## \brief Iterator to travel a sub-tree of DOM. |
42c4874c8d1e
Move _duplicate_group to domview_ui.
Thinker K.F. Li <thinker@codemud.net>
parents:
1244
diff
changeset
|
297 # |
42c4874c8d1e
Move _duplicate_group to domview_ui.
Thinker K.F. Li <thinker@codemud.net>
parents:
1244
diff
changeset
|
298 def _DOM_iterator(node): |
42c4874c8d1e
Move _duplicate_group to domview_ui.
Thinker K.F. Li <thinker@codemud.net>
parents:
1244
diff
changeset
|
299 nodes = [node] |
42c4874c8d1e
Move _duplicate_group to domview_ui.
Thinker K.F. Li <thinker@codemud.net>
parents:
1244
diff
changeset
|
300 while nodes: |
42c4874c8d1e
Move _duplicate_group to domview_ui.
Thinker K.F. Li <thinker@codemud.net>
parents:
1244
diff
changeset
|
301 node = nodes.pop(0) |
42c4874c8d1e
Move _duplicate_group to domview_ui.
Thinker K.F. Li <thinker@codemud.net>
parents:
1244
diff
changeset
|
302 child = node.firstChild() |
42c4874c8d1e
Move _duplicate_group to domview_ui.
Thinker K.F. Li <thinker@codemud.net>
parents:
1244
diff
changeset
|
303 while child: |
42c4874c8d1e
Move _duplicate_group to domview_ui.
Thinker K.F. Li <thinker@codemud.net>
parents:
1244
diff
changeset
|
304 nodes.append(child) |
42c4874c8d1e
Move _duplicate_group to domview_ui.
Thinker K.F. Li <thinker@codemud.net>
parents:
1244
diff
changeset
|
305 child = child.next() |
42c4874c8d1e
Move _duplicate_group to domview_ui.
Thinker K.F. Li <thinker@codemud.net>
parents:
1244
diff
changeset
|
306 pass |
42c4874c8d1e
Move _duplicate_group to domview_ui.
Thinker K.F. Li <thinker@codemud.net>
parents:
1244
diff
changeset
|
307 yield node |
42c4874c8d1e
Move _duplicate_group to domview_ui.
Thinker K.F. Li <thinker@codemud.net>
parents:
1244
diff
changeset
|
308 pass |
42c4874c8d1e
Move _duplicate_group to domview_ui.
Thinker K.F. Li <thinker@codemud.net>
parents:
1244
diff
changeset
|
309 pass |
42c4874c8d1e
Move _duplicate_group to domview_ui.
Thinker K.F. Li <thinker@codemud.net>
parents:
1244
diff
changeset
|
310 |
42c4874c8d1e
Move _duplicate_group to domview_ui.
Thinker K.F. Li <thinker@codemud.net>
parents:
1244
diff
changeset
|
311 |
1243
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
312 ## \brief This layer provide a data view to the DOM-tree. |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
313 # |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
314 # This class maintains layers information, and provides functions to create, |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
315 # change and destroy scene node and scene group. A scene node is a 'ns0:scene' |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
316 # in 'ns0:scenes' tag. A scene group is respective 'svg:g' for a scene. |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
317 # |
1244
b241f9768833
Remove MBScene_ from the prefix of class names.
Thinker K.F. Li <thinker@codemud.net>
parents:
1243
diff
changeset
|
318 class domview(domview_monitor): |
1243
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
319 # Declare variables, here, for keeping tracking |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
320 _doc = None |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
321 _root = None |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
322 |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
323 def __init__(self, *args, **kws): |
1244
b241f9768833
Remove MBScene_ from the prefix of class names.
Thinker K.F. Li <thinker@codemud.net>
parents:
1243
diff
changeset
|
324 super(domview, self).__init__() |
1243
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
325 pass |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
326 |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
327 ## \brief Create a scenes node if not existed. |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
328 # |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
329 def _init_metadata(self): |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
330 for node in self._root.childList(): |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
331 if node.name() == 'svg:metadata': |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
332 break |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
333 pass |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
334 else: |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
335 raise RuntimeError, \ |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
336 'can not find <svg:metadata> node in the document' |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
337 |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
338 for n in node.childList(): |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
339 if n.name() == 'ns0:scenes': |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
340 self._scenes_node = n |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
341 break |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
342 pass |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
343 else: |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
344 ns = "http://madbutterfly.sourceforge.net/DTD/madbutterfly.dtd" |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
345 self._root.setAttribute("xmlns:ns0", ns) |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
346 scenes_node = self._doc.createElement("ns0:scenes") |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
347 node.appendChild(scenes_node) |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
348 self._scenes_node = scenes_node |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
349 pass |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
350 pass |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
351 |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
352 def _parse_all_layers(self): |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
353 root = self._root |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
354 layers = self._layers |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
355 |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
356 for child in root.childList(): |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
357 if child.name() != 'svg:g': |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
358 continue |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
359 |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
360 layer_group = child |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
361 layer = Layer(layer_group) |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
362 layer.idx = len(layers) |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
363 layers.append(layer) |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
364 self.parse_layer(layer.idx) |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
365 pass |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
366 pass |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
367 |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
368 def handle_doc_root(self, doc, root): |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
369 self._doc = doc |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
370 self._root = root |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
371 self._layers = [] |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
372 |
1244
b241f9768833
Remove MBScene_ from the prefix of class names.
Thinker K.F. Li <thinker@codemud.net>
parents:
1243
diff
changeset
|
373 self._start_monitor() # start domview_monitor |
1243
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
374 self._init_metadata() |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
375 self._parse_all_layers() |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
376 pass |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
377 |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
378 def dumpattr(self, n): |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
379 s = "" |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
380 for a,v in n.attrib.items(): |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
381 s = s + ("%s=%s" % (a,v)) |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
382 pass |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
383 return s |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
384 |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
385 def dump(self, node, l=0): |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
386 print " " * l*2,"<", node.tag, self.dumpattr(node),">" |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
387 for n in node: |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
388 self.dump(n, l+1) |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
389 pass |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
390 print " " * l * 2,"/>" |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
391 pass |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
392 |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
393 ## \brief Create and add a ns0:scene node under ns0:scenes subtree. |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
394 # |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
395 def add_scene_node(self, start, end, |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
396 frame_type=TweenObject.TWEEN_TYPE_NORMAL, |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
397 ref=None): |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
398 type_names = ('normal', 'scale') |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
399 scenes_node = self._scenes_node |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
400 doc = self._doc |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
401 |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
402 scene_node = doc.createElement('ns0:scene') |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
403 self.chg_scene_node(scene_node, start=start) |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
404 if start != end: |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
405 self.chg_scene_node(scene_node, end=end) |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
406 pass |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
407 type_name = type_names[frame_type] |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
408 self.chg_scene_node(scene_node, tween_type=type_name) |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
409 if ref: |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
410 self.chg_scene_node(scene_node, ref=ref) |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
411 pass |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
412 |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
413 scenes_node.appendChild(scene_node) |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
414 |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
415 return scene_node |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
416 |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
417 ## \brief Change attributes of a scene node. |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
418 # |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
419 # This is here to monitor changes of scene node. |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
420 def chg_scene_node(self, scene_node, start=None, end=None, |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
421 tween_type=None, ref=None): |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
422 if start is not None: |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
423 scene_node.setAttribute('start', str(start)) |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
424 pass |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
425 if end is not None: |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
426 scene_node.setAttribute('end', str(end)) |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
427 pass |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
428 if tween_type is not None: |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
429 scene_node.setAttribute('type', tween_type) |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
430 pass |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
431 if ref is not None: |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
432 scene_node.setAttribute('ref', ref) |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
433 pass |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
434 pass |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
435 |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
436 def rm_scene_node(self, scene_node): |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
437 self._scenes_node.removeChild(scene_node) |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
438 pass |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
439 |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
440 def rm_scene_node_n_group(self, scene_node): |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
441 scene_group_id = scene_node.getAttribute('ref') |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
442 scene_group_node = self.get_node(scene_group_id) |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
443 scene_group_node.parent().removeChild(scene_group_node) |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
444 |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
445 self._scenes_node.removeChild(scene_node) |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
446 pass |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
447 |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
448 ## \brief Create and add a svg:g for a scene under a group for a layer. |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
449 # |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
450 def add_scene_group(self, layer_idx): |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
451 layer = self._layers[layer_idx] |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
452 doc = self._doc |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
453 |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
454 scene_group = doc.createElement('svg:g') |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
455 gid = self.new_id() |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
456 scene_group.setAttribute("id", gid) |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
457 scene_group.setAttribute("inkscape:groupmode", "layer") |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
458 |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
459 layer.group.appendChild(scene_group) |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
460 |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
461 return scene_group |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
462 |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
463 def parse_layer(self, layer_idx): |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
464 layer = self._layers[layer_idx] |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
465 layer_group = layer.group |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
466 |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
467 for child in layer_group.childList(): |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
468 if child.name() != 'svg:g': |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
469 continue |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
470 try: |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
471 child_id = child.getAttribute('id') |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
472 scene_node = self.get_scene(child_id) |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
473 except: |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
474 continue |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
475 |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
476 layer.scenes.append(scene_node) |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
477 pass |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
478 pass |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
479 |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
480 ## \brief Add/insert a layer at given position. |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
481 # |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
482 # \param layer_idx is the position in the layer list. |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
483 # |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
484 def insert_layer(self, layer_idx, layer_group): |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
485 layers = self._layers |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
486 |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
487 layer = Layer(layer_group) |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
488 if layer_idx >= len(layers): |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
489 layers.append(layer) |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
490 else: |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
491 layers.insert(layer_idx, layer) |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
492 for idx in range(layer_idx, len(layers)): |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
493 layers[idx].idx = idx |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
494 pass |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
495 pass |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
496 pass |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
497 |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
498 ## \brief Remove layer and associated scene nodes and scene groups. |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
499 # |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
500 def rm_layer(self, layer_idx): |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
501 layers = self._layers |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
502 |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
503 for layer in layers: |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
504 for scene_node in layer.scenes: |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
505 scene_group_id = scene_node.getAttribute('ref') |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
506 scene_group_node = self.get_node(scene_group_id) |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
507 scene_group_node.parent().removeChild(scene_group_node) |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
508 |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
509 scene_node.parent().removeChild(scene_node) |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
510 pass |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
511 pass |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
512 |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
513 del layers[layer_idx] |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
514 |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
515 for idx in range(layer_idx, len(layers)): |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
516 layers[idx].idx = idx |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
517 pass |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
518 pass |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
519 |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
520 def get_layer_num(self): |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
521 return len(self._layers) |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
522 |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
523 def find_layer_n_scene_of_node(self, node_id): |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
524 for layer_idx, layer in enumerate(self._layers): |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
525 for scene_node in layer.scenes: |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
526 scene_group_id = scene_node.getAttribute('ref') |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
527 if scene_group_id == node_id: |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
528 return layer_idx, scene_node |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
529 pass |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
530 pass |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
531 return -1, None |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
532 |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
533 def get_layer_group(self, layer_idx): |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
534 layer = self._layers[layer_idx] |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
535 return layer.group |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
536 |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
537 def get_all_scene_node_of_layer(self, layer_idx): |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
538 layer = self._layers[layer_idx] |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
539 return layer.scenes |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
540 |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
541 def get_layer_data(self, layer_idx): |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
542 layer = self._layers[layer_idx] |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
543 try: |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
544 data = layer.data |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
545 except: |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
546 return None |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
547 return data |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
548 |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
549 def set_layer_data(self, layer_idx, data): |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
550 layer = self._layers[layer_idx] |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
551 layer.data = data |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
552 pass |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
553 |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
554 def create_layer_dup_group(self, layer_idx): |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
555 layer = self._layers[layer_idx] |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
556 |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
557 dup_group = self._doc.createElement('svg:g') |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
558 gid = self.new_id() |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
559 dup_group.setAttribute('id', gid) |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
560 dup_group.setAttribute('inkscape:label', 'dup') |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
561 dup_group.setAttribute('sodipodi:insensitive', '1') |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
562 dup_group.setAttribute('style', '') |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
563 |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
564 layer.group.appendChild(dup_group) |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
565 |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
566 return dup_group |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
567 |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
568 def insert_frames(self, layer_idx, frame_idx, num): |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
569 layer = self._layers[layer_idx] |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
570 for scene_node in layer.scenes: |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
571 start, end, tween_type = self._parse_one_scene(scene_node) |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
572 if start >= frame_idx: |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
573 self.chg_scene_node(scene_node, start=(start + num)) |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
574 pass |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
575 if end >= frame_idx: |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
576 self.chg_scene_node(scene_node, end=(end + num)) |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
577 pass |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
578 pass |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
579 pass |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
580 |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
581 ## \brief Remove frames |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
582 # |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
583 # - Scenes covered by removing range were removed. |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
584 # - Scenes after removing range were shifted left. |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
585 # |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
586 def rm_frames(self, layer_idx, frame_idx, num): |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
587 layer = self._layers[layer_idx] |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
588 |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
589 last_rm = frame_idx + num - 1 # last removed frame |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
590 for scene_node in layer.scenes: |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
591 start, end, tween_type = \ |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
592 self._dom._parse_one_scene(scene_node) |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
593 |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
594 if end < frame_idx: |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
595 continue |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
596 |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
597 if start > last_rm: # this scene is at right side |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
598 self.chg_scene_node(scene_node, |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
599 start=(start - num), |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
600 end=(end - num)) |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
601 else: # this scene is covered by removing range |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
602 self.rm_scene_node_n_group(scene_node) |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
603 pass |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
604 pass |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
605 pass |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
606 |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
607 def get_max_frame(self): |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
608 return self._maxframe |
1246
42c4874c8d1e
Move _duplicate_group to domview_ui.
Thinker K.F. Li <thinker@codemud.net>
parents:
1244
diff
changeset
|
609 |
42c4874c8d1e
Move _duplicate_group to domview_ui.
Thinker K.F. Li <thinker@codemud.net>
parents:
1244
diff
changeset
|
610 ## \brief Copy children of a group. |
42c4874c8d1e
Move _duplicate_group to domview_ui.
Thinker K.F. Li <thinker@codemud.net>
parents:
1244
diff
changeset
|
611 # |
42c4874c8d1e
Move _duplicate_group to domview_ui.
Thinker K.F. Li <thinker@codemud.net>
parents:
1244
diff
changeset
|
612 # Duplicate children of a group, and append them to another group. |
42c4874c8d1e
Move _duplicate_group to domview_ui.
Thinker K.F. Li <thinker@codemud.net>
parents:
1244
diff
changeset
|
613 # |
42c4874c8d1e
Move _duplicate_group to domview_ui.
Thinker K.F. Li <thinker@codemud.net>
parents:
1244
diff
changeset
|
614 def copy_group_children(self, src_group, dst_group): |
42c4874c8d1e
Move _duplicate_group to domview_ui.
Thinker K.F. Li <thinker@codemud.net>
parents:
1244
diff
changeset
|
615 # Search for the duplicated group |
42c4874c8d1e
Move _duplicate_group to domview_ui.
Thinker K.F. Li <thinker@codemud.net>
parents:
1244
diff
changeset
|
616 doc = self._doc |
42c4874c8d1e
Move _duplicate_group to domview_ui.
Thinker K.F. Li <thinker@codemud.net>
parents:
1244
diff
changeset
|
617 |
42c4874c8d1e
Move _duplicate_group to domview_ui.
Thinker K.F. Li <thinker@codemud.net>
parents:
1244
diff
changeset
|
618 dup_group = src_group.duplicate(doc) |
42c4874c8d1e
Move _duplicate_group to domview_ui.
Thinker K.F. Li <thinker@codemud.net>
parents:
1244
diff
changeset
|
619 for child in dup_group.childList(): |
42c4874c8d1e
Move _duplicate_group to domview_ui.
Thinker K.F. Li <thinker@codemud.net>
parents:
1244
diff
changeset
|
620 dup_group.removeChild(child) # prvent from crash |
42c4874c8d1e
Move _duplicate_group to domview_ui.
Thinker K.F. Li <thinker@codemud.net>
parents:
1244
diff
changeset
|
621 dst_group.appendChild(child) |
42c4874c8d1e
Move _duplicate_group to domview_ui.
Thinker K.F. Li <thinker@codemud.net>
parents:
1244
diff
changeset
|
622 pass |
42c4874c8d1e
Move _duplicate_group to domview_ui.
Thinker K.F. Li <thinker@codemud.net>
parents:
1244
diff
changeset
|
623 |
42c4874c8d1e
Move _duplicate_group to domview_ui.
Thinker K.F. Li <thinker@codemud.net>
parents:
1244
diff
changeset
|
624 old_nodes = _DOM_iterator(src_group) |
42c4874c8d1e
Move _duplicate_group to domview_ui.
Thinker K.F. Li <thinker@codemud.net>
parents:
1244
diff
changeset
|
625 new_nodes = _DOM_iterator(dst_group) |
42c4874c8d1e
Move _duplicate_group to domview_ui.
Thinker K.F. Li <thinker@codemud.net>
parents:
1244
diff
changeset
|
626 for old_node in old_nodes: |
42c4874c8d1e
Move _duplicate_group to domview_ui.
Thinker K.F. Li <thinker@codemud.net>
parents:
1244
diff
changeset
|
627 old_node_id = old_node.getAttribute('id') |
42c4874c8d1e
Move _duplicate_group to domview_ui.
Thinker K.F. Li <thinker@codemud.net>
parents:
1244
diff
changeset
|
628 new_node = new_nodes.next() |
42c4874c8d1e
Move _duplicate_group to domview_ui.
Thinker K.F. Li <thinker@codemud.net>
parents:
1244
diff
changeset
|
629 new_node.setAttribute('ns0:duplicate-src', old_node_id) |
42c4874c8d1e
Move _duplicate_group to domview_ui.
Thinker K.F. Li <thinker@codemud.net>
parents:
1244
diff
changeset
|
630 pass |
42c4874c8d1e
Move _duplicate_group to domview_ui.
Thinker K.F. Li <thinker@codemud.net>
parents:
1244
diff
changeset
|
631 pass |
1243
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
632 pass |
d5f70928e9f1
Move MBScene_domview_ui and MBScene_domview to separated modules.
Thinker K.F. Li <thinker@codemud.net>
parents:
diff
changeset
|
633 |