Skip to content

Commit

Permalink
preliminary change to support #244 (#247)
Browse files Browse the repository at this point in the history
  • Loading branch information
facontidavide authored Feb 9, 2020
1 parent bf121c1 commit 0b453ae
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion plotter_gui/transforms/custom_function.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,22 @@ PlotData::Point CustomFunction::calculatePoint(QJSValue& calcFct,
{
throw std::runtime_error("JS Engine : " + jsData.toString().toStdString());
}
new_point.y = jsData.toNumber();

if( jsData.isArray() )
{
const int length = jsData.property("length").toInt();
if( length == 2 )
{
new_point.x = jsData.property(0).toNumber();
new_point.y = jsData.property(1).toNumber();
}
else{
throw std::runtime_error("JS Engine : if you return an array, the size must be 2 (time/value pair)");
}
}
else{
new_point.y = jsData.toNumber();
}

return new_point;
}
Expand Down

0 comments on commit 0b453ae

Please sign in to comment.