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

#1026 SVG/PNG: Contracted 'Functional Groups' and 'Salts and Solvents' are rendered expanded when saved #1154

Merged
Show file tree
Hide file tree
Changes from 24 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
f8c27f7
creates previous tests. should be changed after algorithm is implemented
Wadym Jun 6, 2023
a574dbf
formats py-file with black
Wadym Jun 6, 2023
057eb90
implements clumsy solution
Wadym Jun 9, 2023
a8477e8
fixes clang formatting requirement
Wadym Jun 9, 2023
ea10741
deletes collapseSuperatoms
Wadym Jun 9, 2023
d59ccfb
modifies tests. contracted_expanded... .svg still require work
Wadym Jun 9, 2023
97d4cf5
corrects tests
Wadym Jun 14, 2023
60b8ae1
adds png to win
Wadym Jun 14, 2023
25dacae
adds molfile_loader
Wadym Jun 14, 2023
2644b43
fixex py test
Wadym Jun 14, 2023
5e5c0df
contracted to 1
Wadym Jun 14, 2023
fae7370
modifies basic_load test for expanded case
Wadym Jun 14, 2023
b00f32b
sets undefined contraction to -1
Wadym Jun 14, 2023
273e12a
lefts png only testing
Wadym Jun 14, 2023
a53629d
purges comments and reverts basic_load test
Wadym Jun 15, 2023
311cea6
purges comments
Wadym Jun 15, 2023
dca222f
deletes methods thhat set up unused parameter
Wadym Jun 15, 2023
69859f0
cleans
Wadym Jun 15, 2023
1dd3bca
adds scoped enum for contractred/expanded state and renames some vari…
Wadym Jun 22, 2023
fbefc11
Merge branch 'master' into bugfix/svg_png_contracted_fun_groups_salts…
Wadym Jun 22, 2023
edee31e
formats with clang
Wadym Jun 22, 2023
852ede5
Merge branch 'bugfix/1094-r-group_isn_t_opened_correctly_from_v3000' …
Wadym Jun 22, 2023
16c888f
cleans and formats
Wadym Jun 22, 2023
90314ab
cleans
Wadym Jun 22, 2023
1343a5e
moves constants
Wadym Jun 23, 2023
d845e81
cleans an unnecessary comment with obsolete code
Wadym Jun 23, 2023
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
30 changes: 0 additions & 30 deletions api/c/indigo-renderer/src/indigo_render2d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -271,35 +271,6 @@ void indigoRenderGetCatalystsPlacement(Array<char>& value)
value.readString("above", true);
}

void indigoRenderSetSuperatomMode(const char* mode)
{
std::string mode_string(mode);
int result;
if (mode_string == "expand")
{
result = 0;
}
else if (mode_string == "collapse")
{
result = 1;
}
else
{
throw IndigoError("Invalid label mode, should be 'expand' or 'collapse'");
}
RenderParams& rp = indigoRendererGetInstance().renderParams;
rp.rOpt.collapseSuperatoms = result != 0;
}

void indigoRenderGetSuperatomMode(Array<char>& value)
{
RenderParams& rp = indigoRendererGetInstance().renderParams;
if (rp.rOpt.collapseSuperatoms)
value.readString("collapse", true);
else
value.readString("expand", true);
}

