annotate pyink/MBScene.py @ 1206:1d476b35dc79

Merge and move code of tracking max frame number to MBScene_dom_monitor
author Thinker K.F. Li <thinker@codemud.net>
date Tue, 04 Jan 2011 10:08:02 +0800
parents 1af64bcdfd7d ca4e89cc464b
children 489e6e474fdf
rev   line source
941
9ba94c577a6f Add scene editor. This vewrsion can only switch scene. It can not change the scene yet.
wycc
parents:
diff changeset
1 #!/usr/bin/python
1150
6586cd10c92f Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents: 1149
diff changeset
2 # -*- indent-tabs-mode: t; tab-width: 8; python-indent: 4; fill-column: 79 -*-
6586cd10c92f Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents: 1149
diff changeset
3 # vim: sw=4:ts=8:sts=4:textwidth=79
941
9ba94c577a6f Add scene editor. This vewrsion can only switch scene. It can not change the scene yet.
wycc
parents:
diff changeset
4 import pygtk
9ba94c577a6f Add scene editor. This vewrsion can only switch scene. It can not change the scene yet.
wycc
parents:
diff changeset
5 import gtk
1064
16c69756ef5d Add NodeObserver to monitor the change of the layer and update it in the scene editor.
wycc
parents: 1032
diff changeset
6 import glib
941
9ba94c577a6f Add scene editor. This vewrsion can only switch scene. It can not change the scene yet.
wycc
parents:
diff changeset
7 from copy import deepcopy
9ba94c577a6f Add scene editor. This vewrsion can only switch scene. It can not change the scene yet.
wycc
parents:
diff changeset
8 from lxml import etree
9ba94c577a6f Add scene editor. This vewrsion can only switch scene. It can not change the scene yet.
wycc
parents:
diff changeset
9 import random
9ba94c577a6f Add scene editor. This vewrsion can only switch scene. It can not change the scene yet.
wycc
parents:
diff changeset
10 import traceback
973
84f502fb3e40 Rewrite the MBScene to use framelines. The old layers/scenes data structure is used to load the scenes only. We should remove it completely in the future.
wycc
parents: 964
diff changeset
11 import time
1064
16c69756ef5d Add NodeObserver to monitor the change of the layer and update it in the scene editor.
wycc
parents: 1032
diff changeset
12 import pybInkscape
1128
b65ac686a7c5 Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents: 1125
diff changeset
13 import math
1140
d4dbcb93aee0 Separate the tween from the main module.
wycc
parents: 1136
diff changeset
14 from tween import TweenObject
1150
6586cd10c92f Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents: 1149
diff changeset
15 from frameline import frameline, frameruler
941
9ba94c577a6f Add scene editor. This vewrsion can only switch scene. It can not change the scene yet.
wycc
parents:
diff changeset
16
957
8e3e46c26137 Break long lines
Thinker K.F. Li <thinker@codemud.net>
parents: 956
diff changeset
17 # Please refer to
8e3e46c26137 Break long lines
Thinker K.F. Li <thinker@codemud.net>
parents: 956
diff changeset
18 # http://www.assembla.com/wiki/show/MadButterfly/Inkscape_extention
8e3e46c26137 Break long lines
Thinker K.F. Li <thinker@codemud.net>
parents: 956
diff changeset
19 # for the designed document.
941
9ba94c577a6f Add scene editor. This vewrsion can only switch scene. It can not change the scene yet.
wycc
parents:
diff changeset
20
9ba94c577a6f Add scene editor. This vewrsion can only switch scene. It can not change the scene yet.
wycc
parents:
diff changeset
21
9ba94c577a6f Add scene editor. This vewrsion can only switch scene. It can not change the scene yet.
wycc
parents:
diff changeset
22 # Algorithm:
9ba94c577a6f Add scene editor. This vewrsion can only switch scene. It can not change the scene yet.
wycc
parents:
diff changeset
23 #
955
53b0f8dc2284 Add tailing 'pass' commands to close indents
Thinker K.F. Li <thinker@codemud.net>
parents: 943
diff changeset
24 # We will parse the first two level of the SVG DOM. collect a table of
53b0f8dc2284 Add tailing 'pass' commands to close indents
Thinker K.F. Li <thinker@codemud.net>
parents: 943
diff changeset
25 # layer and scene.
53b0f8dc2284 Add tailing 'pass' commands to close indents
Thinker K.F. Li <thinker@codemud.net>
parents: 943
diff changeset
26 # - 1. Collect the layer table which will be displayed as the first
53b0f8dc2284 Add tailing 'pass' commands to close indents
Thinker K.F. Li <thinker@codemud.net>
parents: 943
diff changeset
27 # column of the grid.
53b0f8dc2284 Add tailing 'pass' commands to close indents
Thinker K.F. Li <thinker@codemud.net>
parents: 943
diff changeset
28 # - 2. Get the maximum scene number. This will decide the size of the
53b0f8dc2284 Add tailing 'pass' commands to close indents
Thinker K.F. Li <thinker@codemud.net>
parents: 943
diff changeset
29 # grid.
53b0f8dc2284 Add tailing 'pass' commands to close indents
Thinker K.F. Li <thinker@codemud.net>
parents: 943
diff changeset
30 # - 3. When F6 is pressed, we will check if this scene has been
53b0f8dc2284 Add tailing 'pass' commands to close indents
Thinker K.F. Li <thinker@codemud.net>
parents: 943
diff changeset
31 # defined. This can be done by scan all second level group and
53b0f8dc2284 Add tailing 'pass' commands to close indents
Thinker K.F. Li <thinker@codemud.net>
parents: 943
diff changeset
32 # check if the current scene number is within the range specified
53b0f8dc2284 Add tailing 'pass' commands to close indents
Thinker K.F. Li <thinker@codemud.net>
parents: 943
diff changeset
33 # by scene field. The function IsSceneDefined(scene) can be used
53b0f8dc2284 Add tailing 'pass' commands to close indents
Thinker K.F. Li <thinker@codemud.net>
parents: 943
diff changeset
34 # for this purpose.
53b0f8dc2284 Add tailing 'pass' commands to close indents
Thinker K.F. Li <thinker@codemud.net>
parents: 943
diff changeset
35 # - 4. If this is a new scene, we will append a new group which
53b0f8dc2284 Add tailing 'pass' commands to close indents
Thinker K.F. Li <thinker@codemud.net>
parents: 943
diff changeset
36 # duplication the content of the last scene in the same
53b0f8dc2284 Add tailing 'pass' commands to close indents
Thinker K.F. Li <thinker@codemud.net>
parents: 943
diff changeset
37 # group. The scene field will contain the number from the last
53b0f8dc2284 Add tailing 'pass' commands to close indents
Thinker K.F. Li <thinker@codemud.net>
parents: 943
diff changeset
38 # scene number of the last scene to the current scenen
53b0f8dc2284 Add tailing 'pass' commands to close indents
Thinker K.F. Li <thinker@codemud.net>
parents: 943
diff changeset
39 # number. For example, if the last scene is from 4-7 and the new
53b0f8dc2284 Add tailing 'pass' commands to close indents
Thinker K.F. Li <thinker@codemud.net>
parents: 943
diff changeset
40 # scene is 10, we will set the scene field as "8-10".
53b0f8dc2284 Add tailing 'pass' commands to close indents
Thinker K.F. Li <thinker@codemud.net>
parents: 943
diff changeset
41 # - 5. If this scene are filled screne, we will split the existing
53b0f8dc2284 Add tailing 'pass' commands to close indents
Thinker K.F. Li <thinker@codemud.net>
parents: 943
diff changeset
42 # scene into two scenes with the same content.
53b0f8dc2284 Add tailing 'pass' commands to close indents
Thinker K.F. Li <thinker@codemud.net>
parents: 943
diff changeset
43 #
941
9ba94c577a6f Add scene editor. This vewrsion can only switch scene. It can not change the scene yet.
wycc
parents:
diff changeset
44
9ba94c577a6f Add scene editor. This vewrsion can only switch scene. It can not change the scene yet.
wycc
parents:
diff changeset
45 class Layer:
955
53b0f8dc2284 Add tailing 'pass' commands to close indents
Thinker K.F. Li <thinker@codemud.net>
parents: 943
diff changeset
46 def __init__(self,node):
962
6612fd386ea9 Rename Layer.scene to Layer.scenes since it is a list of scenes
Thinker K.F. Li <thinker@codemud.net>
parents: 961
diff changeset
47 self.scenes = []
1190
a4df892fb4e5 Use meaningful name for scene, scene group, and layer group
Thinker K.F. Li <thinker@codemud.net>
parents: 1189
diff changeset
48 self.group = node
955
53b0f8dc2284 Add tailing 'pass' commands to close indents
Thinker K.F. Li <thinker@codemud.net>
parents: 943
diff changeset
49 pass
53b0f8dc2284 Add tailing 'pass' commands to close indents
Thinker K.F. Li <thinker@codemud.net>
parents: 943
diff changeset
50 pass
53b0f8dc2284 Add tailing 'pass' commands to close indents
Thinker K.F. Li <thinker@codemud.net>
parents: 943
diff changeset
51
941
9ba94c577a6f Add scene editor. This vewrsion can only switch scene. It can not change the scene yet.
wycc
parents:
diff changeset
52 class Scene:
1120
214e1f628d63 Add tween type selector into the UI. This UI can be used to update the type attribute of the SVG.
wycc
parents: 1099
diff changeset
53 def __init__(self, node, start,end,typ):
956
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
54 self.node = node
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
55 self.start = int(start)
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
56 self.end = int(end)
1120
214e1f628d63 Add tween type selector into the UI. This UI can be used to update the type attribute of the SVG.
wycc
parents: 1099
diff changeset
57 self.type = typ
955
53b0f8dc2284 Add tailing 'pass' commands to close indents
Thinker K.F. Li <thinker@codemud.net>
parents: 943
diff changeset
58 pass
956
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
59 pass
1128
b65ac686a7c5 Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents: 1125
diff changeset
60 class DOM(pybInkscape.PYSPObject):
b65ac686a7c5 Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents: 1125
diff changeset
61 def __init__(self,obj=None):
b65ac686a7c5 Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents: 1125
diff changeset
62 self.proxy = obj
b65ac686a7c5 Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents: 1125
diff changeset
63 pass
1149
0ffef2df6201 Rename MBScene.dom to MBScene.root
Thinker K.F. Li <thinker@codemud.net>
parents: 1148
diff changeset
64
1128
b65ac686a7c5 Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents: 1125
diff changeset
65 def duplicate(self,doc):
b65ac686a7c5 Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents: 1125
diff changeset
66 return DOM(self.repr.duplicate(doc))
b65ac686a7c5 Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents: 1125
diff changeset
67
b65ac686a7c5 Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents: 1125
diff changeset
68 class ObjectWatcher(pybInkscape.PYNodeObserver):
b65ac686a7c5 Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents: 1125
diff changeset
69 def __init__(self,obj,type,func,arg):
b65ac686a7c5 Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents: 1125
diff changeset
70 self.obj = obj
b65ac686a7c5 Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents: 1125
diff changeset
71 self.type = type
b65ac686a7c5 Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents: 1125
diff changeset
72 self.func = func
b65ac686a7c5 Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents: 1125
diff changeset
73 self.arg = arg
b65ac686a7c5 Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents: 1125
diff changeset
74
1191
6442fb198418 Refactory insertKeyScene() and fix bug of ObjectWatcher
Thinker K.F. Li <thinker@codemud.net>
parents: 1190
diff changeset
75 def notifyChildAdded(self, node, child, prev):
1128
b65ac686a7c5 Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents: 1125
diff changeset
76 if self.type == 'DOMNodeInserted':
1191
6442fb198418 Refactory insertKeyScene() and fix bug of ObjectWatcher
Thinker K.F. Li <thinker@codemud.net>
parents: 1190
diff changeset
77 self.func(node, child)
6442fb198418 Refactory insertKeyScene() and fix bug of ObjectWatcher
Thinker K.F. Li <thinker@codemud.net>
parents: 1190
diff changeset
78 def notifyChildRemoved(self, node, child, prev):
1128
b65ac686a7c5 Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents: 1125
diff changeset
79 if self.type == 'DOMNodeRemoved':
1191
6442fb198418 Refactory insertKeyScene() and fix bug of ObjectWatcher
Thinker K.F. Li <thinker@codemud.net>
parents: 1190
diff changeset
80 self.func(node, child)
1128
b65ac686a7c5 Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents: 1125
diff changeset
81 def notifyChildOrderChanged(self,node,child,prev):
b65ac686a7c5 Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents: 1125
diff changeset
82 pass
b65ac686a7c5 Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents: 1125
diff changeset
83 def notifyContentChanged(self,node,old_content,new_content):
b65ac686a7c5 Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents: 1125
diff changeset
84 if self.type == 'DOMSubtreeModified':
b65ac686a7c5 Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents: 1125
diff changeset
85 self.func(node)
b65ac686a7c5 Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents: 1125
diff changeset
86 def notifyAttributeChanged(self,node, name, old_value, new_value):
b65ac686a7c5 Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents: 1125
diff changeset
87 if self.type == 'DOMAttrModified':
1188
45e3a9273af2 Move code about monitoring DOM-tree to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1185
diff changeset
88 self.func(node, name, old_value, new_value)
1128
b65ac686a7c5 Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents: 1125
diff changeset
89
b65ac686a7c5 Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents: 1125
diff changeset
90 def addEventListener(obj, type, func,arg):
b65ac686a7c5 Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents: 1125
diff changeset
91 obs = ObjectWatcher(obj,type,func,arg)
b65ac686a7c5 Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents: 1125
diff changeset
92 obj.addSubtreeObserver(obs)
b65ac686a7c5 Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents: 1125
diff changeset
93
941
9ba94c577a6f Add scene editor. This vewrsion can only switch scene. It can not change the scene yet.
wycc
parents:
diff changeset
94
957
8e3e46c26137 Break long lines
Thinker K.F. Li <thinker@codemud.net>
parents: 956
diff changeset
95 _scenes = '{http://madbutterfly.sourceforge.net/DTD/madbutterfly.dtd}scenes'
8e3e46c26137 Break long lines
Thinker K.F. Li <thinker@codemud.net>
parents: 956
diff changeset
96 _scene = '{http://madbutterfly.sourceforge.net/DTD/madbutterfly.dtd}scene'
1064
16c69756ef5d Add NodeObserver to monitor the change of the layer and update it in the scene editor.
wycc
parents: 1032
diff changeset
97 class LayerAttributeWatcher(pybInkscape.PYNodeObserver):
16c69756ef5d Add NodeObserver to monitor the change of the layer and update it in the scene editor.
wycc
parents: 1032
diff changeset
98 def __init__(self,ui):
16c69756ef5d Add NodeObserver to monitor the change of the layer and update it in the scene editor.
wycc
parents: 1032
diff changeset
99 self.ui = ui
16c69756ef5d Add NodeObserver to monitor the change of the layer and update it in the scene editor.
wycc
parents: 1032
diff changeset
100 def notifyChildAdded(self,node,child,prev):
16c69756ef5d Add NodeObserver to monitor the change of the layer and update it in the scene editor.
wycc
parents: 1032
diff changeset
101 pass
1144
257beac7c982 Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents: 1142
diff changeset
102
1064
16c69756ef5d Add NodeObserver to monitor the change of the layer and update it in the scene editor.
wycc
parents: 1032
diff changeset
103 def notifyChildRemoved(self,node,child,prev):
16c69756ef5d Add NodeObserver to monitor the change of the layer and update it in the scene editor.
wycc
parents: 1032
diff changeset
104 pass
1144
257beac7c982 Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents: 1142
diff changeset
105
1064
16c69756ef5d Add NodeObserver to monitor the change of the layer and update it in the scene editor.
wycc
parents: 1032
diff changeset
106 def notifyChildOrderChanged(self,node,child,prev):
16c69756ef5d Add NodeObserver to monitor the change of the layer and update it in the scene editor.
wycc
parents: 1032
diff changeset
107 pass
1144
257beac7c982 Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents: 1142
diff changeset
108
1064
16c69756ef5d Add NodeObserver to monitor the change of the layer and update it in the scene editor.
wycc
parents: 1032
diff changeset
109 def notifyContentChanged(self,node,old_content,new_content):
16c69756ef5d Add NodeObserver to monitor the change of the layer and update it in the scene editor.
wycc
parents: 1032
diff changeset
110 pass
1144
257beac7c982 Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents: 1142
diff changeset
111
1064
16c69756ef5d Add NodeObserver to monitor the change of the layer and update it in the scene editor.
wycc
parents: 1032
diff changeset
112 def notifyAttributeChanged(self,node, name, old_value, new_value):
16c69756ef5d Add NodeObserver to monitor the change of the layer and update it in the scene editor.
wycc
parents: 1032
diff changeset
113 self.ui.updateUI()
1144
257beac7c982 Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents: 1142
diff changeset
114 pass
257beac7c982 Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents: 1142
diff changeset
115
1064
16c69756ef5d Add NodeObserver to monitor the change of the layer and update it in the scene editor.
wycc
parents: 1032
diff changeset
116 class LayerAddRemoveWatcher(pybInkscape.PYNodeObserver):
16c69756ef5d Add NodeObserver to monitor the change of the layer and update it in the scene editor.
wycc
parents: 1032
diff changeset
117 def __init__(self,ui):
16c69756ef5d Add NodeObserver to monitor the change of the layer and update it in the scene editor.
wycc
parents: 1032
diff changeset
118 self.ui = ui
1144
257beac7c982 Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents: 1142
diff changeset
119 pass
257beac7c982 Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents: 1142
diff changeset
120
1064
16c69756ef5d Add NodeObserver to monitor the change of the layer and update it in the scene editor.
wycc
parents: 1032
diff changeset
121 def notifyChildAdded(self,node,child,prev):
16c69756ef5d Add NodeObserver to monitor the change of the layer and update it in the scene editor.
wycc
parents: 1032
diff changeset
122 self.ui.updateUI()
1144
257beac7c982 Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents: 1142
diff changeset
123 pass
257beac7c982 Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents: 1142
diff changeset
124
1064
16c69756ef5d Add NodeObserver to monitor the change of the layer and update it in the scene editor.
wycc
parents: 1032
diff changeset
125 def notifyChildRemoved(self,node,child,prev):
16c69756ef5d Add NodeObserver to monitor the change of the layer and update it in the scene editor.
wycc
parents: 1032
diff changeset
126 self.ui.updateUI()
1144
257beac7c982 Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents: 1142
diff changeset
127 pass
257beac7c982 Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents: 1142
diff changeset
128
1064
16c69756ef5d Add NodeObserver to monitor the change of the layer and update it in the scene editor.
wycc
parents: 1032
diff changeset
129 def notifyChildOrderChanged(self,node,child,prev):
16c69756ef5d Add NodeObserver to monitor the change of the layer and update it in the scene editor.
wycc
parents: 1032
diff changeset
130 self.ui.updateUI()
1144
257beac7c982 Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents: 1142
diff changeset
131 pass
257beac7c982 Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents: 1142
diff changeset
132
1064
16c69756ef5d Add NodeObserver to monitor the change of the layer and update it in the scene editor.
wycc
parents: 1032
diff changeset
133 def notifyContentChanged(self,node,old_content,new_content):
16c69756ef5d Add NodeObserver to monitor the change of the layer and update it in the scene editor.
wycc
parents: 1032
diff changeset
134 self.ui.updateUI()
1144
257beac7c982 Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents: 1142
diff changeset
135 pass
257beac7c982 Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents: 1142
diff changeset
136
1064
16c69756ef5d Add NodeObserver to monitor the change of the layer and update it in the scene editor.
wycc
parents: 1032
diff changeset
137 def notifyAttributeChanged(self,node, name, old_value, new_value):
16c69756ef5d Add NodeObserver to monitor the change of the layer and update it in the scene editor.
wycc
parents: 1032
diff changeset
138 self.ui.updateUI()
1144
257beac7c982 Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents: 1142
diff changeset
139 pass
257beac7c982 Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents: 1142
diff changeset
140
1151
71c72e8d6755 Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents: 1150
diff changeset
141 def _travel_DOM(node):
71c72e8d6755 Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents: 1150
diff changeset
142 nodes = [node]
71c72e8d6755 Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents: 1150
diff changeset
143 while nodes:
71c72e8d6755 Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents: 1150
diff changeset
144 node = nodes.pop(0)
71c72e8d6755 Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents: 1150
diff changeset
145 child = node.firstChild()
71c72e8d6755 Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents: 1150
diff changeset
146 while child:
71c72e8d6755 Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents: 1150
diff changeset
147 nodes.append(child)
71c72e8d6755 Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents: 1150
diff changeset
148 child = child.next()
71c72e8d6755 Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents: 1150
diff changeset
149 pass
71c72e8d6755 Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents: 1150
diff changeset
150 yield node
71c72e8d6755 Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents: 1150
diff changeset
151 pass
71c72e8d6755 Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents: 1150
diff changeset
152 pass
71c72e8d6755 Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents: 1150
diff changeset
153
1188
45e3a9273af2 Move code about monitoring DOM-tree to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1185
diff changeset
154
45e3a9273af2 Move code about monitoring DOM-tree to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1185
diff changeset
155 ## \brief Monitor changes of DOM-tree.
1181
f14dbcf19e2b Move MBScene.insertKeyScene() to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents: 1180
diff changeset
156 #
1188
45e3a9273af2 Move code about monitoring DOM-tree to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1185
diff changeset
157 class MBScene_dom_monitor(object):
45e3a9273af2 Move code about monitoring DOM-tree to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1185
diff changeset
158 def __init__(self, *args, **kws):
45e3a9273af2 Move code about monitoring DOM-tree to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1185
diff changeset
159 super(MBScene_dom_monitor, self).__init__()
45e3a9273af2 Move code about monitoring DOM-tree to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1185
diff changeset
160
1206
1d476b35dc79 Merge and move code of tracking max frame number to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1205 1186
diff changeset
161 self._maxframe = 0
1188
45e3a9273af2 Move code about monitoring DOM-tree to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1185
diff changeset
162 self._id2node = {} # map ID to the node in the DOM tree.
1189
9cf183faf89f Maintaining scene group ID to scene node mapping in MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1188
diff changeset
163 self._group2scene = {} # map ID of a group to associated scene node.
1188
45e3a9273af2 Move code about monitoring DOM-tree to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1185
diff changeset
164 pass
45e3a9273af2 Move code about monitoring DOM-tree to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1185
diff changeset
165
45e3a9273af2 Move code about monitoring DOM-tree to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1185
diff changeset
166 def _start_monitor(self):
45e3a9273af2 Move code about monitoring DOM-tree to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1185
diff changeset
167 self._collect_node_ids()
1206
1d476b35dc79 Merge and move code of tracking max frame number to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1205 1186
diff changeset
168 self._collect_all_scenes()
1188
45e3a9273af2 Move code about monitoring DOM-tree to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1185
diff changeset
169
45e3a9273af2 Move code about monitoring DOM-tree to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1185
diff changeset
170 doc = self._doc
45e3a9273af2 Move code about monitoring DOM-tree to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1185
diff changeset
171 addEventListener(doc,'DOMNodeInserted', self._on_insert_node, None)
45e3a9273af2 Move code about monitoring DOM-tree to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1185
diff changeset
172 addEventListener(doc,'DOMNodeRemoved', self._on_remove_node, None)
45e3a9273af2 Move code about monitoring DOM-tree to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1185
diff changeset
173 addEventListener(doc, 'DOMAttrModified', self._on_attr_modified, None)
45e3a9273af2 Move code about monitoring DOM-tree to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1185
diff changeset
174 pass
45e3a9273af2 Move code about monitoring DOM-tree to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1185
diff changeset
175
1191
6442fb198418 Refactory insertKeyScene() and fix bug of ObjectWatcher
Thinker K.F. Li <thinker@codemud.net>
parents: 1190
diff changeset
176 def _on_insert_node(self, node, child):
1188
45e3a9273af2 Move code about monitoring DOM-tree to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1185
diff changeset
177 try:
1191
6442fb198418 Refactory insertKeyScene() and fix bug of ObjectWatcher
Thinker K.F. Li <thinker@codemud.net>
parents: 1190
diff changeset
178 child_id = child.getAttribute('id')
1188
45e3a9273af2 Move code about monitoring DOM-tree to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1185
diff changeset
179 except:
1189
9cf183faf89f Maintaining scene group ID to scene node mapping in MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1188
diff changeset
180 pass
9cf183faf89f Maintaining scene group ID to scene node mapping in MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1188
diff changeset
181 else:
1191
6442fb198418 Refactory insertKeyScene() and fix bug of ObjectWatcher
Thinker K.F. Li <thinker@codemud.net>
parents: 1190
diff changeset
182 if child_id not in self._id2node:
6442fb198418 Refactory insertKeyScene() and fix bug of ObjectWatcher
Thinker K.F. Li <thinker@codemud.net>
parents: 1190
diff changeset
183 self._id2node[child_id] = child
1189
9cf183faf89f Maintaining scene group ID to scene node mapping in MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1188
diff changeset
184 pass
9cf183faf89f Maintaining scene group ID to scene node mapping in MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1188
diff changeset
185 pass
9cf183faf89f Maintaining scene group ID to scene node mapping in MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1188
diff changeset
186
1191
6442fb198418 Refactory insertKeyScene() and fix bug of ObjectWatcher
Thinker K.F. Li <thinker@codemud.net>
parents: 1190
diff changeset
187 if child.name() == 'ns0:scene':
1189
9cf183faf89f Maintaining scene group ID to scene node mapping in MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1188
diff changeset
188 try:
1191
6442fb198418 Refactory insertKeyScene() and fix bug of ObjectWatcher
Thinker K.F. Li <thinker@codemud.net>
parents: 1190
diff changeset
189 ref = child.getAttribute('ref')
1189
9cf183faf89f Maintaining scene group ID to scene node mapping in MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1188
diff changeset
190 except:
9cf183faf89f Maintaining scene group ID to scene node mapping in MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1188
diff changeset
191 pass
9cf183faf89f Maintaining scene group ID to scene node mapping in MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1188
diff changeset
192 else:
9cf183faf89f Maintaining scene group ID to scene node mapping in MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1188
diff changeset
193 if ref not in self._group2scene:
1191
6442fb198418 Refactory insertKeyScene() and fix bug of ObjectWatcher
Thinker K.F. Li <thinker@codemud.net>
parents: 1190
diff changeset
194 self._group2scene[ref] = child
1189
9cf183faf89f Maintaining scene group ID to scene node mapping in MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1188
diff changeset
195 pass
9cf183faf89f Maintaining scene group ID to scene node mapping in MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1188
diff changeset
196 pass
1206
1d476b35dc79 Merge and move code of tracking max frame number to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1205 1186
diff changeset
197
1d476b35dc79 Merge and move code of tracking max frame number to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1205 1186
diff changeset
198 try:
1d476b35dc79 Merge and move code of tracking max frame number to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1205 1186
diff changeset
199 start = child.getAttribute('start')
1d476b35dc79 Merge and move code of tracking max frame number to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1205 1186
diff changeset
200 self._maxframe = max(int(start), self._maxframe)
1d476b35dc79 Merge and move code of tracking max frame number to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1205 1186
diff changeset
201 except:
1d476b35dc79 Merge and move code of tracking max frame number to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1205 1186
diff changeset
202 pass
1d476b35dc79 Merge and move code of tracking max frame number to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1205 1186
diff changeset
203 try:
1d476b35dc79 Merge and move code of tracking max frame number to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1205 1186
diff changeset
204 start = child.getAttribute('end')
1d476b35dc79 Merge and move code of tracking max frame number to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1205 1186
diff changeset
205 self._maxframe = max(int(start), self._maxframe)
1d476b35dc79 Merge and move code of tracking max frame number to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1205 1186
diff changeset
206 except:
1d476b35dc79 Merge and move code of tracking max frame number to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1205 1186
diff changeset
207 pass
1189
9cf183faf89f Maintaining scene group ID to scene node mapping in MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1188
diff changeset
208 pass
1188
45e3a9273af2 Move code about monitoring DOM-tree to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1185
diff changeset
209 pass
45e3a9273af2 Move code about monitoring DOM-tree to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1185
diff changeset
210
1206
1d476b35dc79 Merge and move code of tracking max frame number to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1205 1186
diff changeset
211 def _find_maxframe(self, scenes_node):
1d476b35dc79 Merge and move code of tracking max frame number to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1205 1186
diff changeset
212 maxframe = 0
1d476b35dc79 Merge and move code of tracking max frame number to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1205 1186
diff changeset
213 for child in scenes_node.childList():
1d476b35dc79 Merge and move code of tracking max frame number to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1205 1186
diff changeset
214 if child.name() != 'ns0:scene':
1d476b35dc79 Merge and move code of tracking max frame number to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1205 1186
diff changeset
215 continue
1d476b35dc79 Merge and move code of tracking max frame number to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1205 1186
diff changeset
216
1d476b35dc79 Merge and move code of tracking max frame number to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1205 1186
diff changeset
217 try:
1d476b35dc79 Merge and move code of tracking max frame number to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1205 1186
diff changeset
218 start = child.getAttribute('start')
1d476b35dc79 Merge and move code of tracking max frame number to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1205 1186
diff changeset
219 maxframe = max(int(start), maxframe)
1d476b35dc79 Merge and move code of tracking max frame number to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1205 1186
diff changeset
220 except:
1d476b35dc79 Merge and move code of tracking max frame number to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1205 1186
diff changeset
221 pass
1d476b35dc79 Merge and move code of tracking max frame number to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1205 1186
diff changeset
222 try:
1d476b35dc79 Merge and move code of tracking max frame number to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1205 1186
diff changeset
223 end = child.getAttribute('end')
1d476b35dc79 Merge and move code of tracking max frame number to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1205 1186
diff changeset
224 maxframe = max(int(end), maxframe)
1d476b35dc79 Merge and move code of tracking max frame number to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1205 1186
diff changeset
225 except:
1d476b35dc79 Merge and move code of tracking max frame number to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1205 1186
diff changeset
226 pass
1d476b35dc79 Merge and move code of tracking max frame number to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1205 1186
diff changeset
227 pass
1d476b35dc79 Merge and move code of tracking max frame number to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1205 1186
diff changeset
228 return maxframe
1d476b35dc79 Merge and move code of tracking max frame number to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1205 1186
diff changeset
229
1191
6442fb198418 Refactory insertKeyScene() and fix bug of ObjectWatcher
Thinker K.F. Li <thinker@codemud.net>
parents: 1190
diff changeset
230 def _on_remove_node(self, node, child):
1188
45e3a9273af2 Move code about monitoring DOM-tree to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1185
diff changeset
231 try:
1191
6442fb198418 Refactory insertKeyScene() and fix bug of ObjectWatcher
Thinker K.F. Li <thinker@codemud.net>
parents: 1190
diff changeset
232 child_id = child.getAttribute('id')
1188
45e3a9273af2 Move code about monitoring DOM-tree to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1185
diff changeset
233 except:
1189
9cf183faf89f Maintaining scene group ID to scene node mapping in MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1188
diff changeset
234 pass
9cf183faf89f Maintaining scene group ID to scene node mapping in MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1188
diff changeset
235 else:
1191
6442fb198418 Refactory insertKeyScene() and fix bug of ObjectWatcher
Thinker K.F. Li <thinker@codemud.net>
parents: 1190
diff changeset
236 if child_id not in self._id2node:
1189
9cf183faf89f Maintaining scene group ID to scene node mapping in MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1188
diff changeset
237 raise ValueError, \
1191
6442fb198418 Refactory insertKeyScene() and fix bug of ObjectWatcher
Thinker K.F. Li <thinker@codemud.net>
parents: 1190
diff changeset
238 'remove a node that is never known (%s)' % (child_id)
6442fb198418 Refactory insertKeyScene() and fix bug of ObjectWatcher
Thinker K.F. Li <thinker@codemud.net>
parents: 1190
diff changeset
239 del self._id2node[child_id]
1189
9cf183faf89f Maintaining scene group ID to scene node mapping in MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1188
diff changeset
240 pass
9cf183faf89f Maintaining scene group ID to scene node mapping in MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1188
diff changeset
241
1191
6442fb198418 Refactory insertKeyScene() and fix bug of ObjectWatcher
Thinker K.F. Li <thinker@codemud.net>
parents: 1190
diff changeset
242 if child.name() == 'ns0:scene':
1189
9cf183faf89f Maintaining scene group ID to scene node mapping in MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1188
diff changeset
243 try:
1191
6442fb198418 Refactory insertKeyScene() and fix bug of ObjectWatcher
Thinker K.F. Li <thinker@codemud.net>
parents: 1190
diff changeset
244 ref = child.getAttribute('ref')
1189
9cf183faf89f Maintaining scene group ID to scene node mapping in MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1188
diff changeset
245 except:
9cf183faf89f Maintaining scene group ID to scene node mapping in MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1188
diff changeset
246 pass
9cf183faf89f Maintaining scene group ID to scene node mapping in MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1188
diff changeset
247 else:
9cf183faf89f Maintaining scene group ID to scene node mapping in MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1188
diff changeset
248 del self._group2scene[ref]
9cf183faf89f Maintaining scene group ID to scene node mapping in MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1188
diff changeset
249 pass
1206
1d476b35dc79 Merge and move code of tracking max frame number to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1205 1186
diff changeset
250
1d476b35dc79 Merge and move code of tracking max frame number to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1205 1186
diff changeset
251 try:
1d476b35dc79 Merge and move code of tracking max frame number to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1205 1186
diff changeset
252 if node.name() == 'ns0:scenes' and \
1d476b35dc79 Merge and move code of tracking max frame number to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1205 1186
diff changeset
253 (int(child.getAttribute('start')) == self._maxframe or
1d476b35dc79 Merge and move code of tracking max frame number to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1205 1186
diff changeset
254 int(child.getAttribute('end')) == self._maxframe):
1d476b35dc79 Merge and move code of tracking max frame number to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1205 1186
diff changeset
255 self._maxframe = self._find_maxframe(node)
1d476b35dc79 Merge and move code of tracking max frame number to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1205 1186
diff changeset
256 pass
1d476b35dc79 Merge and move code of tracking max frame number to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1205 1186
diff changeset
257 except:
1d476b35dc79 Merge and move code of tracking max frame number to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1205 1186
diff changeset
258 pass
1189
9cf183faf89f Maintaining scene group ID to scene node mapping in MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1188
diff changeset
259 pass
1188
45e3a9273af2 Move code about monitoring DOM-tree to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1185
diff changeset
260 pass
45e3a9273af2 Move code about monitoring DOM-tree to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1185
diff changeset
261
45e3a9273af2 Move code about monitoring DOM-tree to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1185
diff changeset
262 def _on_attr_modified(self, node, name, old_value, new_value):
1189
9cf183faf89f Maintaining scene group ID to scene node mapping in MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1188
diff changeset
263 if name == 'id' and old_value != new_value:
9cf183faf89f Maintaining scene group ID to scene node mapping in MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1188
diff changeset
264 if old_value and (old_value not in self._id2node):
9cf183faf89f Maintaining scene group ID to scene node mapping in MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1188
diff changeset
265 raise ValueError, \
1195
cb2c611d1656 Fix bug of duplicating a keyframe
Thinker K.F. Li <thinker@codemud.net>
parents: 1194
diff changeset
266 'old ID value of passed node is invalid one (%s)' % \
1189
9cf183faf89f Maintaining scene group ID to scene node mapping in MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1188
diff changeset
267 (old_value)
9cf183faf89f Maintaining scene group ID to scene node mapping in MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1188
diff changeset
268 if (new_value in self._id2node):
9cf183faf89f Maintaining scene group ID to scene node mapping in MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1188
diff changeset
269 raise ValueError, \
1195
cb2c611d1656 Fix bug of duplicating a keyframe
Thinker K.F. Li <thinker@codemud.net>
parents: 1194
diff changeset
270 'new ID value of passed node is invalid one (%s)' % \
1189
9cf183faf89f Maintaining scene group ID to scene node mapping in MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1188
diff changeset
271 (new_value)
9cf183faf89f Maintaining scene group ID to scene node mapping in MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1188
diff changeset
272
9cf183faf89f Maintaining scene group ID to scene node mapping in MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1188
diff changeset
273 if old_value:
9cf183faf89f Maintaining scene group ID to scene node mapping in MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1188
diff changeset
274 del self._id2node[old_value]
9cf183faf89f Maintaining scene group ID to scene node mapping in MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1188
diff changeset
275 pass
9cf183faf89f Maintaining scene group ID to scene node mapping in MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1188
diff changeset
276 self._id2node[new_value] = node
9cf183faf89f Maintaining scene group ID to scene node mapping in MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1188
diff changeset
277 pass
9cf183faf89f Maintaining scene group ID to scene node mapping in MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1188
diff changeset
278 elif name == 'ref' and node.name() == 'ns0:scene':
9cf183faf89f Maintaining scene group ID to scene node mapping in MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1188
diff changeset
279 if old_value == new_value:
9cf183faf89f Maintaining scene group ID to scene node mapping in MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1188
diff changeset
280 return
9cf183faf89f Maintaining scene group ID to scene node mapping in MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1188
diff changeset
281 if old_value:
9cf183faf89f Maintaining scene group ID to scene node mapping in MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1188
diff changeset
282 node = self._group2scene[old_value] # use old node. Binding
9cf183faf89f Maintaining scene group ID to scene node mapping in MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1188
diff changeset
283 # may generate a new
9cf183faf89f Maintaining scene group ID to scene node mapping in MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1188
diff changeset
284 # wrapper.
9cf183faf89f Maintaining scene group ID to scene node mapping in MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1188
diff changeset
285 del self._group2scene[old_value]
9cf183faf89f Maintaining scene group ID to scene node mapping in MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1188
diff changeset
286 pass
9cf183faf89f Maintaining scene group ID to scene node mapping in MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1188
diff changeset
287 if new_value:
9cf183faf89f Maintaining scene group ID to scene node mapping in MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1188
diff changeset
288 self._group2scene[new_value] = node
9cf183faf89f Maintaining scene group ID to scene node mapping in MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1188
diff changeset
289 pass
1206
1d476b35dc79 Merge and move code of tracking max frame number to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1205 1186
diff changeset
290 pass
1d476b35dc79 Merge and move code of tracking max frame number to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1205 1186
diff changeset
291 elif (name in ('start', 'end')) and node.name() == 'ns0:scene':
1d476b35dc79 Merge and move code of tracking max frame number to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1205 1186
diff changeset
292 self._maxframe = max(int(new_value), self._maxframe)
1183
e8446e138427 Move update_scenes_of_dom() to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents: 1182
diff changeset
293 pass
e8446e138427 Move update_scenes_of_dom() to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents: 1182
diff changeset
294 pass
e8446e138427 Move update_scenes_of_dom() to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents: 1182
diff changeset
295
1203
b90a1e2eb9ec Add document for methods
Thinker K.F. Li <thinker@codemud.net>
parents: 1202
diff changeset
296 ## \brief Collect ID of nodes in the document.
b90a1e2eb9ec Add document for methods
Thinker K.F. Li <thinker@codemud.net>
parents: 1202
diff changeset
297 #
b90a1e2eb9ec Add document for methods
Thinker K.F. Li <thinker@codemud.net>
parents: 1202
diff changeset
298 # It is used to implement a fast mapping from an ID to the respective node.
b90a1e2eb9ec Add document for methods
Thinker K.F. Li <thinker@codemud.net>
parents: 1202
diff changeset
299 #
1188
45e3a9273af2 Move code about monitoring DOM-tree to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1185
diff changeset
300 def _collect_node_ids(self):
45e3a9273af2 Move code about monitoring DOM-tree to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1185
diff changeset
301 self._id2node = {}
45e3a9273af2 Move code about monitoring DOM-tree to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1185
diff changeset
302 root = self._root
45e3a9273af2 Move code about monitoring DOM-tree to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1185
diff changeset
303 for n in root.childList():
45e3a9273af2 Move code about monitoring DOM-tree to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1185
diff changeset
304 self._collect_node_ids_recursive(n)
1183
e8446e138427 Move update_scenes_of_dom() to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents: 1182
diff changeset
305 pass
e8446e138427 Move update_scenes_of_dom() to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents: 1182
diff changeset
306 pass
e8446e138427 Move update_scenes_of_dom() to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents: 1182
diff changeset
307
1188
45e3a9273af2 Move code about monitoring DOM-tree to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1185
diff changeset
308 def _collect_node_ids_recursive(self, node):
45e3a9273af2 Move code about monitoring DOM-tree to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1185
diff changeset
309 try:
45e3a9273af2 Move code about monitoring DOM-tree to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1185
diff changeset
310 node_id = node.getAttribute('id')
45e3a9273af2 Move code about monitoring DOM-tree to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1185
diff changeset
311 except:
45e3a9273af2 Move code about monitoring DOM-tree to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1185
diff changeset
312 return
45e3a9273af2 Move code about monitoring DOM-tree to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1185
diff changeset
313
45e3a9273af2 Move code about monitoring DOM-tree to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1185
diff changeset
314 self._id2node[node_id] = node
45e3a9273af2 Move code about monitoring DOM-tree to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1185
diff changeset
315 for n in node.childList():
45e3a9273af2 Move code about monitoring DOM-tree to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1185
diff changeset
316 self._collect_node_ids_recursive(n)
1183
e8446e138427 Move update_scenes_of_dom() to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents: 1182
diff changeset
317 pass
e8446e138427 Move update_scenes_of_dom() to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents: 1182
diff changeset
318 pass
e8446e138427 Move update_scenes_of_dom() to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents: 1182
diff changeset
319
1206
1d476b35dc79 Merge and move code of tracking max frame number to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1205 1186
diff changeset
320 def _parse_one_scene(self, scene_node):
1d476b35dc79 Merge and move code of tracking max frame number to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1205 1186
diff changeset
321 assert scene_node.name() == 'ns0:scene'
1d476b35dc79 Merge and move code of tracking max frame number to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1205 1186
diff changeset
322
1d476b35dc79 Merge and move code of tracking max frame number to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1205 1186
diff changeset
323 start = int(scene_node.getAttribute("start"))
1d476b35dc79 Merge and move code of tracking max frame number to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1205 1186
diff changeset
324 try:
1d476b35dc79 Merge and move code of tracking max frame number to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1205 1186
diff changeset
325 end = int(scene_node.getAttribute("end"))
1d476b35dc79 Merge and move code of tracking max frame number to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1205 1186
diff changeset
326 except:
1d476b35dc79 Merge and move code of tracking max frame number to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1205 1186
diff changeset
327 end = start
1d476b35dc79 Merge and move code of tracking max frame number to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1205 1186
diff changeset
328 pass
1d476b35dc79 Merge and move code of tracking max frame number to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1205 1186
diff changeset
329
1d476b35dc79 Merge and move code of tracking max frame number to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1205 1186
diff changeset
330 try:
1d476b35dc79 Merge and move code of tracking max frame number to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1205 1186
diff changeset
331 scene_type = scene_node.getAttribute('type')
1d476b35dc79 Merge and move code of tracking max frame number to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1205 1186
diff changeset
332 if scene_type == None:
1d476b35dc79 Merge and move code of tracking max frame number to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1205 1186
diff changeset
333 scene_type = 'normal'
1d476b35dc79 Merge and move code of tracking max frame number to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1205 1186
diff changeset
334 pass
1d476b35dc79 Merge and move code of tracking max frame number to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1205 1186
diff changeset
335 except:
1d476b35dc79 Merge and move code of tracking max frame number to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1205 1186
diff changeset
336 scene_type = 'normal'
1d476b35dc79 Merge and move code of tracking max frame number to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1205 1186
diff changeset
337 pass
1d476b35dc79 Merge and move code of tracking max frame number to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1205 1186
diff changeset
338
1d476b35dc79 Merge and move code of tracking max frame number to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1205 1186
diff changeset
339 return start, end, scene_type
1d476b35dc79 Merge and move code of tracking max frame number to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1205 1186
diff changeset
340
1d476b35dc79 Merge and move code of tracking max frame number to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1205 1186
diff changeset
341 def _parse_one_scenes(self, scenes_node):
1d476b35dc79 Merge and move code of tracking max frame number to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1205 1186
diff changeset
342 try:
1d476b35dc79 Merge and move code of tracking max frame number to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1205 1186
diff changeset
343 cur = int(n.getAttribute("current"))
1d476b35dc79 Merge and move code of tracking max frame number to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1205 1186
diff changeset
344 except:
1d476b35dc79 Merge and move code of tracking max frame number to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1205 1186
diff changeset
345 cur = 0
1d476b35dc79 Merge and move code of tracking max frame number to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1205 1186
diff changeset
346 pass
1d476b35dc79 Merge and move code of tracking max frame number to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1205 1186
diff changeset
347 self.current = cur
1d476b35dc79 Merge and move code of tracking max frame number to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1205 1186
diff changeset
348
1d476b35dc79 Merge and move code of tracking max frame number to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1205 1186
diff changeset
349 for scene_node in scenes_node.childList():
1d476b35dc79 Merge and move code of tracking max frame number to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1205 1186
diff changeset
350 if scene_node.name() != 'ns0:scene':
1d476b35dc79 Merge and move code of tracking max frame number to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1205 1186
diff changeset
351 continue
1d476b35dc79 Merge and move code of tracking max frame number to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1205 1186
diff changeset
352
1d476b35dc79 Merge and move code of tracking max frame number to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1205 1186
diff changeset
353 try:
1d476b35dc79 Merge and move code of tracking max frame number to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1205 1186
diff changeset
354 start, end, scene_type = self._parse_one_scene(scene_node)
1d476b35dc79 Merge and move code of tracking max frame number to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1205 1186
diff changeset
355 except:
1d476b35dc79 Merge and move code of tracking max frame number to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1205 1186
diff changeset
356 continue
1d476b35dc79 Merge and move code of tracking max frame number to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1205 1186
diff changeset
357
1d476b35dc79 Merge and move code of tracking max frame number to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1205 1186
diff changeset
358 group_id = scene_node.getAttribute("ref")
1d476b35dc79 Merge and move code of tracking max frame number to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1205 1186
diff changeset
359 self._group2scene[group_id] = (start, end, scene_type)
1d476b35dc79 Merge and move code of tracking max frame number to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1205 1186
diff changeset
360 pass
1d476b35dc79 Merge and move code of tracking max frame number to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1205 1186
diff changeset
361 pass
1d476b35dc79 Merge and move code of tracking max frame number to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1205 1186
diff changeset
362
1d476b35dc79 Merge and move code of tracking max frame number to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1205 1186
diff changeset
363 ## \brief Parse all scenes node in svg:metadata subtree.
1d476b35dc79 Merge and move code of tracking max frame number to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1205 1186
diff changeset
364 #
1d476b35dc79 Merge and move code of tracking max frame number to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1205 1186
diff changeset
365 def _collect_all_scenes(self):
1d476b35dc79 Merge and move code of tracking max frame number to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1205 1186
diff changeset
366 root = self._root
1d476b35dc79 Merge and move code of tracking max frame number to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1205 1186
diff changeset
367 for child in root.childList():
1d476b35dc79 Merge and move code of tracking max frame number to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1205 1186
diff changeset
368 if child.name() != 'svg:metadata':
1d476b35dc79 Merge and move code of tracking max frame number to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1205 1186
diff changeset
369 continue
1d476b35dc79 Merge and move code of tracking max frame number to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1205 1186
diff changeset
370
1d476b35dc79 Merge and move code of tracking max frame number to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1205 1186
diff changeset
371 metadata_node = child
1d476b35dc79 Merge and move code of tracking max frame number to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1205 1186
diff changeset
372 for metachild in metadata_node.childList():
1d476b35dc79 Merge and move code of tracking max frame number to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1205 1186
diff changeset
373 if metachild.name() == 'ns0:scenes':
1d476b35dc79 Merge and move code of tracking max frame number to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1205 1186
diff changeset
374 self._parse_one_scenes(metachild)
1d476b35dc79 Merge and move code of tracking max frame number to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1205 1186
diff changeset
375 self._maxframe = self._find_maxframe(metachild)
1d476b35dc79 Merge and move code of tracking max frame number to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1205 1186
diff changeset
376 pass
1d476b35dc79 Merge and move code of tracking max frame number to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1205 1186
diff changeset
377 pass
1d476b35dc79 Merge and move code of tracking max frame number to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1205 1186
diff changeset
378 pass
1d476b35dc79 Merge and move code of tracking max frame number to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1205 1186
diff changeset
379 pass
1d476b35dc79 Merge and move code of tracking max frame number to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1205 1186
diff changeset
380
1203
b90a1e2eb9ec Add document for methods
Thinker K.F. Li <thinker@codemud.net>
parents: 1202
diff changeset
381 ## \brief Return the node with given ID.
b90a1e2eb9ec Add document for methods
Thinker K.F. Li <thinker@codemud.net>
parents: 1202
diff changeset
382 #
1188
45e3a9273af2 Move code about monitoring DOM-tree to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1185
diff changeset
383 def get_node(self, node_id):
45e3a9273af2 Move code about monitoring DOM-tree to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1185
diff changeset
384 return self._id2node[node_id]
45e3a9273af2 Move code about monitoring DOM-tree to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1185
diff changeset
385
1203
b90a1e2eb9ec Add document for methods
Thinker K.F. Li <thinker@codemud.net>
parents: 1202
diff changeset
386 ## \brief Return a scene node corresponding to a scene group of given ID.
b90a1e2eb9ec Add document for methods
Thinker K.F. Li <thinker@codemud.net>
parents: 1202
diff changeset
387 #
1189
9cf183faf89f Maintaining scene group ID to scene node mapping in MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1188
diff changeset
388 def get_scene(self, group_id):
9cf183faf89f Maintaining scene group ID to scene node mapping in MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1188
diff changeset
389 return self._group2scene[group_id]
9cf183faf89f Maintaining scene group ID to scene node mapping in MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1188
diff changeset
390
1188
45e3a9273af2 Move code about monitoring DOM-tree to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1185
diff changeset
391 def new_id(self):
45e3a9273af2 Move code about monitoring DOM-tree to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1185
diff changeset
392 while True:
45e3a9273af2 Move code about monitoring DOM-tree to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1185
diff changeset
393 candidate = 's%d' % int(random.random()*100000)
45e3a9273af2 Move code about monitoring DOM-tree to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1185
diff changeset
394 if candidate not in self._id2node:
45e3a9273af2 Move code about monitoring DOM-tree to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1185
diff changeset
395 return candidate
45e3a9273af2 Move code about monitoring DOM-tree to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1185
diff changeset
396 pass
45e3a9273af2 Move code about monitoring DOM-tree to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1185
diff changeset
397 pass
45e3a9273af2 Move code about monitoring DOM-tree to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1185
diff changeset
398 pass
45e3a9273af2 Move code about monitoring DOM-tree to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1185
diff changeset
399
45e3a9273af2 Move code about monitoring DOM-tree to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1185
diff changeset
400
45e3a9273af2 Move code about monitoring DOM-tree to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1185
diff changeset
401 ## \brief Layer of MBScene to manipulate DOM tree.
45e3a9273af2 Move code about monitoring DOM-tree to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1185
diff changeset
402 #
45e3a9273af2 Move code about monitoring DOM-tree to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1185
diff changeset
403 class MBScene_dom(MBScene_dom_monitor):
1191
6442fb198418 Refactory insertKeyScene() and fix bug of ObjectWatcher
Thinker K.F. Li <thinker@codemud.net>
parents: 1190
diff changeset
404 # Declare variables, here, for keeping tracking
6442fb198418 Refactory insertKeyScene() and fix bug of ObjectWatcher
Thinker K.F. Li <thinker@codemud.net>
parents: 1190
diff changeset
405 _doc = None
6442fb198418 Refactory insertKeyScene() and fix bug of ObjectWatcher
Thinker K.F. Li <thinker@codemud.net>
parents: 1190
diff changeset
406 _root = None
6442fb198418 Refactory insertKeyScene() and fix bug of ObjectWatcher
Thinker K.F. Li <thinker@codemud.net>
parents: 1190
diff changeset
407
1188
45e3a9273af2 Move code about monitoring DOM-tree to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1185
diff changeset
408 def __init__(self, *args, **kws):
45e3a9273af2 Move code about monitoring DOM-tree to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1185
diff changeset
409 super(MBScene_dom, self).__init__()
45e3a9273af2 Move code about monitoring DOM-tree to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1185
diff changeset
410 pass
45e3a9273af2 Move code about monitoring DOM-tree to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1185
diff changeset
411
45e3a9273af2 Move code about monitoring DOM-tree to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1185
diff changeset
412 def handle_doc_root(self, doc, root):
45e3a9273af2 Move code about monitoring DOM-tree to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1185
diff changeset
413 self._doc = doc
45e3a9273af2 Move code about monitoring DOM-tree to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1185
diff changeset
414 self._root = root
1205
1af64bcdfd7d Move to MBScene._make_layers_integral()
Thinker K.F. Li <thinker@codemud.net>
parents: 1204
diff changeset
415 self._layers = []
1188
45e3a9273af2 Move code about monitoring DOM-tree to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1185
diff changeset
416
45e3a9273af2 Move code about monitoring DOM-tree to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1185
diff changeset
417 self._start_monitor() # start MBScene_dom_monitor
1189
9cf183faf89f Maintaining scene group ID to scene node mapping in MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1188
diff changeset
418 self._init_metadata()
1205
1af64bcdfd7d Move to MBScene._make_layers_integral()
Thinker K.F. Li <thinker@codemud.net>
parents: 1204
diff changeset
419 self._parse_all_layers()
1188
45e3a9273af2 Move code about monitoring DOM-tree to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1185
diff changeset
420 pass
45e3a9273af2 Move code about monitoring DOM-tree to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1185
diff changeset
421
1176
0c1ceecb8ddb Move parseMetadata to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents: 1174
diff changeset
422 def dumpattr(self, n):
0c1ceecb8ddb Move parseMetadata to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents: 1174
diff changeset
423 s = ""
0c1ceecb8ddb Move parseMetadata to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents: 1174
diff changeset
424 for a,v in n.attrib.items():
0c1ceecb8ddb Move parseMetadata to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents: 1174
diff changeset
425 s = s + ("%s=%s" % (a,v))
0c1ceecb8ddb Move parseMetadata to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents: 1174
diff changeset
426 pass
0c1ceecb8ddb Move parseMetadata to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents: 1174
diff changeset
427 return s
0c1ceecb8ddb Move parseMetadata to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents: 1174
diff changeset
428
0c1ceecb8ddb Move parseMetadata to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents: 1174
diff changeset
429 def dump(self, node, l=0):
0c1ceecb8ddb Move parseMetadata to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents: 1174
diff changeset
430 print " " * l*2,"<", node.tag, self.dumpattr(node),">"
0c1ceecb8ddb Move parseMetadata to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents: 1174
diff changeset
431 for n in node:
0c1ceecb8ddb Move parseMetadata to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents: 1174
diff changeset
432 self.dump(n, l+1)
0c1ceecb8ddb Move parseMetadata to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents: 1174
diff changeset
433 pass
0c1ceecb8ddb Move parseMetadata to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents: 1174
diff changeset
434 print " " * l * 2,"/>"
0c1ceecb8ddb Move parseMetadata to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents: 1174
diff changeset
435 pass
0c1ceecb8ddb Move parseMetadata to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents: 1174
diff changeset
436
1202
2f3d523a3871 Parse all scenes when start handling a document
Thinker K.F. Li <thinker@codemud.net>
parents: 1201
diff changeset
437 ## \brief Create a scenes node if not existed.
2f3d523a3871 Parse all scenes when start handling a document
Thinker K.F. Li <thinker@codemud.net>
parents: 1201
diff changeset
438 #
1189
9cf183faf89f Maintaining scene group ID to scene node mapping in MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1188
diff changeset
439 def _init_metadata(self):
9cf183faf89f Maintaining scene group ID to scene node mapping in MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1188
diff changeset
440 for node in self._root.childList():
9cf183faf89f Maintaining scene group ID to scene node mapping in MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1188
diff changeset
441 if node.name() == 'svg:metadata':
9cf183faf89f Maintaining scene group ID to scene node mapping in MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1188
diff changeset
442 break
1176
0c1ceecb8ddb Move parseMetadata to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents: 1174
diff changeset
443 pass
1189
9cf183faf89f Maintaining scene group ID to scene node mapping in MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1188
diff changeset
444 else:
9cf183faf89f Maintaining scene group ID to scene node mapping in MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1188
diff changeset
445 raise RuntimeError, \
9cf183faf89f Maintaining scene group ID to scene node mapping in MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1188
diff changeset
446 'can not find <svg:metadata> node in the document'
1176
0c1ceecb8ddb Move parseMetadata to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents: 1174
diff changeset
447
0c1ceecb8ddb Move parseMetadata to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents: 1174
diff changeset
448 for n in node.childList():
0c1ceecb8ddb Move parseMetadata to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents: 1174
diff changeset
449 if n.name() == 'ns0:scenes':
1191
6442fb198418 Refactory insertKeyScene() and fix bug of ObjectWatcher
Thinker K.F. Li <thinker@codemud.net>
parents: 1190
diff changeset
450 self._scenes_node = n
1176
0c1ceecb8ddb Move parseMetadata to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents: 1174
diff changeset
451 break
0c1ceecb8ddb Move parseMetadata to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents: 1174
diff changeset
452 pass
0c1ceecb8ddb Move parseMetadata to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents: 1174
diff changeset
453 else:
0c1ceecb8ddb Move parseMetadata to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents: 1174
diff changeset
454 ns = "http://madbutterfly.sourceforge.net/DTD/madbutterfly.dtd"
1188
45e3a9273af2 Move code about monitoring DOM-tree to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1185
diff changeset
455 self._root.setAttribute("xmlns:ns0", ns)
1190
a4df892fb4e5 Use meaningful name for scene, scene group, and layer group
Thinker K.F. Li <thinker@codemud.net>
parents: 1189
diff changeset
456 scenes_node = self._doc.createElement("ns0:scenes")
a4df892fb4e5 Use meaningful name for scene, scene group, and layer group
Thinker K.F. Li <thinker@codemud.net>
parents: 1189
diff changeset
457 node.appendChild(scenes_node)
1191
6442fb198418 Refactory insertKeyScene() and fix bug of ObjectWatcher
Thinker K.F. Li <thinker@codemud.net>
parents: 1190
diff changeset
458 self._scenes_node = scenes_node
1176
0c1ceecb8ddb Move parseMetadata to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents: 1174
diff changeset
459 pass
0c1ceecb8ddb Move parseMetadata to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents: 1174
diff changeset
460 pass
1189
9cf183faf89f Maintaining scene group ID to scene node mapping in MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1188
diff changeset
461
1191
6442fb198418 Refactory insertKeyScene() and fix bug of ObjectWatcher
Thinker K.F. Li <thinker@codemud.net>
parents: 1190
diff changeset
462 ## \brief Create and add a ns0:scene node under ns0:scenes subtree.
6442fb198418 Refactory insertKeyScene() and fix bug of ObjectWatcher
Thinker K.F. Li <thinker@codemud.net>
parents: 1190
diff changeset
463 #
6442fb198418 Refactory insertKeyScene() and fix bug of ObjectWatcher
Thinker K.F. Li <thinker@codemud.net>
parents: 1190
diff changeset
464 def _add_scene_node(self, start, end,
6442fb198418 Refactory insertKeyScene() and fix bug of ObjectWatcher
Thinker K.F. Li <thinker@codemud.net>
parents: 1190
diff changeset
465 frame_type=TweenObject.TWEEN_TYPE_NORMAL,
6442fb198418 Refactory insertKeyScene() and fix bug of ObjectWatcher
Thinker K.F. Li <thinker@codemud.net>
parents: 1190
diff changeset
466 ref=None):
6442fb198418 Refactory insertKeyScene() and fix bug of ObjectWatcher
Thinker K.F. Li <thinker@codemud.net>
parents: 1190
diff changeset
467 type_names = ('normal', 'scale')
6442fb198418 Refactory insertKeyScene() and fix bug of ObjectWatcher
Thinker K.F. Li <thinker@codemud.net>
parents: 1190
diff changeset
468 scenes_node = self._scenes_node
6442fb198418 Refactory insertKeyScene() and fix bug of ObjectWatcher
Thinker K.F. Li <thinker@codemud.net>
parents: 1190
diff changeset
469 doc = self._doc
6442fb198418 Refactory insertKeyScene() and fix bug of ObjectWatcher
Thinker K.F. Li <thinker@codemud.net>
parents: 1190
diff changeset
470
6442fb198418 Refactory insertKeyScene() and fix bug of ObjectWatcher
Thinker K.F. Li <thinker@codemud.net>
parents: 1190
diff changeset
471 scene_node = doc.createElement('ns0:scene')
1206
1d476b35dc79 Merge and move code of tracking max frame number to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1205 1186
diff changeset
472 self._chg_scene_node(scene_node, start=start)
1191
6442fb198418 Refactory insertKeyScene() and fix bug of ObjectWatcher
Thinker K.F. Li <thinker@codemud.net>
parents: 1190
diff changeset
473 if start != end:
1199
25e1579ed3d1 Fix bug of running animation
Thinker K.F. Li <thinker@codemud.net>
parents: 1198
diff changeset
474 self._chg_scene_node(scene_node, end=end)
1191
6442fb198418 Refactory insertKeyScene() and fix bug of ObjectWatcher
Thinker K.F. Li <thinker@codemud.net>
parents: 1190
diff changeset
475 pass
6442fb198418 Refactory insertKeyScene() and fix bug of ObjectWatcher
Thinker K.F. Li <thinker@codemud.net>
parents: 1190
diff changeset
476 type_name = type_names[frame_type]
1206
1d476b35dc79 Merge and move code of tracking max frame number to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1205 1186
diff changeset
477 self._chg_scene_node(scene_node, tween_type=type_name)
1191
6442fb198418 Refactory insertKeyScene() and fix bug of ObjectWatcher
Thinker K.F. Li <thinker@codemud.net>
parents: 1190
diff changeset
478 if ref:
1206
1d476b35dc79 Merge and move code of tracking max frame number to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1205 1186
diff changeset
479 self._chg_scene_node(scene_node, ref=ref)
1191
6442fb198418 Refactory insertKeyScene() and fix bug of ObjectWatcher
Thinker K.F. Li <thinker@codemud.net>
parents: 1190
diff changeset
480 pass
6442fb198418 Refactory insertKeyScene() and fix bug of ObjectWatcher
Thinker K.F. Li <thinker@codemud.net>
parents: 1190
diff changeset
481
6442fb198418 Refactory insertKeyScene() and fix bug of ObjectWatcher
Thinker K.F. Li <thinker@codemud.net>
parents: 1190
diff changeset
482 scenes_node.appendChild(scene_node)
6442fb198418 Refactory insertKeyScene() and fix bug of ObjectWatcher
Thinker K.F. Li <thinker@codemud.net>
parents: 1190
diff changeset
483
6442fb198418 Refactory insertKeyScene() and fix bug of ObjectWatcher
Thinker K.F. Li <thinker@codemud.net>
parents: 1190
diff changeset
484 return scene_node
6442fb198418 Refactory insertKeyScene() and fix bug of ObjectWatcher
Thinker K.F. Li <thinker@codemud.net>
parents: 1190
diff changeset
485
1206
1d476b35dc79 Merge and move code of tracking max frame number to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1205 1186
diff changeset
486 ## \brief Change attributes of a scene node.
1d476b35dc79 Merge and move code of tracking max frame number to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1205 1186
diff changeset
487 #
1d476b35dc79 Merge and move code of tracking max frame number to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1205 1186
diff changeset
488 # This is here to monitor changes of scene node.
1199
25e1579ed3d1 Fix bug of running animation
Thinker K.F. Li <thinker@codemud.net>
parents: 1198
diff changeset
489 def _chg_scene_node(self, scene_node, start=None, end=None,
25e1579ed3d1 Fix bug of running animation
Thinker K.F. Li <thinker@codemud.net>
parents: 1198
diff changeset
490 tween_type=None, ref=None):
25e1579ed3d1 Fix bug of running animation
Thinker K.F. Li <thinker@codemud.net>
parents: 1198
diff changeset
491 if start:
25e1579ed3d1 Fix bug of running animation
Thinker K.F. Li <thinker@codemud.net>
parents: 1198
diff changeset
492 scene_node.setAttribute('start', str(start))
25e1579ed3d1 Fix bug of running animation
Thinker K.F. Li <thinker@codemud.net>
parents: 1198
diff changeset
493 pass
25e1579ed3d1 Fix bug of running animation
Thinker K.F. Li <thinker@codemud.net>
parents: 1198
diff changeset
494 if end:
25e1579ed3d1 Fix bug of running animation
Thinker K.F. Li <thinker@codemud.net>
parents: 1198
diff changeset
495 scene_node.setAttribute('end', str(end))
25e1579ed3d1 Fix bug of running animation
Thinker K.F. Li <thinker@codemud.net>
parents: 1198
diff changeset
496 pass
25e1579ed3d1 Fix bug of running animation
Thinker K.F. Li <thinker@codemud.net>
parents: 1198
diff changeset
497 if tween_type:
25e1579ed3d1 Fix bug of running animation
Thinker K.F. Li <thinker@codemud.net>
parents: 1198
diff changeset
498 scene_node.setAttribute('type', tween_type)
25e1579ed3d1 Fix bug of running animation
Thinker K.F. Li <thinker@codemud.net>
parents: 1198
diff changeset
499 pass
25e1579ed3d1 Fix bug of running animation
Thinker K.F. Li <thinker@codemud.net>
parents: 1198
diff changeset
500 if ref:
25e1579ed3d1 Fix bug of running animation
Thinker K.F. Li <thinker@codemud.net>
parents: 1198
diff changeset
501 scene_node.setAttribute('ref', ref)
25e1579ed3d1 Fix bug of running animation
Thinker K.F. Li <thinker@codemud.net>
parents: 1198
diff changeset
502 pass
25e1579ed3d1 Fix bug of running animation
Thinker K.F. Li <thinker@codemud.net>
parents: 1198
diff changeset
503 pass
25e1579ed3d1 Fix bug of running animation
Thinker K.F. Li <thinker@codemud.net>
parents: 1198
diff changeset
504
1204
78925515836f Add methods for managing framelines
Thinker K.F. Li <thinker@codemud.net>
parents: 1203
diff changeset
505 def _rm_scene_node(self, scene_node):
78925515836f Add methods for managing framelines
Thinker K.F. Li <thinker@codemud.net>
parents: 1203
diff changeset
506 self._scenes_node.removeChild(scene_node)
78925515836f Add methods for managing framelines
Thinker K.F. Li <thinker@codemud.net>
parents: 1203
diff changeset
507 pass
78925515836f Add methods for managing framelines
Thinker K.F. Li <thinker@codemud.net>
parents: 1203
diff changeset
508
1191
6442fb198418 Refactory insertKeyScene() and fix bug of ObjectWatcher
Thinker K.F. Li <thinker@codemud.net>
parents: 1190
diff changeset
509 ## \brief Create and add a svg:g for a scene under a group for a layer.
6442fb198418 Refactory insertKeyScene() and fix bug of ObjectWatcher
Thinker K.F. Li <thinker@codemud.net>
parents: 1190
diff changeset
510 #
6442fb198418 Refactory insertKeyScene() and fix bug of ObjectWatcher
Thinker K.F. Li <thinker@codemud.net>
parents: 1190
diff changeset
511 def _add_scene_group(self, layer_idx):
1205
1af64bcdfd7d Move to MBScene._make_layers_integral()
Thinker K.F. Li <thinker@codemud.net>
parents: 1204
diff changeset
512 layer = self._layers[layer_idx]
1191
6442fb198418 Refactory insertKeyScene() and fix bug of ObjectWatcher
Thinker K.F. Li <thinker@codemud.net>
parents: 1190
diff changeset
513 doc = self._doc
6442fb198418 Refactory insertKeyScene() and fix bug of ObjectWatcher
Thinker K.F. Li <thinker@codemud.net>
parents: 1190
diff changeset
514
6442fb198418 Refactory insertKeyScene() and fix bug of ObjectWatcher
Thinker K.F. Li <thinker@codemud.net>
parents: 1190
diff changeset
515 scene_group = doc.createElement('svg:g')
6442fb198418 Refactory insertKeyScene() and fix bug of ObjectWatcher
Thinker K.F. Li <thinker@codemud.net>
parents: 1190
diff changeset
516 gid = self.new_id()
6442fb198418 Refactory insertKeyScene() and fix bug of ObjectWatcher
Thinker K.F. Li <thinker@codemud.net>
parents: 1190
diff changeset
517 scene_group.setAttribute("id", gid)
6442fb198418 Refactory insertKeyScene() and fix bug of ObjectWatcher
Thinker K.F. Li <thinker@codemud.net>
parents: 1190
diff changeset
518 scene_group.setAttribute("inkscape:groupmode", "layer")
6442fb198418 Refactory insertKeyScene() and fix bug of ObjectWatcher
Thinker K.F. Li <thinker@codemud.net>
parents: 1190
diff changeset
519
6442fb198418 Refactory insertKeyScene() and fix bug of ObjectWatcher
Thinker K.F. Li <thinker@codemud.net>
parents: 1190
diff changeset
520 layer.group.appendChild(scene_group)
6442fb198418 Refactory insertKeyScene() and fix bug of ObjectWatcher
Thinker K.F. Li <thinker@codemud.net>
parents: 1190
diff changeset
521
6442fb198418 Refactory insertKeyScene() and fix bug of ObjectWatcher
Thinker K.F. Li <thinker@codemud.net>
parents: 1190
diff changeset
522 return scene_group
1181
f14dbcf19e2b Move MBScene.insertKeyScene() to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents: 1180
diff changeset
523
f14dbcf19e2b Move MBScene.insertKeyScene() to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents: 1180
diff changeset
524 def insertKeyScene(self, line, frame):
f14dbcf19e2b Move MBScene.insertKeyScene() to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents: 1180
diff changeset
525 """
f14dbcf19e2b Move MBScene.insertKeyScene() to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents: 1180
diff changeset
526 Insert a new key scene into the stage. If the nth is always a
f14dbcf19e2b Move MBScene.insertKeyScene() to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents: 1180
diff changeset
527 key scene, we will return without changing anything. If the
f14dbcf19e2b Move MBScene.insertKeyScene() to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents: 1180
diff changeset
528 nth is a filled scene, we will break the original scene into
f14dbcf19e2b Move MBScene.insertKeyScene() to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents: 1180
diff changeset
529 two parts. If the nth is out of any scene, we will append a
f14dbcf19e2b Move MBScene.insertKeyScene() to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents: 1180
diff changeset
530 new scene.
f14dbcf19e2b Move MBScene.insertKeyScene() to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents: 1180
diff changeset
531
f14dbcf19e2b Move MBScene.insertKeyScene() to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents: 1180
diff changeset
532 """
1191
6442fb198418 Refactory insertKeyScene() and fix bug of ObjectWatcher
Thinker K.F. Li <thinker@codemud.net>
parents: 1190
diff changeset
533 doc = self._doc
6442fb198418 Refactory insertKeyScene() and fix bug of ObjectWatcher
Thinker K.F. Li <thinker@codemud.net>
parents: 1190
diff changeset
534 layer_idx = self._framelines.index(line)
6442fb198418 Refactory insertKeyScene() and fix bug of ObjectWatcher
Thinker K.F. Li <thinker@codemud.net>
parents: 1190
diff changeset
535
6442fb198418 Refactory insertKeyScene() and fix bug of ObjectWatcher
Thinker K.F. Li <thinker@codemud.net>
parents: 1190
diff changeset
536 scene_group = self._add_scene_group(layer_idx)
6442fb198418 Refactory insertKeyScene() and fix bug of ObjectWatcher
Thinker K.F. Li <thinker@codemud.net>
parents: 1190
diff changeset
537 scene_group_id = scene_group.getAttribute('id')
6442fb198418 Refactory insertKeyScene() and fix bug of ObjectWatcher
Thinker K.F. Li <thinker@codemud.net>
parents: 1190
diff changeset
538 scene_node = self._add_scene_node(frame, frame, ref=scene_group_id)
6442fb198418 Refactory insertKeyScene() and fix bug of ObjectWatcher
Thinker K.F. Li <thinker@codemud.net>
parents: 1190
diff changeset
539 line.add_keyframe(frame, scene_node)
6442fb198418 Refactory insertKeyScene() and fix bug of ObjectWatcher
Thinker K.F. Li <thinker@codemud.net>
parents: 1190
diff changeset
540
1205
1af64bcdfd7d Move to MBScene._make_layers_integral()
Thinker K.F. Li <thinker@codemud.net>
parents: 1204
diff changeset
541 for node in self._layers[layer_idx].group.childList():
1181
f14dbcf19e2b Move MBScene.insertKeyScene() to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents: 1180
diff changeset
542 try:
1191
6442fb198418 Refactory insertKeyScene() and fix bug of ObjectWatcher
Thinker K.F. Li <thinker@codemud.net>
parents: 1190
diff changeset
543 label = node.getAttribute('inkscape:label')
1181
f14dbcf19e2b Move MBScene.insertKeyScene() to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents: 1180
diff changeset
544 except:
f14dbcf19e2b Move MBScene.insertKeyScene() to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents: 1180
diff changeset
545 continue
1191
6442fb198418 Refactory insertKeyScene() and fix bug of ObjectWatcher
Thinker K.F. Li <thinker@codemud.net>
parents: 1190
diff changeset
546 if label == 'dup':
6442fb198418 Refactory insertKeyScene() and fix bug of ObjectWatcher
Thinker K.F. Li <thinker@codemud.net>
parents: 1190
diff changeset
547 node.setAttribute('style', 'display: none')
6442fb198418 Refactory insertKeyScene() and fix bug of ObjectWatcher
Thinker K.F. Li <thinker@codemud.net>
parents: 1190
diff changeset
548 pass
1181
f14dbcf19e2b Move MBScene.insertKeyScene() to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents: 1180
diff changeset
549 pass
f14dbcf19e2b Move MBScene.insertKeyScene() to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents: 1180
diff changeset
550 pass
f14dbcf19e2b Move MBScene.insertKeyScene() to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents: 1180
diff changeset
551
1205
1af64bcdfd7d Move to MBScene._make_layers_integral()
Thinker K.F. Li <thinker@codemud.net>
parents: 1204
diff changeset
552 def parse_layer(self, layer_idx):
1af64bcdfd7d Move to MBScene._make_layers_integral()
Thinker K.F. Li <thinker@codemud.net>
parents: 1204
diff changeset
553 layer = self._layers[layer_idx]
1af64bcdfd7d Move to MBScene._make_layers_integral()
Thinker K.F. Li <thinker@codemud.net>
parents: 1204
diff changeset
554 layer_group = layer.group
1af64bcdfd7d Move to MBScene._make_layers_integral()
Thinker K.F. Li <thinker@codemud.net>
parents: 1204
diff changeset
555
1af64bcdfd7d Move to MBScene._make_layers_integral()
Thinker K.F. Li <thinker@codemud.net>
parents: 1204
diff changeset
556 for child in layer_group.childList():
1af64bcdfd7d Move to MBScene._make_layers_integral()
Thinker K.F. Li <thinker@codemud.net>
parents: 1204
diff changeset
557 if child.name() != 'svg:g':
1af64bcdfd7d Move to MBScene._make_layers_integral()
Thinker K.F. Li <thinker@codemud.net>
parents: 1204
diff changeset
558 continue
1af64bcdfd7d Move to MBScene._make_layers_integral()
Thinker K.F. Li <thinker@codemud.net>
parents: 1204
diff changeset
559 try:
1af64bcdfd7d Move to MBScene._make_layers_integral()
Thinker K.F. Li <thinker@codemud.net>
parents: 1204
diff changeset
560 child_id = child.getAttribute('id')
1af64bcdfd7d Move to MBScene._make_layers_integral()
Thinker K.F. Li <thinker@codemud.net>
parents: 1204
diff changeset
561 scene_node = self.get_scene(child_id)
1af64bcdfd7d Move to MBScene._make_layers_integral()
Thinker K.F. Li <thinker@codemud.net>
parents: 1204
diff changeset
562 except:
1af64bcdfd7d Move to MBScene._make_layers_integral()
Thinker K.F. Li <thinker@codemud.net>
parents: 1204
diff changeset
563 continue
1183
e8446e138427 Move update_scenes_of_dom() to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents: 1182
diff changeset
564
1205
1af64bcdfd7d Move to MBScene._make_layers_integral()
Thinker K.F. Li <thinker@codemud.net>
parents: 1204
diff changeset
565 layer.scenes.append(scene_node)
1181
f14dbcf19e2b Move MBScene.insertKeyScene() to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents: 1180
diff changeset
566 pass
f14dbcf19e2b Move MBScene.insertKeyScene() to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents: 1180
diff changeset
567 pass
f14dbcf19e2b Move MBScene.insertKeyScene() to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents: 1180
diff changeset
568
1205
1af64bcdfd7d Move to MBScene._make_layers_integral()
Thinker K.F. Li <thinker@codemud.net>
parents: 1204
diff changeset
569 def _parse_all_layers(self):
1af64bcdfd7d Move to MBScene._make_layers_integral()
Thinker K.F. Li <thinker@codemud.net>
parents: 1204
diff changeset
570 root = self._root
1af64bcdfd7d Move to MBScene._make_layers_integral()
Thinker K.F. Li <thinker@codemud.net>
parents: 1204
diff changeset
571 layers = self._layers
1af64bcdfd7d Move to MBScene._make_layers_integral()
Thinker K.F. Li <thinker@codemud.net>
parents: 1204
diff changeset
572
1af64bcdfd7d Move to MBScene._make_layers_integral()
Thinker K.F. Li <thinker@codemud.net>
parents: 1204
diff changeset
573 for child in root.childList():
1af64bcdfd7d Move to MBScene._make_layers_integral()
Thinker K.F. Li <thinker@codemud.net>
parents: 1204
diff changeset
574 if child.name() != 'svg:g':
1af64bcdfd7d Move to MBScene._make_layers_integral()
Thinker K.F. Li <thinker@codemud.net>
parents: 1204
diff changeset
575 continue
1181
f14dbcf19e2b Move MBScene.insertKeyScene() to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents: 1180
diff changeset
576
1205
1af64bcdfd7d Move to MBScene._make_layers_integral()
Thinker K.F. Li <thinker@codemud.net>
parents: 1204
diff changeset
577 layer_group = child
1af64bcdfd7d Move to MBScene._make_layers_integral()
Thinker K.F. Li <thinker@codemud.net>
parents: 1204
diff changeset
578 layer = Layer(layer_group)
1af64bcdfd7d Move to MBScene._make_layers_integral()
Thinker K.F. Li <thinker@codemud.net>
parents: 1204
diff changeset
579 layer.idx = len(layers)
1af64bcdfd7d Move to MBScene._make_layers_integral()
Thinker K.F. Li <thinker@codemud.net>
parents: 1204
diff changeset
580 layers.append(layer)
1af64bcdfd7d Move to MBScene._make_layers_integral()
Thinker K.F. Li <thinker@codemud.net>
parents: 1204
diff changeset
581 self.parse_layer(layer.idx)
1183
e8446e138427 Move update_scenes_of_dom() to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents: 1182
diff changeset
582 pass
e8446e138427 Move update_scenes_of_dom() to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents: 1182
diff changeset
583 pass
e8446e138427 Move update_scenes_of_dom() to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents: 1182
diff changeset
584
1205
1af64bcdfd7d Move to MBScene._make_layers_integral()
Thinker K.F. Li <thinker@codemud.net>
parents: 1204
diff changeset
585 ## \brief Add/insert a layer at given position.
1af64bcdfd7d Move to MBScene._make_layers_integral()
Thinker K.F. Li <thinker@codemud.net>
parents: 1204
diff changeset
586 #
1af64bcdfd7d Move to MBScene._make_layers_integral()
Thinker K.F. Li <thinker@codemud.net>
parents: 1204
diff changeset
587 # \param layer_idx is the position in the layer list.
1af64bcdfd7d Move to MBScene._make_layers_integral()
Thinker K.F. Li <thinker@codemud.net>
parents: 1204
diff changeset
588 #
1af64bcdfd7d Move to MBScene._make_layers_integral()
Thinker K.F. Li <thinker@codemud.net>
parents: 1204
diff changeset
589 def add_layer(self, layer_idx, layer_group):
1af64bcdfd7d Move to MBScene._make_layers_integral()
Thinker K.F. Li <thinker@codemud.net>
parents: 1204
diff changeset
590 layers = self._layers
1af64bcdfd7d Move to MBScene._make_layers_integral()
Thinker K.F. Li <thinker@codemud.net>
parents: 1204
diff changeset
591
1af64bcdfd7d Move to MBScene._make_layers_integral()
Thinker K.F. Li <thinker@codemud.net>
parents: 1204
diff changeset
592 layer = Layer(layer_group)
1af64bcdfd7d Move to MBScene._make_layers_integral()
Thinker K.F. Li <thinker@codemud.net>
parents: 1204
diff changeset
593 if layer_idx >= len(layers):
1af64bcdfd7d Move to MBScene._make_layers_integral()
Thinker K.F. Li <thinker@codemud.net>
parents: 1204
diff changeset
594 layers.append(layer)
1af64bcdfd7d Move to MBScene._make_layers_integral()
Thinker K.F. Li <thinker@codemud.net>
parents: 1204
diff changeset
595 else:
1af64bcdfd7d Move to MBScene._make_layers_integral()
Thinker K.F. Li <thinker@codemud.net>
parents: 1204
diff changeset
596 layers.insert(layer_idx, layer)
1af64bcdfd7d Move to MBScene._make_layers_integral()
Thinker K.F. Li <thinker@codemud.net>
parents: 1204
diff changeset
597 for idx in range(layer_idx, len(layers)):
1af64bcdfd7d Move to MBScene._make_layers_integral()
Thinker K.F. Li <thinker@codemud.net>
parents: 1204
diff changeset
598 layers[idx].idx = idx
1183
e8446e138427 Move update_scenes_of_dom() to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents: 1182
diff changeset
599 pass
e8446e138427 Move update_scenes_of_dom() to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents: 1182
diff changeset
600 pass
e8446e138427 Move update_scenes_of_dom() to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents: 1182
diff changeset
601 pass
1205
1af64bcdfd7d Move to MBScene._make_layers_integral()
Thinker K.F. Li <thinker@codemud.net>
parents: 1204
diff changeset
602
1af64bcdfd7d Move to MBScene._make_layers_integral()
Thinker K.F. Li <thinker@codemud.net>
parents: 1204
diff changeset
603 def rm_layer(self, layer_idx):
1af64bcdfd7d Move to MBScene._make_layers_integral()
Thinker K.F. Li <thinker@codemud.net>
parents: 1204
diff changeset
604 layers = self._layers
956
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
605
1205
1af64bcdfd7d Move to MBScene._make_layers_integral()
Thinker K.F. Li <thinker@codemud.net>
parents: 1204
diff changeset
606 del layers[layer_idx]
1128
b65ac686a7c5 Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents: 1125
diff changeset
607
1205
1af64bcdfd7d Move to MBScene._make_layers_integral()
Thinker K.F. Li <thinker@codemud.net>
parents: 1204
diff changeset
608 for idx in range(layer_idx, len(layers)):
1af64bcdfd7d Move to MBScene._make_layers_integral()
Thinker K.F. Li <thinker@codemud.net>
parents: 1204
diff changeset
609 layers[idx].idx = idx
956
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
610 pass
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
611 pass
1176
0c1ceecb8ddb Move parseMetadata to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents: 1174
diff changeset
612 pass
0c1ceecb8ddb Move parseMetadata to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents: 1174
diff changeset
613
0c1ceecb8ddb Move parseMetadata to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents: 1174
diff changeset
614 class MBScene(MBScene_dom):
1151
71c72e8d6755 Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents: 1150
diff changeset
615 _frameline_tween_types = (frameline.TWEEN_TYPE_NONE,
71c72e8d6755 Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents: 1150
diff changeset
616 frameline.TWEEN_TYPE_SHAPE)
71c72e8d6755 Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents: 1150
diff changeset
617 _tween_obj_tween_types = (TweenObject.TWEEN_TYPE_NORMAL,
71c72e8d6755 Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents: 1150
diff changeset
618 TweenObject.TWEEN_TYPE_SCALE)
1157
3a891dccabd8 Remove the locate tween. It is a special case for the scale tween
wycc
parents: 1155
diff changeset
619 _tween_type_names = ('normal', 'scale')
1150
6586cd10c92f Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents: 1149
diff changeset
620
1204
78925515836f Add methods for managing framelines
Thinker K.F. Li <thinker@codemud.net>
parents: 1203
diff changeset
621 _num_frames_of_line = 100
78925515836f Add methods for managing framelines
Thinker K.F. Li <thinker@codemud.net>
parents: 1203
diff changeset
622
1149
0ffef2df6201 Rename MBScene.dom to MBScene.root
Thinker K.F. Li <thinker@codemud.net>
parents: 1148
diff changeset
623 def __init__(self, desktop, win, root=None):
1188
45e3a9273af2 Move code about monitoring DOM-tree to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1185
diff changeset
624 super(MBScene, self).__init__()
45e3a9273af2 Move code about monitoring DOM-tree to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1185
diff changeset
625
956
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
626 self.desktop = desktop
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
627 self.window = win
1064
16c69756ef5d Add NodeObserver to monitor the change of the layer and update it in the scene editor.
wycc
parents: 1032
diff changeset
628 self.top = None
16c69756ef5d Add NodeObserver to monitor the change of the layer and update it in the scene editor.
wycc
parents: 1032
diff changeset
629 self.last_update = None
1128
b65ac686a7c5 Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents: 1125
diff changeset
630 pybInkscape.inkscape.connect('change_selection', self.show_selection)
1099
5ba2cab1d505 Add name editor to edit the inkscape:label withgout using the object property editor. This is more Flash-like operation.
wycc
parents: 1097
diff changeset
631 self.last_select = None
1206
1d476b35dc79 Merge and move code of tracking max frame number to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1205 1186
diff changeset
632 self._lockui = False
1d476b35dc79 Merge and move code of tracking max frame number to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1205 1186
diff changeset
633 self.tween = None
1140
d4dbcb93aee0 Separate the tween from the main module.
wycc
parents: 1136
diff changeset
634 self.document = None
1149
0ffef2df6201 Rename MBScene.dom to MBScene.root
Thinker K.F. Li <thinker@codemud.net>
parents: 1148
diff changeset
635 self.root = root
1206
1d476b35dc79 Merge and move code of tracking max frame number to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1205 1186
diff changeset
636 self.framerate = 12
1150
6586cd10c92f Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents: 1149
diff changeset
637 self._disable_tween_type_selector = False
956
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
638 pass
941
9ba94c577a6f Add scene editor. This vewrsion can only switch scene. It can not change the scene yet.
wycc
parents:
diff changeset
639
1128
b65ac686a7c5 Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents: 1125
diff changeset
640 def show_selection(self,w,obj):
b65ac686a7c5 Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents: 1125
diff changeset
641 objs = self.desktop.selection.list()
b65ac686a7c5 Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents: 1125
diff changeset
642 try:
b65ac686a7c5 Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents: 1125
diff changeset
643 o = objs[0]
b65ac686a7c5 Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents: 1125
diff changeset
644 print o.getCenter()
b65ac686a7c5 Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents: 1125
diff changeset
645 if o == self.last_select:
b65ac686a7c5 Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents: 1125
diff changeset
646 return
b65ac686a7c5 Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents: 1125
diff changeset
647 except:
b65ac686a7c5 Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents: 1125
diff changeset
648 self.nameEditor.set_text('')
b65ac686a7c5 Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents: 1125
diff changeset
649 self.last_select = None
b65ac686a7c5 Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents: 1125
diff changeset
650 return
b65ac686a7c5 Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents: 1125
diff changeset
651 self.last_select = o
b65ac686a7c5 Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents: 1125
diff changeset
652 try:
1139
a2b068594412 Use pybind with new DOM API (at PYNode).
Thinker K.F. Li <thinker@codemud.net>
parents: 1136
diff changeset
653 self.nameEditor.set_text(o.getAttribute("inkscape:label"))
1128
b65ac686a7c5 Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents: 1125
diff changeset
654 except:
b65ac686a7c5 Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents: 1125
diff changeset
655 self.nameEditor.set_text('')
b65ac686a7c5 Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents: 1125
diff changeset
656 pass
1144
257beac7c982 Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents: 1142
diff changeset
657 pass
1099
5ba2cab1d505 Add name editor to edit the inkscape:label withgout using the object property editor. This is more Flash-like operation.
wycc
parents: 1097
diff changeset
658
1200
213f03dbfc41 Fix issue of removing a scene
Thinker K.F. Li <thinker@codemud.net>
parents: 1199
diff changeset
659 def removeKeyScene(self, frameline, frame_idx):
213f03dbfc41 Fix issue of removing a scene
Thinker K.F. Li <thinker@codemud.net>
parents: 1199
diff changeset
660 start, end, scene_type = frameline.get_frame_block(frame_idx)
213f03dbfc41 Fix issue of removing a scene
Thinker K.F. Li <thinker@codemud.net>
parents: 1199
diff changeset
661 scene_node = frameline.get_frame_data(start)
1184
05d33f0fbc76 Add comment for some TODO item
Thinker K.F. Li <thinker@codemud.net>
parents: 1183
diff changeset
662
1200
213f03dbfc41 Fix issue of removing a scene
Thinker K.F. Li <thinker@codemud.net>
parents: 1199
diff changeset
663 frameline.rm_keyframe(start)
213f03dbfc41 Fix issue of removing a scene
Thinker K.F. Li <thinker@codemud.net>
parents: 1199
diff changeset
664 if start != end:
213f03dbfc41 Fix issue of removing a scene
Thinker K.F. Li <thinker@codemud.net>
parents: 1199
diff changeset
665 frameline.rm_keyframe(end)
1144
257beac7c982 Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents: 1142
diff changeset
666 pass
1200
213f03dbfc41 Fix issue of removing a scene
Thinker K.F. Li <thinker@codemud.net>
parents: 1199
diff changeset
667
213f03dbfc41 Fix issue of removing a scene
Thinker K.F. Li <thinker@codemud.net>
parents: 1199
diff changeset
668 scene_group_id = scene_node.getAttribute('ref')
213f03dbfc41 Fix issue of removing a scene
Thinker K.F. Li <thinker@codemud.net>
parents: 1199
diff changeset
669 scene_group = self.get_node(scene_group_id)
213f03dbfc41 Fix issue of removing a scene
Thinker K.F. Li <thinker@codemud.net>
parents: 1199
diff changeset
670 scene_group.parent().removeChild(scene_group)
213f03dbfc41 Fix issue of removing a scene
Thinker K.F. Li <thinker@codemud.net>
parents: 1199
diff changeset
671 scene_node.parent().removeChild(scene_node)
956
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
672
1139
a2b068594412 Use pybind with new DOM API (at PYNode).
Thinker K.F. Li <thinker@codemud.net>
parents: 1136
diff changeset
673 try:
1200
213f03dbfc41 Fix issue of removing a scene
Thinker K.F. Li <thinker@codemud.net>
parents: 1199
diff changeset
674 frameline.duplicateGroup.setAttribute('style', 'display: none')
213f03dbfc41 Fix issue of removing a scene
Thinker K.F. Li <thinker@codemud.net>
parents: 1199
diff changeset
675 except AttributeError:
1144
257beac7c982 Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents: 1142
diff changeset
676 pass
257beac7c982 Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents: 1142
diff changeset
677 pass
257beac7c982 Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents: 1142
diff changeset
678
973
84f502fb3e40 Rewrite the MBScene to use framelines. The old layers/scenes data structure is used to load the scenes only. We should remove it completely in the future.
wycc
parents: 964
diff changeset
679 def extendScene(self):
1190
a4df892fb4e5 Use meaningful name for scene, scene group, and layer group
Thinker K.F. Li <thinker@codemud.net>
parents: 1189
diff changeset
680 frame_idx = self.last_frame
a4df892fb4e5 Use meaningful name for scene, scene group, and layer group
Thinker K.F. Li <thinker@codemud.net>
parents: 1189
diff changeset
681 frameline = self.last_line
1193
0e3a65b7b00c Simplify extendScened()
Thinker K.F. Li <thinker@codemud.net>
parents: 1192
diff changeset
682
0e3a65b7b00c Simplify extendScened()
Thinker K.F. Li <thinker@codemud.net>
parents: 1192
diff changeset
683 start, end, scene_type = frameline.get_frame_block_floor(frame_idx)
0e3a65b7b00c Simplify extendScened()
Thinker K.F. Li <thinker@codemud.net>
parents: 1192
diff changeset
684 if frame_idx <= end:
0e3a65b7b00c Simplify extendScened()
Thinker K.F. Li <thinker@codemud.net>
parents: 1192
diff changeset
685 return
0e3a65b7b00c Simplify extendScened()
Thinker K.F. Li <thinker@codemud.net>
parents: 1192
diff changeset
686
0e3a65b7b00c Simplify extendScened()
Thinker K.F. Li <thinker@codemud.net>
parents: 1192
diff changeset
687 if start < end:
0e3a65b7b00c Simplify extendScened()
Thinker K.F. Li <thinker@codemud.net>
parents: 1192
diff changeset
688 frameline.rm_keyframe(end)
956
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
689 pass
1193
0e3a65b7b00c Simplify extendScened()
Thinker K.F. Li <thinker@codemud.net>
parents: 1192
diff changeset
690
0e3a65b7b00c Simplify extendScened()
Thinker K.F. Li <thinker@codemud.net>
parents: 1192
diff changeset
691 scene_node = frameline.get_frame_data(start)
1199
25e1579ed3d1 Fix bug of running animation
Thinker K.F. Li <thinker@codemud.net>
parents: 1198
diff changeset
692 self._chg_scene_node(scene_node, end=frame_idx)
1193
0e3a65b7b00c Simplify extendScened()
Thinker K.F. Li <thinker@codemud.net>
parents: 1192
diff changeset
693 frameline.add_keyframe(frame_idx)
0e3a65b7b00c Simplify extendScened()
Thinker K.F. Li <thinker@codemud.net>
parents: 1192
diff changeset
694 frameline.tween(start, scene_type)
956
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
695 pass
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
696
1194
319414e4d87a Fix the issue that is fault to switch scenes
Thinker K.F. Li <thinker@codemud.net>
parents: 1193
diff changeset
697 def setCurrentScene(self, idx):
1123
aad659b6b625 Add motion animation editor.
wycc
parents: 1120
diff changeset
698 """
1144
257beac7c982 Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents: 1142
diff changeset
699 Update the scene group according to the curretn scene
257beac7c982 Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents: 1142
diff changeset
700 data. There are a couple of cases.
1148
wycc
parents: 1147 1145
diff changeset
701 1. If the type of the scene is normal, we display it when
wycc
parents: 1147 1145
diff changeset
702 it contains the current frame. Otherwise hide it.
wycc
parents: 1147 1145
diff changeset
703 2. If the type of the scene is relocate or scale, we need
wycc
parents: 1147 1145
diff changeset
704 to duplicate the scene group and then modify its
wycc
parents: 1147 1145
diff changeset
705 transform matrix according to the definition of the
wycc
parents: 1147 1145
diff changeset
706 scene. Then, hide the original scenr group and display
wycc
parents: 1147 1145
diff changeset
707 the duplciate scene group. In addition, we may need to
1144
257beac7c982 Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents: 1142
diff changeset
708 delete the old duplicated scene group as well.
257beac7c982 Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents: 1142
diff changeset
709
1148
wycc
parents: 1147 1145
diff changeset
710 For each layer, we will always use the duplicated scene
wycc
parents: 1147 1145
diff changeset
711 group whose name as dup.
wycc
parents: 1147 1145
diff changeset
712 We will put the duplicated scene group inside it. We will
wycc
parents: 1147 1145
diff changeset
713 create this group if it is not
1123
aad659b6b625 Add motion animation editor.
wycc
parents: 1120
diff changeset
714 available.
aad659b6b625 Add motion animation editor.
wycc
parents: 1120
diff changeset
715 """
1194
319414e4d87a Fix the issue that is fault to switch scenes
Thinker K.F. Li <thinker@codemud.net>
parents: 1193
diff changeset
716 self.current = idx
1140
d4dbcb93aee0 Separate the tween from the main module.
wycc
parents: 1136
diff changeset
717 self.tween.updateMapping()
1190
a4df892fb4e5 Use meaningful name for scene, scene group, and layer group
Thinker K.F. Li <thinker@codemud.net>
parents: 1189
diff changeset
718 for frameline in self._framelines:
973
84f502fb3e40 Rewrite the MBScene to use framelines. The old layers/scenes data structure is used to load the scenes only. We should remove it completely in the future.
wycc
parents: 964
diff changeset
719 i=0
1123
aad659b6b625 Add motion animation editor.
wycc
parents: 1120
diff changeset
720
aad659b6b625 Add motion animation editor.
wycc
parents: 1120
diff changeset
721 # Check the duplicated scene group and create it if it is not available
aad659b6b625 Add motion animation editor.
wycc
parents: 1120
diff changeset
722 try:
1190
a4df892fb4e5 Use meaningful name for scene, scene group, and layer group
Thinker K.F. Li <thinker@codemud.net>
parents: 1189
diff changeset
723 frameline.duplicateGroup.setAttribute("style","display:none")
1123
aad659b6b625 Add motion animation editor.
wycc
parents: 1120
diff changeset
724 except:
1199
25e1579ed3d1 Fix bug of running animation
Thinker K.F. Li <thinker@codemud.net>
parents: 1198
diff changeset
725 print "*" * 40
25e1579ed3d1 Fix bug of running animation
Thinker K.F. Li <thinker@codemud.net>
parents: 1198
diff changeset
726 layer_idx = frameline.layer_idx
1205
1af64bcdfd7d Move to MBScene._make_layers_integral()
Thinker K.F. Li <thinker@codemud.net>
parents: 1204
diff changeset
727 layer = self._layers[layer_idx]
1199
25e1579ed3d1 Fix bug of running animation
Thinker K.F. Li <thinker@codemud.net>
parents: 1198
diff changeset
728 for child in layer.group.childList():
25e1579ed3d1 Fix bug of running animation
Thinker K.F. Li <thinker@codemud.net>
parents: 1198
diff changeset
729 label = child.getAttribute('inkscape:label')
25e1579ed3d1 Fix bug of running animation
Thinker K.F. Li <thinker@codemud.net>
parents: 1198
diff changeset
730 if label == 'dup':
25e1579ed3d1 Fix bug of running animation
Thinker K.F. Li <thinker@codemud.net>
parents: 1198
diff changeset
731 frameline.duplicateGroup = child
25e1579ed3d1 Fix bug of running animation
Thinker K.F. Li <thinker@codemud.net>
parents: 1198
diff changeset
732 break
25e1579ed3d1 Fix bug of running animation
Thinker K.F. Li <thinker@codemud.net>
parents: 1198
diff changeset
733 pass
25e1579ed3d1 Fix bug of running animation
Thinker K.F. Li <thinker@codemud.net>
parents: 1198
diff changeset
734 else:
25e1579ed3d1 Fix bug of running animation
Thinker K.F. Li <thinker@codemud.net>
parents: 1198
diff changeset
735 duplicateGroup = self.document.createElement("svg:g")
25e1579ed3d1 Fix bug of running animation
Thinker K.F. Li <thinker@codemud.net>
parents: 1198
diff changeset
736 duplicateGroup.setAttribute("inkscape:label","dup")
25e1579ed3d1 Fix bug of running animation
Thinker K.F. Li <thinker@codemud.net>
parents: 1198
diff changeset
737 duplicateGroup.setAttribute("sodipodi:insensitive","1")
25e1579ed3d1 Fix bug of running animation
Thinker K.F. Li <thinker@codemud.net>
parents: 1198
diff changeset
738 duplicateGroup.setAttribute("style","")
1204
78925515836f Add methods for managing framelines
Thinker K.F. Li <thinker@codemud.net>
parents: 1203
diff changeset
739
78925515836f Add methods for managing framelines
Thinker K.F. Li <thinker@codemud.net>
parents: 1203
diff changeset
740 layer.group.appendChild(duplicateGroup)
1199
25e1579ed3d1 Fix bug of running animation
Thinker K.F. Li <thinker@codemud.net>
parents: 1198
diff changeset
741 frameline.duplicateGroup = duplicateGroup
25e1579ed3d1 Fix bug of running animation
Thinker K.F. Li <thinker@codemud.net>
parents: 1198
diff changeset
742 pass
1123
aad659b6b625 Add motion animation editor.
wycc
parents: 1120
diff changeset
743 pass
1199
25e1579ed3d1 Fix bug of running animation
Thinker K.F. Li <thinker@codemud.net>
parents: 1198
diff changeset
744
1123
aad659b6b625 Add motion animation editor.
wycc
parents: 1120
diff changeset
745 # Create a new group
1190
a4df892fb4e5 Use meaningful name for scene, scene group, and layer group
Thinker K.F. Li <thinker@codemud.net>
parents: 1189
diff changeset
746 for start_idx, stop_idx, tween_type in frameline.get_frame_blocks():
1151
71c72e8d6755 Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents: 1150
diff changeset
747 if start_idx == stop_idx:
1190
a4df892fb4e5 Use meaningful name for scene, scene group, and layer group
Thinker K.F. Li <thinker@codemud.net>
parents: 1189
diff changeset
748 scene_node = frameline.get_frame_data(start_idx)
1194
319414e4d87a Fix the issue that is fault to switch scenes
Thinker K.F. Li <thinker@codemud.net>
parents: 1193
diff changeset
749 scene_group_id = scene_node.getAttribute('ref')
319414e4d87a Fix the issue that is fault to switch scenes
Thinker K.F. Li <thinker@codemud.net>
parents: 1193
diff changeset
750 scene_group = self.get_node(scene_group_id)
1151
71c72e8d6755 Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents: 1150
diff changeset
751 if idx == start_idx:
71c72e8d6755 Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents: 1150
diff changeset
752 scene_group.setAttribute('style', '')
973
84f502fb3e40 Rewrite the MBScene to use framelines. The old layers/scenes data structure is used to load the scenes only. We should remove it completely in the future.
wycc
parents: 964
diff changeset
753 else:
1151
71c72e8d6755 Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents: 1150
diff changeset
754 scene_group.setAttribute('style', 'display: none')
71c72e8d6755 Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents: 1150
diff changeset
755 pass
1155
5db4d769387c Show the frame when we select the keyframe. The duplicated group must be shown only in the tweened frame
wycc
parents: 1151
diff changeset
756 elif idx == start_idx:
1190
a4df892fb4e5 Use meaningful name for scene, scene group, and layer group
Thinker K.F. Li <thinker@codemud.net>
parents: 1189
diff changeset
757 frameline.duplicateGroup.setAttribute("style","display:none")
a4df892fb4e5 Use meaningful name for scene, scene group, and layer group
Thinker K.F. Li <thinker@codemud.net>
parents: 1189
diff changeset
758 scene_node = frameline.get_frame_data(start_idx)
1196
42f8cee2118b Fix the issue that is falut to show first frame of a tween
Thinker K.F. Li <thinker@codemud.net>
parents: 1195
diff changeset
759 scene_group_id = scene_node.getAttribute('ref')
42f8cee2118b Fix the issue that is falut to show first frame of a tween
Thinker K.F. Li <thinker@codemud.net>
parents: 1195
diff changeset
760 scene_group = self.get_node(scene_group_id)
1155
5db4d769387c Show the frame when we select the keyframe. The duplicated group must be shown only in the tweened frame
wycc
parents: 1151
diff changeset
761 scene_group.setAttribute("style","")
1199
25e1579ed3d1 Fix bug of running animation
Thinker K.F. Li <thinker@codemud.net>
parents: 1198
diff changeset
762 elif start_idx < idx and stop_idx >= idx:
1190
a4df892fb4e5 Use meaningful name for scene, scene group, and layer group
Thinker K.F. Li <thinker@codemud.net>
parents: 1189
diff changeset
763 scene_node = frameline.get_frame_data(start_idx)
1194
319414e4d87a Fix the issue that is fault to switch scenes
Thinker K.F. Li <thinker@codemud.net>
parents: 1193
diff changeset
764 scene_group_id = scene_node.getAttribute('ref')
319414e4d87a Fix the issue that is fault to switch scenes
Thinker K.F. Li <thinker@codemud.net>
parents: 1193
diff changeset
765 scene_group = self.get_node(scene_group_id)
1151
71c72e8d6755 Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents: 1150
diff changeset
766 scene_group.setAttribute("style","display:none")
1190
a4df892fb4e5 Use meaningful name for scene, scene group, and layer group
Thinker K.F. Li <thinker@codemud.net>
parents: 1189
diff changeset
767 frameline.duplicateGroup.setAttribute("style","")
1151
71c72e8d6755 Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents: 1150
diff changeset
768 tween_type_idx = \
71c72e8d6755 Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents: 1150
diff changeset
769 self._frameline_tween_types.index(tween_type)
71c72e8d6755 Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents: 1150
diff changeset
770 tween_obj_tween_type = \
71c72e8d6755 Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents: 1150
diff changeset
771 self._tween_obj_tween_types[tween_type_idx]
71c72e8d6755 Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents: 1150
diff changeset
772
1180
bfd7d466a022 Fix yeiling error message when select a scene.
Thinker K.F. Li <thinker@codemud.net>
parents: 1179
diff changeset
773 try:
bfd7d466a022 Fix yeiling error message when select a scene.
Thinker K.F. Li <thinker@codemud.net>
parents: 1179
diff changeset
774 next_idx, next_stop_idx, next_tween_type = \
1190
a4df892fb4e5 Use meaningful name for scene, scene group, and layer group
Thinker K.F. Li <thinker@codemud.net>
parents: 1189
diff changeset
775 frameline.get_frame_block(stop_idx + 1)
1180
bfd7d466a022 Fix yeiling error message when select a scene.
Thinker K.F. Li <thinker@codemud.net>
parents: 1179
diff changeset
776 except:
1190
a4df892fb4e5 Use meaningful name for scene, scene group, and layer group
Thinker K.F. Li <thinker@codemud.net>
parents: 1189
diff changeset
777 next_scene_node = scene_node
1163
wycc
parents: 1161
diff changeset
778 else:
1190
a4df892fb4e5 Use meaningful name for scene, scene group, and layer group
Thinker K.F. Li <thinker@codemud.net>
parents: 1189
diff changeset
779 next_scene_node = frameline.get_frame_data(next_idx)
1180
bfd7d466a022 Fix yeiling error message when select a scene.
Thinker K.F. Li <thinker@codemud.net>
parents: 1179
diff changeset
780 pass
1194
319414e4d87a Fix the issue that is fault to switch scenes
Thinker K.F. Li <thinker@codemud.net>
parents: 1193
diff changeset
781
319414e4d87a Fix the issue that is fault to switch scenes
Thinker K.F. Li <thinker@codemud.net>
parents: 1193
diff changeset
782 next_scene_group_id = next_scene_node.getAttribute('ref')
319414e4d87a Fix the issue that is fault to switch scenes
Thinker K.F. Li <thinker@codemud.net>
parents: 1193
diff changeset
783 next_scene_group = self.get_node(next_scene_group_id)
1151
71c72e8d6755 Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents: 1150
diff changeset
784
1160
1a699dc00fa3 Fix the issue of not removing node in old scene when switching scenes.
Thinker K.F. Li <thinker@codemud.net>
parents: 1159
diff changeset
785 nframes = stop_idx - start_idx + 1
1151
71c72e8d6755 Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents: 1150
diff changeset
786 percent = float(idx - start_idx) / nframes
1199
25e1579ed3d1 Fix bug of running animation
Thinker K.F. Li <thinker@codemud.net>
parents: 1198
diff changeset
787 print tween_obj_tween_type
1190
a4df892fb4e5 Use meaningful name for scene, scene group, and layer group
Thinker K.F. Li <thinker@codemud.net>
parents: 1189
diff changeset
788 self.tween.updateTweenContent(frameline.duplicateGroup,
1151
71c72e8d6755 Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents: 1150
diff changeset
789 tween_obj_tween_type,
71c72e8d6755 Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents: 1150
diff changeset
790 scene_group,
71c72e8d6755 Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents: 1150
diff changeset
791 next_scene_group,
71c72e8d6755 Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents: 1150
diff changeset
792 percent)
959
67823f7a0a17 Use frameline module in MBScene
Thinker K.F. Li <thinker@codemud.net>
parents: 957
diff changeset
793 else:
1190
a4df892fb4e5 Use meaningful name for scene, scene group, and layer group
Thinker K.F. Li <thinker@codemud.net>
parents: 1189
diff changeset
794 scene_node = frameline.get_frame_data(start_idx)
1194
319414e4d87a Fix the issue that is fault to switch scenes
Thinker K.F. Li <thinker@codemud.net>
parents: 1193
diff changeset
795 scene_group_id = scene_node.getAttribute('ref')
319414e4d87a Fix the issue that is fault to switch scenes
Thinker K.F. Li <thinker@codemud.net>
parents: 1193
diff changeset
796 scene_group = self.get_node(scene_group_id)
1151
71c72e8d6755 Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents: 1150
diff changeset
797 scene_group.setAttribute("style","display:none")
71c72e8d6755 Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents: 1150
diff changeset
798 pass
955
53b0f8dc2284 Add tailing 'pass' commands to close indents
Thinker K.F. Li <thinker@codemud.net>
parents: 943
diff changeset
799 pass
956
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
800 pass
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
801 pass
1125
5b2394f67ad0 Add shape tween support.
wycc
parents: 1123
diff changeset
802
1191
6442fb198418 Refactory insertKeyScene() and fix bug of ObjectWatcher
Thinker K.F. Li <thinker@codemud.net>
parents: 1190
diff changeset
803 def enterGroup(self, obj):
1205
1af64bcdfd7d Move to MBScene._make_layers_integral()
Thinker K.F. Li <thinker@codemud.net>
parents: 1204
diff changeset
804 for l in self._layers:
1190
a4df892fb4e5 Use meaningful name for scene, scene group, and layer group
Thinker K.F. Li <thinker@codemud.net>
parents: 1189
diff changeset
805 for s in l.group.childList():
1139
a2b068594412 Use pybind with new DOM API (at PYNode).
Thinker K.F. Li <thinker@codemud.net>
parents: 1136
diff changeset
806 if s.getAttribute('id') == obj.getAttribute("id"):
1142
dd6c60c6f41e Use getAttribute()/spitem instead of .label and DOMtoItem().
Thinker K.F. Li <thinker@codemud.net>
parents: 1141
diff changeset
807 self.desktop.setCurrentLayer(s.spitem)
1144
257beac7c982 Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents: 1142
diff changeset
808 pass
257beac7c982 Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents: 1142
diff changeset
809 pass
257beac7c982 Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents: 1142
diff changeset
810 pass
257beac7c982 Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents: 1142
diff changeset
811 pass
257beac7c982 Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents: 1142
diff changeset
812
1178
416e41952b76 Fix issue that pyink does not switch current layer to the new key scene.
Thinker K.F. Li <thinker@codemud.net>
parents: 1177
diff changeset
813 def selectSceneObject(self, frameline, frame_idx):
1177
ec1ea8555911 Stop selectSceneObject() from using private variable _keys of frameline
Thinker K.F. Li <thinker@codemud.net>
parents: 1176
diff changeset
814 try:
1178
416e41952b76 Fix issue that pyink does not switch current layer to the new key scene.
Thinker K.F. Li <thinker@codemud.net>
parents: 1177
diff changeset
815 start, stop, tween_type = frameline.get_frame_block(frame_idx)
1177
ec1ea8555911 Stop selectSceneObject() from using private variable _keys of frameline
Thinker K.F. Li <thinker@codemud.net>
parents: 1176
diff changeset
816 except:
ec1ea8555911 Stop selectSceneObject() from using private variable _keys of frameline
Thinker K.F. Li <thinker@codemud.net>
parents: 1176
diff changeset
817 return
1070
afa42d5836cc Call setCurrentLayer to enter the current scene group.
wycc
parents: 1064
diff changeset
818
1190
a4df892fb4e5 Use meaningful name for scene, scene group, and layer group
Thinker K.F. Li <thinker@codemud.net>
parents: 1189
diff changeset
819 scene_node = frameline.get_frame_data(start)
1191
6442fb198418 Refactory insertKeyScene() and fix bug of ObjectWatcher
Thinker K.F. Li <thinker@codemud.net>
parents: 1190
diff changeset
820 scene_group_id = scene_node.getAttribute('ref')
6442fb198418 Refactory insertKeyScene() and fix bug of ObjectWatcher
Thinker K.F. Li <thinker@codemud.net>
parents: 1190
diff changeset
821 scene_group = self.get_node(scene_group_id)
1177
ec1ea8555911 Stop selectSceneObject() from using private variable _keys of frameline
Thinker K.F. Li <thinker@codemud.net>
parents: 1176
diff changeset
822 self.enterGroup(scene_group)
ec1ea8555911 Stop selectSceneObject() from using private variable _keys of frameline
Thinker K.F. Li <thinker@codemud.net>
parents: 1176
diff changeset
823 self.setTweenType(tween_type)
ec1ea8555911 Stop selectSceneObject() from using private variable _keys of frameline
Thinker K.F. Li <thinker@codemud.net>
parents: 1176
diff changeset
824 pass
1144
257beac7c982 Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents: 1142
diff changeset
825
1150
6586cd10c92f Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents: 1149
diff changeset
826 def setTweenType(self, tween_type):
1151
71c72e8d6755 Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents: 1150
diff changeset
827 sel_type = MBScene._frameline_tween_types.index(tween_type)
1150
6586cd10c92f Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents: 1149
diff changeset
828 self._disable_tween_type_selector = True
6586cd10c92f Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents: 1149
diff changeset
829 self.tweenTypeSelector.set_active(sel_type)
6586cd10c92f Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents: 1149
diff changeset
830 self._disable_tween_type_selector = False
1144
257beac7c982 Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents: 1142
diff changeset
831 pass
955
53b0f8dc2284 Add tailing 'pass' commands to close indents
Thinker K.F. Li <thinker@codemud.net>
parents: 943
diff changeset
832
1179
b65df4f0d30a Change signature of MBScene.insertKeyScene()
Thinker K.F. Li <thinker@codemud.net>
parents: 1178
diff changeset
833 def onCellClick(self, line, frame, but):
973
84f502fb3e40 Rewrite the MBScene to use framelines. The old layers/scenes data structure is used to load the scenes only. We should remove it completely in the future.
wycc
parents: 964
diff changeset
834 self.last_line = line
84f502fb3e40 Rewrite the MBScene to use framelines. The old layers/scenes data structure is used to load the scenes only. We should remove it completely in the future.
wycc
parents: 964
diff changeset
835 self.last_frame = frame
976
ab09c536a137 Hide the hover of all inactive framelines. This fix the issue of multiple hover in every frameline objects.
wycc
parents: 975
diff changeset
836 self.last_line.active_frame(frame)
1189
9cf183faf89f Maintaining scene group ID to scene node mapping in MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1188
diff changeset
837 self._lockui = True
1179
b65df4f0d30a Change signature of MBScene.insertKeyScene()
Thinker K.F. Li <thinker@codemud.net>
parents: 1178
diff changeset
838 self.doEditScene(None)
1189
9cf183faf89f Maintaining scene group ID to scene node mapping in MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1188
diff changeset
839 self._lockui = False
1144
257beac7c982 Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents: 1142
diff changeset
840 pass
973
84f502fb3e40 Rewrite the MBScene to use framelines. The old layers/scenes data structure is used to load the scenes only. We should remove it completely in the future.
wycc
parents: 964
diff changeset
841
976
ab09c536a137 Hide the hover of all inactive framelines. This fix the issue of multiple hover in every frameline objects.
wycc
parents: 975
diff changeset
842 def _remove_active_frame(self,widget,event):
ab09c536a137 Hide the hover of all inactive framelines. This fix the issue of multiple hover in every frameline objects.
wycc
parents: 975
diff changeset
843 """
ab09c536a137 Hide the hover of all inactive framelines. This fix the issue of multiple hover in every frameline objects.
wycc
parents: 975
diff changeset
844 Hide all hover frames. This is a hack. We should use the lost focus event
ab09c536a137 Hide the hover of all inactive framelines. This fix the issue of multiple hover in every frameline objects.
wycc
parents: 975
diff changeset
845 instead in the future to reduce the overhead.
ab09c536a137 Hide the hover of all inactive framelines. This fix the issue of multiple hover in every frameline objects.
wycc
parents: 975
diff changeset
846 """
ab09c536a137 Hide the hover of all inactive framelines. This fix the issue of multiple hover in every frameline objects.
wycc
parents: 975
diff changeset
847 for f in self._framelines:
ab09c536a137 Hide the hover of all inactive framelines. This fix the issue of multiple hover in every frameline objects.
wycc
parents: 975
diff changeset
848 if f != widget:
ab09c536a137 Hide the hover of all inactive framelines. This fix the issue of multiple hover in every frameline objects.
wycc
parents: 975
diff changeset
849 f.hide_hover()
1144
257beac7c982 Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents: 1142
diff changeset
850 pass
257beac7c982 Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents: 1142
diff changeset
851 pass
257beac7c982 Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents: 1142
diff changeset
852 pass
1204
78925515836f Add methods for managing framelines
Thinker K.F. Li <thinker@codemud.net>
parents: 1203
diff changeset
853
78925515836f Add methods for managing framelines
Thinker K.F. Li <thinker@codemud.net>
parents: 1203
diff changeset
854 ## \brief Add a frameline into the frameline box for the given layer.
78925515836f Add methods for managing framelines
Thinker K.F. Li <thinker@codemud.net>
parents: 1203
diff changeset
855 #
78925515836f Add methods for managing framelines
Thinker K.F. Li <thinker@codemud.net>
parents: 1203
diff changeset
856 def _add_frameline(self, layer_idx):
78925515836f Add methods for managing framelines
Thinker K.F. Li <thinker@codemud.net>
parents: 1203
diff changeset
857 if layer_idx > len(self._framelines):
78925515836f Add methods for managing framelines
Thinker K.F. Li <thinker@codemud.net>
parents: 1203
diff changeset
858 raise ValueError, 'layer number should be a consequence'
78925515836f Add methods for managing framelines
Thinker K.F. Li <thinker@codemud.net>
parents: 1203
diff changeset
859
1205
1af64bcdfd7d Move to MBScene._make_layers_integral()
Thinker K.F. Li <thinker@codemud.net>
parents: 1204
diff changeset
860 vbox = self._frameline_vbox
1204
78925515836f Add methods for managing framelines
Thinker K.F. Li <thinker@codemud.net>
parents: 1203
diff changeset
861
78925515836f Add methods for managing framelines
Thinker K.F. Li <thinker@codemud.net>
parents: 1203
diff changeset
862 line = frameline(self._num_frames_of_line)
78925515836f Add methods for managing framelines
Thinker K.F. Li <thinker@codemud.net>
parents: 1203
diff changeset
863 line.set_size_request(self._num_frames_of_line * 10, 20)
78925515836f Add methods for managing framelines
Thinker K.F. Li <thinker@codemud.net>
parents: 1203
diff changeset
864
78925515836f Add methods for managing framelines
Thinker K.F. Li <thinker@codemud.net>
parents: 1203
diff changeset
865 hbox = gtk.HBox()
78925515836f Add methods for managing framelines
Thinker K.F. Li <thinker@codemud.net>
parents: 1203
diff changeset
866 label = gtk.Label('')
78925515836f Add methods for managing framelines
Thinker K.F. Li <thinker@codemud.net>
parents: 1203
diff changeset
867 label.set_size_request(100,0)
78925515836f Add methods for managing framelines
Thinker K.F. Li <thinker@codemud.net>
parents: 1203
diff changeset
868 hbox.pack_start(label,expand=False, fill=True)
78925515836f Add methods for managing framelines
Thinker K.F. Li <thinker@codemud.net>
parents: 1203
diff changeset
869 hbox.pack_start(line)
78925515836f Add methods for managing framelines
Thinker K.F. Li <thinker@codemud.net>
parents: 1203
diff changeset
870 vbox.pack_start(hbox, False)
78925515836f Add methods for managing framelines
Thinker K.F. Li <thinker@codemud.net>
parents: 1203
diff changeset
871
78925515836f Add methods for managing framelines
Thinker K.F. Li <thinker@codemud.net>
parents: 1203
diff changeset
872 if layer_idx != len(self._framelines):
78925515836f Add methods for managing framelines
Thinker K.F. Li <thinker@codemud.net>
parents: 1203
diff changeset
873 vbox.reorder_child(hbox, layer_idx + 1) # there is ruler at pos 0
1166
d73ef03c96de Refactory code of MBScene.updateUI() from MBScene.show()
Thinker K.F. Li <thinker@codemud.net>
parents: 1164
diff changeset
874 pass
959
67823f7a0a17 Use frameline module in MBScene
Thinker K.F. Li <thinker@codemud.net>
parents: 957
diff changeset
875
1204
78925515836f Add methods for managing framelines
Thinker K.F. Li <thinker@codemud.net>
parents: 1203
diff changeset
876 self._framelines[layer_idx: layer_idx] = [line]
78925515836f Add methods for managing framelines
Thinker K.F. Li <thinker@codemud.net>
parents: 1203
diff changeset
877
78925515836f Add methods for managing framelines
Thinker K.F. Li <thinker@codemud.net>
parents: 1203
diff changeset
878 line.label = label
78925515836f Add methods for managing framelines
Thinker K.F. Li <thinker@codemud.net>
parents: 1203
diff changeset
879 line.layer_idx = layer_idx
78925515836f Add methods for managing framelines
Thinker K.F. Li <thinker@codemud.net>
parents: 1203
diff changeset
880 line.connect(line.FRAME_BUT_PRESS, self.onCellClick)
78925515836f Add methods for managing framelines
Thinker K.F. Li <thinker@codemud.net>
parents: 1203
diff changeset
881 line.connect('motion-notify-event', self._remove_active_frame)
78925515836f Add methods for managing framelines
Thinker K.F. Li <thinker@codemud.net>
parents: 1203
diff changeset
882 pass
78925515836f Add methods for managing framelines
Thinker K.F. Li <thinker@codemud.net>
parents: 1203
diff changeset
883
78925515836f Add methods for managing framelines
Thinker K.F. Li <thinker@codemud.net>
parents: 1203
diff changeset
884 ## \brief Remove the given frameline from the frameline box.
78925515836f Add methods for managing framelines
Thinker K.F. Li <thinker@codemud.net>
parents: 1203
diff changeset
885 #
78925515836f Add methods for managing framelines
Thinker K.F. Li <thinker@codemud.net>
parents: 1203
diff changeset
886 def _remove_frameline(self, layer_idx):
1205
1af64bcdfd7d Move to MBScene._make_layers_integral()
Thinker K.F. Li <thinker@codemud.net>
parents: 1204
diff changeset
887 vbox = self._frameline_vbox
1204
78925515836f Add methods for managing framelines
Thinker K.F. Li <thinker@codemud.net>
parents: 1203
diff changeset
888 line = self._framelines[layer_idx]
78925515836f Add methods for managing framelines
Thinker K.F. Li <thinker@codemud.net>
parents: 1203
diff changeset
889
78925515836f Add methods for managing framelines
Thinker K.F. Li <thinker@codemud.net>
parents: 1203
diff changeset
890 hbox = line.parent
78925515836f Add methods for managing framelines
Thinker K.F. Li <thinker@codemud.net>
parents: 1203
diff changeset
891 vbox.remove(hbox)
78925515836f Add methods for managing framelines
Thinker K.F. Li <thinker@codemud.net>
parents: 1203
diff changeset
892 del self._framelines[layer_idx]
78925515836f Add methods for managing framelines
Thinker K.F. Li <thinker@codemud.net>
parents: 1203
diff changeset
893 pass
78925515836f Add methods for managing framelines
Thinker K.F. Li <thinker@codemud.net>
parents: 1203
diff changeset
894
1205
1af64bcdfd7d Move to MBScene._make_layers_integral()
Thinker K.F. Li <thinker@codemud.net>
parents: 1204
diff changeset
895 ## \brief Remove the layer that lost the layer group.
1af64bcdfd7d Move to MBScene._make_layers_integral()
Thinker K.F. Li <thinker@codemud.net>
parents: 1204
diff changeset
896 #
1af64bcdfd7d Move to MBScene._make_layers_integral()
Thinker K.F. Li <thinker@codemud.net>
parents: 1204
diff changeset
897 # This function is called when a layer group being removed from the
1af64bcdfd7d Move to MBScene._make_layers_integral()
Thinker K.F. Li <thinker@codemud.net>
parents: 1204
diff changeset
898 # DOM-tree.
1204
78925515836f Add methods for managing framelines
Thinker K.F. Li <thinker@codemud.net>
parents: 1203
diff changeset
899 def _remove_lost_group_layer(self, layer_idx):
1205
1af64bcdfd7d Move to MBScene._make_layers_integral()
Thinker K.F. Li <thinker@codemud.net>
parents: 1204
diff changeset
900 layer = self._layers[layer_idx]
1204
78925515836f Add methods for managing framelines
Thinker K.F. Li <thinker@codemud.net>
parents: 1203
diff changeset
901 frameline = self._framelines[layer_idx]
78925515836f Add methods for managing framelines
Thinker K.F. Li <thinker@codemud.net>
parents: 1203
diff changeset
902 for start, end, tween_type in frameline.get_frame_blocks():
78925515836f Add methods for managing framelines
Thinker K.F. Li <thinker@codemud.net>
parents: 1203
diff changeset
903 scene_node = frameline.get_frame_data(start)
78925515836f Add methods for managing framelines
Thinker K.F. Li <thinker@codemud.net>
parents: 1203
diff changeset
904 self._rm_scene_node(scene_node)
78925515836f Add methods for managing framelines
Thinker K.F. Li <thinker@codemud.net>
parents: 1203
diff changeset
905 pass
78925515836f Add methods for managing framelines
Thinker K.F. Li <thinker@codemud.net>
parents: 1203
diff changeset
906
78925515836f Add methods for managing framelines
Thinker K.F. Li <thinker@codemud.net>
parents: 1203
diff changeset
907 self._remove_frameline(layer_idx) # TODO
1205
1af64bcdfd7d Move to MBScene._make_layers_integral()
Thinker K.F. Li <thinker@codemud.net>
parents: 1204
diff changeset
908 del self._layers[layer_idx]
1204
78925515836f Add methods for managing framelines
Thinker K.F. Li <thinker@codemud.net>
parents: 1203
diff changeset
909 pass
78925515836f Add methods for managing framelines
Thinker K.F. Li <thinker@codemud.net>
parents: 1203
diff changeset
910
1205
1af64bcdfd7d Move to MBScene._make_layers_integral()
Thinker K.F. Li <thinker@codemud.net>
parents: 1204
diff changeset
911 ## \brief Make status of layers is updated when DOM is changed.
1af64bcdfd7d Move to MBScene._make_layers_integral()
Thinker K.F. Li <thinker@codemud.net>
parents: 1204
diff changeset
912 #
1af64bcdfd7d Move to MBScene._make_layers_integral()
Thinker K.F. Li <thinker@codemud.net>
parents: 1204
diff changeset
913 # When DOM-tree is changed, this function make sure layer information is up
1af64bcdfd7d Move to MBScene._make_layers_integral()
Thinker K.F. Li <thinker@codemud.net>
parents: 1204
diff changeset
914 # to date.
1204
78925515836f Add methods for managing framelines
Thinker K.F. Li <thinker@codemud.net>
parents: 1203
diff changeset
915 def _make_layers_integral(self):
78925515836f Add methods for managing framelines
Thinker K.F. Li <thinker@codemud.net>
parents: 1203
diff changeset
916 root = self._root
78925515836f Add methods for managing framelines
Thinker K.F. Li <thinker@codemud.net>
parents: 1203
diff changeset
917 root_id = root.getAttribute('id')
959
67823f7a0a17 Use frameline module in MBScene
Thinker K.F. Li <thinker@codemud.net>
parents: 957
diff changeset
918
1205
1af64bcdfd7d Move to MBScene._make_layers_integral()
Thinker K.F. Li <thinker@codemud.net>
parents: 1204
diff changeset
919 # Remove group of removed layers
1204
78925515836f Add methods for managing framelines
Thinker K.F. Li <thinker@codemud.net>
parents: 1203
diff changeset
920 layer_idx = 0
1205
1af64bcdfd7d Move to MBScene._make_layers_integral()
Thinker K.F. Li <thinker@codemud.net>
parents: 1204
diff changeset
921 while layer_idx < len(self._layers):
1af64bcdfd7d Move to MBScene._make_layers_integral()
Thinker K.F. Li <thinker@codemud.net>
parents: 1204
diff changeset
922 layer = self._layers[layer_idx]
1204
78925515836f Add methods for managing framelines
Thinker K.F. Li <thinker@codemud.net>
parents: 1203
diff changeset
923
78925515836f Add methods for managing framelines
Thinker K.F. Li <thinker@codemud.net>
parents: 1203
diff changeset
924 if layer.group.name() != 'svg:g':
1205
1af64bcdfd7d Move to MBScene._make_layers_integral()
Thinker K.F. Li <thinker@codemud.net>
parents: 1204
diff changeset
925 self._remove_lost_group_layer(layer_idx) # TODO
1204
78925515836f Add methods for managing framelines
Thinker K.F. Li <thinker@codemud.net>
parents: 1203
diff changeset
926 continue
78925515836f Add methods for managing framelines
Thinker K.F. Li <thinker@codemud.net>
parents: 1203
diff changeset
927
78925515836f Add methods for managing framelines
Thinker K.F. Li <thinker@codemud.net>
parents: 1203
diff changeset
928 parent = layer.group.parent()
1205
1af64bcdfd7d Move to MBScene._make_layers_integral()
Thinker K.F. Li <thinker@codemud.net>
parents: 1204
diff changeset
929 if parent.name() != 'svg:svg':
1af64bcdfd7d Move to MBScene._make_layers_integral()
Thinker K.F. Li <thinker@codemud.net>
parents: 1204
diff changeset
930 self._remove_lost_group_layer(layer_idx)
1204
78925515836f Add methods for managing framelines
Thinker K.F. Li <thinker@codemud.net>
parents: 1203
diff changeset
931 continue
78925515836f Add methods for managing framelines
Thinker K.F. Li <thinker@codemud.net>
parents: 1203
diff changeset
932
78925515836f Add methods for managing framelines
Thinker K.F. Li <thinker@codemud.net>
parents: 1203
diff changeset
933 if parent.getAttribute('id') != root_id:
1205
1af64bcdfd7d Move to MBScene._make_layers_integral()
Thinker K.F. Li <thinker@codemud.net>
parents: 1204
diff changeset
934 self._remove_lost_group_layer(layer_idx)
1204
78925515836f Add methods for managing framelines
Thinker K.F. Li <thinker@codemud.net>
parents: 1203
diff changeset
935 continue
78925515836f Add methods for managing framelines
Thinker K.F. Li <thinker@codemud.net>
parents: 1203
diff changeset
936
78925515836f Add methods for managing framelines
Thinker K.F. Li <thinker@codemud.net>
parents: 1203
diff changeset
937 layer_idx = layer_idx + 1
78925515836f Add methods for managing framelines
Thinker K.F. Li <thinker@codemud.net>
parents: 1203
diff changeset
938 pass
78925515836f Add methods for managing framelines
Thinker K.F. Li <thinker@codemud.net>
parents: 1203
diff changeset
939
1205
1af64bcdfd7d Move to MBScene._make_layers_integral()
Thinker K.F. Li <thinker@codemud.net>
parents: 1204
diff changeset
940 # Add new layers
1204
78925515836f Add methods for managing framelines
Thinker K.F. Li <thinker@codemud.net>
parents: 1203
diff changeset
941 layer_idx = 0
78925515836f Add methods for managing framelines
Thinker K.F. Li <thinker@codemud.net>
parents: 1203
diff changeset
942 for child in root.childList():
78925515836f Add methods for managing framelines
Thinker K.F. Li <thinker@codemud.net>
parents: 1203
diff changeset
943 if child.name() != 'svg:g':
78925515836f Add methods for managing framelines
Thinker K.F. Li <thinker@codemud.net>
parents: 1203
diff changeset
944 continue
1205
1af64bcdfd7d Move to MBScene._make_layers_integral()
Thinker K.F. Li <thinker@codemud.net>
parents: 1204
diff changeset
945
1af64bcdfd7d Move to MBScene._make_layers_integral()
Thinker K.F. Li <thinker@codemud.net>
parents: 1204
diff changeset
946 layer = self._layers[layer_idx]
1af64bcdfd7d Move to MBScene._make_layers_integral()
Thinker K.F. Li <thinker@codemud.net>
parents: 1204
diff changeset
947 layer_group_id = layer.group.getAttribute('id')
1204
78925515836f Add methods for managing framelines
Thinker K.F. Li <thinker@codemud.net>
parents: 1203
diff changeset
948 child_id = child.getAttribute('id')
1205
1af64bcdfd7d Move to MBScene._make_layers_integral()
Thinker K.F. Li <thinker@codemud.net>
parents: 1204
diff changeset
949 if layer_group_id != child_id:
1af64bcdfd7d Move to MBScene._make_layers_integral()
Thinker K.F. Li <thinker@codemud.net>
parents: 1204
diff changeset
950 self.add_layer(layer_idx, child)
1af64bcdfd7d Move to MBScene._make_layers_integral()
Thinker K.F. Li <thinker@codemud.net>
parents: 1204
diff changeset
951 self.parse_layer(layer_idx)
1af64bcdfd7d Move to MBScene._make_layers_integral()
Thinker K.F. Li <thinker@codemud.net>
parents: 1204
diff changeset
952 self._add_frameline(layer_idx)
1204
78925515836f Add methods for managing framelines
Thinker K.F. Li <thinker@codemud.net>
parents: 1203
diff changeset
953 pass
78925515836f Add methods for managing framelines
Thinker K.F. Li <thinker@codemud.net>
parents: 1203
diff changeset
954
78925515836f Add methods for managing framelines
Thinker K.F. Li <thinker@codemud.net>
parents: 1203
diff changeset
955 layer_idx = layer_idx + 1
78925515836f Add methods for managing framelines
Thinker K.F. Li <thinker@codemud.net>
parents: 1203
diff changeset
956 pass
78925515836f Add methods for managing framelines
Thinker K.F. Li <thinker@codemud.net>
parents: 1203
diff changeset
957 pass
1205
1af64bcdfd7d Move to MBScene._make_layers_integral()
Thinker K.F. Li <thinker@codemud.net>
parents: 1204
diff changeset
958
1af64bcdfd7d Move to MBScene._make_layers_integral()
Thinker K.F. Li <thinker@codemud.net>
parents: 1204
diff changeset
959 def _init_framelines(self):
1af64bcdfd7d Move to MBScene._make_layers_integral()
Thinker K.F. Li <thinker@codemud.net>
parents: 1204
diff changeset
960 self._framelines = []
959
67823f7a0a17 Use frameline module in MBScene
Thinker K.F. Li <thinker@codemud.net>
parents: 957
diff changeset
961
1205
1af64bcdfd7d Move to MBScene._make_layers_integral()
Thinker K.F. Li <thinker@codemud.net>
parents: 1204
diff changeset
962 box = gtk.ScrolledWindow()
1af64bcdfd7d Move to MBScene._make_layers_integral()
Thinker K.F. Li <thinker@codemud.net>
parents: 1204
diff changeset
963 self._frameline_box = box
1af64bcdfd7d Move to MBScene._make_layers_integral()
Thinker K.F. Li <thinker@codemud.net>
parents: 1204
diff changeset
964 box.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
1af64bcdfd7d Move to MBScene._make_layers_integral()
Thinker K.F. Li <thinker@codemud.net>
parents: 1204
diff changeset
965 box.set_size_request(-1, 150)
1af64bcdfd7d Move to MBScene._make_layers_integral()
Thinker K.F. Li <thinker@codemud.net>
parents: 1204
diff changeset
966 vbox = gtk.VBox()
1af64bcdfd7d Move to MBScene._make_layers_integral()
Thinker K.F. Li <thinker@codemud.net>
parents: 1204
diff changeset
967 self._frameline_vbox = vbox
1af64bcdfd7d Move to MBScene._make_layers_integral()
Thinker K.F. Li <thinker@codemud.net>
parents: 1204
diff changeset
968 box.add_with_viewport(vbox)
1af64bcdfd7d Move to MBScene._make_layers_integral()
Thinker K.F. Li <thinker@codemud.net>
parents: 1204
diff changeset
969
1af64bcdfd7d Move to MBScene._make_layers_integral()
Thinker K.F. Li <thinker@codemud.net>
parents: 1204
diff changeset
970 nframes = self._num_frames_of_line
959
67823f7a0a17 Use frameline module in MBScene
Thinker K.F. Li <thinker@codemud.net>
parents: 957
diff changeset
971
1204
78925515836f Add methods for managing framelines
Thinker K.F. Li <thinker@codemud.net>
parents: 1203
diff changeset
972 #
78925515836f Add methods for managing framelines
Thinker K.F. Li <thinker@codemud.net>
parents: 1203
diff changeset
973 # Set up a ruler
78925515836f Add methods for managing framelines
Thinker K.F. Li <thinker@codemud.net>
parents: 1203
diff changeset
974 #
1150
6586cd10c92f Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents: 1149
diff changeset
975 ruler = frameruler(nframes)
959
67823f7a0a17 Use frameline module in MBScene
Thinker K.F. Li <thinker@codemud.net>
parents: 957
diff changeset
976 ruler.set_size_request(nframes * 10, 20)
67823f7a0a17 Use frameline module in MBScene
Thinker K.F. Li <thinker@codemud.net>
parents: 957
diff changeset
977 ruler.show()
1032
148ce30a861d SHift the ruler to the right to align to the frames
wycc
parents: 983
diff changeset
978 hbox = gtk.HBox()
148ce30a861d SHift the ruler to the right to align to the frames
wycc
parents: 983
diff changeset
979 label=gtk.Label('')
148ce30a861d SHift the ruler to the right to align to the frames
wycc
parents: 983
diff changeset
980 label.set_size_request(100,0)
148ce30a861d SHift the ruler to the right to align to the frames
wycc
parents: 983
diff changeset
981 hbox.pack_start(label,expand=False,fill=True)
148ce30a861d SHift the ruler to the right to align to the frames
wycc
parents: 983
diff changeset
982 hbox.pack_start(ruler)
148ce30a861d SHift the ruler to the right to align to the frames
wycc
parents: 983
diff changeset
983 vbox.pack_start(hbox, False)
1205
1af64bcdfd7d Move to MBScene._make_layers_integral()
Thinker K.F. Li <thinker@codemud.net>
parents: 1204
diff changeset
984
1174
96a7abce774a Add functions to insert and remove frame.
wycc
parents: 1171
diff changeset
985 vbox.show_all()
960
8fd97e0becb3 Add a frameline for each layer
Thinker K.F. Li <thinker@codemud.net>
parents: 959
diff changeset
986 pass
8fd97e0becb3 Add a frameline for each layer
Thinker K.F. Li <thinker@codemud.net>
parents: 959
diff changeset
987
1205
1af64bcdfd7d Move to MBScene._make_layers_integral()
Thinker K.F. Li <thinker@codemud.net>
parents: 1204
diff changeset
988 def _add_frameline_for_layers(self):
1af64bcdfd7d Move to MBScene._make_layers_integral()
Thinker K.F. Li <thinker@codemud.net>
parents: 1204
diff changeset
989 for layer_idx in range(len(self._layers)):
1af64bcdfd7d Move to MBScene._make_layers_integral()
Thinker K.F. Li <thinker@codemud.net>
parents: 1204
diff changeset
990 self._add_frameline(layer_idx)
962
6612fd386ea9 Rename Layer.scene to Layer.scenes since it is a list of scenes
Thinker K.F. Li <thinker@codemud.net>
parents: 961
diff changeset
991 pass
959
67823f7a0a17 Use frameline module in MBScene
Thinker K.F. Li <thinker@codemud.net>
parents: 957
diff changeset
992 pass
1205
1af64bcdfd7d Move to MBScene._make_layers_integral()
Thinker K.F. Li <thinker@codemud.net>
parents: 1204
diff changeset
993
956
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
994 def cellSelect(self, cell, data):
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
995 if self.last_cell:
957
8e3e46c26137 Break long lines
Thinker K.F. Li <thinker@codemud.net>
parents: 956
diff changeset
996 color = self.last_cell.get_colormap().alloc_color("gray")
8e3e46c26137 Break long lines
Thinker K.F. Li <thinker@codemud.net>
parents: 956
diff changeset
997 self.last_cell.modify_bg(gtk.STATE_NORMAL, color)
956
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
998 pass
955
53b0f8dc2284 Add tailing 'pass' commands to close indents
Thinker K.F. Li <thinker@codemud.net>
parents: 943
diff changeset
999
956
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
1000 self.last_cell = cell
957
8e3e46c26137 Break long lines
Thinker K.F. Li <thinker@codemud.net>
parents: 956
diff changeset
1001 color = cell.get_colormap().alloc_color("green")
8e3e46c26137 Break long lines
Thinker K.F. Li <thinker@codemud.net>
parents: 956
diff changeset
1002 cell.modify_bg(gtk.STATE_NORMAL, color)
956
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
1003 pass
1144
257beac7c982 Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents: 1142
diff changeset
1004
1097
52d8bf5d12b4 Implement the function to duplicate the previous scene. This require the latest inkscape-pybind, which contains duplicate() for the Node
wycc
parents: 1070
diff changeset
1005 def duplicateKeyScene(self):
52d8bf5d12b4 Implement the function to duplicate the previous scene. This require the latest inkscape-pybind, which contains duplicate() for the Node
wycc
parents: 1070
diff changeset
1006 # Search for the current scene
1195
cb2c611d1656 Fix bug of duplicating a keyframe
Thinker K.F. Li <thinker@codemud.net>
parents: 1194
diff changeset
1007 frameline = self.last_line
cb2c611d1656 Fix bug of duplicating a keyframe
Thinker K.F. Li <thinker@codemud.net>
parents: 1194
diff changeset
1008 frame_idx = self.last_frame
cb2c611d1656 Fix bug of duplicating a keyframe
Thinker K.F. Li <thinker@codemud.net>
parents: 1194
diff changeset
1009
cb2c611d1656 Fix bug of duplicating a keyframe
Thinker K.F. Li <thinker@codemud.net>
parents: 1194
diff changeset
1010 try:
cb2c611d1656 Fix bug of duplicating a keyframe
Thinker K.F. Li <thinker@codemud.net>
parents: 1194
diff changeset
1011 start, end, scene_type = frameline.get_frame_block_floor(frame_idx)
cb2c611d1656 Fix bug of duplicating a keyframe
Thinker K.F. Li <thinker@codemud.net>
parents: 1194
diff changeset
1012 except:
cb2c611d1656 Fix bug of duplicating a keyframe
Thinker K.F. Li <thinker@codemud.net>
parents: 1194
diff changeset
1013 return
cb2c611d1656 Fix bug of duplicating a keyframe
Thinker K.F. Li <thinker@codemud.net>
parents: 1194
diff changeset
1014 if end >= frame_idx:
cb2c611d1656 Fix bug of duplicating a keyframe
Thinker K.F. Li <thinker@codemud.net>
parents: 1194
diff changeset
1015 return
cb2c611d1656 Fix bug of duplicating a keyframe
Thinker K.F. Li <thinker@codemud.net>
parents: 1194
diff changeset
1016
cb2c611d1656 Fix bug of duplicating a keyframe
Thinker K.F. Li <thinker@codemud.net>
parents: 1194
diff changeset
1017 prev_scene_node = frameline.get_frame_data(start)
cb2c611d1656 Fix bug of duplicating a keyframe
Thinker K.F. Li <thinker@codemud.net>
parents: 1194
diff changeset
1018 prev_scene_group_id = prev_scene_node.getAttribute('ref')
cb2c611d1656 Fix bug of duplicating a keyframe
Thinker K.F. Li <thinker@codemud.net>
parents: 1194
diff changeset
1019
cb2c611d1656 Fix bug of duplicating a keyframe
Thinker K.F. Li <thinker@codemud.net>
parents: 1194
diff changeset
1020 scene_group = self.duplicateSceneGroup(prev_scene_group_id)
cb2c611d1656 Fix bug of duplicating a keyframe
Thinker K.F. Li <thinker@codemud.net>
parents: 1194
diff changeset
1021 scene_group_id = scene_group.getAttribute('id')
cb2c611d1656 Fix bug of duplicating a keyframe
Thinker K.F. Li <thinker@codemud.net>
parents: 1194
diff changeset
1022 scene_node = self._add_scene_node(frame_idx, frame_idx,
cb2c611d1656 Fix bug of duplicating a keyframe
Thinker K.F. Li <thinker@codemud.net>
parents: 1194
diff changeset
1023 ref=scene_group_id)
cb2c611d1656 Fix bug of duplicating a keyframe
Thinker K.F. Li <thinker@codemud.net>
parents: 1194
diff changeset
1024
cb2c611d1656 Fix bug of duplicating a keyframe
Thinker K.F. Li <thinker@codemud.net>
parents: 1194
diff changeset
1025 frameline.add_keyframe(frame_idx, scene_node)
cb2c611d1656 Fix bug of duplicating a keyframe
Thinker K.F. Li <thinker@codemud.net>
parents: 1194
diff changeset
1026
cb2c611d1656 Fix bug of duplicating a keyframe
Thinker K.F. Li <thinker@codemud.net>
parents: 1194
diff changeset
1027 self.setCurrentScene(frame_idx)
1144
257beac7c982 Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents: 1142
diff changeset
1028 pass
257beac7c982 Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents: 1142
diff changeset
1029
1097
52d8bf5d12b4 Implement the function to duplicate the previous scene. This require the latest inkscape-pybind, which contains duplicate() for the Node
wycc
parents: 1070
diff changeset
1030 def duplicateSceneGroup(self,gid):
52d8bf5d12b4 Implement the function to duplicate the previous scene. This require the latest inkscape-pybind, which contains duplicate() for the Node
wycc
parents: 1070
diff changeset
1031 # Search for the duplicated group
1149
0ffef2df6201 Rename MBScene.dom to MBScene.root
Thinker K.F. Li <thinker@codemud.net>
parents: 1148
diff changeset
1032 doc = self.root
1128
b65ac686a7c5 Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents: 1125
diff changeset
1033 rdoc = self.document
1097
52d8bf5d12b4 Implement the function to duplicate the previous scene. This require the latest inkscape-pybind, which contains duplicate() for the Node
wycc
parents: 1070
diff changeset
1034 orig = None
52d8bf5d12b4 Implement the function to duplicate the previous scene. This require the latest inkscape-pybind, which contains duplicate() for the Node
wycc
parents: 1070
diff changeset
1035 for node in doc.childList():
1128
b65ac686a7c5 Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents: 1125
diff changeset
1036 if node.name() == 'svg:g':
1097
52d8bf5d12b4 Implement the function to duplicate the previous scene. This require the latest inkscape-pybind, which contains duplicate() for the Node
wycc
parents: 1070
diff changeset
1037 for t in node.childList():
1128
b65ac686a7c5 Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents: 1125
diff changeset
1038 if t.name() == "svg:g":
1139
a2b068594412 Use pybind with new DOM API (at PYNode).
Thinker K.F. Li <thinker@codemud.net>
parents: 1136
diff changeset
1039 if t.getAttribute("id") == gid:
1128
b65ac686a7c5 Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents: 1125
diff changeset
1040 orig = t
1097
52d8bf5d12b4 Implement the function to duplicate the previous scene. This require the latest inkscape-pybind, which contains duplicate() for the Node
wycc
parents: 1070
diff changeset
1041 break
1144
257beac7c982 Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents: 1142
diff changeset
1042 pass
257beac7c982 Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents: 1142
diff changeset
1043 pass
257beac7c982 Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents: 1142
diff changeset
1044 pass
257beac7c982 Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents: 1142
diff changeset
1045 pass
1097
52d8bf5d12b4 Implement the function to duplicate the previous scene. This require the latest inkscape-pybind, which contains duplicate() for the Node
wycc
parents: 1070
diff changeset
1046 if orig == None:
52d8bf5d12b4 Implement the function to duplicate the previous scene. This require the latest inkscape-pybind, which contains duplicate() for the Node
wycc
parents: 1070
diff changeset
1047 return None
1190
a4df892fb4e5 Use meaningful name for scene, scene group, and layer group
Thinker K.F. Li <thinker@codemud.net>
parents: 1189
diff changeset
1048 scene_group = orig.duplicate(rdoc)
1151
71c72e8d6755 Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents: 1150
diff changeset
1049
71c72e8d6755 Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents: 1150
diff changeset
1050 old_nodes = _travel_DOM(orig)
1190
a4df892fb4e5 Use meaningful name for scene, scene group, and layer group
Thinker K.F. Li <thinker@codemud.net>
parents: 1189
diff changeset
1051 new_nodes = _travel_DOM(scene_group)
1151
71c72e8d6755 Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents: 1150
diff changeset
1052 for old_node in old_nodes:
1164
2cb5047d8f2b Add support to insert key frame in the middle of the tween.
wycc
parents: 1163
diff changeset
1053 print old_node
1151
71c72e8d6755 Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents: 1150
diff changeset
1054 old_node_id = old_node.getAttribute('id')
71c72e8d6755 Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents: 1150
diff changeset
1055 new_node = new_nodes.next()
71c72e8d6755 Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents: 1150
diff changeset
1056 new_node.setAttribute('ns0:duplicate-src', old_node_id)
71c72e8d6755 Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents: 1150
diff changeset
1057 pass
71c72e8d6755 Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents: 1150
diff changeset
1058
1205
1af64bcdfd7d Move to MBScene._make_layers_integral()
Thinker K.F. Li <thinker@codemud.net>
parents: 1204
diff changeset
1059 layer = self._layers[self.last_line.layer_idx]
1204
78925515836f Add methods for managing framelines
Thinker K.F. Li <thinker@codemud.net>
parents: 1203
diff changeset
1060 gid = layer.group.getAttribute("inkscape:label")+self.new_id()
1190
a4df892fb4e5 Use meaningful name for scene, scene group, and layer group
Thinker K.F. Li <thinker@codemud.net>
parents: 1189
diff changeset
1061 scene_group.setAttribute("id",gid)
a4df892fb4e5 Use meaningful name for scene, scene group, and layer group
Thinker K.F. Li <thinker@codemud.net>
parents: 1189
diff changeset
1062 scene_group.setAttribute("inkscape:groupmode","layer")
1204
78925515836f Add methods for managing framelines
Thinker K.F. Li <thinker@codemud.net>
parents: 1203
diff changeset
1063 layer.group.appendChild(scene_group)
1193
0e3a65b7b00c Simplify extendScened()
Thinker K.F. Li <thinker@codemud.net>
parents: 1192
diff changeset
1064 return scene_group
956
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
1065
1178
416e41952b76 Fix issue that pyink does not switch current layer to the new key scene.
Thinker K.F. Li <thinker@codemud.net>
parents: 1177
diff changeset
1066 def doEditScene(self, w):
1194
319414e4d87a Fix the issue that is fault to switch scenes
Thinker K.F. Li <thinker@codemud.net>
parents: 1193
diff changeset
1067 self.setCurrentScene(self.last_frame)
1179
b65df4f0d30a Change signature of MBScene.insertKeyScene()
Thinker K.F. Li <thinker@codemud.net>
parents: 1178
diff changeset
1068 self.selectSceneObject(self.last_line, self.last_frame)
956
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
1069 pass
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
1070
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
1071 def doInsertKeyScene(self,w):
1189
9cf183faf89f Maintaining scene group ID to scene node mapping in MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1188
diff changeset
1072 self._lockui=True
1179
b65df4f0d30a Change signature of MBScene.insertKeyScene()
Thinker K.F. Li <thinker@codemud.net>
parents: 1178
diff changeset
1073 self.insertKeyScene(self.last_line, self.last_frame)
1178
416e41952b76 Fix issue that pyink does not switch current layer to the new key scene.
Thinker K.F. Li <thinker@codemud.net>
parents: 1177
diff changeset
1074 self.selectSceneObject(self.last_line, self.last_frame)
1189
9cf183faf89f Maintaining scene group ID to scene node mapping in MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1188
diff changeset
1075 self._lockui=False
956
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
1076 # self.grid.show_all()
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
1077 return
1144
257beac7c982 Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents: 1142
diff changeset
1078
1097
52d8bf5d12b4 Implement the function to duplicate the previous scene. This require the latest inkscape-pybind, which contains duplicate() for the Node
wycc
parents: 1070
diff changeset
1079 def doDuplicateKeyScene(self,w):
1189
9cf183faf89f Maintaining scene group ID to scene node mapping in MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1188
diff changeset
1080 self._lockui = True
1097
52d8bf5d12b4 Implement the function to duplicate the previous scene. This require the latest inkscape-pybind, which contains duplicate() for the Node
wycc
parents: 1070
diff changeset
1081 self.duplicateKeyScene()
1189
9cf183faf89f Maintaining scene group ID to scene node mapping in MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1188
diff changeset
1082 self._lockui = False
956
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
1083
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
1084 def doRemoveScene(self,w):
1189
9cf183faf89f Maintaining scene group ID to scene node mapping in MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1188
diff changeset
1085 self._lockui = True
1200
213f03dbfc41 Fix issue of removing a scene
Thinker K.F. Li <thinker@codemud.net>
parents: 1199
diff changeset
1086 self.removeKeyScene(self.last_line, self.last_frame)
1189
9cf183faf89f Maintaining scene group ID to scene node mapping in MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1188
diff changeset
1087 self._lockui = False
956
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
1088 return
941
9ba94c577a6f Add scene editor. This vewrsion can only switch scene. It can not change the scene yet.
wycc
parents:
diff changeset
1089
956
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
1090
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
1091 def doExtendScene(self,w):
1189
9cf183faf89f Maintaining scene group ID to scene node mapping in MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1188
diff changeset
1092 self._lockui = True
956
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
1093 self.extendScene()
1189
9cf183faf89f Maintaining scene group ID to scene node mapping in MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1188
diff changeset
1094 self._lockui = False
956
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
1095 pass
1146
e14ec6d1a661 CHange the implementation to set the transformation matrix only. This is be more friendly for the animation inside the inskcape.
wycc
parents: 1141
diff changeset
1096
1099
5ba2cab1d505 Add name editor to edit the inkscape:label withgout using the object property editor. This is more Flash-like operation.
wycc
parents: 1097
diff changeset
1097 def changeObjectLabel(self,w):
5ba2cab1d505 Add name editor to edit the inkscape:label withgout using the object property editor. This is more Flash-like operation.
wycc
parents: 1097
diff changeset
1098 o = self.desktop.selection.list()[0]
1128
b65ac686a7c5 Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents: 1125
diff changeset
1099 o.setAttribute("inkscape:label", self.nameEditor.get_text())
1144
257beac7c982 Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents: 1142
diff changeset
1100 pass
257beac7c982 Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents: 1142
diff changeset
1101
1099
5ba2cab1d505 Add name editor to edit the inkscape:label withgout using the object property editor. This is more Flash-like operation.
wycc
parents: 1097
diff changeset
1102 def addNameEditor(self,hbox):
5ba2cab1d505 Add name editor to edit the inkscape:label withgout using the object property editor. This is more Flash-like operation.
wycc
parents: 1097
diff changeset
1103 self.nameEditor = gtk.Entry(max=40)
5ba2cab1d505 Add name editor to edit the inkscape:label withgout using the object property editor. This is more Flash-like operation.
wycc
parents: 1097
diff changeset
1104 hbox.pack_start(self.nameEditor,expand=False,fill=False)
5ba2cab1d505 Add name editor to edit the inkscape:label withgout using the object property editor. This is more Flash-like operation.
wycc
parents: 1097
diff changeset
1105 self.editDone = gtk.Button('Set')
5ba2cab1d505 Add name editor to edit the inkscape:label withgout using the object property editor. This is more Flash-like operation.
wycc
parents: 1097
diff changeset
1106 hbox.pack_start(self.editDone,expand=False,fill=False)
5ba2cab1d505 Add name editor to edit the inkscape:label withgout using the object property editor. This is more Flash-like operation.
wycc
parents: 1097
diff changeset
1107 self.editDone.connect('clicked', self.changeObjectLabel)
1144
257beac7c982 Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents: 1142
diff changeset
1108 pass
257beac7c982 Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents: 1142
diff changeset
1109
1147
5cfa73d7e80f Add the Run button to simulate the animation
wycc
parents: 1146
diff changeset
1110 def doRun(self,arg):
1146
e14ec6d1a661 CHange the implementation to set the transformation matrix only. This is be more friendly for the animation inside the inskcape.
wycc
parents: 1141
diff changeset
1111 """
e14ec6d1a661 CHange the implementation to set the transformation matrix only. This is be more friendly for the animation inside the inskcape.
wycc
parents: 1141
diff changeset
1112 Execute the current animation till the last frame.
e14ec6d1a661 CHange the implementation to set the transformation matrix only. This is be more friendly for the animation inside the inskcape.
wycc
parents: 1141
diff changeset
1113 """
1147
5cfa73d7e80f Add the Run button to simulate the animation
wycc
parents: 1146
diff changeset
1114 if self.btnRun.get_label() == "Run":
5cfa73d7e80f Add the Run button to simulate the animation
wycc
parents: 1146
diff changeset
1115 self.btnRun.set_label("Stop")
1189
9cf183faf89f Maintaining scene group ID to scene node mapping in MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1188
diff changeset
1116 self._lockui = True
1206
1d476b35dc79 Merge and move code of tracking max frame number to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1205 1186
diff changeset
1117 tmout = 1000 / self.framerate
1d476b35dc79 Merge and move code of tracking max frame number to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1205 1186
diff changeset
1118 self.last_update = glib.timeout_add(tmout, self.doRunNext)
1147
5cfa73d7e80f Add the Run button to simulate the animation
wycc
parents: 1146
diff changeset
1119 else:
5cfa73d7e80f Add the Run button to simulate the animation
wycc
parents: 1146
diff changeset
1120 self.btnRun.set_label("Run")
5cfa73d7e80f Add the Run button to simulate the animation
wycc
parents: 1146
diff changeset
1121 glib.source_remove(self.last_update)
1189
9cf183faf89f Maintaining scene group ID to scene node mapping in MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1188
diff changeset
1122 self._lockui = False
1161
a7faab54e8f8 Fix broken of running animation
Thinker K.F. Li <thinker@codemud.net>
parents: 1160
diff changeset
1123 pass
1206
1d476b35dc79 Merge and move code of tracking max frame number to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1205 1186
diff changeset
1124 pass
1147
5cfa73d7e80f Add the Run button to simulate the animation
wycc
parents: 1146
diff changeset
1125
5cfa73d7e80f Add the Run button to simulate the animation
wycc
parents: 1146
diff changeset
1126 def doRunNext(self):
1206
1d476b35dc79 Merge and move code of tracking max frame number to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1205 1186
diff changeset
1127 if self.current > self._maxframe:
1147
5cfa73d7e80f Add the Run button to simulate the animation
wycc
parents: 1146
diff changeset
1128 self.current = 0
1206
1d476b35dc79 Merge and move code of tracking max frame number to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1205 1186
diff changeset
1129 pass
1161
a7faab54e8f8 Fix broken of running animation
Thinker K.F. Li <thinker@codemud.net>
parents: 1160
diff changeset
1130 try:
1194
319414e4d87a Fix the issue that is fault to switch scenes
Thinker K.F. Li <thinker@codemud.net>
parents: 1193
diff changeset
1131 self.setCurrentScene(self.current)
1161
a7faab54e8f8 Fix broken of running animation
Thinker K.F. Li <thinker@codemud.net>
parents: 1160
diff changeset
1132 except:
a7faab54e8f8 Fix broken of running animation
Thinker K.F. Li <thinker@codemud.net>
parents: 1160
diff changeset
1133 traceback.print_exc()
a7faab54e8f8 Fix broken of running animation
Thinker K.F. Li <thinker@codemud.net>
parents: 1160
diff changeset
1134 raise
1199
25e1579ed3d1 Fix bug of running animation
Thinker K.F. Li <thinker@codemud.net>
parents: 1198
diff changeset
1135 self.current = self.current + 1
1206
1d476b35dc79 Merge and move code of tracking max frame number to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1205 1186
diff changeset
1136 tmout = 1000 / self.framerate
1d476b35dc79 Merge and move code of tracking max frame number to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1205 1186
diff changeset
1137 self.last_update = glib.timeout_add(tmout, self.doRunNext)
1d476b35dc79 Merge and move code of tracking max frame number to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1205 1186
diff changeset
1138 pass
1174
96a7abce774a Add functions to insert and remove frame.
wycc
parents: 1171
diff changeset
1139
956
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
1140 def addButtons(self,hbox):
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
1141 btn = gtk.Button('Insert Key')
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
1142 btn.connect('clicked',self.doInsertKeyScene)
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
1143 hbox.pack_start(btn,expand=False,fill=False)
1174
96a7abce774a Add functions to insert and remove frame.
wycc
parents: 1171
diff changeset
1144
956
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
1145 btn=gtk.Button('Remove Key')
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
1146 btn.connect('clicked', self.doRemoveScene)
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
1147 hbox.pack_start(btn,expand=False,fill=False)
1174
96a7abce774a Add functions to insert and remove frame.
wycc
parents: 1171
diff changeset
1148
956
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
1149 btn=gtk.Button('Extend scene')
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
1150 btn.connect('clicked', self.doExtendScene)
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
1151 hbox.pack_start(btn,expand=False,fill=False)
1174
96a7abce774a Add functions to insert and remove frame.
wycc
parents: 1171
diff changeset
1152
96a7abce774a Add functions to insert and remove frame.
wycc
parents: 1171
diff changeset
1153 btn=gtk.Button('Duplicate Key')
96a7abce774a Add functions to insert and remove frame.
wycc
parents: 1171
diff changeset
1154 btn.connect('clicked', self.doDuplicateKeyScene)
96a7abce774a Add functions to insert and remove frame.
wycc
parents: 1171
diff changeset
1155 hbox.pack_start(btn,expand=False,fill=False)
96a7abce774a Add functions to insert and remove frame.
wycc
parents: 1171
diff changeset
1156
1146
e14ec6d1a661 CHange the implementation to set the transformation matrix only. This is be more friendly for the animation inside the inskcape.
wycc
parents: 1141
diff changeset
1157 btn=gtk.Button('Run')
e14ec6d1a661 CHange the implementation to set the transformation matrix only. This is be more friendly for the animation inside the inskcape.
wycc
parents: 1141
diff changeset
1158 btn.connect('clicked', self.doRun)
1147
5cfa73d7e80f Add the Run button to simulate the animation
wycc
parents: 1146
diff changeset
1159 self.btnRun = btn
1146
e14ec6d1a661 CHange the implementation to set the transformation matrix only. This is be more friendly for the animation inside the inskcape.
wycc
parents: 1141
diff changeset
1160 hbox.pack_start(btn,expand=False,fill=False)
1174
96a7abce774a Add functions to insert and remove frame.
wycc
parents: 1171
diff changeset
1161
1099
5ba2cab1d505 Add name editor to edit the inkscape:label withgout using the object property editor. This is more Flash-like operation.
wycc
parents: 1097
diff changeset
1162 self.addNameEditor(hbox)
1120
214e1f628d63 Add tween type selector into the UI. This UI can be used to update the type attribute of the SVG.
wycc
parents: 1099
diff changeset
1163 self.addTweenTypeSelector(hbox)
956
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
1164 pass
1144
257beac7c982 Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents: 1142
diff changeset
1165
1150
6586cd10c92f Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents: 1149
diff changeset
1166 def onTweenTypeChange(self, w):
6586cd10c92f Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents: 1149
diff changeset
1167 if self._disable_tween_type_selector:
6586cd10c92f Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents: 1149
diff changeset
1168 return
6586cd10c92f Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents: 1149
diff changeset
1169
1120
214e1f628d63 Add tween type selector into the UI. This UI can be used to update the type attribute of the SVG.
wycc
parents: 1099
diff changeset
1170 if self.last_line == None:
214e1f628d63 Add tween type selector into the UI. This UI can be used to update the type attribute of the SVG.
wycc
parents: 1099
diff changeset
1171 return
214e1f628d63 Add tween type selector into the UI. This UI can be used to update the type attribute of the SVG.
wycc
parents: 1099
diff changeset
1172 frameline = self.last_line
1197
8c5492b096f1 Fix bug of changing tween type
Thinker K.F. Li <thinker@codemud.net>
parents: 1196
diff changeset
1173 start, end, old_tween_type = frameline.get_frame_block(self.last_frame)
8c5492b096f1 Fix bug of changing tween type
Thinker K.F. Li <thinker@codemud.net>
parents: 1196
diff changeset
1174
8c5492b096f1 Fix bug of changing tween type
Thinker K.F. Li <thinker@codemud.net>
parents: 1196
diff changeset
1175 type_idx = self.tweenTypeSelector.get_active()
8c5492b096f1 Fix bug of changing tween type
Thinker K.F. Li <thinker@codemud.net>
parents: 1196
diff changeset
1176 tween_type = MBScene._frameline_tween_types[type_idx]
8c5492b096f1 Fix bug of changing tween type
Thinker K.F. Li <thinker@codemud.net>
parents: 1196
diff changeset
1177 type_name = self._tween_type_names[type_idx]
8c5492b096f1 Fix bug of changing tween type
Thinker K.F. Li <thinker@codemud.net>
parents: 1196
diff changeset
1178
8c5492b096f1 Fix bug of changing tween type
Thinker K.F. Li <thinker@codemud.net>
parents: 1196
diff changeset
1179 frameline.tween(start, tween_type)
8c5492b096f1 Fix bug of changing tween type
Thinker K.F. Li <thinker@codemud.net>
parents: 1196
diff changeset
1180
8c5492b096f1 Fix bug of changing tween type
Thinker K.F. Li <thinker@codemud.net>
parents: 1196
diff changeset
1181 scene_node = frameline.get_frame_data(start)
1199
25e1579ed3d1 Fix bug of running animation
Thinker K.F. Li <thinker@codemud.net>
parents: 1198
diff changeset
1182 self._chg_scene_node(scene_node, tween_type=type_name)
1144
257beac7c982 Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents: 1142
diff changeset
1183 pass
1120
214e1f628d63 Add tween type selector into the UI. This UI can be used to update the type attribute of the SVG.
wycc
parents: 1099
diff changeset
1184
214e1f628d63 Add tween type selector into the UI. This UI can be used to update the type attribute of the SVG.
wycc
parents: 1099
diff changeset
1185 def addTweenTypeSelector(self,hbox):
214e1f628d63 Add tween type selector into the UI. This UI can be used to update the type attribute of the SVG.
wycc
parents: 1099
diff changeset
1186 tweenbox = gtk.HBox()
214e1f628d63 Add tween type selector into the UI. This UI can be used to update the type attribute of the SVG.
wycc
parents: 1099
diff changeset
1187 label = gtk.Label('Tween Type')
214e1f628d63 Add tween type selector into the UI. This UI can be used to update the type attribute of the SVG.
wycc
parents: 1099
diff changeset
1188 tweenbox.pack_start(label)
214e1f628d63 Add tween type selector into the UI. This UI can be used to update the type attribute of the SVG.
wycc
parents: 1099
diff changeset
1189
214e1f628d63 Add tween type selector into the UI. This UI can be used to update the type attribute of the SVG.
wycc
parents: 1099
diff changeset
1190 self.tweenTypeSelector = gtk.combo_box_new_text()
214e1f628d63 Add tween type selector into the UI. This UI can be used to update the type attribute of the SVG.
wycc
parents: 1099
diff changeset
1191 self.tweenTypeSelector.append_text('normal')
1157
3a891dccabd8 Remove the locate tween. It is a special case for the scale tween
wycc
parents: 1155
diff changeset
1192 #self.tweenTypeSelector.append_text('relocate')
1120
214e1f628d63 Add tween type selector into the UI. This UI can be used to update the type attribute of the SVG.
wycc
parents: 1099
diff changeset
1193 self.tweenTypeSelector.append_text('scale')
214e1f628d63 Add tween type selector into the UI. This UI can be used to update the type attribute of the SVG.
wycc
parents: 1099
diff changeset
1194 self.tweenTypeSelector.set_active(0)
214e1f628d63 Add tween type selector into the UI. This UI can be used to update the type attribute of the SVG.
wycc
parents: 1099
diff changeset
1195 tweenbox.pack_start(self.tweenTypeSelector, expand=False,fill=False)
214e1f628d63 Add tween type selector into the UI. This UI can be used to update the type attribute of the SVG.
wycc
parents: 1099
diff changeset
1196 hbox.pack_start(tweenbox,expand=False,fill=False)
214e1f628d63 Add tween type selector into the UI. This UI can be used to update the type attribute of the SVG.
wycc
parents: 1099
diff changeset
1197 self.tweenTypeSelector.connect('changed', self.onTweenTypeChange)
1144
257beac7c982 Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents: 1142
diff changeset
1198 pass
956
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
1199
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
1200 def onQuit(self, event):
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
1201 self.OK = False
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
1202 gtk.main_quit()
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
1203 pass
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
1204
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
1205 def onOK(self,event):
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
1206 self.OK = True
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
1207 gtk.main_quit()
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
1208 pass
941
9ba94c577a6f Add scene editor. This vewrsion can only switch scene. It can not change the scene yet.
wycc
parents:
diff changeset
1209
1191
6442fb198418 Refactory insertKeyScene() and fix bug of ObjectWatcher
Thinker K.F. Li <thinker@codemud.net>
parents: 1190
diff changeset
1210 def updateUI(self, node=None, child=None, arg=None):
1189
9cf183faf89f Maintaining scene group ID to scene node mapping in MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1188
diff changeset
1211 if self._lockui: return
1166
d73ef03c96de Refactory code of MBScene.updateUI() from MBScene.show()
Thinker K.F. Li <thinker@codemud.net>
parents: 1164
diff changeset
1212
d73ef03c96de Refactory code of MBScene.updateUI() from MBScene.show()
Thinker K.F. Li <thinker@codemud.net>
parents: 1164
diff changeset
1213 if self.last_update!= None:
d73ef03c96de Refactory code of MBScene.updateUI() from MBScene.show()
Thinker K.F. Li <thinker@codemud.net>
parents: 1164
diff changeset
1214 glib.source_remove(self.last_update)
d73ef03c96de Refactory code of MBScene.updateUI() from MBScene.show()
Thinker K.F. Li <thinker@codemud.net>
parents: 1164
diff changeset
1215 self.last_update = glib.timeout_add(300,self._updateUI)
d73ef03c96de Refactory code of MBScene.updateUI() from MBScene.show()
Thinker K.F. Li <thinker@codemud.net>
parents: 1164
diff changeset
1216
1144
257beac7c982 Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents: 1142
diff changeset
1217 pass
257beac7c982 Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents: 1142
diff changeset
1218
1130
37a0f6ab2f91 Lock the UI from refreshing during the update procedure
wycc
parents: 1128
diff changeset
1219 def _updateUI(self,node=None,arg=None):
1189
9cf183faf89f Maintaining scene group ID to scene node mapping in MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1188
diff changeset
1220 self._lockui = True
1205
1af64bcdfd7d Move to MBScene._make_layers_integral()
Thinker K.F. Li <thinker@codemud.net>
parents: 1204
diff changeset
1221 self._make_layers_integral()
1189
9cf183faf89f Maintaining scene group ID to scene node mapping in MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1188
diff changeset
1222 self._lockui = False
1144
257beac7c982 Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents: 1142
diff changeset
1223 pass
257beac7c982 Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents: 1142
diff changeset
1224
956
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
1225 def show(self):
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
1226 self.OK = True
1149
0ffef2df6201 Rename MBScene.dom to MBScene.root
Thinker K.F. Li <thinker@codemud.net>
parents: 1148
diff changeset
1227 if not self.root:
0ffef2df6201 Rename MBScene.dom to MBScene.root
Thinker K.F. Li <thinker@codemud.net>
parents: 1148
diff changeset
1228 self.root = self.desktop.doc().root().repr
0ffef2df6201 Rename MBScene.dom to MBScene.root
Thinker K.F. Li <thinker@codemud.net>
parents: 1148
diff changeset
1229 pass
0ffef2df6201 Rename MBScene.dom to MBScene.root
Thinker K.F. Li <thinker@codemud.net>
parents: 1148
diff changeset
1230
1128
b65ac686a7c5 Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents: 1125
diff changeset
1231 self.document = self.desktop.doc().rdoc
1188
45e3a9273af2 Move code about monitoring DOM-tree to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1185
diff changeset
1232 self.handle_doc_root(self.document, self.root)
1149
0ffef2df6201 Rename MBScene.dom to MBScene.root
Thinker K.F. Li <thinker@codemud.net>
parents: 1148
diff changeset
1233 self.tween = TweenObject(self.document, self.root)
1205
1af64bcdfd7d Move to MBScene._make_layers_integral()
Thinker K.F. Li <thinker@codemud.net>
parents: 1204
diff changeset
1234 self._init_framelines()
1af64bcdfd7d Move to MBScene._make_layers_integral()
Thinker K.F. Li <thinker@codemud.net>
parents: 1204
diff changeset
1235 self._add_frameline_for_layers()
1af64bcdfd7d Move to MBScene._make_layers_integral()
Thinker K.F. Li <thinker@codemud.net>
parents: 1204
diff changeset
1236
1064
16c69756ef5d Add NodeObserver to monitor the change of the layer and update it in the scene editor.
wycc
parents: 1032
diff changeset
1237 if self.top == None:
16c69756ef5d Add NodeObserver to monitor the change of the layer and update it in the scene editor.
wycc
parents: 1032
diff changeset
1238 self.top = gtk.VBox(False,0)
1206
1d476b35dc79 Merge and move code of tracking max frame number to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1205 1186
diff changeset
1239 toplevel = self.desktop.getToplevel()
1d476b35dc79 Merge and move code of tracking max frame number to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1205 1186
diff changeset
1240 toplevel.child.child.pack_end(self.top,expand=False)
1064
16c69756ef5d Add NodeObserver to monitor the change of the layer and update it in the scene editor.
wycc
parents: 1032
diff changeset
1241 else:
16c69756ef5d Add NodeObserver to monitor the change of the layer and update it in the scene editor.
wycc
parents: 1032
diff changeset
1242 self.top.remove(self.startWindow)
1150
6586cd10c92f Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents: 1149
diff changeset
1243 pass
6586cd10c92f Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents: 1149
diff changeset
1244
981
9e7865906bfc Add MadButterfly name space
wycc
parents: 980
diff changeset
1245 vbox = gtk.VBox(False,0)
1064
16c69756ef5d Add NodeObserver to monitor the change of the layer and update it in the scene editor.
wycc
parents: 1032
diff changeset
1246 self.startWindow = vbox
16c69756ef5d Add NodeObserver to monitor the change of the layer and update it in the scene editor.
wycc
parents: 1032
diff changeset
1247 self.top.pack_start(vbox,expand=False)
1205
1af64bcdfd7d Move to MBScene._make_layers_integral()
Thinker K.F. Li <thinker@codemud.net>
parents: 1204
diff changeset
1248 vbox.pack_start(self._frameline_box,expand=False)
981
9e7865906bfc Add MadButterfly name space
wycc
parents: 980
diff changeset
1249 hbox=gtk.HBox(False,0)
9e7865906bfc Add MadButterfly name space
wycc
parents: 980
diff changeset
1250 self.addButtons(hbox)
9e7865906bfc Add MadButterfly name space
wycc
parents: 980
diff changeset
1251 vbox.pack_start(hbox,expand=False)
9e7865906bfc Add MadButterfly name space
wycc
parents: 980
diff changeset
1252
1064
16c69756ef5d Add NodeObserver to monitor the change of the layer and update it in the scene editor.
wycc
parents: 1032
diff changeset
1253 self.top.show_all()
16c69756ef5d Add NodeObserver to monitor the change of the layer and update it in the scene editor.
wycc
parents: 1032
diff changeset
1254 self.last_update = None
16c69756ef5d Add NodeObserver to monitor the change of the layer and update it in the scene editor.
wycc
parents: 1032
diff changeset
1255 return False
956
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
1256 pass