Пример #1
0
QString ConstraintsChecker::portName(const QString &robotId
		, model::RobotModel * const robot, const kitBase::robotModel::PortInfo &port) const
{
	// We wish to know would be there a collision if someone writes "A1" or not.
	int portsWithSuchName = 0;
	for (kitBase::robotModel::PortInfo &otherPort : robot->info().availablePorts()) {
		if (port.name() == otherPort.name()) {
			++portsWithSuchName;
		}
	}

	// Making user write "robot1.DisplayPort_out.ellipses" or "robot1.MarkerPort_out" is non-humanistic.
	// So letting him write "robot1.display.ellipses" or "robot1.marker".
	QRegExp portRegExp("^(\\w+)Port$");
	const QString readablePortName = portRegExp.exactMatch(port.name())
			? utils::StringUtils::lowercaseFirstLetter(portRegExp.cap(1))
			: port.name();

	return portsWithSuchName > 1
			// If collision in name exists then user must specify what port exactly he wishes to process.
			? QString("%1.%2_%3").arg(robotId, readablePortName
					, port.direction() == kitBase::robotModel::input ? "in" : "out")
			: QString("%1.%2").arg(robotId, readablePortName);
}
Пример #2
0
QString ConstraintsChecker::portName(const QString &robotId, const kitBase::robotModel::PortInfo &port) const
{
	return QString("%1.%2_%3").arg(robotId, port.name()
			, port.direction() == kitBase::robotModel::input ? "in" : "out");
}