Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge branch 'master' of https://github.com/qreal/qreal

Conflicts:
	qrgui/mainwindow/mainWindow.cpp
  • Loading branch information...
commit f6fcc41c9ead61a4e7ff6a6b1296145ba563e613 2 parents ae3b18b + b1cd9e8
@terrwwww terrwwww authored
Showing with 5,007 additions and 1,720 deletions.
  1. +7 −0 plugins/ains.pro
  2. +5 −0 plugins/ains/ains.pro
  3. BIN  plugins/ains/generators/ains_ru.qm
  4. +12 −0 plugins/ains/generators/ains_ru.ts
  5. +166 −0 plugins/ains/generators/databaseSchemeGenerator/databaseSchemeGenerator.cpp
  6. +30 −0 plugins/ains/generators/databaseSchemeGenerator/databaseSchemeGenerator.h
  7. +1 −1  plugins/metaEditor/editor/metaEditor.xml
  8. +5 −0 plugins/robots.pro
  9. BIN  plugins/robots/editor/doc/html/pics/programming-linkers-menu.png
  10. BIN  plugins/robots/editor/doc/html/pics/programming-linkers.png
  11. BIN  plugins/robots/editor/doc/html/pics/robot-setup-connection-successful.png
  12. BIN  plugins/robots/editor/doc/html/pics/robot-setup-select-connection-type.png
  13. +21 −3 plugins/robots/editor/doc/html/programming.html
  14. +35 −0 plugins/robots/editor/doc/html/robot-setup.html
  15. BIN  plugins/robots/editor/doc/qreal-robots.qch
  16. BIN  plugins/robots/editor/doc/qreal-robots.qhc
  17. +10 −10 plugins/robots/editor/generated/robotsMetamodel.xml
  18. +9 −9 plugins/robots/robotsInterpreter/details/autoconfigurer.cpp
  19. +10 −0 plugins/robots/robotsInterpreter/details/d2RobotModel/colorFieldItem.cpp
  20. +28 −0 plugins/robots/robotsInterpreter/details/d2RobotModel/colorFieldItem.h
  21. +357 −212 plugins/robots/robotsInterpreter/details/d2RobotModel/d2Form.ui
  22. +8 −4 plugins/robots/robotsInterpreter/details/d2RobotModel/d2ModelScene.cpp
  23. +3 −2 plugins/robots/robotsInterpreter/details/d2RobotModel/d2ModelScene.h
  24. +322 −43 plugins/robots/robotsInterpreter/details/d2RobotModel/d2ModelWidget.cpp
  25. +28 −1 plugins/robots/robotsInterpreter/details/d2RobotModel/d2ModelWidget.h
  26. +106 −11 plugins/robots/robotsInterpreter/details/d2RobotModel/d2RobotModel.cpp
  27. +23 −0 plugins/robots/robotsInterpreter/details/d2RobotModel/d2RobotModel.h
  28. +109 −0 plugins/robots/robotsInterpreter/details/d2RobotModel/lineItem.cpp
  29. +45 −0 plugins/robots/robotsInterpreter/details/d2RobotModel/lineItem.h
  30. +102 −32 plugins/robots/robotsInterpreter/details/d2RobotModel/robotItem.cpp
  31. +29 −8 plugins/robots/robotsInterpreter/details/d2RobotModel/robotItem.h
  32. +3 −0  plugins/robots/robotsInterpreter/details/d2RobotModel/robotModelInterface.h
  33. +179 −28 plugins/robots/robotsInterpreter/details/d2RobotModel/rotater.cpp
  34. +29 −6 plugins/robots/robotsInterpreter/details/d2RobotModel/rotater.h
  35. +107 −22 plugins/robots/robotsInterpreter/details/d2RobotModel/sensorItem.cpp
  36. +28 −9 plugins/robots/robotsInterpreter/details/d2RobotModel/sensorItem.h
  37. +17 −10 plugins/robots/robotsInterpreter/details/d2RobotModel/sonarSensorItem.cpp
  38. +4 −2 plugins/robots/robotsInterpreter/details/d2RobotModel/sonarSensorItem.h
  39. +124 −0 plugins/robots/robotsInterpreter/details/d2RobotModel/stylusItem.cpp
  40. +51 −0 plugins/robots/robotsInterpreter/details/d2RobotModel/stylusItem.h
  41. +74 −0 plugins/robots/robotsInterpreter/details/d2RobotModel/wallItem.cpp
  42. +43 −0 plugins/robots/robotsInterpreter/details/d2RobotModel/wallItem.h
  43. +59 −34 plugins/robots/robotsInterpreter/details/d2RobotModel/worldModel.cpp
  44. +13 −7 plugins/robots/robotsInterpreter/details/d2RobotModel/worldModel.h
  45. +9 −18 plugins/robots/robotsInterpreter/details/robotImplementations/abstractRobotModelImplementation.cpp
  46. +8 −5 plugins/robots/robotsInterpreter/details/robotImplementations/abstractRobotModelImplementation.h
  47. +22 −9 plugins/robots/robotsInterpreter/details/robotImplementations/nullRobotModelImplementation.cpp
  48. +2 −1  plugins/robots/robotsInterpreter/details/robotImplementations/nullRobotModelImplementation.h
  49. +24 −22 plugins/robots/robotsInterpreter/details/robotImplementations/realRobotModelImplementation.cpp
  50. +4 −1 plugins/robots/robotsInterpreter/details/robotImplementations/realRobotModelImplementation.h
  51. +18 −3 ...obots/robotsInterpreter/details/robotImplementations/sensorImplementations/abstractSensorImplementation.cpp
  52. +7 −2 .../robots/robotsInterpreter/details/robotImplementations/sensorImplementations/abstractSensorImplementation.h
  53. +16 −5 ...robotsInterpreter/details/robotImplementations/sensorImplementations/bluetoothColorSensorImplementation.cpp
  54. +4 −1 ...s/robotsInterpreter/details/robotImplementations/sensorImplementations/bluetoothColorSensorImplementation.h
  55. +5 −4 ...bots/robotsInterpreter/details/robotImplementations/sensorImplementations/bluetoothSensorImplementation.cpp
  56. +4 −4 ...robots/robotsInterpreter/details/robotImplementations/sensorImplementations/bluetoothSensorImplementation.h
  57. +9 −1 ...robotsInterpreter/details/robotImplementations/sensorImplementations/bluetoothSonarSensorImplementation.cpp
  58. +9 −1 ...robotsInterpreter/details/robotImplementations/sensorImplementations/bluetoothTouchSensorImplementation.cpp
  59. +2 −2 ...bots/robotsInterpreter/details/robotImplementations/sensorImplementations/nullColorSensorImplementation.cpp
  60. +1 −1  ...robots/robotsInterpreter/details/robotImplementations/sensorImplementations/nullColorSensorImplementation.h
  61. +7 −2 ...ns/robots/robotsInterpreter/details/robotImplementations/sensorImplementations/nullSensorImplementation.cpp
  62. +2 −1  plugins/robots/robotsInterpreter/details/robotImplementations/sensorImplementations/nullSensorImplementation.h
  63. +1 −1  ...bots/robotsInterpreter/details/robotImplementations/sensorImplementations/nullSonarSensorImplementation.cpp
  64. +2 −0  ...robots/robotsInterpreter/details/robotImplementations/sensorImplementations/nullSonarSensorImplementation.h
  65. +1 −1  ...bots/robotsInterpreter/details/robotImplementations/sensorImplementations/nullTouchSensorImplementation.cpp
  66. +2 −2 ...ts/robotsInterpreter/details/robotImplementations/sensorImplementations/unrealColorSensorImplementation.cpp
  67. +1 −1  ...bots/robotsInterpreter/details/robotImplementations/sensorImplementations/unrealColorSensorImplementation.h
  68. +3 −2 ...robots/robotsInterpreter/details/robotImplementations/sensorImplementations/unrealEncoderImplementation.cpp
  69. +4 −3 .../robots/robotsInterpreter/details/robotImplementations/sensorImplementations/unrealSensorImplementation.cpp
  70. +3 −2 ...ns/robots/robotsInterpreter/details/robotImplementations/sensorImplementations/unrealSensorImplementation.h
  71. +1 −1  ...ts/robotsInterpreter/details/robotImplementations/sensorImplementations/unrealSonarSensorImplementation.cpp
  72. +1 −1  ...ts/robotsInterpreter/details/robotImplementations/sensorImplementations/unrealTouchSensorImplementation.cpp
  73. +94 −0 plugins/robots/robotsInterpreter/details/robotImplementations/sensorsConfigurer.cpp
  74. +47 −0 plugins/robots/robotsInterpreter/details/robotImplementations/sensorsConfigurer.h
  75. +24 −8 plugins/robots/robotsInterpreter/details/robotImplementations/unrealRobotModelImplementation.cpp
  76. +2 −1  plugins/robots/robotsInterpreter/details/robotImplementations/unrealRobotModelImplementation.h
  77. +5 −9 plugins/robots/robotsInterpreter/details/robotParts/robotModel.cpp
  78. +0 −1  plugins/robots/robotsInterpreter/details/robotParts/robotModel.h
  79. +4 −3 plugins/robots/robotsInterpreter/details/robotsBlockParser.cpp
  80. +2 −2 plugins/robots/robotsInterpreter/details/robotsBlockParser.h
  81. BIN  plugins/robots/robotsInterpreter/icons/wall.png
  82. +15 −1 plugins/robots/robotsInterpreter/interpreter.cpp
  83. +3 −1 plugins/robots/robotsInterpreter/interpreter.h
  84. +4 −4 plugins/robots/robotsInterpreter/robotSettingsPage.ui
  85. +10 −0 plugins/robots/robotsInterpreter/robotsInterpreter.pro
  86. +1 −0  plugins/robots/robotsInterpreter/robotsInterpreter.qrc
  87. BIN  plugins/robots/robotsInterpreter/robotsInterpreter_ru.qm
  88. +129 −51 plugins/robots/robotsInterpreter/robotsInterpreter_ru.ts
  89. +7 −3 plugins/robots/robotsInterpreter/robotsPlugin.cpp
  90. +1 −0  plugins/robots/robotsInterpreter/robotsPlugin.h
  91. +6 −6 plugins/robots/robotsInterpreter/watchListWindow.cpp
  92. +3 −3 plugins/robots/robotsInterpreter/watchListWindow.h
  93. +39 −0 qreal.pri
  94. +3 −0  qrealAins.pro
  95. +3 −0  qrealRobots.pro
  96. +1 −0  qrgui/editorPluginInterface/editorInterface.h
  97. +11 −6 qrgui/generators/nxtOSEK/nxtOSEKRobotGenerator.cpp
  98. +1 −0  qrgui/interpreters/visualDebugger/blockParser.cpp
  99. +1 −1  qrgui/interpreters/visualDebugger/blockParser.h
  100. +107 −53 qrgui/mainwindow/mainWindow.cpp
  101. +3 −2 qrgui/mainwindow/mainWindow.h
  102. +4 −14 qrgui/mainwindow/shapeEdit/ellipse.cpp
  103. +4 −0 qrgui/mainwindow/shapeEdit/ellipse.h
  104. +7 −14 qrgui/mainwindow/shapeEdit/image.cpp
  105. +2 −0  qrgui/mainwindow/shapeEdit/image.h
  106. +4 −313 qrgui/mainwindow/shapeEdit/item.cpp
  107. +6 −58 qrgui/mainwindow/shapeEdit/item.h
  108. +14 −39 qrgui/mainwindow/shapeEdit/line.cpp
  109. +5 −1 qrgui/mainwindow/shapeEdit/line.h
  110. +14 −19 qrgui/mainwindow/shapeEdit/pointPort.cpp
  111. +3 −1 qrgui/mainwindow/shapeEdit/pointPort.h
  112. +4 −14 qrgui/mainwindow/shapeEdit/rectangle.cpp
  113. +3 −0  qrgui/mainwindow/shapeEdit/rectangle.h
  114. +28 −164 qrgui/mainwindow/shapeEdit/scene.cpp
  115. +11 −35 qrgui/mainwindow/shapeEdit/scene.h
  116. +122 −15 qrgui/mainwindow/shapeEdit/shapeEdit.cpp
  117. +19 −2 qrgui/mainwindow/shapeEdit/shapeEdit.h
  118. +85 −104 qrgui/mainwindow/shapeEdit/shapeEdit.ui
  119. +22 −52 qrgui/mainwindow/shapeEdit/stylus.cpp
  120. +8 −6 qrgui/mainwindow/shapeEdit/stylus.h
  121. +1 −1  qrgui/mainwindow/shapeEdit/xmlLoader.cpp
  122. +54 −0 qrgui/pluginManager/editorManager.cpp
  123. +5 −0 qrgui/pluginManager/editorManager.h
  124. +26 −23 qrgui/toolPluginInterface/toolPluginInterface.h
  125. +4 −0 qrgui/umllib/edgeElement.cpp
  126. +6 −6 qrgui/umllib/embedded/linkers/embeddedLinker.cpp
  127. +29 −18 qrgui/view/editorViewScene.cpp
  128. +9 −8 qrrepo/private/client.cpp
  129. +3 −4 qrrepo/private/client.h
  130. +119 −0 qrrepo/private/folderCompressor.cpp
  131. +26 −0 qrrepo/private/folderCompressor.h
  132. +4 −4 qrrepo/private/repoApi.cpp
  133. +39 −9 qrrepo/private/serializer.cpp
  134. +4 −1 qrrepo/private/serializer.h
  135. +17 −2 qrrepo/qrrepo.pro
  136. +1 −1  qrrepo/repoApi.h
  137. +1 −0  qrutils/expressionsParser/expressionsParser.cpp
  138. +8 −8 qrutils/expressionsParser/expressionsParser.h
  139. +7 −0 qrutils/expressionsParser/expressionsParser.pri
  140. +38 −18 qrutils/expressionsParser/number.cpp
  141. +33 −31 qrutils/expressionsParser/number.h
  142. +353 −0 qrutils/graphicsUtils/abstractItem.cpp
  143. +91 −0 qrutils/graphicsUtils/abstractItem.h
  144. +34 −0 qrutils/graphicsUtils/abstractItemView.cpp
  145. +27 −0 qrutils/graphicsUtils/abstractItemView.h
  146. +238 −0 qrutils/graphicsUtils/abstractScene.cpp
  147. +70 −0 qrutils/graphicsUtils/abstractScene.h
  148. +33 −0 qrutils/graphicsUtils/colorlisteditor.cpp
  149. +26 −0 qrutils/graphicsUtils/colorlisteditor.h
  150. +21 −0 qrutils/graphicsUtils/graphicsUtils.pri
  151. +74 −0 qrutils/graphicsUtils/lineImpl.cpp
  152. +24 −0 qrutils/graphicsUtils/lineImpl.h
  153. +22 −0 qrutils/graphicsUtils/pointImpl.cpp
  154. +17 −0 qrutils/graphicsUtils/pointImpl.h
  155. +57 −0 qrutils/graphicsUtils/rectangleImpl.cpp
  156. +20 −0 qrutils/graphicsUtils/rectangleImpl.h
  157. +8 −0 qrutils/graphicsUtils/rotateInterface.cpp
  158. +21 −0 qrutils/graphicsUtils/rotateInterface.h
  159. +103 −0 qrutils/graphicsUtils/stylusImpl.cpp
  160. +31 −0 qrutils/graphicsUtils/stylusImpl.h
  161. +14 −14 qrutils/outFile.h
  162. +8 −11 qrutils/qrutils.pro
  163. +4 −4 qrutils/xmlUtils.h
  164. +11 −0 qrxc/xmlCompiler.cpp
  165. +1 −0  qrxc/xmlCompiler.h
  166. BIN  umlDocumentation/QReal - robots.vpp
