It’s not something we can fix for 2.1. It’s just the way the OBMol
works. I’ll do my best to explain what is happening.
In Avogadro we subclassed OBMol and then implemented the virtual
Create* function so that we can do callbacks when things are created.
But lets take for instance CreateAtom.
At the time CreateAtom is called we know nothing about the atom (no
coordinates, no element type), just that it was created. So I can add
this atom to the GLWidget view, but it will not render it in the desired
location because again, at the time of calling CreateAtom we don’t know
the coordinates of the atom. This means that in the “draw” tool we have
to do the atom creation and then once we have actually set the
coordinates, we have to make another call (which i designed as
::update()) which says, “hey, coordinates changed for this atom better
redraw”. And the draw tool needs to keep pointers to atoms which it’s
created at least while it’s running.
This is avoided when we “load” for the following reason: when the
GLWidget::setMolecule() is called the GLWidget gets all the
Atoms/Bonds/Residues that already exist and add it to the view, then
connects to the Molecules signals “watching” for changes after it’s been
initially loaded.
I just think that it would be more convenient in the future (3.0) to not
require the users of libopenbabel to have to use OBMol::NewAtom to add
new atoms. ie. I should be able to create a new Atom pointer, setup
the coordinates, THEN add it to the molecule with the stipulation that
my "new"ly allocated atom is added, not a copy of my atom. Because
after i add a new atom i want to keep my pointer to the same atom.
I think this has never been a big issue because normally Molecules are
created and destroyed, not really modified all that much. So using
indexes was a fine approach, but this isn’t the best approach for us and
having to rely on indexes is much more error prone in my opinion.
(Wed, Mar 14, 2007 at 01:49:34PM -0400) Geoffrey Hutchison geoff.hutchison@gmail.com:
On Mar 14, 2007, at 2:36 PM, Donald Ephraim Curtis wrote:
This isn’t bad, it just means that at the point i add my atom to the
molecule it doesn’t have the coordinates that i want (ie. NewAtom()
sets
to 0 coordinates or something).
Yes, it really creates a new atom, just like “new OBAtom” would.
I guess what I’m saying is that I don’t see a problem. But if you do,
please let me know so we can fix it before 2.1 is released.
Thanks,
-Geoff
(Wed, Mar 14, 2007 at 01:49:34PM -0400) Geoffrey Hutchison geoff.hutchison@gmail.com:
On Mar 14, 2007, at 2:36 PM, Donald Ephraim Curtis wrote:
This isn’t bad, it just means that at the point i add my atom to the
molecule it doesn’t have the coordinates that i want (ie. NewAtom()
sets
to 0 coordinates or something).
Yes, it really creates a new atom, just like “new OBAtom” would.
I guess what I’m saying is that I don’t see a problem. But if you do,
please let me know so we can fix it before 2.1 is released.
Thanks,
-Geoff