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

#1954 Draw selected structure at mouse cursor after closing Templates window #2079

Conversation

yuleicul
Copy link
Collaborator

@yuleicul yuleicul commented Jan 11, 2023

Resolves #1954

To make the template tool consistent with the paste tool, I marked the previous implementation as deprecated instead of deleting it directly, in case the previous code is helpful to future work.

Bug collections

Bug Status
#2079 (comment) Convert to new issue #2114
#2079 (comment) Convert to new issue #2113
#2079 (comment) Resolved by #2087
#2079 (comment) Redirect to #2091
#2079 (comment)
#2079 (comment)
#2079 (comment) Convert to new issue #2110
#2079 (comment) 1 Redirect to #2109
#2079 (comment) 2 Convert to new issue #2110

Showcase

ketcher-paste-01

Comment on lines 34 to 45
/**
* Why deprecated?
*
* We want to make this tool consistent with `PasteTool`,
* @see https://github.com/epam/ketcher/issues/1954
*
* We know, there will be some features being lost, such as rotation.
* There also will be some bugs, such as multiple attachment atoms.
*
* So, next steps, in `PasteTool`, lost features will be added and bugs will be fixed.
* Keep this file here in case it's helpful to future work.
*/
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indicated why.

@yuleicul yuleicul requested a review from Nitvex January 11, 2023 08:38
@yuleicul yuleicul self-assigned this Jan 11, 2023
@KonstantinEpam23
Copy link
Collaborator

Please note - there is a bit of an issue w/ Paste tool, if you want to select another tool with your mouse while hovering - it will move the scroll position. I dont think this is a particularly big issue, something to note though:

rec-paste-2.mov

@KonstantinEpam23
Copy link
Collaborator

Another edge-case issue w/ Paste tool (I dont think its that important, but good to know) - if you press Ctrl+S (save) on your keyboard - the structure that is being hovered will get into the saved molecule.

rec-paste.mov

@yuleicul
Copy link
Collaborator Author

yuleicul commented Jan 12, 2023

Note another issue with Cut Tool and Copy Tool —— Functional Groups and Salts and Solvents can't be copied or cut.

ketcher-paste-bug-01

@yuleicul
Copy link
Collaborator Author

Note one more, after selecting one of Functional Groups or Salts and Solvents, click Clear Canvas, an error occurs

ketcher-paste-bug-02

@KonstantinEpam23
Copy link
Collaborator

KonstantinEpam23 commented Jan 12, 2023

Note one more, after selecting one of Functional Groups or Salts and Solvents, click Clear Canvas, an error occurs

btw, I cant reproduce this on master

@KonstantinEpam23
Copy link
Collaborator

Note another issue with Cut Tool and Copy Tool —— Functional Groups and Salts and Solvents can't be copied or cut.

looks like #2087 resolves this

@yuleicul yuleicul changed the title Make template tool consistent with paste tool #1954 Draw selected structure at mouse cursor after closing Templates window Jan 13, 2023
@yuleicul
Copy link
Collaborator Author

yuleicul commented Jan 18, 2023

(This bug has been fixed by commit 829fbf2 in this PR)

Bug: when pasting a salt or solvent next to another structure, it shouldn't be merged

Steps to Reproduce

  1. Copy or cut a salt or solvent
  2. Paste it to the canvas
  3. Move your mouse close to other structures, until the green circle shows
  4. Mouse up

Actual behavior
The salt or solvent merges with other structure

Expected behavior
In step 3, the green circle shouldn't be shown. And at last, the salt or solvent shouldn't be merged

Screenshots
ketcher-paste-bug-03

@yuleicul yuleicul marked this pull request as draft January 18, 2023 10:36
@yuleicul
Copy link
Collaborator Author

yuleicul commented Jan 18, 2023

(This bug has been fixed by commit 829fbf2 and 3afa70e in this PR)

Bug: Green hovered circle showing when moving salts and solvents close to other structures by select tool

Steps to Reproduce

  1. Select a salt or solvent
  2. Drag it close to other structures, until the green circle shows
  3. Mouse up, and nothing will be merged

Actual behavior
Described above

Expected behavior
Because it's correct that the salt or solvent doesn't merge with other structures in step 3, it doesn't make sense that in step 2 the green circle shows. The expected behavior is the green circle shouldn't show.

Screenshots
ketcher-paste-bug-04

@yuleicul
Copy link
Collaborator Author

This bug occurs after the two bugs above have been fixed. I guess It's a bit complicated to resolve. Consider creating a new ticket or maybe there are other tickets that are working on it.

