partridgejiang / Kekule.js

A Javascript cheminformatics toolkit.
http://partridgejiang.github.io/Kekule.js
MIT License
248 stars 61 forks source link

Molecule absCoord2D didn't update after moving #249

Closed lsdsjy closed 2 years ago

lsdsjy commented 2 years ago

As posted below, a molecule is moved using marquee manipulate tool(also tried other manipulation tools), its descendants' absCoord2D are correct, but its own absCoord2D property is not updated correspondingly. Is it a feature or a bug? descendant molecule

partridgejiang commented 2 years ago

Hi @lsdsjy, to some degree, it is a feature. When using the marquee tool, only atoms (not the molecule) are selected and moved. Therefore the coordinates of atoms are changed but the coordinate of molecule is retained. However, if the molecule itself is selected (from the structure tree or by the select molecule tool) and moved, the coordinates of molecule will surely be modified.

lsdsjy commented 2 years ago

@partridgejiang thanks for your reply but I tried both selecting from the structure tree and selecting by select molecule tool, it still doesn't work. (FYI, I used https://partridgejiang.github.io/Kekule.js/demos/items/chemEditor/chemEditor.html for experiments.)

partridgejiang commented 2 years ago

Sorry I have made a mistake... the actual objects changing coordinates when moving are determined by getCoordDependentObjects method of object. To an instance of Molecule, this method returns its child atoms. So the coordinate of molecule will not change in normal manipulations of editor.

lsdsjy commented 2 years ago

I see... so maybe I should use the child atoms to calculate the actual position of the molecule object. Thanks!