Hi,
since i feel guilty for not yet having put comments/documentation, here’s a
quick update on what recently changed:
- new class MolGeomInfo. It stores radius,center,normal vector and farthest
atom of a molecule. It doesn’t auto-update, you have to call
MolGeomInfo::compute(molecule) manually. No need to update everytime an atom
moves, only at the end of molecule loading and after every subsequent atom
creation/deletion (bonds don’t matter here). - class GLWidget now has a member d->molGeomInfo. It is updated by method
GLWidget::updateGeomInfo(). - class Molecule consequently shrinks and no longer has a d-pointer.
- new class Camera. It has a 4x4 modelview matrix to pass to opengl, using
Eigen to provide translation/rotation methods. It also stores the viewing
angle (default 40°) and, more importantly, a pointer to the parent GLWidget.
It uses it to call parent->molGeomInfo(), retrieving geometric info about the
current molecule, and using it so automatically set up a nice viewpoint
(Camera::initializeViewPoint()) and apply a nice OpenGL perspective
projection (Camera::applyPerspective()). This solves the classical issue when
an object would get clipped when it’s too close or too far from the camera. - Feature from Kalzium: automatic double-bonds orientation. Engine::render now
takes a reference to a MolGeomInfo. It uses it to draw multiple bonds in such
a way that from the default viewpoint, they don’t look like single bonds.
Thus Cylinder::draw now takes an additional argument, planeNormalVector. - Draw::moveAtom now lets the atom move in the plan that’s parallel to the
screen and passing through the molecule center. If you want to move in
another plane, just rotate the view. Formerly, the plane of movement was
arbitrary and thus unintuitive for the user.
The issues with empty molecules (impossible to create atoms, etc) are solved.
I hope to document that ASAP.
Cheers,
Benoit