31 if(!f.open(QIODevice::ReadOnly))
36 auto [_, desc] = isf::parser::parse_isf_header(score::readFileAsString(f));
37 if(desc.credits.starts_with(
"Automatically converted from "))
38 desc.credits = desc.credits.substr(strlen(
"Automatically converted from "));
39 else if(desc.credits.starts_with(
"by "))
40 desc.credits = desc.credits.substr(strlen(
"by "));
41 if(!desc.credits.empty())
42 base.author = QString::fromStdString(desc.credits);
43 if(!desc.description.empty())
44 base.description = QString::fromStdString(desc.description);
45 for(
auto& cat : desc.categories)
46 base.tags.push_back(QString::fromStdString(cat));
56 static void setupISFModelPorts(
57 T& self,
const isf::descriptor& desc,
58 const ossia::flat_map<QString, ossia::value>& previous_values)
78 const ossia::flat_map<QString, ossia::value>& previous_values;
79 const isf::input& input;
85 auto nm = QString::fromStdString(input.name);
89 self.m_inlets.push_back(port);
90 if(
auto it = previous_values.find(nm);
91 it != previous_values.end()
92 && it->second.get_type() == ossia::val_type::FLOAT)
93 port->setValue(it->second);
95 self.controlAdded(port->id());
101 auto nm = QString::fromStdString(input.name);
103 std::vector<std::pair<QString, ossia::value>> alternatives;
104 if(v.labels.size() == v.values.size())
107 for(std::size_t value_idx = 0; value_idx < v.values.size(); value_idx++)
109 auto& val = v.values[value_idx];
110 if(
auto int_ptr = ossia::get_if<int64_t>(&val))
112 alternatives.emplace_back(
113 QString::fromStdString(v.labels[value_idx]),
int(*int_ptr));
115 else if(
auto dbl_ptr = ossia::get_if<double>(&val))
117 alternatives.emplace_back(
118 QString::fromStdString(v.labels[value_idx]),
int(*dbl_ptr));
122 alternatives.emplace_back(
123 QString::fromStdString(v.labels[value_idx]),
int(value_idx));
129 for(std::size_t value_idx = 0; value_idx < v.values.size(); value_idx++)
131 auto& val = v.values[value_idx];
132 if(
auto int_ptr = ossia::get_if<int64_t>(&val))
134 alternatives.emplace_back(QString::number(*int_ptr),
int(*int_ptr));
136 else if(
auto dbl_ptr = ossia::get_if<double>(&val))
138 alternatives.emplace_back(QString::number(*dbl_ptr),
int(*dbl_ptr));
140 else if(
auto str_ptr = ossia::get_if<std::string>(&val))
142 alternatives.emplace_back(
143 QString::fromStdString(*str_ptr),
int(value_idx));
148 if(alternatives.empty())
150 alternatives.emplace_back(
"0", 0);
151 alternatives.emplace_back(
"1", 1);
152 alternatives.emplace_back(
"2", 2);
158 if(
auto it = previous_values.find(nm);
159 it != previous_values.end()
160 && it->second.get_type() == port->value().get_type())
161 port->setValue(it->second);
163 self.m_inlets.push_back(port);
164 self.controlAdded(port->id());
170 auto nm = QString::fromStdString(input.name);
173 self.m_inlets.push_back(port);
174 self.controlAdded(port->id());
180 auto nm = QString::fromStdString(input.name);
183 if(
auto it = previous_values.find(nm);
184 it != previous_values.end()
185 && it->second.get_type() == port->value().get_type())
186 port->setValue(it->second);
188 self.m_inlets.push_back(port);
189 self.controlAdded(port->id());
195 auto nm = QString::fromStdString(input.name);
196 ossia::vec2f min{-100., -100.};
197 ossia::vec2f max{100., 100.};
198 ossia::vec2f init{0.0, 0.0};
200 std::copy_n(v.def->begin(), 2, init.begin());
202 std::copy_n(v.min->begin(), 2, min.begin());
204 std::copy_n(v.max->begin(), 2, max.begin());
208 auto& ctx = score::IDocument::documentContext(self);
209 auto& device_plug = ctx.template plugin<Explorer::DeviceDocumentPlugin>();
211 QString firstWindowDeviceName;
212 for(
auto dev : list.devices())
214 if(
auto win = qobject_cast<WindowDevice*>(dev))
216 firstWindowDeviceName = win->name();
221 if(!firstWindowDeviceName.isEmpty())
223 if(nm.contains(
"iMouse"))
227 else if(nm.contains(
"mouse", Qt::CaseInsensitive))
233 if(
auto it = previous_values.find(nm);
234 it != previous_values.end()
235 && it->second.get_type() == port->value().get_type())
236 port->setValue(it->second);
238 self.m_inlets.push_back(port);
239 self.controlAdded(port->id());
245 auto nm = QString::fromStdString(input.name);
246 ossia::vec3f min{-100., -100., -100.};
247 ossia::vec3f max{100., 100., 100.};
248 ossia::vec3f init{0., 0., 0.};
250 std::copy_n(v.def->begin(), 3, init.begin());
252 std::copy_n(v.min->begin(), 3, min.begin());
254 std::copy_n(v.max->begin(), 3, max.begin());
258 if(
auto it = previous_values.find(nm);
259 it != previous_values.end()
260 && it->second.get_type() == port->value().get_type())
261 port->setValue(it->second);
263 self.m_inlets.push_back(port);
264 self.controlAdded(port->id());
270 auto nm = QString::fromStdString(input.name);
271 ossia::vec4f init{0.5, 0.5, 0.5, 1.};
274 std::copy_n(v.def->begin(), 4, init.begin());
279 if(
auto it = previous_values.find(nm);
280 it != previous_values.end()
281 && it->second.get_type() == port->value().get_type())
282 port->setValue(it->second);
284 self.m_inlets.push_back(port);
285 self.controlAdded(port->id());
290 auto port =
new Gfx::TextureInlet(
293 self.m_inlets.push_back(port);
300 self.m_inlets.push_back(port);
307 self.m_inlets.push_back(port);
314 self.m_inlets.push_back(port);
319 Process::Inlet* operator()(
const storage_input& v) {
return nullptr; }
320 Process::Inlet* operator()(
const texture_input& v) {
return nullptr; }
321 Process::Inlet* operator()(
const csf_image_input& v) {
return nullptr; }
324 for(
const isf::input& input : desc.inputs)
326 ossia::visit(input_vis{previous_values, input, i, self}, input.data);