-
Notifications
You must be signed in to change notification settings - Fork 17
feat: modify node display #554
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: mrd/new-nodes-management-system
Are you sure you want to change the base?
Changes from all commits
3b0bf7f
04056e8
719f497
2c6fab2
871f667
abf1f83
78e1a92
42b4f8d
e9807c4
c43b300
b8df4bb
7ade86b
99bef05
1a466ae
6a3040c
c2d19b1
74da689
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1469,4 +1469,59 @@ export class TrainrunSectionService implements OnDestroy { | |
| trainrunSection.routeEdgeAndPlaceText(); | ||
| trainrunSection.convertVec2DToPath(); | ||
| } | ||
|
|
||
| /** | ||
| * Groups consecutive TrainrunSections that have collapsed nodes between them | ||
| * into chains. Each chain starts and ends with a non-collapsed node. | ||
| * Start and end nodes can be accessed via: sections[0].getSourceNode() and sections[sections.length - 1].getTargetNode() | ||
| * @param trainrunSections List of TrainrunSections to group | ||
| * @returns Array of section chains | ||
| */ | ||
| groupTrainrunSectionsIntoChains(trainrunSections: TrainrunSection[]): TrainrunSection[][] { | ||
| const groups: TrainrunSection[][] = []; | ||
| const visitedSections = new Set<number>(); | ||
|
|
||
| trainrunSections.forEach((section) => { | ||
emersion marked this conversation as resolved.
Show resolved
Hide resolved
emersion marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| if (visitedSections.has(section.getId())) { | ||
| 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 iterator = this.trainrunService.getIterator(startNode, startSection); | ||
|
|
||
| // Traverse the trainrun and collect sections with collapsed intermediate nodes | ||
| while (iterator.hasNext()) { | ||
| const pair = iterator.next(); | ||
|
|
||
| if (visitedSections.has(pair.trainrunSection.getId())) { | ||
| break; // Already processed this section | ||
| } | ||
|
Comment on lines
+1507
to
+1509
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Small question, this case should never happen right ?
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, normally this case should never happen, it's a relicat from previous development, but now we find the first section of the chain, thanks to the backward iterator.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Throwing an error sounds good to me. |
||
|
|
||
| chain.push(pair.trainrunSection); | ||
| visitedSections.add(pair.trainrunSection.getId()); | ||
|
|
||
| // Stop if we reach a non-collapsed node (end of collapsed chain) | ||
| if (!pair.node.getIsCollapsed()) { | ||
| break; | ||
| } | ||
| } | ||
|
|
||
| if (chain.length > 0) { | ||
| groups.push(chain); | ||
| } | ||
| }); | ||
|
|
||
| return groups; | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -240,6 +240,12 @@ export class ConnectionsView { | |
| } | ||
|
|
||
| const node: Node = this.editorView.getNodeFromConnection(con); | ||
|
|
||
| // filter if node is collapsed - do not show connections for collapsed nodes | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Tiny nit: why the comment here and not in transitions.view.ts? |
||
| if (node.getIsCollapsed()) { | ||
| return false; | ||
| } | ||
|
|
||
| const trainrunSection1: TrainrunSection = node.getPort(con.getPortId1()).getTrainrunSection(); | ||
| const trainrunSection2: TrainrunSection = node.getPort(con.getPortId2()).getTrainrunSection(); | ||
| const filterTrainrun1 = this.editorView.filterTrainrun(trainrunSection1.getTrainrun()); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -89,7 +89,7 @@ export class NodesView { | |
| } | ||
|
|
||
| filterNodesToDisplay(node: Node): boolean { | ||
| return this.editorView.isNodeVisible(node); | ||
| return this.editorView.isNodeVisible(node) && !node.getIsCollapsed(); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: |
||
| } | ||
|
|
||
| displayNodes(inputNodes: Node[]) { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure this function is used anymore
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True, good catch i'll remove it