Skip to content

Commit

Permalink
fix: recessions
Browse files Browse the repository at this point in the history
  • Loading branch information
iffse committed Jun 26, 2023
1 parent 8520de3 commit dbbeaa1
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 19 deletions.
2 changes: 1 addition & 1 deletion src-qml/RecessionPanel.qml
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ ApplicationWindow {
Button {
text: qsTr("Save")
onClicked: {
actions.updateRecession(textArea.text, saveToFile.checked, savePretty.checked);
actions.updateRecessions(textArea.text, saveToFile.checked, savePretty.checked);
}
}
CheckBox {
Expand Down
32 changes: 14 additions & 18 deletions src/interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -415,18 +415,18 @@ void Actions::updateRecessions(QString recessions, bool save, bool pretty) {
return;
}
auto recessionsList = recessions.split("\n");
if (recessionsList[0].split(" ").size() == 3) {
if (recessionsList[0].simplified().split(" ").size() == 3) {
recessionAnisotropic = vector<array<double, 3>>(numNodes, {0, 0, 0});
anisotropic = true;
for (uint node = 0; node < numNodes; ++node) {
auto values = recessionsList[node].split(" ");
auto values = recessionsList[node].simplified().split(" ");
recessionAnisotropic[node][0] = values[0].toDouble();
recessionAnisotropic[node][1] = values[1].toDouble();
recessionAnisotropic[node][2] = values[2].toDouble();
}
appendOutput("Recessions updated to anisotropic");
return;
} else if (recessionsList[0].split(" ").size() == 1) {
} else if (recessionsList[0].simplified().split(" ").size() == 1) {
recession = vector<double>(numNodes);
anisotropic = false;
recessionAnisotropic.clear();
Expand All @@ -444,22 +444,18 @@ void Actions::updateRecessions(QString recessions, bool save, bool pretty) {
appendOutput("Error while updating recessions");
}

try {
if (save){
auto filepath = root->findChild<QObject*>("fileDialog")->property("fileUrl").toString();
clearSubstring(filepath);

try {
Writer::Json::updateRecessions(filepath, pretty);
appendOutput("Updated to " + filepath);
} catch (const std::exception &e) {
appendOutput("Error while updating boundaries: " + QString(e.what()));
} catch (...) {
appendOutput("Error while updating boundaries");
}
if (save){
auto filepath = root->findChild<QObject*>("fileDialog")->property("fileUrl").toString();
clearSubstring(filepath);

try {
Writer::Json::updateRecessions(filepath, pretty);
appendOutput("Updated to " + filepath);
} catch (const std::exception &e) {
appendOutput("Error while updating boundaries: " + QString(e.what()));
} catch (...) {
appendOutput("Error while updating boundaries");
}
}catch(...) {

}
}

Expand Down

0 comments on commit dbbeaa1

Please sign in to comment.