VariableInitGenerator::VariableInitGenerator(qrRepo::RepoApi const &repo
		, GeneratorCustomizer &customizer
		, Id const &id
		, QObject *parent)
	: BindingGenerator(repo, customizer, id, "function.t"
			, { Binding::createStaticConverting("@@BODY@@"
					, repo.property(id, "variable").toString() + "=" + repo.property(id, "value").toString()
					, customizer.factory()->functionBlockConverter(id, "value")) }
			, parent)
{
}
Exemple #2
0
SayGenerator::SayGenerator(const qrRepo::RepoApi &repo
		, generatorBase::GeneratorCustomizer &customizer
		, const qReal::Id &id
		, QObject *parent)
	: BindingGenerator(repo, customizer, id
			, "say.t"
			, { repo.property(id, "Evaluate").toBool()
					? Binding::createConverting("@@TEXT@@", "Text"
								, customizer.factory()->stringPropertyConverter(id, "Text"))
					: Binding::createStatic("@@TEXT@@", utils::StringUtils::wrap(repo.property(id, "Text").toString()))
			} , parent)
{
}
Exemple #3
0
SystemGenerator::SystemGenerator(const qrRepo::RepoApi &repo
		, generatorBase::GeneratorCustomizer &customizer
		, const qReal::Id &id
		, QObject *parent)
	: BindingGenerator(repo, customizer, id
			, repo.property(id, "Code").toBool() ? "nativeCode.t" : "system.t"
			, { repo.property(id, "Code").toBool()
					? Binding::createStatic("@@COMMAND@@"
							, utils::StringUtils::dequote(repo.property(id, "Command").toString()))
					: repo.property(id, "Evaluate").toBool()
							? Binding::createConverting("@@COMMAND@@", "Command"
									, customizer.factory()->stringPropertyConverter(id, "Command"))
							: Binding::createStatic("@@COMMAND@@"
									, utils::StringUtils::wrap(repo.property(id, "Command").toString()))
			}
			, parent)
{
}
InitCameraGenerator::InitCameraGenerator(const qrRepo::RepoApi &repo
		, generatorBase::GeneratorCustomizer &customizer
		, const qReal::Id &id
		, QObject *parent)
	: BindingGenerator(repo, customizer, id
			, "videosensors/init" + repo.property(id, "Mode").toString() + "Sensor.t"
			, {}
			, parent)
{
}
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()));
}
Exemple #6
0
ClearScreenBlockGenerator::ClearScreenBlockGenerator(const qrRepo::RepoApi &repo
        , GeneratorCustomizer &customizer
        , const Id &id
        , QObject *parent)
    : BindingGenerator(repo, customizer, id, "drawing/clearScreen.t"
    , {}
, 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()));
}
Exemple #7
0
InitCameraGenerator::InitCameraGenerator(const qrRepo::RepoApi &repo
		, generatorBase::GeneratorCustomizer &customizer
		, const qReal::Id &id
		, QObject *parent)
	: BindingGenerator(repo, customizer, id
			, "videosensors/init" + repo.property(id, "Mode").toString() + "Sensor.t"
			, { Binding::createConverting("@@DRAW@@"
						, "DrawStream", customizer.factory()->boolPropertyConverter(id, "DrawStream", false))
			}
			, parent)
{
}
SetBackgroundGenerator::SetBackgroundGenerator(const qrRepo::RepoApi &repo
		, generatorBase::GeneratorCustomizer &customizer
		, const qReal::Id &id
		, QObject *parent)
	: BindingGenerator(repo, customizer, id
			, "drawing/setBackground.t"
			, { Binding::createConverting("@@COLOR@@", "Color"
					, new BackgroundColorConverter(customizer.factory()->pathsToTemplates()))
			}, 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()));
}
Exemple #9
0
void Binding::apply(const qrRepo::RepoApi &repo
		, const Id &id, QString &data)
{
	const QString property = mProperty.isEmpty()
			? mValue
			: mProperty == "name"
					? repo.name(id)
					: repo.property(id, mProperty).toString();

	if (mConverter) {
		data.replace(mLabel, mConverter->convert(property));
	} else {
		applyMulti(property, data);
	}
}
TrikEnginesGenerator::TrikEnginesGenerator(qrRepo::RepoApi const &repo
		, generatorBase::GeneratorCustomizer &customizer
		, qReal::Id const &id
		, QString const &engineType
		, QObject *parent)
	: BindingGenerator(repo, customizer, id
			, engineType.contains("EnginesBackward") ? "engines/backward.t" : "engines/forward.t"
			, { Binding::createMultiTarget("@@PORT@@", "Ports"
						, dynamic_cast<trik::TrikGeneratorFactory *>(customizer.factory())->enginesConverter())
				, Binding::createConverting("@@POWER@@", "Power", customizer.factory()->intPropertyConverter()) }
			, parent)
{
	// AngularServo is just another block for EnginesForward, since it is controlled the same way as radial servo
	// or power motor.
	mCustomizer.factory()->engines()->registerUsageOnPorts(repo.property(id, "Ports").toString());
}
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)
{
}
Exemple #12
0
EnginesGenerator::EnginesGenerator(qrRepo::RepoApi const &repo
		, GeneratorCustomizer &customizer
		, Id const &id
		, QString const &engineType
		, QObject *parent)
	: BindingGenerator(repo, customizer, id
			, engineType.contains("EnginesBackward")
					? "engines/enginesBackward.t"
					: "engines/enginesForward.t"
			, QList<Binding *>()
					<< Binding::createMultiTarget("@@PORT@@", "Ports", customizer.factory()->enginesConverter())
					<< Binding::createConverting("@@POWER@@", "Power", customizer.factory()->intPropertyConverter())
					<< Binding::createConverting("@@BREAK_MODE@@", "Mode", customizer.factory()->breakModeConverter())
			, parent)
{
	mCustomizer.factory()->engines()->registerUsageOnPorts(repo.property(id, "Ports").toString());
}
QString QrsMetamodelLoader::validateRootNode(const qrRepo::RepoApi &repo, const Id &diagram)
{
	if (!repo.hasProperty(diagram, "nodeName")) {
		return QString();
	}

	const QString rootNode = repo.property(diagram, "nodeName").toString();
	for (const Id &child : repo.children(diagram)) {
		if (repo.name(child) == rootNode && (child.type() == metamodelNodeType || child.type() == metamodelGroupType)) {
			return rootNode;
		}
	}

	emit errorOccured(QObject::tr("Root node for diagram %1 (which is %2) does not exist!")
			.arg(repo.name(diagram)).arg(rootNode), diagram);
	return rootNode;
}
DrawPixelGenerator::DrawPixelGenerator(const qrRepo::RepoApi &repo
		, generatorBase::GeneratorCustomizer &customizer
		, const qReal::Id &id
		, QObject *parent)
	: BindingGenerator(repo, customizer, id, "drawing/drawPixel.t"
			, {
			Binding::createConverting("@@XCoordinatePix@@", "XCoordinatePix"
					, customizer.factory()->intPropertyConverter(id, "XCoordinatePix"))
			, Binding::createConverting("@@YCoordinatePix@@", "YCoordinatePix"
					, customizer.factory()->intPropertyConverter(id, "YCoordinatePix"))
			}
			, 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()));
}
Exemple #15
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()));
}