Skip to content

Commit

Permalink
#2033: Abbreviations: Atoms protrude beyond the expanded view (#2125)
Browse files Browse the repository at this point in the history
* #2033 - Abbreviations: Atoms protrude beyond the expanded view for Functional Groups and Salts and Solvents

* #2033 - review fixes

* #2033 - review fix (replaced in with instanceof check)

* Revert "#2033 - review fix (replaced in with instanceof check)" to fix the build failure

This reverts commit 3b983e8.
  • Loading branch information
TimSPb89 authored Feb 3, 2023
1 parent 7a69893 commit 5016dee
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class ReSGroup extends ReObject {
let set = this.render.paper.set()
const atomSet = new Pile(sgroup.atoms)
const crossBonds = SGroup.getCrossBonds(remol.molecule, atomSet)
SGroup.bracketPos(sgroup, remol.molecule, crossBonds)
SGroup.bracketPos(sgroup, remol.molecule, crossBonds, remol, this.render)
const bracketBox = sgroup.bracketBox
const d = sgroup.bracketDir
sgroup.areas = [bracketBox]
Expand Down
25 changes: 20 additions & 5 deletions packages/ketcher-core/src/domain/entities/sgroup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { Pile } from './pile'
import { Struct } from './struct'
import { SaltsAndSolventsProvider } from '../helpers'
import { Vec2 } from './vec2'
import { ReStruct } from '../../application/render'

export class SGroupBracketParams {
readonly c: Vec2
Expand Down Expand Up @@ -335,7 +336,9 @@ export class SGroup {
static bracketPos(
sGroup,
mol,
crossBondsPerAtom: { [key: number]: Array<Bond> }
crossBondsPerAtom: { [key: number]: Array<Bond> },
remol?: ReStruct,
render?
): void {
const atoms = sGroup.atoms
const crossBonds = crossBondsPerAtom
Expand All @@ -352,12 +355,24 @@ export class SGroup {

let braketBox: Box2Abs | null = null
const contentBoxes: Array<any> = []
const getAtom = (aid) => {
if (remol && render) {
return remol.atoms.get(aid)
}
return mol.atoms.get(aid)
}
atoms.forEach((aid) => {
const atom = mol.atoms.get(aid)
const pos = new Vec2(atom.pp)
const atom = getAtom(aid)
const ext = new Vec2(0.05 * 3, 0.05 * 3)
const bba = new Box2Abs(pos, pos).extend(ext, ext)
contentBoxes.push(bba)
let position
let structBoundingBox
if ('getVBoxObj' in atom && render) {
structBoundingBox = atom.getVBoxObj(render)
} else {
position = new Vec2(atom.pp)
structBoundingBox = new Box2Abs(position, position)
}
contentBoxes.push(structBoundingBox.extend(ext, ext))
})
contentBoxes.forEach((bba) => {
let bbb: Box2Abs | null = null
Expand Down

0 comments on commit 5016dee

Please sign in to comment.