diff --git a/api/tests/integration/ref/rendering/basic.py.out b/api/tests/integration/ref/rendering/basic.py.out index dddc112d3f..9d4e63ae14 100644 --- a/api/tests/integration/ref/rendering/basic.py.out +++ b/api/tests/integration/ref/rendering/basic.py.out @@ -22,3 +22,5 @@ bond-length-options-3.png rendering status: OK smart-layout-crown.png rendering status: OK ****** Nameless S-Group ***** sa-mono.png rendering status: OK +issue 2746 incorrect phosphorus valence +incorrect_phosphorus_valence_2746.png rendering status: OK diff --git a/api/tests/integration/tests/rendering/basic.py b/api/tests/integration/tests/rendering/basic.py index 7cc904239e..a5922f87a9 100644 --- a/api/tests/integration/tests/rendering/basic.py +++ b/api/tests/integration/tests/rendering/basic.py @@ -162,6 +162,16 @@ renderer.renderToFile(mol, joinPathPy("out/sa-mono.png", __file__)) print(checkImageSimilarity("sa-mono.png")) +print("issue 2746 incorrect phosphorus valence") +indigo.resetOptions() +indigo.setOption("render-output-format", "png") +fname = "incorrect_phosphorus_valence_2746" +png_fname = fname + ".png" +cdxml_fname = joinPathPy("molecules/%s.cdxml" % fname, __file__) +mol = indigo.loadMoleculeFromFile(cdxml_fname) +renderer.renderToFile(mol, joinPathPy("out/" + png_fname, __file__)) +print(checkImageSimilarity(png_fname)) + if isIronPython(): renderer.Dispose() indigo.Dispose() diff --git a/api/tests/integration/tests/rendering/molecules/incorrect_phosphorus_valence_2746.cdxml b/api/tests/integration/tests/rendering/molecules/incorrect_phosphorus_valence_2746.cdxml new file mode 100644 index 0000000000..259d3bf6e6 --- /dev/null +++ b/api/tests/integration/tests/rendering/molecules/incorrect_phosphorus_valence_2746.cdxml @@ -0,0 +1,389 @@ + + + + + + + + + + + + + + +PhPPhPh \ No newline at end of file diff --git a/api/tests/integration/tests/rendering/ref/linux/incorrect_phosphorus_valence_2746.png b/api/tests/integration/tests/rendering/ref/linux/incorrect_phosphorus_valence_2746.png new file mode 100644 index 0000000000..a8503170dc Binary files /dev/null and b/api/tests/integration/tests/rendering/ref/linux/incorrect_phosphorus_valence_2746.png differ diff --git a/api/tests/integration/tests/rendering/ref/mac/incorrect_phosphorus_valence_2746.png b/api/tests/integration/tests/rendering/ref/mac/incorrect_phosphorus_valence_2746.png new file mode 100644 index 0000000000..a8503170dc Binary files /dev/null and b/api/tests/integration/tests/rendering/ref/mac/incorrect_phosphorus_valence_2746.png differ diff --git a/api/tests/integration/tests/rendering/ref/win/incorrect_phosphorus_valence_2746.png b/api/tests/integration/tests/rendering/ref/win/incorrect_phosphorus_valence_2746.png new file mode 100644 index 0000000000..a8503170dc Binary files /dev/null and b/api/tests/integration/tests/rendering/ref/win/incorrect_phosphorus_valence_2746.png differ diff --git a/core/render2d/src/render_internal.cpp b/core/render2d/src/render_internal.cpp index 2655125171..1accc60150 100644 --- a/core/render2d/src/render_internal.cpp +++ b/core/render2d/src/render_internal.cpp @@ -866,6 +866,7 @@ void MoleculeRenderInternal::_prepareSGroups(bool collapseAtLeastOneSuperatom) int neighboringBondID = v.neiEdge(j), bondID = -1; if (mol.findEdgeIndex(neighboringAtomID, superAtomID) < 0) { + int oldBondMappingInvPosition = _bondMappingInv.at(neighboringBondID); if (mol.isQueryMolecule()) { QueryMolecule& qm = mol.asQueryMolecule(); @@ -874,13 +875,16 @@ void MoleculeRenderInternal::_prepareSGroups(bool collapseAtLeastOneSuperatom) else { Molecule& amol = mol.asMolecule(); + int oldBondTopology = amol.getBondTopology(neighboringBondID); + int oldBondDirection = amol.getBondDirection(neighboringBondID); + amol.removeBond(neighboringBondID); bondID = amol.addBond(neighboringAtomID, superAtomID, amol.getBondOrder(neighboringBondID)); - amol.setEdgeTopology(bondID, amol.getBondTopology(neighboringBondID)); - amol.setBondDirection(bondID, mol.getBondDirection(neighboringBondID)); + amol.setEdgeTopology(bondID, oldBondTopology); + amol.setBondDirection(bondID, oldBondDirection); } if (_bondMappingInv.find(bondID) != _bondMappingInv.end()) _bondMappingInv.erase(bondID); - _bondMappingInv.emplace(bondID, _bondMappingInv.at(neighboringBondID)); + _bondMappingInv.emplace(bondID, oldBondMappingInvPosition); } } }