-
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?
Conversation
cd61d5d
to
087bc7c
Compare
- Add createViewObjectForCollapsedChain() static method to handle path routing between start/end nodes - Replace standard TrainrunSectionViewObject creation with custom method for collapsed chains - Path now correctly goes from first visible node to last visible node instead of using primary section's path
087bc7c
to
185666b
Compare
Thanks you for the new feature - would it be possible to get a live demo? |
I haven't done a full review yet, but at first glance I don't understand why:
It seems there's no change status (generateKey) related to isCollapsed. These objects are supposed to signal that something has changed so that a visual update can be triggered (i.e., only render what has changed to improve performance). I assume that if we don't explicitly trigger the update (mark the object as changed), it won't be updated (rendered). displayNodes(inputNodes: Node[]) {
const nodes = inputNodes.filter(
(n) =>
this.editorView.doCullCheckPositionsInViewport([
new Vec2D(n.getPositionX(), n.getPositionY()),
new Vec2D(n.getPositionX() + n.getNodeWidth(), n.getPositionY()),
new Vec2D(n.getPositionX(), n.getPositionY() + n.getNodeHeight()),
new Vec2D(n.getPositionX() + n.getNodeWidth(), n.getPositionY() + n.getNodeHeight()),
]) && this.filterNodesToDisplay(n),
);
const group = this.nodeGroup
.selectAll(StaticDomTags.NODE_ROOT_CONTAINER_DOM_REF)
.data(this.createViewNodeDataObjects(nodes), (n: NodeViewObject) => n.key);
... It would be very helpful if we could add some tests to verify that changes to isCollapsed and it's functionality are functioning as intended. Even if this doesn't directly affect the visualization layer, it’s still important for the underlying service methods, especially in areas like data migration. The base functionality should be properly tested to ensure robustness and maintainability. |
|
||
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 comment
The reason will be displayed to describe this comment to others. Learn more.
Tiny nit: why the comment here and not in transitions.view.ts?
Context: This PR implements part of the 3 first sections of the implementation plan given here |
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.
LGTM, not tested.
Maybe, instead of fully hiding the nodes when isCollapsed
is true
, you should display them as a "Dot", as it is shown here (mock-up from main issue). But maybe you've planned to do it in the next PR, ignore this comment if so.
|
||
filterNodesToDisplay(node: Node): boolean { | ||
return this.editorView.isNodeVisible(node); | ||
return this.editorView.isNodeVisible(node) && !node.getIsCollapsed(); |
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.
Nit: isCollapsed()
would be nice instead of getIsCollapsed()
groupTrainrunSectionsIntoChains(trainrunSections: TrainrunSection[]): Array<{ | ||
sections: TrainrunSection[]; | ||
startNode: Node; | ||
endNode: 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.
Nice function, very readable. I wonder if we could/should create a new type for the group
object, if it will be reused elsewhere
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.
Thanks for the suggestion, as I simplified it thanks to @emersion it's no longer necessary
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.
Thanks for splitting the changes into small commits! Here are a few comments.
try { | ||
// Set temporary nodes for path calculation | ||
primarySection.setSourceNode(startNode); | ||
primarySection.setTargetNode(endNode); |
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 a fan of temporarily mutating a trainrun section to make existing functions such as
routeEdgeAndPlaceText()
behave like we want. This mutates the DTO and doesn't only affect rendering. I would prefer to stick to the solution outlined in the implementation plan instead. - I don't think this shows times correctly. I've created this trainrun:

After adding "isCollapsed": true
to the "OL" node, I get this:

The total time as well as the arrival/departure times on the top left of "OL" are wrong. They should read: travel time 2 (1 + 1), arrival time 4, departure time 56.
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 tried something without modiying the dto. Plus i adpt the horaries to respect the stop even if they are collapsed. Tell me what you think of thoses changes.
startNode: Node; | ||
endNode: 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.
Nit: do we really need to store startNode
/endNode
if they're that easy to grab from the chain?
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 removed it
}> = []; | ||
const visitedSections = new Set<number>(); | ||
|
||
trainrunSections.forEach((section) => { |
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.
Instead of hand-rolling our own graph traversal, can we use TrainrunService.getIterator()
? (Perhaps even introduce a new ExpandedTrainrunIterator
, just like we already have NonStopTrainrunIterator
? Not sure it's worth the effort.)
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.
sure i modified it thanks
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.
Made a pass, nothing to add for now. I'll do another pass after you resolved @emersion's comments.
c4cc009
to
6145bff
Compare
Sorry for the late answer. i'm not sure to completly understand your first point. And sure, I will add some test in the next commit |
6145bff
to
a1d2b05
Compare
a1d2b05
to
fa9b231
Compare
Description
This PR implements the collapsed nodes functionality for the Netzgrafik editor, allowing intermediate nodes to be hidden while maintaining proper visual representation of train routes.
Features Implemented
1. Node Model Enhancement
isCollapsed
field to Node model with getter/setter methods2. Visual Filtering System
3. Intelligent Section Grouping
4. Direct Path Calculation
User Experience
collapsed
become invisibleTechnical Implementation
Issues
Related to feature request for collapsed nodes functionality to simplify complex network display.
Checklist
documentation/
(documentation to be added in follow-up)Next Steps (Future PRs)