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

#1990: Functional group does not connect with another functional group on click&drag #2208

Conversation

St-Permiakov
Copy link
Collaborator

@St-Permiakov St-Permiakov commented Feb 13, 2023

Fixed

  • Attaching salt or solvent with mousemove to atoms

Added

  • Create bond between groups when adding a group with Template or Paste tool
  • Get attachment atom id method in sgroup entity (needs fixed MOL files to work properly)

Refactored

  • getGroupsIdsFromBondId — since bond can belong to more than one group, it should return array and not single number. Previously added `getGroupIdFromBondId" left for compatibility purposes and should be removed later
  • findClosestFG extended with possibility to skip items, but for now not used (replaced with easier solution). Potentially required to get target group for hover when pasting/inserting another group (to avoid editor picking the same group you're pasting as "closest")

@St-Permiakov St-Permiakov force-pushed the #1990-functional-group-does-not-connect-with-another-functional-group-on-clickdrag branch from 941319b to 5d7b2a3 Compare February 16, 2023 08:53
@St-Permiakov St-Permiakov force-pushed the #1990-functional-group-does-not-connect-with-another-functional-group-on-clickdrag branch from 8211e49 to 3bed375 Compare February 16, 2023 09:01
@St-Permiakov St-Permiakov changed the title #1990 - Detect if group is attached to smth + get attachment atom #1990: Functional group does not connect with another functional group on click&drag Feb 16, 2023
@St-Permiakov St-Permiakov marked this pull request as ready for review February 16, 2023 09:01
Stanislav Permiakov added 2 commits February 16, 2023 15:36
@@ -403,7 +354,7 @@ class TemplateTool {
let action
let pasteItems = null

if (SGroup.isSaltOrSolvent(this.template.molecule.name)) {
if (this.isSaltOrSolvant) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
if (this.isSaltOrSolvant) {
if (this.isSaltOrSolvent) {

xy0?: Vec2
angle0?: number
}
function prepareTemplateFromSingleGroup(molecule: Struct): Template | null {
Copy link
Collaborator

Choose a reason for hiding this comment

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

May be we need to add some comment that this function calculates the position of FG and its rotation angle?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Added.


constructor(editor, struct) {
this.editor = editor
this.editor.selection(null)
this.struct = struct

this.isSingleContractedGroup =
struct.isSingleGroup() && !struct.functionalGroups.get(0).isExpanded
Copy link
Collaborator

Choose a reason for hiding this comment

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

Hmm, are you sure we can rely on 0 ?
I guess, in this case we need to get first FG by something like struct.functionaGroups.values().next()

Copy link
Collaborator Author

@St-Permiakov St-Permiakov Feb 21, 2023

Choose a reason for hiding this comment

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

I am sure.
If id is something else than 0, it should be treated as a bug and fixed.
This "struct" is considered to be a brand-new structure with ids different from actual canvas.
And if first (and only, as we verify beforehand) group has non-0 id, it's a clear marker of a bug.

@St-Permiakov St-Permiakov merged commit cb487e5 into master Feb 21, 2023
@St-Permiakov St-Permiakov deleted the #1990-functional-group-does-not-connect-with-another-functional-group-on-clickdrag branch February 21, 2023 13:25
ansivgit pushed a commit that referenced this pull request Feb 22, 2023
…p on click&drag (#2208)

* #1990 - Detect if group is attached to smth + get attachment atom

* #1990 - template tool mousedown() refactor

* #1990 - Functional group does not connect with another functional group on click&drag

* #1990 - #2195 merge fixes

* #1990 - cleanup

* #1990 - hotfix

* #1990 - fixes and clarifications after review

---------

Co-authored-by: Stanislav Permiakov <Stanislav.Permiakov@primark.onmicrosoft.com>
Co-authored-by: Stanislav Permiakov <stanislav_permiakov@epam.com>
@yuleicul yuleicul restored the #1990-functional-group-does-not-connect-with-another-functional-group-on-clickdrag branch February 28, 2023 09:06
@yuleicul yuleicul deleted the #1990-functional-group-does-not-connect-with-another-functional-group-on-clickdrag branch February 28, 2023 09:39
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.

Functional group does not connect with another functional group on click&drag
2 participants