Skip to content

Commit b89aee3

Browse files
authored
Add files via upload
1 parent 27f4419 commit b89aee3

12 files changed

Lines changed: 19596 additions & 0 deletions

chemlambda-gui/cc-by-4-0.png

1.43 KB
Loading

chemlambda-gui/d3.min.js

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

chemlambda-gui/firstpart_q.txt

Lines changed: 234 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,234 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<title>Chemlambda movies productions presents:</title>
5+
<!-- <script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script>
6+
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script> -->
7+
8+
<script src="d3.min.js" charset="utf-8"></script>
9+
<script src="jquery.min.js"></script>
10+
<style>
11+
12+
13+
.link line {
14+
stroke: #696969;
15+
}
16+
17+
.link line.separator {
18+
stroke: #95A5A6;
19+
stroke-width: 2px;
20+
}
21+
22+
.node circle {
23+
stroke: #95A5A6;
24+
stroke-width: 1.5px;
25+
}
26+
27+
.node text {
28+
font: 10px sans-serif;
29+
pointer-events: none;
30+
}
31+
32+
33+
34+
</style>
35+
</head>
36+
<body style="background-color: rgb(255, 255, 255); color: rgb(255, 255, 255);"
37+
alink="#ee0000" link="#000250" vlink="#551a8b">
38+
39+
<!-- <button onclick="addNodes()">Start!</button> -->
40+
41+
42+
43+
44+
<script>
45+
var graph;
46+
function myGraph() {
47+
48+
// Add and remove elements on the graph object
49+
this.addNode = function (id, atom, size, colour) {
50+
nodes.push({"id": id, "atom": atom, "size": size, "colour": colour});
51+
update();
52+
};
53+
54+
this.removeNode = function (id) {
55+
var i = 0;
56+
var n = findNode(id);
57+
while (i < links.length) {
58+
if ((links[i]['source'] == n) || (links[i]['target'] == n)) {
59+
links.splice(i, 1);
60+
}
61+
else i++;
62+
}
63+
nodes.splice(findNodeIndex(id), 1);
64+
update();
65+
};
66+
67+
this.removeLink = function (source, target) {
68+
for (var i = 0; i < links.length; i++) {
69+
if (links[i].source.id == source && links[i].target.id == target) {
70+
links.splice(i, 1);
71+
break;
72+
}
73+
}
74+
update();
75+
};
76+
77+
this.removeallLinks = function () {
78+
links.splice(0, links.length);
79+
update();
80+
};
81+
82+
this.removeAllNodes = function () {
83+
nodes.splice(0, links.length);
84+
update();
85+
};
86+
87+
this.addLink = function (source, target, bond) {
88+
links.push({"source": findNode(source), "target": findNode(target), "bond": bond});
89+
update();
90+
};
91+
92+
var findNode = function (id) {
93+
for (var i in nodes) {
94+
if (nodes[i]["id"] === id) return nodes[i];
95+
}
96+
;
97+
};
98+
99+
var findNodeIndex = function (id) {
100+
for (var i = 0; i < nodes.length; i++) {
101+
if (nodes[i].id == id) {
102+
return i;
103+
}
104+
}
105+
;
106+
};
107+
108+
// set up the D3 visualisation in the specified element
109+
var w = 500,
110+
h = 500;
111+
112+
// var radius = d3.scale.sqrt()
113+
// .range([0, 4]);
114+
115+
var vis = d3.select("body")
116+
.append("svg:svg")
117+
.attr("width", w)
118+
.attr("height", h)
119+
.attr("id", "svg")
120+
.attr("pointer-events", "all")
121+
.attr("viewBox", "0 0 " + w + " " + h)
122+
.attr("perserveAspectRatio", "xMinYMid")
123+
.append('svg:g');
124+
125+
var force = d3.layout.force();
126+
127+
var nodes = force.nodes(),
128+
links = force.links();
129+
130+
131+
132+
var update = function () {
133+
var link = vis.selectAll("line")
134+
.data(links, function (d) {
135+
return d.source.id + "-" + d.target.id;
136+
});
137+
138+
link.enter().append("line")
139+
.style("stroke-opacity",0.4).style("fill-opacity",0.4)
140+
.attr("id", function (d) {
141+
return d.source.id + "-" + d.target.id;
142+
})
143+
.attr("stroke-width", function (d) {
144+
return (d.bond * 2 - 1) * 2 + "px";
145+
})
146+
.attr("stroke", "#FFFFFF");
147+
// #ADD8E6
148+
link.filter(function(d) { return d.bond > 1; }).append("line")
149+
// .attr("class", "separator");
150+
.attr("class", "link");
151+
// link.append("title")
152+
// .text(function (d) {
153+
// return d.value;
154+
// });
155+
link.exit().remove();
156+
157+
158+
var node = vis.selectAll("g.node")
159+
.data(nodes, function (d) {
160+
return d.id;
161+
});
162+
163+
var nodeEnter = node.enter().append("g")
164+
.attr("class", "node")
165+
.call(force.drag);
166+
167+
nodeEnter.append("svg:circle")
168+
.style("stroke-opacity",0.4).style("fill-opacity",0.8)
169+
.attr("r", function(d) { return d.size*2;})
170+
.attr("id", function (d) {
171+
return "Node;" + d.id;
172+
})
173+
.attr("class", "nodeStrokeClass")
174+
.attr("fill", function(d) { return d.colour; })
175+
// .transition()
176+
// .delay(700000)
177+
// .attr("r", 2);
178+
179+
// node.append("text")
180+
// .attr("dy", ".35em")
181+
// .attr("dx", function(d) { return (0 - ((12/4) * (d.size + 0.5 )* (d.size + 0.5)) );})
182+
// // .attr("text-anchor", "middle")
183+
// .text(function(d) { return d.atom; });
184+
185+
node.on("dblclick", function(d) { d.fixed = false; });
186+
187+
node.on("mousedown", function(d) { d.fixed = true; });
188+
189+
node.exit().remove();
190+
191+
force.on("tick", function () {
192+
193+
node.attr("transform", function (d) {
194+
return "translate(" + d.x + "," + d.y + ")";
195+
});
196+
197+
link.attr("x1", function (d) {
198+
return d.source.x;
199+
})
200+
.attr("y1", function (d) {
201+
return d.source.y;
202+
})
203+
.attr("x2", function (d) {
204+
return d.target.x;
205+
})
206+
.attr("y2", function (d) {
207+
return d.target.y;
208+
});
209+
});
210+
211+
// Restart the force layout.
212+
213+
force
214+
// .friction(.01)
215+
.charge(-20)
216+
.gravity(.38)
217+
.linkStrength(8.8)
218+
.linkDistance( function(d) { return ((d.source.size + d.target.size + 3)/(40*d.bond)); } )
219+
.size([w, h])
220+
.start();
221+
};
222+
223+
224+
// Make it all go
225+
update();
226+
}
227+
228+
229+
230+
function drawGraph() {
231+
232+
graph = new myGraph("#svgdiv");
233+
234+

chemlambda-gui/getmoves.sh

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#!/bin/sh
2+
3+
4+
printf "choose a file from the list: \n"
5+
6+
ls *.html
7+
8+
printf "> "
9+
10+
read firstarg
11+
12+
filename=${firstarg%%.*}
13+
14+
15+
16+
awk '{ sub(/^[ \t]+/, ""); print }' $firstarg > lista.txh
17+
18+
awk '/^graph\./{print}' lista.txh > lista2.txh
19+
20+
rm lista.txh
21+
22+
awk '{ sub(/\(/,","); print }' lista2.txh > lista3.txh
23+
24+
rm lista2.txh
25+
26+
awk '{ sub(/\);/,""); print }' lista3.txh > lista4.txh
27+
28+
rm lista3.txh
29+
30+
awk '{ sub(/graph\./,""); print }' lista4.txh > lista5.txh
31+
32+
rm lista4.txh
33+
34+
awk -f modifier.awk lista5.txh
35+
36+
rm lista5.txh
37+
38+
mv essy.txt universal.js
39+
40+
41+

chemlambda-gui/jquery.min.js

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

chemlambda-gui/lastpart.txt

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
2+
}
3+
4+
drawGraph();
5+
// because of the way the network is created, nodes are created first, and links second,
6+
// so the lines were on top of the nodes, this just reorders the DOM to put the svg:g on top
7+
function keepNodesOnTop() {
8+
$(".nodeStrokeClass").each(function( index ) {
9+
var gnode = this.parentNode;
10+
gnode.parentNode.appendChild(gnode);
11+
});
12+
}
13+
function addNodes() {
14+
d3.select("svg")
15+
.remove();
16+
drawGraph();
17+
}
18+
19+
20+
</script>
21+
</body>
22+
</html>

