Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions src/app/services/data/trainrunsection.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1486,10 +1486,19 @@ export class TrainrunSectionService implements OnDestroy {
return;
}

const backwardIterator = this.trainrunService.getBackwardIterator(
section.getTargetNode(),
section,
);
while (backwardIterator.hasNext() && backwardIterator.current().node.getIsCollapsed()) {
backwardIterator.next();
}
const startNode = backwardIterator.current().node;
const startSection = backwardIterator.current().trainrunSection;

// Build chain using TrainrunIterator to leverage existing graph traversal
const chain: TrainrunSection[] = [];
const startNode = section.getSourceNode();
const iterator = this.trainrunService.getIterator(startNode, section);
const iterator = this.trainrunService.getIterator(startNode, startSection);

// Traverse the trainrun and collect sections with collapsed intermediate nodes
while (iterator.hasNext()) {
Expand Down
44 changes: 22 additions & 22 deletions src/app/view/editor-main-view/data-views/d3.utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,21 +45,21 @@ export class D3Utils {
d3.selectAll(StaticDomTags.EDGE_LINE_ARROW_DOM_REF)
.filter(
(d: TrainrunSectionViewObject) =>
d !== undefined && d.trainrunSection.getTrainrunId() === trainrunSection.getTrainrunId(),
d !== undefined && d.getTrainrun().getId() === trainrunSection.getTrainrunId(),
)
.classed(StaticDomTags.TAG_HOVER, true);

d3.selectAll(StaticDomTags.EDGE_LINE_DOM_REF)
.filter(
(d: TrainrunSectionViewObject) =>
d !== undefined && d.trainrunSection.getTrainrunId() === trainrunSection.getTrainrunId(),
d !== undefined && d.getTrainrun().getId() === trainrunSection.getTrainrunId(),
)
.classed(StaticDomTags.TAG_HOVER, true);

d3.selectAll(StaticDomTags.EDGE_ROOT_CONTAINER_DOM_REF)
.filter(
(d: TrainrunSectionViewObject) =>
d !== undefined && d.trainrunSection.getTrainrunId() === trainrunSection.getTrainrunId(),
d !== undefined && d.getTrainrun().getId() === trainrunSection.getTrainrunId(),
)
.classed(StaticDomTags.TAG_HOVER, true);

Expand Down Expand Up @@ -90,20 +90,20 @@ export class D3Utils {
d3.selectAll(StaticDomTags.EDGE_LINE_ARROW_DOM_REF)
.filter(
(d: TrainrunSectionViewObject) =>
d !== undefined && d.trainrunSection.getTrainrunId() === trainrunSection.getTrainrunId(),
d !== undefined && d.trainrunSections[0].getTrainrunId() === trainrunSection.getTrainrunId(),
)
.classed(StaticDomTags.TAG_HOVER, false);
d3.selectAll(StaticDomTags.EDGE_LINE_DOM_REF)
.filter(
(d: TrainrunSectionViewObject) =>
d !== undefined && d.trainrunSection.getTrainrunId() === trainrunSection.getTrainrunId(),
d !== undefined && d.trainrunSections[0].getTrainrunId() === trainrunSection.getTrainrunId(),
)
.classed(StaticDomTags.TAG_HOVER, false);

d3.selectAll(StaticDomTags.EDGE_ROOT_CONTAINER_DOM_REF)
.filter(
(d: TrainrunSectionViewObject) =>
d !== undefined && d.trainrunSection.getTrainrunId() === trainrunSection.getTrainrunId(),
d !== undefined && d.trainrunSections[0].getTrainrunId() === trainrunSection.getTrainrunId(),
)
.classed(StaticDomTags.TAG_HOVER, false);

Expand Down Expand Up @@ -347,7 +347,7 @@ export class D3Utils {
if (d === undefined) {
return false;
}
return d.trainrunSection.getId() === trainrunSection.getId();
return d.trainrunSections[0].getId() === trainrunSection.getId();
})
.classed(StaticDomTags.TAG_SELECTED, false)
.classed(StaticDomTags.TAG_HOVER, false)
Expand All @@ -359,7 +359,7 @@ export class D3Utils {
if (d === undefined) {
return false;
}
return d.trainrunSection.getId() === trainrunSection.getId();
return d.trainrunSections[0].getId() === trainrunSection.getId();
})
.classed(StaticDomTags.TAG_SELECTED, false)
.classed(StaticDomTags.TAG_HOVER, false)
Expand All @@ -371,7 +371,7 @@ export class D3Utils {
if (d === undefined) {
return false;
}
return d.trainrunSection.getId() === trainrunSection.getId();
return d.trainrunSections[0].getId() === trainrunSection.getId();
})
.classed(StaticDomTags.TAG_SELECTED, false)
.classed(StaticDomTags.TAG_HOVER, false)
Expand All @@ -383,7 +383,7 @@ export class D3Utils {
if (d === undefined) {
return false;
}
return d.trainrunSection.getId() === trainrunSection.getId();
return d.trainrunSections[0].getId() === trainrunSection.getId();
})
.classed(StaticDomTags.EDGE_LINE_GRAYEDOUT, true);

