Skip to content

Commit

Permalink
Merge branch 'master' of github.com:mbsim-env/mbsim
Browse files Browse the repository at this point in the history
  • Loading branch information
friedrichatgc committed Sep 11, 2024
2 parents 4244a6a + 2d6d9c4 commit ecc7ea9
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 12 deletions.
2 changes: 1 addition & 1 deletion mbsimgui/RELEASENOTES.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Release NEXT
Release 10.3
============

All
Expand Down
2 changes: 1 addition & 1 deletion mbsimgui/configure.ac
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
dnl Process this file with autoconf to produce a configure script.
AC_PREREQ([2.57])
AC_INIT([mbsimgui],[10.2],[[email protected]])
AC_INIT([mbsimgui],[10.3],[[email protected]])
AC_CONFIG_HEADER(config.h)
AM_INIT_AUTOMAKE([subdir-objects])
AC_CONFIG_SRCDIR([mbsimgui/body.h])
Expand Down
22 changes: 14 additions & 8 deletions mbsimgui/mbsimgui/mainwindow.cc
Original file line number Diff line number Diff line change
Expand Up @@ -839,7 +839,7 @@ namespace MBSimGUI {
IDcounter = 0;

doc = impl->createDocument();
doc->setDocumentURI(X()%QUrl::fromLocalFile(QDir::currentPath()+"/Project.mbsx").toString().toStdString());
doc->setDocumentURI(X()%QDir::current().absoluteFilePath("Project.mbsx").toStdString());

project = new Project;
project->createXMLElement(doc);
Expand All @@ -863,9 +863,13 @@ namespace MBSimGUI {
list << fileInfoList.at(i).baseName();
}
NewProjectFromTemplateDialog dialog(list,this);
if(dialog.exec())
loadProject(fileInfoList.at(dialog.getSelectedRow()).absoluteFilePath(),false);
doc->setDocumentURI(X()%QUrl::fromLocalFile(QDir::currentPath()+"/Project.mbsx").toString().toStdString());
if(dialog.exec()) {
auto file = fileInfoList.at(dialog.getSelectedRow()).absoluteFilePath();
if(file.startsWith("//"))
file.replace('/','\\'); // xerces-c is not able to parse files from network shares that begin with "//"
loadProject(file,false);
}
doc->setDocumentURI(X()%QDir::current().absoluteFilePath("Project.mbsx").toStdString());
}

void MainWindow::loadProject(const QString &fileName, bool updateRecent) {
Expand Down Expand Up @@ -958,7 +962,9 @@ namespace MBSimGUI {
QString file=QFileDialog::getSaveFileName(this, "Save MBSim file", getProjectFilePath(), "MBSim files (*.mbsx)");
if(not(file.isEmpty())) {
file = file.endsWith(".mbsx")?file:file+".mbsx";
doc->setDocumentURI(X()%QUrl::fromLocalFile(file).toString().toStdString());
if(file.startsWith("//"))
file.replace('/','\\'); // xerces-c is not able to parse files from network shares that begin with "//"
doc->setDocumentURI(X()%file.toStdString());
projectFile = QDir::current().relativeFilePath(file);
setCurrentProjectFile(file);
setWindowTitle(projectFile+"[*]");
Expand Down Expand Up @@ -2730,9 +2736,9 @@ namespace MBSimGUI {
for (int i = 0; i < event->mimeData()->urls().size(); i++) {
QString path = event->mimeData()->urls()[i].toLocalFile().toLocal8Bit().data();
if(path.endsWith(".mbsx")) {
QFile Fout(path);
if (Fout.exists())
loadProject(Fout.fileName());
if(path.startsWith("//"))
path.replace('/','\\'); // xerces-c is not able to parse files from network shares that begin with "//"
loadProject(path);
}
}
}
Expand Down
6 changes: 4 additions & 2 deletions mbsimgui/mbsimgui/variable_widgets.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1321,8 +1321,10 @@ namespace MBSimGUI {
}

vector<vector<QString>> FromFileWidget::getEvalMat() const {
string file = mw->eval->cast<MBXMLUtils::CodeString>(mw->eval->stringToValue((path->isChecked()?getFile():mw->getProjectDir().absoluteFilePath(getFile())).toStdString(),mw->getProject()->getXMLElement(),false));
QString str = QString::fromStdString(mw->eval->cast<MBXMLUtils::CodeString>(mw->eval->stringToValue("ret=load(" + file + ")",mw->getProject()->getXMLElement())));
vector<MBXMLUtils::Eval::Value> args(1);
args[0] = mw->eval->stringToValue((path->isChecked()?getFile():mw->getProjectDir().absoluteFilePath(getFile())).toStdString(),mw->getProject()->getXMLElement(),false);
auto ret = mw->eval->callFunction("load",args);
auto str = QString::fromStdString(mw->eval->cast<MBXMLUtils::CodeString>(ret));
str = removeWhiteSpace(str);
return strToMat((str));
}
Expand Down

0 comments on commit ecc7ea9

Please sign in to comment.