Skip to content
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

Fix rendering of line cell templates #4752

Merged

Conversation

kwvanderlinde
Copy link
Collaborator

@kwvanderlinde kwvanderlinde commented Apr 12, 2024

Identify the Bug or Feature request

Fixes #3692

Description of the Change

This PR fixes the calculation of the bounding box for LineCellTemplate which stops it from being cut off depending on the viewport.

Also spent some time simplifying a few things while I tried to diagnose the underlying issue:

  1. LineCellTemplate is a bit more encapsulated now. E.g., it now manages its own quadrant rather than requiring the tool to figure that out.
  2. All LineCellTemplate fields aside from pathVertex are now marked transient as they can be recalculated any time. Excluding <path> and <pool> from the XML significantly reduces its size.
  3. calcPath() is now Bressenham's algorithm which requires less casework.
  4. getBounds() now only checks the first and last points in the path, rather than checking all points for the smallest values.

Possible Drawbacks

Should be none.

Documentation Notes

N/A

Release Notes

  • Fixed a bug where line cell templates would be cut off depending on the current zoom level.

This change is Reviewable

`calcPath()` has been simplified to essentially Bressenham's algorithm. It only calculates and returns a path, while
`getPath()` (previously unused) will call it if needed.

`getBounds()` now correctly accounts for the path's quadrant and the position of the first vertex to produce a correctly
located and sized bounding box. This method was also simplified to only look at the two endpoints rather than iterating
over the entire line.

All fields except `pathVertex` are now marked as `transient` since they can be recovered from only `getVertex()` and
`pathVertex`. Correspondingly, the quadrant is not longer part of the DTO, and the serialized XML is much smaller.

With the above changes in, it was natural to simplify `LineCellTemplateTool` to avoid a lot of case work, especially in
not relying on mutations of `getPathVertex()`.
@kwvanderlinde kwvanderlinde force-pushed the bugfix/3692-line-cell-template-fix branch from 2f3bac8 to 6de6d88 Compare April 15, 2024 22:23
@cwisniew cwisniew added this pull request to the merge queue Apr 16, 2024
Merged via the queue into RPTools:develop with commit 8424030 Apr 16, 2024
4 checks passed
@kwvanderlinde kwvanderlinde deleted the bugfix/3692-line-cell-template-fix branch April 16, 2024 13:02
@kwvanderlinde kwvanderlinde self-assigned this Apr 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Merged
Development

Successfully merging this pull request may close these issues.

[Bug]: Line cell template is cut off at certain zoom levels
2 participants