Skip to content

Commit

Permalink
#5640 – Fix circular dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
svvald committed Nov 1, 2024
1 parent bcd2f76 commit c3d5337
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ export class MonomerMicromolecule extends SGroup {
this.data.attached = false;
}

public get isMonomer() {
return true;
}

public override getContractedPosition(struct: Struct) {
assert(this.pp);
const sgroupContractedPosition = super.getContractedPosition(struct);
Expand Down
17 changes: 6 additions & 11 deletions packages/ketcher-core/src/domain/entities/sgroup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,7 @@ import { Struct } from './struct';
import { SaltsAndSolventsProvider } from '../helpers';
import { Vec2 } from './vec2';
import { ReStruct } from '../../application/render';
import {
FunctionalGroup,
MonomerMicromolecule,
Pool,
SGroupAttachmentPoint,
} from 'domain/entities';
import { FunctionalGroup, Pool, SGroupAttachmentPoint } from 'domain/entities';
import { ReSGroup } from 'application/render';
import { SgContexts } from 'application/editor/shared/constants';
import assert from 'assert';
Expand Down Expand Up @@ -373,6 +368,10 @@ export class SGroup {
return this.type === SGroup.TYPES.SUP && !this.data.name;
}

public get isMonomer() {
return false;
}

static getOffset(sgroup: SGroup): null | Vec2 {
if (!sgroup?.pp || !sgroup.bracketBox) return null;
return Vec2.diff(sgroup.pp, sgroup.bracketBox.p1);
Expand Down Expand Up @@ -510,11 +509,7 @@ export class SGroup {
? Object.values(crossBondsPerAtom).flat()
: null;
// TODO: Overall cross bonds logic seems unclear and not-correct for s groups in general leading to tilted hover plate
if (
sGroup instanceof MonomerMicromolecule ||
!crossBonds ||
crossBonds.length !== 2
) {
if (sGroup.isMonomer || !crossBonds || crossBonds.length !== 2) {
sGroup.bracketDirection = new Vec2(1, 0);
} else {
const p1 = mol.bonds.get(crossBonds[0]).getCenter(mol);
Expand Down

0 comments on commit c3d5337

Please sign in to comment.