Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#2513 - Elliptical arrows can not be saved to the png #2634

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions api/tests/integration/ref/rendering/render_reactions.py.out
Original file line number Diff line number Diff line change
Expand Up @@ -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
102 changes: 102 additions & 0 deletions api/tests/integration/tests/rendering/reactions/issue_2513.ket
Original file line number Diff line number Diff line change
@@ -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
]
}
]
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 12 additions & 0 deletions api/tests/integration/tests/rendering/render_reactions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
2 changes: 1 addition & 1 deletion core/render2d/src/render_context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
122 changes: 122 additions & 0 deletions utils/indigo-service/backend/service/tests/api/indigo_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading