ModificationPull working
This commit is contained in:
parent
d59857ab2b
commit
9d31fd8113
@ -43,22 +43,7 @@ let Styles = {
|
||||
`
|
||||
};
|
||||
|
||||
let ModificationPull = (inModifier) =>
|
||||
{
|
||||
let getDAG = inModifier => N.Step(inModifier, "ModifyAt")[0];
|
||||
let getMod = inBranch => N.Step(inBranch, "ModifyAt", false)[0];
|
||||
let collect = inArray => n => n.Meta.Tweak.forEach((t, i)=>inArray[i] += t;);
|
||||
|
||||
let dag = getDAG(inModifier);
|
||||
let totalScale = [];
|
||||
let totalAdd = [];
|
||||
|
||||
N.ID.Walk++;
|
||||
N.Walk(collect(totalScale), dag, "ModifyDown", false);
|
||||
N.Walk(collect(totalScale), dag, "ModifyAt", false);
|
||||
N.Walk(collect(totalAdd), dag, "ModifyUp", false);
|
||||
N.Walk(collect(totalAdd), dag, "ModifyOut", false);
|
||||
};
|
||||
|
||||
let PivotForm = props =>
|
||||
{
|
||||
|
126
index.html
126
index.html
@ -168,6 +168,35 @@ var N =
|
||||
};
|
||||
</script>
|
||||
|
||||
<!-- calc testing -->
|
||||
<script>
|
||||
let ModificationPull = (inDAG) =>
|
||||
{
|
||||
let collect = inArray => n => { n.Meta.Tweak.forEach((t, i)=>{ inArray[n.Meta.Indicies[i]] += t; }); };
|
||||
let totalScale = [0, 0, 0, 0, 0, 0, 0, 0];
|
||||
let totalAdd = [0, 0, 0, 0, 0, 0, 0, 0];
|
||||
|
||||
N.ID.Walk++;
|
||||
N.Walk(collect(totalScale), inDAG, "ModifyAt", false);
|
||||
N.Walk(collect(totalScale), inDAG, "ModifyDown", false);
|
||||
N.Walk(collect(totalAdd), inDAG, "ModifyUp", false);
|
||||
N.Walk(collect(totalAdd), inDAG, "ModifyOut", false);
|
||||
|
||||
return [totalScale, totalAdd];
|
||||
};
|
||||
|
||||
let dag1 = N.Create({Label:"dag-1"});
|
||||
let m0 = N.Create({Label:"m-0", Tweak:[-1, 2, 0.7], Indicies:[0, 1, 2]});
|
||||
let m1 = N.Create({Label:"m-1", Tweak:[0.1, 0.1, 0.1], Indicies:[1, 2, 3]});
|
||||
|
||||
N.Connect(m0, dag1, "ModifyAt");
|
||||
N.Connect(m1, dag1, "ModifyDown");
|
||||
|
||||
let results = ModificationPull(dag1);
|
||||
console.log(results);
|
||||
|
||||
</script>
|
||||
|
||||
<script>
|
||||
var Pivot =
|
||||
{
|
||||
@ -378,108 +407,15 @@ Pivot.Init(
|
||||
]
|
||||
);
|
||||
|
||||
let ElNode = ({node, depth}) =>
|
||||
{
|
||||
let nodeBase = css`
|
||||
position:relative;
|
||||
padding:0;
|
||||
margin:0;
|
||||
border-top:1px solid lightgrey;
|
||||
|
||||
.Table
|
||||
{
|
||||
display:inline-block;
|
||||
text-align:right;
|
||||
}
|
||||
.Cell
|
||||
{
|
||||
width:50px;
|
||||
display:inline-block;
|
||||
padding:10px;
|
||||
}
|
||||
`;
|
||||
let label = css`
|
||||
display:inline-block;
|
||||
width:200px;
|
||||
|
||||
&::before
|
||||
{
|
||||
content:" ";
|
||||
display:inline-block;
|
||||
width:${depth*15}px;
|
||||
}
|
||||
.Modify
|
||||
{
|
||||
float:right;
|
||||
}
|
||||
`;
|
||||
|
||||
let icon = cx(
|
||||
{
|
||||
[css`
|
||||
display:inline-block;
|
||||
width:0px;
|
||||
height:0px;
|
||||
border:7px solid white;` ]: true,
|
||||
[css`border-bottom-color:lightblue;`]: N.Step(node, "ModifyUp" ),
|
||||
[css`border-top-color:orange;` ]: N.Step(node, "ModifyDown"),
|
||||
[css`border-left-color:grey;` ]: N.Step(node, "ModifyOut" ),
|
||||
[css`border-right-color:red;` ]: N.Step(node, "ModifyAt" )
|
||||
},
|
||||
);
|
||||
|
||||
let buttonModify = h("span", {
|
||||
className:"Icon Modify Add",
|
||||
onClick:e=>
|
||||
{
|
||||
Pivot.Modify(node);
|
||||
Render();
|
||||
}
|
||||
}, "Modify");
|
||||
|
||||
let buttonUnmodify = h("span", {
|
||||
className:"Icon Modify remove",
|
||||
onClick:e=>
|
||||
{
|
||||
Pivot.Unmodify(N.Step(node, "ModifyAt", false)[0]);
|
||||
Render();
|
||||
}
|
||||
}, "Unmodify");
|
||||
|
||||
let children = N.Step(node, "Hierarchy");
|
||||
let childrenDisplay = {};
|
||||
if(children.length)
|
||||
{
|
||||
childrenDisplay = h("div", {className:"Nodes"}, N.Step(node, "Hierarchy").map(child=>h(ElNode, {node:child, depth:depth+1})) );
|
||||
}
|
||||
else
|
||||
{
|
||||
childrenDisplay = h("div", {className:"Nodes Leaf"}, N.Step(node, "Leaf").map(child=>h(ElNode, {node:child, depth:depth+1})) );
|
||||
}
|
||||
|
||||
return h("div", {className:"Node"}, [
|
||||
h("div", {className:cx(nodeBase, "Upper")}, [
|
||||
h("div", {className:label}, [
|
||||
h("span", {className:"Icon Expand"}),
|
||||
h("span", {className:"Name"}, (node.Meta.Label || "a node")+" "+node.ID.Walk),
|
||||
h("span", {className: icon}),
|
||||
N.Step(node, "ModifyAt") ? buttonUnmodify : buttonModify
|
||||
] ),
|
||||
h("div", {className:"Table"}, (node.Meta.Row || []).map( cell => h("div", {className:"Cell"}, cell)) )
|
||||
]),
|
||||
childrenDisplay
|
||||
]);
|
||||
};
|
||||
|
||||
let ElRoot = props =>
|
||||
{
|
||||
let pivots = N.Step(Pivot.Root, "Pivot")||[];
|
||||
return h("div", null, [
|
||||
h(PivotForm),
|
||||
pivots.map(pivot=>h(PivotRoot, {key:pivot.Meta.Label, pivot}, h(ElNode, {node:pivot, depth:0})))
|
||||
pivots.map(pivot=>h(PivotRoot, {key:pivot.Meta.Label, pivot}))
|
||||
])
|
||||
};
|
||||
Render = () => render(h(ElRoot), document.querySelector("#app"));
|
||||
Render();
|
||||
|
||||
</script>
|
||||
</script>
|
Loading…
Reference in New Issue
Block a user