Skip to content

Commit

Permalink
#269 refactor and rename
Browse files Browse the repository at this point in the history
  • Loading branch information
ensemenova committed Mar 2, 2021
1 parent 484a0f9 commit 0cf3a60
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions packages/ketcher-core/src/chemistry/entities/SGroup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -245,14 +245,16 @@ export class SGroup {

static getBracketParameters(
mol,
xbonds,
crossBonds,
atomSet: Pile<number>,
bb,
d,
n
): Array<any> {
var brackets: Array<any> = []
if (xbonds.length < 2) {
const crossBondsPerAtom = Object.values(crossBonds)
const crossBondsValues = Array.prototype.concat.apply([], crossBondsPerAtom)
if (crossBondsValues.length < 2) {
;(function () {
d = d || new Vec2(1, 0)
n = n || d.rotateSC(1, 0)
Expand All @@ -266,11 +268,11 @@ export class SGroup {
new SGroupBracketParams(cr, d, bracketWidth, bracketHeight)
)
})()
} else if (xbonds.length === 2) {
} else if (crossBondsValues.length === 2) {
;(function () {
// eslint-disable-line max-statements
var b1 = mol.bonds.get(xbonds[0])
var b2 = mol.bonds.get(xbonds[1])
var b1 = mol.bonds.get(crossBondsValues[0])
var b2 = mol.bonds.get(crossBondsValues[1])
var cl0 = b1.getCenter(mol)
var cr0 = b2.getCenter(mol)
var dr = Vec2.diff(cr0, cl0).normalized()
Expand All @@ -295,8 +297,8 @@ export class SGroup {
})()
} else {
;(function () {
for (var i = 0; i < xbonds.length; ++i) {
var b = mol.bonds.get(xbonds[i])
for (var i = 0; i < crossBondsValues.length; ++i) {
var b = mol.bonds.get(crossBondsValues[i])
var c = b.getCenter(mol)
var d = atomSet.has(b.begin) ? b.getDir(mol) : b.getDir(mol).negated()
brackets.push(new SGroupBracketParams(c, d, 0.2, 1.0))
Expand Down

0 comments on commit 0cf3a60

Please sign in to comment.