Skip to content

Commit 1d5b79d

Browse files
authored
Merge branch 'master' into MinyazevR-grid-improvements
2 parents 9d29495 + 97540ad commit 1d5b79d

File tree

59 files changed

+2453
-146
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+2453
-146
lines changed

.clang-tidy

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ misc-throw-by-value-catch-by-reference,
7676
misc-unconventional-assign-operator,
7777
misc-uniqueptr-reset-release,
7878
modernize-avoid-bind,
79-
modernize-concat-nested-namespaces,
79+
#modernize-concat-nested-namespaces,
8080
modernize-deprecated-headers,
8181
modernize-deprecated-ios-base-aliases,
8282
modernize-loop-convert,
@@ -96,7 +96,7 @@ modernize-use-bool-literals,
9696
modernize-use-emplace,
9797
modernize-use-equals-default,
9898
modernize-use-equals-delete,
99-
modernize-use-nodiscard,
99+
#modernize-use-nodiscard,
100100
modernize-use-noexcept,
101101
modernize-use-nullptr,
102102
modernize-use-override,

buildScripts/github/run_tests.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,10 @@ pushd "bin" && eval "$TESTS" && popd
1919
[ -r tests_qrs.7z ] || curl -Lo tests_qrs.7z https://dl.trikset.com/edu/.solutions20200701/testing_small.7z
2020
which 7z &> /dev/null && 7z -y x tests_qrs.7z || 7za x tests_qrs.7z
2121
python3.${TRIK_PYTHON3_VERSION_MINOR} "$(dirname $(realpath ${BASH_SOURCE[0]}))"/../tests/fieldstest.py bin/2D-model testing_small
22+
23+
XML_PREPOCESSOR_TEST_DIR="$(dirname $(realpath ${BASH_SOURCE[0]}))"/../tests/xml-preprocessor-tests/
24+
XML_PREPOCESSOR_OUTPUT_FILE="$XML_PREPOCESSOR_TEST_DIR/system_library.xml"
25+
XML_PREPOCESSOR_TEST_FILE="$XML_PREPOCESSOR_TEST_DIR/system_library.qrs"
26+
XML_PREPOCESSOR_EXPECTED_FILE="$XML_PREPOCESSOR_TEST_DIR/system_library_expected.xml"
27+
TRIK_PREPROCESSOR_XML_OUTPUT="$XML_PREPOCESSOR_OUTPUT_FILE" bin/2D-model --close "$XML_PREPOCESSOR_TEST_FILE" || true
28+
diff "$XML_PREPOCESSOR_OUTPUT_FILE" "$XML_PREPOCESSOR_EXPECTED_FILE" || exit 1
6.07 KB
Binary file not shown.
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
<constraints>
2+
<timelimit value="10000"/>
3+
<event settedUpInitially="true">
4+
<condition>
5+
<timer forceDropOnTimeout="false" timeout="5000"/>
6+
</condition>
7+
<triggers>
8+
<success/>
9+
</triggers>
10+
</event>
11+
<event settedUpInitially="true">
12+
<condition>
13+
<timer forceDropOnTimeout="false" timeout="10000"/>
14+
</condition>
15+
<triggers>
16+
<setUp id="mock_id"/>
17+
<success/>
18+
</triggers>
19+
</event>
20+
<event settedUpInitially="true">
21+
<condition>
22+
<not>
23+
<inside objectId="skittle" objectPoint="all" regionId="zone1"/>
24+
</not>
25+
</condition>
26+
<triggers>
27+
<message text="Object skittle not inside zone"/>
28+
<success/>
29+
</triggers>
30+
</event>
31+
<event id="id_1" settedUpInitially="true">
32+
<condition>
33+
<not>
34+
<inside objectId="object" objectPoint="any" regionId="zone1"/>
35+
</not>
36+
</condition>
37+
<triggers>
38+
<setter name="score">
39+
<sum>
40+
<variableValue name="score"/>
41+
<variableValue name="sumVariable"/>
42+
</sum>
43+
</setter>
44+
<message text="Points scored: ${score}"/>
45+
</triggers>
46+
</event>
47+
<event id="id_2" settedUpInitially="true">
48+
<condition>
49+
<inside objectId="object" objectPoint="all" regionId="zone1"/>
50+
</condition>
51+
<triggers>
52+
<setter name="score">
53+
<sum>
54+
<variableValue name="score"/>
55+
<variableValue name="sumVariable"/>
56+
</sum>
57+
</setter>
58+
<message text="Points scored: ${score}"/>
59+
</triggers>
60+
</event>
61+
</constraints>

installer/packages/trik-studio/ru.qreal.root.trik_studio_kernel/meta/prebuild-common.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ rsync -a "$INSTALLER_ROOT"/licenses/Box2D-license*.txt "$PW
99
mkdir -p "$PWD"/../data/plugins/editors
1010
mkdir -p "$PWD"/../data/plugins/tools
1111
rsync -a "$BIN_DIR"/help "$PWD"/../data
12+
rsync -a "$BIN_DIR"/templates "$PWD"/../data
1213
rsync -a "$BIN_DIR"/images "$PWD"/../data
1314
rsync -a "$BIN_DIR"/palettes "$PWD"/../data
1415
rsync -a "$BIN_DIR"/externalToolsConfig "$PWD"/../data

