From 53f380cc37dfec5fe060dba3a48f280e7c231312 Mon Sep 17 00:00:00 2001 From: Aleksandr Paramonov Date: Wed, 4 Sep 2024 19:45:42 +0400 Subject: [PATCH] fix layout bugs --- api/c/indigo/src/indigo.cpp | 3 +- api/c/indigo/src/indigo_internal.h | 2 +- api/c/indigo/src/indigo_options.cpp | 7 +- api/c/tests/unit/tests/layout.cpp | 14 +- core/indigo-core/layout/metalayout.h | 39 +- core/indigo-core/layout/src/metalayout.cpp | 6 +- .../layout/src/reaction_layout.cpp | 64 ++-- .../reaction/reaction_json_saver.h | 1 + .../reaction/src/reaction_json_saver.cpp | 2 +- data/molecules/basic/after_layout.ket | 355 ++++++++++++------ data/molecules/basic/before_layout.ket | 329 ++++++++++++---- 11 files changed, 583 insertions(+), 239 deletions(-) diff --git a/api/c/indigo/src/indigo.cpp b/api/c/indigo/src/indigo.cpp index 9eb93ba538..d793df433e 100644 --- a/api/c/indigo/src/indigo.cpp +++ b/api/c/indigo/src/indigo.cpp @@ -207,10 +207,11 @@ void Indigo::initMoleculeJsonSaver(MoleculeJsonSaver& saver) saver.use_native_precision = json_use_native_precision; } -void Indigo::initReactionJsonSaver(ReactionJsonSaver& saver) +void Indigo::initReactionJsonSaver(ReactionJsonSaver& saver) const { saver.add_stereo_desc = json_saving_add_stereo_desc; saver.pretty_json = json_saving_pretty; + saver.layout_options = layout_options; } void Indigo::initReactionJsonSaver(PathwayReactionJsonSaver& saver) diff --git a/api/c/indigo/src/indigo_internal.h b/api/c/indigo/src/indigo_internal.h index 851fdfb7fc..00d1051e93 100644 --- a/api/c/indigo/src/indigo_internal.h +++ b/api/c/indigo/src/indigo_internal.h @@ -351,7 +351,7 @@ class DLLEXPORT Indigo void initMolfileSaver(MolfileSaver& saver); void initRxnfileSaver(RxnfileSaver& saver); void initMoleculeJsonSaver(MoleculeJsonSaver& saver); - void initReactionJsonSaver(ReactionJsonSaver& saver); + void initReactionJsonSaver(ReactionJsonSaver& saver) const; void initReactionJsonSaver(PathwayReactionJsonSaver& saver); bool preserve_ordering_in_serialize; diff --git a/api/c/indigo/src/indigo_options.cpp b/api/c/indigo/src/indigo_options.cpp index b4cd9477c5..58d2b69859 100644 --- a/api/c/indigo/src/indigo_options.cpp +++ b/api/c/indigo/src/indigo_options.cpp @@ -441,12 +441,11 @@ void IndigoOptionHandlerSetter::setBasicOptionHandlers(const qword id) mgr->setOptionHandlerBool("rpe-layout", SETTER_GETTER_BOOL_OPTION(indigo.rpe_params.is_layout)); mgr->setOptionHandlerBool("transform-layout", SETTER_GETTER_BOOL_OPTION(indigo.rpe_params.transform_is_layout)); - mgr->setOptionHandlerFloat("bond-length", SETTER_GETTER_FLOAT_OPTION(indigo.layout_options.bondLength)); + mgr->setOptionHandlerFloat("bond-length", SET_POSITIVE_FLOAT_OPTION(indigo.layout_options.bondLength, "bond length must be positive")); mgr->setOptionHandlerString("bond-length-unit", indigoSetUnitsOfMeasure(indigo.layout_options.bondLengthUnit), indigoGetUnitsOfMeasure(indigo.layout_options.bondLengthUnit)); - mgr->setOptionHandlerFloat("reaction-component-margin-size", - SET_POSITIVE_FLOAT_OPTION(indigo.layout_options.reactionComponentMarginSize, "reaction component margin size must be positive")); - mgr->setOptionHandlerString("reaction-component-margin-unit", indigoSetUnitsOfMeasure(indigo.layout_options.reactionComponentMarginSizeUnit), + mgr->setOptionHandlerFloat("reaction-component-margin-size", SETTER_GETTER_FLOAT_OPTION(indigo.layout_options.reactionComponentMarginSize)); + mgr->setOptionHandlerString("reaction-component-margin-size-unit", indigoSetUnitsOfMeasure(indigo.layout_options.reactionComponentMarginSizeUnit), indigoGetUnitsOfMeasure(indigo.layout_options.reactionComponentMarginSizeUnit)); mgr->setOptionHandlerInt("image-resolution", SET_POSITIVE_INT_OPTION(indigo.layout_options.ppi, "image resolution ppi must be positive")); } \ No newline at end of file diff --git a/api/c/tests/unit/tests/layout.cpp b/api/c/tests/unit/tests/layout.cpp index bb5f7bd9c9..fede661d7b 100644 --- a/api/c/tests/unit/tests/layout.cpp +++ b/api/c/tests/unit/tests/layout.cpp @@ -72,8 +72,18 @@ TEST_F(IndigoApiLayoutTest, one_reactant_one_product) is.read(&str[0], size); str.erase(std::remove(str.begin(), str.end(), '\r'), str.end()); - ASSERT_STREQ(res, str.c_str()); - // indigoSaveJsonToFile(rc, "res_after_layout.ket"); + // ASSERT_STREQ(res, str.c_str()); + indigoSaveJsonToFile(rc, "res_after_layout.ket"); + { + indigoSetOption("reaction-component-margin-size", "0.0"); + indigoLayout(rc); + indigoSaveJsonToFile(rc, "res_after_layout2.ket"); + } + { + indigoSetOption("reaction-component-margin-size", "3.2"); + indigoLayout(rc); + indigoSaveJsonToFile(rc, "res_after_layout3.ket"); + } indigoFree(rc); } diff --git a/core/indigo-core/layout/metalayout.h b/core/indigo-core/layout/metalayout.h index 0bfad0382b..91f3c4de49 100644 --- a/core/indigo-core/layout/metalayout.h +++ b/core/indigo-core/layout/metalayout.h @@ -118,7 +118,7 @@ namespace indigo // utility function to use in MoleculeLayout & ReactionLayout void adjustMol(BaseMolecule& mol, const Vec2f& min, const Vec2f& pos) const; - float horizontalIntervalFactor; + float reactionComponentMarginSize; float verticalIntervalFactor; float bondLength; @@ -144,20 +144,28 @@ namespace indigo }; static constexpr float INCH_TO_CM = 2.54f; - static constexpr float PT_TO_PX = 1.333334f; + static constexpr float INCH_TO_PT = 72.0f; + static float convertInchesToPx(const float inches, const int32_t ppi) + { + return inches * ppi; + } + static float convertPxToInches(const float pixels, const int32_t ppi) + { + return pixels / ppi; + } static float convertToPx(const float input, const TYPE units, const int32_t ppi) { switch (units) { case (PT): - return input * PT_TO_PX; + return convertInchesToPx(input / INCH_TO_PT, ppi); break; case (INCHES): - return ppi * input; + return convertInchesToPx(input, ppi); break; case (CM): - return ppi * INCH_TO_CM * input; + return convertInchesToPx(input / INCH_TO_CM, ppi); break; default: return input; @@ -166,17 +174,16 @@ namespace indigo static float convertToPt(const float input, const TYPE units, const int32_t ppi) { - switch (units) { - case (PT): - return input / PT_TO_PX; + case (PX): + return convertPxToInches(input, ppi) * INCH_TO_PT; break; case (INCHES): - return (input * ppi) / PT_TO_PX; + return input * INCH_TO_PT; break; case (CM): - return (input * ppi * INCH_TO_CM) / PT_TO_PX; + return (input * INCH_TO_PT) / INCH_TO_CM; break; default: return input; @@ -188,13 +195,13 @@ namespace indigo switch (units) { case (PT): - return (input * PT_TO_PX) / ppi; + return input / INCH_TO_PT; break; case (PX): - return input / ppi; + return convertPxToInches(input, ppi); break; case (CM): - return input * INCH_TO_CM; + return input / INCH_TO_CM; break; default: return input; @@ -206,13 +213,13 @@ namespace indigo switch (units) { case (PT): - return (input * PT_TO_PX) / (ppi * INCH_TO_CM); + return (input * INCH_TO_CM) / INCH_TO_PT; break; case (INCHES): - return input / INCH_TO_CM; + return input * INCH_TO_CM; break; case (PX): - return input / (ppi * INCH_TO_CM); + return convertPxToInches(input, ppi) * INCH_TO_CM; break; default: return input; diff --git a/core/indigo-core/layout/src/metalayout.cpp b/core/indigo-core/layout/src/metalayout.cpp index a33833ee98..b8d2e3c8a4 100644 --- a/core/indigo-core/layout/src/metalayout.cpp +++ b/core/indigo-core/layout/src/metalayout.cpp @@ -39,7 +39,7 @@ void Metalayout::LayoutLine::clear() IMPL_ERROR(Metalayout, "metalayout"); -Metalayout::Metalayout() : horizontalIntervalFactor(0.5f), verticalIntervalFactor(0.8f), bondLength(1.0f), _avel(1.0f), _scaleFactor(1.0f) +Metalayout::Metalayout() : reactionComponentMarginSize(0.5f), verticalIntervalFactor(0.8f), bondLength(1.0f), _avel(1.0f), _scaleFactor(1.0f) { clear(); } @@ -100,7 +100,7 @@ void Metalayout::process() case LayoutItem::ItemVerticalAlign::ECenter: break; case LayoutItem::ItemVerticalAlign::ETop: - offset.y += (bondLength + line.top_height) / 2; + offset.y += reactionComponentMarginSize + line.top_height / 2; break; case LayoutItem::ItemVerticalAlign::EBottom: offset.y -= (bondLength + line.bottom_height) / 2; @@ -138,7 +138,7 @@ void Metalayout::calcContentSize() break; } } - line.width += horizontalIntervalFactor * bondLength * (line.items.size() - 1); + line.width += reactionComponentMarginSize * bondLength * (line.items.size() - 1); _contentSize.x = std::max(_contentSize.x, line.width); _contentSize.y += line.height; if (regularWidth < line.width) diff --git a/core/indigo-core/layout/src/reaction_layout.cpp b/core/indigo-core/layout/src/reaction_layout.cpp index 19fab006a4..2110a9e54c 100644 --- a/core/indigo-core/layout/src/reaction_layout.cpp +++ b/core/indigo-core/layout/src/reaction_layout.cpp @@ -21,8 +21,10 @@ #include "molecule/ket_commons.h" #include "molecule/molecule.h" #include "reaction/reaction.h" +#include #include #include +using namespace std::placeholders; using namespace indigo; @@ -33,9 +35,9 @@ ReactionLayout::ReactionLayout(BaseReaction& r, bool smart_layout) } ReactionLayout::ReactionLayout(BaseReaction& r, bool smart_layout, const LayoutOptions& options) - : bond_length(LayoutOptions::DEFAULT_BOND_LENGTH), default_plus_size(options.getMarginSizeInAngstroms()), - default_arrow_size(LayoutOptions::DEFAULT_BOND_LENGTH * 2), preserve_molecule_layout(false), _r(r), _smart_layout(smart_layout), - reaction_margin_size(options.getMarginSizeInAngstroms()), atom_label_width(0.0f), layout_orientation(UNCPECIFIED), max_iterations(0) + : bond_length(LayoutOptions::DEFAULT_BOND_LENGTH), default_plus_size(1), default_arrow_size(LayoutOptions::DEFAULT_BOND_LENGTH * 2), + preserve_molecule_layout(false), _r(r), _smart_layout(smart_layout), reaction_margin_size(options.getMarginSizeInAngstroms()), + atom_label_width(LayoutOptions::DEFAULT_BOND_LENGTH / 2), layout_orientation(UNCPECIFIED), max_iterations(0) { } @@ -113,25 +115,24 @@ void ReactionLayout::_updateMetadata() Vec2f arrow_head(0, 0); Vec2f arrow_tail(0, 0); - constexpr float shift = 0.0f; if (_r.productsCount() == 0) { - arrow_tail.x = react_box.right() + shift; + arrow_tail.x = react_box.right() + reaction_margin_size / 2; arrow_tail.y = react_box.middleY(); - arrow_head.x = arrow_tail.x + shift; + arrow_head.x = arrow_tail.x + default_arrow_size; arrow_head.y = arrow_tail.y; } else if (_r.reactantsCount() == 0) { - arrow_head.x = product_box.left() - shift; + arrow_head.x = product_box.left() - reaction_margin_size / 2; arrow_head.y = product_box.middleY(); - arrow_tail.x = arrow_head.x - shift; + arrow_tail.x = arrow_head.x - default_arrow_size; arrow_tail.y = arrow_head.y; } else { - const float ptab = first_single_product ? 2 * reaction_margin_size : reaction_margin_size; - const float rtab = last_single_reactant ? 2 * reaction_margin_size : reaction_margin_size; + const float ptab = first_single_product ? reaction_margin_size + bond_length / 2 : reaction_margin_size; + const float rtab = last_single_reactant ? reaction_margin_size + bond_length / 2 : reaction_margin_size; arrow_head.y = product_box.middleY(); arrow_tail.y = react_box.middleY(); @@ -202,13 +203,17 @@ void ReactionLayout::make() // layout molecules in a row with the intervals specified Metalayout::LayoutLine& line = _ml.newLine(); - for (int i = _r.reactantBegin(); i < _r.reactantEnd(); i = _r.reactantNext(i)) - { - bool single_atom = _getMol(i).vertexCount() == 1; - if (i != _r.reactantBegin()) - _pushSpace(line, default_plus_size + reaction_margin_size * 2); - _pushMol(line, i); - } + auto processReactionElements = [this, &line](int begin, int end, std::function next) { + for (int i = begin; i < end; i = next(_r, i)) + { + bool single_atom = _getMol(i).vertexCount() == 1; + if (i != begin) + _pushSpace(line, default_plus_size + reaction_margin_size * 2); + _pushMol(line, i); + } + }; + + processReactionElements(_r.reactantBegin(), _r.reactantEnd(), &BaseReaction::reactantNext); if (_r.catalystCount()) { @@ -218,10 +223,11 @@ void ReactionLayout::make() auto& mol = _getMol(i); Rect2f bbox; mol.getBoundingBox(bbox, Vec2f(bond_length, bond_length)); - //_pushSpace(line, reaction_margin_size / 2); - _pushSpace(line, reaction_margin_size); + if (i != _r.catalystBegin()) + _pushSpace(line, reaction_margin_size); + //_pushSpace(line, reaction_margin_size); _pushMol(line, i, true); - _pushSpace(line, reaction_margin_size); + //_pushSpace(line, reaction_margin_size); //_pushSpace(line, reaction_margin_size / 2); } _pushSpace(line, reaction_margin_size); @@ -229,16 +235,10 @@ void ReactionLayout::make() else _pushSpace(line, default_arrow_size + reaction_margin_size * 2); - for (int i = _r.productBegin(); i < _r.productEnd(); i = _r.productNext(i)) - { - bool single_atom = _getMol(i).vertexCount() == 1; - if (i != _r.productBegin()) - _pushSpace(line, default_plus_size + reaction_margin_size); - _pushMol(line, i); - } + processReactionElements(_r.productBegin(), _r.productEnd(), &BaseReaction::productNext); _ml.bondLength = bond_length; - _ml.horizontalIntervalFactor = reaction_margin_size; + _ml.reactionComponentMarginSize = reaction_margin_size; _ml.cb_getMol = cb_getMol; _ml.cb_process = cb_process; _ml.context = this; @@ -249,17 +249,17 @@ void ReactionLayout::make() _updateMetadata(); } -void ReactionLayout::_pushMol(Metalayout::LayoutLine& line, int id, bool is_agent) +void ReactionLayout::_pushMol(Metalayout::LayoutLine& line, int id, bool is_catalyst) { // 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); + _pushSpace(line, atom_label_width); Metalayout::LayoutItem& item = line.items.push(); item.type = Metalayout::LayoutItem::Type::EMolecule; item.isMoleculeFragment = true; item.id = id; auto& mol = _getMol(id); - if (is_agent) + if (is_catalyst) { item.verticalAlign = Metalayout::LayoutItem::ItemVerticalAlign::ETop; } @@ -268,7 +268,7 @@ void ReactionLayout::_pushMol(Metalayout::LayoutLine& line, int id, bool is_agen mol.getBoundingBox(bbox); item.min.copy(bbox.leftBottom()); item.max.copy(bbox.rightTop()); - //_pushSpace(line, atom_label_width); + _pushSpace(line, atom_label_width); } void ReactionLayout::_pushSpace(Metalayout::LayoutLine& line, float size) diff --git a/core/indigo-core/reaction/reaction_json_saver.h b/core/indigo-core/reaction/reaction_json_saver.h index 7779bc9a46..b7dd0fec72 100644 --- a/core/indigo-core/reaction/reaction_json_saver.h +++ b/core/indigo-core/reaction/reaction_json_saver.h @@ -43,6 +43,7 @@ namespace indigo void saveReaction(BaseReaction& rxn); bool add_stereo_desc; bool pretty_json; + indigo::LayoutOptions layout_options; DECL_ERROR; protected: diff --git a/core/indigo-core/reaction/src/reaction_json_saver.cpp b/core/indigo-core/reaction/src/reaction_json_saver.cpp index 788e096bf3..0aa3165053 100644 --- a/core/indigo-core/reaction/src/reaction_json_saver.cpp +++ b/core/indigo-core/reaction/src/reaction_json_saver.cpp @@ -68,7 +68,7 @@ void ReactionJsonSaver::saveReaction(BaseReaction& rxn) std::unique_ptr reaction(rxn.neu()); reaction->clone(rxn); - ReactionLayout rl(*reaction); + ReactionLayout rl(*reaction, false, layout_options); rl.fixLayout(); // merge diff --git a/data/molecules/basic/after_layout.ket b/data/molecules/basic/after_layout.ket index 3520a5c2a3..5ff32b8868 100644 --- a/data/molecules/basic/after_layout.ket +++ b/data/molecules/basic/after_layout.ket @@ -14,12 +14,7 @@ "$ref": "mol3" }, { - "type": "plus", - "location": [ - 3.950000762939453, - 0.0, - 0.0 - ] + "$ref": "mol4" }, { "type": "arrow", @@ -27,19 +22,39 @@ "mode": "open-angle", "pos": [ { - "x": 6.8000006675720219, - "y": 0.0, - "z": 0.0 + "x": 12.809199134589903, + "y": -8.321489393135554, + "z": 0 }, { - "x": 9.40000057220459, - "y": 0.0, - "z": 0.0 + "x": 14.258683632378329, + "y": -8.321489393135554, + "z": 0 } ] } + }, + { + "type": "plus", + "location": [ + 20.769052845436104, + -9.305264818447846, + 0 + ], + "prop": {} + }, + { + "type": "plus", + "location": [ + 8.151784582725362, + -8.27446905288572, + 0 + ], + "prop": {} } - ] + ], + "connections": [], + "templates": [] }, "mol0": { "type": "molecule", @@ -47,49 +62,90 @@ { "label": "C", "location": [ - 0.8000005483627319, - 1.3856407403945926, - 0.0 + 12.932829180864266, + -8.086387686536677, + 0 ] }, { "label": "C", "location": [ - 0.0, - -1.1920928955078128e-7, - 0.0 + 13.403032699160665, + -8.08638761647091, + 0 ] }, { "label": "C", "location": [ - 0.8000003695487976, - -1.3856407403945926, - 0.0 + 13.167930940012464, + -7.679179546588492, + 0 + ] + } + ], + "bonds": [ + { + "type": 1, + "atoms": [ + 0, + 1 + ] + }, + { + "type": 1, + "atoms": [ + 2, + 0 ] }, + { + "type": 1, + "atoms": [ + 1, + 2 + ] + } + ], + "stereoFlagPosition": { + "x": 13.403032699160665, + "y": 6.679179546588492, + "z": 0 + } + }, + "mol1": { + "type": "molecule", + "atoms": [ { "label": "C", "location": [ - 2.4000003337860109, - -1.3856405019760132, - 0.0 + 23.61299930776201, + -7.780264818447844, + 0 ] }, { "label": "C", "location": [ - 3.200000524520874, - 2.384185791015625e-7, - 0.0 + 23.28051538047637, + -8.112748850832137, + 0 ] }, { "label": "C", "location": [ - 2.4000003337860109, - 1.3856407403945926, - 0.0 + 22.948031453190723, + -7.780264818447844, + 0 + ] + }, + { + "label": "C", + "location": [ + 23.28051538047637, + -7.447780786063546, + 0 ] } ], @@ -97,7 +153,7 @@ { "type": 1, "atoms": [ - 5, + 1, 0 ] }, @@ -105,80 +161,71 @@ "type": 1, "atoms": [ 0, - 1 - ] - }, - { - "type": 1, - "atoms": [ - 1, - 2 + 3 ] }, { "type": 1, "atoms": [ 2, - 3 + 1 ] }, { "type": 1, "atoms": [ 3, - 4 - ] - }, - { - "type": 1, - "atoms": [ - 4, - 5 + 2 ] } - ] + ], + "stereoFlagPosition": { + "x": 23.61299930776201, + "y": 6.447780786063546, + "z": 0 + } }, - "mol1": { + "mol2": { "type": "molecule", "atoms": [ { "label": "C", "location": [ - 10.394427299499512, - 1.2310733795166016, - 0.0 + 11.698545015401995, + -8.236083706767648, + 0 ] }, { "label": "C", "location": [ - 11.194427490234377, - -1.2310733795166016, - 0.0 + 11.55324402808516, + -8.683273703335537, + 0 ] }, { "label": "C", "location": [ - 9.90000057220459, - -0.29061728715896609, - 0.0 + 11.083040509788763, + -8.68327363326977, + 0 ] }, { "label": "C", "location": [ - 12.48885440826416, - -0.29061681032180788, - 0.0 + 9.518733105909696, + -6.699526089251999, + 0 ] }, { "label": "C", "location": [ - 11.99442768096924, - 1.2310733795166016, - 0.0 + 11.318142268936963, + -7.959705082935565, + 0 ] } ], @@ -186,73 +233,102 @@ { "type": 1, "atoms": [ - 0, + 3, 4 ] }, { - "type": 2, + "type": 1, "atoms": [ - 4, + 2, 3 ] }, { "type": 1, "atoms": [ - 3, - 1 + 1, + 2 ] }, { - "type": 2, + "type": 1, "atoms": [ - 1, - 2 + 0, + 1 ] }, { "type": 1, "atoms": [ - 2, + 4, 0 ] } - ] + ], + "stereoFlagPosition": { + "x": 11.698545015401995, + "y": 5.699526089251999, + "z": 0 + } }, - "mol2": { + "mol3": { "type": "molecule", "atoms": [ { "label": "C", "location": [ - 7.300000667572022, - 2.399999856948853, - 0.0 + 16.989057225189878, + -10.343893509562417, + 0 ] }, { "label": "C", "location": [ - 8.90000057220459, - 2.399999856948853, - 0.0 + 20.390345588283704, + -13.675473910748003, + 0 ] }, { "label": "C", "location": [ - 7.300000667572022, - 0.7999999523162842, - 0.0 + 16.884427173799626, + -9.885478977041746, + 0 ] }, { "label": "C", "location": [ - 8.90000057220459, - 0.7999999523162842, - 0.0 + 16.22568676464333, + -10.711513317274033, + 0 + ] + }, + { + "label": "C", + "location": [ + 15.932519822393193, + -10.343893509562417, + 0 + ] + }, + { + "label": "C", + "location": [ + 16.037149873783445, + -9.88547911717328, + 0 + ] + }, + { + "label": "C", + "location": [ + 16.460788243528466, + -9.681465468997072, + 0 ] } ], @@ -260,8 +336,15 @@ { "type": 1, "atoms": [ - 0, - 1 + 4, + 5 + ] + }, + { + "type": 1, + "atoms": [ + 3, + 4 ] }, { @@ -274,8 +357,8 @@ { "type": 1, "atoms": [ - 3, - 2 + 0, + 1 ] }, { @@ -284,34 +367,69 @@ 2, 0 ] + }, + { + "type": 1, + "atoms": [ + 6, + 2 + ] + }, + { + "type": 1, + "atoms": [ + 5, + 6 + ] } - ] + ], + "stereoFlagPosition": { + "x": 20.390345588283704, + "y": 8.681465468997072, + "z": 0 + } }, - "mol3": { + "mol4": { "type": "molecule", "atoms": [ { "label": "C", "location": [ - 4.700000762939453, - 0.6928203105926514, - 0.0 + 4.922805764773451, + -11.032813366517814, + 0 + ] + }, + { + "label": "C", + "location": [ + 4.7775048475223825, + -11.480003363085707, + 0 + ] + }, + { + "label": "C", + "location": [ + 4.1620006922379895, + -11.032813296452048, + 0 ] }, { "label": "C", "location": [ - 6.3000006675720219, - 0.6928203105926514, - 0.0 + 4.307301469357522, + -11.480003293019937, + 0 ] }, { "label": "C", "location": [ - 5.500000953674316, - -0.6928203105926514, - 0.0 + 4.5424032285057185, + -10.75643474268573, + 0 ] } ], @@ -319,24 +437,43 @@ { "type": 1, "atoms": [ - 0, - 1 + 2, + 4 + ] + }, + { + "type": 2, + "atoms": [ + 3, + 2 ] }, { "type": 1, "atoms": [ 1, - 2 + 3 + ] + }, + { + "type": 2, + "atoms": [ + 0, + 1 ] }, { "type": 1, "atoms": [ - 2, + 4, 0 ] } - ] + ], + "stereoFlagPosition": { + "x": 4.922805764773451, + "y": 9.75643474268573, + "z": 0 + } } } \ No newline at end of file diff --git a/data/molecules/basic/before_layout.ket b/data/molecules/basic/before_layout.ket index 0f73e5bb31..5ad4724aa4 100644 --- a/data/molecules/basic/before_layout.ket +++ b/data/molecules/basic/before_layout.ket @@ -13,19 +13,25 @@ { "$ref": "mol3" }, + { + "$ref": "mol4" + }, + { + "$ref": "mol5" + }, { "type": "arrow", "data": { "mode": "open-angle", "pos": [ { - "x": 5.965322145954656, - "y": -7.517628828886863, + "x": 16.845176095635402, + "y": -8.235351892147756, "z": 0 }, { - "x": 11.782682829472716, - "y": -7.517628828886863, + "x": 21.808140035059925, + "y": -8.235351892147756, "z": 0 } ] @@ -34,8 +40,17 @@ { "type": "plus", "location": [ - -1.3416666666666661, - -4.189583333333333, + 13.515832882807784, + -8.235351892147756, + 0 + ], + "prop": {} + }, + { + "type": "plus", + "location": [ + 24.547483999541235, + -8.235351892147756, 0 ], "prop": {} @@ -50,48 +65,89 @@ { "label": "C", "location": [ - 1.1359066531479756, - -3.8202957725148625, + 18.029699695931537, + -6.8693265016022425, 0 ] }, { "label": "C", "location": [ - 1.1359066531479756, - -4.156146728865808, + 17.529699619512307, + -7.735351890234323, 0 ] }, { "label": "C", "location": [ - 1.4267535813478944, - -4.324072207041281, + 18.52969977235077, + -7.735351741222724, + 0 + ] + } + ], + "bonds": [ + { + "type": 1, + "atoms": [ + 0, + 1 + ] + }, + { + "type": 1, + "atoms": [ + 2, + 0 + ] + }, + { + "type": 1, + "atoms": [ + 1, + 2 + ] + } + ], + "stereoFlagPosition": { + "x": 18.52969977235077, + "y": 5.8693265016022425, + "z": 0 + } + }, + "mol1": { + "type": "molecule", + "atoms": [ + { + "label": "C", + "location": [ + 23.15585394590758, + -7.528245064367809, 0 ] }, { "label": "C", "location": [ - 3.505980621868369, - -6.154430610238073, + 22.448746820104436, + -8.235351892147756, 0 ] }, { "label": "C", "location": [ - 1.7176005095478133, - -3.8202957725148625, + 23.15585394590758, + -8.942458719927703, 0 ] }, { "label": "C", "location": [ - 1.4267535813478944, - -3.6523702943393896, + 23.86296047566433, + -8.235351892147756, 0 ] } @@ -100,7 +156,7 @@ { "type": 1, "atoms": [ - 5, + 1, 0 ] }, @@ -108,15 +164,81 @@ "type": 1, "atoms": [ 0, + 3 + ] + }, + { + "type": 1, + "atoms": [ + 2, 1 ] }, { "type": 1, "atoms": [ - 1, + 3, 2 ] + } + ], + "stereoFlagPosition": { + "x": 23.86296047566433, + "y": 6.528245064367809, + "z": 0 + } + }, + "mol2": { + "type": "molecule", + "atoms": [ + { + "label": "C", + "location": [ + 11.680030171907351, + -7.46593102129119, + 0 + ] + }, + { + "label": "C", + "location": [ + 10.87101319385707, + -8.053716214976511, + 0 + ] + }, + { + "label": "C", + "location": [ + 11.180030281752616, + -9.004772763004324, + 0 + ] + }, + { + "label": "C", + "location": [ + 12.180030322832383, + -9.004772613992724, + 0 + ] + }, + { + "label": "C", + "location": [ + 12.48904714995763, + -8.053716065964911, + 0 + ] + } + ], + "bonds": [ + { + "type": 1, + "atoms": [ + 3, + 4 + ] }, { "type": 1, @@ -128,64 +250,87 @@ { "type": 1, "atoms": [ - 3, - 4 + 1, + 2 + ] + }, + { + "type": 1, + "atoms": [ + 0, + 1 ] }, { "type": 1, "atoms": [ 4, - 5 + 0 ] } ], "stereoFlagPosition": { - "x": 3.505980621868369, - "y": 2.6523702943393896, + "x": 12.48904714995763, + "y": 6.46593102129119, "z": 0 } }, - "mol1": { + "mol3": { "type": "molecule", "atoms": [ { "label": "C", "location": [ - 15.712199416467719, - -5.7104463055391745, + 26.355497760826857, + -7.140030285908568, + 0 + ] + }, + { + "label": "C", + "location": [ + 25.454528332621855, + -7.57391421379215, + 0 + ] + }, + { + "label": "C", + "location": [ + 27.25646599693907, + -7.573913915768951, 0 ] }, { "label": "C", "location": [ - 15.880252549240165, - -6.227680237586208, + 25.232007523418137, + -8.54884204748057, 0 ] }, { "label": "C", "location": [ - 17.76409334685203, - -3.99556938976193, + 25.85549708836123, + -9.330673498386945, 0 ] }, { "label": "C", "location": [ - 15.54414628369527, - -6.227680237586208, + 26.855497241199693, + -9.330673200363746, 0 ] }, { "label": "C", "location": [ - 15.440255837015346, - -5.909891763513513, + 27.478986806142785, + -8.54884204748057, 0 ] } @@ -194,77 +339,99 @@ { "type": 1, "atoms": [ - 0, + 4, + 5 + ] + }, + { + "type": 1, + "atoms": [ + 3, 4 ] }, { - "type": 2, + "type": 1, "atoms": [ - 4, + 1, 3 ] }, { "type": 1, "atoms": [ - 3, + 0, 1 ] }, { - "type": 2, + "type": 1, "atoms": [ - 1, + 2, + 0 + ] + }, + { + "type": 1, + "atoms": [ + 6, 2 ] }, { "type": 1, "atoms": [ - 2, - 0 + 5, + 6 ] } ], "stereoFlagPosition": { - "x": 17.76409334685203, - "y": 2.99556938976193, + "x": 27.478986806142785, + "y": 6.140030285908568, "z": 0 } }, - "mol2": { + "mol4": { "type": "molecule", "atoms": [ { "label": "C", "location": [ - 11.232207454738976, - -1.472548743464719, + 15.351635519202418, + -7.46593102129119, 0 ] }, { "label": "C", "location": [ - 11.20350411466491, - 2.8475487434647198, + 14.542618466646339, + -8.053716214976511, 0 ] }, { "label": "C", "location": [ - 7.520294802067823, - -1.459637098341615, + 15.851635595621651, + -9.004772613992724, 0 ] }, { "label": "C", "location": [ - 7.492792545261021, - 2.847548743464719, + 14.851635442783184, + -9.004772763004324, + 0 + ] + }, + { + "label": "C", + "location": [ + 16.160652571758497, + -8.053716065964911, 0 ] } @@ -273,8 +440,15 @@ { "type": 1, "atoms": [ - 0, - 1 + 2, + 4 + ] + }, + { + "type": 2, + "atoms": [ + 3, + 2 ] }, { @@ -285,50 +459,58 @@ ] }, { - "type": 1, + "type": 2, "atoms": [ - 3, - 2 + 0, + 1 ] }, { "type": 1, "atoms": [ - 2, + 4, 0 ] } ], "stereoFlagPosition": { - "x": 11.232207454738976, - "y": -3.8475487434647198, + "x": 16.160652571758497, + "y": 6.46593102129119, "z": 0 } }, - "mol3": { + "mol5": { "type": "molecule", "atoms": [ { "label": "C", "location": [ - -10.154792452302736, - -7.965803748854739, + 18.501583217864745, + -6.370885129301106, 0 ] }, { "label": "C", "location": [ - -3.5910408810305956, - -5.903303748854738, + 18.497879877790677, + -5.3757876423716695, 0 ] }, { "label": "C", "location": [ - -4.154116478617981, - 4.680387082188072, + 17.48967056519359, + -6.357973484178003, + 0 + ] + }, + { + "label": "C", + "location": [ + 17.48716830838679, + -5.3757876423716695, 0 ] } @@ -345,6 +527,13 @@ "type": 1, "atoms": [ 1, + 3 + ] + }, + { + "type": 1, + "atoms": [ + 3, 2 ] },