-
Notifications
You must be signed in to change notification settings - Fork 165
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
#2088 Selection Tool: use rounded rectangles for selection of bonds and atom labels #2602
#2088 Selection Tool: use rounded rectangles for selection of bonds and atom labels #2602
Conversation
51e7670
to
216c45b
Compare
3c900d6
to
6ec58d3
Compare
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.
Hi @KonstantinEpam23 , almost everything looks good to me.
One thing I'm not sure about is the fill of circle when I'm adding a bond or an atom. I thought the fill would be none because I was just adding a new bond instead of hovering on a selected one. What's your take on this?
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.
Another issue is also about the fill of circle.
Scenario 1
Reproduction steps
- Click Bond Tool
- Click canvas to create a new bond
- Move slowly to the closest atom
Actual behavior
Fill of circle is light green
Expected behavior
Fill of circle would be none, because the atom was not selected
Scenario 2
Reproduction steps
- Click Bond Tool
- Click canvas to create a new bond
- Click Select Tool
- Move slowly to one of the atoms
Actual behavior
Fill of circle is light green
Expected behavior
Fill of circle is none, because the atom is not selected
.circle(ps.x, ps.y, options.atomSelectionPlateRadius) | ||
.attr(options.hoverStyle) | ||
|
||
const result = |
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.
May be we can move this repeating block to a separate function?
|
||
hb1.p = shiftBondEnd(atom1, p1, hb1.dir, 2 * options.lineWidth) | ||
hb2.p = shiftBondEnd(atom2, p2, hb2.dir, 2 * options.lineWidth) | ||
bond.b.center = Vec2.lc2(atom1.a.pp, 0.5, atom2.a.pp, 0.5) |
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.
May be you can add a comment for lc2
(where it is defined)?
For me it is still a mystery, what it does.
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.
@Nitvex I actually just moved the bondRecalc function so it is a static method now, its a bit of a mystery for myself what lc2 does 😄 I'll try to figure it out and a dd a 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.
@KonstantinEpam23 @Nitvex I thought lc was the abbreviation of Linear Combination. The difference between lc()
and lc2()
was the number of arguments they could receive. lc()
could combine lots of vectors, but lc2()
could only combine 2 vectors, so functionality-wise lc2
could be replaced by lc
.
const regularSelectionThikness = doubleBondWidth + bondThickness | ||
|
||
// half-bonds | ||
const hbStart = restruct.molecule.halfBonds.get(bond.hb1!) |
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.
May be we can?
const halfBondStart = restruct.molecule.halfBonds.get(bond.hb1!).p // p at the end
@@ -221,6 +232,40 @@ export class Vec2 { | |||
) | |||
} | |||
|
|||
rotateAroundOrigin(angle: number, origin: 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.
may be we can rename a angle
param to something like angleInDegrees
?
Thx, good catch! Fixed. |
@@ -24,7 +24,7 @@ function defaultOptions(opt) { | |||
if (opt.rotationStep) utils.setFracAngle(opt.rotationStep) |
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.
In options.js we just change the values to suit the new UX
@@ -57,18 +57,167 @@ class ReBond extends ReObject { | |||
return true | |||
} | |||
|
|||
static bondRecalc(bond: ReBond, restruct: ReStruct, options: any): 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.
This function is just converted from member to static function, b/c we need to recalculate bond positions after they moved (it is used later in dropAndMerge.ts)
for (const bondId of bonds) { | ||
const rebond = restruct.bonds.get(bondId) | ||
if (rebond) { | ||
ReBond.bondRecalc(rebond, restruct, editor.options()) |
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.
Here we add bond recalculation b/c without it the position values for halfBonds do not update
drawHover(render: Render) { | ||
const ret = this.makeHoverPlate(render) | ||
render.ctab.addReObjectPath(LayerMap.hovering, this.visel, ret) | ||
return ret | ||
} | ||
|
||
getSelectionPoints(render: Render) { | ||
const bond: Bond = this.b |
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.
halfBondEnd, | ||
-bondThickness * 2.5 | ||
) | ||
|
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.
// rotate the points +/-90 degrees to find the | ||
// perpendicular points that will be used for actual drawing | ||
// of selection contour on canvas | ||
const startTop = startPoint.rotateAroundOrigin( |
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.
angle - 90, | ||
contourPaddedEnd | ||
) | ||
|
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.
Closes #2088