diff --git a/ketcher-autotests/tests/Macromolecule-editor/Import-Saving-Files/import-saving-mol.spec.ts-snapshots/Import-modified-mol-files-from-external-editor-for-rna-mod-phosphate-mod-base-example-mol-1-chromium-linux.png b/ketcher-autotests/tests/Macromolecule-editor/Import-Saving-Files/import-saving-mol.spec.ts-snapshots/Import-modified-mol-files-from-external-editor-for-rna-mod-phosphate-mod-base-example-mol-1-chromium-linux.png index 5999923936..e700ebc60a 100644 Binary files a/ketcher-autotests/tests/Macromolecule-editor/Import-Saving-Files/import-saving-mol.spec.ts-snapshots/Import-modified-mol-files-from-external-editor-for-rna-mod-phosphate-mod-base-example-mol-1-chromium-linux.png and b/ketcher-autotests/tests/Macromolecule-editor/Import-Saving-Files/import-saving-mol.spec.ts-snapshots/Import-modified-mol-files-from-external-editor-for-rna-mod-phosphate-mod-base-example-mol-1-chromium-linux.png differ diff --git a/ketcher-autotests/tests/Macromolecule-editor/Macro-Micro-Switcher/macro-micro-switcher.spec.ts-snapshots/Macro-Micro-Switcher-Check-that-the-Ket-struct-3dd89-e-file-in-Macro-mode-is-visible-in-Micro-mode-1-chromium-linux.png b/ketcher-autotests/tests/Macromolecule-editor/Macro-Micro-Switcher/macro-micro-switcher.spec.ts-snapshots/Macro-Micro-Switcher-Check-that-the-Ket-struct-3dd89-e-file-in-Macro-mode-is-visible-in-Micro-mode-1-chromium-linux.png index ca1e16d08b..e697379dda 100644 Binary files a/ketcher-autotests/tests/Macromolecule-editor/Macro-Micro-Switcher/macro-micro-switcher.spec.ts-snapshots/Macro-Micro-Switcher-Check-that-the-Ket-struct-3dd89-e-file-in-Macro-mode-is-visible-in-Micro-mode-1-chromium-linux.png and b/ketcher-autotests/tests/Macromolecule-editor/Macro-Micro-Switcher/macro-micro-switcher.spec.ts-snapshots/Macro-Micro-Switcher-Check-that-the-Ket-struct-3dd89-e-file-in-Macro-mode-is-visible-in-Micro-mode-1-chromium-linux.png differ diff --git a/ketcher-autotests/tests/Macromolecule-editor/Macro-Micro-Switcher/macro-micro-switcher.spec.ts-snapshots/Macro-Micro-Switcher-Check-that-the-Ket-struct-7b663-oard-in-Macro-mode-is-visible-in-Micro-mode-1-chromium-linux.png b/ketcher-autotests/tests/Macromolecule-editor/Macro-Micro-Switcher/macro-micro-switcher.spec.ts-snapshots/Macro-Micro-Switcher-Check-that-the-Ket-struct-7b663-oard-in-Macro-mode-is-visible-in-Micro-mode-1-chromium-linux.png index 354ffa4160..f9344ebf67 100755 Binary files a/ketcher-autotests/tests/Macromolecule-editor/Macro-Micro-Switcher/macro-micro-switcher.spec.ts-snapshots/Macro-Micro-Switcher-Check-that-the-Ket-struct-7b663-oard-in-Macro-mode-is-visible-in-Micro-mode-1-chromium-linux.png and b/ketcher-autotests/tests/Macromolecule-editor/Macro-Micro-Switcher/macro-micro-switcher.spec.ts-snapshots/Macro-Micro-Switcher-Check-that-the-Ket-struct-7b663-oard-in-Macro-mode-is-visible-in-Micro-mode-1-chromium-linux.png differ diff --git a/ketcher-autotests/tests/Macromolecule-editor/Macro-Micro-Switcher/macro-micro-switcher.spec.ts-snapshots/Macro-Micro-Switcher-Check-that-the-Mol-struct-10443-e-file-in-Macro-mode-is-visible-on-Micro-mode-1-chromium-linux.png b/ketcher-autotests/tests/Macromolecule-editor/Macro-Micro-Switcher/macro-micro-switcher.spec.ts-snapshots/Macro-Micro-Switcher-Check-that-the-Mol-struct-10443-e-file-in-Macro-mode-is-visible-on-Micro-mode-1-chromium-linux.png index eb0eb7c179..82723ccef6 100755 Binary files a/ketcher-autotests/tests/Macromolecule-editor/Macro-Micro-Switcher/macro-micro-switcher.spec.ts-snapshots/Macro-Micro-Switcher-Check-that-the-Mol-struct-10443-e-file-in-Macro-mode-is-visible-on-Micro-mode-1-chromium-linux.png and b/ketcher-autotests/tests/Macromolecule-editor/Macro-Micro-Switcher/macro-micro-switcher.spec.ts-snapshots/Macro-Micro-Switcher-Check-that-the-Mol-struct-10443-e-file-in-Macro-mode-is-visible-on-Micro-mode-1-chromium-linux.png differ diff --git a/ketcher-autotests/tests/Macromolecule-editor/Macro-Micro-Switcher/macro-micro-switcher.spec.ts-snapshots/Macro-Micro-Switcher-Check-that-the-Mol-struct-36f81-board-in-Macro-mode-is-visible-in-Micro-mode-1-chromium-linux.png b/ketcher-autotests/tests/Macromolecule-editor/Macro-Micro-Switcher/macro-micro-switcher.spec.ts-snapshots/Macro-Micro-Switcher-Check-that-the-Mol-struct-36f81-board-in-Macro-mode-is-visible-in-Micro-mode-1-chromium-linux.png index f155004124..eaec8f5a28 100755 Binary files a/ketcher-autotests/tests/Macromolecule-editor/Macro-Micro-Switcher/macro-micro-switcher.spec.ts-snapshots/Macro-Micro-Switcher-Check-that-the-Mol-struct-36f81-board-in-Macro-mode-is-visible-in-Micro-mode-1-chromium-linux.png and b/ketcher-autotests/tests/Macromolecule-editor/Macro-Micro-Switcher/macro-micro-switcher.spec.ts-snapshots/Macro-Micro-Switcher-Check-that-the-Mol-struct-36f81-board-in-Macro-mode-is-visible-in-Micro-mode-1-chromium-linux.png differ diff --git a/ketcher-autotests/tests/Macromolecule-editor/Macro-Micro-Switcher/macro-micro-switcher2.spec.ts-snapshots/Macro-Micro-Switcher2-Check-that-switching-bet-407ef-A-with-modified-monomer-with-modyfied-monomer-1-chromium-linux.png b/ketcher-autotests/tests/Macromolecule-editor/Macro-Micro-Switcher/macro-micro-switcher2.spec.ts-snapshots/Macro-Micro-Switcher2-Check-that-switching-bet-407ef-A-with-modified-monomer-with-modyfied-monomer-1-chromium-linux.png index 73cd933f99..d1687c4439 100644 Binary files a/ketcher-autotests/tests/Macromolecule-editor/Macro-Micro-Switcher/macro-micro-switcher2.spec.ts-snapshots/Macro-Micro-Switcher2-Check-that-switching-bet-407ef-A-with-modified-monomer-with-modyfied-monomer-1-chromium-linux.png and b/ketcher-autotests/tests/Macromolecule-editor/Macro-Micro-Switcher/macro-micro-switcher2.spec.ts-snapshots/Macro-Micro-Switcher2-Check-that-switching-bet-407ef-A-with-modified-monomer-with-modyfied-monomer-1-chromium-linux.png differ diff --git a/ketcher-autotests/tests/Macromolecule-editor/Macro-Micro-Switcher/macro-micro-switcher2.spec.ts-snapshots/Macro-Micro-Switcher2-Check-that-switching-bet-8a35b-A-with-modified-monomer-with-modyfied-monomer-2-chromium-linux.png b/ketcher-autotests/tests/Macromolecule-editor/Macro-Micro-Switcher/macro-micro-switcher2.spec.ts-snapshots/Macro-Micro-Switcher2-Check-that-switching-bet-8a35b-A-with-modified-monomer-with-modyfied-monomer-2-chromium-linux.png index 4837ca761f..51fe747bff 100644 Binary files a/ketcher-autotests/tests/Macromolecule-editor/Macro-Micro-Switcher/macro-micro-switcher2.spec.ts-snapshots/Macro-Micro-Switcher2-Check-that-switching-bet-8a35b-A-with-modified-monomer-with-modyfied-monomer-2-chromium-linux.png and b/ketcher-autotests/tests/Macromolecule-editor/Macro-Micro-Switcher/macro-micro-switcher2.spec.ts-snapshots/Macro-Micro-Switcher2-Check-that-switching-bet-8a35b-A-with-modified-monomer-with-modyfied-monomer-2-chromium-linux.png differ diff --git a/packages/ketcher-core/src/application/editor/modes/BaseMode.ts b/packages/ketcher-core/src/application/editor/modes/BaseMode.ts index f150e28d26..a08e0fc562 100644 --- a/packages/ketcher-core/src/application/editor/modes/BaseMode.ts +++ b/packages/ketcher-core/src/application/editor/modes/BaseMode.ts @@ -265,7 +265,7 @@ export abstract class BaseMode { return; } - this.updateMonomersPosition(drawingEntitiesManager); + this.updateEntitiesPosition(drawingEntitiesManager); const { command: modelChanges, mergedDrawingEntities } = drawingEntitiesManager.mergeInto(editor.drawingEntitiesManager); @@ -303,24 +303,19 @@ export abstract class BaseMode { } } - private updateMonomersPosition( + private updateEntitiesPosition( drawingEntitiesManager: DrawingEntitiesManager, ) { - let offset: Vec2; - let index = 0; const newNodePosition = this.getNewNodePosition(); - drawingEntitiesManager.monomers.forEach((monomer) => { - let position; - if (index === 0) { - offset = Vec2.diff(newNodePosition, new Vec2(monomer.position)); - position = newNodePosition; - } else { - position = offset - ? new Vec2(monomer.position).add(offset) - : new Vec2(monomer.position); - } - drawingEntitiesManager.moveMonomer(monomer, position); - index++; + const firstEntityPosition = + drawingEntitiesManager.allEntities[0]?.[1].position; + const offset = Vec2.diff(newNodePosition, new Vec2(firstEntityPosition)); + + drawingEntitiesManager.allEntities.forEach(([, drawindEntity]) => { + drawingEntitiesManager.moveDrawingEntityModelChange( + drawindEntity, + offset, + ); }); } diff --git a/packages/ketcher-core/src/application/editor/modes/FlexMode.ts b/packages/ketcher-core/src/application/editor/modes/FlexMode.ts index bdf100dbee..d889fcf312 100644 --- a/packages/ketcher-core/src/application/editor/modes/FlexMode.ts +++ b/packages/ketcher-core/src/application/editor/modes/FlexMode.ts @@ -25,6 +25,7 @@ export class FlexMode extends BaseMode { getNewNodePosition() { const editor = CoreEditor.provideEditorInstance(); + return Coordinates.canvasToModel(editor.lastCursorPositionOfCanvas); } diff --git a/packages/ketcher-core/src/domain/entities/DrawingEntitiesManager.ts b/packages/ketcher-core/src/domain/entities/DrawingEntitiesManager.ts index f8b42b7561..25af74d182 100644 --- a/packages/ketcher-core/src/domain/entities/DrawingEntitiesManager.ts +++ b/packages/ketcher-core/src/domain/entities/DrawingEntitiesManager.ts @@ -168,8 +168,8 @@ export class DrawingEntitiesManager { public get allBondsToMonomers() { return [ - ...(this.polymerBonds as Map), - ...(this.monomerToAtomBonds as Map), + ...(this.polymerBonds as Map), + ...(this.monomerToAtomBonds as Map), ]; } @@ -1808,14 +1808,9 @@ export class DrawingEntitiesManager { ); const structCenter = this.getMacroStructureCenter(); const offset = Vec2.diff(centerPointOfModel, structCenter); - this.monomers.forEach((monomer: BaseMonomer) => { - this.moveMonomer(monomer, new Vec2(monomer.position).add(offset)); - }); - this.polymerBonds.forEach((bond: PolymerBond) => { - const { x: startX, y: startY } = new Vec2(bond.position).add(offset); - bond.moveBondStartAbsolute(startX, startY); - const { x: endX, y: endY } = new Vec2(bond.endPosition).add(offset); - bond.moveBondEndAbsolute(endX, endY); + + this.allEntities.forEach(([, entity]) => { + this.moveDrawingEntityModelChange(entity, offset); }); }