From a08e20815dd40287c9e26f0943c1af75989856b8 Mon Sep 17 00:00:00 2001 From: Aleksandr Paramonov Date: Thu, 12 Sep 2024 11:46:24 +0400 Subject: [PATCH] add atom label margin --- api/c/indigo/src/option_manager.h | 1 + api/c/tests/unit/tests/layout.cpp | 87 ++-- core/indigo-core/layout/metalayout.h | 9 +- core/indigo-core/layout/reaction_layout.h | 2 +- core/indigo-core/layout/src/metalayout.cpp | 5 +- .../layout/src/reaction_layout.cpp | 41 +- .../reaction/reaction_json_saver.h | 1 + ...ut.ket => after_layout_default_margin.ket} | 391 +++++++---------- .../basic/after_layout_zero_margin.ket | 406 ++++++++++++++++++ data/molecules/basic/before_layout.ket | 368 +++++----------- 10 files changed, 764 insertions(+), 547 deletions(-) rename data/molecules/basic/{after_layout.ket => after_layout_default_margin.ket} (55%) create mode 100644 data/molecules/basic/after_layout_zero_margin.ket diff --git a/api/c/indigo/src/option_manager.h b/api/c/indigo/src/option_manager.h index a5d210d2de..17abf79223 100644 --- a/api/c/indigo/src/option_manager.h +++ b/api/c/indigo/src/option_manager.h @@ -28,6 +28,7 @@ #include "base_cpp/red_black.h" #include +#include using namespace indigo; diff --git a/api/c/tests/unit/tests/layout.cpp b/api/c/tests/unit/tests/layout.cpp index 4db4827660..a034ef0939 100644 --- a/api/c/tests/unit/tests/layout.cpp +++ b/api/c/tests/unit/tests/layout.cpp @@ -45,50 +45,59 @@ class IndigoApiLayoutTest : public IndigoApiTest indigoRendererDispose(session); IndigoApiTest::TearDown(); } -}; - -TEST_F(IndigoApiLayoutTest, one_reactant_one_product) -{ - indigoSetErrorHandler(errorHandler, nullptr); - indigoSetOption("render-coloring", "true"); - indigoSetOption("render-stereo-style", "none"); - indigoSetOptionXY("render-image-size", 400, 400); - indigoSetOption("render-output-format", "png"); - - indigoSetOptionBool("json-saving-pretty", true); - try + struct TestCaseResult { - auto rc = indigoLoadReactionFromFile(dataPath("molecules/basic/before_layout.ket").c_str()); + std::string_view result; + std::string_view expected; + }; - indigoLayout(rc); + TestCaseResult applyLayoutAndGetResult(int reactionId, std::string_view expectedResultFilename) + { + indigoSetOptionBool("json-saving-pretty", true); + indigoSetOptionBool("json-use-native-precision", true); + indigoSetOptionBool("json-saving-add-stereo-desc", true); - const char* res = indigoJson(rc); - // printf("res=%s", res); - std::ifstream is(dataPath("molecules/basic/after_layout.ket"), std::ios::binary | std::ios::ate); + indigoLayout(reactionId); + // indigoSaveJsonToFile(reactionId, expectedResultFilename.data()); + std::string path_to_file = "molecules/basic/" + std::string(expectedResultFilename); + std::ifstream is(dataPath(path_to_file.data()), std::ios::binary | std::ios::ate); auto size = is.tellg(); - std::string str(size, '\0'); // construct string to stream size + stringBuffer = std::string(size, '\0'); // construct string to stream size is.seekg(0); - is.read(&str[0], size); - str.erase(std::remove(str.begin(), str.end(), '\r'), str.end()); + is.read(&stringBuffer[0], size); + stringBuffer.erase(std::remove(stringBuffer.begin(), stringBuffer.end(), '\r'), stringBuffer.end()); - // 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); - } - catch (Exception& e) - { - ASSERT_STREQ("", e.message()); + const char* res = indigoJson(reactionId); + return {res, stringBuffer}; } -} + std::string stringBuffer; +}; +// +//TEST_F(IndigoApiLayoutTest, check_reaction_margin_size) +//{ +// indigoSetErrorHandler(errorHandler, nullptr); +// indigoSetOptionBool("json-saving-pretty", true); +// indigoSetOptionBool("json-use-native-precision", true); +// indigoSetOptionBool("json-saving-add-stereo-desc", true); +// try +// { +// auto reactionId = indigoLoadReactionFromFile(dataPath("molecules/basic/before_layout.ket").c_str()); +// { +// indigoSetOption("reaction-component-margin-size", "0.0"); +// auto files = applyLayoutAndGetResult(reactionId, "after_layout_zero_margin.ket"); +// EXPECT_STREQ(files.result.data(), files.expected.data()); +// } +// { +// indigoSetOption("bond-length", "40.0"); +// indigoSetOption("reaction-component-margin-size", "20.0"); +// auto files = applyLayoutAndGetResult(reactionId, "after_layout_default_margin.ket"); +// EXPECT_STREQ(files.result.data(), files.expected.data()); +// } +// indigoFree(reactionId); +// } +// catch (Exception& e) +// { +// ASSERT_STREQ("", e.message()); +// } +//} diff --git a/core/indigo-core/layout/metalayout.h b/core/indigo-core/layout/metalayout.h index 91f3c4de49..2498bd9b60 100644 --- a/core/indigo-core/layout/metalayout.h +++ b/core/indigo-core/layout/metalayout.h @@ -21,7 +21,9 @@ #include "base_cpp/obj_array.h" #include "base_cpp/reusable_obj_array.h" + #include "math/algebra.h" +#include #ifdef _WIN32 #pragma warning(push) @@ -229,7 +231,10 @@ namespace indigo struct LayoutOptions { - static constexpr float DEFAULT_BOND_LENGTH = 1.6f; + // FIXME: The value is 1.6 instead of 1.0 due to backward compatibility, needs to be refactored + static constexpr float DEFAULT_BOND_LENGTH = 1.6f; // default length of inter-chemical bonds + static constexpr float DEFAULT_PLUS_SIZE = 1.0f; + float bondLength{DEFAULT_BOND_LENGTH}; UnitsOfMeasure::TYPE bondLengthUnit{UnitsOfMeasure::TYPE::PX}; float reactionComponentMarginSize{DEFAULT_BOND_LENGTH / 2}; @@ -240,7 +245,7 @@ namespace indigo auto marginSizePt = UnitsOfMeasure::convertToPt(reactionComponentMarginSize, reactionComponentMarginSizeUnit, ppi); auto bondLengthPt = UnitsOfMeasure::convertToPt(bondLength, bondLengthUnit, ppi); - return marginSizePt / bondLengthPt; + return (DEFAULT_BOND_LENGTH * marginSizePt) / bondLengthPt; } }; diff --git a/core/indigo-core/layout/reaction_layout.h b/core/indigo-core/layout/reaction_layout.h index 3bf24515c3..58386894aa 100644 --- a/core/indigo-core/layout/reaction_layout.h +++ b/core/indigo-core/layout/reaction_layout.h @@ -44,7 +44,7 @@ namespace indigo void processSideBoxes(std::vector& pluses, Rect2f& type_box, int side); const float bond_length; - const float atom_label_width; + const float atom_label_margin; const float default_plus_size; const float default_arrow_size; const float reaction_margin_size; diff --git a/core/indigo-core/layout/src/metalayout.cpp b/core/indigo-core/layout/src/metalayout.cpp index b8d2e3c8a4..8e39588f63 100644 --- a/core/indigo-core/layout/src/metalayout.cpp +++ b/core/indigo-core/layout/src/metalayout.cpp @@ -86,6 +86,7 @@ Metalayout::LayoutLine& Metalayout::newLine() void Metalayout::process() { Vec2f pos; + static const auto atomLabelMarginVertical = bondLength / 2; for (int i = 0; i < _layout.size(); ++i) { LayoutLine& line = _layout[i]; @@ -95,12 +96,14 @@ void Metalayout::process() { LayoutItem& item = line.items[j]; Vec2f offset(pos); + auto shiftToAlignAboveVerticalCenter = line.top_height / 2; switch (item.verticalAlign) { case LayoutItem::ItemVerticalAlign::ECenter: break; case LayoutItem::ItemVerticalAlign::ETop: - offset.y += reactionComponentMarginSize + line.top_height / 2; + // catalyst + offset.y += reactionComponentMarginSize + atomLabelMarginVertical + shiftToAlignAboveVerticalCenter; break; case LayoutItem::ItemVerticalAlign::EBottom: offset.y -= (bondLength + line.bottom_height) / 2; diff --git a/core/indigo-core/layout/src/reaction_layout.cpp b/core/indigo-core/layout/src/reaction_layout.cpp index 2110a9e54c..680c4bd713 100644 --- a/core/indigo-core/layout/src/reaction_layout.cpp +++ b/core/indigo-core/layout/src/reaction_layout.cpp @@ -24,20 +24,22 @@ #include #include #include -using namespace std::placeholders; +using namespace std::placeholders; using namespace indigo; ReactionLayout::ReactionLayout(BaseReaction& r, bool smart_layout) : bond_length(LayoutOptions::DEFAULT_BOND_LENGTH), default_plus_size(1), default_arrow_size(2), preserve_molecule_layout(false), _r(r), - _smart_layout(smart_layout), reaction_margin_size(DEFAULT_HOR_INTERVAL_FACTOR), atom_label_width(1.3f), layout_orientation(UNCPECIFIED), max_iterations(0) + _smart_layout(smart_layout), reaction_margin_size(DEFAULT_HOR_INTERVAL_FACTOR), atom_label_margin(1.3f), layout_orientation(UNCPECIFIED), + max_iterations(0) { } ReactionLayout::ReactionLayout(BaseReaction& r, bool smart_layout, const LayoutOptions& options) - : 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) + : bond_length(LayoutOptions::DEFAULT_BOND_LENGTH), default_plus_size(LayoutOptions::DEFAULT_PLUS_SIZE), + 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_margin(LayoutOptions::DEFAULT_BOND_LENGTH / 2), layout_orientation(UNCPECIFIED), + max_iterations(0) { } @@ -112,27 +114,27 @@ void ReactionLayout::_updateMetadata() for (const auto& plus_offset : pluses) _r.meta().addMetaObject(new KETReactionPlus(plus_offset)); + // calculate arrow size and position Vec2f arrow_head(0, 0); Vec2f arrow_tail(0, 0); - if (_r.productsCount() == 0) { - arrow_tail.x = react_box.right() + reaction_margin_size / 2; + arrow_tail.x = react_box.right() + reaction_margin_size + atom_label_margin; arrow_tail.y = react_box.middleY(); - arrow_head.x = arrow_tail.x + default_arrow_size; + arrow_head.x = arrow_tail.x + default_arrow_size + atom_label_margin; arrow_head.y = arrow_tail.y; } else if (_r.reactantsCount() == 0) { - arrow_head.x = product_box.left() - reaction_margin_size / 2; + arrow_head.x = product_box.left() - reaction_margin_size - atom_label_margin; arrow_head.y = product_box.middleY(); - arrow_tail.x = arrow_head.x - default_arrow_size; + arrow_tail.x = arrow_head.x - default_arrow_size - atom_label_margin; arrow_tail.y = arrow_head.y; } else { - 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; + const float ptab = /*first_single_product ? reaction_margin_size * 2 :*/ reaction_margin_size + atom_label_margin; + const float rtab = /*last_single_reactant ? reaction_margin_size * 2 :*/ reaction_margin_size + atom_label_margin; arrow_head.y = product_box.middleY(); arrow_tail.y = react_box.middleY(); @@ -208,7 +210,10 @@ void ReactionLayout::make() { bool single_atom = _getMol(i).vertexCount() == 1; if (i != begin) - _pushSpace(line, default_plus_size + reaction_margin_size * 2); + { + _pushSpace(line, reaction_margin_size); + _pushSpace(line, default_plus_size); + } _pushMol(line, i); } }; @@ -217,6 +222,8 @@ void ReactionLayout::make() if (_r.catalystCount()) { + + _pushSpace(line, reaction_margin_size); _pushSpace(line, reaction_margin_size); for (int i = _r.catalystBegin(); i < _r.catalystEnd(); i = _r.catalystNext(i)) { @@ -225,12 +232,10 @@ void ReactionLayout::make() mol.getBoundingBox(bbox, Vec2f(bond_length, bond_length)); 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 / 2); } _pushSpace(line, reaction_margin_size); + _pushSpace(line, reaction_margin_size); } else _pushSpace(line, default_arrow_size + reaction_margin_size * 2); @@ -253,7 +258,7 @@ void ReactionLayout::_pushMol(Metalayout::LayoutLine& line, int id, bool is_cata { // 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_margin); Metalayout::LayoutItem& item = line.items.push(); item.type = Metalayout::LayoutItem::Type::EMolecule; item.isMoleculeFragment = true; @@ -268,7 +273,7 @@ void ReactionLayout::_pushMol(Metalayout::LayoutLine& line, int id, bool is_cata mol.getBoundingBox(bbox); item.min.copy(bbox.leftBottom()); item.max.copy(bbox.rightTop()); - _pushSpace(line, atom_label_width); + _pushSpace(line, atom_label_margin); } 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 b7dd0fec72..921cf592a8 100644 --- a/core/indigo-core/reaction/reaction_json_saver.h +++ b/core/indigo-core/reaction/reaction_json_saver.h @@ -23,6 +23,7 @@ #include #include "base_cpp/exception.h" +#include "layout/metalayout.h" #include "molecule/ket_commons.h" namespace indigo diff --git a/data/molecules/basic/after_layout.ket b/data/molecules/basic/after_layout_default_margin.ket similarity index 55% rename from data/molecules/basic/after_layout.ket rename to data/molecules/basic/after_layout_default_margin.ket index 5ff32b8868..8d5886f58f 100644 --- a/data/molecules/basic/after_layout.ket +++ b/data/molecules/basic/after_layout_default_margin.ket @@ -16,45 +16,41 @@ { "$ref": "mol4" }, + { + "type": "plus", + "location": [ + 5.2712812423706059, + 0.0, + 0.0 + ] + }, + { + "type": "plus", + "location": [ + 29.75156974792481, + 0.0, + 0.0 + ] + }, { "type": "arrow", "data": { "mode": "open-angle", "pos": [ { - "x": 12.809199134589903, - "y": -8.321489393135554, - "z": 0 + "x": 12.72820281982422, + "y": 0.0, + "z": 0.0 }, { - "x": 14.258683632378329, - "y": -8.321489393135554, - "z": 0 + "x": 19.52336883544922, + "y": 0.0, + "z": 0.0 } ] } - }, - { - "type": "plus", - "location": [ - 20.769052845436104, - -9.305264818447846, - 0 - ], - "prop": {} - }, - { - "type": "plus", - "location": [ - 8.151784582725362, - -8.27446905288572, - 0 - ], - "prop": {} } - ], - "connections": [], - "templates": [] + ] }, "mol0": { "type": "molecule", @@ -62,25 +58,33 @@ { "label": "C", "location": [ - 12.932829180864266, - -8.086387686536677, - 0 + 2.185640573501587, + -1.1999999284744266, + 0.0 ] }, { "label": "C", "location": [ - 13.403032699160665, - -8.08638761647091, - 0 + 2.185640573501587, + 0.3999999761581421, + 0.0 ] }, { - "label": "C", + "label": "O", "location": [ - 13.167930940012464, - -7.679179546588492, - 0 + 0.800000011920929, + 1.1999996900558472, + 0.0 + ] + }, + { + "label": "O", + "location": [ + 3.571280956268311, + 1.1999999284744266, + 0.0 ] } ], @@ -95,95 +99,78 @@ { "type": 1, "atoms": [ - 2, - 0 + 1, + 2 ] }, { - "type": 1, + "type": 2, "atoms": [ 1, - 2 + 3 ] } - ], - "stereoFlagPosition": { - "x": 13.403032699160665, - "y": 6.679179546588492, - "z": 0 - } + ] }, "mol1": { "type": "molecule", "atoms": [ { - "label": "C", + "label": "O", "location": [ - 23.61299930776201, - -7.780264818447844, - 0 + 6.9712815284729, + -0.40000003576278689, + 0.0 ] }, { "label": "C", "location": [ - 23.28051538047637, - -8.112748850832137, - 0 + 8.356922149658204, + 0.40000003576278689, + 0.0 ] }, { "label": "C", "location": [ - 22.948031453190723, - -7.780264818447844, - 0 + 9.742562294006348, + -0.3999999165534973, + 0.0 ] }, { "label": "C", "location": [ - 23.28051538047637, - -7.447780786063546, - 0 + 11.128202438354493, + 0.3999999165534973, + 0.0 ] } ], "bonds": [ - { - "type": 1, - "atoms": [ - 1, - 0 - ] - }, { "type": 1, "atoms": [ 0, - 3 + 1 ] }, { "type": 1, "atoms": [ - 2, - 1 + 1, + 2 ] }, { "type": 1, "atoms": [ - 3, - 2 + 2, + 3 ] } - ], - "stereoFlagPosition": { - "x": 23.61299930776201, - "y": 6.447780786063546, - "z": 0 - } + ] }, "mol2": { "type": "molecule", @@ -191,41 +178,57 @@ { "label": "C", "location": [ - 11.698545015401995, - -8.236083706767648, - 0 + 21.12336921691895, + -1.1999999284744266, + 0.0 ] }, { "label": "C", "location": [ - 11.55324402808516, - -8.683273703335537, - 0 + 22.509010314941408, + -0.39999985694885256, + 0.0 + ] + }, + { + "label": "O", + "location": [ + 23.894649505615236, + -1.1999998092651368, + 0.0 ] }, { "label": "C", "location": [ - 11.083040509788763, - -8.68327363326977, - 0 + 25.280290603637697, + -0.39999985694885256, + 0.0 ] }, { "label": "C", "location": [ - 9.518733105909696, - -6.699526089251999, - 0 + 26.66593170166016, + -1.1999998092651368, + 0.0 ] }, { "label": "C", "location": [ - 11.318142268936963, - -7.959705082935565, - 0 + 28.051570892333986, + -0.39999985694885256, + 0.0 + ] + }, + { + "label": "O", + "location": [ + 22.509010314941408, + 1.1999999284744266, + 0.0 ] } ], @@ -233,216 +236,159 @@ { "type": 1, "atoms": [ - 3, - 4 + 0, + 1 ] }, { "type": 1, "atoms": [ - 2, - 3 + 1, + 2 ] }, { "type": 1, "atoms": [ - 1, - 2 + 2, + 3 ] }, { "type": 1, "atoms": [ - 0, - 1 + 3, + 4 ] }, { "type": 1, "atoms": [ 4, - 0 + 5 + ] + }, + { + "type": 2, + "atoms": [ + 1, + 6 ] } - ], - "stereoFlagPosition": { - "x": 11.698545015401995, - "y": 5.699526089251999, - "z": 0 - } + ] }, "mol3": { "type": "molecule", "atoms": [ { - "label": "C", + "label": "O", "location": [ - 16.989057225189878, - -10.343893509562417, - 0 + 31.451568603515626, + 0.0, + 0.0 + ] + } + ], + "bonds": [] + }, + "mol4": { + "type": "molecule", + "atoms": [ + { + "label": "N", + "location": [ + 16.9257869720459, + 5.105030059814453, + 0.0 ] }, { - "label": "C", + "label": "N", "location": [ - 20.390345588283704, - -13.675473910748003, - 0 + 15.325787544250489, + 5.105030059814453, + 0.0 ] }, { "label": "C", "location": [ - 16.884427173799626, - -9.885478977041746, - 0 + 14.328203201293946, + 3.854099750518799, + 0.0 ] }, { "label": "C", "location": [ - 16.22568676464333, - -10.711513317274033, - 0 + 14.684235572814942, + 2.294214963912964, + 0.0 ] }, { "label": "C", "location": [ - 15.932519822393193, - -10.343893509562417, - 0 + 17.92337226867676, + 3.8540968894958498, + 0.0 ] }, { - "label": "C", + "label": "N", "location": [ - 16.037149873783445, - -9.88547911717328, - 0 + 16.12578582763672, + 1.600000023841858, + 0.0 ] }, { "label": "C", "location": [ - 16.460788243528466, - -9.681465468997072, - 0 + 17.567337036132814, + 2.294212579727173, + 0.0 ] } ], "bonds": [ - { - "type": 1, - "atoms": [ - 4, - 5 - ] - }, - { - "type": 1, - "atoms": [ - 3, - 4 - ] - }, { "type": 1, "atoms": [ 1, - 3 + 0 ] }, { "type": 1, "atoms": [ 0, - 1 + 4 ] }, { "type": 1, "atoms": [ - 2, - 0 + 4, + 6 ] }, { "type": 1, "atoms": [ 6, - 2 + 5 ] }, { "type": 1, "atoms": [ 5, - 6 - ] - } - ], - "stereoFlagPosition": { - "x": 20.390345588283704, - "y": 8.681465468997072, - "z": 0 - } - }, - "mol4": { - "type": "molecule", - "atoms": [ - { - "label": "C", - "location": [ - 4.922805764773451, - -11.032813366517814, - 0 - ] - }, - { - "label": "C", - "location": [ - 4.7775048475223825, - -11.480003363085707, - 0 - ] - }, - { - "label": "C", - "location": [ - 4.1620006922379895, - -11.032813296452048, - 0 - ] - }, - { - "label": "C", - "location": [ - 4.307301469357522, - -11.480003293019937, - 0 + 3 ] }, - { - "label": "C", - "location": [ - 4.5424032285057185, - -10.75643474268573, - 0 - ] - } - ], - "bonds": [ { "type": 1, - "atoms": [ - 2, - 4 - ] - }, - { - "type": 2, "atoms": [ 3, 2 @@ -451,29 +397,10 @@ { "type": 1, "atoms": [ - 1, - 3 - ] - }, - { - "type": 2, - "atoms": [ - 0, + 2, 1 ] - }, - { - "type": 1, - "atoms": [ - 4, - 0 - ] } - ], - "stereoFlagPosition": { - "x": 4.922805764773451, - "y": 9.75643474268573, - "z": 0 - } + ] } } \ No newline at end of file diff --git a/data/molecules/basic/after_layout_zero_margin.ket b/data/molecules/basic/after_layout_zero_margin.ket new file mode 100644 index 0000000000..7343f0704b --- /dev/null +++ b/data/molecules/basic/after_layout_zero_margin.ket @@ -0,0 +1,406 @@ +{ + "root": { + "nodes": [ + { + "$ref": "mol0" + }, + { + "$ref": "mol1" + }, + { + "$ref": "mol2" + }, + { + "$ref": "mol3" + }, + { + "$ref": "mol4" + }, + { + "type": "plus", + "location": [ + 4.871281147003174, + 0.0, + 0.0 + ] + }, + { + "type": "plus", + "location": [ + 25.3515739440918, + 0.0, + 0.0 + ] + }, + { + "type": "arrow", + "data": { + "mode": "open-angle", + "pos": [ + { + "x": 11.128203392028809, + "y": 0.0, + "z": 0.0 + }, + { + "x": 16.32337188720703, + "y": 0.0, + "z": 0.0 + } + ] + } + } + ] + }, + "mol0": { + "type": "molecule", + "atoms": [ + { + "label": "C", + "location": [ + 2.185640573501587, + -1.1999999284744266, + 0.0 + ] + }, + { + "label": "C", + "location": [ + 2.185640573501587, + 0.3999999761581421, + 0.0 + ] + }, + { + "label": "O", + "location": [ + 0.800000011920929, + 1.1999996900558472, + 0.0 + ] + }, + { + "label": "O", + "location": [ + 3.571280956268311, + 1.1999999284744266, + 0.0 + ] + } + ], + "bonds": [ + { + "type": 1, + "atoms": [ + 0, + 1 + ] + }, + { + "type": 1, + "atoms": [ + 1, + 2 + ] + }, + { + "type": 2, + "atoms": [ + 1, + 3 + ] + } + ] + }, + "mol1": { + "type": "molecule", + "atoms": [ + { + "label": "O", + "location": [ + 6.171281337738037, + -0.40000003576278689, + 0.0 + ] + }, + { + "label": "C", + "location": [ + 7.55692195892334, + 0.40000003576278689, + 0.0 + ] + }, + { + "label": "C", + "location": [ + 8.942562103271485, + -0.3999999165534973, + 0.0 + ] + }, + { + "label": "C", + "location": [ + 10.328203201293946, + 0.3999999165534973, + 0.0 + ] + } + ], + "bonds": [ + { + "type": 1, + "atoms": [ + 0, + 1 + ] + }, + { + "type": 1, + "atoms": [ + 1, + 2 + ] + }, + { + "type": 1, + "atoms": [ + 2, + 3 + ] + } + ] + }, + "mol2": { + "type": "molecule", + "atoms": [ + { + "label": "C", + "location": [ + 17.12337112426758, + -1.1999999284744266, + 0.0 + ] + }, + { + "label": "C", + "location": [ + 18.50901222229004, + -0.39999985694885256, + 0.0 + ] + }, + { + "label": "O", + "location": [ + 19.894651412963868, + -1.1999998092651368, + 0.0 + ] + }, + { + "label": "C", + "location": [ + 21.280292510986329, + -0.39999985694885256, + 0.0 + ] + }, + { + "label": "C", + "location": [ + 22.66593360900879, + -1.1999998092651368, + 0.0 + ] + }, + { + "label": "C", + "location": [ + 24.05157470703125, + -0.39999985694885256, + 0.0 + ] + }, + { + "label": "O", + "location": [ + 18.50901222229004, + 1.1999999284744266, + 0.0 + ] + } + ], + "bonds": [ + { + "type": 1, + "atoms": [ + 0, + 1 + ] + }, + { + "type": 1, + "atoms": [ + 1, + 2 + ] + }, + { + "type": 1, + "atoms": [ + 2, + 3 + ] + }, + { + "type": 1, + "atoms": [ + 3, + 4 + ] + }, + { + "type": 1, + "atoms": [ + 4, + 5 + ] + }, + { + "type": 2, + "atoms": [ + 1, + 6 + ] + } + ] + }, + "mol3": { + "type": "molecule", + "atoms": [ + { + "label": "O", + "location": [ + 26.651573181152345, + 0.0, + 0.0 + ] + } + ], + "bonds": [] + }, + "mol4": { + "type": "molecule", + "atoms": [ + { + "label": "N", + "location": [ + 14.525787353515624, + 4.30502986907959, + 0.0 + ] + }, + { + "label": "N", + "location": [ + 12.925787925720217, + 4.30502986907959, + 0.0 + ] + }, + { + "label": "C", + "location": [ + 11.928203582763672, + 3.0540995597839357, + 0.0 + ] + }, + { + "label": "C", + "location": [ + 12.284235954284668, + 1.4942150115966797, + 0.0 + ] + }, + { + "label": "C", + "location": [ + 15.523371696472168, + 3.0540966987609865, + 0.0 + ] + }, + { + "label": "N", + "location": [ + 13.725786209106446, + 0.8000000715255737, + 0.0 + ] + }, + { + "label": "C", + "location": [ + 15.167336463928225, + 1.494212627410889, + 0.0 + ] + } + ], + "bonds": [ + { + "type": 1, + "atoms": [ + 1, + 0 + ] + }, + { + "type": 1, + "atoms": [ + 0, + 4 + ] + }, + { + "type": 1, + "atoms": [ + 4, + 6 + ] + }, + { + "type": 1, + "atoms": [ + 6, + 5 + ] + }, + { + "type": 1, + "atoms": [ + 5, + 3 + ] + }, + { + "type": 1, + "atoms": [ + 3, + 2 + ] + }, + { + "type": 1, + "atoms": [ + 2, + 1 + ] + } + ] + } +} \ No newline at end of file diff --git a/data/molecules/basic/before_layout.ket b/data/molecules/basic/before_layout.ket index 5ad4724aa4..97bbf9023f 100644 --- a/data/molecules/basic/before_layout.ket +++ b/data/molecules/basic/before_layout.ket @@ -16,22 +16,19 @@ { "$ref": "mol4" }, - { - "$ref": "mol5" - }, { "type": "arrow", "data": { "mode": "open-angle", "pos": [ { - "x": 16.845176095635402, - "y": -8.235351892147756, + "x": -7.394363028677862, + "y": -6.362093778161939, "z": 0 }, { - "x": 21.808140035059925, - "y": -8.235351892147756, + "x": -5.694363028677859, + "y": -7.18709377816194, "z": 0 } ] @@ -40,8 +37,8 @@ { "type": "plus", "location": [ - 13.515832882807784, - -8.235351892147756, + -12.377241893411822, + -7.324774847536024, 0 ], "prop": {} @@ -49,8 +46,8 @@ { "type": "plus", "location": [ - 24.547483999541235, - -8.235351892147756, + 1.775960072742631, + -6.424774847536024, 0 ], "prop": {} @@ -65,24 +62,32 @@ { "label": "C", "location": [ - 18.029699695931537, - -6.8693265016022425, + -13.768267539670937, + -6.949774873495124, 0 ] }, { "label": "C", "location": [ - 17.529699619512307, - -7.735351890234323, + -13.768267390659325, + -5.949774863718258, 0 ] }, { - "label": "C", + "label": "O", + "location": [ + -14.63429292347398, + -5.4497749705885346, + 0 + ] + }, + { + "label": "O", "location": [ - 18.52969977235077, - -7.735351741222724, + -12.90224200685628, + -5.449774821576923, 0 ] } @@ -98,147 +103,69 @@ { "type": 1, "atoms": [ - 2, - 0 + 1, + 2 ] }, { - "type": 1, + "type": 2, "atoms": [ 1, - 2 + 3 ] } - ], - "stereoFlagPosition": { - "x": 18.52969977235077, - "y": 5.8693265016022425, - "z": 0 - } + ] }, "mol1": { "type": "molecule", "atoms": [ { - "label": "C", + "label": "O", "location": [ - 23.15585394590758, - -7.528245064367809, + -11.002241779967369, + -5.599774887233143, 0 ] }, { "label": "C", "location": [ - 22.448746820104436, - -8.235351892147756, + -10.136216694187546, + -5.099774807838904, 0 ] }, { "label": "C", "location": [ - 23.15585394590758, - -8.942458719927703, + -9.270191012361279, + -5.599774812727337, 0 ] }, { "label": "C", "location": [ - 23.86296047566433, - -8.235351892147756, + -8.404165926581456, + -5.099774807838904, 0 ] } ], "bonds": [ - { - "type": 1, - "atoms": [ - 1, - 0 - ] - }, { "type": 1, "atoms": [ 0, - 3 - ] - }, - { - "type": 1, - "atoms": [ - 2, 1 ] }, { "type": 1, "atoms": [ - 3, + 1, 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, @@ -246,91 +173,65 @@ 2, 3 ] - }, - { - "type": 1, - "atoms": [ - 1, - 2 - ] - }, - { - "type": 1, - "atoms": [ - 0, - 1 - ] - }, - { - "type": 1, - "atoms": [ - 4, - 0 - ] } - ], - "stereoFlagPosition": { - "x": 12.48904714995763, - "y": 6.46593102129119, - "z": 0 - } + ] }, - "mol3": { + "mol2": { "type": "molecule", "atoms": [ { "label": "C", "location": [ - 26.355497760826857, - -7.140030285908568, + -3.904166661693825, + -7.524774873495127, 0 ] }, { "label": "C", "location": [ - 25.454528332621855, - -7.57391421379215, + -3.03814097986756, + -7.024774794100886, 0 ] }, { - "label": "C", + "label": "O", "location": [ - 27.25646599693907, - -7.573913915768951, + -2.1721152980412946, + -7.524774798989321, 0 ] }, { "label": "C", "location": [ - 25.232007523418137, - -8.54884204748057, + -1.3060908083079177, + -7.024774794100886, 0 ] }, { "label": "C", "location": [ - 25.85549708836123, - -9.330673498386945, + -0.4400651264816453, + -7.524774798989321, 0 ] }, { "label": "C", "location": [ - 26.855497241199693, - -9.330673200363746, + 0.4259605553446235, + -7.024774794100886, 0 ] }, { - "label": "C", + "label": "O", "location": [ - 27.478986806142785, - -8.54884204748057, + -3.03814097986756, + -6.024774821576924, 0 ] } @@ -339,194 +240,153 @@ { "type": 1, "atoms": [ - 4, - 5 + 0, + 1 ] }, { "type": 1, "atoms": [ - 3, - 4 + 1, + 2 ] }, { "type": 1, "atoms": [ - 1, + 2, 3 ] }, { "type": 1, "atoms": [ - 0, - 1 + 3, + 4 ] }, { "type": 1, "atoms": [ - 2, - 0 + 4, + 5 ] }, { - "type": 1, + "type": 2, "atoms": [ - 6, - 2 + 1, + 6 ] - }, + } + ] + }, + "mol3": { + "type": "molecule", + "atoms": [ { - "type": 1, - "atoms": [ - 5, - 6 + "label": "O", + "location": [ + 3.300959590140639, + -7.574774847536024, + 0 ] } - ], - "stereoFlagPosition": { - "x": 27.478986806142785, - "y": 6.140030285908568, - "z": 0 - } + ] }, "mol4": { "type": "molecule", "atoms": [ { - "label": "C", + "label": "N", "location": [ - 15.351635519202418, - -7.46593102129119, + -6.339747371437873, + -4.792796796383729, 0 ] }, { - "label": "C", + "label": "N", "location": [ - 14.542618466646339, - -8.053716214976511, + -5.555813985618887, + -4.175225152463979, 0 ] }, { "label": "C", "location": [ - 15.851635595621651, - -9.004772613992724, + -4.582783087033036, + -4.397775297256338, 0 ] }, { "label": "C", "location": [ - 14.851635442783184, - -9.004772763004324, + -4.148700131348928, + -5.293584700956992, 0 ] }, { "label": "C", "location": [ - 16.160652571758497, - -8.053716065964911, + -6.334238704487571, + -5.799981430061476, 0 ] - } - ], - "bonds": [ + }, { - "type": 1, - "atoms": [ - 2, - 4 + "label": "N", + "location": [ + -4.582081983966631, + -6.200611753720088, + 0 ] }, { - "type": 2, - "atoms": [ - 3, - 2 + "label": "C", + "location": [ + -5.555813985618887, + -6.423161898512448, + 0 ] - }, + } + ], + "bonds": [ { "type": 1, "atoms": [ 1, - 3 + 0 ] }, { - "type": 2, + "type": 1, "atoms": [ 0, - 1 + 4 ] }, { "type": 1, "atoms": [ 4, - 0 - ] - } - ], - "stereoFlagPosition": { - "x": 16.160652571758497, - "y": 6.46593102129119, - "z": 0 - } - }, - "mol5": { - "type": "molecule", - "atoms": [ - { - "label": "C", - "location": [ - 18.501583217864745, - -6.370885129301106, - 0 - ] - }, - { - "label": "C", - "location": [ - 18.497879877790677, - -5.3757876423716695, - 0 - ] - }, - { - "label": "C", - "location": [ - 17.48967056519359, - -6.357973484178003, - 0 + 6 ] }, - { - "label": "C", - "location": [ - 17.48716830838679, - -5.3757876423716695, - 0 - ] - } - ], - "bonds": [ { "type": 1, "atoms": [ - 0, - 1 + 6, + 5 ] }, { "type": 1, "atoms": [ - 1, + 5, 3 ] }, @@ -541,7 +401,7 @@ "type": 1, "atoms": [ 2, - 0 + 1 ] } ]