Hi,
I have talked with Benoit and Donald about this on IRC. After chatting with
Donald earlier I think it might be a good idea to write down my ideas. This
will hopefully let everyone know what my intentions are as well as giving you
a chance to point out flaws in my thinking or better methodologies for
implementing these features.
- Goal
The goal of having multiple painters is to provide some level of independence
for the engines from the particular method of rendering the molecular
structure. This will immediately allow me to write a POVPainter in order to
output the scene as POVRay primitives for high quality ray tracing.
It will also allow us to write an alternate painter that takes advantage of
programmable OpenGL shaders such as those used by Qutemol to render awesome
images using relatively few triangles for the spheres etc. Other targets
could include writing a gl2ps painter to take advantage of the gl2ps library
and an SVG painter to export our scenes as SVG.
- Possible Implementations
It could be implemented in a very similar fashion to the tools, engines etc
where a base class is written with all core functions. Each painter would
then take care of the specifics for that particular rendering surface. This
was the initial approach I took.
Donald suggested that a PaintEngine approach could be taken where we have a
painter that can use different PaintEngines depending up on the rendering
surface. This is the way that Qt does this and so it could be advantageous to
remain consistent with Qt. I need to read up a little on this approach.
Either approach would also necessitate having a base rendering surface too -
i.e. something the current GLWidget would inherit from. It would also mean
that the engines would not be passed a GLWidget but a painter. So all drawing
operations would need to be encapsulated in the painter/paint engine.
- Conclusions
There are probably other ways that this could be implemented. I was going to
work on this tomorrow. As Donald pointed out nothing would be set in stone
and the API could be improved if it were found to be lacking. I am open to
suggestions on how people would like to see this implemented.
The engines would remain largely unchanged, simply
calling ::drawSphere(), ::drawText(), ::drawCylinder(), ::drawRibbon() (soon)
etc. It would be up to the painter to implement the low level drawing.
Thanks,
Marcus