#118 Improve highlight/select speed

cdk.render (13)

Currently, changing the highlight on a rendered molecule will cause the whole diagram to be re-generated from the model. This slows things down considerably.

There is a similar situation for actively selecting - for each point created on the lasso selection, all the bond lines and atom text symbols are recreated. Since a typical lasso has 10s to 100s of points, this is a waste of cycles.

A solution would be to have different methods in the event relay (beyond updateView) for different situations - highlight, select, etc. The renderer would then have to activate the generator appropriate to the situation, remove the elements to be regenerated, and make only the necessary new elements. This may well require that the ElementGroup class have some kind of label to identify its children as belonging to a particular type.

Note that this needs to be done carefully so that the diagram does not get out of sync with the model. The simplest and most guaranteed rendering is always to regenerate the diagram for every change, no matter how minor, but this is at least as expensive as direct rendering, if not worse.


Log in to post a comment.