diff --git a/packages/ketcher-core/src/application/render/restruct/resgroup.js b/packages/ketcher-core/src/application/render/restruct/resgroup.js index 90468749d6..9483ee13cf 100644 --- a/packages/ketcher-core/src/application/render/restruct/resgroup.js +++ b/packages/ketcher-core/src/application/render/restruct/resgroup.js @@ -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] diff --git a/packages/ketcher-core/src/domain/entities/sgroup.ts b/packages/ketcher-core/src/domain/entities/sgroup.ts index cfd39b0a0a..7d3d90ecee 100644 --- a/packages/ketcher-core/src/domain/entities/sgroup.ts +++ b/packages/ketcher-core/src/domain/entities/sgroup.ts @@ -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 @@ -335,7 +336,9 @@ export class SGroup { static bracketPos( sGroup, mol, - crossBondsPerAtom: { [key: number]: Array } + crossBondsPerAtom: { [key: number]: Array }, + remol?: ReStruct, + render? ): void { const atoms = sGroup.atoms const crossBonds = crossBondsPerAtom @@ -352,12 +355,24 @@ export class SGroup { let braketBox: Box2Abs | null = null const contentBoxes: Array = [] + 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