static MultilineTextLayout _parseTextLayout(const char* text)
{
// Try to read as float for compatibility with previous versions
Expand Down Expand Up @@ -735,7 +706,6 @@ void IndigoRenderer::setOptionsHandlers()
mgr->setOptionHandlerString("render-comment-position", indigoRenderSetCommentPosition, indigoRenderGetCommentPosition);
mgr->setOptionHandlerString("render-stereo-style", indigoRenderSetStereoStyle, indigoRenderGetStereoStyle);
mgr->setOptionHandlerString("render-catalysts-placement", indigoRenderSetCatalystsPlacement, indigoRenderGetCatalystsPlacement);
mgr->setOptionHandlerString("render-superatom-mode", indigoRenderSetSuperatomMode, indigoRenderGetSuperatomMode);
mgr->setOptionHandlerString("render-atom-color-property", SETTER_GETTER_STR_OPTION(rp.rOpt.atomColorProp));

mgr->setOptionHandlerBool("render-coloring", SETTER_GETTER_BOOL_OPTION(rp.rOpt.atomColoring));
Expand Down
6 changes: 3 additions & 3 deletions api/c/indigo/src/indigo_molecule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3216,8 +3216,8 @@ CEXPORT int indigoGetSGroupDisplayOption(int sgroup)
INDIGO_BEGIN
{
Superatom& sup = IndigoSuperatom::cast(self.getObject(sgroup)).get();
if (sup.contracted > -1)
return sup.contracted;
if (sup.contracted > DisplayOption::Undefined)
return (int)sup.contracted;

return 0;
}
Expand All @@ -3229,7 +3229,7 @@ CEXPORT int indigoSetSGroupDisplayOption(int sgroup, int option)
INDIGO_BEGIN
{
Superatom& sup = IndigoSuperatom::cast(self.getObject(sgroup)).get();
sup.contracted = option;
sup.contracted = (DisplayOption)option;

return 1;
}
Expand Down
3 changes: 0 additions & 3 deletions api/c/tests/unit/tests/renderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ class IndigoApiRendererTest : public IndigoApiTest
indigoSetOption("render-stereo-style", "none");
indigoSetOptionXY("render-image-size", 400, 400);
indigoSetOption("render-output-format", "png");
indigoSetOption("render-superatom-mode", "collapse");

try
{
Expand Down Expand Up @@ -89,7 +88,6 @@ TEST_F(IndigoApiRendererTest, layout_rings)
indigoSetOption("render-stereo-style", "none");
indigoSetOptionXY("render-image-size", 400, 400);
indigoSetOption("render-output-format", "png");
indigoSetOption("render-superatom-mode", "collapse");
indigoRenderToFile(m, "ring.png");
}
catch (Exception& e)
Expand All @@ -112,7 +110,6 @@ TEST_F(IndigoApiRendererTest, layout_crown)
indigoSetOption("render-stereo-style", "none");
indigoSetOptionXY("render-image-size", 400, 400);
indigoSetOption("render-output-format", "png");
indigoSetOption("render-superatom-mode", "collapse");
indigoRenderToFile(m, "crown.png");
}
catch (Exception& e)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
*** test png output ***
*** test ket input ***
contracted_fg_ss_ket.png rendering status: OK
contracted_expanded_fg_ss_ket.png rendering status: OK
expanded_fg_ss_ket.png rendering status: OK
*** test mol input ***
*** contracted_fg_ss_mol.png done ***
contracted_fg_ss_mol.png rendering status: OK
contracted_expanded_fg_ss_mol.png rendering status: OK
expanded_fg_ss_mol.png rendering status: OK
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
import errno
import os
import sys

sys.path.append(
os.path.normpath(
os.path.join(os.path.abspath(__file__), "..", "..", "..", "common")
)
)
from env_indigo import * # noqa
from rendering import *

if not os.path.exists(joinPathPy("out", __file__)):
try:
os.makedirs(joinPathPy("out", __file__))
except OSError as e:
if e.errno != errno.EEXIST:
raise

indigo = Indigo()
renderer = IndigoRenderer(indigo)

print("*** test png output ***")

print("*** test ket input ***")

mol11 = indigo.loadMoleculeFromFile(
joinPathPy("molecules/contracted_fg_ss.ket", __file__)
)
indigo.setOption("render-output-format", "png")
renderer.renderToFile(
mol11, joinPathPy("out/contracted_fg_ss_ket.png", __file__)
)
print(checkImageSimilarity("contracted_fg_ss_ket.png"))

mol12 = indigo.loadMoleculeFromFile(
joinPathPy("molecules/contracted_expanded_fg_ss.ket", __file__)
)
indigo.setOption("render-output-format", "png")
renderer.renderToFile(
mol12, joinPathPy("out/contracted_expanded_fg_ss_ket.png", __file__)
)
print(checkImageSimilarity("contracted_expanded_fg_ss_ket.png"))

mol13 = indigo.loadMoleculeFromFile(
joinPathPy("molecules/expanded_fg_ss.ket", __file__)
)
indigo.setOption("render-output-format", "png")
renderer.renderToFile(
mol13, joinPathPy("out/expanded_fg_ss_ket.png", __file__)
)
print(checkImageSimilarity("expanded_fg_ss_ket.png"))

print("*** test mol input ***")

mol14 = indigo.loadMoleculeFromFile(
joinPathPy("molecules/contracted_fg_ss.mol", __file__)
)
indigo.setOption("render-output-format", "png")
renderer.renderToFile(
mol14, joinPathPy("out/contracted_fg_ss_mol.png", __file__)
)
print("*** contracted_fg_ss_mol.png done ***")
print(checkImageSimilarity("contracted_fg_ss_mol.png"))

mol15 = indigo.loadMoleculeFromFile(
joinPathPy("molecules/contracted_expanded_fg_ss.mol", __file__)
)
indigo.setOption("render-output-format", "png")
renderer.renderToFile(
mol15, joinPathPy("out/contracted_expanded_fg_ss_mol.png", __file__)
)
print(checkImageSimilarity("contracted_expanded_fg_ss_mol.png"))

mol16 = indigo.loadMoleculeFromFile(
joinPathPy("molecules/expanded_fg_ss.mol", __file__)
)
indigo.setOption("render-output-format", "png")
renderer.renderToFile(
mol16, joinPathPy("out/expanded_fg_ss_mol.png", __file__)
)
print(checkImageSimilarity("expanded_fg_ss_mol.png"))

if isIronPython():
renderer.Dispose()
indigo.Dispose()
Loading