Skip to content

Commit

Permalink
render nav lines if needed
Browse files Browse the repository at this point in the history
  • Loading branch information
KlausSchaefers committed Aug 1, 2023
1 parent 7921ab0 commit c7ef174
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 11 deletions.
20 changes: 13 additions & 7 deletions src/canvas/Lines.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ export default {
bendFactorX : 0.5,
bendFactorY : 0.5,
lineEventType :"receives", // emits
lineFromCorrect: 1
lineFromCorrect: 1,
renderNavLines: false,
}
},
components: {},
Expand Down Expand Up @@ -94,7 +95,7 @@ export default {
/**
* create new line
*/
const svg = this.drawLine(line.id, layoutedLine);
const svg = this.drawLine(line.id, layoutedLine, line.style);
this.lineSVGs[line.id] = svg;
/**
Expand All @@ -114,7 +115,7 @@ export default {
/**
* update line
*/
const svg = this.lineSVGs[line.id];
const svg = this.lineSVGs[line.id];
svg.attr("d", this.lineFunction(layoutedLine));
if (this.mode === "edit") {
Expand Down Expand Up @@ -502,8 +503,8 @@ export default {
},
drawLine (id, line){
return this.drawSVGLine(id, line,this.defaultLineColor, this.defaultLineWidth, 1);
drawLine (id, line, style){
return this.drawSVGLine(id, line,this.defaultLineColor, this.defaultLineWidth, 1, style);
},
drawSVGLineWidthArrow (id, line, color, width, op) {
Expand All @@ -512,14 +513,14 @@ export default {
.attr("d", this.lineFunction(line))
.attr("stroke", color)
.attr("stroke-width", width )
.attr("fill", "none")
.attr("fill", "none")
.style("opacity", op);
return line
},
drawSVGLine (id, line, color, width, op){
drawSVGLine (id, line, color, width, op, style){
this.svg.append("defs").append("marker")
.attr("id", "arrowhead_"+id)
Expand All @@ -542,6 +543,11 @@ export default {
.style("opacity", op)
.attr("marker-end", "url(#" + "arrowhead_"+id +")");
if (style === 'dashed') {
lineGraph.attr("stroke-dasharray", 4)
}
return lineGraph;
},
Expand Down
39 changes: 35 additions & 4 deletions src/canvas/RenderFlow.vue
Original file line number Diff line number Diff line change
Expand Up @@ -28,32 +28,61 @@ export default {
}
for (let id in zoomedModel.screens){
let zoomedScreen = zoomedModel.screens[id]
const zoomedScreen = zoomedModel.screens[id]
this.updateScreenDnd(zoomedScreen)
this.updateCommentDnd(zoomedScreen)
}
for (let id in zoomedModel.widgets){
let zoomedWidget = zoomedModel.widgets[id]
const zoomedWidget = zoomedModel.widgets[id]
if (zoomedWidget && this.widgetDivs[id]) {
let dnd = this.widgetDivs[id]
const dnd = this.widgetDivs[id]
this.updateBox(zoomedWidget, dnd)
}
}
if (this.renderLines){
for (let id in zoomedModel.lines){
let line = zoomedModel.lines[id];
const line = zoomedModel.lines[id];
if (!line.hidden){
this.renderLine(line);
}
}
this._renderNavigationLines(zoomedModel)
}
this._updateDNDRendered = true
},
_renderNavigationLines (zoomedModel) {
if (!this.renderNavLines) {
return
}
for (let id in zoomedModel.widgets){
const zoomedWidget = zoomedModel.widgets[id]
if (zoomedWidget.props?.navigation) {
const navigation = zoomedWidget.props.navigation
for (let i=0; i < navigation.length; i++) {
const item = navigation[i]
if (item.to) {
const tempLine = {
id: i +'@' + zoomedWidget.id,
from: zoomedWidget.id,
to: item.to,
style: 'dashed',
points:[]
}
this.renderLine(tempLine);
}
}
}
}
},
afterUpdateDnd () {
// can be implemented in child classes
},
Expand Down Expand Up @@ -149,6 +178,8 @@ export default {
this.renderLine(zoomedModel.lines[id]);
}
}
this._renderNavigationLines(zoomedModel)
}
/**
Expand Down

0 comments on commit c7ef174

Please sign in to comment.