View
7 plugins/ains.pro
@@ -0,0 +1,7 @@
+TEMPLATE = subdirs
+
+SUBDIRS = \
+ metaEditor/metaEditor.pro \
+ ains/editors/ainsEditor/ainsEditor.pro \
+ ains/editors/databaseEditor/databaseEditor.pro \
+ ains/generators/generators.pro \
View
5 plugins/ains/ains.pro
@@ -0,0 +1,5 @@
+TEMPLATE = subdirs
+
+SUBDIRS = \
+ editors \
+ generators \
View
BIN  plugins/ains/generators/ains_ru.qm
Binary file not shown
View
12 plugins/ains/generators/ains_ru.ts
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE TS>
+<TS version="2.0" language="ru_RU">
+<context>
+ <name>QObject</name>
+ <message>
+ <location filename="generators.cpp" line="34"/>
+ <source>generate Database Scheme</source>
+ <translation>Сгенерировать схему БД</translation>
+ </message>
+</context>
+</TS>
View
166 plugins/ains/generators/databaseSchemeGenerator/databaseSchemeGenerator.cpp
@@ -0,0 +1,166 @@
+#include "databaseSchemeGenerator.h"
+
+#include "../../../../qrkernel/exception/exception.h"
+
+using namespace qReal;
+using namespace utils;
+
+DatabaseEditorSchemeGenerator::DatabaseEditorSchemeGenerator(const LogicalModelAssistInterface &api, ErrorReporterInterface &errorReporter)
+: mApi(api)
+, mErrorReporter(errorReporter)
+{
+}
+
+QHash<Id, QPair<QString, QString> > DatabaseEditorSchemeGenerator::modelList()
+{
+ Id repoId = Id::rootId();
+ IdList models = mApi.children(repoId);
+ QHash<Id, QPair<QString, QString> > currentModelList;
+
+ foreach (Id modelId, models) {
+ QString const elementType = mApi.logicalRepoApi().typeName(modelId);
+ if (elementType == "DatabaseDiagram" && mApi.isLogicalId(modelId)) {
+ QString directoryName = mApi.logicalRepoApi().stringProperty(modelId, "saveToTheDirectory");
+ QString fileName = mApi.logicalRepoApi().stringProperty(modelId, "filename");
+ QPair<QString, QString> fileAttributes;
+ if (directoryName.isEmpty() || fileName.isEmpty()) {
+ mErrorReporter.addError(QObject::tr("no directory or filename"), modelId);
+ return QHash<Id, QPair<QString, QString> >();
+ }
+ fileAttributes.first = directoryName;
+ fileAttributes.second = fileName;
+ currentModelList.insert(modelId,fileAttributes);
+ }
+ }
+
+ return currentModelList;
+}
+
+ErrorReporterInterface& DatabaseEditorSchemeGenerator::generateDatabaseScheme(const Id &modelId, const QString &pathToFile)
+{
+ IdList tableList = mApi.children(modelId);
+ try {
+ OutFile sqlFile(pathToFile + ".sql");
+ foreach (Id tableId, tableList) {
+ QString const tableType = mApi.logicalRepoApi().typeName(tableId);
+ if (tableType == "Table" && mApi.isLogicalId(tableId)) {
+ QString tableName = mApi.logicalRepoApi().stringProperty(tableId, "name");
+ sqlFile() << QString("CREATE TABLE %1\n").arg(tableName);
+ processingColumns(tableId, sqlFile);
+ sqlFile() <<"\n\n";
+ }
+ }
+ return mErrorReporter;
+ }
+ catch (qReal::Exception) {
+ mErrorReporter.addCritical(QObject::tr("incorrect file path"));
+ return mErrorReporter;
+ }
+}
+
+void DatabaseEditorSchemeGenerator::processingColumns(const Id &tableId, utils::OutFile &outFile)
+{
+ IdList columns = mApi.children(tableId);
+ outFile() << "(\n";
+ outFile.incIndent();
+ bool start = true;
+ foreach (Id id, columns) {
+ if (!start) {
+ outFile.decIndent();
+ outFile() << ",\n";
+ outFile.incIndent();
+ }
+ start = false;
+ QString name = mApi.logicalRepoApi().stringProperty(id, "name");
+ if (name == "") {
+ mErrorReporter.addError("no name of the element", id);
+ return;
+ }
+ QString isPrimaryKey = mApi.logicalRepoApi().stringProperty(id, "is Primary Key");
+ QString type = columnType(id);
+ outFile() << QString("%1 %2").arg(name, type);
+ if (isPrimaryKey == "true") {
+ outFile() << " primary key";
+ }
+ }
+ addForeignKeys(tableId, outFile);
+ outFile() << "\n";
+ outFile.decIndent();
+ outFile() << ");";
+}
+
+void DatabaseEditorSchemeGenerator::addForeignKeys(const Id &tableId, utils::OutFile &outFile)
+{
+ IdList foreignKeys = mApi.logicalRepoApi().outgoingLinks(tableId);
+
+ foreach (Id id, foreignKeys) {
+ outFile() << ",\n";
+ if (mApi.logicalRepoApi().typeName(id) == "Connection") {
+ QString foreignKeyName = mApi.logicalRepoApi().stringProperty(id, "Foreign Key");
+ if (foreignKeyName == "") {
+ mErrorReporter.addError("no name of foreign key", id);
+ return;
+ }
+ Id const connectedId = mApi.logicalRepoApi().to(id);
+ QString const type = mApi.logicalRepoApi().typeName(connectedId);
+ if (isColumn(type)) {
+ Id columnParentId = mApi.logicalRepoApi().parent(connectedId);
+ if (mApi.logicalRepoApi().typeName(columnParentId) == "Table")
+ outFile() << QString("%1 %4 references %2(%3)").arg(foreignKeyName, mApi.logicalRepoApi().name(columnParentId), mApi.logicalRepoApi().name(connectedId), columnType(connectedId));
+ }
+ }
+ }
+}
+
+bool DatabaseEditorSchemeGenerator::isColumn(const QString &type)
+{
+ return ((type == "ColumnString") || (type == "ColumnNumber") || (type == "ColumnLogical") || (type == "ColumnDate") || (type == "ColumnInterval"));
+}
+
+const QString DatabaseEditorSchemeGenerator::columnType(const Id &id)
+{
+ QString const columnType = mApi.logicalRepoApi().typeName(id);
+ QString specificColumnType;
+ if (mApi.isLogicalId(id)) {
+ if (columnType == "ColumnString") {
+ QString type = mApi.logicalRepoApi().stringProperty(id, "StringTypeProperty");
+ QString maxtypeLength = mApi.logicalRepoApi().stringProperty(id, "maxtypeLength");
+ if (maxtypeLength == "")
+ specificColumnType = type;
+ else
+ specificColumnType = QString("%1(%2)").arg(type, maxtypeLength);
+ }
+ else if (columnType == "ColumnNumber") {
+ QString type = mApi.logicalRepoApi().stringProperty(id, "NumTypeProperty");
+ QString numberOfSigns = mApi.logicalRepoApi().stringProperty(id, "numberOfSigns");
+ QString numberOfSignAfterPoint = mApi.logicalRepoApi().stringProperty(id, "numberOfSignAfterPoint");
+ specificColumnType = type;
+ if (type == "DECIMAL") {
+ if (numberOfSignAfterPoint != "0")
+ specificColumnType += QString("(%1, %2)").arg(numberOfSigns, numberOfSignAfterPoint);
+ }
+ }
+ else if (columnType == "ColumnLogical") {
+ QString defaultValue = mApi.logicalRepoApi().stringProperty(id, "DefaultValue");
+ specificColumnType = QString("boolean default '%1'").arg(defaultValue);
+ }
+ else if (columnType == "ColumnDate") {
+ QString type = mApi.logicalRepoApi().stringProperty(id, "TypeProperty");
+ if (type == "") {
+ mErrorReporter.addError("no type of the element", id);
+ return "";
+ }
+ specificColumnType = type;
+ }
+ else if (columnType == "ColumnInterval") {
+ QString type = mApi.logicalRepoApi().stringProperty(id, "IntervalProperty");
+ if (type == "") {
+ mErrorReporter.addError("no type of the element", id);
+ return "";
+ }
+ specificColumnType = type;
+ }
+ }
+ return specificColumnType;
+}
+
View
30 plugins/ains/generators/databaseSchemeGenerator/databaseSchemeGenerator.h
@@ -0,0 +1,30 @@
+#pragma once
+
+#include <QtCore/QString>
+#include <QHash>
+
+#include "../../../../qrkernel/ids.h"
+#include "../../../../qrutils/outFile.h"
+#include "../../../../qrgui/mainwindow/errorReporter.h"
+#include "../../../../qrrepo/logicalRepoApi.h"
+
+namespace qReal {
+
+class DatabaseEditorSchemeGenerator
+{
+public:
+ explicit DatabaseEditorSchemeGenerator(LogicalModelAssistInterface const &api, ErrorReporterInterface& errorReporter);
+ ErrorReporterInterface& generateDatabaseScheme(Id const &modelId, QString const &pathToFile);
+ QHash<Id, QPair<QString, QString> > modelList();
+
+private:
+ LogicalModelAssistInterface const &mApi;
+ ErrorReporterInterface& mErrorReporter;
+ void processingColumns(Id const &tableId, utils::OutFile &outFile);
+ void addForeignKeys(Id const &tableId, utils::OutFile &outFile);
+ bool isColumn(QString const &type);
+ QString const columnType(Id const &id);
+};
+}
+
+
View
2  plugins/metaEditor/editor/metaEditor.xml
@@ -176,7 +176,7 @@
</properties>
<container>
<contains type="MetaEditor::MetaEntity Attribute"/>
- <contains type="MetaEditor::MetaEntityConnetction"/>
+ <contains type="MetaEditor::MetaEntityConnection"/>
<contains type="MetaEditor::MetaEntityUsage"/>
<contains type="MetaEditor::Inheritance"/>
<contains type="MetaEditor::MetaEntityPossibleEdge"/>
View
5 plugins/robots.pro
@@ -0,0 +1,5 @@
+TEMPLATE = subdirs
+
+SUBDIRS = \
+ metaEditor/metaEditor.pro \
+ robots/robots.pro \
View
BIN  plugins/robots/editor/doc/html/pics/programming-linkers-menu.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  plugins/robots/editor/doc/html/pics/programming-linkers.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  plugins/robots/editor/doc/html/pics/robot-setup-connection-successful.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  plugins/robots/editor/doc/html/pics/robot-setup-select-connection-type.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
24 plugins/robots/editor/doc/html/programming.html
@@ -206,14 +206,32 @@
<br/><br/>
-<!--
+
+<div>
+<i>Третий подход</i> — использование встроенных линкеров, т.е. цветных кружков, размещающихся при выделении элементов на диаграмме чуть выше соответствующей иконки.
+</div>
+
+<br/><br/>
+
+<center><img src="pics/programming-linkers.png" alt="Создание связи с помощью линкеров"></center>
+
+<br/><br/>
+
+<div>
+При нажатии на этот кружок и движении мыши с зажатой левой клавишей, из элемента начинает вытягиваться связь. Если "бросить" эту связь на существующем элементе, произойдет соединение данных элементов. Если же отпустить левую клавишу мыши, когда курсор находится на пустом участке диаграммы, то появится следующее меню:
+</div>
+
+<center><img src="pics/programming-linkers-menu.png" alt="Меню встроенных линкеров"></center>
+
+<br/><br/>
+
<div>
-<i>Третий подход</i> — линкеры, но они у меня почему-то не работаэ, поэтому скриншотов не будет.
+При выборе пункта меню "Удалить" созданная ассоциация удаляется, при выборе пункта "Очистить" связь остается на диаграмме и меню закрывается. При наведении на пункт меню "Создать новый элемент" появляется новое меню, в котором перечислены все возможные для создания элементы. При выборе одного из этих пунктов на диаграмме создастся соответствующий элемент и присоединится к текущему связью.
</div>
--->
<br/><br/>
+
<div>
Связи в QReal:Robots могут быть ломаными линиям. Для того, чтобы добавить новую точку излома, нужно навести курсор мыши на точку линии связи, где хочется сделать излом, нажать левой кнопкой мыши и потянуть появившийся серый маркер:
</div>
View
35 plugins/robots/editor/doc/html/robot-setup.html
@@ -10,6 +10,41 @@
<h3>Подключение робота в QReal:Robots</h3>
+<h4>Подключение по USB</h4>
+
+Для управления роботом прямыми командами по USB и для загрузки программ на робот потребуются драйвера из поставки конструктора. Скачать их отдельно можно с сайта Lego:
+<a href="http://mindstorms.lego.com/en-us/support/files/Driver.aspx">http://mindstorms.lego.com/en-us/support/files/Driver.aspx</a>. После установки драйверов QReal сможет подключаться к
+роботу. Задайте в окне настроек робота подключение по USB, нажмите "ОК", нажмите кнопку "Подключиться" на панели инструментов.
+
+<center><img src="pics/robot-setup-select-connection-type.png" alt="Выбор способа соединения"></center>
+
+В окне вывода должно появиться сообщение об успешном подключении, после этого робот готов к работе.
+
+<center><img src="pics/robot-setup-connection-successful.png" alt="Успешное подключение" width="900" height="590"></center>
+
+<h4>Подключение по Bluetooth</h4>
+
+Робот подключается к компьютеру по Bluetooth как обычное Bluetooth-устройство, поэтому, во-первых, никаких специальных драйверов робота для подключения не требуется, во-вторых, процесс
+подключения сильно зависит как от операционной системы, так и от драйверов конкретного Bluetooth-адаптера. Ниже приведены инструкции по настройке подключения для Windows Vista с
+использованием встроенных в ОС драйверов для Generic Bluetooth Radio
+<ol>
+ <li> Включить робот </li>
+ <li> В "панели управления" операционной системы надо найти значок "Устройства Bluetooth"</li>
+ <li> Нажать "Добавление беспроводного устройства" </li>
+ <li> Выбрать в появившемся окне устройство "NXT" </li>
+ <li> Нажать на роботе оранжевую кнопку, подтвердив пароль 1234 на Bluetooth-соединение</li>
+ <li> В появившемся на компьютере окне ввести код 1234 и нажать "Далее"</li>
+ <li> Нажать "Закрыть"</li>
+ <li> Правой кнопкой мыши кликнуть по значку устройства, выбрать пункт меню "Свойства"</li>
+ <li> В появившемся окне перейти на вкладку "Службы" и запомнить номер последовательного порта (например, COM7)</li>
+ <li> Закрыть окно и панель управления, теперь робот подключен как Bluetooth-устройство, надо настроить QReal</li>
+ <li> Запустить QReal, открыть окно настроек робота</li>
+ <li> Выбрать подключение по Bluetooth и реальный робот</li>
+ <li> В разделе "Настройки Bluetooth" указать номер COM-порта, который был написан во вкладке "Службы" (например, COM7)</li>
+ <li> Нажать "ОК"</li>
+ <li> Перезапустить QReal</li>
+</ol>
+
См. также раздел <a href="interface.html#robotSettings">Диалог настроек робота</a>.
</body>
View
BIN  plugins/robots/editor/doc/qreal-robots.qch
Binary file not shown
View
BIN  plugins/robots/editor/doc/qreal-robots.qhc
Binary file not shown
View
20 plugins/robots/editor/generated/robotsMetamodel.xml
@@ -324,7 +324,7 @@
<logic>
<container/>
<properties>
- <property displayedName="Задержка" type="int" name="Delay">
+ <property displayedName="Задержка" type="string" name="Delay">
<default>0</default>
</property>
</properties>
@@ -523,10 +523,10 @@
<property displayedName="Ждать завершения" type="bool" name="WaitForCompletion">
<default>true</default>
</property>
- <property displayedName="Частота" type="int" name="Frequency">
+ <property displayedName="Частота" type="string" name="Frequency">
<default>1000</default>
</property>
- <property displayedName="Длительность" type="int" name="Duration">
+ <property displayedName="Длительность" type="string" name="Duration">
<default>1000</default>
</property>
</properties>
@@ -571,7 +571,7 @@
<logic>
<container/>
<properties>
- <property displayedName="Дистанция" type="int" name="Distance">
+ <property displayedName="Дистанция" type="string" name="Distance">
<default>0</default>
</property>
<property displayedName="Знак" type="DistanceSign" name="Sign">
@@ -605,10 +605,10 @@
<logic>
<container/>
<properties>
- <property displayedName="Мощность (%)" type="int" name="Power">
+ <property displayedName="Мощность (%)" type="string" name="Power">
<default>100</default>
</property>
- <property displayedName="Предел оборотов (гр.)" type="int" name="TachoLimit">
+ <property displayedName="Предел оборотов (гр.)" type="string" name="TachoLimit">
<default>0</default>
</property>
</properties>
@@ -653,7 +653,7 @@
<logic>
<container/>
<properties>
- <property displayedName="Интенсивность" type="int" name="Intensity">
+ <property displayedName="Интенсивность" type="string" name="Intensity">
<default>0</default>
</property>
<property displayedName="Знак" type="DistanceSign" name="Sign">
@@ -741,7 +741,7 @@
<container/>
<properties>
<property displayedName="Порт" type="string" name="Port"/>
- <property displayedName="Предел оборотов" type="int" name="TachoLimit"/>
+ <property displayedName="Предел оборотов" type="string" name="TachoLimit"/>
</properties>
<generalizations>
<parent parentName="AbstractNode"/>
@@ -819,7 +819,7 @@
<logic>
<container/>
<properties>
- <property displayedName="Тело функции" type="int" name="Body"/>
+ <property displayedName="Тело функции" type="string" name="Body"/>
</properties>
<generalizations>
<parent parentName="AbstractNode"/>
@@ -858,7 +858,7 @@
<logic>
<container/>
<properties>
- <property displayedName="Условие" type="int" name="Condition">
+ <property displayedName="Условие" type="string" name="Condition">
<default>0</default>
</property>
</properties>
View
18 plugins/robots/robotsInterpreter/details/autoconfigurer.cpp
@@ -8,10 +8,10 @@ using namespace interpreters::robots;
using namespace interpreters::robots::details;
Autoconfigurer::Autoconfigurer(GraphicalModelAssistInterface const &graphicalModelApi
- , BlocksTable * const blocksTable
- , ErrorReporterInterface * const errorReporter
- , RobotModel *robotModel
- )
+ , BlocksTable * const blocksTable
+ , ErrorReporterInterface * const errorReporter
+ , RobotModel *robotModel
+ )
: mGraphicalModelApi(&graphicalModelApi)
, mBlocksTable(blocksTable)
, mErrorReporter(errorReporter)
@@ -47,11 +47,11 @@ bool Autoconfigurer::configure(Id const &diagram)
if (result)
mRobotModel->configureSensors(
- mUsedSensors[0]
- , mUsedSensors[1]
- , mUsedSensors[2]
- , mUsedSensors[3]
- );
+ mUsedSensors[0]
+ , mUsedSensors[1]
+ , mUsedSensors[2]
+ , mUsedSensors[3]
+ );
return result;
}
View
10 plugins/robots/robotsInterpreter/details/d2RobotModel/colorFieldItem.cpp
@@ -0,0 +1,10 @@
+#include "colorFieldItem.h"
+
+using namespace qReal::interpreters::robots;
+using namespace details::d2Model;
+using namespace graphicsUtils;
+
+ColorFieldItem::ColorFieldItem(QGraphicsItem* parent)
+ : AbstractItem(parent)
+{
+}
View
28 plugins/robots/robotsInterpreter/details/d2RobotModel/colorFieldItem.h
@@ -0,0 +1,28 @@
+#pragma once
+#include <QtXml/QDomDocument>
+#include <QtGui/QGraphicsItem>
+#include "../../../../../qrutils/graphicsUtils/abstractItem.h"
+
+namespace qReal {
+namespace interpreters {
+namespace robots {
+namespace details {
+namespace d2Model {
+
+class ColorFieldItem : public graphicsUtils::AbstractItem
+{
+public:
+ ColorFieldItem(QGraphicsItem* parent = 0);
+
+ virtual QRectF boundingRect() const = 0;
+ virtual void drawItem(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget = 0) = 0;
+
+ virtual QDomElement serialize(QDomDocument &document, QPoint const &topLeftPicture) = 0;
+ virtual void deserialize(QDomElement const &element) = 0;
+};
+
+}
+}
+}
+}
+}
View
569 plugins/robots/robotsInterpreter/details/d2RobotModel/d2Form.ui
@@ -14,272 +14,417 @@
<string>2D Robot Model</string>
</property>
<layout class="QGridLayout" name="gridLayout">
- <item row="0" column="1" colspan="3">
- <layout class="QGridLayout" name="gridLayout_3">
- <property name="rightMargin">
- <number>10</number>
+ <item row="0" column="0">
+ <widget class="QPushButton" name="lineButton">
+ <property name="maximumSize">
+ <size>
+ <width>75</width>
+ <height>16777215</height>
+ </size>
</property>
- <property name="bottomMargin">
- <number>10</number>
+ <property name="text">
+ <string>Line</string>
</property>
- <item row="2" column="0">
- <widget class="QPushButton" name="doNothingButton">
- <property name="text">
- <string>do nothing</string>
- </property>
- <property name="checkable">
- <bool>false</bool>
+ <property name="checkable">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1">
+ <widget class="QPushButton" name="wallButton">
+ <property name="maximumSize">
+ <size>
+ <width>75</width>
+ <height>16777215</height>
+ </size>
+ </property>
+ <property name="text">
+ <string>Wall</string>
+ </property>
+ <property name="checkable">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="2" rowspan="11">
+ <widget class="graphicsUtils::AbstractView" name="graphicsView"/>
+ </item>
+ <item row="1" column="0">
+ <widget class="QPushButton" name="stylusButton">
+ <property name="maximumSize">
+ <size>
+ <width>75</width>
+ <height>16777215</height>
+ </size>
+ </property>
+ <property name="text">
+ <string>Stylus</string>
+ </property>
+ <property name="checkable">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1">
+ <widget class="QPushButton" name="clearButton">
+ <property name="maximumSize">
+ <size>
+ <width>75</width>
+ <height>16777215</height>
+ </size>
+ </property>
+ <property name="text">
+ <string>Clear</string>
+ </property>
+ <property name="checkable">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="0" colspan="2">
+ <widget class="QGroupBox" name="penBrushToolBox">
+ <property name="minimumSize">
+ <size>
+ <width>150</width>
+ <height>80</height>
+ </size>
+ </property>
+ <property name="maximumSize">
+ <size>
+ <width>155</width>
+ <height>80</height>
+ </size>
+ </property>
+ <property name="title">
+ <string>Pen</string>
+ </property>
+ <widget class="QWidget" name="justSomeWidget" native="true">
+ <property name="geometry">
+ <rect>
+ <x>10</x>
+ <y>20</y>
+ <width>141</width>
+ <height>21</height>
+ </rect>
+ </property>
+ <widget class="QSpinBox" name="penWidthSpinBox">
+ <property name="geometry">
+ <rect>
+ <x>40</x>
+ <y>0</y>
+ <width>98</width>
+ <height>21</height>
+ </rect>
</property>
</widget>
- </item>
- <item row="1" column="0">
- <widget class="QPushButton" name="clearButton">
+ <widget class="QLabel" name="label_7">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>31</width>
+ <height>16</height>
+ </rect>
+ </property>
+ <property name="font">
+ <font>
+ <weight>75</weight>
+ <bold>true</bold>
+ </font>
+ </property>
<property name="text">
- <string>Clear</string>
+ <string>Width</string>
</property>
- <property name="checkable">
- <bool>false</bool>
+ <property name="alignment">
+ <set>Qt::AlignCenter</set>
</property>
</widget>
- </item>
- <item row="3" column="0">
- <spacer name="verticalSpacer">
- <property name="orientation">
- <enum>Qt::Vertical</enum>
+ </widget>
+ <widget class="QWidget" name="widget_2" native="true">
+ <property name="geometry">
+ <rect>
+ <x>10</x>
+ <y>50</y>
+ <width>141</width>
+ <height>21</height>
+ </rect>
+ </property>
+ <widget class="graphicsUtils::ColorListEditor" name="penColorComboBox">
+ <property name="geometry">
+ <rect>
+ <x>40</x>
+ <y>0</y>
+ <width>98</width>
+ <height>20</height>
+ </rect>
+ </property>
+ </widget>
+ <widget class="QLabel" name="label_6">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>-60</y>
+ <width>29</width>
+ <height>142</height>
+ </rect>
</property>
- <property name="sizeHint" stdset="0">
+ <property name="maximumSize">
<size>
- <width>20</width>
- <height>40</height>
+ <width>64</width>
+ <height>16777215</height>
</size>
</property>
- </spacer>
- </item>
- <item row="0" column="0">
- <widget class="QPushButton" name="wallButton">
+ <property name="font">
+ <font>
+ <weight>75</weight>
+ <bold>true</bold>
+ </font>
+ </property>
<property name="text">
- <string>Wall</string>
+ <string>Color</string>
</property>
- <property name="checkable">
- <bool>true</bool>
+ <property name="alignment">
+ <set>Qt::AlignCenter</set>
+ </property>
+ </widget>
+ </widget>
+ </widget>
+ </item>
+ <item row="3" column="0">
+ <spacer name="verticalSpacer">
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>20</width>
+ <height>74</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item row="4" column="0" colspan="2">
+ <layout class="QGridLayout" name="gridLayout_2">
+ <item row="0" column="0">
+ <widget class="QLabel" name="label">
+ <property name="text">
+ <string>Port 1:</string>
</property>
</widget>
</item>
- <item row="7" column="0">
- <spacer name="verticalSpacer_2">
- <property name="orientation">
- <enum>Qt::Vertical</enum>
+ <item row="1" column="0">
+ <widget class="QLabel" name="label_2">
+ <property name="text">
+ <string>Port 2:</string>
</property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>20</width>
- <height>40</height>
- </size>
+ </widget>
+ </item>
+ <item row="2" column="0">
+ <widget class="QLabel" name="label_3">
+ <property name="text">
+ <string>Port 3:</string>
</property>
- </spacer>
+ </widget>
</item>
- <item row="5" column="0">
- <layout class="QGridLayout" name="gridLayout_2">
- <item row="0" column="0">
- <widget class="QLabel" name="label">
- <property name="text">
- <string>Port 1:</string>
- </property>
- </widget>
- </item>
- <item row="1" column="0">
- <widget class="QLabel" name="label_2">
- <property name="text">
- <string>Port 2:</string>
- </property>
- </widget>
- </item>
- <item row="2" column="0">
- <widget class="QLabel" name="label_3">
- <property name="text">
- <string>Port 3:</string>
- </property>
- </widget>
+ <item row="0" column="1">
+ <widget class="QComboBox" name="port1Box">
+ <item>
+ <property name="text">
+ <string>touch</string>
+ </property>
</item>
- <item row="0" column="1">
- <widget class="QComboBox" name="port1Box">
- <item>
- <property name="text">
- <string>touch</string>
- </property>
- </item>
- <item>
- <property name="text">
- <string>color</string>
- </property>
- </item>
- <item>
- <property name="text">
- <string>sonar</string>
- </property>
- </item>
- </widget>
+ <item>
+ <property name="text">
+ <string>color</string>
+ </property>
</item>
- <item row="2" column="1">
- <widget class="QComboBox" name="port3Box">
- <property name="currentIndex">
- <number>2</number>
- </property>
- <item>
- <property name="text">
- <string>touch</string>
- </property>
- </item>
- <item>
- <property name="text">
- <string>color</string>
- </property>
- </item>
- <item>
- <property name="text">
- <string>sonar</string>
- </property>
- </item>
- </widget>
+ <item>
+ <property name="text">
+ <string>sonar</string>
+ </property>
</item>
- <item row="1" column="1">
- <widget class="QComboBox" name="port2Box">
- <property name="currentIndex">
- <number>1</number>
- </property>
- <item>
- <property name="text">
- <string>touch</string>
- </property>
- </item>
- <item>
- <property name="text">
- <string>color</string>
- </property>
- </item>
- <item>
- <property name="text">
- <string>sonar</string>
- </property>
- </item>
- </widget>
- </item>
- <item row="0" column="2">
- <widget class="QPushButton" name="port1AddButton">
- <property name="text">
- <string>add</string>
- </property>
- <property name="checkable">
- <bool>true</bool>
- </property>
- </widget>
+ </widget>
+ </item>
+ <item row="2" column="1">
+ <widget class="QComboBox" name="port3Box">
+ <property name="currentIndex">
+ <number>2</number>
+ </property>
+ <item>
+ <property name="text">
+ <string>touch</string>
+ </property>
</item>
- <item row="1" column="2">
- <widget class="QPushButton" name="port2AddButton">
- <property name="text">
- <string>add</string>
- </property>
- <property name="checkable">
- <bool>true</bool>
- </property>
- </widget>
+ <item>
+ <property name="text">
+ <string>color</string>
+ </property>
</item>
- <item row="2" column="2">
- <widget class="QPushButton" name="port3AddButton">
- <property name="text">
- <string>add</string>
- </property>
- <property name="checkable">
- <bool>true</bool>
- </property>
- </widget>
+ <item>
+ <property name="text">
+ <string>sonar</string>
+ </property>
</item>
- <item row="3" column="0">
- <widget class="QLabel" name="label_4">
- <property name="text">
- <string>Port 4:</string>
- </property>
- </widget>
+ </widget>
+ </item>
+ <item row="1" column="1">
+ <widget class="QComboBox" name="port2Box">
+ <property name="currentIndex">
+ <number>1</number>
+ </property>
+ <item>
+ <property name="text">
+ <string>touch</string>
+ </property>
</item>
- <item row="3" column="1">
- <widget class="QComboBox" name="port4Box">
- <item>
- <property name="text">
- <string>touch</string>
- </property>
- </item>
- <item>
- <property name="text">
- <string>color</string>
- </property>
- </item>
- <item>
- <property name="text">
- <string>sonar</string>
- </property>
- </item>
- </widget>
+ <item>
+ <property name="text">
+ <string>color</string>
+ </property>
</item>
- <item row="3" column="2">
- <widget class="QPushButton" name="port4AddButton">
- <property name="text">
- <string>add</string>
- </property>
- <property name="checkable">
- <bool>true</bool>
- </property>
- </widget>
+ <item>
+ <property name="text">
+ <string>sonar</string>
+ </property>
</item>
- </layout>
+ </widget>
</item>
- <item row="10" column="0">
- <spacer name="verticalSpacer_3">
- <property name="orientation">
- <enum>Qt::Vertical</enum>
+ <item row="0" column="2">
+ <widget class="QPushButton" name="port1AddButton">
+ <property name="text">
+ <string>add</string>
</property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>20</width>
- <height>40</height>
- </size>
+ <property name="checkable">
+ <bool>true</bool>
</property>
- </spacer>
+ </widget>
</item>
- <item row="8" column="0">
- <widget class="QPushButton" name="saveWorldModelPushButton">
+ <item row="1" column="2">
+ <widget class="QPushButton" name="port2AddButton">
<property name="text">
- <string>Save World Model</string>
+ <string>add</string>
+ </property>
+ <property name="checkable">
+ <bool>true</bool>
</property>
</widget>
</item>
- <item row="9" column="0">
- <widget class="QPushButton" name="loadWorldModelPushButton">
+ <item row="2" column="2">
+ <widget class="QPushButton" name="port3AddButton">
<property name="text">
- <string>Load World Model</string>
+ <string>add</string>
+ </property>
+ <property name="checkable">
+ <bool>true</bool>
</property>
</widget>
</item>
- <item row="11" column="0">
- <widget class="QPushButton" name="runButton">
+ <item row="3" column="0">
+ <widget class="QLabel" name="label_4">
<property name="text">
- <string>Run program</string>
+ <string>Port 4:</string>
</property>
</widget>
</item>
- <item row="12" column="0">
- <widget class="QPushButton" name="stopButton">
+ <item row="3" column="1">
+ <widget class="QComboBox" name="port4Box">
+ <item>
+ <property name="text">
+ <string>touch</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>color</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>sonar</string>
+ </property>
+ </item>
+ </widget>
+ </item>
+ <item row="3" column="2">
+ <widget class="QPushButton" name="port4AddButton">
<property name="text">
- <string>Stop program</string>
+ <string>add</string>
+ </property>
+ <property name="checkable">
+ <bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
- <item row="0" column="9">
- <widget class="QGraphicsView" name="graphicsView"/>
+ <item row="5" column="0">
+ <spacer name="verticalSpacer_2">
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>20</width>
+ <height>73</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item row="6" column="0" colspan="2">
+ <widget class="QPushButton" name="saveWorldModelPushButton">
+ <property name="text">
+ <string>Save World Model</string>
+ </property>
+ </widget>
+ </item>
+ <item row="7" column="0" colspan="2">
+ <widget class="QPushButton" name="loadWorldModelPushButton">
+ <property name="text">
+ <string>Load World Model</string>
+ </property>
+ </widget>
+ </item>
+ <item row="8" column="0">
+ <spacer name="verticalSpacer_3">
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>20</width>
+ <height>74</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item row="9" column="0" colspan="2">
+ <widget class="QPushButton" name="runButton">
+ <property name="text">
+ <string>Run program</string>
+ </property>
+ </widget>
+ </item>
+ <item row="10" column="0" colspan="2">
+ <widget class="QPushButton" name="stopButton">
+ <property name="text">
+ <string>Stop program</string>
+ </property>
+ </widget>
</item>
</layout>
</widget>
+ <customwidgets>
+ <customwidget>
+ <class>graphicsUtils::AbstractView</class>
+ <extends>QGraphicsView</extends>
+ <header>../../../qrutils/graphicsUtils/abstractItemView.h</header>
+ </customwidget>
+ <customwidget>
+ <class>graphicsUtils::ColorListEditor</class>
+ <extends>QComboBox</extends>
+ <header>../../../qrutils/graphicsUtils/colorlisteditor.h</header>
+ </customwidget>
+ </customwidgets>
<resources/>
<connections/>
</ui>
View
12 plugins/robots/robotsInterpreter/details/d2RobotModel/d2ModelScene.cpp
@@ -2,16 +2,20 @@
#include <QtGui/QGraphicsSceneMouseEvent>
#include <QtGui/QKeyEvent>
-#include <QDebug>
using namespace qReal::interpreters::robots;
using namespace details::d2Model;
+using namespace graphicsUtils;
-D2ModelScene::D2ModelScene(QObject *parent) : QGraphicsScene(parent)
+D2ModelScene::D2ModelScene(AbstractView *view, QObject *parent)
+ : AbstractScene(view, parent)
{
- addRect(-500, -500, 1000, 1000, QPen(Qt::NoPen), QBrush(Qt::NoBrush));
+ mFirstPenWidth = 6;
+ mSizeEmptyRectX = 1000;
+ mSizeEmptyRectY = 1000;
+ setEmptyRect(-500, -500, mSizeEmptyRectX, mSizeEmptyRectY);
setItemIndexMethod(NoIndex);
-// clear();
+ setEmptyPenBrushItems();
}
D2ModelScene::~D2ModelScene()
View
5 plugins/robots/robotsInterpreter/details/d2RobotModel/d2ModelScene.h
@@ -1,6 +1,7 @@
#pragma once
#include <QGraphicsScene>
+#include "../../../../../qrutils/graphicsUtils/abstractScene.h"
namespace qReal {
namespace interpreters {
@@ -10,11 +11,11 @@ namespace d2Model {
/** @brief Implementation of QGraphicsScene for 2D robot model
*/
-class D2ModelScene: public QGraphicsScene
+class D2ModelScene: public graphicsUtils::AbstractScene
{
Q_OBJECT
public:
- D2ModelScene(QObject *parent = 0);
+ D2ModelScene(graphicsUtils::AbstractView *view, QObject *parent = 0);
virtual ~D2ModelScene();
void keyPressEvent(QKeyEvent *event);
View
365 plugins/robots/robotsInterpreter/details/d2RobotModel/d2ModelWidget.cpp
@@ -2,6 +2,8 @@
#include "ui_d2Form.h"
#include <QtGui/QFileDialog>
+#include <QRegion>
+#include <qmath.h>
#include "sensorItem.h"
#include "sonarSensorItem.h"
@@ -9,10 +11,9 @@
#include "../../../../../qrutils/outFile.h"
#include "../../../../../qrutils/xmlUtils.h"
-#include <QtCore/QDebug>
-
using namespace qReal::interpreters::robots;
using namespace details::d2Model;
+using namespace graphicsUtils;
D2ModelWidget::D2ModelWidget(RobotModelInterface *robotModel, WorldModel *worldModel, QWidget *parent)
: QWidget(parent)
@@ -24,22 +25,23 @@ D2ModelWidget::D2ModelWidget(RobotModelInterface *robotModel, WorldModel *worldM
, mWorldModel(worldModel)
, mDrawingAction(drawingAction::none)
, mMouseClicksCount(0)
+ , mCurrentWall(NULL)
+ , mCurrentLine(NULL)
+ , mCurrentStylus(NULL)
, mCurrentPort(inputPort::none)
, mCurrentSensorType(sensorType::unused)
- , mButtonsCount(6) // magic numbers are baaad, mkay?
+ , mButtonsCount(8) // magic numbers are baaad, mkay?
{
- mUi->setupUi(this);
- mSensors.resize(4);
-
- mScene = new D2ModelScene(mUi->graphicsView);
- mUi->graphicsView->setScene(mScene);
- mUi->graphicsView->setDragMode(QGraphicsView::RubberBandDrag);
- move(0, 0);
+ initWidget();
connectUiButtons();
connect(mScene, SIGNAL(mouseClicked(QGraphicsSceneMouseEvent *)), this, SLOT(mouseClicked(QGraphicsSceneMouseEvent *)));
+ connect(mScene, SIGNAL(mouseMoved(QGraphicsSceneMouseEvent*)), this, SLOT(mouseMoved(QGraphicsSceneMouseEvent*)));
+ connect(mScene, SIGNAL(mouseReleased(QGraphicsSceneMouseEvent*)), this, SLOT(mouseReleased(QGraphicsSceneMouseEvent*)));
connect(mScene, SIGNAL(itemDeleted(QGraphicsItem*)), this, SLOT(deleteItem(QGraphicsItem*)));
+
+ connect(mScene, SIGNAL(selectionChanged()), this, SLOT(changePalette()));
}
D2ModelWidget::~D2ModelWidget()
@@ -50,11 +52,39 @@ D2ModelWidget::~D2ModelWidget()
delete mUi;
}
+void D2ModelWidget::initWidget()
+{
+ mUi->setupUi(this);
+ mSensors.resize(4);
+ mSensorRotaters.resize(4);
+
+ mScene = new D2ModelScene(mUi->graphicsView);
+ mUi->graphicsView->setScene(mScene);
+ mUi->graphicsView->setDragMode(QGraphicsView::RubberBandDrag);
+ move(0, 0);
+
+ mUi->penWidthSpinBox->setRange(6, 13);
+
+ QStringList colorNames;
+ colorNames.push_back("Black");
+ colorNames.push_back("Blue");
+ colorNames.push_back("Green");
+ colorNames.push_back("Yellow");
+ colorNames.push_back("Red");
+
+ mUi->penColorComboBox->setColorList(colorNames);
+ mUi->penColorComboBox->setColor(QColor("black"));
+}
+
void D2ModelWidget::connectUiButtons()
{
+ connect(mUi->stylusButton, SIGNAL(toggled(bool)), this, SLOT(addStylus(bool)));
+ connect(mUi->lineButton, SIGNAL(toggled(bool)), this, SLOT(addLine(bool)));
connect(mUi->wallButton, SIGNAL(toggled(bool)), this, SLOT(addWall(bool)));
connect(mUi->clearButton, SIGNAL(clicked()), this, SLOT(clearScene()));
- connect(mUi->doNothingButton, SIGNAL(clicked()), this, SLOT(resetButtons()));
+
+ connect(mUi->penWidthSpinBox, SIGNAL(valueChanged(int)), this, SLOT(changePenWidth(int)));
+ connect(mUi->penColorComboBox, SIGNAL(activated(const QString &)), this, SLOT(changePenColor(const QString &)));
connect(mUi->port1AddButton, SIGNAL(clicked()), &mPortsMapper, SLOT(map()));
mPortsMapper.setMapping(mUi->port1AddButton, inputPort::port1);
@@ -108,7 +138,11 @@ void D2ModelWidget::drawInitialRobot()
mRotater->setMasterItem(mRobot);
mRotater->setVisible(true);
mScene->addItem(mRotater);
+
+ mRotater->setVisible(false);
+
mRobot->setRotater(mRotater);
+ mRobot->setRobotModel(mRobotModel);
mLine.startsWith(mRobot->mapToScene(mRobot->boundingRect().center()));
mPolygon = mScene->addPolygon(mLine, QPen(Qt::black));
@@ -137,6 +171,7 @@ void D2ModelWidget::update()
{
QWidget::update();
drawWalls();
+ drawColorFields();
}
void D2ModelWidget::changeEvent(QEvent *e)
@@ -172,11 +207,15 @@ void D2ModelWidget::draw(QPointF newCoord, qreal angle, QPointF dPoint)
void D2ModelWidget::drawWalls()
{
- QPen pen(Qt::red);
- pen.setWidth(5);
- typedef QPair<QPointF, QPointF> Wall;
- foreach (Wall const wall, mWorldModel->walls()) {
- mScene->addLine(QLineF(wall.first,wall.second), pen);
+ foreach (WallItem *wall, mWorldModel->walls()) {
+ mScene->addItem(wall);
+ }
+}
+
+void D2ModelWidget::drawColorFields()
+{
+ foreach (ColorFieldItem *colorField, mWorldModel->colorFields()) {
+ mScene->addItem(colorField);
}
}
@@ -188,10 +227,10 @@ void D2ModelWidget::drawBeep(QColor const &color)
QPolygonF const D2ModelWidget::robotBoundingPolygon(QPointF const &coord, qreal const &angle) const
{
- Q_UNUSED(angle)
- Q_UNUSED(coord)
- QRectF rect = mRobot->mapRectToScene(mRobot->boundingRect());
- return QPolygonF() << rect.topLeft() << rect.topRight() << rect.bottomRight() << rect.bottomLeft();
+ Q_UNUSED(coord);
+ Q_UNUSED(angle);
+
+ return mRobot->mapToScene(QPolygon(mRobot->boundingRect().toRect()));
}
void D2ModelWidget::addWall(bool on)
@@ -202,11 +241,32 @@ void D2ModelWidget::addWall(bool on)
return;
}
- setActiveButton(mButtonsCount - 2);
-
+ setActiveButton(4);
mDrawingAction = drawingAction::wall;
}
+void D2ModelWidget::addLine(bool on)
+{
+ if (!on) {
+ mDrawingAction = drawingAction::none;
+ mMouseClicksCount = 0;
+ return;
+ }
+ setActiveButton(5);
+ mDrawingAction = drawingAction::line;
+}
+
+void D2ModelWidget::addStylus(bool on)
+{
+ if (!on) {
+ mDrawingAction = drawingAction::none;
+ mMouseClicksCount = 0;
+ return;
+ }
+ setActiveButton(6);
+ mDrawingAction = drawingAction::stylus;
+}
+
void D2ModelWidget::setActiveButton(int active)
{
mButtonFlags.clear();
@@ -220,19 +280,29 @@ void D2ModelWidget::setActiveButton(int active)
mUi->port3AddButton->setChecked(mButtonFlags.at(2));
mUi->port4AddButton->setChecked(mButtonFlags.at(3));
mUi->wallButton->setChecked(mButtonFlags.at(4));
+ mUi->lineButton->setChecked(mButtonFlags.at(5));
+ mUi->stylusButton->setChecked(mButtonFlags.at(6));
+
}
void D2ModelWidget::clearScene()
{
mWorldModel->clearScene();
mRobot->clearSensors();
+ mRobotModel->clear();
+ mLine.clear();
+ foreach (SensorItem *sensor, mSensors) {
+ mScene->removeItem(sensor);
+ }
mScene->clear();
drawInitialRobot();
}
void D2ModelWidget::resetButtons()
{
- mCurrentWall.clear();
+ mCurrentWall = NULL;
+ mCurrentLine = NULL;
+ mCurrentStylus = NULL;
mMouseClicksCount = 0;
mDrawingAction = drawingAction::none;
setActiveButton(mButtonsCount - 1);
@@ -296,48 +366,161 @@ void D2ModelWidget::addPort(int const port)
}
}
+void D2ModelWidget::reshapeWall(QGraphicsSceneMouseEvent *event)
+{
+ QPointF const pos = event->scenePos();
+ if (mCurrentWall != NULL) {
+ mCurrentWall->setX2andY2(pos.x(), pos.y());
+ if (event->modifiers() & Qt::ShiftModifier)
+ mCurrentWall->reshapeRectWithShift();
+ }
+}
+
+void D2ModelWidget::reshapeLine(QGraphicsSceneMouseEvent *event)
+{
+ QPointF const pos = event->scenePos();
+ if (mCurrentLine != NULL) {
+ mCurrentLine->setX2andY2(pos.x(), pos.y());
+ if (event->modifiers() & Qt::ShiftModifier)
+ mCurrentLine->reshapeRectWithShift();
+ }
+}
+
+void D2ModelWidget::reshapeStylus(QGraphicsSceneMouseEvent *event)
+{
+ QPointF const pos = event->scenePos();
+ if (mCurrentStylus != NULL) {
+ mCurrentStylus->addLine(pos.x(), pos.y());
+ }
+}
+
void D2ModelWidget::mouseClicked(QGraphicsSceneMouseEvent *mouseEvent)
{
- QPointF const position = mouseEvent->scenePos();
+ mRobot->checkSelection();
+ foreach (SensorItem *sensor, mSensors) {
+ if (sensor != NULL)
+ sensor->checkSelection();
+ }
+ QPointF const position = mouseEvent->scenePos();
+ mScene->setDragMode(mDrawingAction);
switch (mDrawingAction){
- case drawingAction::wall:
- mCurrentWall.append(position);
+ case drawingAction::wall: {
+ mCurrentWall = new WallItem(position, position);
+ mScene->removeMoveFlag(mouseEvent, mCurrentWall);
+ mWorldModel->addWall(mCurrentWall);
+ mMouseClicksCount++;
+ }
+ break;
+ case drawingAction::line: {
+ mCurrentLine = new LineItem(position, position);
+ mCurrentLine->setPenBrush(mScene->penStyleItems(), mScene->penWidthItems(), mScene->penColorItems()
+ , mScene->brushStyleItems(), mScene->brushColorItems());
+ mScene->removeMoveFlag(mouseEvent, mCurrentLine);
+ mWorldModel->addColorField(mCurrentLine);
+ mMouseClicksCount++;
+ }
+ break;
+ case drawingAction::stylus: {
+ mCurrentStylus = new StylusItem(position.x(), position.y());
+ mCurrentStylus->setPenBrush(mScene->penStyleItems(), mScene->penWidthItems(), mScene->penColorItems()
+ , mScene->brushStyleItems(), mScene->brushColorItems());
+ mScene->removeMoveFlag(mouseEvent, mCurrentStylus);
+ mWorldModel->addColorField(mCurrentStylus);
mMouseClicksCount++;
+ }
break;
case drawingAction::port: {
- QPointF newpos = mRobot->mapFromScene(mouseEvent->scenePos().x(), mouseEvent->scenePos().y());
- mRobotModel->configuration().setSensor(mCurrentPort, mCurrentSensorType, newpos.toPoint(), 0); // TODO: handle direction
+ QPointF newpos = mRobot->mapFromScene(mouseEvent->scenePos());
+ mRobotModel->configuration().setSensor(mCurrentPort, mCurrentSensorType, newpos.toPoint(), 0);
reinitSensor(mCurrentPort);
resetButtons();
}
- break;
- case drawingAction::none:
+ break;
+ case drawingAction::none: {
mMouseClicksCount = 0;
+ mScene->forPressResize(mouseEvent);
+ }
break;
default:
break;
}
- if (mMouseClicksCount >= 2)
- {
- mWorldModel->addWall(mCurrentWall.at(0), mCurrentWall.at(1));
- mCurrentWall.clear();
- mMouseClicksCount = 0;
- }
update();
}
-void D2ModelWidget::mouseReleased(QGraphicsSceneMouseEvent *mouseEvent)
+
+void D2ModelWidget::mouseMoved(QGraphicsSceneMouseEvent *mouseEvent)
{
- Q_UNUSED(mouseEvent)
+ mRobot->checkSelection();
+ foreach (SensorItem *sensor, mSensors) {
+ if (sensor != NULL)
+ sensor->checkSelection();
+ }
+
+ mScene->setDragMode(mDrawingAction);
+ switch (mDrawingAction){
+ case drawingAction::wall:
+ reshapeWall(mouseEvent);
+ break;
+ case drawingAction::line: {
+ reshapeLine(mouseEvent);
+ }
+ break;
+ case drawingAction::stylus: {
+ reshapeStylus(mouseEvent);
+ }
+ break;
+ default:
+ mScene->forMoveResize(mouseEvent);
+ break;
+ }
+ mScene->update();
}
-void D2ModelWidget::mouseMoved(QGraphicsSceneMouseEvent *mouseEvent)
+void D2ModelWidget::mouseReleased(QGraphicsSceneMouseEvent *mouseEvent)
{
- Q_UNUSED(mouseEvent)
+ mRobot->checkSelection();
+ foreach (SensorItem *sensor, mSensors) {
+ if (sensor != NULL)
+ sensor->checkSelection();
+ }
+
+ mScene->setDragMode(mDrawingAction);
+
+ switch (mDrawingAction){
+ case drawingAction::wall: {
+ reshapeWall(mouseEvent);
+ mCurrentWall = NULL;
+ mMouseClicksCount = 0;
+ mDrawingAction = drawingAction::none;
+ }
+ break;
+ case drawingAction::line: {
+ reshapeLine(mouseEvent);
+ mCurrentLine = NULL;
+ mMouseClicksCount = 0;
+ mDrawingAction = drawingAction::none;
+ }
+ break;
+ case drawingAction::stylus: {
+ reshapeStylus(mouseEvent);
+ mCurrentStylus = NULL;
+ mMouseClicksCount = 0;
+ mDrawingAction = drawingAction::none;
+ }
+ break;
+ default:
+ mScene->forReleaseResize(mouseEvent);
+ break;
+ }
+ mUi->wallButton->setChecked(false);
+ mUi->lineButton->setChecked(false);
+ mUi->stylusButton->setChecked(false);
+ mScene->setMoveFlag(mouseEvent);
+ mScene->update();
}
void D2ModelWidget::saveWorldModel()
@@ -349,8 +532,8 @@ void D2ModelWidget::saveWorldModel()
QDomDocument save;
QDomElement root = save.createElement("root");
- save.appendChild(root);
- root.appendChild(mWorldModel->serialize(save));
+ save.appendChild(root);
+ root.appendChild(mWorldModel->serialize(save, QPoint(0, 0)));
root.appendChild(mRobotModel->configuration().serialize(save));
utils::OutFile saveFile(saveFileName);
@@ -398,8 +581,11 @@ void D2ModelWidget::removeSensor(inputPort::InputPortEnum port)
if (mSensors[port]) {
mRobot->removeSensor(mSensors[port]);
mScene->removeItem(mSensors[port]);
+ mScene->removeItem(mSensorRotaters[port]);
delete mSensors[port];
+ delete mSensorRotaters[port];
mSensors[port] = NULL;
+ mSensorRotaters[port] = NULL;
}
}
@@ -413,10 +599,19 @@ void D2ModelWidget::reinitSensor(inputPort::InputPortEnum port)
SensorItem *sensor = mRobotModel->configuration().type(port) == sensorType::sonar
? new SonarSensorItem(*mWorldModel, mRobotModel->configuration(), port)
: new SensorItem(mRobotModel->configuration(), port);
+ sensor->setRotatePoint(rotatePoint);
mRobot->addSensor(sensor);
mScene->addItem(sensor);
- sensor->setBasePosition(mRobot->scenePos());
+
+ /*íàçíà÷àåì ðîòàòåð*/
+ mSensorRotaters[port] = new Rotater();
+ mSensorRotaters[port]->setMasterItem(sensor);
+ mSensorRotaters[port]->setVisible(false);
+ sensor->setRotater(mSensorRotaters[port]);
+
+ sensor->setBasePosition(mRobot->basePoint(), mRobot->rotateAngle()/*, rotatePoint*/);
+ mScene->addItem(mSensorRotaters[port]);
mSensors[port] = sensor;
}
@@ -430,3 +625,87 @@ void D2ModelWidget::deleteItem(QGraphicsItem *item)
if (port != -1)
removeSensor(static_cast<inputPort::InputPortEnum>(port));
}
+
+bool D2ModelWidget::isColorItem(AbstractItem *item)
+{
+ RobotItem* robotItem = dynamic_cast<RobotItem*>(item);
+ SensorItem* sensorItem = dynamic_cast<SensorItem*>(item);
+ WallItem* wallItem = dynamic_cast<WallItem*>(item);
+ Rotater* rotaterItem = dynamic_cast<Rotater*>(item);
+ return (!robotItem && !sensorItem && !wallItem && !rotaterItem);
+}
+
+QList<AbstractItem *> D2ModelWidget::selectedColorItems()
+{
+ QList<AbstractItem *> resList;
+ QList<QGraphicsItem *> listSelectedItems = mScene->selectedItems();
+ foreach (QGraphicsItem *graphicsItem, listSelectedItems) {
+ AbstractItem* item = dynamic_cast<AbstractItem*>(graphicsItem);
+ if (item != NULL) {
+ //òåïåðü íàäî èñêëþ÷èòü åùå òå îáúåêòû, êîòîðûì íå íàäî ìåíÿòü öâåò è ò.ä., à ò.å. ðîáîòà, ñåíñîðû, ñòåíû è ðîòàòåðû
+ if (isColorItem(item))
+ resList.push_back(item);
+ }
+ }
+ qSort(resList.begin(), resList.end(), mScene->compareItems);
+ return resList;
+}
+
+void D2ModelWidget::changePenWidth(int width)
+{
+ mScene->setPenWidthItems(width);
+ foreach (AbstractItem *item, selectedColorItems())
+ item->setPenWidth(width);
+ mScene->update();
+}
+
+void D2ModelWidget::changePenColor(const QString &text)
+{
+ mScene->setPenColorItems(text);
+ foreach (AbstractItem *item, selectedColorItems())
+ item->setPenColor(text);
+ mScene->update();
+}
+
+void D2ModelWidget::changePalette()
+{
+ if(mDrawingAction == drawingAction::none) {
+ QList<QGraphicsItem *> listSelectedItems = mScene->selectedItems();
+ if (listSelectedItems.isEmpty()) {
+ setNoPalette();
+ mScene->setEmptyPenBrushItems();
+ }
+ else {
+ AbstractItem* item = dynamic_cast<AbstractItem*>(listSelectedItems.back());
+ if (isColorItem(item)) {
+ QPen penItem = item->pen();
+ QBrush brushItem = item->brush();
+ setItemPalette(penItem, brushItem);
+ mScene->setPenBrushItems(penItem, brushItem);
+ }
+ }
+ }
+}
+
+void D2ModelWidget::setValuePenColorComboBox(QColor penColor)
+{
+ mUi->penColorComboBox->setColor(penColor);
+}
+
+void D2ModelWidget::setValuePenWidthSpinBox(int width)
+{
+ mUi->penWidthSpinBox->setValue(width);
+}
+
+void D2ModelWidget::setItemPalette(QPen const &penItem, QBrush const &brushItem)
+{
+ Q_UNUSED(brushItem)
+ setValuePenWidthSpinBox(penItem.width());
+ setValuePenColorComboBox(penItem.color());
+}
+
+void D2ModelWidget::setNoPalette()
+{
+ mUi->penWidthSpinBox->setValue(6);
+ mUi->penColorComboBox->setColor(QColor("black"));
+}
View
29 plugins/robots/robotsInterpreter/details/d2RobotModel/d2ModelWidget.h
@@ -8,11 +8,14 @@
#include <QtGui/QComboBox>
#include <QtGui/QPushButton>
+#include "lineItem.h"
+#include "stylusItem.h"
#include "worldModel.h"
#include "robotModelInterface.h"
#include "d2ModelScene.h"
#include "robotItem.h"
#include "rotater.h"
+#include "../../../../../qrutils/graphicsUtils/lineImpl.h"
namespace Ui {
class D2Form;
@@ -28,6 +31,8 @@ namespace drawingAction {
enum DrawingAction {
none,
wall,
+ line,
+ stylus,
port
};
}
@@ -60,6 +65,8 @@ public slots:
private slots:
void addWall(bool on);
+ void addLine(bool on);
+ void addStylus(bool on);
void clearScene();
void resetButtons();
@@ -76,6 +83,10 @@ private slots:
void saveWorldModel();
void loadWorldModel();
+ void changePenWidth(int width);
+ void changePenColor(const QString &text);
+ void changePalette();
+
private:
Ui::D2Form *mUi;
D2ModelScene *mScene;
@@ -92,7 +103,9 @@ private slots:
int mMouseClicksCount;
/** @brief Temporary wall that's being created. When it's complete, it's added to world model */
- QList<QPointF> mCurrentWall;
+ WallItem* mCurrentWall;
+ LineItem* mCurrentLine;
+ StylusItem* mCurrentStylus;
/** @brief Latest value of angle for drawing robot image */
qreal mAngleOld;
@@ -119,9 +132,11 @@ private slots:
QVector<SensorItem *> mSensors;
Rotater *mRotater;
+ QVector<Rotater *> mSensorRotaters;
void connectUiButtons();
void drawWalls();
+ void drawColorFields();
void drawInitialRobot();
/** @brief Set active panel toggle button and deactivate all others */
@@ -142,6 +157,18 @@ private slots:
/// Reread sensor configuration on given port, delete old sensor item and create new.
void reinitSensor(inputPort::InputPortEnum port);
+ void reshapeWall(QGraphicsSceneMouseEvent *event);
+ void reshapeLine(QGraphicsSceneMouseEvent *event);
+ void reshapeStylus(QGraphicsSceneMouseEvent *event);
+
+ void setValuePenColorComboBox(QColor penColor);
+ void setValuePenWidthSpinBox(int width);
+ void setItemPalette(QPen const &penItem, QBrush const &brushItem);
+ void setNoPalette();
+
+ void initWidget();
+ QList<graphicsUtils::AbstractItem *> selectedColorItems();
+ bool isColorItem(graphicsUtils::AbstractItem *item);
};
}
View
117 plugins/robots/robotsInterpreter/details/d2RobotModel/d2RobotModel.cpp
@@ -1,5 +1,4 @@
#include "d2RobotModel.h"
-#include <QDebug>
using namespace qReal::interpreters::robots;
using namespace details::d2Model;
@@ -8,6 +7,7 @@ D2RobotModel::D2RobotModel(QObject *parent)
: QObject(parent)
, mD2ModelWidget(NULL)
{
+ mAngle = 0;
mTimer = new QTimer(this);
connect(mTimer, SIGNAL(timeout()), this, SLOT(nextFragment()));
initPosition();
@@ -22,10 +22,17 @@ void D2RobotModel::initPosition()
mMotorA = initMotor(5, 0, 0, 0);
mMotorB = initMotor(5, 0, 0, 1);
mMotorC = initMotor(5, 0, 0, 2);
- setBeep(0, 0);
- mAngle = 0;
+ setBeep(0, 0);
mPos = mD2ModelWidget ? mD2ModelWidget->robotPos() : QPointF(0, 0);
mRotatePoint = QPointF(0, 0);
+
+}
+
+void D2RobotModel::clear()
+{
+ initPosition();
+ mAngle = 0;
+ mPos = QPointF(0,0);
}
D2RobotModel::Motor* D2RobotModel::initMotor(int radius, int speed, long unsigned int degrees, int port)
@@ -34,7 +41,15 @@ D2RobotModel::Motor* D2RobotModel::initMotor(int radius, int speed, long unsigne
motor->radius = radius;
motor->speed = speed;
motor->degrees = degrees;
+ if (degrees == 0) {
+ motor->activeTime = QPair<ATime, qreal>(DoInf , 0);
+ }
+ else {
+ qreal activeTime = degrees / speed ;
+ motor->activeTime = QPair<ATime, qreal>(Do , activeTime);
+ }
mMotors[port] = motor;
+ mTurnoverMotors[port] = 0;
return motor;
}
@@ -48,6 +63,51 @@ void D2RobotModel::setNewMotor(int speed, unsigned long degrees, const int port)