# HG changeset patch # User Thinker K.F. Li # Date 1302071854 -28800 # Node ID 036f2b447860b2d7b640dae99810013ce311dba0 # Parent b8dfa491ed9d6bc9132d849bbcad6e4a3de89695# Parent 5dd46a4f6257d34dffb44b5ab00bccc0acfded8c Merge diff -r b8dfa491ed9d -r 036f2b447860 nodejs/component.js --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/nodejs/component.js Wed Apr 06 14:37:34 2011 +0800 @@ -0,0 +1,118 @@ +var mbfly = require("mbfly"); +var svg = require("./svg"); +var sys=require("sys"); +/* +The Component and ComponentManager is used to keep track of the symbol +table in different frame. + + +*/ +function mul(a,b) +{ + var m = [a[0]*b[0]+a[1]*b[3], a[0]*b[1]+a[1]*b[4], a[0]*b[2]+a[1]*b[5]+a[2], + a[3]*b[0]+a[4]*b[3], a[3]*b[1]+a[4]*b[4], a[3]*b[2]+a[4]*b[5]+a[5]]; + a[0] = m[0]; + a[1] = m[1]; + a[2] = m[2]; + a[3] = m[3]; + a[4] = m[4]; + a[5] = m[5]; +} + +function Component(app, name) { + this.app = app; + this.name = name; + this.coord = null; +} + +Component.prototype.translate=function(tx,ty) { + if (this.coord) { + mul(this.coord, [1,0,tx,0,1,ty]); + } +} + +Component.prototype.resize=function(sx,sy) { + + if (this.coord) { + mul(this.coord, [sx,0,0,0,sy,0]); + } +} + +Component.prototype.set=function(m) { + + if (this.coord) { + this.coord[0] = m[0]; + this.coord[1] = m[1]; + this.coord[2] = m[2]; + this.coord[3] = m[3]; + this.coord[4] = m[4]; + this.coord[5] = m[5]; + } +} +Component.prototype.hide=function(m) { + if (this.coord) { + this.coord.hide(); + } +} + +Component.prototype.show=function(m) { + if (this.coord) { + this.coord.show(); + } +} + +Component.prototype.search=function() { + this.coord = this.app._componentmanager.search(this.name); +} + +Component.prototype.realize=function() { + if (this.coord == null) { + this.search(); + } + return this.coord; +} + +Component.prototype.toCoord=function() { + return this.coord; +} + + +function ComponentManager(app) +{ + this.app = app; + this.object_table = {}; +} + +/* \brief add an object into the current current component table. + * This first argument is the source node of the screen object. + * The second argument is the coord object which is displayed at + * the screen now. + * + * We need to use the soucer node to get the name of the object. + */ +ComponentManager.prototype.add=function(source,obj) { + if (source.refid==undefined) { + sys.puts("Internal Error: no refid is defined\n"); + return; + } + this.object_table[source.refid] = obj; +} + + +ComponentManager.prototype.del=function(name) { + delete this.object_table[name]; +} + +ComponentManager.prototype.dump=function(name) { + for(i in this.object_table) { + sys.puts(i); + } +} + +ComponentManager.prototype.search=function(name) { + return this.object_table[name]; +} + + +exports.Component = Component; +exports.ComponentManager = ComponentManager; diff -r b8dfa491ed9d -r 036f2b447860 nodejs/coord.cc --- a/nodejs/coord.cc Wed Apr 06 11:14:15 2011 +0800 +++ b/nodejs/coord.cc Wed Apr 06 14:37:34 2011 +0800 @@ -81,6 +81,7 @@ FOR_COORDS_PREORDER(coord, child) { child_hdl = (Persistent *)mb_prop_get(&child->obj.props, PROP_JSOBJ); + if (child_hdl == NULL) continue; SET(*child_hdl, "valid", _false); WRAP(*child_hdl, NULL); child_hdl->Dispose(); @@ -90,6 +91,7 @@ FOR_COORD_SHAPES(child, mem) { mem_hdl = (Persistent *)mb_prop_get(&mem->obj.props, PROP_JSOBJ); + if (mem_hdl == NULL) continue; SET(*mem_hdl, "valid", _false); WRAP(*mem_hdl, NULL); mem_hdl->Dispose(); diff -r b8dfa491ed9d -r 036f2b447860 nodejs/examples/mce/epg.js --- a/nodejs/examples/mce/epg.js Wed Apr 06 11:14:15 2011 +0800 +++ b/nodejs/examples/mce/epg.js Wed Apr 06 14:37:34 2011 +0800 @@ -101,7 +101,9 @@ sys.puts("fetch "+ file); var u = URL.parse(url); var cachepath = 'cache/'+u.pathname; - if (isCached(cachepath,file,obj)) return; + if (isCached(cachepath,file,obj)) { + return; + } CreateDirectory(cachepath); // Fetch file from the server and convert it tyo PNG if it is not PNG format. @@ -145,6 +147,7 @@ obj.pend = obj.pend - 1; if (obj.pend == 0) { obj.onInitDone(); + sys.puts("done"); } }); @@ -159,7 +162,10 @@ for (i in cats) { c = cats[i]; httpGetFile(c['ProgramPIC'],'cat'+i+'.jpg',this); + sys.puts("this.pend="+this.pend); } + if (this.pend == 0) + this.onInitDone(); } EPG.prototype.getList=function(item,func) { diff -r b8dfa491ed9d -r 036f2b447860 nodejs/examples/mce/main.svg --- a/nodejs/examples/mce/main.svg Wed Apr 06 11:14:15 2011 +0800 +++ b/nodejs/examples/mce/main.svg Wed Apr 06 14:37:34 2011 +0800 @@ -15,981 +15,160 @@ height="1052.3622" id="svg2" version="1.1" - inkscape:version="0.48+devel r9795 custom" - sodipodi:docname="main.svg" + inkscape:version="0.48+devel r9798 custom" + sodipodi:docname="test1.svg" style="display:inline"> - - - - - - - - - - - image/svg+xml - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -