Skip to content

Commit

Permalink
revert unit-test changes
Browse files Browse the repository at this point in the history
  • Loading branch information
AleksandrParamonoff committed Sep 2, 2024
1 parent a087650 commit bad3411
Show file tree
Hide file tree
Showing 7 changed files with 71 additions and 94 deletions.
1 change: 1 addition & 0 deletions api/c/indigo-renderer/src/indigo_render2d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -720,6 +720,7 @@ void IndigoRenderer::setOptionsHandlers()
mgr->setOptionHandlerBool("render-highlighted-labels-visible", SETTER_GETTER_BOOL_OPTION(rp.rOpt.highlightedLabelsVisible));
mgr->setOptionHandlerBool("render-bold-bond-detection", SETTER_GETTER_BOOL_OPTION(rp.rOpt.boldBondDetection));

mgr->setOptionHandlerFloat("render-bond-length", SETTER_GETTER_FLOAT_OPTION(rp.cnvOpt.bondLength));
mgr->setOptionHandlerFloat("render-relative-thickness", SET_POSITIVE_FLOAT_OPTION(rp.relativeThickness, "relative thickness must be positive"));
mgr->setOptionHandlerFloat("render-bond-line-width", SET_POSITIVE_FLOAT_OPTION(rp.bondLineWidthFactor, "bond line width factor must be positive"));
mgr->setOptionHandlerFloat("render-comment-font-size", SETTER_GETTER_FLOAT_OPTION(rp.rOpt.commentFontFactor));
Expand Down
42 changes: 5 additions & 37 deletions api/c/indigo/src/indigo_options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -317,38 +317,6 @@ IndigoOptionManager::get_optf_string_t indigoGetUnitsOfMeasure(const UnitsOfMeas
return [](Array<char>& res) -> void { return func(res); };
}

void indigoRenderSetImageResolution(const char* mode)
{
Indigo& self = indigoGetInstance();
auto& result = self.layout_options.ppi;
std::string mode_string(mode);
if (isEqual(mode, "high"))
{
result = 600.0;
}
else if (isEqual(mode, "low"))
{
result = 72.0;
}
else
{
throw IndigoError("Invalid label mode, should be 'none', 'hetero', 'terminal-hetero' or 'all'");
}
}

void indigoRenderGetImageResolution(Array<char>& result)
{
const Indigo& self = indigoGetInstance();
if (self.layout_options.ppi == 600.0)
{
result.readString("high", true);
}
else if (self.layout_options.ppi == 72.0)
{
result.readString("low", true);
}
}

