Aromatic/dashed bond order rendering #455 #842
Merged
+379
−71
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR extends the dashed bond work from #641 and #740 to handle aromatic and fractional bond orders. Bonds with order 1.5, 2.5, or type 4 (aromatic) now display as a solid+dashed pair matching standard chemical drawing conventions.
Background
PR #641/#740 added dashed bond rendering for bond orders < 1. This PR builds on that foundation to handle the more complex case raised in #455: aromatic bonds (type 4 in SDF) and fractional orders like 1.5 need to render as a solid+dashed pair, not just a single dashed line. The tricky part is determining which side gets the dashed portion - it should face the ring interior.
What changed
Fractional bond orders (1.5, 2.5) and aromatic type (4) render as one solid cylinder plus one dashed cylinder. The dashed portion automatically faces the ring interior by computing a weighted centroid of neighboring atoms. Ring atoms get full weight, terminal hydrogens get 0.25 weight.
Fine-tuned previous formula for dash creation
Two-color bonds between different atom types (e.g. C-N in pyridine) now split correctly at the midpoint for both solid and dashed portions.
Added solidColor and dashedColor properties to dashedBondConfig for explicit color control: