PioneerGetLPSPosition::PioneerGetLPSPosition(const qrRepo::RepoApi &repo
		, generatorBase::GeneratorCustomizer &customizer
		, const qReal::Id &id
		, QObject *parent)
	: BindingGenerator(repo, customizer, id, "quadcopterCommands/getLPSPosition.t"
		, {
			Binding::createConverting(
					"@@X@@"
					, "X"
					, customizer.factory()->stringPropertyConverter(id, "X"))
			, Binding::createConverting(
					"@@Y@@"
					, "Y"
					, customizer.factory()->stringPropertyConverter(id, "Y"))
			, Binding::createConverting(
					"@@Z@@"
					, "Z"
					, customizer.factory()->stringPropertyConverter(id, "Z"))
			}
		, parent)
{
	customizer.factory()->functionBlockConverter(id, "")->convert(
			QString("%1 = 0;%2 = 0;%3 = 0;")
					.arg(repo.stringProperty(id, "X"))
					.arg(repo.stringProperty(id, "Y"))
					.arg(repo.stringProperty(id, "Z")));
}
Esempio n. 2
0
int QrsMetamodelLoader::intProperty(const qrRepo::RepoApi &repo, const Id &id
		, const QString &propertyName, int defaultValue)
{
	if (!repo.hasProperty(id, propertyName)) {
		return defaultValue;
	}

	return parseInt(repo.stringProperty(id, propertyName), id);
}
Esempio n. 3
0
bool QrsMetamodelLoader::boolProperty(const qrRepo::RepoApi &repo, const Id &id
		, const QString &propertyName, bool defaultValue)
{
	if (!repo.hasProperty(id, propertyName)) {
		return defaultValue;
	}

	return repo.stringProperty(id, propertyName) == "true";
}
Esempio n. 4
0
QString QrsMetamodelLoader::stringProperty(const qrRepo::RepoApi &repo, const Id &id
		, const QString &propertyName, const QString &defaultValue)
{
	if (!repo.hasProperty(id, propertyName)) {
		return defaultValue;
	}

	return repo.stringProperty(id, propertyName);
}
Esempio n. 5
0
QVector<int> QrsMetamodelLoader::intVectorProperty(const qrRepo::RepoApi &repo, const Id &id
		, const QString &propertyName, const QVector<int> &defaultValue)
{
	if (!repo.hasProperty(id, propertyName)) {
		return defaultValue;
	}

	const QStringList values = repo.stringProperty(id, propertyName).split(",", QString::SkipEmptyParts);
	QVector<int> result(values.size());
	for (int i = 0; i < values.size(); ++i) {
		result[i] = parseInt(values[i], id);
	}

	return result;
}
Esempio n. 6
0
void QrsMetamodelLoader::parseProperties(const qrRepo::RepoApi &repo, ElementType &element, const Id &id)
{
	const IdList children = repo.children(id);

	for (const Id &child : children) {
		if (child.type() == metamodelAttributeType && repo.isLogicalElement(id)) {
			const QString type = repo.stringProperty(child, "attributeType");
			element.addProperty(repo.name(child), type
					, stringProperty(repo, child, "defaultValue", "string")
					, stringProperty(repo, child, "displayedName")
					, stringProperty(repo, child, "description")
					, type == "reference");
		}
	}
}
PrintTextBlockGenerator::PrintTextBlockGenerator(const qrRepo::RepoApi &repo
		, GeneratorCustomizer &customizer
		, const Id &id
		, QObject *parent)
	: BindingGenerator(repo, customizer, id, "drawing/printText.t", QList<Binding *>()
			<< Binding::createConverting("@@X@@", "XCoordinateText"
					, customizer.factory()->intPropertyConverter(id, "XCoordinateText"))
			<< Binding::createConverting("@@Y@@", "YCoordinateText"
					, customizer.factory()->intPropertyConverter(id, "YCoordinateText"))
			<< (repo.property(id, "Evaluate").toBool()
					? Binding::createConverting("@@TEXT@@", "PrintText"
							, customizer.factory()->stringPropertyConverter(id, "PrintText"))
					: Binding::createStatic("@@TEXT@@"
							, utils::StringUtils::wrap(repo.stringProperty(id, "PrintText"))))
			, parent)
{
}
Esempio n. 8
0
void QrsMetamodelLoader::parseNode(const qrRepo::RepoApi &repo
		, Metamodel &metamodel, const Id &diagram, const Id &id)
{
	NodeElementType *node = new NodeElementType(metamodel);

	node->setName(validateName(repo, id));
	node->setFriendlyName(repo.stringProperty(id, "displayedName"));
	node->setDiagram(repo.name(diagram));
	node->setMouseGesture(stringProperty(repo, id, "path"));
	node->setDescription(stringProperty(repo, id, "description"));
	node->setHidden(boolProperty(repo, id, "abstract"));
	node->setResizable(boolProperty(repo, id, "isResizeable", true));
	node->setCreateChildrenFromMenu(boolProperty(repo, id, "createChildrenFromMenu"));

	parseSdfGraphics(repo, *node, id);
	parseContainerProperties(repo, *node, id);
	parseProperties(repo, *node, id);

	metamodel.addElement(*node);
}
Esempio n. 9
0
PrintTextBlockGenerator::PrintTextBlockGenerator(const qrRepo::RepoApi &repo
		, GeneratorCustomizer &customizer
		, const Id &id
		, QObject *parent)
	: BindingGenerator(repo, customizer, id, "drawing/printText.t", {
			Binding::createConverting("@@X@@", "XCoordinateText"
					, customizer.factory()->intPropertyConverter(id, "XCoordinateText"))
			, Binding::createConverting("@@Y@@", "YCoordinateText"
					, customizer.factory()->intPropertyConverter(id, "YCoordinateText"))
			, (repo.property(id, "Evaluate").toBool()
					? Binding::createConverting("@@TEXT@@", "PrintText"
							, customizer.factory()->stringPropertyConverter(id, "PrintText"))
					: Binding::createStatic("@@TEXT@@"
							, utils::StringUtils::wrap(repo.stringProperty(id, "PrintText"))))
			}, parent)
{
	// Calling virtual readTemplate() before base class constructor will cause segfault.
	addBinding(Binding::createStatic("@@REDRAW@@", repo.property(id, "Redraw").toBool()
			? readTemplate("drawing/redraw.t") : QString()));
}
Esempio n. 10
0
void QrsMetamodelLoader::parseEdge(const qrRepo::RepoApi &repo
		, Metamodel &metamodel, const Id &diagram, const Id &id)
{
	EdgeElementType *edge = new EdgeElementType(metamodel);

	edge->setName(validateName(repo, id));
	edge->setFriendlyName(repo.stringProperty(id, "displayedName"));
	edge->setDiagram(repo.name(diagram));
	edge->setDescription(stringProperty(repo, id, "description"));
	edge->setDividable(boolProperty(repo, id, "isDividable"));

	edge->setPenWidth(1);
	edge->setPenColor(Qt::black);
	edge->setPenStyle(parsePenStyle(stringProperty(repo, id, "lineType"), id));
	edge->setShapeType(parseLinkShape(stringProperty(repo, id, "shape"), id));

	const QString labelText = stringProperty(repo, id, "labelText");

	if (!labelText.isEmpty()) {
		LabelProperties label;
		const QString labelType = stringProperty(repo, id, "labelType");
		if (labelType.contains("static", Qt::CaseInsensitive)) {
			label = LabelProperties(0, 0, 0, labelText, 0);
		} else if (labelType.contains("dynamic", Qt::CaseInsensitive)) {
			label = LabelProperties(0, 0, 0, labelText, false, 0);
		} else {
			emit errorOccured(tr("Incorrect label type"), id);
		}

		label.setHard(boolProperty(repo, id, "hardLabel"));
		edge->addLabel(label);
	}

	parseAssociations(repo, *edge, id);
	parseProperties(repo, *edge, id);
	parsePorts(repo, *edge, id, "from");
	parsePorts(repo, *edge, id, "to");

	metamodel.addElement(*edge);
}
Esempio n. 11
0
DrawRectGenerator::DrawRectGenerator(const qrRepo::RepoApi &repo
		, generatorBase::GeneratorCustomizer &customizer
		, const qReal::Id &id
		, QObject *parent)
	: BindingGenerator(repo, customizer, id, (repo.stringProperty(id, "Filled") == "true")
					? "drawing/drawFilledRect.t"
					: "drawing/drawRect.t"
			, {
				Binding::createConverting("@@XCoordinateRect@@", "XCoordinateRect"
						, customizer.factory()->intPropertyConverter(id, "XCoordinateRect"))
				, Binding::createConverting("@@YCoordinateRect@@", "YCoordinateRect"
						, customizer.factory()->intPropertyConverter(id, "YCoordinateRect"))
				, Binding::createConverting("@@WidthRect@@", "WidthRect"
						, customizer.factory()->intPropertyConverter(id, "WidthRect"))
				, Binding::createConverting("@@HeightRect@@", "HeightRect"
						, customizer.factory()->intPropertyConverter(id, "HeightRect"))
			}
			, parent)
{
	addBinding(Binding::createStatic("@@REDRAW@@", repo.property(id, "Redraw").toBool()
			? readTemplate("drawing/redraw.t") : QString()));
}