Suggestion on GL Views

Here is what i came up with as a solution to multiple views on the same
molecule.

We start with basic wrapper classes; Molecule / Atom / Bond. The reason
for this will become more apparent after i explain the rest.

Next we have MoleculeView / AtomView / BondView. This is more like the
current primatives we have (have the “render” functions). Each GLWidget
contains a MoleculeView. MoleculeView has a pointer to the Molecule for
the window. Same goes to AtomView and BondView (pointers to Atom and
Bond respectively).

Now, the benefit of the Molecule class is that we overload any functions
that need to impact the views. And then everytime we start a new view,
we register it with the Molecule. That way when we need to do drawing
and such; we only manipulate the Molecule class AND even better, the
syntax for plugins to manipulate the Molecules is exactly like OB.

It’s a problem of accessing the primatives from both the directions; the
GL interface and the MainWindow.

One suggestion i have is that functions we use from OB should be
virtual. That way we can write an operational library (say FF
calculations) that works on OBMol. If the OBMol functions are virtual
and we pass our Molecule to the operational library it’ll call our
virtual functions. This also means that any operational library we
develop will work with and without avogadro. (like our geometric
optimizaion functions).

On another note; at one point we were talking about a render queue.
It’s possible we could still do this but with the use of Display Lists
it doesn’t make much sense. If you’re still thinking about this i’d be
interested in what you’re thinking or at least how you’re thinking about
the implementation.

-Donald

On Aug 21, 2006, at 1:02 PM, Donald Ephraim Curtis wrote:

Here is what i came up with as a solution to multiple views on the
same
molecule.

Now, the benefit of the Molecule class is that we overload any
functions
that need to impact the views. And then everytime we start a new
view,
we register it with the Molecule.

Yes, I think this is exactly right. As far as “register it with the
molecule,” I think that can be done with Qt signals/slots:
http://doc.trolltech.com/4.2/signalsandslots.html

So the Molecule class will have a signal “update” or “changed” which
is emit anytime something significant happens (e.g., NewAtom,
NewBond, DeleteAtom, DeleteBond…).

Then anything which needs notification can connect a slot to a
particular object.

I guess this implies that those four functions should be made virtual
in Open Babel so that Avogadro can overload them. I guess atom and
bond assignment too. (e.g., rather than make every single Get/Set
access method in Open Babel virtual, make the assignment operators
virtual, and operate on temporaries)

On another note; at one point we were talking about a render queue.
It’s possible we could still do this but with the use of Display Lists
it doesn’t make much sense.

No, it doesn’t make much sense. It’s already rolled into the idea of
having a list of render engines in a given GLWidget. I worried that
rendering can get intense, so it’s better to spin off a thread just
for rendering which hands off a list of GL Display Lists. I don’t
think this is going to be a significant problem. For example, Apple
has just pushed out an example of multithreaded OpenGL, which I
suspect will be copied quickly.

Cheers,
-Geoff