2 #include <Process/Script/ScriptEditor.hpp>
4 #include <ossia/math/math_expression.hpp>
7 #include <QDoubleSpinBox>
11 #include <Spline3D/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);
40 expr.add_variable(
"z", z);
42 expr.register_symbol_table();
44 setText(R
"_(x := cos(2 * pi * t);
50 void on_accepted()
override
52 this->setError(0, QString{});
53 auto txt = this->text().toStdString();
54 bool ok = expr.set_expression(txt);
57 setError(0, QString::fromStdString(expr.error()));
62 ossia::spline3d_data data;
63 for(t = 0.; t < 1.; t += m_step)
66 data.points.push_back({x, y, z});
71 data.points.push_back({x, y, z});
75 m_model, std::move(data));
78 double t{}, x{}, y{}, z{};
80 ossia::math_expression expr;
The CommandDispatcher class.
Definition: CommandDispatcher.hpp:13
Definition: ScriptEditor.hpp:21
Definition: plugins/score-plugin-spline3d/Spline3D/commands.hpp:13
Definition: d/Spline3D/GeneratorDialog.hpp:16
Definition: score-plugin-spline3d/Spline3D/Model.hpp:19
Definition: DocumentContext.hpp:18