2 #include <Process/Script/ScriptEditor.hpp>
4 #include <ossia/math/math_expression.hpp>
7 #include <QDoubleSpinBox>
11 #include <Spline/Commands.hpp>
23 auto step =
new QDoubleSpinBox{
this};
24 step->setRange(0.0001, 0.3);
25 step->setValue(m_step);
26 step->setSingleStep(0.001);
29 auto lay =
static_cast<QBoxLayout*
>(this->layout());
30 auto controls =
new QFormLayout;
31 controls->addRow(
"Step (smaller is more precise)", step);
32 lay->insertLayout(2, controls);
34 step, qOverload<double>(&QDoubleSpinBox::valueChanged),
this,
35 [
this](
double step) { m_step = step; });
37 expr.add_variable(
"t", t);
38 expr.add_variable(
"x", x);
39 expr.add_variable(
"y", y);
41 expr.register_symbol_table();
43 setText(R
"_(x := cos(2 * pi * t);
48 void on_accepted()
override
50 this->setError(0, QString{});
51 auto txt = this->text().toStdString();
52 bool ok = expr.set_expression(txt);
55 setError(0, QString::fromStdString(expr.error()));
60 ossia::spline_data data;
61 for(t = 0.; t < 1.; t += m_step)
64 data.points.push_back({x, y});
69 data.points.push_back({x, y});
73 m_model, std::move(data));
78 ossia::math_expression expr;
The CommandDispatcher class.
Definition: CommandDispatcher.hpp:13
Definition: ScriptEditor.hpp:21
Definition: plugins/score-plugin-spline/Spline/commands.hpp:13
Definition: Spline/GeneratorDialog.hpp:16
Definition: score-plugin-spline/Spline/Model.hpp:19
Definition: DocumentContext.hpp:18