Bug: Non-expanded functional group doesn't show the green merging circle because the circle is hidden in the functional group

Steps to Reproduce

  1. Select a functional group
  2. Drag it close to other structures

Actual behavior
The green circle doesn't show

Expected behavior
The green circle shows because it can be merged

Screenshots
ketcher-paste-bug-05

@yuleicul yuleicul marked this pull request as ready for review January 18, 2023 13:33
if (mergeMap.atoms.size === 0 && mergeMap.bonds.size === 0) return null

return mergeMap
}

function omitAtomsAndBondsOfSaltsAndSolventsFromMergeMap(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general, LGTM.
But the only thing I want to clarify – can't mergeMap include 'salt or solvents'?
From this function, I see it doesn't add salt or solvent to a map, but can't they be added before this function gets called? In lines 85-88, there new Map created from atoms and bonds of closestItem:

let mergeMap: MergeMap = {
    atoms: new Map(closestMap.atoms),
    bonds: new Map(closestMap.bonds)
  }

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really good suggestion. Have changed to call this function a bit earlier. Thank you!

@Nitvex
Copy link
Collaborator

Nitvex commented Jan 18, 2023

Found a couple of problems:
image
image
To reproduce this:

  1. Add benzene ring
  2. Choose some salt or solvent
  3. Put it exactly on some atom of benzene ring
    – Acetic acid is merged with benzene ring
    – Acetic acid was added twice
    – If click 'esc' and move mouse, then error in console is thrown

Other problem:

  1. Add benzene ring
  2. Choose some functional group
  3. Put it exactly on some atom of benzene ring
    – Functional group is added twice
    – No green circle is shown, when hovering over atom

This is how it looks like, when adding only one functional group
image

Expected behaviour:
When hovering over an atom with functional group chosen:
image
After adding functional group:
image

@yuleicul yuleicul marked this pull request as draft January 19, 2023 03:11
@yuleicul
Copy link
Collaborator Author

Other problem:

  1. Add benzene ring
  2. Choose some functional group
  3. Put it exactly on some atom of benzene ring
    – Functional group is added twice
    – No green circle is shown, when hovering over atom

This is how it looks like, when adding only one functional group image

Expected behaviour: When hovering over an atom with functional group chosen: image After adding functional group: image

@Nitvex I suppose this one is complicated. I have created a new issue for it, see #2110

@yuleicul
Copy link
Collaborator Author

Found a couple of problems: image image To reproduce this:

  1. Add benzene ring
  2. Choose some salt or solvent
  3. Put it exactly on some atom of benzene ring
    – Acetic acid is merged with benzene ring
    – Acetic acid was added twice
    – If click 'esc' and move mouse, then error in console is thrown

This one is redirected to #2109

}
})

return mergeMap
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we shouldn't separate testing for atoms and bonds involved in merge and cancel merge if there is any sign of salt or solvent at all.
But I'm not sure about all possible consequences, so it's just an assumption for now.

Copy link
Collaborator

@KonstantinEpam23 KonstantinEpam23 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We might want to wait for #2110 and get back to re-implementing this

@St-Permiakov St-Permiakov force-pushed the #1954-draw-selected-structure-at-mouse-cursor-as-pasting-does branch from bbcd21b to a2d0c0b Compare February 20, 2023 06:58
@St-Permiakov St-Permiakov force-pushed the #1954-draw-selected-structure-at-mouse-cursor-as-pasting-does branch from a2d0c0b to fb73c1f Compare February 21, 2023 13:16
@KonstantinEpam23
Copy link
Collaborator

KonstantinEpam23 commented Mar 6, 2023

I can observe an issue where the tooltip appears for previous functional groups if you start inserting multiple ones. I believe this should be fixed before merging.
Screenshot 2023-03-06 at 03 03 09

@KonstantinEpam23
Copy link
Collaborator

One more note - it seems to lag a bit when devtools are open and a benzene ring is following cursor around the canvas.

@KonstantinEpam23 KonstantinEpam23 merged commit 932733d into master Mar 10, 2023
@KonstantinEpam23 KonstantinEpam23 deleted the #1954-draw-selected-structure-at-mouse-cursor-as-pasting-does branch March 10, 2023 13:30
@KonstantinEpam23 KonstantinEpam23 restored the #1954-draw-selected-structure-at-mouse-cursor-as-pasting-does branch March 23, 2023 09:01
@KonstantinEpam23 KonstantinEpam23 deleted the #1954-draw-selected-structure-at-mouse-cursor-as-pasting-does branch March 23, 2023 09:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Draw selected structure at mouse cursor after closing Templates window
4 participants