Skip to content

Commit

Permalink
Backmerge: #2656 – After opening or pasting an unknown superatom onto…
Browse files Browse the repository at this point in the history
… canvas, it becomes non-interactive (#2670)
  • Loading branch information
Nitvex committed May 24, 2023
1 parent 3b46db1 commit 10394be
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,10 @@ export function setExpandSGroup(restruct, sgid, attrs) {
})

const sgroup = restruct.molecule.sgroups.get(sgid)
if (sgroup.firstSgroupAtom) delete sgroup.firstSgroupAtom
if (sgroup.firstSgroupAtom) {
delete sgroup.firstSgroupAtom
delete sgroup.firstSgroupAtomId
}
const atoms = SGroup.getAtoms(restruct, sgroup)

atoms.forEach((aid) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ class ReSGroup extends ReObject {
if (FunctionalGroup.isAttachmentPointAtom(aid, remol.molecule)) {
sgroup.firstSgroupAtom = remol.molecule.atoms.get(aid)
sgroup.functionalGroup = true
sgroup.firstSgroupAtomId = aid
}
})
} else {
Expand Down Expand Up @@ -139,10 +140,9 @@ class ReSGroup extends ReObject {
sGroupItem.firstSgroupAtom
if (sGroupHasFirstAtom) {
const firstAtomPosition = sGroupItem.firstSgroupAtom.pp
const [firstAtomId] = sGroupItem.atoms
const reSGroupAtom = render.ctab.atoms.get(firstAtomId)
const reSGroupAtom = render.ctab.atoms.get(sGroupItem.firstSgroupAtomId)
const sGroupTextBoundingBox =
reSGroupAtom.visel.boundingBox || reSGroupAtom.visel.oldBoundingBox
reSGroupAtom?.visel.boundingBox || reSGroupAtom?.visel.oldBoundingBox
if (sGroupTextBoundingBox) {
const { x, y } = Scale.obj2scaled(firstAtomPosition, render.options)
const { p0, p1 } = sGroupTextBoundingBox
Expand Down
2 changes: 2 additions & 0 deletions packages/ketcher-core/src/domain/entities/sgroup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ export class SGroup {
pp: Vec2 | null
data: any
firstSgroupAtom: any
firstSgroupAtomId: number

constructor(type: string) {
this.type = type
Expand All @@ -101,6 +102,7 @@ export class SGroup {
this.xBonds = []
this.neiAtoms = []
this.pp = null
this.firstSgroupAtomId = -1
this.data = {
mul: 1, // multiplication count for MUL group
connectivity: 'ht', // head-to-head, head-to-tail or either-unknown
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,9 @@ import classes from './InfoPanel.module.less'
const HOVER_PANEL_PADDING = 20

function getSGroupFirstAtom(sGroup: SGroup, render: Render): Vec2 {
const { firstSgroupAtom } = sGroup
const { firstSgroupAtom, firstSgroupAtomId } = sGroup
if (firstSgroupAtom) return firstSgroupAtom.pp
const [firstAtomId] = sGroup.atoms
return render.ctab.atoms?.get(firstAtomId)?.a.pp || new Vec2(0, 0)
return render.ctab.atoms?.get(firstSgroupAtomId)?.a.pp || new Vec2(0, 0)
}

function getPanelPosition(
Expand Down

0 comments on commit 10394be

Please sign in to comment.