diff --git a/api/tests/integration/ref/rendering/render_reactions.py.out b/api/tests/integration/ref/rendering/render_reactions.py.out index 7d74ddb834..5fdd2c5b3a 100644 --- a/api/tests/integration/ref/rendering/render_reactions.py.out +++ b/api/tests/integration/ref/rendering/render_reactions.py.out @@ -13,3 +13,5 @@ issue 2444 wrong arrow and plus width issue_2444.png rendering status: OK issue 2512 two short equilibrium half arrows issue_2512.png rendering status: OK +issue 2513 elliptical-arc-arrow render error +issue_2513.png rendering status: OK diff --git a/api/tests/integration/tests/rendering/reactions/issue_2513.ket b/api/tests/integration/tests/rendering/reactions/issue_2513.ket new file mode 100644 index 0000000000..07c0ccfcc3 --- /dev/null +++ b/api/tests/integration/tests/rendering/reactions/issue_2513.ket @@ -0,0 +1,102 @@ +{ + "root": { + "nodes": [ + { + "$ref": "mol0" + }, + { + "$ref": "mol1" + }, + { + "$ref": "mol2" + }, + { + "type": "arrow", + "data": { + "mode": "elliptical-arc-arrow-open-angle", + "pos": [ + { + "x": 5.799999999999997, + "y": -8.200000000000003, + "z": 0 + }, + { + "x": 7.205569279687058, + "y": -8.200000000000003, + "z": 0 + } + ], + "height": 1 + } + }, + { + "type": "arrow", + "data": { + "mode": "open-angle", + "pos": [ + { + "x": 7.775, + "y": -8.225, + "z": 0 + }, + { + "x": 8.875, + "y": -8.225, + "z": 0 + } + ] + } + }, + { + "type": "plus", + "location": [ + 6.525, + -8.225, + 0 + ], + "prop": {} + } + ], + "connections": [], + "templates": [] + }, + "mol0": { + "type": "molecule", + "atoms": [ + { + "label": "N", + "location": [ + 5.749999999999999, + -8.350000000000001, + 0 + ] + } + ] + }, + "mol1": { + "type": "molecule", + "atoms": [ + { + "label": "O", + "location": [ + 7.3999999999999995, + -8.3, + 0 + ] + } + ] + }, + "mol2": { + "type": "molecule", + "atoms": [ + { + "label": "C", + "location": [ + 9.15, + -8.3, + 0 + ] + } + ] + } +} \ No newline at end of file diff --git a/api/tests/integration/tests/rendering/ref/linux/issue_2513.png b/api/tests/integration/tests/rendering/ref/linux/issue_2513.png new file mode 100644 index 0000000000..7ed22ae2c3 Binary files /dev/null and b/api/tests/integration/tests/rendering/ref/linux/issue_2513.png differ diff --git a/api/tests/integration/tests/rendering/ref/mac/issue_2513.png b/api/tests/integration/tests/rendering/ref/mac/issue_2513.png new file mode 100644 index 0000000000..1fb5b46e2e Binary files /dev/null and b/api/tests/integration/tests/rendering/ref/mac/issue_2513.png differ diff --git a/api/tests/integration/tests/rendering/ref/win/issue_2513.png b/api/tests/integration/tests/rendering/ref/win/issue_2513.png new file mode 100644 index 0000000000..7ed22ae2c3 Binary files /dev/null and b/api/tests/integration/tests/rendering/ref/win/issue_2513.png differ diff --git a/api/tests/integration/tests/rendering/render_reactions.py b/api/tests/integration/tests/rendering/render_reactions.py index 2b3d8cd68d..954bcc6ccc 100644 --- a/api/tests/integration/tests/rendering/render_reactions.py +++ b/api/tests/integration/tests/rendering/render_reactions.py @@ -105,6 +105,18 @@ def renderRxnfile(filename, outfile): renderer.renderToFile(rxn, joinPathPy("out/" + png_fname, __file__)) print(checkImageSimilarity(png_fname)) +print("issue 2513 elliptical-arc-arrow render error") +indigo.resetOptions() +indigo.setOption("ignore-stereochemistry-errors", "true") +indigo.setOption("render-background-color", "255, 255, 255") +indigo.setOption("render-output-format", "png") +fname = "issue_2513" +png_fname = fname + ".png" +ket_fname = joinPathPy("reactions/%s.ket" % fname, __file__) +rxn = indigo.loadReactionFromFile(ket_fname) +renderer.renderToFile(rxn, joinPathPy("out/" + png_fname, __file__)) +print(checkImageSimilarity(png_fname)) + if isIronPython(): renderer.Dispose() indigo.Dispose() diff --git a/core/render2d/src/render_context.cpp b/core/render2d/src/render_context.cpp index 43f086914d..e332ad4bc0 100644 --- a/core/render2d/src/render_context.cpp +++ b/core/render2d/src/render_context.cpp @@ -1036,7 +1036,7 @@ void RenderContext::drawPlus(const Vec2f& pos, const float linewidth, const floa void RenderContext::drawHalfEllipse(const Vec2f& v1, const Vec2f& v2, const float height, const bool is_negative) { - float h = abs(height); + float h = std::fabs(height); double angle1 = height > 0 ? -M_PI : 0; double angle2 = height > 0 ? 0 : M_PI; Vec2f d; diff --git a/utils/indigo-service/backend/service/tests/api/indigo_test.py b/utils/indigo-service/backend/service/tests/api/indigo_test.py index 78c5d709af..273e1b6209 100644 --- a/utils/indigo-service/backend/service/tests/api/indigo_test.py +++ b/utils/indigo-service/backend/service/tests/api/indigo_test.py @@ -1670,6 +1670,128 @@ def test_check_overlap(self): result_data["overlapping_atoms"], ) + def test_render_eleptical_arrow(self): + ket = """{ + "root": { + "nodes": [ + { + "$ref": "mol0" + }, + { + "$ref": "mol1" + }, + { + "$ref": "mol2" + }, + { + "type": "arrow", + "data": { + "mode": "elliptical-arc-arrow-open-angle", + "pos": [ + { + "x": 5.799999999999997, + "y": -8.200000000000003, + "z": 0 + }, + { + "x": 7.205569279687058, + "y": -8.200000000000003, + "z": 0 + } + ], + "height": 1 + } + }, + { + "type": "arrow", + "data": { + "mode": "open-angle", + "pos": [ + { + "x": 7.775, + "y": -8.225, + "z": 0 + }, + { + "x": 8.875, + "y": -8.225, + "z": 0 + } + ] + } + }, + { + "type": "plus", + "location": [ + 6.525, + -8.225, + 0 + ], + "prop": {} + } + ], + "connections": [], + "templates": [] + }, + "mol0": { + "type": "molecule", + "atoms": [ + { + "label": "N", + "location": [ + 5.749999999999999, + -8.350000000000001, + 0 + ] + } + ] + }, + "mol1": { + "type": "molecule", + "atoms": [ + { + "label": "O", + "location": [ + 7.3999999999999995, + -8.3, + 0 + ] + } + ] + }, + "mol2": { + "type": "molecule", + "atoms": [ + { + "label": "C", + "location": [ + 9.15, + -8.3, + 0 + ] + } + ] + } +}""" + ref_path = joinPathPy("ref/", __file__) + headers, data = self.get_headers( + { + "output_format": "image/png", + "struct": ket, + } + ) + result = requests.post( + self.url_prefix + "/render", + headers=headers, + data=data, + ) + fname = "render-eleptical-arrow.png" + # with open(os.path.join(ref_path, fname), "wb") as file: + # file.write(result.content) + with open(os.path.join(ref_path, fname), "rb") as file: + ref = file.read() + self.assertEqual(result.content, ref) + def test_check_stereo(self): # up headers, data = self.get_headers( diff --git a/utils/indigo-service/backend/service/tests/api/ref/render-eleptical-arrow.png b/utils/indigo-service/backend/service/tests/api/ref/render-eleptical-arrow.png new file mode 100644 index 0000000000..39157a278f Binary files /dev/null and b/utils/indigo-service/backend/service/tests/api/ref/render-eleptical-arrow.png differ