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

#2332 - Add peptide monomers to canvas (by click) #2995

Merged
merged 1 commit into from
Aug 9, 2023

Conversation

rrodionov91
Copy link
Collaborator

@rrodionov91 rrodionov91 commented Jul 28, 2023

Closes #2332

  • added an ability to add peptides on canvas and move by drag n drop

How the feature works? / How did you fix the issue?

Screen.Recording.2023-07-28.at.16.36.05.mov

Check list

  • unit-tests written
  • e2e-tests written
  • documentation updated
  • PR name follows the pattern #1234 – issue name
  • branch name doesn't contain '#'
  • PR is linked with the issue
  • base branch (master or release/xx) is correct
  • task status changed to "Code review"

return true;
}

// if (eventName !== 'mouseup' && eventName !== 'mouseleave') {
Copy link
Contributor

Choose a reason for hiding this comment

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

do we need this comment?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Same here

return true;
}

return true;
Copy link
Contributor

Choose a reason for hiding this comment

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

So basically, this function return true in any case. Is that ok?
Also, why does it return value at all?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I copy pasted it from ketcher-react Editor. In future we are going to replace it by ketcher-core Editor.

if (!editorTool) {
return false;
}
// this.lastEvent = event;
Copy link
Contributor

Choose a reason for hiding this comment

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

do we need this comments?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Same here. It will be uncommented in future

restruct.peptides.set(newPeptide.id, peptideRenderer);
}

invert() {
Copy link
Contributor

Choose a reason for hiding this comment

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

what for do we use this method?
Actually, maybe you can add some short comments about main methods and their purpose, where applicable? I don't insist, just idea. In this PR are a lot new methods that will be used somewhere in the future, so maybe some short explanation will help. Is it ok?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Operations are a part of regular ketcher. I just used the same interface

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

For sure it should be documented, however I'm not sure that in this PR, because it is quite big and the main part of it is related to peptides mainly

class PeptideTool implements Tool {
private peptidePreview: Peptide | undefined;
private peptidePreviewRenderer: PeptideRenderer | undefined;
readonly PEPTIDE_PREVIEW_SCALE_FACTOR = 0.4;
Copy link
Contributor

Choose a reason for hiding this comment

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

Why this exact numbers? Just curious)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

To match the design. Preview is less than a regular peptide in this scale factor

@@ -652,6 +664,13 @@ class ReStruct {
});
}

private showPeptides(): void {
this.peptides.forEach((peptideRenderer) => {
peptideRenderer.remove();
Copy link
Contributor

Choose a reason for hiding this comment

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

why do we first remove it?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We need it to rerender. In future we will be able to rerender only parts which are actually need to be rerendered, not all ones

>
<defs>
<symbol id="peptide" viewBox="0 0 70 61" width="70" height="61">
<path d="M16.9236 1.00466C17.2801 0.383231 17.9418 6.10888e-07 18.6583 5.98224e-07L51.3417 2.04752e-08C52.0582 7.81036e-09 52.7199 0.383234 53.0764 1.00466L69.4289 29.5047C69.7826 30.1211 69.7826 30.8789 69.4289 31.4953L53.0764 59.9953C52.7199 60.6168 52.0582 61 51.3417 61H18.6583C17.9418 61 17.2801 60.6168 16.9236 59.9953L0.571095 31.4953C0.217407 30.8789 0.217408 30.1211 0.571096 29.5047L16.9236 1.00466Z"></path>
Copy link
Contributor

Choose a reason for hiding this comment

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

Idk, maybe move it to separate file? I looks not very beautiful here xD

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah good idea. Let me do it in the nest pr related to this topic

@SashaGraves SashaGraves self-requested a review August 4, 2023 09:03
@rrodionov91 rrodionov91 force-pushed the 2332-add-peptides-to-canvas branch from c69dce2 to 3a5cd1f Compare August 8, 2023 10:21
- added an ability  to add peptides on canvas and move by drag n drop
@rrodionov91 rrodionov91 force-pushed the 2332-add-peptides-to-canvas branch from 3a5cd1f to 1c6f094 Compare August 8, 2023 10:33

class SelectLasso implements Tool {
private isMouseDown = false;
private selectedItem;
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

add type

this._position.y += position.y;
}

public moveAbsolute(position: Vec2) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

consider change to point


public get textColor() {
const WHITE = 'white';
const colorsMap = {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Add type

return canvas
.append('g')
.data([this])
.attr('transition', 'transform 0.2s')
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

remove

this.canvas = select<SVGElement, unknown>('#polymer-editor-canvas');
}

public abstract show(theme): void;
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

type

@rrodionov91 rrodionov91 merged commit 6bfc0f9 into master Aug 9, 2023
@rrodionov91 rrodionov91 deleted the 2332-add-peptides-to-canvas branch August 9, 2023 08:40
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.

Add peptide monomers to canvas (by click)
3 participants