Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#1764 ket objects coordinates issues #1869

Merged
merged 2 commits into from
Nov 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions packages/ketcher-core/src/domain/entities/struct.ts
Original file line number Diff line number Diff line change
Expand Up @@ -738,6 +738,15 @@ export class Struct {
this.sgroups.forEach((item) => {
item.pp = item.pp ? item.pp.scaled(scale) : null
})

this.texts.forEach((item) => {
// Scale text only for reactions - i.e file contains reaction arrows
const isReactionStruct = this.rxnArrows.size
if (isReactionStruct) {
item.pos = item.pos.map((p) => p.scaled(scale))
item.position = item.position.scaled(scale)
}
})
}

rescale() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ import {
Pile,
SGroup,
getStereoAtomsMap,
identifyStructFormat
identifyStructFormat,
Struct
} from 'ketcher-core'

import { supportedSGroupTypes } from './constants'
Expand All @@ -44,13 +45,13 @@ export function onAction(action) {
}

export function loadStruct(struct) {
return (dispatch, getState) => {
return (_dispatch, getState) => {
const editor = getState().editor
editor.struct(struct)
}
}

function parseStruct(struct, server, options) {
function parseStruct(struct: Struct, server, options?): Promise<Struct> {
if (typeof struct === 'string') {
options = options || {}
const { rescale, fragment, ...formatterOptions } = options
Expand All @@ -65,7 +66,7 @@ function parseStruct(struct, server, options) {
}
}

export function load(struct, options) {
export function load(struct: Struct, options?) {
return async (dispatch, getState) => {
const state = getState()
const editor = state.editor
Expand All @@ -90,7 +91,7 @@ export function load(struct, options) {
if (hasUnsupportedGroups) {
await editor.event.confirm.dispatch()
parsedStruct.sgroups = parsedStruct.sgroups.filter(
(key, sGroup) => supportedSGroupTypes[sGroup.type]
(_key, sGroup) => supportedSGroupTypes[sGroup.type]
)
}

Expand All @@ -117,7 +118,7 @@ export function load(struct, options) {
)

parsedStruct.atoms.forEach((atom, id) => {
if (parsedStruct.atomGetNeighbors(id).length === 0) {
if (parsedStruct?.atomGetNeighbors(id)?.length === 0) {
atom.stereoLabel = null
atom.stereoParity = 0
} else {
Expand Down Expand Up @@ -145,7 +146,7 @@ export function load(struct, options) {
}
dispatch(setAnalyzingFile(false))
dispatch({ type: 'MODAL_CLOSE' })
} catch (err) {
} catch (err: any) {
dispatch(setAnalyzingFile(false))
err && errorHandler(err.message)
}
Expand Down