23 lines
629 B
C++
23 lines
629 B
C++
#include "param.h"
|
|
|
|
using Xybrid::NodeLib::Param;
|
|
using namespace Xybrid::Data;
|
|
|
|
ParameterPort* Param::makePort(Data::Node* node, const QString& name) {
|
|
if (port) return port;
|
|
|
|
node->inputs.try_emplace(Port::Parameter);
|
|
auto& inp = node->inputs.find(Port::Parameter)->second;
|
|
|
|
uint8_t id = 0;
|
|
auto it = inp.begin();
|
|
while (it != inp.end() && it->first == id) { ++id; ++it; } // scan for first unused id
|
|
|
|
auto n = name;
|
|
if (n.isEmpty()) n = this->name.toLower();
|
|
|
|
port = static_cast<ParameterPort*>(node->addPort(Port::Input, Port::Parameter, id).get());
|
|
port->name = n;
|
|
return port;
|
|
}
|