cheminfo / jsme

19 stars 5 forks source link

multiple "readMolFile" events ? #4

Closed lpatiny closed 8 years ago

lpatiny commented 8 years ago

When I do a

jsmeApplet.readMolFile(mol);

I have the impression that

jsmeApplet.setAfterStructureModifiedCallback(changeCallback);

throws 3 times the "readMolFile" action event.

image

And I think it should be only 1 time

lpatiny commented 8 years ago

@brunob54

brunob54 commented 8 years ago

I have not be abled to reproduce this issue. I added a readMolfile function to the html test page named JSME_callback_and_star.html tha logs all the events. There was a problem with reading JME strings (double events). The readMolFIle() works OK in this test.

lpatiny commented 8 years ago

Sorry indeed it was on our side. I need to use a 'setTimeout' in order to be able to extract the SVG from JSME of the currently drawn molecule and the consequence is that we had the reset event and setMolfile event that where send but interpreted twice as setMolfile.

It would be nice if we could make a setMolfile followed directly by getMolecularAreaGraphicsString. However if we do this we get systematically the previous state. Is it possible to send the event once the Graphics Area has been actually updated ?

Here is what we currently have to do: https://github.com/NPellet/visualizer/blob/250745b7b60ef175f77ee47f0a39e980d0810a3f/src/modules/types/science/chemistry/jsme/jsme.html#L66-L85

brunob54 commented 8 years ago

I changed the behavior of readMolfile(). The event for setAfterStructureModifiedCallback is sent now after the applet repaint(), thus after the SVG has been updated. Have a try and let me know if this fixes the problem.

lpatiny commented 8 years ago

The last commit really solve all my issues, thanks. https://github.com/cheminfo/jsme/commit/e86b35bfb836316d11eab801712b5535944a7dc8