From 5fb2726c47d5a6b8410131a06e7ef660b63da0cd Mon Sep 17 00:00:00 2001 From: Aliaksandr Dziarkach <18146690+AliaksandrDziarkach@users.noreply.github.com> Date: Thu, 17 Aug 2023 10:31:24 +0300 Subject: [PATCH] #1224 Different indent after loading reaction from file and after layout it (#1227) Co-authored-by: Aliaksandr Dziarkach --- api/c/indigo/src/indigo_internal.h | 4 +- api/c/indigo/src/indigo_layout.cpp | 4 +- .../ref/formats/rxn_no_layout.py.out | 196 ++-- .../tests/basic/ref/crazystereo.ket | 888 +++++++++--------- .../tests/layout/ref/932-agents.ket | 118 +-- .../tests/layout/ref/reaction_layout.rdf | 56 +- .../integration/tests/layout/ref/test1.rxn | 54 +- .../tests/layout/ref/test_sgroup.rxn | 28 +- core/indigo-core/layout/molecule_layout.h | 1 + core/indigo-core/layout/reaction_layout.h | 8 +- .../layout/src/reaction_layout.cpp | 36 +- 11 files changed, 694 insertions(+), 699 deletions(-) diff --git a/api/c/indigo/src/indigo_internal.h b/api/c/indigo/src/indigo_internal.h index cb692e671d..12b6a1c58b 100644 --- a/api/c/indigo/src/indigo_internal.h +++ b/api/c/indigo/src/indigo_internal.h @@ -34,6 +34,8 @@ #include "base_cpp/exception.h" #include "base_cpp/io_base.h" +#include "layout/reaction_layout.h" + #include "molecule/molecule_fingerprint.h" #include "molecule/molecule_gross_formula.h" #include "molecule/molecule_ionize.h" @@ -329,7 +331,7 @@ class DLLEXPORT Indigo int layout_max_iterations; // default is zero -- no limit bool smart_layout = false; - float layout_horintervalfactor = 1.4f; + float layout_horintervalfactor = ReactionLayout::DEFAULT_HOR_INTERVAL_FACTOR; int layout_orientation = 0; diff --git a/api/c/indigo/src/indigo_layout.cpp b/api/c/indigo/src/indigo_layout.cpp index a9bb9b4b72..d8e7107a51 100644 --- a/api/c/indigo/src/indigo_layout.cpp +++ b/api/c/indigo/src/indigo_layout.cpp @@ -56,7 +56,7 @@ CEXPORT int indigoLayout(int object) } ml.max_iterations = self.layout_max_iterations; - ml.bond_length = 1.6f; + ml.bond_length = MoleculeLayout::DEFAULT_BOND_LENGTH; ml.layout_orientation = (layout_orientation_value)self.layout_orientation; TimeoutCancellationHandler cancellation(self.cancellation_timeout); @@ -105,7 +105,7 @@ CEXPORT int indigoLayout(int object) ReactionLayout rl(rxn, self.smart_layout); rl.max_iterations = self.layout_max_iterations; rl.layout_orientation = (layout_orientation_value)self.layout_orientation; - rl.bond_length = 1.6f; + rl.bond_length = MoleculeLayout::DEFAULT_BOND_LENGTH; rl.horizontal_interval_factor = self.layout_horintervalfactor; rl.make(); try diff --git a/api/tests/integration/ref/formats/rxn_no_layout.py.out b/api/tests/integration/ref/formats/rxn_no_layout.py.out index 8419bece36..17697cf853 100644 --- a/api/tests/integration/ref/formats/rxn_no_layout.py.out +++ b/api/tests/integration/ref/formats/rxn_no_layout.py.out @@ -29,7 +29,7 @@ { "type": "plus", "location": [ - 5.2510833740234379, + 9.501733779907227, 0.0, 0.0 ] @@ -37,7 +37,7 @@ { "type": "plus", "location": [ - 12.91125774383545, + 19.503467559814454, 0.0, 0.0 ] @@ -45,7 +45,7 @@ { "type": "plus", "location": [ - 18.638530731201173, + 23.103466033935548, 0.0, 0.0 ] @@ -53,7 +53,7 @@ { "type": "plus", "location": [ - 24.1688289642334, + 26.70346450805664, 0.0, 0.0 ] @@ -61,7 +61,7 @@ { "type": "plus", "location": [ - 28.737014770507814, + 31.90349578857422, 0.0, 0.0 ] @@ -69,7 +69,7 @@ { "type": "plus", "location": [ - 38.702880859375, + 48.909507751464847, 0.0, 0.0 ] @@ -80,12 +80,12 @@ "mode": "open-angle", "pos": [ { - "x": 32.09308624267578, + "x": 36.30352783203125, "y": 0.0, "z": 0.0 }, { - "x": 33.19913864135742, + "x": 40.50352478027344, "y": 0.0, "z": 0.0 } @@ -100,80 +100,80 @@ { "label": "C", "location": [ - 1.5023635625839234, - 0.8676860332489014, + 3.7037816047668459, + 1.3882975578308106, 0.0 ] }, { "label": "C", "location": [ - 3.0010616779327394, - 0.0030012130737304689, + 6.101698875427246, + 0.004801750183105469, 0.0 ] }, { "label": "C", "location": [ - 2.5030517578125, - 0.8673515319824219, + 5.304883003234863, + 1.3877620697021485, 0.0 ] }, { "label": "C", "location": [ - 2.500718593597412, - -0.8640168309211731, + 5.301149368286133, + -1.3824270963668824, 0.0 ] }, { "label": "C", "location": [ - 1.0000206232070926, - -0.002666711807250977, + 2.900032997131348, + -0.004266738891601563, 0.0 ] }, { "label": "C", "location": [ - 1.50503146648407, - -0.8656835556030273, + 3.708050489425659, + -1.3850938081741334, 0.0 ] }, { "label": "C", "location": [ - 1.0023539066314698, - 1.7337028980255128, + 2.90376615524292, + 2.773924827575684, 0.0 ] }, { "label": "C", "location": [ - 1.0083551406860352, - -1.7337028980255128, + 2.9133682250976564, + -2.773924827575684, 0.0 ] }, { "label": "C", "location": [ - 0.0, - -0.005331993103027344, + 1.2999999523162842, + -0.008531332015991211, 0.0 ] }, { "label": "C", "location": [ - 4.0010833740234379, - 0.002666711807250977, + 7.701733589172363, + 0.004266738891601563, 0.0 ] } @@ -257,80 +257,80 @@ { "label": "C", "location": [ - 8.003446578979493, - 0.8676860332489014, + 13.70551586151123, + 1.3882975578308106, 0.0 ] }, { "label": "C", "location": [ - 9.502144813537598, - 0.0030012130737304689, + 16.10343360900879, + 0.004801750183105469, 0.0 ] }, { "label": "C", "location": [ - 9.004135131835938, - 0.8673515319824219, + 15.306617736816408, + 1.3877620697021485, 0.0 ] }, { "label": "C", "location": [ - 9.001802444458008, - -0.8640168309211731, + 15.30288314819336, + -1.3824270963668824, 0.0 ] }, { "label": "C", "location": [ - 7.50110387802124, - -0.002666711807250977, + 12.901766777038576, + -0.004266738891601563, 0.0 ] }, { "label": "C", "location": [ - 8.006114959716797, - -0.8656835556030273, + 13.709784507751465, + -1.3850938081741334, 0.0 ] }, { "label": "C", "location": [ - 7.503437042236328, - 1.7337028980255128, + 12.905500411987305, + 2.773924827575684, 0.0 ] }, { "label": "C", "location": [ - 7.509438514709473, - -1.7337028980255128, + 12.915102005004885, + -2.773924827575684, 0.0 ] }, { "label": "C", "location": [ - 6.5010833740234379, - -0.005331993103027344, + 11.30173397064209, + -0.008531332015991211, 0.0 ] }, { "label": "C", "location": [ - 10.502166748046877, - 0.002666711807250977, + 17.703468322753908, + 0.004266738891601563, 0.0 ] } @@ -414,7 +414,7 @@ { "label": "O", "location": [ - 15.320348739624024, + 21.303466796875, 0.0, 0.0 ] @@ -428,7 +428,7 @@ { "label": "O", "location": [ - 21.95671272277832, + 24.903465270996099, 0.0, 0.0 ] @@ -442,7 +442,7 @@ { "label": "O", "location": [ - 26.38094520568848, + 28.503463745117189, 0.0, 0.0 ], @@ -451,7 +451,7 @@ { "label": "O", "location": [ - 27.38096427917481, + 30.10349464416504, 0.0, 0.0 ] @@ -473,7 +473,7 @@ { "label": "O", "location": [ - 30.093067169189458, + 33.703495025634769, 0.0, 0.0 ] @@ -481,7 +481,7 @@ { "label": "O", "location": [ - 31.09308624267578, + 35.30352783203125, 0.0, 0.0 ] @@ -503,88 +503,88 @@ { "label": "C", "location": [ - 36.20417785644531, - 0.8676860332489014, + 44.71158981323242, + 1.3882975578308106, 0.0 ] }, { "label": "C", "location": [ - 37.702880859375, - 0.0030012130737304689, + 47.1095085144043, + 0.004801750183105469, 0.0 ] }, { "label": "C", "location": [ - 37.20486831665039, - 0.8673515319824219, + 46.31269073486328, + 1.3877620697021485, 0.0 ] }, { "label": "C", "location": [ - 37.20253372192383, - -0.8640168309211731, + 46.3089599609375, + -1.3824270963668824, 0.0 ] }, { "label": "C", "location": [ - 35.70183944702149, - -0.002666711807250977, + 43.90784454345703, + -0.004266738891601563, 0.0 ] }, { "label": "C", "location": [ - 36.20684814453125, - -0.8656835556030273, + 44.715858459472659, + -1.3850938081741334, 0.0 ] }, { "label": "C", "location": [ - 35.71017074584961, - -1.7337028980255128, + 43.921180725097659, + -2.773924827575684, 0.0 ] }, { "label": "C", "location": [ - 34.70181655883789, - -0.005331993103027344, + 42.30780792236328, + -0.008531332015991211, 0.0 ] }, { "label": "O", "location": [ - 34.19913864135742, - 0.859018087387085, + 41.50352478027344, + 1.3744287490844729, 0.0 ] }, { "label": "O", "location": [ - 34.20413589477539, - -0.873016893863678, + 41.51152420043945, + -1.3968271017074586, 0.0 ] }, { "label": "C", "location": [ - 35.70417022705078, - 1.7337028980255128, + 43.91157531738281, + 2.773924827575684, 0.0 ] } @@ -675,88 +675,88 @@ { "label": "C", "location": [ - 41.70792007446289, - 0.8676860332489014, + 53.917572021484378, + 1.3882975578308106, 0.0 ] }, { "label": "C", "location": [ - 43.20661926269531, - 0.0030012130737304689, + 56.31549072265625, + 0.004801750183105469, 0.0 ] }, { "label": "C", "location": [ - 42.70861053466797, - 0.8673515319824219, + 55.51867294311524, + 1.3877620697021485, 0.0 ] }, { "label": "C", "location": [ - 42.706275939941409, - -0.8640168309211731, + 55.51494216918945, + -1.3824270963668824, 0.0 ] }, { "label": "C", "location": [ - 41.20558166503906, - -0.002666711807250977, + 53.113826751708987, + -0.004266738891601563, 0.0 ] }, { "label": "C", "location": [ - 41.71059036254883, - -0.8656835556030273, + 53.92184066772461, + -1.3850938081741334, 0.0 ] }, { "label": "C", "location": [ - 41.21391296386719, - -1.7337028980255128, + 53.12716293334961, + -2.773924827575684, 0.0 ] }, { "label": "C", "location": [ - 40.20555877685547, - -0.005331993103027344, + 51.51379013061524, + -0.008531332015991211, 0.0 ] }, { "label": "O", "location": [ - 39.702880859375, - 0.859018087387085, + 50.70950698852539, + 1.3744287490844729, 0.0 ] }, { "label": "O", "location": [ - 39.70787811279297, - -0.873016893863678, + 50.717506408691409, + -1.3968271017074586, 0.0 ] }, { "label": "C", "location": [ - 41.20791244506836, - 1.7337028980255128, + 53.117557525634769, + 2.773924827575684, 0.0 ] } diff --git a/api/tests/integration/tests/basic/ref/crazystereo.ket b/api/tests/integration/tests/basic/ref/crazystereo.ket index fe4a79bc83..021d14692f 100644 --- a/api/tests/integration/tests/basic/ref/crazystereo.ket +++ b/api/tests/integration/tests/basic/ref/crazystereo.ket @@ -1,445 +1,445 @@ -{ - "root": { - "nodes": [ - { - "$ref": "mol0" - }, - { - "$ref": "mol1" - }, - { - "type": "arrow", - "data": { - "mode": "open-angle", - "pos": [ - { - "x": 4.464198589324951, - "y": 0.0, - "z": 0.0 - }, - { - "x": 5.464198589324951, - "y": 0.0, - "z": 0.0 - } - ] - } - } - ] - }, - "mol0": { - "type": "molecule", - "atoms": [ - { - "label": "C", - "location": [ - 1.7320992946624756, - 0.49999362230300906, - 0.0 - ] - }, - { - "label": "C", - "location": [ - 0.8660491108894348, - 0.9999874234199524, - 0.0 - ] - }, - { - "label": "C", - "location": [ - 0.0, - 0.49999362230300906, - 0.0 - ] - }, - { - "label": "C", - "location": [ - 0.0, - -0.4999937117099762, - 0.0 - ] - }, - { - "label": "C", - "location": [ - 0.8660491108894348, - -0.9999874234199524, - 0.0 - ] - }, - { - "label": "C", - "location": [ - 1.7320992946624756, - -0.4999937117099762, - 0.0 - ] - }, - { - "label": "C", - "location": [ - 2.5980277061462404, - -0.9999874234199524, - 0.0 - ] - }, - { - "label": "C", - "location": [ - 3.464198589324951, - -0.4999937117099762, - 0.0 - ] - }, - { - "label": "C", - "location": [ - 3.464198589324951, - 0.49999362230300906, - 0.0 - ] - }, - { - "label": "C", - "location": [ - 2.5980277061462404, - 0.9999874234199524, - 0.0 - ] - } - ], - "bonds": [ - { - "type": 1, - "atoms": [ - 0, - 1 - ] - }, - { - "type": 2, - "atoms": [ - 1, - 2 - ] - }, - { - "type": 1, - "atoms": [ - 2, - 3 - ] - }, - { - "type": 2, - "atoms": [ - 3, - 4 - ] - }, - { - "type": 1, - "atoms": [ - 4, - 5 - ] - }, - { - "type": 2, - "atoms": [ - 6, - 7 - ] - }, - { - "type": 1, - "atoms": [ - 7, - 8 - ] - }, - { - "type": 2, - "atoms": [ - 8, - 9 - ] - }, - { - "type": 2, - "atoms": [ - 0, - 5 - ] - }, - { - "type": 1, - "atoms": [ - 0, - 9 - ] - }, - { - "type": 1, - "atoms": [ - 5, - 6 - ] - } - ] - }, - "mol1": { - "type": "molecule", - "atoms": [ - { - "label": "C", - "location": [ - 9.92827606201172, - 2.249971866607666, - 0.0 - ] - }, - { - "label": "C", - "location": [ - 9.062226295471192, - 1.7499775886535645, - 0.0 - ] - }, - { - "label": "C", - "location": [ - 9.062226295471192, - 0.7499902248382568, - 0.0 - ] - }, - { - "label": "C", - "location": [ - 9.92827606201172, - 0.2499966621398926, - 0.0 - ] - }, - { - "label": "C", - "location": [ - 10.794326782226565, - 0.7499902248382568, - 0.0 - ] - }, - { - "label": "C", - "location": [ - 10.794326782226565, - 1.7499775886535645, - 0.0 - ] - }, - { - "label": "C", - "location": [ - 8.196298599243164, - 0.2499966621398926, - 0.0 - ], - "stereoLabel": "&1" - }, - { - "label": "C", - "location": [ - 7.3302483558654789, - 0.7499902248382568, - 0.0 - ] - }, - { - "label": "C", - "location": [ - 6.464198589324951, - 0.2499966621398926, - 0.0 - ] - }, - { - "label": "C", - "location": [ - 6.464198589324951, - -0.7499908208847046, - 0.0 - ] - }, - { - "label": "C", - "location": [ - 7.3302483558654789, - -1.2499845027923585, - 0.0 - ] - }, - { - "label": "C", - "location": [ - 8.196298599243164, - -0.7499908208847046, - 0.0 - ] - }, - { - "label": "P", - "location": [ - 9.062226295471192, - -1.2499845027923585, - 0.0 - ] - }, - { - "label": "C", - "location": [ - 10.06221389770508, - -1.2499845027923585, - 0.0 - ] - }, - { - "label": "C", - "location": [ - 9.062226295471192, - -2.249971866607666, - 0.0 - ] - } - ], - "bonds": [ - { - "type": 1, - "atoms": [ - 0, - 1 - ], - "stereo": 1 - }, - { - "type": 1, - "atoms": [ - 0, - 5 - ], - "stereo": 6 - }, - { - "type": 1, - "atoms": [ - 2, - 1 - ] - }, - { - "type": 1, - "atoms": [ - 2, - 3 - ] - }, - { - "type": 1, - "atoms": [ - 2, - 6 - ], - "stereo": 4 - }, - { - "type": 1, - "atoms": [ - 4, - 3 - ], - "stereo": 6 - }, - { - "type": 1, - "atoms": [ - 4, - 5 - ], - "stereo": 1 - }, - { - "type": 1, - "atoms": [ - 11, - 6 - ], - "stereo": 6 - }, - { - "type": 1, - "atoms": [ - 6, - 7 - ], - "stereo": 1 - }, - { - "type": 1, - "atoms": [ - 7, - 8 - ], - "stereo": 6 - }, - { - "type": 1, - "atoms": [ - 8, - 9 - ], - "stereo": 1 - }, - { - "type": 1, - "atoms": [ - 9, - 10 - ], - "stereo": 6 - }, - { - "type": 1, - "atoms": [ - 11, - 10 - ], - "stereo": 1 - }, - { - "type": 1, - "atoms": [ - 11, - 12 - ] - }, - { - "type": 2, - "atoms": [ - 12, - 13 - ] - }, - { - "type": 1, - "atoms": [ - 12, - 14 - ] - } - ] - } +{ + "root": { + "nodes": [ + { + "$ref": "mol0" + }, + { + "$ref": "mol1" + }, + { + "type": "arrow", + "data": { + "mode": "open-angle", + "pos": [ + { + "x": 7.842718124389648, + "y": 0.0, + "z": 0.0 + }, + { + "x": 12.042718887329102, + "y": 0.0, + "z": 0.0 + } + ] + } + } + ] + }, + "mol0": { + "type": "molecule", + "atoms": [ + { + "label": "C", + "location": [ + 4.071358680725098, + 0.7999899387359619, + 0.0 + ] + }, + { + "label": "C", + "location": [ + 2.685678482055664, + 1.599979877471924, + 0.0 + ] + }, + { + "label": "C", + "location": [ + 1.2999999523162842, + 0.7999899387359619, + 0.0 + ] + }, + { + "label": "C", + "location": [ + 1.2999999523162842, + -0.7999899387359619, + 0.0 + ] + }, + { + "label": "C", + "location": [ + 2.685678482055664, + -1.599979877471924, + 0.0 + ] + }, + { + "label": "C", + "location": [ + 4.071358680725098, + -0.7999899387359619, + 0.0 + ] + }, + { + "label": "C", + "location": [ + 5.456844329833984, + -1.599979877471924, + 0.0 + ] + }, + { + "label": "C", + "location": [ + 6.842718124389648, + -0.7999899387359619, + 0.0 + ] + }, + { + "label": "C", + "location": [ + 6.842718124389648, + 0.7999899387359619, + 0.0 + ] + }, + { + "label": "C", + "location": [ + 5.456844329833984, + 1.599979877471924, + 0.0 + ] + } + ], + "bonds": [ + { + "type": 1, + "atoms": [ + 0, + 1 + ] + }, + { + "type": 2, + "atoms": [ + 1, + 2 + ] + }, + { + "type": 1, + "atoms": [ + 2, + 3 + ] + }, + { + "type": 2, + "atoms": [ + 3, + 4 + ] + }, + { + "type": 1, + "atoms": [ + 4, + 5 + ] + }, + { + "type": 2, + "atoms": [ + 6, + 7 + ] + }, + { + "type": 1, + "atoms": [ + 7, + 8 + ] + }, + { + "type": 2, + "atoms": [ + 8, + 9 + ] + }, + { + "type": 2, + "atoms": [ + 0, + 5 + ] + }, + { + "type": 1, + "atoms": [ + 0, + 9 + ] + }, + { + "type": 1, + "atoms": [ + 5, + 6 + ] + } + ] + }, + "mol1": { + "type": "molecule", + "atoms": [ + { + "label": "C", + "location": [ + 18.585243225097658, + 3.599954843521118, + 0.0 + ] + }, + { + "label": "C", + "location": [ + 17.19956398010254, + 2.799964189529419, + 0.0 + ] + }, + { + "label": "C", + "location": [ + 17.19956398010254, + 1.1999847888946534, + 0.0 + ] + }, + { + "label": "C", + "location": [ + 18.585243225097658, + 0.3999948501586914, + 0.0 + ] + }, + { + "label": "C", + "location": [ + 19.970922470092778, + 1.1999847888946534, + 0.0 + ] + }, + { + "label": "C", + "location": [ + 19.970922470092778, + 2.799964189529419, + 0.0 + ] + }, + { + "label": "C", + "location": [ + 15.814078330993653, + 0.3999948501586914, + 0.0 + ], + "stereoLabel": "&1" + }, + { + "label": "C", + "location": [ + 14.42839813232422, + 1.1999847888946534, + 0.0 + ] + }, + { + "label": "C", + "location": [ + 13.042718887329102, + 0.3999948501586914, + 0.0 + ] + }, + { + "label": "C", + "location": [ + 13.042718887329102, + -1.1999850273132325, + 0.0 + ] + }, + { + "label": "C", + "location": [ + 14.42839813232422, + -1.999975085258484, + 0.0 + ] + }, + { + "label": "C", + "location": [ + 15.814078330993653, + -1.1999850273132325, + 0.0 + ] + }, + { + "label": "P", + "location": [ + 17.19956398010254, + -1.999975085258484, + 0.0 + ] + }, + { + "label": "C", + "location": [ + 18.799543380737306, + -1.999975085258484, + 0.0 + ] + }, + { + "label": "C", + "location": [ + 17.19956398010254, + -3.599954843521118, + 0.0 + ] + } + ], + "bonds": [ + { + "type": 1, + "atoms": [ + 0, + 1 + ], + "stereo": 1 + }, + { + "type": 1, + "atoms": [ + 0, + 5 + ], + "stereo": 6 + }, + { + "type": 1, + "atoms": [ + 2, + 1 + ] + }, + { + "type": 1, + "atoms": [ + 2, + 3 + ] + }, + { + "type": 1, + "atoms": [ + 2, + 6 + ], + "stereo": 4 + }, + { + "type": 1, + "atoms": [ + 4, + 3 + ], + "stereo": 6 + }, + { + "type": 1, + "atoms": [ + 4, + 5 + ], + "stereo": 1 + }, + { + "type": 1, + "atoms": [ + 11, + 6 + ], + "stereo": 6 + }, + { + "type": 1, + "atoms": [ + 6, + 7 + ], + "stereo": 1 + }, + { + "type": 1, + "atoms": [ + 7, + 8 + ], + "stereo": 6 + }, + { + "type": 1, + "atoms": [ + 8, + 9 + ], + "stereo": 1 + }, + { + "type": 1, + "atoms": [ + 9, + 10 + ], + "stereo": 6 + }, + { + "type": 1, + "atoms": [ + 11, + 10 + ], + "stereo": 1 + }, + { + "type": 1, + "atoms": [ + 11, + 12 + ] + }, + { + "type": 2, + "atoms": [ + 12, + 13 + ] + }, + { + "type": 1, + "atoms": [ + 12, + 14 + ] + } + ] + } } \ No newline at end of file diff --git a/api/tests/integration/tests/layout/ref/932-agents.ket b/api/tests/integration/tests/layout/ref/932-agents.ket index 27b827673f..a579fbfeb9 100644 --- a/api/tests/integration/tests/layout/ref/932-agents.ket +++ b/api/tests/integration/tests/layout/ref/932-agents.ket @@ -43,15 +43,15 @@ { "type": "plus", "location": [ - 4.59999942779541, - -5.960464477539063e-8, + 4.699999809265137, + 0.0, 0.0 ] }, { "type": "plus", "location": [ - 10.199999809265137, + 8.300000190734864, 0.0, 0.0 ] @@ -59,7 +59,7 @@ { "type": "plus", "location": [ - 56.54255676269531, + 55.84254455566406, 0.0, 0.0 ] @@ -67,7 +67,7 @@ { "type": "plus", "location": [ - 65.60529327392578, + 63.3052864074707, 0.0, 0.0 ] @@ -78,12 +78,12 @@ "mode": "open-angle", "pos": [ { - "x": 15.399999618530274, - "y": -1.1920928955078126e-7, + "x": 12.699999809265137, + "y": 0.0, "z": 0.0 }, { - "x": 52.34255599975586, + "x": 52.042545318603519, "y": 0.0, "z": 0.0 } @@ -98,24 +98,24 @@ { "label": "C", "location": [ - 0.0, - 0.6928202509880066, + 1.2999999523162842, + 0.6928203105926514, 0.0 ] }, { "label": "C", "location": [ - 1.5999997854232789, - 0.6928202509880066, + 2.8999996185302736, + 0.6928203105926514, 0.0 ] }, { "label": "C", "location": [ - 0.7999998927116394, - -0.6928203701972961, + 2.0999999046325685, + -0.6928203105926514, 0.0 ] } @@ -150,7 +150,7 @@ { "label": "S", "location": [ - 7.59999942779541, + 6.5, 0.0, 0.0 ] @@ -164,32 +164,32 @@ { "label": "C", "location": [ - 12.800000190734864, - 0.7999997735023499, + 10.100000381469729, + 0.7999998927116394, 0.0 ] }, { "label": "C", "location": [ - 14.399999618530274, - 0.7999997735023499, + 11.699999809265137, + 0.7999998927116394, 0.0 ] }, { "label": "C", "location": [ - 14.399999618530274, - -0.800000011920929, + 11.699999809265137, + -0.7999998927116394, 0.0 ] }, { "label": "C", "location": [ - 12.800000190734864, - -0.800000011920929, + 10.100000381469729, + -0.7999998927116394, 0.0 ] } @@ -231,7 +231,7 @@ { "label": "S", "location": [ - 54.34255599975586, + 54.04254531860352, 0.0, 0.0 ] @@ -245,7 +245,7 @@ { "label": "C", "location": [ - 61.47392272949219, + 60.3739128112793, 1.931370735168457, 0.0 ] @@ -253,7 +253,7 @@ { "label": "C", "location": [ - 59.873924255371097, + 58.7739143371582, 1.931370735168457, 0.0 ] @@ -261,7 +261,7 @@ { "label": "C", "location": [ - 58.7425537109375, + 57.64254379272461, 0.7999999523162842, 0.0 ] @@ -269,7 +269,7 @@ { "label": "C", "location": [ - 58.7425537109375, + 57.64254379272461, -0.7999998331069946, 0.0 ] @@ -277,7 +277,7 @@ { "label": "C", "location": [ - 59.873924255371097, + 58.7739143371582, -1.931370735168457, 0.0 ] @@ -285,7 +285,7 @@ { "label": "C", "location": [ - 61.47392272949219, + 60.3739128112793, -1.931370735168457, 0.0 ] @@ -293,7 +293,7 @@ { "label": "C", "location": [ - 62.60529327392578, + 61.50528717041016, -0.7999998331069946, 0.0 ] @@ -301,7 +301,7 @@ { "label": "C", "location": [ - 62.60529327392578, + 61.50528335571289, 0.7999999523162842, 0.0 ] @@ -372,7 +372,7 @@ { "label": "O", "location": [ - 68.60529327392578, + 65.10528564453125, 0.0, 0.0 ] @@ -386,24 +386,24 @@ { "label": "C", "location": [ - 16.0, - 2.0, + 15.90000057220459, + 1.892820119857788, 0.0 ] }, { "label": "C", "location": [ - 17.38564109802246, - 1.1999999284744266, + 17.285640716552736, + 1.0928202867507937, 0.0 ] }, { "label": "C", "location": [ - 18.77128028869629, - 1.999999761581421, + 18.671281814575197, + 1.892820119857788, 0.0 ] } @@ -431,8 +431,8 @@ { "label": "C", "location": [ - 22.77128028869629, - 1.600000023841858, + 22.871280670166017, + 1.4928202629089356, 0.0 ] } @@ -445,8 +445,8 @@ { "label": "P", "location": [ - 29.171279907226564, - 1.600000023841858, + 27.071279525756837, + 1.4928202629089356, 0.0 ] } @@ -459,24 +459,24 @@ { "label": "C", "location": [ - 33.17127990722656, - 2.0, + 31.271278381347658, + 1.892820119857788, 0.0 ] }, { "label": "C", "location": [ - 34.55691909790039, - 1.1999999284744266, + 32.65691757202149, + 1.0928202867507937, 0.0 ] }, { "label": "C", "location": [ - 35.94256210327149, - 1.999999761581421, + 34.04256057739258, + 1.892820119857788, 0.0 ] } @@ -504,24 +504,24 @@ { "label": "C", "location": [ - 37.54256057739258, - 2.29282021522522, + 38.242557525634769, + 2.185640573501587, 0.0 ] }, { "label": "C", "location": [ - 39.14255905151367, - 2.29282021522522, + 39.84255599975586, + 2.185640573501587, 0.0 ] }, { "label": "C", "location": [ - 38.342559814453128, - 0.9071796536445618, + 39.04255676269531, + 0.7999999523162842, 0.0 ] } @@ -556,8 +556,8 @@ { "label": "F", "location": [ - 42.34255599975586, - 1.600000023841858, + 44.04255294799805, + 1.4928202629089356, 0.0 ] } @@ -570,8 +570,8 @@ { "label": "I", "location": [ - 47.142555236816409, - 1.600000023841858, + 48.24254989624024, + 1.4928202629089356, 0.0 ] } diff --git a/api/tests/integration/tests/layout/ref/reaction_layout.rdf b/api/tests/integration/tests/layout/ref/reaction_layout.rdf index b1bbfeebe5..46f3e0097b 100644 --- a/api/tests/integration/tests/layout/ref/reaction_layout.rdf +++ b/api/tests/integration/tests/layout/ref/reaction_layout.rdf @@ -9,14 +9,14 @@ $MOL -INDIGO-01000000002D 8 7 0 0 0 0 0 0 0 0999 V2000 - 0.0000 1.2000 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0 - 1.3856 0.4000 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0 - 2.7713 1.2000 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0 - 4.1569 0.4000 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0 - 5.5426 1.2000 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0 - 6.9282 0.4000 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0 - 8.3138 1.2000 0.0000 P 0 0 0 0 0 0 0 0 0 0 0 0 - 4.1569 -1.2000 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0 + 1.3000 1.2000 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0 + 2.6856 0.4000 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0 + 4.0713 1.2000 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0 + 5.4569 0.4000 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0 + 6.8426 1.2000 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0 + 8.2282 0.4000 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0 + 9.6138 1.2000 0.0000 P 0 0 0 0 0 0 0 0 0 0 0 0 + 5.4569 -1.2000 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0 1 2 1 0 0 0 0 2 3 1 0 0 0 0 3 4 1 0 0 0 0 @@ -30,12 +30,12 @@ $MOL -INDIGO-01000000002D 6 6 0 0 0 0 0 0 0 0999 V2000 - 12.4995 1.6000 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0 - 11.1138 0.8000 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0 - 11.1138 -0.8000 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0 - 12.4995 -1.6000 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0 - 13.8851 -0.8000 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0 - 13.8851 0.8000 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0 + 14.5995 1.6000 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0 + 13.2138 0.8000 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0 + 13.2138 -0.8000 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0 + 14.5995 -1.6000 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0 + 15.9851 -0.8000 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0 + 15.9851 0.8000 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0 1 2 1 0 0 0 0 2 3 2 0 0 0 0 3 4 1 0 0 0 0 @@ -48,13 +48,13 @@ $MOL -INDIGO-01000000002D 7 6 0 0 0 0 0 0 0 0999 V2000 - 17.4851 0.4000 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0 - 18.8708 1.2000 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0 - 20.2564 0.4000 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0 - 21.6420 1.2000 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0 - 23.0277 0.4000 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0 - 24.4133 1.2000 0.0000 P 0 0 0 0 0 0 0 0 0 0 0 0 - 20.2564 -1.2000 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0 + 22.1851 0.4000 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0 + 23.5708 1.2000 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0 + 24.9564 0.4000 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0 + 26.3420 1.2000 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0 + 27.7277 0.4000 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0 + 29.1133 1.2000 0.0000 P 0 0 0 0 0 0 0 0 0 0 0 0 + 24.9564 -1.2000 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0 1 2 1 0 0 0 0 2 3 1 0 0 0 0 3 4 1 0 0 0 0 @@ -67,13 +67,13 @@ $MOL -INDIGO-01000000002D 7 7 0 0 0 0 0 0 0 0999 V2000 - 26.4133 0.0000 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0 - 27.2133 1.3856 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0 - 28.8133 1.3856 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0 - 29.6133 0.0000 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0 - 28.8133 -1.3856 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0 - 27.2133 -1.3856 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0 - 31.2133 0.0000 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0 + 32.7133 0.0000 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0 + 33.5133 1.3856 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0 + 35.1133 1.3856 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0 + 35.9133 0.0000 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0 + 35.1133 -1.3856 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0 + 33.5133 -1.3856 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0 + 37.5133 0.0000 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0 1 2 1 0 0 0 0 2 3 2 0 0 0 0 3 4 1 0 0 0 0 diff --git a/api/tests/integration/tests/layout/ref/test1.rxn b/api/tests/integration/tests/layout/ref/test1.rxn index c7b54a78e8..38bf3dff3a 100644 --- a/api/tests/integration/tests/layout/ref/test1.rxn +++ b/api/tests/integration/tests/layout/ref/test1.rxn @@ -8,11 +8,11 @@ $MOL -INDIGO-01000000002D 5 5 0 0 0 0 0 0 0 0999 V2000 - 0.0000 -1.0928 0.0000 Cl 0 0 0 0 0 0 0 0 0 0 0 0 - 0.8000 0.2928 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0 - 2.4000 0.2928 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0 - 3.7856 -0.5072 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0 - 3.7856 1.0928 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0 + 1.3000 -1.0928 0.0000 Cl 0 0 0 0 0 0 0 0 0 0 0 0 + 2.1000 0.2928 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0 + 3.7000 0.2928 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0 + 5.0856 -0.5072 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0 + 5.0856 1.0928 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0 1 2 1 0 0 0 0 2 3 1 0 0 0 0 3 4 1 0 0 0 0 @@ -24,28 +24,28 @@ $MOL -INDIGO-01000000002D 22 22 0 0 0 0 0 0 0 0999 V2000 - 11.7569 -2.3391 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0 - 11.7569 -0.7391 0.0000 N 0 0 0 0 0 0 0 0 0 0 0 0 - 10.3713 0.0609 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0 - 8.9856 -0.7391 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0 - 8.1856 -2.1247 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0 - 7.3856 -0.7391 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0 - 13.1426 0.0609 0.0000 S 0 0 0 0 0 0 0 0 0 0 0 0 - 12.3426 1.4465 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0 - 13.9426 -1.3247 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0 - 14.5282 0.8609 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0 - 15.1405 2.3391 0.0000 F 0 0 0 0 0 0 0 0 0 0 0 0 - 13.9159 2.3391 0.0000 F 0 0 0 0 0 0 0 0 0 0 0 0 - 15.9138 0.0609 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0 - 15.3016 -1.4173 0.0000 F 0 0 0 0 0 0 0 0 0 0 0 0 - 16.5261 -1.4173 0.0000 F 0 0 0 0 0 0 0 0 0 0 0 0 - 17.2995 0.8609 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0 - 17.9118 2.3391 0.0000 F 0 0 0 0 0 0 0 0 0 0 0 0 - 16.6872 2.3391 0.0000 F 0 0 0 0 0 0 0 0 0 0 0 0 - 18.6851 0.0609 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0 - 18.6851 -1.5391 0.0000 F 0 0 0 0 0 0 0 0 0 0 0 0 - 20.0708 0.8609 0.0000 F 0 0 0 0 0 0 0 0 0 0 0 0 - 20.0708 -0.7391 0.0000 F 0 0 0 0 0 0 0 0 0 0 0 0 + 15.6569 -2.3391 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0 + 15.6569 -0.7391 0.0000 N 0 0 0 0 0 0 0 0 0 0 0 0 + 14.2713 0.0609 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0 + 12.8856 -0.7391 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0 + 12.0856 -2.1247 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0 + 11.2856 -0.7391 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0 + 17.0426 0.0609 0.0000 S 0 0 0 0 0 0 0 0 0 0 0 0 + 16.2426 1.4465 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0 + 17.8426 -1.3247 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0 + 18.4282 0.8609 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0 + 19.0405 2.3391 0.0000 F 0 0 0 0 0 0 0 0 0 0 0 0 + 17.8159 2.3391 0.0000 F 0 0 0 0 0 0 0 0 0 0 0 0 + 19.8138 0.0609 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0 + 19.2016 -1.4173 0.0000 F 0 0 0 0 0 0 0 0 0 0 0 0 + 20.4261 -1.4173 0.0000 F 0 0 0 0 0 0 0 0 0 0 0 0 + 21.1995 0.8609 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0 + 21.8118 2.3391 0.0000 F 0 0 0 0 0 0 0 0 0 0 0 0 + 20.5872 2.3391 0.0000 F 0 0 0 0 0 0 0 0 0 0 0 0 + 22.5851 0.0609 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0 + 22.5851 -1.5391 0.0000 F 0 0 0 0 0 0 0 0 0 0 0 0 + 23.9708 0.8609 0.0000 F 0 0 0 0 0 0 0 0 0 0 0 0 + 23.9708 -0.7391 0.0000 F 0 0 0 0 0 0 0 0 0 0 0 0 1 2 1 0 0 0 0 2 3 1 0 0 0 0 3 4 1 0 0 0 0 diff --git a/api/tests/integration/tests/layout/ref/test_sgroup.rxn b/api/tests/integration/tests/layout/ref/test_sgroup.rxn index 29d5a803c0..8ccdbbdb32 100644 --- a/api/tests/integration/tests/layout/ref/test_sgroup.rxn +++ b/api/tests/integration/tests/layout/ref/test_sgroup.rxn @@ -8,12 +8,12 @@ $MOL -INDIGO-01000000002D 6 6 0 0 0 0 0 0 0 0999 V2000 - 2.4000 1.3856 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0 - 0.8000 1.3856 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0 - 0.0000 0.0000 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0 - 0.8000 -1.3856 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0 - 2.4000 -1.3856 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0 - 3.2000 0.0000 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0 + 3.7000 1.3856 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0 + 2.1000 1.3856 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0 + 1.3000 0.0000 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0 + 2.1000 -1.3856 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0 + 3.7000 -1.3856 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0 + 4.5000 0.0000 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0 1 2 2 0 0 0 0 2 3 1 0 0 0 0 3 4 2 0 0 0 0 @@ -24,7 +24,7 @@ M STY 1 1 DAT M SLB 1 1 1 M SAL 1 6 1 2 3 4 5 6 M SDT 1 asd -M SDD 1 2.7571 -0.8839 DA ALL 1 1 +M SDD 1 4.0571 -0.8839 DA ALL 1 1 M SED 1 asd M END $MOL @@ -32,12 +32,12 @@ $MOL -INDIGO-01000000002D 6 6 0 0 0 0 0 0 0 0999 V2000 - 9.2000 1.3856 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0 - 7.6000 1.3856 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0 - 6.8000 0.0000 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0 - 7.6000 -1.3856 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0 - 9.2000 -1.3856 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0 - 10.0000 0.0000 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0 + 13.1000 1.3856 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0 + 11.5000 1.3856 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0 + 10.7000 0.0000 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0 + 11.5000 -1.3856 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0 + 13.1000 -1.3856 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0 + 13.9000 0.0000 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0 1 2 2 0 0 0 0 2 3 1 0 0 0 0 3 4 2 0 0 0 0 @@ -48,6 +48,6 @@ M STY 1 1 DAT M SLB 1 1 1 M SAL 1 6 1 2 3 4 5 6 M SDT 1 AAA -M SDD 1 6.3376 -2.0277 DAU ALL 1 1 +M SDD 1 10.2376 -2.0277 DAU ALL 1 1 M SED 1 BBBBB M END diff --git a/core/indigo-core/layout/molecule_layout.h b/core/indigo-core/layout/molecule_layout.h index ce1f71ecf1..d52920acce 100644 --- a/core/indigo-core/layout/molecule_layout.h +++ b/core/indigo-core/layout/molecule_layout.h @@ -40,6 +40,7 @@ namespace indigo { LAYOUT_MAX_ITERATION = 20 }; + static constexpr float DEFAULT_BOND_LENGTH = 1.6f; explicit MoleculeLayout(BaseMolecule& molecule, bool smart_layout = false); diff --git a/core/indigo-core/layout/reaction_layout.h b/core/indigo-core/layout/reaction_layout.h index c33b6eb4e8..b6488c7a58 100644 --- a/core/indigo-core/layout/reaction_layout.h +++ b/core/indigo-core/layout/reaction_layout.h @@ -17,6 +17,7 @@ ***************************************************************************/ #ifndef __reaction_layout__ +#define __reaction_layout__ #include "layout/metalayout.h" #include "reaction/base_reaction.h" @@ -33,9 +34,12 @@ namespace indigo public: explicit ReactionLayout(BaseReaction& r, bool smart_layout = false); + static constexpr float DEFAULT_HOR_INTERVAL_FACTOR = 1.4f; + void make(); float bond_length; + float atom_label_width; float plus_interval_factor; float arrow_interval_factor; float horizontal_interval_factor; @@ -45,8 +49,8 @@ namespace indigo layout_orientation_value layout_orientation; private: - Metalayout::LayoutItem& _pushMol(Metalayout::LayoutLine& line, int id, bool is_agent = false); - Metalayout::LayoutItem& _pushSpace(Metalayout::LayoutLine& line, float size); + void _pushMol(Metalayout::LayoutLine& line, int id, bool is_agent = false); + void _pushSpace(Metalayout::LayoutLine& line, float size); BaseMolecule& _getMol(int id); void _shiftMol(const Metalayout::LayoutItem& item, const Vec2f& pos); void _make(); diff --git a/core/indigo-core/layout/src/reaction_layout.cpp b/core/indigo-core/layout/src/reaction_layout.cpp index 0578f0a9ef..34eb55eda6 100644 --- a/core/indigo-core/layout/src/reaction_layout.cpp +++ b/core/indigo-core/layout/src/reaction_layout.cpp @@ -20,12 +20,13 @@ #include "layout/molecule_layout.h" #include "molecule/molecule.h" #include "reaction/reaction.h" +#include using namespace indigo; ReactionLayout::ReactionLayout(BaseReaction& r, bool smart_layout) - : bond_length(1), plus_interval_factor(2), arrow_interval_factor(2), preserve_molecule_layout(false), _r(r), _smart_layout(smart_layout), - horizontal_interval_factor(0.5f) + : bond_length(MoleculeLayout::DEFAULT_BOND_LENGTH), plus_interval_factor(1), arrow_interval_factor(2), preserve_molecule_layout(false), _r(r), + _smart_layout(smart_layout), horizontal_interval_factor(DEFAULT_HOR_INTERVAL_FACTOR), atom_label_width(1.3f) { max_iterations = 0; } @@ -53,7 +54,7 @@ void ReactionLayout::make() { bool single_atom = _getMol(i).vertexCount() == 1; if (i != _r.reactantBegin()) - _pushSpace(line, plus_interval_factor + (single_atom ? bond_length : kHalfBondLength)); + _pushSpace(line, plus_interval_factor); _pushMol(line, i); } @@ -78,7 +79,7 @@ void ReactionLayout::make() { bool single_atom = _getMol(i).vertexCount() == 1; if (i != _r.productBegin()) - _pushSpace(line, plus_interval_factor + (single_atom ? bond_length : 0)); + _pushSpace(line, plus_interval_factor); _pushMol(line, i); } @@ -93,10 +94,11 @@ void ReactionLayout::make() _ml.process(); } -Metalayout::LayoutItem& ReactionLayout::_pushMol(Metalayout::LayoutLine& line, int id, bool is_agent) +void ReactionLayout::_pushMol(Metalayout::LayoutLine& line, int id, bool is_agent) { - const int kMaxSymbols = 3; - const auto kMinHeight = bond_length / 8; + // Molecule label alligned to atom center by non-hydrogen + // Hydrogen may be at left or at right H2O, PH3 - so add space before and after molecule + _pushSpace(line, atom_label_width); Metalayout::LayoutItem& item = line.items.push(); item.type = 0; item.fragment = true; @@ -108,32 +110,18 @@ Metalayout::LayoutItem& ReactionLayout::_pushMol(Metalayout::LayoutLine& line, i } Rect2f bbox; - if (mol.vertexCount() == 1) - { - int max_h = mol.getAtomMaxH(0); - int mult = max_h + 1; - if (mult > kMaxSymbols) - mult = kMaxSymbols; - item.minScaledSize.set(0, kMinHeight); - mol.getBoundingBox(bbox, Vec2f(bond_length * mult, bond_length)); - } - else - { - mol.getBoundingBox(bbox, Vec2f(bond_length, bond_length)); - item.minScaledSize.set(bond_length, bond_length); - } + mol.getBoundingBox(bbox); item.min.copy(bbox.leftBottom()); item.max.copy(bbox.rightTop()); - return item; + _pushSpace(line, atom_label_width); } -Metalayout::LayoutItem& ReactionLayout::_pushSpace(Metalayout::LayoutLine& line, float size) +void ReactionLayout::_pushSpace(Metalayout::LayoutLine& line, float size) { Metalayout::LayoutItem& item = line.items.push(); item.type = 1; item.fragment = false; item.scaledSize.set(size, 0); - return item; } BaseMolecule& ReactionLayout::_getMol(int id)