chemlambda-gui/modifier.awk

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
BEGIN {
2+
3+
FS =",";
4+
printf("function commands\(\) \{ var commandsArray = \[") > "essy.txt" ;
5+
# this variant 07.09.2019
6+
7+
8+
#
9+
# used for turning the addNode, etc, commands from a simulation into a js function (array)
10+
# I started from removing spaces at the beginning
11+
# awk '{ sub(/^[ \t]+/, ""); print }' bigpred.html > lista.txt
12+
# awk '/^graph\./{print}' lista.txt > lista2.txt
13+
# awk '{ sub(/\(/,","); print }' lista2.txt > lista3.txt
14+
# awk '{ sub(/\);/,""); print }' lista3.txt > lista4.txt
15+
# awk '{ sub(/graph\./,""); print }' lista4.txt > lista5.txt
16+
# awk -f modifier.awk lista5.txt
17+
# mv essy.txt whatever.js
18+
#
19+
20+
21+
#
22+
#
23+
#
24+
#
25+
26+
}
27+
28+
29+
{
30+
31+
32+
#
33+
34+
if ($1 == "removeLink") {
35+
36+
a="\{c:\"" "rl" "\", a:\{s:" $2 ", t:" $3 "\}\}, \n";
37+
38+
39+
}
40+
41+
if ($1 == "addLink") {
42+
43+
a="\{c:\"" "al" "\", a:\{s:" $2 ", t:" $3 ", b:" $4 "\}\}, \n";
44+
45+
}
46+
47+
if ($1 == "removeNode") {
48+
49+
a="\{c:\"" "rn" "\", a:\{i:" $2 "\}\}, \n";
50+
51+
}
52+
53+
if ($1 == "addNode") {
54+
55+
a="\{c:\"" "an" "\", a:\{i:" $2 ", a:" $3 ", si:" $4 ", co:" $5 "\}\}, \n";
56+
57+
}
58+
59+
b=a "";
60+
printf(b) >> "essy.txt";
61+
62+
63+
64+
65+
66+
}
67+
68+
END {
69+
70+
printf("\{c:\"\" , a:\{i:\"\", a:\"\", si:0, co:\"\" \}\}\]; \n return commandsArray; \n \}") >> "essy.txt";
71+
72+
73+
}
74+
75+
76+
77+
78+
79+
80+
81+
82+

0 commit comments

Comments
 (0)