There's something that's always annoyed me when using Avogadro. On Windows, it often takes several clicks on a hydrogen before I hit the sweet spot and it sprouts a methyl group. This is only mildly annoying when building a structure, but very frustrating for operations where misclicking cause it to lose selection (e.g. rotating around a dihedral). It's awkward to report a bug about this though because it's hard to prove.
Enter Sikuli. It's a Java application running Jython that's used for testing GUIs (among other things). It uses a sort of visual programming style to match regions of the screen based on screenshots and carry out operations based on whether or not a match exists. (At this point you may want to check out the videos on the Sikuli website to figure out what I'm talking about.)
My original idea was to get Sikuli to click all over the offending hydrogen and see which points worked and which didn't. In the interests of time, I reduced this down to all points on a horizontal line through the centre of the hydrogen. First of all, here is the result, with the 'allowed area' indicated by the red line:
I would argue that that red line is neither long enough nor in the expected location. In any case, check out the sort of code needed to run this test:
You mightn't understand everything here, but you should get the gist. On every iteration of the loop it clears the Avogadro window, clicks to create a methane, and then clicks at point x, y on a particular hydrogen (where x, y are relative to the centre of the image of the matched hydrogen) trying to sprout a methyl. The "success test" checks that a methyl sprouted. The "fail test" checks whether a methane was added (i.e. the region to the right of the red bar in the diagram of the atom above). Note that fuzzy matching is used to match screenshots against the actual contents of the screen or a region.
Apparently, "that's not a bug, it's a feature" ;-)
ReplyDeletehttps://github.com/cryos/avogadro/commit/f95f23fcea
Post this on the avogadro-devel mailing list. We might be able to just remove the "slop" factors entirely, but let's find out why they were added first.
Nice find, but dude, with features like this who needs bugs? :-)
ReplyDeleteI'm open to suggestions. The flip side of this is when you're drawing things with "auto add hydrogens" and it's a pain to click on the carbons and *not* the hydrogens. (Try, for example, to ring-close cyclohexane.)
ReplyDeleteSo that's where the feature comes. If you have elegant suggestions, I'm all ears. I obviously want it to be as intuitive as possible and would be happy to remove this.
Ok - that's good to know. But is it possible to treat the special case differently, rather than altering behaviour across the board? For me, the intuitive place to click is in the centre.
ReplyDeleteReplied to mailing list post, but for posterity/anyone reading along...it never felt right to me either, but it was hard to gauge how many people were wanting to click on a hydrogen to do stuff (such as change element type to build up a larger molecule with add hydrogens). I would argue that for many structures drawing the backbone and adding hydrogens at the end is the quickest way, but we obviously want to be as flexible as we can here and many people like the addition of hydrogens as they go.
ReplyDeleteIt looks to me like the center is just pushed to where the center of the sphere is, with a smaller radius, due to the perspective projection. I once changed the code a little to look at rendered versus picking spheres, it wouldn't be hard to render that to show more clearly what is happening and perhaps at least tweak if not remove this. It probably wouldn't take much to add an option to turn this on and off, as we did for the navigation rendering you didn't like.