forked from enviPath/enviPy
Compare commits
12 Commits
9aa52e1bbe
...
66129f676d
| Author | SHA1 | Date | |
|---|---|---|---|
| 66129f676d | |||
| 90932d02a0 | |||
| 6d4c99e8eb | |||
| fe4da5518d | |||
| f2dcb249c3 | |||
| f4c3b42be8 | |||
| 4b9bf94943 | |||
| 8839626255 | |||
| d0c52b51ee | |||
| c045b0680c | |||
| 17ae593d95 | |||
| 6ab9180291 |
@ -101,10 +101,24 @@ function draw(pathway, elem) {
|
|||||||
// Update pseudo node positions first
|
// Update pseudo node positions first
|
||||||
updatePseudoNodePositions();
|
updatePseudoNodePositions();
|
||||||
|
|
||||||
link.attr("x1", d => d.source.x)
|
link.attr("d", d => {
|
||||||
.attr("y1", d => d.source.y)
|
// Check if it's a self-loop (source equals target)
|
||||||
.attr("x2", d => d.target.x)
|
if (d.source.id === d.target.id) {
|
||||||
.attr("y2", d => d.target.y);
|
// Create a bezier curve for self-loops
|
||||||
|
const x = d.source.x;
|
||||||
|
const y = d.source.y;
|
||||||
|
const loopRadius = nodeRadius * 2; // Adjust size of the loop
|
||||||
|
|
||||||
|
// Create a circular path to the left of the node
|
||||||
|
return `M ${x},${y - nodeRadius}
|
||||||
|
C ${x - loopRadius},${y - nodeRadius - loopRadius}
|
||||||
|
${x - loopRadius},${y + nodeRadius + loopRadius}
|
||||||
|
${x},${y + nodeRadius}`;
|
||||||
|
} else {
|
||||||
|
// Regular straight line for normal edges
|
||||||
|
return `M ${d.source.x},${d.source.y} L ${d.target.x},${d.target.y}`;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
node.attr("transform", d => `translate(${d.x},${d.y})`);
|
node.attr("transform", d => `translate(${d.x},${d.y})`);
|
||||||
}
|
}
|
||||||
@ -599,16 +613,21 @@ function draw(pathway, elem) {
|
|||||||
|
|
||||||
// Kanten zeichnen
|
// Kanten zeichnen
|
||||||
const link = zoomable.append("g")
|
const link = zoomable.append("g")
|
||||||
.selectAll("line")
|
.selectAll("path")
|
||||||
.data(links)
|
.data(links)
|
||||||
.enter().append("line")
|
.enter().append("path")
|
||||||
// Check if target is pseudo and draw marker only if not pseudo
|
// Check if target is pseudo and draw marker only if not pseudo
|
||||||
.attr("class", d => d.target.pseudo ? "link_no_arrow" : "link")
|
.attr("class", d => d.target.pseudo ? "link_no_arrow" : "link")
|
||||||
.attr("marker-end", d => d.target.pseudo ? '' : d.multi_step ? 'url(#doublearrow)' : 'url(#arrow)')
|
.attr("marker-end", d => {
|
||||||
.on("click", function(event, d) {
|
if (d.target.pseudo) return '';
|
||||||
|
if (d.source.id === d.target.id) return 'url(#curve-arrow)'; // Use curve arrow for self-loops
|
||||||
|
return d.multi_step ? 'url(#doublearrow)' : 'url(#arrow)';
|
||||||
|
})
|
||||||
|
.attr("fill", "none")
|
||||||
|
.on("click", function(event, d) {
|
||||||
const wasHighlighted = d3.select(this).classed("highlighted");
|
const wasHighlighted = d3.select(this).classed("highlighted");
|
||||||
|
|
||||||
d3.selectAll("line").classed("highlighted", false);
|
d3.selectAll("path").classed("highlighted", false);
|
||||||
|
|
||||||
if (!wasHighlighted) {
|
if (!wasHighlighted) {
|
||||||
const toHighlight = [];
|
const toHighlight = [];
|
||||||
@ -616,13 +635,13 @@ function draw(pathway, elem) {
|
|||||||
|
|
||||||
if (d.source.pseudo || d.target.pseudo) {
|
if (d.source.pseudo || d.target.pseudo) {
|
||||||
if (d.target.pseudo) {
|
if (d.target.pseudo) {
|
||||||
d3.selectAll("line").each(e => {
|
d3.selectAll("path").each(e => {
|
||||||
if (e !== undefined && e.source.id === d.target.id) {
|
if (e !== undefined && e.source.id === d.target.id) {
|
||||||
toHighlight.push(e.el);
|
toHighlight.push(e.el);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
d3.selectAll("line").each(e => {
|
d3.selectAll("path").each(e => {
|
||||||
if (e !== undefined && (e.target.id === d.source.id || e.source.id === d.source.id)) {
|
if (e !== undefined && (e.target.id === d.source.id || e.source.id === d.source.id)) {
|
||||||
toHighlight.push(e.el);
|
toHighlight.push(e.el);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5,8 +5,8 @@
|
|||||||
class="modal"
|
class="modal"
|
||||||
x-data="modalForm({ state: { selectedEdge: '', imageUrl: '' } })"
|
x-data="modalForm({ state: { selectedEdge: '', imageUrl: '' } })"
|
||||||
@modal-opened.window="
|
@modal-opened.window="
|
||||||
const links = d3.selectAll('line.highlighted');
|
const links = d3.selectAll('path.highlighted');
|
||||||
console.log(links);
|
|
||||||
if (!links.empty()) {
|
if (!links.empty()) {
|
||||||
const el = links.node();
|
const el = links.node();
|
||||||
const selectElement = document.getElementById('delete_pathway_edge_edges');
|
const selectElement = document.getElementById('delete_pathway_edge_edges');
|
||||||
|
|||||||
@ -367,6 +367,18 @@
|
|||||||
>
|
>
|
||||||
<path d="M 0 0 L 10 5 L 0 10 z" fill="#999" />
|
<path d="M 0 0 L 10 5 L 0 10 z" fill="#999" />
|
||||||
</marker>
|
</marker>
|
||||||
|
<marker
|
||||||
|
id="curve-arrow"
|
||||||
|
viewBox="0 0 10 10"
|
||||||
|
refX="10"
|
||||||
|
refY="5"
|
||||||
|
markerWidth="6"
|
||||||
|
markerHeight="6"
|
||||||
|
orient="auto"
|
||||||
|
markerUnits="strokeWidth"
|
||||||
|
>
|
||||||
|
<path d="M 0 0 L 10 5 L 0 10 z" fill="#999" />
|
||||||
|
</marker>
|
||||||
<marker
|
<marker
|
||||||
id="doublearrow"
|
id="doublearrow"
|
||||||
viewBox="0 0 20 30"
|
viewBox="0 0 20 30"
|
||||||
|
|||||||
Reference in New Issue
Block a user