From e26a02032f0957f607ab10049aae95f526cfe77f Mon Sep 17 00:00:00 2001 From: Roman Rodionov Date: Thu, 27 Jul 2023 16:50:15 +0200 Subject: [PATCH 1/2] #2332 - Add peptide monomers to canvas (by click) - added an ability to add peptides on canvas and move by drag n drop --- .../monomerLibraryGroup/MonomerGroup.tsx | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/packages/ketcher-polymer-editor-react/src/components/monomerLibrary/monomerLibraryGroup/MonomerGroup.tsx b/packages/ketcher-polymer-editor-react/src/components/monomerLibrary/monomerLibraryGroup/MonomerGroup.tsx index 53a8765b2d..d73d4938c5 100644 --- a/packages/ketcher-polymer-editor-react/src/components/monomerLibrary/monomerLibraryGroup/MonomerGroup.tsx +++ b/packages/ketcher-polymer-editor-react/src/components/monomerLibrary/monomerLibraryGroup/MonomerGroup.tsx @@ -86,6 +86,18 @@ const MonomerGroup = ({ } }; + const selectMonomer = (monomer: MonomerItemType) => { + switch (libraryName) { + case 'PEPTIDE': + editor.events.selectPeptide.dispatch(monomer); + onItemClick(monomer); + break; + default: + onItemClick(monomer); + break; + } + }; + return ( {title && ( From 19b56dfd56b3a3a784d6e484535fdb094279632c Mon Sep 17 00:00:00 2001 From: Roman Rodionov Date: Wed, 23 Aug 2023 15:42:18 +0200 Subject: [PATCH 2/2] #2370 - "Erase" tool #2360 - "Select" tool - added select and erase tools - implemented DrawingEntitiesManager and RenderersManager which controls entities parameters changes and render - added rootDir to tsconfig of core package --- example/src/PolymerToggler/PolymerToggler.tsx | 2 +- .../constants/testIdConstants.ts | 2 +- .../Erase-Tool/erase-tool.spec.ts | 55 +++ ...ith-another-monomers-1-chromium-darwin.png | Bin 0 -> 9168 bytes ...ith-another-monomers-2-chromium-darwin.png | Bin 0 -> 7774 bytes .../polymer-bond-tool.spec.ts | 13 +- .../RNAEditor/add-default-presets.spec.ts | 9 +- .../rectangle-selection-tool.spec.ts | 72 +++ .../add-custom-preset-add-to-canvas.png | Bin 52297 -> 48063 bytes .../screenshots/add-custom-preset-add.png | Bin 48127 -> 44180 bytes .../add-custom-preset-duplicate.png | Bin 49911 -> 46565 bytes .../add-default-preset-to-canvas.png | Bin 49615 -> 45516 bytes .../screenshots/chem-add-to-canvas.png | Bin 32721 -> 29656 bytes .../screenshots/chem-library.png | Bin 29675 -> 28637 bytes .../screenshots/default-presets.png | Bin 46242 -> 42174 bytes .../screenshots/peptides-add-to-canvas.png | Bin 40978 -> 38431 bytes .../screenshots/polymer-bond-tool-chem1.png | Bin 34130 -> 31405 bytes .../screenshots/polymer-bond-tool-chem2.png | Bin 33513 -> 30509 bytes .../screenshots/polymer-bond-tool.png | Bin 43477 -> 43735 bytes .../screenshots/polymer-bond-tool2.png | Bin 41933 -> 42214 bytes .../screenshots/polymer-bond-tool3.png | Bin 48839 -> 47539 bytes .../screenshots/rectangle-selection-tool.png | Bin 0 -> 42284 bytes .../screenshots/rectangle-selection-tool2.png | Bin 0 -> 47235 bytes .../screenshots/rectangle-selection-tool3.png | Bin 0 -> 39543 bytes .../tests/utils/canvas/helpers.ts | 10 + .../tests/utils/canvas/tools/helpers.ts | 24 + .../tests/utils/macromolecules/index.ts | 7 + .../tests/utils/macromolecules/polymerBond.ts | 12 + packages/ketcher-core/.eslintrc.json | 4 + .../editor/tools/SelectRectangleTool.test.ts | 72 +++ .../PeptideRenderer.test.ts.snap | 2 + .../PolymerBondRenderer.test.ts.snap | 15 +- .../entities/drawingEntitiesManager.test.ts | 118 +++++ .../domain/entities/polymerBond.test.ts | 2 + .../ketcher-core/__tests__/helpers/dom.ts | 4 + packages/ketcher-core/__tests__/mock-data.ts | 4 + .../src/application/editor/Editor.ts | 45 +- .../src/application/editor/actions/index.ts | 1 - .../src/application/editor/actions/monomer.ts | 52 --- .../application/editor/actions/polymerBond.ts | 46 -- .../src/application/editor/editorEvents.ts | 26 ++ .../editor/operations/OperationType.ts | 10 + .../editor/operations/drawingEntity/index.ts | 19 + .../editor/operations/monomer/PresetAdd.ts | 182 -------- .../editor/operations/monomer/index.ts | 62 +-- .../editor/operations/polymerBond/index.ts | 73 +-- .../polymerBond/polymerBondDelete.ts | 56 --- .../src/application/editor/tools/Bond.ts | 192 ++++---- .../src/application/editor/tools/Erase.ts | 44 ++ .../src/application/editor/tools/Monomer.ts | 13 +- .../editor/tools/{Preset.ts => RnaPreset.ts} | 23 +- .../application/editor/tools/SelectLasso.ts | 57 --- .../editor/tools/SelectRectangle.ts | 114 +++++ .../src/application/editor/tools/Tool.ts | 29 +- .../src/application/editor/tools/index.ts | 10 +- .../render/renderers/BaseMonomerRenderer.ts | 157 ++++--- .../render/renderers/BaseRenderer.ts | 102 ++++- .../render/renderers/ChemRenderer.ts | 4 +- .../render/renderers/PeptideRenderer.ts | 10 +- .../render/renderers/PhosphateRenderer.ts | 9 +- .../render/renderers/PolymerBondRenderer.ts | 124 ++++- .../render/renderers/RNABaseRenderer.ts | 9 +- .../render/renderers/RenderersManager.ts | 106 +++++ .../render/renderers/SugarRenderer.ts | 4 +- .../application/render/restruct/restruct.ts | 27 +- .../src/application/render/types.ts | 6 + .../src/domain/entities/BaseMonomer.ts | 14 +- .../src/domain/entities/Command.ts | 13 + .../domain/entities/DrawingEntitiesManager.ts | 432 ++++++++++++++++++ .../src/domain/entities/DrawingEntity.ts | 38 ++ .../src/domain/entities/Operation.ts | 5 + .../src/domain/entities/PolymerBond.ts | 20 +- .../src/domain/services/bond/BondService.ts | 45 -- .../src/Editor.tsx | 38 +- .../src/components/menu/subMenu/SubMenu.tsx | 2 +- .../monomerLibraryGroup/MonomerGroup.tsx | 12 - .../src/state/common/editorSlice.ts | 4 + 77 files changed, 1844 insertions(+), 818 deletions(-) create mode 100644 ketcher-autotests/tests/Macromolecule-editor/Erase-Tool/erase-tool.spec.ts create mode 100644 ketcher-autotests/tests/Macromolecule-editor/Erase-Tool/erase-tool.spec.ts-snapshots/Erase-Tool-Delete-monomer-bonded-with-another-monomers-1-chromium-darwin.png create mode 100644 ketcher-autotests/tests/Macromolecule-editor/Erase-Tool/erase-tool.spec.ts-snapshots/Erase-Tool-Delete-monomer-bonded-with-another-monomers-2-chromium-darwin.png create mode 100644 ketcher-autotests/tests/Macromolecule-editor/Rectangle-Selection-Tool/rectangle-selection-tool.spec.ts create mode 100644 ketcher-autotests/tests/Macromolecule-editor/screenshots/rectangle-selection-tool.png create mode 100644 ketcher-autotests/tests/Macromolecule-editor/screenshots/rectangle-selection-tool2.png create mode 100644 ketcher-autotests/tests/Macromolecule-editor/screenshots/rectangle-selection-tool3.png create mode 100644 ketcher-autotests/tests/utils/macromolecules/index.ts create mode 100644 ketcher-autotests/tests/utils/macromolecules/polymerBond.ts create mode 100644 packages/ketcher-core/__tests__/application/editor/tools/SelectRectangleTool.test.ts create mode 100644 packages/ketcher-core/__tests__/domain/entities/drawingEntitiesManager.test.ts delete mode 100644 packages/ketcher-core/src/application/editor/actions/monomer.ts delete mode 100644 packages/ketcher-core/src/application/editor/actions/polymerBond.ts create mode 100644 packages/ketcher-core/src/application/editor/editorEvents.ts create mode 100644 packages/ketcher-core/src/application/editor/operations/drawingEntity/index.ts delete mode 100644 packages/ketcher-core/src/application/editor/operations/monomer/PresetAdd.ts delete mode 100644 packages/ketcher-core/src/application/editor/operations/polymerBond/polymerBondDelete.ts create mode 100644 packages/ketcher-core/src/application/editor/tools/Erase.ts rename packages/ketcher-core/src/application/editor/tools/{Preset.ts => RnaPreset.ts} (92%) delete mode 100644 packages/ketcher-core/src/application/editor/tools/SelectLasso.ts create mode 100644 packages/ketcher-core/src/application/editor/tools/SelectRectangle.ts create mode 100644 packages/ketcher-core/src/application/render/renderers/RenderersManager.ts create mode 100644 packages/ketcher-core/src/application/render/types.ts create mode 100644 packages/ketcher-core/src/domain/entities/Command.ts create mode 100644 packages/ketcher-core/src/domain/entities/DrawingEntitiesManager.ts create mode 100644 packages/ketcher-core/src/domain/entities/Operation.ts delete mode 100644 packages/ketcher-core/src/domain/services/bond/BondService.ts diff --git a/example/src/PolymerToggler/PolymerToggler.tsx b/example/src/PolymerToggler/PolymerToggler.tsx index bdb6a7ee57..b35a65eab8 100644 --- a/example/src/PolymerToggler/PolymerToggler.tsx +++ b/example/src/PolymerToggler/PolymerToggler.tsx @@ -22,7 +22,7 @@ export interface PolymerTogglerProps { const PolymerToggler = ({ toggle }: PolymerTogglerProps): JSX.Element => { return ( -