Skip to content

Commit

Permalink
Fix lost robot's position for loadWorldModel action (#1622)
Browse files Browse the repository at this point in the history
* Fix lost robot's position for loadWorldModel action
* Fix deploy
Co-authored-by: iakov <[email protected]>
  • Loading branch information
IKhonakhbeeva authored Feb 13, 2023
1 parent ff6360f commit 683154d
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 31 deletions.
9 changes: 4 additions & 5 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ jobs:
run: |
ARCH=32
PLATFORM=i686
pacman --verbose --noconfirm -S msys/zlib-devel dos2unix ccache rsync unzip mingw$ARCH/mingw-w64-$PLATFORM-libzip mingw$ARCH/mingw-w64-$PLATFORM-libusb mingw$ARCH/mingw-w64-$PLATFORM-zlib mingw$ARCH/mingw-w64-$PLATFORM-pkg-config
pacman --verbose --noconfirm -S msys/zlib-devel dos2unix ccache rsync unzip openssh mingw$ARCH/mingw-w64-$PLATFORM-libzip mingw$ARCH/mingw-w64-$PLATFORM-libusb mingw$ARCH/mingw-w64-$PLATFORM-zlib mingw$ARCH/mingw-w64-$PLATFORM-pkg-config
- name: Inject slug/short variables
uses: rlespinasse/[email protected]
Expand Down Expand Up @@ -233,10 +233,9 @@ jobs:
- name: Deploy installer
if: ${{ matrix.deploy-installer && github.event_name != 'pull_request' && github.repository_owner == 'trikset' }}
run: |
INSTALLER_PATH=$(ls -1b installer/trik-studio*installer*.exe | head -n 1)
[ -r "$INSTALLER_PATH" ] || INSTALLER_PATH=/dev/null
export INSTALLER_PATH
echo "${{ secrets.DL_PASSWORD }}"| script -E never -q -c "rsync -ve 'ssh -o StrictHostKeyChecking=no' $INSTALLER_PATH ${{ secrets.DL_USERNAME }}@${{ secrets.DL_HOST }}:~/dl/ts/fresh/installer/trik-studio-${{ env.GITHUB_REF_SLUG }}-i686-installer.exe"
install -m 600 -D /dev/null ~/.ssh/id_rsa
echo "${{ secrets.DL_PRIVATE_SSH_KEY }}" > ~/.ssh/id_rsa
rsync -v --rsh="ssh -o StrictHostKeyChecking=no" installer/trik-studio*installer*.exe ${{ secrets.DL_USERNAME }}@${{ secrets.DL_HOST }}:~/dl/ts/fresh/installer/trik-studio-${{ env.GITHUB_REF_SLUG }}-i686-installer.exe
- name: Prepare for RDP connection
if: false #comment this line to create RDP session
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,8 @@ private slots:

void incrementTimelineCounter();

const QDomDocument loadXmlWithConversion(const QString &loadFileName) const;

Ui::TwoDModelWidget *mUi {};
QScopedPointer<TwoDModelScene> mScene;
QScopedPointer<ActionsBox> mActions;
Expand Down
57 changes: 39 additions & 18 deletions plugins/robots/common/twoDModel/src/engine/view/twoDModelWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -506,16 +506,7 @@ void TwoDModelWidget::loadWorldModel()
return;
}

QString errorMessage;
int errorLine = 0;
int errorColumn = 0;
const QDomDocument save = utils::xmlUtils::loadDocument(loadFileName, &errorMessage, &errorLine, &errorColumn);
if (!errorMessage.isEmpty()) {
mModel.errorReporter()->addError(QString("%1:%2: %3")
.arg(QString::number(errorLine), QString::number(errorColumn), errorMessage));
}

auto command = new commands::LoadWorldCommand(*this, save);
auto command = new commands::LoadWorldCommand(*this, loadXmlWithConversion(loadFileName));
if (mController) {
mController->execute(command);
}
Expand All @@ -528,14 +519,7 @@ void TwoDModelWidget::loadWorldModelWithoutRobot()
return;
}

