-
Notifications
You must be signed in to change notification settings - Fork 177
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
Conversation
fd0ddde
to
c69dce2
Compare
return true; | ||
} | ||
|
||
// if (eventName !== 'mouseup' && eventName !== 'mouseleave') { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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() { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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(); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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> |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
c69dce2
to
3a5cd1f
Compare
- added an ability to add peptides on canvas and move by drag n drop
3a5cd1f
to
1c6f094
Compare
|
||
class SelectLasso implements Tool { | ||
private isMouseDown = false; | ||
private selectedItem; |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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 = { |
There was a problem hiding this comment.
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') |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
type
Closes #2332
How the feature works? / How did you fix the issue?
Screen.Recording.2023-07-28.at.16.36.05.mov
Check list
#1234 – issue name