Hi,
today I committed my auto-center-and-fit-in-XY-plane feature. Finally I
thought it made sense to combine both in one function, tell me if that’s not
OK.
Finally I put it in Molecule, not in GLWidget, I think that makes more sense,
hope I got your design right.
Just to demonstrate it, I added a call to it from GLWidget::setMolecule.
But anyway, it will have to be completely modified for Avo: as Geoff said,
changing the molecule’s coordinate system is not good for a molecular
editor (while for Kalzium it was OK).
I propose to do the following changes if you’re OK:
- replace the translationVector, rotation and scaling by a single 4x4
modelview matrix, using Eigen::MatrixP3d. - at molecule loading, don’t change the molecule coords; instead, compute a
sensible default modelview matrix, reusing my auto-center-and-fit-in-XY-plane
code, and auto-adjusting to the molecule’s radius. - store separately the "approximate normal vector to the molecule’s plane"
computed in previous step - modify (or overload) Cylinder::draw to take this normal vector as argument,
using it for auto-orientation of double bonds. This doesn’t mean any overhead,
thanks to using OpenGL display lists.
After all, the only reason why I wanted to change molecule coordinates, was
that it allowed to make Cylinder::draw slightly simpler. Not anything
fundamental…
Cheers,
Benoit