QString errorMessage;
int errorLine = 0;
int errorColumn = 0;
QDomDocument save = utils::xmlUtils::loadDocument(loadFileName, &errorMessage, &errorLine, &errorColumn);
if (!errorMessage.isEmpty()) {
mModel.errorReporter()->addError(QString("%1:%2: %3")
.arg(QString::number(errorLine), QString::number(errorColumn), errorMessage));
}
QDomDocument save = loadXmlWithConversion(loadFileName);

auto newWorld = save.firstChildElement("root");
auto oldWorld = generateWorldModelXml().firstChildElement("root");
Expand Down Expand Up @@ -1131,3 +1115,40 @@ void TwoDModelWidget::incrementTimelineCounter()
{
mUi->timelineBox->stepBy(1);
}

const QDomDocument TwoDModelWidget::loadXmlWithConversion(const QString &loadFileName) const
{
QString errorMessage;
int errorLine = 0;
int errorColumn = 0;
const QDomDocument save = utils::xmlUtils::loadDocument(loadFileName, &errorMessage, &errorLine, &errorColumn);
if (!errorMessage.isEmpty()) {
mModel.errorReporter()->addError(QString("%1:%2: %3")
.arg(QString::number(errorLine), QString::number(errorColumn), errorMessage));
return save;
}

QDomElement root = save.firstChildElement("root");

QDomElement oldRobot = root.firstChildElement("robots").firstChildElement("robot");
if (oldRobot.hasAttribute("position") || oldRobot.hasAttribute("direction")
|| !oldRobot.firstChildElement("startPosition").isNull()) {
QDomElement world = root.firstChildElement("world");
if (world.isNull()) {
world = root.ownerDocument().createElement("world");
root.appendChild(world);
}

QDomElement robot = world.ownerDocument().createElement("robot");
robot.setAttribute("position", oldRobot.attribute("position", "0:0"));
robot.setAttribute("direction", oldRobot.attribute("direction", "0"));
robot.appendChild(oldRobot.firstChildElement("startPosition"));
world.appendChild(robot);

oldRobot.removeAttribute("position");
oldRobot.removeAttribute("direction");
// start position reparented automatically
}

return save;
}
8 changes: 4 additions & 4 deletions qrtranslations/fr/plugins/robots/twoDModel_fr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -763,22 +763,22 @@
<message>
<location line="+0"/>
<location line="+20"/>
<location line="+22"/>
<location line="+13"/>
<source>2D model saves (*.xml)</source>
<translation>Fichiers de sauvegarde du modèle 2D (*.xml) </translation>
</message>
<message>
<location line="-22"/>
<location line="-13"/>
<source>Loading world and robot model</source>
<translation>Chargement des modèles du monde et du robot</translation>
</message>
<message>
<location line="+22"/>
<location line="+13"/>
<source>Loading world without robot model</source>
<translation type="unfinished"></translation>
</message>
<message>
<location line="+316"/>
<location line="+309"/>
<source>Hide details</source>
<translation type="unfinished"></translation>
</message>
Expand Down
8 changes: 4 additions & 4 deletions qrtranslations/ru/plugins/robots/twoDModel_ru.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1106,17 +1106,17 @@
<message>
<location line="+0"/>
<location line="+20"/>
<location line="+22"/>
<location line="+13"/>
<source>2D model saves (*.xml)</source>
<translation>Файлы 2D модели (*.xml)</translation>
</message>
<message>
<location line="-22"/>
<location line="-13"/>
<source>Loading world and robot model</source>
<translation>Загрузка модели мира</translation>
</message>
<message>
<location line="+22"/>
<location line="+13"/>
<source>Loading world without robot model</source>
<translation>Загрузка модели мира без модели робота</translation>
</message>
Expand All @@ -1133,7 +1133,7 @@
<translation type="vanished">Попытка загрузить слишком большое изображение может заморозить выполнение на некоторое время. Продолжить?</translation>
</message>
<message>
<location line="+316"/>
<location line="+309"/>
<source>Hide details</source>
<translation>Скрыть детали</translation>
</message>
Expand Down

0 comments on commit 683154d

Please sign in to comment.