Expand All @@ -394,8 +394,8 @@ export class D3Utils {
return false;
}
return (
d.trainrunSection.getId() === trainrunSection.getId() &&
d.trainrunSection.getSourceNodeId() === grayoutEdgeLinePinNode.getId()
d.trainrunSections[0].getId() === trainrunSection.getId() &&
d.trainrunSections[0].getSourceNodeId() === grayoutEdgeLinePinNode.getId()
);
})
.classed(StaticDomTags.EDGE_LINE_GRAYEDOUT, true);
Expand All @@ -405,8 +405,8 @@ export class D3Utils {
return false;
}
return (
d.trainrunSection.getId() === trainrunSection.getId() &&
d.trainrunSection.getTargetNodeId() === grayoutEdgeLinePinNode.getId()
d.trainrunSections[0].getId() === trainrunSection.getId() &&
d.trainrunSections[0].getTargetNodeId() === grayoutEdgeLinePinNode.getId()
);
})
.classed(StaticDomTags.EDGE_LINE_GRAYEDOUT, true);
Expand All @@ -419,7 +419,7 @@ export class D3Utils {
if (d === undefined) {
return false;
}
return d.trainrunSection.getId() === trainrunSection.getId();
return d.trainrunSections[0].getId() === trainrunSection.getId();
})
.classed(StaticDomTags.TAG_SELECTED, true)
.classed(StaticDomTags.TAG_HOVER, false)
Expand All @@ -431,7 +431,7 @@ export class D3Utils {
if (d === undefined) {
return false;
}
return d.trainrunSection.getId() === trainrunSection.getId();
return d.trainrunSections[0].getId() === trainrunSection.getId();
})
.classed(StaticDomTags.TAG_SELECTED, true)
.classed(StaticDomTags.TAG_HOVER, false)
Expand All @@ -443,7 +443,7 @@ export class D3Utils {
if (d === undefined) {
return false;
}
return d.trainrunSection.getId() === trainrunSection.getId();
return d.trainrunSections[0].getId() === trainrunSection.getId();
})
.classed(StaticDomTags.TAG_SELECTED, true)
.classed(StaticDomTags.TAG_HOVER, false)
Expand All @@ -455,7 +455,7 @@ export class D3Utils {
if (d === undefined) {
return false;
}
return d.trainrunSection.getId() === trainrunSection.getId();
return d.trainrunSections[0].getId() === trainrunSection.getId();
})
.classed(StaticDomTags.EDGE_LINE_GRAYEDOUT, false);

Expand All @@ -466,8 +466,8 @@ export class D3Utils {
return false;
}
return (
d.trainrunSection.getId() === trainrunSection.getId() &&
d.trainrunSection.getSourceNodeId() === grayoutEdgeLinePinNode.getId()
d.trainrunSections[0].getId() === trainrunSection.getId() &&
d.trainrunSections[0].getSourceNodeId() === grayoutEdgeLinePinNode.getId()
);
})
.classed(StaticDomTags.EDGE_LINE_GRAYEDOUT, false);
Expand All @@ -477,8 +477,8 @@ export class D3Utils {
return false;
}
return (
d.trainrunSection.getId() === trainrunSection.getId() &&
d.trainrunSection.getTargetNodeId() === grayoutEdgeLinePinNode.getId()
d.trainrunSections[0].getId() === trainrunSection.getId() &&
d.trainrunSections[0].getTargetNodeId() === grayoutEdgeLinePinNode.getId()
);
})
.classed(StaticDomTags.EDGE_LINE_GRAYEDOUT, false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export class TrainrunSectionViewObject {

constructor(
private editorView: EditorView,
public trainrunSection: TrainrunSection,
public trainrunSections: TrainrunSection[],
isNonStopAtSource: boolean,
isNonStopAtTarget: boolean,
isMuted: boolean,
Expand All @@ -18,7 +18,7 @@ export class TrainrunSectionViewObject {
) {
this.key = TrainrunSectionViewObject.generateKey(
editorView,
trainrunSection,
trainrunSections,
isNonStopAtSource,
isNonStopAtTarget,
isMuted,
Expand All @@ -30,9 +30,13 @@ export class TrainrunSectionViewObject {
);
}

getTrainrun() {
return this.trainrunSections[0].getTrainrun();
}

static generateKey(
editorView: EditorView,
d: TrainrunSection,
trainrunSections: TrainrunSection[],
isNonStopAtSource: boolean,
isNonStopAtTarget: boolean,
isMuted: boolean,
Expand All @@ -42,6 +46,7 @@ export class TrainrunSectionViewObject {
hiddenTagTrainrunName: boolean,
hiddenTagDirectionArrows: boolean,
): string {
const d = trainrunSections[0];
const cumulativeTravelTimeData = editorView.getCumulativeTravelTimeAndNodePath(d);
const cumulativeTravelTime =
cumulativeTravelTimeData[cumulativeTravelTimeData.length - 1].sumTravelTime;
Expand Down Expand Up @@ -162,6 +167,4 @@ export class TrainrunSectionViewObject {

return key;
}


}
Loading