modifier-form #8

Merged
SethTrowbridge merged 11 commits from modifier-form into master 2021-05-29 17:11:18 -04:00
Showing only changes of commit 30ac8d0d00 - Show all commits

View File

@ -148,11 +148,20 @@ var N =
if(next.ID.Walk !== N.ID.Walk) if(next.ID.Walk !== N.ID.Walk)
{ {
next.ID.Walk = N.ID.Walk; next.ID.Walk = N.ID.Walk;
//console.log("processing", next.Meta)
let results = inIterator(next); let results = inIterator(next);
if(results !== false) if(results !== false)
{ {
N.Walk(inIterator, next, inKey, inForward, inTerminal); N.Walk(inIterator, next, inKey, inForward, inTerminal);
} }
else
{
//console.log("routine exited");
}
}
else
{
//console.log("id collision");
} }
} }
}, },
@ -198,7 +207,11 @@ var Pivot =
// - optional traversal depth, defaults to 0 // - optional traversal depth, defaults to 0
let depth = inDepth||0; let depth = inDepth||0;
let uniques = {}; let uniques = {};
let indexPivot = inPivotIndicies[depth] let indexPivot = inPivotIndicies[depth];
if(!inParent.Meta.Leaves)
{
console.log("problem")
}
inParent.Meta.Leaves.forEach((inLeaf)=> inParent.Meta.Leaves.forEach((inLeaf)=>
{ {
let row = inLeaf.Meta.Row; // shorthand for the raw "CSV" row in the leaf Node's Meta let row = inLeaf.Meta.Row; // shorthand for the raw "CSV" row in the leaf Node's Meta
@ -233,8 +246,9 @@ var Pivot =
match.Leaves.push(inLeaf); match.Leaves.push(inLeaf);
}); });
// get the leaves out of the parent, at this point they have been re-distributed to the children
delete inParent.Meta.Leaves; delete inParent.Meta.Leaves;
var iterator; let iterator = () => {};
if(depth >= inPivotIndicies.length-1) if(depth >= inPivotIndicies.length-1)
{ {
iterator = inLastBranch => iterator = inLastBranch =>
@ -244,11 +258,15 @@ var Pivot =
// collect modifiers effecting leaves // collect modifiers effecting leaves
let modifiers = []; let modifiers = [];
let collectModifier = n => modifiers.push(n); let collectModifier = n => modifiers.push(n);
let connectModifiers = n => modifiers.forEach(inModifier => N.Connect(inModifier, n, "ModifyOut", true)); let connectModifiers = n =>
{
modifiers.forEach(inModifier => N.Connect(inModifier, n, "ModifyOut", true));
};
N.Walk(collectModifier, inLeaf, "ModifyAt", false); N.Walk(collectModifier, inLeaf, "ModifyAt", false);
N.Walk(collectModifier, inLeaf, "ModifyDown", false); N.Walk(collectModifier, inLeaf, "ModifyDown", false);
if(modifiers.length) if(modifiers.length)
{ {
// apply them to the branch // apply them to the branch
@ -256,20 +274,38 @@ var Pivot =
connectModifiers(inLastBranch); connectModifiers(inLastBranch);
// also walk them up and connect, but with "check unique" enabled // also walk them up and connect, but with "check unique" enabled
console.log("walking modifiers up from", inLastBranch.Meta.Label);
N.ID.Walk++;
N.Walk(connectModifiers, inLastBranch, "Hierarchy", false); N.Walk(connectModifiers, inLastBranch, "Hierarchy", false);
/*
N.Walk((n)=>
{
console.log("going up", n);
}
, inLastBranch, "Hierarchy", false);
*/
} }
// lastly connect the leaf to the branch // lastly connect the leaf to the branch
N.Connect(inLastBranch, inLeaf, "Leaf"); N.Connect(inLastBranch, inLeaf, "Leaf");
}); });
delete inLastBranch.Meta.Leaves; delete inLastBranch.Meta.Leaves;
} }
} }
else else
{ {
iterator = child => Pivot.Pivot(inRoot, child, inPivotIndicies, inSumIndicies, depth+1); iterator = child => {
if(child.Meta.Label == "b")
{
console.log("at b for some reason");
}
Pivot.Pivot(inRoot, child, inPivotIndicies, inSumIndicies, depth+1);
};
} }
N.Walk(iterator, inParent, "Hierarchy"); N.Walk(iterator, inParent, "Hierarchy");
return inParent; return inParent;
}, },
Create(inPivotIndicies, inSumIndicies) Create(inPivotIndicies, inSumIndicies)
@ -741,10 +777,19 @@ const Render = () => render(h(ElRoot), document.querySelector("#app"));
Render(); Render();
Pivot.Create([1, 2], [3, 4]);
let pivot = N.Path([0], Pivot.Root, "Pivot");
let node = N.Path([0, 1], pivot, "Hierarchy");
Pivot.Modify(node);
Pivot.Create([2, 1], [3, 4]);
Render();
</script> </script>
<!-- testing area --> <!-- testing area -->
<script> <script>
/*
let ModificationPull = (inDAG) => let ModificationPull = (inDAG) =>
{ {
let collect = inArray => n => { n.Meta.Tweak.forEach((t, i)=>{ inArray[n.Meta.Indicies[i]] += t; }); }; let collect = inArray => n => { n.Meta.Tweak.forEach((t, i)=>{ inArray[n.Meta.Indicies[i]] += t; }); };
@ -769,5 +814,6 @@ Render();
let results = ModificationPull(dag1); let results = ModificationPull(dag1);
console.log(results); console.log(results);
*/
</script> </script>