void IndigoOptionHandlerSetter::setBasicOptionHandlers(const qword id)
{
auto mgr = sf::xlock_safe_ptr(indigoGetOptionManager(id));
Expand Down Expand Up @@ -473,12 +441,12 @@ 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("render-bond-length", SETTER_GETTER_FLOAT_OPTION(indigo.layout_options.bondLength));
mgr->setOptionHandlerString("render-bond-length-units", indigoSetUnitsOfMeasure(indigo.layout_options.bondLengthUnit),
mgr->setOptionHandlerFloat("bond-length", SETTER_GETTER_FLOAT_OPTION(indigo.layout_options.bondLength));
mgr->setOptionHandlerString("bond-length-unit", indigoSetUnitsOfMeasure(indigo.layout_options.bondLengthUnit),
indigoGetUnitsOfMeasure(indigo.layout_options.bondLengthUnit));
mgr->setOptionHandlerFloat("render-reaction-component-margin-size",
mgr->setOptionHandlerFloat("reaction-component-margin-size",
SET_POSITIVE_FLOAT_OPTION(indigo.layout_options.reactionComponentMarginSize, "reaction component margin size must be positive"));
mgr->setOptionHandlerString("render-reaction-component-margin-units", indigoSetUnitsOfMeasure(indigo.layout_options.reactionComponentMarginSizeUnit),
mgr->setOptionHandlerString("reaction-component-margin-unit", indigoSetUnitsOfMeasure(indigo.layout_options.reactionComponentMarginSizeUnit),
indigoGetUnitsOfMeasure(indigo.layout_options.reactionComponentMarginSizeUnit));
mgr->setOptionHandlerString("render-image-resolution", indigoRenderSetImageResolution, indigoRenderGetImageResolution);
mgr->setOptionHandlerInt("image-resolution", SET_POSITIVE_INT_OPTION(indigo.layout_options.ppi, "image resolution ppi must be positive"));
}
8 changes: 8 additions & 0 deletions api/c/indigo/src/option_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,14 @@ using namespace indigo;
}, \
[](float& value) { value = option; }

#define SET_POSITIVE_INT_OPTION(option, error) \
[](int32_t value) { \
if (value <= 0) \
throw IndigoError(error); \
option = value; \
}, \
[](int32_t& value) { value = option; }

class DLLEXPORT IndigoOptionManager
{
public:
Expand Down
10 changes: 5 additions & 5 deletions core/indigo-core/layout/metalayout.h
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ namespace indigo
static constexpr float INCH_TO_CM = 2.54f;
static constexpr float PT_TO_PX = 1.333334f;

static float convertToPx(const float input, const TYPE units, const float ppi)
static float convertToPx(const float input, const TYPE units, const int32_t ppi)
{
switch (units)
{
Expand All @@ -164,7 +164,7 @@ namespace indigo
}
}

static float convertToPt(const float input, const TYPE units, const float ppi)
static float convertToPt(const float input, const TYPE units, const int32_t ppi)
{

switch (units)
Expand All @@ -183,7 +183,7 @@ namespace indigo
}
}

static float convertToInches(const float input, const TYPE units, const float ppi)
static float convertToInches(const float input, const TYPE units, const int32_t ppi)
{
switch (units)
{
Expand All @@ -201,7 +201,7 @@ namespace indigo
}
}

static float convertToCm(const float input, const TYPE units, const float ppi)
static float convertToCm(const float input, const TYPE units, const int32_t ppi)
{
switch (units)
{
Expand All @@ -227,7 +227,7 @@ namespace indigo
UnitsOfMeasure::TYPE bondLengthUnit{UnitsOfMeasure::TYPE::PX};
float reactionComponentMarginSize{DEFAULT_BOND_LENGTH / 2};
UnitsOfMeasure::TYPE reactionComponentMarginSizeUnit{UnitsOfMeasure::TYPE::PX};
float ppi{72.0f};
int32_t ppi{72};
float getMarginSizeInAngstroms() const
{
auto marginSizePt = UnitsOfMeasure::convertToPt(reactionComponentMarginSize, reactionComponentMarginSizeUnit, ppi);
Expand Down
2 changes: 1 addition & 1 deletion core/render2d/render_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -581,7 +581,7 @@ namespace indigo
std::unique_ptr<RenderCdxmlContext> cdxml_context;
float reactionComponentMarginSize;
UnitsOfMeasure::TYPE reactionComponentMarginSizeUnit;
float ppi;
int32_t ppi;

private:
RenderOptions(const RenderOptions&);
Expand Down
76 changes: 38 additions & 38 deletions data/molecules/basic/after_layout.ket
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
{
"type": "plus",
"location": [
2.750000476837158,
3.950000762939453,
0.0,
0.0
]
Expand All @@ -27,12 +27,12 @@
"mode": "open-angle",
"pos": [
{
"x": 4.750000476837158,
"x": 6.8000006675720219,
"y": 0.0,
"z": 0.0
},
{
"x": 6.750000476837158,
"x": 9.40000057220459,
"y": 0.0,
"z": 0.0
}
Expand All @@ -47,48 +47,48 @@
{
"label": "C",
"location": [
0.5000003576278687,
0.8660255074501038,
0.8000005483627319,
1.3856407403945926,
0.0
]
},
{
"label": "C",
"location": [
0.0,
-5.960464477539064e-8,
-1.1920928955078128e-7,
0.0
]
},
{
"label": "C",
"location": [
0.5000002384185791,
-0.8660255074501038,
0.8000003695487976,
-1.3856407403945926,
0.0
]
},
{
"label": "C",
"location": [
1.5000003576278689,
-0.8660253882408142,
2.4000003337860109,
-1.3856405019760132,
0.0
]
},
{
"label": "C",
"location": [
2.000000476837158,
1.1920928955078128e-7,
3.200000524520874,
2.384185791015625e-7,
0.0
]
},
{
"label": "C",
"location": [
1.5000003576278689,
0.8660255074501038,
2.4000003337860109,
1.3856407403945926,
0.0
]
}
Expand Down Expand Up @@ -144,40 +144,40 @@
{
"label": "C",
"location": [
7.309017181396484,
0.7694209218025208,
10.394427299499512,
1.2310733795166016,
0.0
]
},
{
"label": "C",
"location": [
7.809017658233643,
-0.7694209218025208,
11.194427490234377,
-1.2310733795166016,
0.0
]
},
{
"label": "C",
"location": [
7.000000476837158,
-0.181635856628418,
9.90000057220459,
-0.29061728715896609,
0.0
]
},
{
"label": "C",
"location": [
8.618034362792969,
-0.1816355586051941,
12.48885440826416,
-0.29061681032180788,
0.0
]
},
{
"label": "C",
"location": [
8.309017181396485,
0.7694209218025208,
11.99442768096924,
1.2310733795166016,
0.0
]
}
Expand Down Expand Up @@ -226,32 +226,32 @@
{
"label": "C",
"location": [
5.250000476837158,
1.5,
7.300000667572022,
2.399999856948853,
0.0
]
},
{
"label": "C",
"location": [
6.250000476837158,
1.5,
8.90000057220459,
2.399999856948853,
0.0
]
},
{
"label": "C",
"location": [
5.250000476837158,
0.5,
7.300000667572022,
0.7999999523162842,
0.0
]
},
{
"label": "C",
"location": [
6.250000476837158,
0.5,
8.90000057220459,
0.7999999523162842,
0.0
]
}
Expand Down Expand Up @@ -293,24 +293,24 @@
{
"label": "C",
"location": [
3.500000476837158,
0.4330127239227295,
4.700000762939453,
0.6928203105926514,
0.0
]
},
{
"label": "C",
"location": [
4.500000476837158,
0.4330127239227295,
6.3000006675720219,
0.6928203105926514,
0.0
]
},
{
"label": "C",
"location": [
4.000000476837158,
-0.4330127239227295,
5.500000953674316,
-0.6928203105926514,
0.0
]
}
Expand Down
Loading

0 comments on commit bad3411

Please sign in to comment.