installer/platform/trik-studio-linux-gnu-platform.config

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
pathToImages=./../resources/images/iconset1/
2+
pathToTemplates=./../resources/templates
23
pathToHelp=./../resources/help/
34
pathToTranslations=./../resources/translations/
45
pathToTrikRuntime=./../resources/trikRuntime/

installer/platform/trik-studio-mac-platform.config

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
pathToImages=./../Resources/images/iconset1/
2+
pathToTemplates=./../Resources/templates
23
pathToHelp=./../Resources/help/
34
pathToTranslations=./../Resources/translations/
45
pathToTrikRuntime=./../Resources/trikRuntime/

plugins/robots/common/twoDModel/include/twoDModel/engine/model/model.h

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ class InterpreterControlInterface;
3434

3535
namespace twoDModel {
3636

37+
namespace templates {
38+
class TemplatesParserApi;
39+
}
40+
3741
namespace constraints {
3842
class ConstraintsChecker;
3943
}
@@ -54,7 +58,7 @@ class TWO_D_MODEL_EXPORT Model : public QObject
5458
/// Dependency injection for the physics engine
5559
explicit Model(physics::PhysicsEngineFactory *engineFactory,
5660
QObject *parent = nullptr);
57-
~Model();
61+
~Model() override;
5862

5963
void init(qReal::ErrorReporterInterface &errorReporter
6064
, kitBase::InterpreterControlInterface &interpreterControl
@@ -81,6 +85,9 @@ class TWO_D_MODEL_EXPORT Model : public QObject
8185
QDomDocument serialize() const;
8286
void deserialize(const QDomDocument &model);
8387

88+
QHash<QString, QDomDocument> generateTemplates(const QString &path);
89+
void loadTemplates();
90+
8491
/// Add new robot model
8592
/// @param robotModel Model to be added
8693
/// @param pos Initial positon of robot model
@@ -107,6 +114,8 @@ class TWO_D_MODEL_EXPORT Model : public QObject
107114
/// @param xml blobs description in xml format
108115
void blobsChanged(const QDomDocument &xml);
109116

117+
void templatesChanged(const QHash<QString, QDomDocument> &xmls);
118+
110119
/// Emitted after new robot model added
111120
/// @param robotModel Pointer to robot model which was removed
112121
void robotAdded(twoDModel::model::RobotModel *robotModel);
@@ -121,12 +130,15 @@ private Q_SLOTS:
121130

122131
private:
123132
void initPhysics();
133+
bool parseTemplates(const QDomElement &templates);
134+
bool proccessTemplates(const QDomElement &constraintsXml);
124135

125136
QPointer<Settings> mSettings; //Has ownership
126137
QPointer<MetricCoordinateSystem> mMetricCoordinateSystem; //Has ownership
127138
WorldModel mWorldModel;
128139
Timeline mTimeline;
129140
QScopedPointer<constraints::ConstraintsChecker> mChecker;
141+
QScopedPointer<templates::TemplatesParserApi> mTemplatesParserApi;
130142
RobotModel * mRobotModel {}; //Has ownership
131143
qReal::ErrorReporterInterface *mErrorReporter; // Doesn`t take ownership.
132144
qReal::LogicalModelAssistInterface *mLogicalModel; // Doesn`t take ownership.

plugins/robots/common/twoDModel/include/twoDModel/engine/view/twoDModelWidget.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,9 @@ class TWO_D_MODEL_EXPORT TwoDModelWidget : public QWidget
8383
SensorItem *sensorItem(const kitBase::robotModel::PortInfo &port);
8484
void setSensorVisible(const kitBase::robotModel::PortInfo &port, bool isVisible);
8585

86-
void loadXmls(const QDomDocument &model, bool withUndo = false);
86+
void loadModelXmls(const QDomDocument &model, bool withUndo = false);
87+
88+
void loadTemplatesXmls();
8789

8890
/// Returns a reference to a model part of 2D model MVC architecture.
8991
model::Model &model() const;
@@ -148,9 +150,11 @@ public Q_SLOTS:
148150
private Q_SLOTS:
149151
void saveWorldModelToRepo();
150152
void saveBlobsToRepo();
153+
void saveTemplatesToRepo(const QHash<QString, QDomDocument> &templates);
151154

152155
void saveWorldModel();
153156
void loadWorldModel();
157+
void loadTemplates();
154158
void loadWorldModelWithoutRobot();
155159

156160
void onSelectionChange();

plugins/robots/common/twoDModel/src/engine/commands/loadWorldCommand.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ bool LoadWorldCommand::restoreState()
3838

3939
void LoadWorldCommand::loadWorld(const QDomDocument &world)
4040
{
41-
mWidget.loadXmls(world, true);
41+
mWidget.loadModelXmls(world, true);
4242
Q_EMIT mWidget.model().modelChanged(mWidget.generateWorldModelXml());
4343
Q_EMIT mWidget.model().blobsChanged(mWidget.generateBlobsXml());
4444
}

0 commit comments

Comments
 (0)