Skip to content

Commit

Permalink
Fixed save and load behaviour.
Browse files Browse the repository at this point in the history
  • Loading branch information
malloch committed Nov 24, 2019
1 parent bd36d44 commit 62ea161
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 11 deletions.
4 changes: 2 additions & 2 deletions js/Database.js
Original file line number Diff line number Diff line change
Expand Up @@ -731,8 +731,8 @@ function MapperDatabase() {
map.muted = c.mute ? true : false;
if (c.expression != null)
map.expression = c.expression.replace('s[', 'src[')
.replace('d[', 'dst[')
.replace('dest[', 'dst[');
.replace('d[', 'dst[')
.replace('dest[', 'dst[');
if (c.srcMin != null)
src.min = c.srcMin;
if (c.srcMax != null)
Expand Down
7 changes: 2 additions & 5 deletions js/MapProperties.js
Original file line number Diff line number Diff line change
Expand Up @@ -420,12 +420,9 @@ class MapProperties {
msg['mode'] = 'expression';
}

// copy src and dst names
msg['srcs'] = map.srcs.map(s => s.signal.key);
msg['dst'] = map.dst.signal.key;

// send the command, should receive a /mapped message after.
command.send("set_map", msg);
command.send("set_map", [map.srcs.map(s => s.signal.key),
map.dst.signal.key, msg]);
});
}

Expand Down
30 changes: 26 additions & 4 deletions webmapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,15 +229,28 @@ def as_number(value):
value = value[0]
return value

def set_map_properties(props, map):
def set_map_properties(args, map):
srckeys, dstkey, props = args
if not map:
map = find_map(props['srcs'], props['dst'])
map = find_map(srckeys, dstkey)
if not map:
print "error: couldn't retrieve map ", props['src'], " -> ", props['dst']
print "error: couldn't retrieve map ", srckeys, " -> ", dstkey
return
for key in props:
if key in ['version']:
continue;
elif key == 'srcs':
srcs = props[key]
srcidx = 0
for src in srcs:
for subkey in src:
value = src[subkey]
if subkey == 'min' or subkey == 'max':
value = as_number(value)
elif subkey == 'bound_min' or subkey == 'bound_max':
value = boundaryStrings[value]
map.source(srcidx).set_property(subkey, value)
srcidx += 1
elif key.startswith('src'):
srcidx = -1
argidx = -1
Expand All @@ -256,6 +269,15 @@ def set_map_properties(props, map):
elif subkey == 'bound_min' or subkey == 'bound_max':
value = boundaryStrings[value]
map.source(srcidx).set_property(subkey, value)
elif key == 'dst':
dst = props[key]
for subkey in dst:
value = dst[subkey]
if subkey == 'min' or subkey == 'max':
value = as_number(value)
elif subkey == 'bound_min' or subkey == 'bound_max':
value = boundaryStrings[value]
map.destination().set_property(subkey, value)
elif key.startswith('dst.'):
subkey = key[4:]
value = props[key]
Expand Down Expand Up @@ -359,7 +381,7 @@ def new_map(args):
else:
print 'created map: ', srckeys, ' -> ', dstkey
if props and type(props) is dict:
set_map_properties(props, map)
set_map_properties(args, map)
map.push()

def release_map(args):
Expand Down

0 comments on commit 62ea161

Please sign in to comment.