annotate pyink/MBScene.py @ 1192:79a3f82edaac

Fix issue of losing keyframe after inerst a node in the scene
author Thinker K.F. Li <thinker@codemud.net>
date Sun, 02 Jan 2011 14:18:48 +0800
parents 6442fb198418
children 0e3a65b7b00c
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
45e3a9273af2 Move code about monitoring DOM-tree to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1185
diff changeset
161 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
162 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
163 pass
45e3a9273af2 Move code about monitoring DOM-tree to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1185
diff changeset
164
45e3a9273af2 Move code about monitoring DOM-tree to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1185
diff changeset
165 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
166 self._collect_node_ids()
45e3a9273af2 Move code about monitoring DOM-tree to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1185
diff changeset
167
45e3a9273af2 Move code about monitoring DOM-tree to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1185
diff changeset
168 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
169 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
170 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
171 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
172 pass
45e3a9273af2 Move code about monitoring DOM-tree to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1185
diff changeset
173
1191
6442fb198418 Refactory insertKeyScene() and fix bug of ObjectWatcher
Thinker K.F. Li <thinker@codemud.net>
parents: 1190
diff changeset
174 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
175 try:
1191
6442fb198418 Refactory insertKeyScene() and fix bug of ObjectWatcher
Thinker K.F. Li <thinker@codemud.net>
parents: 1190
diff changeset
176 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
177 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
178 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
179 else:
1191
6442fb198418 Refactory insertKeyScene() and fix bug of ObjectWatcher
Thinker K.F. Li <thinker@codemud.net>
parents: 1190
diff changeset
180 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
181 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
182 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
183 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
184
1191
6442fb198418 Refactory insertKeyScene() and fix bug of ObjectWatcher
Thinker K.F. Li <thinker@codemud.net>
parents: 1190
diff changeset
185 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
186 try:
1191
6442fb198418 Refactory insertKeyScene() and fix bug of ObjectWatcher
Thinker K.F. Li <thinker@codemud.net>
parents: 1190
diff changeset
187 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
188 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
189 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
190 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
191 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
192 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
193 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
194 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
195 pass
1188
45e3a9273af2 Move code about monitoring DOM-tree to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1185
diff changeset
196 pass
45e3a9273af2 Move code about monitoring DOM-tree to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1185
diff changeset
197
1191
6442fb198418 Refactory insertKeyScene() and fix bug of ObjectWatcher
Thinker K.F. Li <thinker@codemud.net>
parents: 1190
diff changeset
198 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
199 try:
1191
6442fb198418 Refactory insertKeyScene() and fix bug of ObjectWatcher
Thinker K.F. Li <thinker@codemud.net>
parents: 1190
diff changeset
200 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
201 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
202 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
203 else:
1191
6442fb198418 Refactory insertKeyScene() and fix bug of ObjectWatcher
Thinker K.F. Li <thinker@codemud.net>
parents: 1190
diff changeset
204 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
205 raise ValueError, \
1191
6442fb198418 Refactory insertKeyScene() and fix bug of ObjectWatcher
Thinker K.F. Li <thinker@codemud.net>
parents: 1190
diff changeset
206 '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
207 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
208 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
209
1191
6442fb198418 Refactory insertKeyScene() and fix bug of ObjectWatcher
Thinker K.F. Li <thinker@codemud.net>
parents: 1190
diff changeset
210 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
211 try:
1191
6442fb198418 Refactory insertKeyScene() and fix bug of ObjectWatcher
Thinker K.F. Li <thinker@codemud.net>
parents: 1190
diff changeset
212 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
213 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
214 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
215 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
216 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
217 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
218 pass
1188
45e3a9273af2 Move code about monitoring DOM-tree to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1185
diff changeset
219 pass
45e3a9273af2 Move code about monitoring DOM-tree to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1185
diff changeset
220
45e3a9273af2 Move code about monitoring DOM-tree to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1185
diff changeset
221 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
222 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
223 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
224 raise ValueError, \
9cf183faf89f Maintaining scene group ID to scene node mapping in MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1188
diff changeset
225 'old ID value of passed node is valid one (%s)' % \
9cf183faf89f Maintaining scene group ID to scene node mapping in MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1188
diff changeset
226 (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
227 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
228 raise ValueError, \
9cf183faf89f Maintaining scene group ID to scene node mapping in MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1188
diff changeset
229 'new ID value of passed node is valid one (%s)' % \
9cf183faf89f Maintaining scene group ID to scene node mapping in MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1188
diff changeset
230 (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
231
9cf183faf89f Maintaining scene group ID to scene node mapping in MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1188
diff changeset
232 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
233 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
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 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
236 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
237 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
238 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
239 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
240 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
241 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
242 # 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
243 # 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
244 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
245 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
246 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
247 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
248 pass
1188
45e3a9273af2 Move code about monitoring DOM-tree to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1185
diff changeset
249 return
45e3a9273af2 Move code about monitoring DOM-tree to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1185
diff changeset
250 pass
45e3a9273af2 Move code about monitoring DOM-tree to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1185
diff changeset
251
45e3a9273af2 Move code about monitoring DOM-tree to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1185
diff changeset
252 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
253 self._id2node = {}
45e3a9273af2 Move code about monitoring DOM-tree to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1185
diff changeset
254 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
255 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
256 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
257 pass
e8446e138427 Move update_scenes_of_dom() to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents: 1182
diff changeset
258 pass
e8446e138427 Move update_scenes_of_dom() to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents: 1182
diff changeset
259
1188
45e3a9273af2 Move code about monitoring DOM-tree to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1185
diff changeset
260 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
261 try:
45e3a9273af2 Move code about monitoring DOM-tree to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1185
diff changeset
262 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
263 except:
45e3a9273af2 Move code about monitoring DOM-tree to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1185
diff changeset
264 return
45e3a9273af2 Move code about monitoring DOM-tree to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1185
diff changeset
265
45e3a9273af2 Move code about monitoring DOM-tree to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1185
diff changeset
266 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
267 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
268 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
269 pass
e8446e138427 Move update_scenes_of_dom() to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents: 1182
diff changeset
270 pass
e8446e138427 Move update_scenes_of_dom() to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents: 1182
diff changeset
271
1188
45e3a9273af2 Move code about monitoring DOM-tree to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1185
diff changeset
272 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
273 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
274
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
275 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
276 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
277
1188
45e3a9273af2 Move code about monitoring DOM-tree to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1185
diff changeset
278 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
279 while True:
45e3a9273af2 Move code about monitoring DOM-tree to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1185
diff changeset
280 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
281 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
282 return candidate
45e3a9273af2 Move code about monitoring DOM-tree to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1185
diff changeset
283 pass
45e3a9273af2 Move code about monitoring DOM-tree to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1185
diff changeset
284 pass
45e3a9273af2 Move code about monitoring DOM-tree to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1185
diff changeset
285 pass
45e3a9273af2 Move code about monitoring DOM-tree to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1185
diff changeset
286
45e3a9273af2 Move code about monitoring DOM-tree to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1185
diff changeset
287
45e3a9273af2 Move code about monitoring DOM-tree to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1185
diff changeset
288 ## \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
289 #
45e3a9273af2 Move code about monitoring DOM-tree to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1185
diff changeset
290 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
291 # 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
292 _doc = None
6442fb198418 Refactory insertKeyScene() and fix bug of ObjectWatcher
Thinker K.F. Li <thinker@codemud.net>
parents: 1190
diff changeset
293 _root = None
6442fb198418 Refactory insertKeyScene() and fix bug of ObjectWatcher
Thinker K.F. Li <thinker@codemud.net>
parents: 1190
diff changeset
294 _scenes_group = None
6442fb198418 Refactory insertKeyScene() and fix bug of ObjectWatcher
Thinker K.F. Li <thinker@codemud.net>
parents: 1190
diff changeset
295
1188
45e3a9273af2 Move code about monitoring DOM-tree to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1185
diff changeset
296 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
297 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
298 pass
45e3a9273af2 Move code about monitoring DOM-tree to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1185
diff changeset
299
45e3a9273af2 Move code about monitoring DOM-tree to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1185
diff changeset
300 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
301 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
302 self._root = root
45e3a9273af2 Move code about monitoring DOM-tree to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1185
diff changeset
303
45e3a9273af2 Move code about monitoring DOM-tree to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1185
diff changeset
304 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
305 self._init_metadata()
1188
45e3a9273af2 Move code about monitoring DOM-tree to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1185
diff changeset
306 pass
45e3a9273af2 Move code about monitoring DOM-tree to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1185
diff changeset
307
1176
0c1ceecb8ddb Move parseMetadata to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents: 1174
diff changeset
308 def dumpattr(self, n):
0c1ceecb8ddb Move parseMetadata to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents: 1174
diff changeset
309 s = ""
0c1ceecb8ddb Move parseMetadata to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents: 1174
diff changeset
310 for a,v in n.attrib.items():
0c1ceecb8ddb Move parseMetadata to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents: 1174
diff changeset
311 s = s + ("%s=%s" % (a,v))
0c1ceecb8ddb Move parseMetadata to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents: 1174
diff changeset
312 pass
0c1ceecb8ddb Move parseMetadata to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents: 1174
diff changeset
313 return s
0c1ceecb8ddb Move parseMetadata to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents: 1174
diff changeset
314
0c1ceecb8ddb Move parseMetadata to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents: 1174
diff changeset
315 def dump(self, node, l=0):
0c1ceecb8ddb Move parseMetadata to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents: 1174
diff changeset
316 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
317 for n in node:
0c1ceecb8ddb Move parseMetadata to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents: 1174
diff changeset
318 self.dump(n, l+1)
0c1ceecb8ddb Move parseMetadata to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents: 1174
diff changeset
319 pass
0c1ceecb8ddb Move parseMetadata to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents: 1174
diff changeset
320 print " " * l * 2,"/>"
0c1ceecb8ddb Move parseMetadata to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents: 1174
diff changeset
321 pass
0c1ceecb8ddb Move parseMetadata to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents: 1174
diff changeset
322
1190
a4df892fb4e5 Use meaningful name for scene, scene group, and layer group
Thinker K.F. Li <thinker@codemud.net>
parents: 1189
diff changeset
323 def _parse_one_scene(self, scene_node):
a4df892fb4e5 Use meaningful name for scene, scene group, and layer group
Thinker K.F. Li <thinker@codemud.net>
parents: 1189
diff changeset
324 assert scene_node.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
325
1190
a4df892fb4e5 Use meaningful name for scene, scene group, and layer group
Thinker K.F. Li <thinker@codemud.net>
parents: 1189
diff changeset
326 start = int(scene_node.getAttribute("start"))
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
327 try:
1190
a4df892fb4e5 Use meaningful name for scene, scene group, and layer group
Thinker K.F. Li <thinker@codemud.net>
parents: 1189
diff changeset
328 end = int(scene_node.getAttribute("end"))
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
329 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
330 end = start
9cf183faf89f Maintaining scene group ID to scene node mapping in MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1188
diff changeset
331 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
332
9cf183faf89f Maintaining scene group ID to scene node mapping in MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1188
diff changeset
333 try:
1190
a4df892fb4e5 Use meaningful name for scene, scene group, and layer group
Thinker K.F. Li <thinker@codemud.net>
parents: 1189
diff changeset
334 scene_type = scene_node.getAttribute('type')
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
335 if scene_type == None:
9cf183faf89f Maintaining scene group ID to scene node mapping in MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1188
diff changeset
336 scene_type = 'normal'
9cf183faf89f Maintaining scene group ID to scene node mapping in MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1188
diff changeset
337 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
338 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
339 scene_type = 'normal'
9cf183faf89f Maintaining scene group ID to scene node mapping in MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1188
diff changeset
340 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
341
9cf183faf89f Maintaining scene group ID to scene node mapping in MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1188
diff changeset
342 return start, end, scene_type
9cf183faf89f Maintaining scene group ID to scene node mapping in MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1188
diff changeset
343
1190
a4df892fb4e5 Use meaningful name for scene, scene group, and layer group
Thinker K.F. Li <thinker@codemud.net>
parents: 1189
diff changeset
344 def _parse_one_scenes(self, scenes_node):
1176
0c1ceecb8ddb Move parseMetadata to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents: 1174
diff changeset
345 self.scenemap = {}
0c1ceecb8ddb Move parseMetadata to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents: 1174
diff changeset
346 try:
0c1ceecb8ddb Move parseMetadata to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents: 1174
diff changeset
347 cur = int(n.getAttribute("current"))
0c1ceecb8ddb Move parseMetadata to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents: 1174
diff changeset
348 except:
0c1ceecb8ddb Move parseMetadata to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents: 1174
diff changeset
349 cur = 1
0c1ceecb8ddb Move parseMetadata to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents: 1174
diff changeset
350 pass
0c1ceecb8ddb Move parseMetadata to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents: 1174
diff changeset
351 self.current = cur
0c1ceecb8ddb Move parseMetadata to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents: 1174
diff changeset
352
1190
a4df892fb4e5 Use meaningful name for scene, scene group, and layer group
Thinker K.F. Li <thinker@codemud.net>
parents: 1189
diff changeset
353 for scene_node in scenes_node.childList():
a4df892fb4e5 Use meaningful name for scene, scene group, and layer group
Thinker K.F. Li <thinker@codemud.net>
parents: 1189
diff changeset
354 if scene_node.name() != 'ns0:scene':
1176
0c1ceecb8ddb Move parseMetadata to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents: 1174
diff changeset
355 continue
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
356
1176
0c1ceecb8ddb Move parseMetadata to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents: 1174
diff changeset
357 try:
1190
a4df892fb4e5 Use meaningful name for scene, scene group, and layer group
Thinker K.F. Li <thinker@codemud.net>
parents: 1189
diff changeset
358 start, end, scene_type = self._parse_one_scene(scene_node)
1176
0c1ceecb8ddb Move parseMetadata to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents: 1174
diff changeset
359 except:
0c1ceecb8ddb Move parseMetadata to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents: 1174
diff changeset
360 continue
0c1ceecb8ddb Move parseMetadata to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents: 1174
diff changeset
361
0c1ceecb8ddb Move parseMetadata to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents: 1174
diff changeset
362 if end > self.maxframe:
0c1ceecb8ddb Move parseMetadata to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents: 1174
diff changeset
363 self.maxframe = end
0c1ceecb8ddb Move parseMetadata to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents: 1174
diff changeset
364 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
365
1190
a4df892fb4e5 Use meaningful name for scene, scene group, and layer group
Thinker K.F. Li <thinker@codemud.net>
parents: 1189
diff changeset
366 link = scene_node.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
367 self.scenemap[link] = (start, end, scene_type)
1176
0c1ceecb8ddb Move parseMetadata to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents: 1174
diff changeset
368 if cur >= start and cur <= end:
0c1ceecb8ddb Move parseMetadata to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents: 1174
diff changeset
369 self.currentscene = link
0c1ceecb8ddb Move parseMetadata to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents: 1174
diff changeset
370 pass
0c1ceecb8ddb Move parseMetadata to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents: 1174
diff changeset
371 pass
0c1ceecb8ddb Move parseMetadata to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents: 1174
diff changeset
372 pass
0c1ceecb8ddb Move parseMetadata to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents: 1174
diff changeset
373
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
374 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
375 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
376 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
377 break
9cf183faf89f Maintaining scene group ID to scene node mapping in MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1188
diff changeset
378 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
379 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
380 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
381 'can not find <svg:metadata> node in the document'
9cf183faf89f Maintaining scene group ID to scene node mapping in MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1188
diff changeset
382
1176
0c1ceecb8ddb Move parseMetadata to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents: 1174
diff changeset
383 for n in node.childList():
0c1ceecb8ddb Move parseMetadata to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents: 1174
diff changeset
384 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
385 self._scenes_node = n
1176
0c1ceecb8ddb Move parseMetadata to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents: 1174
diff changeset
386 break
0c1ceecb8ddb Move parseMetadata to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents: 1174
diff changeset
387 pass
0c1ceecb8ddb Move parseMetadata to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents: 1174
diff changeset
388 else:
0c1ceecb8ddb Move parseMetadata to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents: 1174
diff changeset
389 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
390 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
391 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
392 node.appendChild(scenes_node)
1191
6442fb198418 Refactory insertKeyScene() and fix bug of ObjectWatcher
Thinker K.F. Li <thinker@codemud.net>
parents: 1190
diff changeset
393 self._scenes_node = scenes_node
1176
0c1ceecb8ddb Move parseMetadata to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents: 1174
diff changeset
394 pass
0c1ceecb8ddb Move parseMetadata to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents: 1174
diff changeset
395 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
396
1191
6442fb198418 Refactory insertKeyScene() and fix bug of ObjectWatcher
Thinker K.F. Li <thinker@codemud.net>
parents: 1190
diff changeset
397 ## \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
398 #
6442fb198418 Refactory insertKeyScene() and fix bug of ObjectWatcher
Thinker K.F. Li <thinker@codemud.net>
parents: 1190
diff changeset
399 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
400 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
401 ref=None):
6442fb198418 Refactory insertKeyScene() and fix bug of ObjectWatcher
Thinker K.F. Li <thinker@codemud.net>
parents: 1190
diff changeset
402 type_names = ('normal', 'scale')
6442fb198418 Refactory insertKeyScene() and fix bug of ObjectWatcher
Thinker K.F. Li <thinker@codemud.net>
parents: 1190
diff changeset
403 scenes_node = self._scenes_node
6442fb198418 Refactory insertKeyScene() and fix bug of ObjectWatcher
Thinker K.F. Li <thinker@codemud.net>
parents: 1190
diff changeset
404 doc = self._doc
6442fb198418 Refactory insertKeyScene() and fix bug of ObjectWatcher
Thinker K.F. Li <thinker@codemud.net>
parents: 1190
diff changeset
405
6442fb198418 Refactory insertKeyScene() and fix bug of ObjectWatcher
Thinker K.F. Li <thinker@codemud.net>
parents: 1190
diff changeset
406 scene_node = doc.createElement('ns0:scene')
6442fb198418 Refactory insertKeyScene() and fix bug of ObjectWatcher
Thinker K.F. Li <thinker@codemud.net>
parents: 1190
diff changeset
407 scene_node.setAttribute('start', str(start))
6442fb198418 Refactory insertKeyScene() and fix bug of ObjectWatcher
Thinker K.F. Li <thinker@codemud.net>
parents: 1190
diff changeset
408 if start != end:
6442fb198418 Refactory insertKeyScene() and fix bug of ObjectWatcher
Thinker K.F. Li <thinker@codemud.net>
parents: 1190
diff changeset
409 scene_node.setAttribute('end', str(end))
6442fb198418 Refactory insertKeyScene() and fix bug of ObjectWatcher
Thinker K.F. Li <thinker@codemud.net>
parents: 1190
diff changeset
410 pass
6442fb198418 Refactory insertKeyScene() and fix bug of ObjectWatcher
Thinker K.F. Li <thinker@codemud.net>
parents: 1190
diff changeset
411 type_name = type_names[frame_type]
6442fb198418 Refactory insertKeyScene() and fix bug of ObjectWatcher
Thinker K.F. Li <thinker@codemud.net>
parents: 1190
diff changeset
412 scene_node.setAttribute('type', type_name)
6442fb198418 Refactory insertKeyScene() and fix bug of ObjectWatcher
Thinker K.F. Li <thinker@codemud.net>
parents: 1190
diff changeset
413 if ref:
6442fb198418 Refactory insertKeyScene() and fix bug of ObjectWatcher
Thinker K.F. Li <thinker@codemud.net>
parents: 1190
diff changeset
414 scene_node.setAttribute('ref', ref)
6442fb198418 Refactory insertKeyScene() and fix bug of ObjectWatcher
Thinker K.F. Li <thinker@codemud.net>
parents: 1190
diff changeset
415 pass
6442fb198418 Refactory insertKeyScene() and fix bug of ObjectWatcher
Thinker K.F. Li <thinker@codemud.net>
parents: 1190
diff changeset
416
6442fb198418 Refactory insertKeyScene() and fix bug of ObjectWatcher
Thinker K.F. Li <thinker@codemud.net>
parents: 1190
diff changeset
417 scenes_node.appendChild(scene_node)
6442fb198418 Refactory insertKeyScene() and fix bug of ObjectWatcher
Thinker K.F. Li <thinker@codemud.net>
parents: 1190
diff changeset
418
6442fb198418 Refactory insertKeyScene() and fix bug of ObjectWatcher
Thinker K.F. Li <thinker@codemud.net>
parents: 1190
diff changeset
419 return scene_node
6442fb198418 Refactory insertKeyScene() and fix bug of ObjectWatcher
Thinker K.F. Li <thinker@codemud.net>
parents: 1190
diff changeset
420
6442fb198418 Refactory insertKeyScene() and fix bug of ObjectWatcher
Thinker K.F. Li <thinker@codemud.net>
parents: 1190
diff changeset
421 ## \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
422 #
6442fb198418 Refactory insertKeyScene() and fix bug of ObjectWatcher
Thinker K.F. Li <thinker@codemud.net>
parents: 1190
diff changeset
423 def _add_scene_group(self, layer_idx):
6442fb198418 Refactory insertKeyScene() and fix bug of ObjectWatcher
Thinker K.F. Li <thinker@codemud.net>
parents: 1190
diff changeset
424 layer = self.layers[layer_idx]
6442fb198418 Refactory insertKeyScene() and fix bug of ObjectWatcher
Thinker K.F. Li <thinker@codemud.net>
parents: 1190
diff changeset
425 doc = self._doc
6442fb198418 Refactory insertKeyScene() and fix bug of ObjectWatcher
Thinker K.F. Li <thinker@codemud.net>
parents: 1190
diff changeset
426
6442fb198418 Refactory insertKeyScene() and fix bug of ObjectWatcher
Thinker K.F. Li <thinker@codemud.net>
parents: 1190
diff changeset
427 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
428 gid = self.new_id()
6442fb198418 Refactory insertKeyScene() and fix bug of ObjectWatcher
Thinker K.F. Li <thinker@codemud.net>
parents: 1190
diff changeset
429 scene_group.setAttribute("id", gid)
6442fb198418 Refactory insertKeyScene() and fix bug of ObjectWatcher
Thinker K.F. Li <thinker@codemud.net>
parents: 1190
diff changeset
430 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
431
6442fb198418 Refactory insertKeyScene() and fix bug of ObjectWatcher
Thinker K.F. Li <thinker@codemud.net>
parents: 1190
diff changeset
432 layer.group.appendChild(scene_group)
6442fb198418 Refactory insertKeyScene() and fix bug of ObjectWatcher
Thinker K.F. Li <thinker@codemud.net>
parents: 1190
diff changeset
433
6442fb198418 Refactory insertKeyScene() and fix bug of ObjectWatcher
Thinker K.F. Li <thinker@codemud.net>
parents: 1190
diff changeset
434 return scene_group
6442fb198418 Refactory insertKeyScene() and fix bug of ObjectWatcher
Thinker K.F. Li <thinker@codemud.net>
parents: 1190
diff changeset
435
1181
f14dbcf19e2b Move MBScene.insertKeyScene() to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents: 1180
diff changeset
436 def insertKeyScene(self, line, frame):
f14dbcf19e2b Move MBScene.insertKeyScene() to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents: 1180
diff changeset
437 """
f14dbcf19e2b Move MBScene.insertKeyScene() to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents: 1180
diff changeset
438 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
439 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
440 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
441 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
442 new scene.
f14dbcf19e2b Move MBScene.insertKeyScene() to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents: 1180
diff changeset
443
f14dbcf19e2b Move MBScene.insertKeyScene() to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents: 1180
diff changeset
444 """
1191
6442fb198418 Refactory insertKeyScene() and fix bug of ObjectWatcher
Thinker K.F. Li <thinker@codemud.net>
parents: 1190
diff changeset
445 doc = self._doc
6442fb198418 Refactory insertKeyScene() and fix bug of ObjectWatcher
Thinker K.F. Li <thinker@codemud.net>
parents: 1190
diff changeset
446 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
447
6442fb198418 Refactory insertKeyScene() and fix bug of ObjectWatcher
Thinker K.F. Li <thinker@codemud.net>
parents: 1190
diff changeset
448 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
449 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
450 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
451 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
452
6442fb198418 Refactory insertKeyScene() and fix bug of ObjectWatcher
Thinker K.F. Li <thinker@codemud.net>
parents: 1190
diff changeset
453 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
454 try:
1191
6442fb198418 Refactory insertKeyScene() and fix bug of ObjectWatcher
Thinker K.F. Li <thinker@codemud.net>
parents: 1190
diff changeset
455 label = node.getAttribute('inkscape:label')
1181
f14dbcf19e2b Move MBScene.insertKeyScene() to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents: 1180
diff changeset
456 except:
f14dbcf19e2b Move MBScene.insertKeyScene() to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents: 1180
diff changeset
457 continue
1191
6442fb198418 Refactory insertKeyScene() and fix bug of ObjectWatcher
Thinker K.F. Li <thinker@codemud.net>
parents: 1190
diff changeset
458 if label == 'dup':
6442fb198418 Refactory insertKeyScene() and fix bug of ObjectWatcher
Thinker K.F. Li <thinker@codemud.net>
parents: 1190
diff changeset
459 node.setAttribute('style', 'display: none')
6442fb198418 Refactory insertKeyScene() and fix bug of ObjectWatcher
Thinker K.F. Li <thinker@codemud.net>
parents: 1190
diff changeset
460 pass
1181
f14dbcf19e2b Move MBScene.insertKeyScene() to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents: 1180
diff changeset
461 pass
f14dbcf19e2b Move MBScene.insertKeyScene() to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents: 1180
diff changeset
462 pass
f14dbcf19e2b Move MBScene.insertKeyScene() to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents: 1180
diff changeset
463
1183
e8446e138427 Move update_scenes_of_dom() to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents: 1182
diff changeset
464 def add_scene_on_dom(self, frameline, scenes_node):
1188
45e3a9273af2 Move code about monitoring DOM-tree to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1185
diff changeset
465 doc = self._doc
1183
e8446e138427 Move update_scenes_of_dom() to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents: 1182
diff changeset
466 for start_idx, stop_idx, tween_type in frameline.get_frame_blocks():
1190
a4df892fb4e5 Use meaningful name for scene, scene group, and layer group
Thinker K.F. Li <thinker@codemud.net>
parents: 1189
diff changeset
467 scene_node = frameline.get_frame_data(start_idx)
1183
e8446e138427 Move update_scenes_of_dom() to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents: 1182
diff changeset
468 tween_type_idx = self._frameline_tween_types.index(tween_type)
e8446e138427 Move update_scenes_of_dom() to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents: 1182
diff changeset
469 tween_type_name = self._tween_type_names[tween_type_idx]
e8446e138427 Move update_scenes_of_dom() to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents: 1182
diff changeset
470
e8446e138427 Move update_scenes_of_dom() to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents: 1182
diff changeset
471 scene_node = doc.createElement("ns0:scene")
e8446e138427 Move update_scenes_of_dom() to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents: 1182
diff changeset
472 scenes_node.appendChild(scene_node)
e8446e138427 Move update_scenes_of_dom() to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents: 1182
diff changeset
473 scene_node.setAttribute("start", str(start_idx + 1))
e8446e138427 Move update_scenes_of_dom() to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents: 1182
diff changeset
474 if start_idx != stop_idx:
e8446e138427 Move update_scenes_of_dom() to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents: 1182
diff changeset
475 scene_node.setAttribute("end", str(stop_idx + 1))
e8446e138427 Move update_scenes_of_dom() to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents: 1182
diff changeset
476 pass
1190
a4df892fb4e5 Use meaningful name for scene, scene group, and layer group
Thinker K.F. Li <thinker@codemud.net>
parents: 1189
diff changeset
477 scene_node.setAttribute("ref", scene_node.getAttribute("id"))
1183
e8446e138427 Move update_scenes_of_dom() to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents: 1182
diff changeset
478 scene_node.setAttribute("type", tween_type_name)
e8446e138427 Move update_scenes_of_dom() to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents: 1182
diff changeset
479 pass
e8446e138427 Move update_scenes_of_dom() to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents: 1182
diff changeset
480 pass
e8446e138427 Move update_scenes_of_dom() to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents: 1182
diff changeset
481
e8446e138427 Move update_scenes_of_dom() to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents: 1182
diff changeset
482 def update_scenes_of_dom(self):
1188
45e3a9273af2 Move code about monitoring DOM-tree to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1185
diff changeset
483 doc = self._root
45e3a9273af2 Move code about monitoring DOM-tree to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1185
diff changeset
484 rdoc = self._doc
1183
e8446e138427 Move update_scenes_of_dom() to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents: 1182
diff changeset
485 for node in doc.childList():
e8446e138427 Move update_scenes_of_dom() to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents: 1182
diff changeset
486 if node.name() == 'svg:metadata':
e8446e138427 Move update_scenes_of_dom() to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents: 1182
diff changeset
487 for t in node.childList():
e8446e138427 Move update_scenes_of_dom() to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents: 1182
diff changeset
488 if t.name() == "ns0:scenes":
e8446e138427 Move update_scenes_of_dom() to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents: 1182
diff changeset
489 node.removeChild(t)
1190
a4df892fb4e5 Use meaningful name for scene, scene group, and layer group
Thinker K.F. Li <thinker@codemud.net>
parents: 1189
diff changeset
490 scenes_node = rdoc.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
491 node.appendChild(scenes_node)
1183
e8446e138427 Move update_scenes_of_dom() to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents: 1182
diff changeset
492 for layer in range(0, len(self._framelines)):
e8446e138427 Move update_scenes_of_dom() to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents: 1182
diff changeset
493 lobj = self._framelines[layer]
1190
a4df892fb4e5 Use meaningful name for scene, scene group, and layer group
Thinker K.F. Li <thinker@codemud.net>
parents: 1189
diff changeset
494 self.add_scene_on_dom(lobj, scenes_node)
1183
e8446e138427 Move update_scenes_of_dom() to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents: 1182
diff changeset
495 pass
e8446e138427 Move update_scenes_of_dom() to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents: 1182
diff changeset
496 pass
e8446e138427 Move update_scenes_of_dom() to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents: 1182
diff changeset
497 pass
e8446e138427 Move update_scenes_of_dom() to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents: 1182
diff changeset
498 pass
e8446e138427 Move update_scenes_of_dom() to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents: 1182
diff changeset
499 pass
e8446e138427 Move update_scenes_of_dom() to MBScene_dom
Thinker K.F. Li <thinker@codemud.net>
parents: 1182
diff changeset
500 pass
956
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
501
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
502 def parseScene(self):
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
503 """
957
8e3e46c26137 Break long lines
Thinker K.F. Li <thinker@codemud.net>
parents: 956
diff changeset
504 In this function, we will collect all items for the current
8e3e46c26137 Break long lines
Thinker K.F. Li <thinker@codemud.net>
parents: 956
diff changeset
505 scene and then relocate them back to the appropriate scene
8e3e46c26137 Break long lines
Thinker K.F. Li <thinker@codemud.net>
parents: 956
diff changeset
506 object.
956
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
507 """
961
b6375e74c69e Rename MBScene.layer to MBScene.layers
Thinker K.F. Li <thinker@codemud.net>
parents: 960
diff changeset
508 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
509 doc = self._root
956
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
510
1184
05d33f0fbc76 Add comment for some TODO item
Thinker K.F. Li <thinker@codemud.net>
parents: 1183
diff changeset
511 # TODO: Remove following code sicne this function is for parsing.
05d33f0fbc76 Add comment for some TODO item
Thinker K.F. Li <thinker@codemud.net>
parents: 1183
diff changeset
512 # Why do this here?
1128
b65ac686a7c5 Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents: 1125
diff changeset
513 addEventListener(doc,'DOMNodeInserted',self.updateUI,None)
b65ac686a7c5 Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents: 1125
diff changeset
514 addEventListener(doc,'DOMNodeRemoved',self.updateUI,None)
1184
05d33f0fbc76 Add comment for some TODO item
Thinker K.F. Li <thinker@codemud.net>
parents: 1183
diff changeset
515
1128
b65ac686a7c5 Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents: 1125
diff changeset
516 doc.childList()
1131
3ec0ad89e443 Fix the mtraix animation.
wycc
parents: 1130
diff changeset
517 try:
1141
8f0ee167c5b2 Fix the issue of the new DOM implementation
wycc
parents: 1140 1139
diff changeset
518 self.width = float(doc.getAttribute("width"))
8f0ee167c5b2 Fix the issue of the new DOM implementation
wycc
parents: 1140 1139
diff changeset
519 self.height= float(doc.getAttribute("height"))
1131
3ec0ad89e443 Fix the mtraix animation.
wycc
parents: 1130
diff changeset
520 except:
3ec0ad89e443 Fix the mtraix animation.
wycc
parents: 1130
diff changeset
521 self.width = 640
3ec0ad89e443 Fix the mtraix animation.
wycc
parents: 1130
diff changeset
522 self.height=480
1144
257beac7c982 Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents: 1142
diff changeset
523 pass
1131
3ec0ad89e443 Fix the mtraix animation.
wycc
parents: 1130
diff changeset
524
956
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
525 for node in doc.childList():
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
526 if node.name() == 'svg:g':
956
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
527 oldscene = None
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
528 lyobj = Layer(node)
961
b6375e74c69e Rename MBScene.layer to MBScene.layers
Thinker K.F. Li <thinker@codemud.net>
parents: 960
diff changeset
529 self.layers.append(lyobj)
1190
a4df892fb4e5 Use meaningful name for scene, scene group, and layer group
Thinker K.F. Li <thinker@codemud.net>
parents: 1189
diff changeset
530 for scene_group in node.childList():
a4df892fb4e5 Use meaningful name for scene, scene group, and layer group
Thinker K.F. Li <thinker@codemud.net>
parents: 1189
diff changeset
531 if scene_group.name() != 'svg:g':
a4df892fb4e5 Use meaningful name for scene, scene group, and layer group
Thinker K.F. Li <thinker@codemud.net>
parents: 1189
diff changeset
532 continue
a4df892fb4e5 Use meaningful name for scene, scene group, and layer group
Thinker K.F. Li <thinker@codemud.net>
parents: 1189
diff changeset
533
a4df892fb4e5 Use meaningful name for scene, scene group, and layer group
Thinker K.F. Li <thinker@codemud.net>
parents: 1189
diff changeset
534 try:
1192
79a3f82edaac Fix issue of losing keyframe after inerst a node in the scene
Thinker K.F. Li <thinker@codemud.net>
parents: 1191
diff changeset
535 label = scene_group.getAttribute('inkscape:label')
1190
a4df892fb4e5 Use meaningful name for scene, scene group, and layer group
Thinker K.F. Li <thinker@codemud.net>
parents: 1189
diff changeset
536 if label == 'dup':
a4df892fb4e5 Use meaningful name for scene, scene group, and layer group
Thinker K.F. Li <thinker@codemud.net>
parents: 1189
diff changeset
537 # TODO: remove this since this functio is for
a4df892fb4e5 Use meaningful name for scene, scene group, and layer group
Thinker K.F. Li <thinker@codemud.net>
parents: 1189
diff changeset
538 # parsing. Why do this here?
a4df892fb4e5 Use meaningful name for scene, scene group, and layer group
Thinker K.F. Li <thinker@codemud.net>
parents: 1189
diff changeset
539 node.removeChild(scene_group)
1192
79a3f82edaac Fix issue of losing keyframe after inerst a node in the scene
Thinker K.F. Li <thinker@codemud.net>
parents: 1191
diff changeset
540 continue
1190
a4df892fb4e5 Use meaningful name for scene, scene group, and layer group
Thinker K.F. Li <thinker@codemud.net>
parents: 1189
diff changeset
541 except:
a4df892fb4e5 Use meaningful name for scene, scene group, and layer group
Thinker K.F. Li <thinker@codemud.net>
parents: 1189
diff changeset
542 pass
1128
b65ac686a7c5 Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents: 1125
diff changeset
543
1190
a4df892fb4e5 Use meaningful name for scene, scene group, and layer group
Thinker K.F. Li <thinker@codemud.net>
parents: 1189
diff changeset
544 try:
a4df892fb4e5 Use meaningful name for scene, scene group, and layer group
Thinker K.F. Li <thinker@codemud.net>
parents: 1189
diff changeset
545 scene_group_id = scene_group.getAttribute('id')
a4df892fb4e5 Use meaningful name for scene, scene group, and layer group
Thinker K.F. Li <thinker@codemud.net>
parents: 1189
diff changeset
546 scene_node = self.get_scene(scene_group_id)
a4df892fb4e5 Use meaningful name for scene, scene group, and layer group
Thinker K.F. Li <thinker@codemud.net>
parents: 1189
diff changeset
547 start, stop, tween_type = \
a4df892fb4e5 Use meaningful name for scene, scene group, and layer group
Thinker K.F. Li <thinker@codemud.net>
parents: 1189
diff changeset
548 self._parse_one_scene(scene_node)
a4df892fb4e5 Use meaningful name for scene, scene group, and layer group
Thinker K.F. Li <thinker@codemud.net>
parents: 1189
diff changeset
549 except:
a4df892fb4e5 Use meaningful name for scene, scene group, and layer group
Thinker K.F. Li <thinker@codemud.net>
parents: 1189
diff changeset
550 continue
a4df892fb4e5 Use meaningful name for scene, scene group, and layer group
Thinker K.F. Li <thinker@codemud.net>
parents: 1189
diff changeset
551
a4df892fb4e5 Use meaningful name for scene, scene group, and layer group
Thinker K.F. Li <thinker@codemud.net>
parents: 1189
diff changeset
552 lyobj.scenes.append(Scene(scene_node, start, stop,
a4df892fb4e5 Use meaningful name for scene, scene group, and layer group
Thinker K.F. Li <thinker@codemud.net>
parents: 1189
diff changeset
553 tween_type))
956
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
554 pass
955
53b0f8dc2284 Add tailing 'pass' commands to close indents
Thinker K.F. Li <thinker@codemud.net>
parents: 943
diff changeset
555 pass
956
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
556 pass
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
557 pass
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
558
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
559 def getLayer(self, layer):
961
b6375e74c69e Rename MBScene.layer to MBScene.layers
Thinker K.F. Li <thinker@codemud.net>
parents: 960
diff changeset
560 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
561 if l.group.getAttribute('id') == layer:
956
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
562 return l
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
563 pass
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
564 return None
1188
45e3a9273af2 Move code about monitoring DOM-tree to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1185
diff changeset
565 pass
45e3a9273af2 Move code about monitoring DOM-tree to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1185
diff changeset
566
45e3a9273af2 Move code about monitoring DOM-tree to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1185
diff changeset
567 class MBScene(MBScene_dom):
45e3a9273af2 Move code about monitoring DOM-tree to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1185
diff changeset
568 _frameline_tween_types = (frameline.TWEEN_TYPE_NONE,
45e3a9273af2 Move code about monitoring DOM-tree to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1185
diff changeset
569 frameline.TWEEN_TYPE_SHAPE)
45e3a9273af2 Move code about monitoring DOM-tree to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1185
diff changeset
570 _tween_obj_tween_types = (TweenObject.TWEEN_TYPE_NORMAL,
45e3a9273af2 Move code about monitoring DOM-tree to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1185
diff changeset
571 TweenObject.TWEEN_TYPE_SCALE)
45e3a9273af2 Move code about monitoring DOM-tree to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1185
diff changeset
572 _tween_type_names = ('normal', 'scale')
956
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
573
1188
45e3a9273af2 Move code about monitoring DOM-tree to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1185
diff changeset
574 def __init__(self, desktop, win, root=None):
45e3a9273af2 Move code about monitoring DOM-tree to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1185
diff changeset
575 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
576
45e3a9273af2 Move code about monitoring DOM-tree to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1185
diff changeset
577 self.desktop = desktop
45e3a9273af2 Move code about monitoring DOM-tree to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1185
diff changeset
578 self.window = win
45e3a9273af2 Move code about monitoring DOM-tree to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1185
diff changeset
579 self.layers = []
45e3a9273af2 Move code about monitoring DOM-tree to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1185
diff changeset
580 self.layers.append(Layer(None))
45e3a9273af2 Move code about monitoring DOM-tree to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1185
diff changeset
581 self.top = None
45e3a9273af2 Move code about monitoring DOM-tree to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1185
diff changeset
582 self.last_update = None
45e3a9273af2 Move code about monitoring DOM-tree to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1185
diff changeset
583 pybInkscape.inkscape.connect('change_selection', self.show_selection)
45e3a9273af2 Move code about monitoring DOM-tree to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1185
diff changeset
584 self.last_select = 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
585 self._lockui=False
1188
45e3a9273af2 Move code about monitoring DOM-tree to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1185
diff changeset
586 self.tween=None
45e3a9273af2 Move code about monitoring DOM-tree to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1185
diff changeset
587 self.document = None
45e3a9273af2 Move code about monitoring DOM-tree to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1185
diff changeset
588 self.root = root
45e3a9273af2 Move code about monitoring DOM-tree to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1185
diff changeset
589 self.framerate=12
45e3a9273af2 Move code about monitoring DOM-tree to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1185
diff changeset
590 self.maxframe=0
45e3a9273af2 Move code about monitoring DOM-tree to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1185
diff changeset
591 self._disable_tween_type_selector = False
45e3a9273af2 Move code about monitoring DOM-tree to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1185
diff changeset
592 pass
45e3a9273af2 Move code about monitoring DOM-tree to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1185
diff changeset
593
45e3a9273af2 Move code about monitoring DOM-tree to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1185
diff changeset
594 def show_selection(self,w,obj):
45e3a9273af2 Move code about monitoring DOM-tree to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1185
diff changeset
595 objs = self.desktop.selection.list()
45e3a9273af2 Move code about monitoring DOM-tree to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1185
diff changeset
596 try:
45e3a9273af2 Move code about monitoring DOM-tree to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1185
diff changeset
597 o = objs[0]
45e3a9273af2 Move code about monitoring DOM-tree to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1185
diff changeset
598 print o.getCenter()
45e3a9273af2 Move code about monitoring DOM-tree to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1185
diff changeset
599 if o == self.last_select:
45e3a9273af2 Move code about monitoring DOM-tree to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1185
diff changeset
600 return
45e3a9273af2 Move code about monitoring DOM-tree to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1185
diff changeset
601 except:
45e3a9273af2 Move code about monitoring DOM-tree to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1185
diff changeset
602 self.nameEditor.set_text('')
45e3a9273af2 Move code about monitoring DOM-tree to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1185
diff changeset
603 self.last_select = None
45e3a9273af2 Move code about monitoring DOM-tree to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1185
diff changeset
604 return
45e3a9273af2 Move code about monitoring DOM-tree to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1185
diff changeset
605 self.last_select = o
45e3a9273af2 Move code about monitoring DOM-tree to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1185
diff changeset
606 try:
45e3a9273af2 Move code about monitoring DOM-tree to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1185
diff changeset
607 self.nameEditor.set_text(o.getAttribute("inkscape:label"))
45e3a9273af2 Move code about monitoring DOM-tree to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1185
diff changeset
608 except:
45e3a9273af2 Move code about monitoring DOM-tree to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1185
diff changeset
609 self.nameEditor.set_text('')
45e3a9273af2 Move code about monitoring DOM-tree to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1185
diff changeset
610 pass
45e3a9273af2 Move code about monitoring DOM-tree to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1185
diff changeset
611 pass
45e3a9273af2 Move code about monitoring DOM-tree to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1185
diff changeset
612
45e3a9273af2 Move code about monitoring DOM-tree to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1185
diff changeset
613 def confirm(self,msg):
45e3a9273af2 Move code about monitoring DOM-tree to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1185
diff changeset
614 vbox = gtk.VBox()
45e3a9273af2 Move code about monitoring DOM-tree to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1185
diff changeset
615 vbox.pack_start(gtk.Label(msg))
45e3a9273af2 Move code about monitoring DOM-tree to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1185
diff changeset
616 self.button = gtk.Button('OK')
45e3a9273af2 Move code about monitoring DOM-tree to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1185
diff changeset
617 vbox.pack_start(self.button)
45e3a9273af2 Move code about monitoring DOM-tree to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1185
diff changeset
618 self.button.connect("clicked", self.onQuit)
45e3a9273af2 Move code about monitoring DOM-tree to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1185
diff changeset
619 self.window.add(vbox)
45e3a9273af2 Move code about monitoring DOM-tree to MBScene_dom_monitor
Thinker K.F. Li <thinker@codemud.net>
parents: 1185
diff changeset
620 pass
956
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
621
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
622 def removeKeyScene(self):
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
623 nth = self.last_frame
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
624 y = self.last_line
1128
b65ac686a7c5 Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents: 1125
diff changeset
625 rdoc = self.document
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
626 i = 0
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
627 layer = self.last_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
628 while i < len(layer._keys):
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
629 s = layer._keys[i]
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
630 print "nth:%d idx %d" % (nth,s.idx)
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
631 if nth > s.idx:
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
632 if i == len(layer._keys)-1:
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
633 return
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
634 if nth == s.idx:
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
635 if s.left_tween:
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
636 # This is left tween, we move the keyframe one frame ahead
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
637 if s.idx == layer._keys[i-1].idx:
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
638 layer._keys[i].ref.parent().removeChild(layer._keys[i].ref)
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
639 self.last_line.rm_keyframe(nth)
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
640 self.last_line.rm_keyframe(nth-1)
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
641 else:
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
642 s.idx = s.idx-1
941
9ba94c577a6f Add scene editor. This vewrsion can only switch scene. It can not change the scene yet.
wycc
parents:
diff changeset
643 else:
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
644 layer._keys[i].ref.parent().removeChild(layer._keys[i].ref)
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
645 if s.right_tween:
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
646 self.last_line.rm_keyframe(layer._keys[i+1].idx)
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
647 self.last_line.rm_keyframe(nth)
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
648 else:
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
649 self.last_line.rm_keyframe(nth)
941
9ba94c577a6f Add scene editor. This vewrsion can only switch scene. It can not change the scene yet.
wycc
parents:
diff changeset
650
1182
8b0e5e8a6b0c Rename MBScene.update() to update_scenes_of_dom()
Thinker K.F. Li <thinker@codemud.net>
parents: 1181
diff changeset
651 self.update_scenes_of_dom()
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
652 self.last_line._draw_all_frames()
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
653 self.last_line.update()
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
654 return
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
655 i = i + 1
1144
257beac7c982 Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents: 1142
diff changeset
656 pass
257beac7c982 Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents: 1142
diff changeset
657 pass
257beac7c982 Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents: 1142
diff changeset
658
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
659 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
660 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
661 frameline = self.last_line
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
662 i = 0
1190
a4df892fb4e5 Use meaningful name for scene, scene group, and layer group
Thinker K.F. Li <thinker@codemud.net>
parents: 1189
diff changeset
663 while i < len(frameline._keys):
a4df892fb4e5 Use meaningful name for scene, scene group, and layer group
Thinker K.F. Li <thinker@codemud.net>
parents: 1189
diff changeset
664 s = frameline._keys[i]
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
665 if s.right_tween:
1190
a4df892fb4e5 Use meaningful name for scene, scene group, and layer group
Thinker K.F. Li <thinker@codemud.net>
parents: 1189
diff changeset
666 if frame_idx > s.idx:
a4df892fb4e5 Use meaningful name for scene, scene group, and layer group
Thinker K.F. Li <thinker@codemud.net>
parents: 1189
diff changeset
667 if frame_idx <= frameline._keys[i+1].idx:
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
668 return
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
669 try:
1190
a4df892fb4e5 Use meaningful name for scene, scene group, and layer group
Thinker K.F. Li <thinker@codemud.net>
parents: 1189
diff changeset
670 if frame_idx <= frameline._keys[i+2].idx:
a4df892fb4e5 Use meaningful name for scene, scene group, and layer group
Thinker K.F. Li <thinker@codemud.net>
parents: 1189
diff changeset
671 frameline._keys[i+1].idx = frame_idx
a4df892fb4e5 Use meaningful name for scene, scene group, and layer group
Thinker K.F. Li <thinker@codemud.net>
parents: 1189
diff changeset
672 frameline.draw_all_frames()
1182
8b0e5e8a6b0c Rename MBScene.update() to update_scenes_of_dom()
Thinker K.F. Li <thinker@codemud.net>
parents: 1181
diff changeset
673 self.update_scenes_of_dom()
1190
a4df892fb4e5 Use meaningful name for scene, scene group, and layer group
Thinker K.F. Li <thinker@codemud.net>
parents: 1189
diff changeset
674 self.setCurrentScene(frame_idx)
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
675 self.last_line.update()
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
676 return
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
677 else:
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
678 # We may in the next scene
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 i = i + 2
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
680 pass
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
681 except:
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
682 # This is the last keyframe, extend the keyframe by
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
683 # relocate the location of the keyframe
1190
a4df892fb4e5 Use meaningful name for scene, scene group, and layer group
Thinker K.F. Li <thinker@codemud.net>
parents: 1189
diff changeset
684 frameline._keys[i+1].idx = frame_idx
a4df892fb4e5 Use meaningful name for scene, scene group, and layer group
Thinker K.F. Li <thinker@codemud.net>
parents: 1189
diff changeset
685 frameline._draw_all_frames()
1182
8b0e5e8a6b0c Rename MBScene.update() to update_scenes_of_dom()
Thinker K.F. Li <thinker@codemud.net>
parents: 1181
diff changeset
686 self.update_scenes_of_dom()
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
687 self.last_line.update()
1190
a4df892fb4e5 Use meaningful name for scene, scene group, and layer group
Thinker K.F. Li <thinker@codemud.net>
parents: 1189
diff changeset
688 self.setCurrentScene(frame_idx)
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
689 return
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
690 else:
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
691 # We are in the front of all keyframes
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
692 return
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
693 else:
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
694 # This is a single keyframe
1190
a4df892fb4e5 Use meaningful name for scene, scene group, and layer group
Thinker K.F. Li <thinker@codemud.net>
parents: 1189
diff changeset
695 if frame_idx < s.idx:
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
696 return
1190
a4df892fb4e5 Use meaningful name for scene, scene group, and layer group
Thinker K.F. Li <thinker@codemud.net>
parents: 1189
diff changeset
697 if frame_idx == s.idx:
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
698 return
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
699 try:
1190
a4df892fb4e5 Use meaningful name for scene, scene group, and layer group
Thinker K.F. Li <thinker@codemud.net>
parents: 1189
diff changeset
700 if frame_idx < frameline._keys[i+1].idx:
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
701 # We are after a single keyframe and no scene is
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
702 # available here. Create a new tween here
1190
a4df892fb4e5 Use meaningful name for scene, scene group, and layer group
Thinker K.F. Li <thinker@codemud.net>
parents: 1189
diff changeset
703 idx = frameline._keys[i].idx
a4df892fb4e5 Use meaningful name for scene, scene group, and layer group
Thinker K.F. Li <thinker@codemud.net>
parents: 1189
diff changeset
704 scene_node = frameline._keys[i].ref
a4df892fb4e5 Use meaningful name for scene, scene group, and layer group
Thinker K.F. Li <thinker@codemud.net>
parents: 1189
diff changeset
705 frameline.add_keyframe(frame_idx, scene_node)
a4df892fb4e5 Use meaningful name for scene, scene group, and layer group
Thinker K.F. Li <thinker@codemud.net>
parents: 1189
diff changeset
706 frameline.tween(idx)
a4df892fb4e5 Use meaningful name for scene, scene group, and layer group
Thinker K.F. Li <thinker@codemud.net>
parents: 1189
diff changeset
707 frameline._draw_all_frames()
1182
8b0e5e8a6b0c Rename MBScene.update() to update_scenes_of_dom()
Thinker K.F. Li <thinker@codemud.net>
parents: 1181
diff changeset
708 self.update_scenes_of_dom()
1190
a4df892fb4e5 Use meaningful name for scene, scene group, and layer group
Thinker K.F. Li <thinker@codemud.net>
parents: 1189
diff changeset
709 self.setCurrentScene(frame_idx)
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
710 self.last_line.update()
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
711 return
956
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
712 else:
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
713 # We may in the next scene
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
714 i = i + 1
956
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
715 pass
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
716 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
717 except:
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
718 # This is the last scene, create a new one
1190
a4df892fb4e5 Use meaningful name for scene, scene group, and layer group
Thinker K.F. Li <thinker@codemud.net>
parents: 1189
diff changeset
719 idx = frameline._keys[i].idx
a4df892fb4e5 Use meaningful name for scene, scene group, and layer group
Thinker K.F. Li <thinker@codemud.net>
parents: 1189
diff changeset
720 scene_node = frameline._keys[i].ref
a4df892fb4e5 Use meaningful name for scene, scene group, and layer group
Thinker K.F. Li <thinker@codemud.net>
parents: 1189
diff changeset
721 frameline.add_keyframe(frame_idx, scene_node)
a4df892fb4e5 Use meaningful name for scene, scene group, and layer group
Thinker K.F. Li <thinker@codemud.net>
parents: 1189
diff changeset
722 frameline.tween(idx)
a4df892fb4e5 Use meaningful name for scene, scene group, and layer group
Thinker K.F. Li <thinker@codemud.net>
parents: 1189
diff changeset
723 frameline._draw_all_frames()
1182
8b0e5e8a6b0c Rename MBScene.update() to update_scenes_of_dom()
Thinker K.F. Li <thinker@codemud.net>
parents: 1181
diff changeset
724 self.update_scenes_of_dom()
1190
a4df892fb4e5 Use meaningful name for scene, scene group, and layer group
Thinker K.F. Li <thinker@codemud.net>
parents: 1189
diff changeset
725 self.setCurrentScene(frame_idx)
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
726 self.last_line.update()
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
727 return
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
728 pass
956
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
729 pass
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
730 pass
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
731
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
732 def setCurrentScene(self,nth):
1123
aad659b6b625 Add motion animation editor.
wycc
parents: 1120
diff changeset
733 """
1144
257beac7c982 Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents: 1142
diff changeset
734 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
735 data. There are a couple of cases.
1148
wycc
parents: 1147 1145
diff changeset
736 1. If the type of the scene is normal, we display it when
wycc
parents: 1147 1145
diff changeset
737 it contains the current frame. Otherwise hide it.
wycc
parents: 1147 1145
diff changeset
738 2. If the type of the scene is relocate or scale, we need
wycc
parents: 1147 1145
diff changeset
739 to duplicate the scene group and then modify its
wycc
parents: 1147 1145
diff changeset
740 transform matrix according to the definition of the
wycc
parents: 1147 1145
diff changeset
741 scene. Then, hide the original scenr group and display
wycc
parents: 1147 1145
diff changeset
742 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
743 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
744
1148
wycc
parents: 1147 1145
diff changeset
745 For each layer, we will always use the duplicated scene
wycc
parents: 1147 1145
diff changeset
746 group whose name as dup.
wycc
parents: 1147 1145
diff changeset
747 We will put the duplicated scene group inside it. We will
wycc
parents: 1147 1145
diff changeset
748 create this group if it is not
1123
aad659b6b625 Add motion animation editor.
wycc
parents: 1120
diff changeset
749 available.
aad659b6b625 Add motion animation editor.
wycc
parents: 1120
diff changeset
750 """
956
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
751 self.current = nth
1140
d4dbcb93aee0 Separate the tween from the main module.
wycc
parents: 1136
diff changeset
752 self.tween.updateMapping()
1151
71c72e8d6755 Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents: 1150
diff changeset
753 idx = nth - 1
1190
a4df892fb4e5 Use meaningful name for scene, scene group, and layer group
Thinker K.F. Li <thinker@codemud.net>
parents: 1189
diff changeset
754 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
755 i=0
1123
aad659b6b625 Add motion animation editor.
wycc
parents: 1120
diff changeset
756
aad659b6b625 Add motion animation editor.
wycc
parents: 1120
diff changeset
757 # Check the duplicated scene group and create it if it is not available
aad659b6b625 Add motion animation editor.
wycc
parents: 1120
diff changeset
758 try:
1190
a4df892fb4e5 Use meaningful name for scene, scene group, and layer group
Thinker K.F. Li <thinker@codemud.net>
parents: 1189
diff changeset
759 frameline.duplicateGroup.setAttribute("style","display:none")
1123
aad659b6b625 Add motion animation editor.
wycc
parents: 1120
diff changeset
760 except:
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
761 print "*"*40
1190
a4df892fb4e5 Use meaningful name for scene, scene group, and layer group
Thinker K.F. Li <thinker@codemud.net>
parents: 1189
diff changeset
762 frameline.duplicateGroup = self.document.createElement("svg:g")
a4df892fb4e5 Use meaningful name for scene, scene group, and layer group
Thinker K.F. Li <thinker@codemud.net>
parents: 1189
diff changeset
763 frameline.duplicateGroup.setAttribute("inkscape:label","dup")
a4df892fb4e5 Use meaningful name for scene, scene group, and layer group
Thinker K.F. Li <thinker@codemud.net>
parents: 1189
diff changeset
764 frameline.duplicateGroup.setAttribute("sodipodi:insensitive","1")
a4df892fb4e5 Use meaningful name for scene, scene group, and layer group
Thinker K.F. Li <thinker@codemud.net>
parents: 1189
diff changeset
765 frameline.duplicateGroup.setAttribute("style","")
a4df892fb4e5 Use meaningful name for scene, scene group, and layer group
Thinker K.F. Li <thinker@codemud.net>
parents: 1189
diff changeset
766 frameline.layer.group.appendChild(frameline.duplicateGroup)
1123
aad659b6b625 Add motion animation editor.
wycc
parents: 1120
diff changeset
767 pass
aad659b6b625 Add motion animation editor.
wycc
parents: 1120
diff changeset
768 # 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
769 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
770 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
771 scene_node = frameline.get_frame_data(start_idx)
1151
71c72e8d6755 Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents: 1150
diff changeset
772 if 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
773 scene_node.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
774 else:
1190
a4df892fb4e5 Use meaningful name for scene, scene group, and layer group
Thinker K.F. Li <thinker@codemud.net>
parents: 1189
diff changeset
775 scene_node.setAttribute('style', 'display: none')
1151
71c72e8d6755 Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents: 1150
diff changeset
776 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
777 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
778 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
779 scene_node = frameline.get_frame_data(start_idx)
a4df892fb4e5 Use meaningful name for scene, scene group, and layer group
Thinker K.F. Li <thinker@codemud.net>
parents: 1189
diff changeset
780 scene_node.setAttribute("style","")
1151
71c72e8d6755 Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents: 1150
diff changeset
781 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
782 scene_node = frameline.get_frame_data(start_idx)
a4df892fb4e5 Use meaningful name for scene, scene group, and layer group
Thinker K.F. Li <thinker@codemud.net>
parents: 1189
diff changeset
783 scene_node.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
784 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
785 tween_type_idx = \
71c72e8d6755 Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents: 1150
diff changeset
786 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
787 tween_obj_tween_type = \
71c72e8d6755 Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents: 1150
diff changeset
788 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
789
1180
bfd7d466a022 Fix yeiling error message when select a scene.
Thinker K.F. Li <thinker@codemud.net>
parents: 1179
diff changeset
790 try:
bfd7d466a022 Fix yeiling error message when select a scene.
Thinker K.F. Li <thinker@codemud.net>
parents: 1179
diff changeset
791 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
792 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
793 except:
1190
a4df892fb4e5 Use meaningful name for scene, scene group, and layer group
Thinker K.F. Li <thinker@codemud.net>
parents: 1189
diff changeset
794 next_scene_node = scene_node
1163
wycc
parents: 1161
diff changeset
795 else:
1190
a4df892fb4e5 Use meaningful name for scene, scene group, and layer group
Thinker K.F. Li <thinker@codemud.net>
parents: 1189
diff changeset
796 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
797 pass
1151
71c72e8d6755 Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents: 1150
diff changeset
798
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
799 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
800 percent = float(idx - start_idx) / nframes
1190
a4df892fb4e5 Use meaningful name for scene, scene group, and layer group
Thinker K.F. Li <thinker@codemud.net>
parents: 1189
diff changeset
801 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
802 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
803 scene_node,
a4df892fb4e5 Use meaningful name for scene, scene group, and layer group
Thinker K.F. Li <thinker@codemud.net>
parents: 1189
diff changeset
804 next_scene_node,
1151
71c72e8d6755 Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents: 1150
diff changeset
805 percent)
959
67823f7a0a17 Use frameline module in MBScene
Thinker K.F. Li <thinker@codemud.net>
parents: 957
diff changeset
806 else:
1190
a4df892fb4e5 Use meaningful name for scene, scene group, and layer group
Thinker K.F. Li <thinker@codemud.net>
parents: 1189
diff changeset
807 scene_node = frameline.get_frame_data(start_idx)
a4df892fb4e5 Use meaningful name for scene, scene group, and layer group
Thinker K.F. Li <thinker@codemud.net>
parents: 1189
diff changeset
808 scene_node.setAttribute("style","display:none")
1151
71c72e8d6755 Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents: 1150
diff changeset
809 pass
955
53b0f8dc2284 Add tailing 'pass' commands to close indents
Thinker K.F. Li <thinker@codemud.net>
parents: 943
diff changeset
810 pass
956
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
811 pass
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
812 pass
1125
5b2394f67ad0 Add shape tween support.
wycc
parents: 1123
diff changeset
813
1191
6442fb198418 Refactory insertKeyScene() and fix bug of ObjectWatcher
Thinker K.F. Li <thinker@codemud.net>
parents: 1190
diff changeset
814 def enterGroup(self, obj):
1070
afa42d5836cc Call setCurrentLayer to enter the current scene group.
wycc
parents: 1064
diff changeset
815 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
816 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
817 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
818 self.desktop.setCurrentLayer(s.spitem)
1144
257beac7c982 Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents: 1142
diff changeset
819 pass
257beac7c982 Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents: 1142
diff changeset
820 pass
257beac7c982 Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents: 1142
diff changeset
821 pass
257beac7c982 Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents: 1142
diff changeset
822 pass
257beac7c982 Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents: 1142
diff changeset
823
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
824 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
825 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
826 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
827 except:
ec1ea8555911 Stop selectSceneObject() from using private variable _keys of frameline
Thinker K.F. Li <thinker@codemud.net>
parents: 1176
diff changeset
828 return
1070
afa42d5836cc Call setCurrentLayer to enter the current scene group.
wycc
parents: 1064
diff changeset
829
1190
a4df892fb4e5 Use meaningful name for scene, scene group, and layer group
Thinker K.F. Li <thinker@codemud.net>
parents: 1189
diff changeset
830 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
831 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
832 scene_group = self.get_node(scene_group_id)
6442fb198418 Refactory insertKeyScene() and fix bug of ObjectWatcher
Thinker K.F. Li <thinker@codemud.net>
parents: 1190
diff changeset
833 self.enterGroup(scene_group)
1177
ec1ea8555911 Stop selectSceneObject() from using private variable _keys of frameline
Thinker K.F. Li <thinker@codemud.net>
parents: 1176
diff changeset
834 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
835 pass
1144
257beac7c982 Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents: 1142
diff changeset
836
1150
6586cd10c92f Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents: 1149
diff changeset
837 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
838 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
839 self._disable_tween_type_selector = True
6586cd10c92f Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents: 1149
diff changeset
840 self.tweenTypeSelector.set_active(sel_type)
6586cd10c92f Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents: 1149
diff changeset
841 self._disable_tween_type_selector = False
1144
257beac7c982 Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents: 1142
diff changeset
842 pass
955
53b0f8dc2284 Add tailing 'pass' commands to close indents
Thinker K.F. Li <thinker@codemud.net>
parents: 943
diff changeset
843
956
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
844 def newCell(self,file):
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
845 img = gtk.Image()
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
846 img.set_from_file(file)
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
847 btn = gtk.EventBox()
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
848 btn.add(img)
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
849 btn.connect("button_press_event", self.cellSelect)
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
850 btn.modify_bg(gtk.STATE_NORMAL, btn.get_colormap().alloc_color("gray"))
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
851 return btn
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
852
1179
b65df4f0d30a Change signature of MBScene.insertKeyScene()
Thinker K.F. Li <thinker@codemud.net>
parents: 1178
diff changeset
853 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
854 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
855 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
856 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
857 self._lockui = True
1179
b65df4f0d30a Change signature of MBScene.insertKeyScene()
Thinker K.F. Li <thinker@codemud.net>
parents: 1178
diff changeset
858 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
859 self._lockui = False
1144
257beac7c982 Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents: 1142
diff changeset
860 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
861
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
862 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
863 """
ab09c536a137 Hide the hover of all inactive framelines. This fix the issue of multiple hover in every frameline objects.
wycc
parents: 975
diff changeset
864 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
865 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
866 """
ab09c536a137 Hide the hover of all inactive framelines. This fix the issue of multiple hover in every frameline objects.
wycc
parents: 975
diff changeset
867 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
868 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
869 f.hide_hover()
1144
257beac7c982 Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents: 1142
diff changeset
870 pass
257beac7c982 Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents: 1142
diff changeset
871 pass
257beac7c982 Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents: 1142
diff changeset
872 pass
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
873
963
a05ec4fb1c20 update framelines according content 0f layers
Thinker K.F. Li <thinker@codemud.net>
parents: 962
diff changeset
874 def _create_framelines(self):
1166
d73ef03c96de Refactory code of MBScene.updateUI() from MBScene.show()
Thinker K.F. Li <thinker@codemud.net>
parents: 1164
diff changeset
875 if not hasattr(self, 'scrollwin'):
d73ef03c96de Refactory code of MBScene.updateUI() from MBScene.show()
Thinker K.F. Li <thinker@codemud.net>
parents: 1164
diff changeset
876 self.scrollwin = gtk.ScrolledWindow()
d73ef03c96de Refactory code of MBScene.updateUI() from MBScene.show()
Thinker K.F. Li <thinker@codemud.net>
parents: 1164
diff changeset
877 self.scrollwin.set_policy(gtk.POLICY_AUTOMATIC,
d73ef03c96de Refactory code of MBScene.updateUI() from MBScene.show()
Thinker K.F. Li <thinker@codemud.net>
parents: 1164
diff changeset
878 gtk.POLICY_AUTOMATIC)
d73ef03c96de Refactory code of MBScene.updateUI() from MBScene.show()
Thinker K.F. Li <thinker@codemud.net>
parents: 1164
diff changeset
879 self.scrollwin.set_size_request(-1,150)
d73ef03c96de Refactory code of MBScene.updateUI() from MBScene.show()
Thinker K.F. Li <thinker@codemud.net>
parents: 1164
diff changeset
880 vbox = gtk.VBox()
d73ef03c96de Refactory code of MBScene.updateUI() from MBScene.show()
Thinker K.F. Li <thinker@codemud.net>
parents: 1164
diff changeset
881 vbox.show()
d73ef03c96de Refactory code of MBScene.updateUI() from MBScene.show()
Thinker K.F. Li <thinker@codemud.net>
parents: 1164
diff changeset
882 self.scrollwin.add_with_viewport(vbox)
d73ef03c96de Refactory code of MBScene.updateUI() from MBScene.show()
Thinker K.F. Li <thinker@codemud.net>
parents: 1164
diff changeset
883 self.scrollwin_vbox = vbox
d73ef03c96de Refactory code of MBScene.updateUI() from MBScene.show()
Thinker K.F. Li <thinker@codemud.net>
parents: 1164
diff changeset
884 else:
1174
96a7abce774a Add functions to insert and remove frame.
wycc
parents: 1171
diff changeset
885 for c in self.scrollwin_vbox.get_children():
96a7abce774a Add functions to insert and remove frame.
wycc
parents: 1171
diff changeset
886 self.scrollwin_vbox.remove(c)
96a7abce774a Add functions to insert and remove frame.
wycc
parents: 1171
diff changeset
887 vbox = self.scrollwin_vbox
1166
d73ef03c96de Refactory code of MBScene.updateUI() from MBScene.show()
Thinker K.F. Li <thinker@codemud.net>
parents: 1164
diff changeset
888 pass
959
67823f7a0a17 Use frameline module in MBScene
Thinker K.F. Li <thinker@codemud.net>
parents: 957
diff changeset
889
67823f7a0a17 Use frameline module in MBScene
Thinker K.F. Li <thinker@codemud.net>
parents: 957
diff changeset
890 nframes = 100
67823f7a0a17 Use frameline module in MBScene
Thinker K.F. Li <thinker@codemud.net>
parents: 957
diff changeset
891
1150
6586cd10c92f Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents: 1149
diff changeset
892 ruler = frameruler(nframes)
959
67823f7a0a17 Use frameline module in MBScene
Thinker K.F. Li <thinker@codemud.net>
parents: 957
diff changeset
893 ruler.set_size_request(nframes * 10, 20)
67823f7a0a17 Use frameline module in MBScene
Thinker K.F. Li <thinker@codemud.net>
parents: 957
diff changeset
894 ruler.show()
1032
148ce30a861d SHift the ruler to the right to align to the frames
wycc
parents: 983
diff changeset
895 hbox = gtk.HBox()
148ce30a861d SHift the ruler to the right to align to the frames
wycc
parents: 983
diff changeset
896 label=gtk.Label('')
148ce30a861d SHift the ruler to the right to align to the frames
wycc
parents: 983
diff changeset
897 label.set_size_request(100,0)
148ce30a861d SHift the ruler to the right to align to the frames
wycc
parents: 983
diff changeset
898 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
899 hbox.pack_start(ruler)
148ce30a861d SHift the ruler to the right to align to the frames
wycc
parents: 983
diff changeset
900 vbox.pack_start(hbox, False)
959
67823f7a0a17 Use frameline module in MBScene
Thinker K.F. Li <thinker@codemud.net>
parents: 957
diff changeset
901
960
8fd97e0becb3 Add a frameline for each layer
Thinker K.F. Li <thinker@codemud.net>
parents: 959
diff changeset
902 #
8fd97e0becb3 Add a frameline for each layer
Thinker K.F. Li <thinker@codemud.net>
parents: 959
diff changeset
903 # Add a frameline for each layer
8fd97e0becb3 Add a frameline for each layer
Thinker K.F. Li <thinker@codemud.net>
parents: 959
diff changeset
904 #
8fd97e0becb3 Add a frameline for each layer
Thinker K.F. Li <thinker@codemud.net>
parents: 959
diff changeset
905 self._framelines = []
983
ee31add87843 Change the order of layer in the scene editor to make it consistent with the inkscape layer manager
wycc
parents: 982
diff changeset
906 for i in range(len(self.layers)-1,-1,-1):
1150
6586cd10c92f Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents: 1149
diff changeset
907 line = frameline(nframes)
983
ee31add87843 Change the order of layer in the scene editor to make it consistent with the inkscape layer manager
wycc
parents: 982
diff changeset
908 hbox = gtk.HBox()
1190
a4df892fb4e5 Use meaningful name for scene, scene group, and layer group
Thinker K.F. Li <thinker@codemud.net>
parents: 1189
diff changeset
909 label = gtk.Label(self.layers[i].group.getAttribute("inkscape:label"))
983
ee31add87843 Change the order of layer in the scene editor to make it consistent with the inkscape layer manager
wycc
parents: 982
diff changeset
910 label.set_size_request(100,0)
ee31add87843 Change the order of layer in the scene editor to make it consistent with the inkscape layer manager
wycc
parents: 982
diff changeset
911 hbox.pack_start(label,expand=False,fill=True)
ee31add87843 Change the order of layer in the scene editor to make it consistent with the inkscape layer manager
wycc
parents: 982
diff changeset
912 hbox.pack_start(line)
960
8fd97e0becb3 Add a frameline for each layer
Thinker K.F. Li <thinker@codemud.net>
parents: 959
diff changeset
913 line.set_size_request(nframes * 10, 20)
983
ee31add87843 Change the order of layer in the scene editor to make it consistent with the inkscape layer manager
wycc
parents: 982
diff changeset
914 vbox.pack_start(hbox, False)
ee31add87843 Change the order of layer in the scene editor to make it consistent with the inkscape layer manager
wycc
parents: 982
diff changeset
915 line.label = label
960
8fd97e0becb3 Add a frameline for each layer
Thinker K.F. Li <thinker@codemud.net>
parents: 959
diff changeset
916 self._framelines.append(line)
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
917 line.connect(line.FRAME_BUT_PRESS, self.onCellClick)
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
918 line.nLayer = i
1190
a4df892fb4e5 Use meaningful name for scene, scene group, and layer group
Thinker K.F. Li <thinker@codemud.net>
parents: 1189
diff changeset
919 line.layer_group = self.layers[i].group
983
ee31add87843 Change the order of layer in the scene editor to make it consistent with the inkscape layer manager
wycc
parents: 982
diff changeset
920 line.layer = self.layers[i]
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
921 line.connect('motion-notify-event', self._remove_active_frame)
960
8fd97e0becb3 Add a frameline for each layer
Thinker K.F. Li <thinker@codemud.net>
parents: 959
diff changeset
922 pass
1174
96a7abce774a Add functions to insert and remove frame.
wycc
parents: 1171
diff changeset
923 vbox.show_all()
960
8fd97e0becb3 Add a frameline for each layer
Thinker K.F. Li <thinker@codemud.net>
parents: 959
diff changeset
924 pass
8fd97e0becb3 Add a frameline for each layer
Thinker K.F. Li <thinker@codemud.net>
parents: 959
diff changeset
925
1191
6442fb198418 Refactory insertKeyScene() and fix bug of ObjectWatcher
Thinker K.F. Li <thinker@codemud.net>
parents: 1190
diff changeset
926 ## \brief Update conetent of framelines according layers.
963
a05ec4fb1c20 update framelines according content 0f layers
Thinker K.F. Li <thinker@codemud.net>
parents: 962
diff changeset
927 #
a05ec4fb1c20 update framelines according content 0f layers
Thinker K.F. Li <thinker@codemud.net>
parents: 962
diff changeset
928 def _update_framelines(self):
983
ee31add87843 Change the order of layer in the scene editor to make it consistent with the inkscape layer manager
wycc
parents: 982
diff changeset
929 for frameline in self._framelines:
ee31add87843 Change the order of layer in the scene editor to make it consistent with the inkscape layer manager
wycc
parents: 982
diff changeset
930 layer = frameline.layer
1190
a4df892fb4e5 Use meaningful name for scene, scene group, and layer group
Thinker K.F. Li <thinker@codemud.net>
parents: 1189
diff changeset
931 if frameline.layer_group.getAttribute("inkscape:label")==None:
1064
16c69756ef5d Add NodeObserver to monitor the change of the layer and update it in the scene editor.
wycc
parents: 1032
diff changeset
932 frameline.label.set_text('???')
16c69756ef5d Add NodeObserver to monitor the change of the layer and update it in the scene editor.
wycc
parents: 1032
diff changeset
933 else:
1190
a4df892fb4e5 Use meaningful name for scene, scene group, and layer group
Thinker K.F. Li <thinker@codemud.net>
parents: 1189
diff changeset
934 frameline.label.set_text(frameline.layer_group.getAttribute("inkscape:label"))
1164
2cb5047d8f2b Add support to insert key frame in the middle of the tween.
wycc
parents: 1163
diff changeset
935 last_scene = None
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
936 for scene in layer.scenes:
1164
2cb5047d8f2b Add support to insert key frame in the middle of the tween.
wycc
parents: 1163
diff changeset
937 if last_scene and last_scene.end == scene.start:
2cb5047d8f2b Add support to insert key frame in the middle of the tween.
wycc
parents: 1163
diff changeset
938 frameline.setRightTween(last_scene.end)
2cb5047d8f2b Add support to insert key frame in the middle of the tween.
wycc
parents: 1163
diff changeset
939 else:
1190
a4df892fb4e5 Use meaningful name for scene, scene group, and layer group
Thinker K.F. Li <thinker@codemud.net>
parents: 1189
diff changeset
940 frameline.add_keyframe(scene.start-1, scene.node)
1164
2cb5047d8f2b Add support to insert key frame in the middle of the tween.
wycc
parents: 1163
diff changeset
941 last_scene = scene
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
942 if scene.start != scene.end:
1190
a4df892fb4e5 Use meaningful name for scene, scene group, and layer group
Thinker K.F. Li <thinker@codemud.net>
parents: 1189
diff changeset
943 frameline.add_keyframe(scene.end-1, scene.node)
1150
6586cd10c92f Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents: 1149
diff changeset
944 tween_type_idx = self._tween_type_names.index(scene.type)
1151
71c72e8d6755 Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents: 1150
diff changeset
945 tween_type = self._frameline_tween_types[tween_type_idx]
1150
6586cd10c92f Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents: 1149
diff changeset
946 frameline.tween(scene.start-1, tween_type)
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
947 pass
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
948 pass
959
67823f7a0a17 Use frameline module in MBScene
Thinker K.F. Li <thinker@codemud.net>
parents: 957
diff changeset
949 pass
67823f7a0a17 Use frameline module in MBScene
Thinker K.F. Li <thinker@codemud.net>
parents: 957
diff changeset
950
956
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
951 def cellSelect(self, cell, data):
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
952 if self.last_cell:
957
8e3e46c26137 Break long lines
Thinker K.F. Li <thinker@codemud.net>
parents: 956
diff changeset
953 color = self.last_cell.get_colormap().alloc_color("gray")
8e3e46c26137 Break long lines
Thinker K.F. Li <thinker@codemud.net>
parents: 956
diff changeset
954 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
955 pass
955
53b0f8dc2284 Add tailing 'pass' commands to close indents
Thinker K.F. Li <thinker@codemud.net>
parents: 943
diff changeset
956
956
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
957 self.last_cell = cell
957
8e3e46c26137 Break long lines
Thinker K.F. Li <thinker@codemud.net>
parents: 956
diff changeset
958 color = cell.get_colormap().alloc_color("green")
8e3e46c26137 Break long lines
Thinker K.F. Li <thinker@codemud.net>
parents: 956
diff changeset
959 cell.modify_bg(gtk.STATE_NORMAL, color)
956
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
960 pass
1144
257beac7c982 Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents: 1142
diff changeset
961
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
962 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
963 self.last_line.add_keyframe(self.last_frame)
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
964 # Search for the current scene
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
965 i = 0
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
966 while i < len(self.last_line._keys):
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
967 key = self.last_line._keys[i]
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
968 if key.idx == self.last_frame:
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
969 if i == 0:
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
970 # This is the first frame, we can not duplicate it
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
971 self.last_line.rm_keyframe(self.last_frame)
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
972 return
1139
a2b068594412 Use pybind with new DOM API (at PYNode).
Thinker K.F. Li <thinker@codemud.net>
parents: 1136
diff changeset
973 node = self.duplicateSceneGroup(last_key.ref.getAttribute("id"))
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
974 key.ref = node
1182
8b0e5e8a6b0c Rename MBScene.update() to update_scenes_of_dom()
Thinker K.F. Li <thinker@codemud.net>
parents: 1181
diff changeset
975 self.update_scenes_of_dom()
1166
d73ef03c96de Refactory code of MBScene.updateUI() from MBScene.show()
Thinker K.F. Li <thinker@codemud.net>
parents: 1164
diff changeset
976 self.updateUI()
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
977 self.doEditScene(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
978 return
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
979 last_key = key
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
980 i = i + 1
1144
257beac7c982 Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents: 1142
diff changeset
981 pass
257beac7c982 Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents: 1142
diff changeset
982 pass
257beac7c982 Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents: 1142
diff changeset
983
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
984 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
985 # Search for the duplicated group
1149
0ffef2df6201 Rename MBScene.dom to MBScene.root
Thinker K.F. Li <thinker@codemud.net>
parents: 1148
diff changeset
986 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
987 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
988 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
989 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
990 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
991 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
992 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
993 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
994 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
995 break
1144
257beac7c982 Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents: 1142
diff changeset
996 pass
257beac7c982 Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents: 1142
diff changeset
997 pass
257beac7c982 Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents: 1142
diff changeset
998 pass
257beac7c982 Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents: 1142
diff changeset
999 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
1000 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
1001 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
1002 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
1003
71c72e8d6755 Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents: 1150
diff changeset
1004 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
1005 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
1006 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
1007 print old_node
1151
71c72e8d6755 Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents: 1150
diff changeset
1008 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
1009 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
1010 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
1011 pass
71c72e8d6755 Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents: 1150
diff changeset
1012
1190
a4df892fb4e5 Use meaningful name for scene, scene group, and layer group
Thinker K.F. Li <thinker@codemud.net>
parents: 1189
diff changeset
1013 gid = self.last_line.layer_group.getAttribute("inkscape:label")+self.new_id()
a4df892fb4e5 Use meaningful name for scene, scene group, and layer group
Thinker K.F. Li <thinker@codemud.net>
parents: 1189
diff changeset
1014 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
1015 scene_group.setAttribute("inkscape:groupmode","layer")
a4df892fb4e5 Use meaningful name for scene, scene group, and layer group
Thinker K.F. Li <thinker@codemud.net>
parents: 1189
diff changeset
1016 self.last_line.layer_group.appendChild(scene_group)
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
1017 return ns
956
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
1018
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
1019 def doEditScene(self, w):
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
1020 self.setCurrentScene(self.last_frame+1)
1179
b65df4f0d30a Change signature of MBScene.insertKeyScene()
Thinker K.F. Li <thinker@codemud.net>
parents: 1178
diff changeset
1021 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
1022 pass
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
1023
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
1024 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
1025 self._lockui=True
1179
b65df4f0d30a Change signature of MBScene.insertKeyScene()
Thinker K.F. Li <thinker@codemud.net>
parents: 1178
diff changeset
1026 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
1027 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
1028 self._lockui=False
956
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
1029 # self.grid.show_all()
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
1030 return
1144
257beac7c982 Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents: 1142
diff changeset
1031
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
1032 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
1033 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
1034 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
1035 self._lockui = False
956
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
1036
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
1037 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
1038 self._lockui = True
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
1039 self.removeKeyScene()
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
1040 self._lockui = False
956
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
1041 return
941
9ba94c577a6f Add scene editor. This vewrsion can only switch scene. It can not change the scene yet.
wycc
parents:
diff changeset
1042
956
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
1043
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
1044 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
1045 self._lockui = True
956
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
1046 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
1047 self._lockui = False
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
1048 #self.grid.show_all()
956
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
1049 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
1050
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
1051 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
1052 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
1053 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
1054 pass
257beac7c982 Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents: 1142
diff changeset
1055
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
1056 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
1057 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
1058 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
1059 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
1060 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
1061 self.editDone.connect('clicked', self.changeObjectLabel)
1144
257beac7c982 Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents: 1142
diff changeset
1062 pass
257beac7c982 Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents: 1142
diff changeset
1063
1147
5cfa73d7e80f Add the Run button to simulate the animation
wycc
parents: 1146
diff changeset
1064 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
1065 """
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
1066 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
1067 """
1147
5cfa73d7e80f Add the Run button to simulate the animation
wycc
parents: 1146
diff changeset
1068 if self.btnRun.get_label() == "Run":
5cfa73d7e80f Add the Run button to simulate the animation
wycc
parents: 1146
diff changeset
1069 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
1070 self._lockui = True
1147
5cfa73d7e80f Add the Run button to simulate the animation
wycc
parents: 1146
diff changeset
1071 self.last_update = glib.timeout_add(1000/self.framerate,self.doRunNext)
5cfa73d7e80f Add the Run button to simulate the animation
wycc
parents: 1146
diff changeset
1072 else:
5cfa73d7e80f Add the Run button to simulate the animation
wycc
parents: 1146
diff changeset
1073 self.btnRun.set_label("Run")
5cfa73d7e80f Add the Run button to simulate the animation
wycc
parents: 1146
diff changeset
1074 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
1075 self._lockui = False
1161
a7faab54e8f8 Fix broken of running animation
Thinker K.F. Li <thinker@codemud.net>
parents: 1160
diff changeset
1076 pass
1147
5cfa73d7e80f Add the Run button to simulate the animation
wycc
parents: 1146
diff changeset
1077
5cfa73d7e80f Add the Run button to simulate the animation
wycc
parents: 1146
diff changeset
1078 def doRunNext(self):
5cfa73d7e80f Add the Run button to simulate the animation
wycc
parents: 1146
diff changeset
1079 if self.current >= self.maxframe:
5cfa73d7e80f Add the Run button to simulate the animation
wycc
parents: 1146
diff changeset
1080 self.current = 0
1161
a7faab54e8f8 Fix broken of running animation
Thinker K.F. Li <thinker@codemud.net>
parents: 1160
diff changeset
1081 try:
a7faab54e8f8 Fix broken of running animation
Thinker K.F. Li <thinker@codemud.net>
parents: 1160
diff changeset
1082 self.setCurrentScene(self.current+1)
a7faab54e8f8 Fix broken of running animation
Thinker K.F. Li <thinker@codemud.net>
parents: 1160
diff changeset
1083 except:
a7faab54e8f8 Fix broken of running animation
Thinker K.F. Li <thinker@codemud.net>
parents: 1160
diff changeset
1084 traceback.print_exc()
a7faab54e8f8 Fix broken of running animation
Thinker K.F. Li <thinker@codemud.net>
parents: 1160
diff changeset
1085 raise
1147
5cfa73d7e80f Add the Run button to simulate the animation
wycc
parents: 1146
diff changeset
1086 self.last_update = glib.timeout_add(1000/self.framerate,self.doRunNext)
1174
96a7abce774a Add functions to insert and remove frame.
wycc
parents: 1171
diff changeset
1087
96a7abce774a Add functions to insert and remove frame.
wycc
parents: 1171
diff changeset
1088 def doInsertScene(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
1089 self._lockui=True
1174
96a7abce774a Add functions to insert and remove frame.
wycc
parents: 1171
diff changeset
1090 self.last_line.insert_frame(self.last_frame)
1182
8b0e5e8a6b0c Rename MBScene.update() to update_scenes_of_dom()
Thinker K.F. Li <thinker@codemud.net>
parents: 1181
diff changeset
1091 self.update_scenes_of_dom()
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=False
1174
96a7abce774a Add functions to insert and remove frame.
wycc
parents: 1171
diff changeset
1093
96a7abce774a Add functions to insert and remove frame.
wycc
parents: 1171
diff changeset
1094 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
1095 self._lockui=True
1174
96a7abce774a Add functions to insert and remove frame.
wycc
parents: 1171
diff changeset
1096 self.last_line.remove_frame(self.last_frame)
1182
8b0e5e8a6b0c Rename MBScene.update() to update_scenes_of_dom()
Thinker K.F. Li <thinker@codemud.net>
parents: 1181
diff changeset
1097 self.update_scenes_of_dom()
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
1098 self._lockui=False
956
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
1099
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
1100 def addButtons(self,hbox):
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
1101 btn = gtk.Button('Insert Key')
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
1102 btn.connect('clicked',self.doInsertKeyScene)
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
1103 hbox.pack_start(btn,expand=False,fill=False)
1174
96a7abce774a Add functions to insert and remove frame.
wycc
parents: 1171
diff changeset
1104
956
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
1105 btn=gtk.Button('Remove Key')
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
1106 btn.connect('clicked', self.doRemoveScene)
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
1107 hbox.pack_start(btn,expand=False,fill=False)
1174
96a7abce774a Add functions to insert and remove frame.
wycc
parents: 1171
diff changeset
1108
956
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
1109 btn=gtk.Button('Extend scene')
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
1110 btn.connect('clicked', self.doExtendScene)
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
1111 hbox.pack_start(btn,expand=False,fill=False)
1174
96a7abce774a Add functions to insert and remove frame.
wycc
parents: 1171
diff changeset
1112
96a7abce774a Add functions to insert and remove frame.
wycc
parents: 1171
diff changeset
1113 btn=gtk.Button('Duplicate Key')
96a7abce774a Add functions to insert and remove frame.
wycc
parents: 1171
diff changeset
1114 btn.connect('clicked', self.doDuplicateKeyScene)
96a7abce774a Add functions to insert and remove frame.
wycc
parents: 1171
diff changeset
1115 hbox.pack_start(btn,expand=False,fill=False)
96a7abce774a Add functions to insert and remove frame.
wycc
parents: 1171
diff changeset
1116
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
1117 btn=gtk.Button('Duplicate Key')
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
1118 btn.connect('clicked', self.doDuplicateKeyScene)
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
1119 hbox.pack_start(btn,expand=False,fill=False)
1174
96a7abce774a Add functions to insert and remove frame.
wycc
parents: 1171
diff changeset
1120
96a7abce774a Add functions to insert and remove frame.
wycc
parents: 1171
diff changeset
1121 btn=gtk.Button('Insert')
96a7abce774a Add functions to insert and remove frame.
wycc
parents: 1171
diff changeset
1122 btn.connect('clicked', self.doInsertScene)
96a7abce774a Add functions to insert and remove frame.
wycc
parents: 1171
diff changeset
1123 hbox.pack_start(btn,expand=False,fill=False)
96a7abce774a Add functions to insert and remove frame.
wycc
parents: 1171
diff changeset
1124
96a7abce774a Add functions to insert and remove frame.
wycc
parents: 1171
diff changeset
1125 btn=gtk.Button('Remove')
96a7abce774a Add functions to insert and remove frame.
wycc
parents: 1171
diff changeset
1126 btn.connect('clicked', self.doRemoveScene)
96a7abce774a Add functions to insert and remove frame.
wycc
parents: 1171
diff changeset
1127 hbox.pack_start(btn,expand=False,fill=False)
96a7abce774a Add functions to insert and remove frame.
wycc
parents: 1171
diff changeset
1128
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
1129 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
1130 btn.connect('clicked', self.doRun)
1147
5cfa73d7e80f Add the Run button to simulate the animation
wycc
parents: 1146
diff changeset
1131 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
1132 hbox.pack_start(btn,expand=False,fill=False)
1174
96a7abce774a Add functions to insert and remove frame.
wycc
parents: 1171
diff changeset
1133
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
1134 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
1135 self.addTweenTypeSelector(hbox)
956
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
1136 pass
1144
257beac7c982 Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents: 1142
diff changeset
1137
1150
6586cd10c92f Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents: 1149
diff changeset
1138 def onTweenTypeChange(self, w):
6586cd10c92f Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents: 1149
diff changeset
1139 if self._disable_tween_type_selector:
6586cd10c92f Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents: 1149
diff changeset
1140 return
6586cd10c92f Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents: 1149
diff changeset
1141
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
1142 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
1143 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
1144 frameline = self.last_line
1159
e731a0eaa35f Fix issue of chagne tween type when there is more than one tween block.
Thinker K.F. Li <thinker@codemud.net>
parents: 1157
diff changeset
1145 idx = self.last_frame
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
1146 i = 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
1147 found = -1
1150
6586cd10c92f Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents: 1149
diff changeset
1148 for start_idx, stop_idx, tween_type in frameline.get_frame_blocks():
1159
e731a0eaa35f Fix issue of chagne tween type when there is more than one tween block.
Thinker K.F. Li <thinker@codemud.net>
parents: 1157
diff changeset
1149 if start_idx <= idx and stop_idx >= idx:
1150
6586cd10c92f Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents: 1149
diff changeset
1150 n = self.tweenTypeSelector.get_active()
1151
71c72e8d6755 Refactory cod eof TweenObject.updateTweenContent and MBScene.setCurrentScene().
Thinker K.F. Li <thinker@codemud.net>
parents: 1150
diff changeset
1151 new_tween_type = MBScene._frameline_tween_types[n]
1150
6586cd10c92f Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents: 1149
diff changeset
1152 self.last_line.set_tween_type(start_idx, new_tween_type)
1182
8b0e5e8a6b0c Rename MBScene.update() to update_scenes_of_dom()
Thinker K.F. Li <thinker@codemud.net>
parents: 1181
diff changeset
1153 self.update_scenes_of_dom()
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
1154 break
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
1155 pass
1144
257beac7c982 Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents: 1142
diff changeset
1156 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
1157
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
1158 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
1159 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
1160 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
1161 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
1162
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.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
1164 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
1165 #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
1166 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
1167 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
1168 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
1169 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
1170 self.tweenTypeSelector.connect('changed', self.onTweenTypeChange)
1144
257beac7c982 Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents: 1142
diff changeset
1171 pass
956
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
1172
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
1173 def onQuit(self, event):
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
1174 self.OK = False
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
1175 gtk.main_quit()
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
1176 pass
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
1177
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
1178 def onOK(self,event):
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
1179 self.OK = True
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
1180 gtk.main_quit()
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
1181 pass
941
9ba94c577a6f Add scene editor. This vewrsion can only switch scene. It can not change the scene yet.
wycc
parents:
diff changeset
1182
1191
6442fb198418 Refactory insertKeyScene() and fix bug of ObjectWatcher
Thinker K.F. Li <thinker@codemud.net>
parents: 1190
diff changeset
1183 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
1184 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
1185
d73ef03c96de Refactory code of MBScene.updateUI() from MBScene.show()
Thinker K.F. Li <thinker@codemud.net>
parents: 1164
diff changeset
1186 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
1187 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
1188 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
1189
1144
257beac7c982 Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents: 1142
diff changeset
1190 pass
257beac7c982 Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents: 1142
diff changeset
1191
1130
37a0f6ab2f91 Lock the UI from refreshing during the update procedure
wycc
parents: 1128
diff changeset
1192 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
1193 self._lockui = True
1166
d73ef03c96de Refactory code of MBScene.updateUI() from MBScene.show()
Thinker K.F. Li <thinker@codemud.net>
parents: 1164
diff changeset
1194 self.parseScene()
d73ef03c96de Refactory code of MBScene.updateUI() from MBScene.show()
Thinker K.F. Li <thinker@codemud.net>
parents: 1164
diff changeset
1195 self._create_framelines()
d73ef03c96de Refactory code of MBScene.updateUI() from MBScene.show()
Thinker K.F. Li <thinker@codemud.net>
parents: 1164
diff changeset
1196 self._update_framelines()
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
1197 self._lockui = False
1144
257beac7c982 Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents: 1142
diff changeset
1198 pass
257beac7c982 Add blank line between methods.
Thinker K.F. Li <thinker@codemud.net>
parents: 1142
diff changeset
1199
956
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
1200 def show(self):
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
1201 self.OK = True
1149
0ffef2df6201 Rename MBScene.dom to MBScene.root
Thinker K.F. Li <thinker@codemud.net>
parents: 1148
diff changeset
1202 if not self.root:
0ffef2df6201 Rename MBScene.dom to MBScene.root
Thinker K.F. Li <thinker@codemud.net>
parents: 1148
diff changeset
1203 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
1204 pass
0ffef2df6201 Rename MBScene.dom to MBScene.root
Thinker K.F. Li <thinker@codemud.net>
parents: 1148
diff changeset
1205
1128
b65ac686a7c5 Switch to the DOM-like API. The SPObject become the base of the DOM-like API.
wycc
parents: 1125
diff changeset
1206 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
1207 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
1208 self.tween = TweenObject(self.document, self.root)
1166
d73ef03c96de Refactory code of MBScene.updateUI() from MBScene.show()
Thinker K.F. Li <thinker@codemud.net>
parents: 1164
diff changeset
1209 self._updateUI()
1064
16c69756ef5d Add NodeObserver to monitor the change of the layer and update it in the scene editor.
wycc
parents: 1032
diff changeset
1210 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
1211 self.top = gtk.VBox(False,0)
16c69756ef5d Add NodeObserver to monitor the change of the layer and update it in the scene editor.
wycc
parents: 1032
diff changeset
1212 self.desktop.getToplevel().child.child.pack_end(self.top,expand=False)
16c69756ef5d Add NodeObserver to monitor the change of the layer and update it in the scene editor.
wycc
parents: 1032
diff changeset
1213 else:
16c69756ef5d Add NodeObserver to monitor the change of the layer and update it in the scene editor.
wycc
parents: 1032
diff changeset
1214 self.top.remove(self.startWindow)
1150
6586cd10c92f Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents: 1149
diff changeset
1215 pass
6586cd10c92f Refactory frameline.py
Thinker K.F. Li <thinker@codemud.net>
parents: 1149
diff changeset
1216
981
9e7865906bfc Add MadButterfly name space
wycc
parents: 980
diff changeset
1217 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
1218 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
1219 self.top.pack_start(vbox,expand=False)
981
9e7865906bfc Add MadButterfly name space
wycc
parents: 980
diff changeset
1220 vbox.pack_start(self.scrollwin,expand=False)
9e7865906bfc Add MadButterfly name space
wycc
parents: 980
diff changeset
1221 hbox=gtk.HBox(False,0)
9e7865906bfc Add MadButterfly name space
wycc
parents: 980
diff changeset
1222 self.addButtons(hbox)
9e7865906bfc Add MadButterfly name space
wycc
parents: 980
diff changeset
1223 vbox.pack_start(hbox,expand=False)
9e7865906bfc Add MadButterfly name space
wycc
parents: 980
diff changeset
1224
1064
16c69756ef5d Add NodeObserver to monitor the change of the layer and update it in the scene editor.
wycc
parents: 1032
diff changeset
1225 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
1226 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
1227 return False
956
167e359c9d5b Re-indent MBScene.py
Thinker K.F. Li <thinker@codemud.net>
parents: 955
diff changeset
1228 pass