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

Backmerge: #5910 – Fix closest sgroup detection to allow focusing on entities within expanded monomer's bounding box #6137

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
2 changes: 1 addition & 1 deletion example/.env
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
SKIP_PREFLIGHT_CHECK=true
REACT_APP_API_PATH=/v2
PUBLIC_URL=./
GENERATE_SOURCEMAP = false
GENERATE_SOURCEMAP = false
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 16 additions & 1 deletion packages/ketcher-react/src/script/editor/shared/closest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,22 @@ function findClosestSGroup(restruct: ReStruct, pos: Vec2) {
let minDist = SELECTION_DISTANCE_COEFFICIENT;

restruct.molecule.sgroups.forEach((sg, sgid) => {
if (sg.isContracted() || sg.isSuperatomWithoutLabel) return;
if (sg.isSuperatomWithoutLabel) {
return;
}

if (sg.isContracted()) {
const sGroupPosition = sg.pp;
if (sGroupPosition) {
const dist = Vec2.dist(pos, sGroupPosition);
if (dist < minDist) {
ret = sgid;
minDist = dist;
}
}

return;
}

const d = sg.bracketDirection;
const n = d.rotateSC(1, 0);
Expand Down
2 changes: 1 addition & 1 deletion packages/ketcher-react/src/script/editor/tool/eraser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ class EraserTool implements Tool {
} else if (ci.map === 'bonds') {
this.editor.update(fromOneBondDeletion(restruct, ci.id));
} else if (
ci.map === 'functionalGroups' &&
(ci.map === 'sgroups' || ci.map === 'functionalGroups') &&
FunctionalGroup.isContractedFunctionalGroup(ci.id, functionalGroups)
) {
const sGroup = sgroups.get(ci.id);
Expand Down
5 changes: 3 additions & 2 deletions packages/ketcher-react/src/script/editor/tool/template.ts
Original file line number Diff line number Diff line change
Expand Up @@ -251,8 +251,9 @@ class TemplateTool implements Tool {
});

if (
// if point is functional group and it is not expanded
this.closestItem?.map === 'functionalGroups' &&
// if point is functional group/sgroup and it is not expanded
(this.closestItem?.map === 'functionalGroups' ||
this.closestItem?.map === 'sgroups') &&
FunctionalGroup.isContractedFunctionalGroup(
this.closestItem.id,
this.functionalGroups,
Expand Down
Loading