Skip to content

Commit

Permalink
Add markerUp and markerDown generation on TRIK model (#861)
Browse files Browse the repository at this point in the history
* Add markerUp and markerDown generation on TRIK model

* Updare copyrights

Co-Authored-By: iakov <iakov@users.noreply.github.com>

Co-authored-by: iakov <iakov@users.noreply.github.com>
  • Loading branch information
IKhonakhbeeva and iakov authored Apr 14, 2020
1 parent d9f6fd7 commit e6adfc5
Show file tree
Hide file tree
Showing 13 changed files with 153 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/* Copyright 2020, CyberTech Labs Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License. */

#include "markerDownGenerator.h"

#include <generatorBase/generatorCustomizer.h>
#include "src/converters/backgroundColorConverter.h"

using namespace trik::simple;
using namespace trik::converters;
using namespace generatorBase::simple;

MarkerDownGenerator::MarkerDownGenerator(const qrRepo::RepoApi &repo
, generatorBase::GeneratorCustomizer &customizer
, const qReal::Id &id
, QObject *parent)
: BindingGenerator(repo, customizer, id
, "markerDown.t"
, { Binding::createConverting("@@COLOR@@", "Color"
, new BackgroundColorConverter(customizer.factory()->pathsToTemplates()))
// , customizer.factory()->stringPropertyConverter(id, "Color"))
}, parent)
{
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/* Copyright 2020, CyberTech Labs Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License. */

#pragma once

#include <generatorBase/simpleGenerators/bindingGenerator.h>

namespace trik {
namespace simple {

/// Generator for 'SetBackground' block.
class MarkerDownGenerator : public generatorBase::simple::BindingGenerator
{
public:
MarkerDownGenerator(const qrRepo::RepoApi &repo
, generatorBase::GeneratorCustomizer &customizer
, const qReal::Id &id
, QObject *parent);
};

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/* Copyright 2020, CyberTech Labs Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License. */

#include "markerUpGenerator.h"

#include <generatorBase/generatorCustomizer.h>
#include "src/converters/backgroundColorConverter.h"

using namespace trik::simple;
using namespace trik::converters;
using namespace generatorBase::simple;

MarkerUpGenerator::MarkerUpGenerator(const qrRepo::RepoApi &repo
, generatorBase::GeneratorCustomizer &customizer
, const qReal::Id &id
, QObject *parent)
: BindingGenerator(repo, customizer, id, "markerUp.t", QList<Binding *>(), parent)
{
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/* Copyright 2020, CyberTech Labs Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License. */

#pragma once

#include <generatorBase/simpleGenerators/bindingGenerator.h>

namespace trik {
namespace simple {

/// Generator for 'SetBackground' block.
class MarkerUpGenerator : public generatorBase::simple::BindingGenerator
{
public:
MarkerUpGenerator(const qrRepo::RepoApi &repo
, generatorBase::GeneratorCustomizer &customizer
, const qReal::Id &id
, QObject *parent);
};

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@
#include "simpleGenerators/waitPadPressGenerator.h"
#include "simpleGenerators/fileWriteGenerator.h"
#include "simpleGenerators/removeFileGenerator.h"
#include "simpleGenerators/markerDownGenerator.h"
#include "simpleGenerators/markerUpGenerator.h"
#include "parts/trikDeviceVariables.h"

using namespace trik;
Expand Down Expand Up @@ -142,6 +144,10 @@ AbstractSimpleGenerator *TrikGeneratorFactory::simpleGenerator(const qReal::Id &
return new FileWriteGenerator(mRepo, customizer, id, this);
} else if (elementType == "TrikRemoveFile") {
return new RemoveFileGenerator(mRepo, customizer, id, this);
} else if (elementType == "MarkerDown") {
return new MarkerDownGenerator(mRepo, customizer, id, this);
} else if (elementType == "MarkerUp") {
return new MarkerUpGenerator(mRepo, customizer, id, this);
}

return GeneratorFactoryBase::simpleGenerator(id, customizer);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,9 @@ HEADERS += \
$$PWD/src/simpleGenerators/fileWriteGenerator.h \
$$PWD/src/simpleGenerators/removeFileGenerator.h \
$$PWD/src/simpleGenerators/stopCameraGenerator.h \
$$PWD/src/simpleGenerators/stopVideoStreamingGenerator.h
$$PWD/src/simpleGenerators/stopVideoStreamingGenerator.h \
$$PWD/src/simpleGenerators/markerDownGenerator.h \
$$PWD/src/simpleGenerators/markerUpGenerator.h \

SOURCES += \
$$PWD/src/trikBlocksValidator.cpp \
Expand Down Expand Up @@ -123,4 +125,6 @@ SOURCES += \
$$PWD/src/simpleGenerators/fileWriteGenerator.cpp \
$$PWD/src/simpleGenerators/removeFileGenerator.cpp \
$$PWD/src/simpleGenerators/stopCameraGenerator.cpp \
$$PWD/src/simpleGenerators/stopVideoStreamingGenerator.cpp
$$PWD/src/simpleGenerators/stopVideoStreamingGenerator.cpp \
$$PWD/src/simpleGenerators/markerDownGenerator.cpp \
$$PWD/src/simpleGenerators/markerUpGenerator.cpp \
Original file line number Diff line number Diff line change
Expand Up @@ -232,5 +232,7 @@
<file>templates/videosensors/stopobjectSensor.t</file>
<file>templates/videosensors/stopVideoStreaming.t</file>
<file>templates/wait/gyroscope.t</file>
<file>templates/markerDown.t</file>
<file>templates/markerUp.t</file>
</qresource>
</RCC>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
brick.marker().down("@@COLOR@@")
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
brick.marker().up()
Original file line number Diff line number Diff line change
Expand Up @@ -237,5 +237,7 @@
<file>templates/switch/middle_switch.t</file>
<file>templates/switch/oneCase_switch.t</file>
<file>templates/wait/gyroscope.t</file>
<file>templates/markerDown.t</file>
<file>templates/markerUp.t</file>
</qresource>
</RCC>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
brick.marker().down("@@COLOR@@");
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
brick.marker().up();
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,8 @@ qReal::IdList CoreBlocksFactory::providedBlocks() const
qReal::IdList CoreBlocksFactory::blocksToDisable() const
{
qReal::IdList result;

if (!mRobotModelManager->model().name().contains("TwoD")) {
auto robotModelName = mRobotModelManager->model().name();
if (!robotModelName.contains("TwoD") && !robotModelName.contains("TrikV62")) {
result
<< id("MarkerDown")
<< id("MarkerUp");
Expand Down

0 comments on commit e6adfc5

Please sign in to comment.