From f1998f336356c7e812392d6009ffc7cea6439c9c Mon Sep 17 00:00:00 2001 From: Oscar Saleta Date: Thu, 12 Jul 2018 16:07:29 +0200 Subject: [PATCH] fix #61 (at least for now no issues have been found) and fix #62 (VFs are loaded even for piecewise data, no more segfaults when trying to add new VFs after loading) --- QtCreator/p4/P4InputVF.cpp | 41 ++++++++++---------------- QtCreator/p4/P4SeparatingCurvesDlg.cpp | 11 ++++--- QtCreator/p4/P4VectorFieldDlg.cpp | 9 ++++-- 3 files changed, 29 insertions(+), 32 deletions(-) diff --git a/QtCreator/p4/P4InputVF.cpp b/QtCreator/p4/P4InputVF.cpp index c19ad27a..12d80eec 100644 --- a/QtCreator/p4/P4InputVF.cpp +++ b/QtCreator/p4/P4InputVF.cpp @@ -543,18 +543,6 @@ bool P4InputVF::load() curveRegions_.emplace_back(indx, std::move(sgns)); } - numeric_.clear(); - precision_.clear(); - epsilon_.clear(); - testsep_.clear(); - taylorlevel_.clear(); - numericlevel_.clear(); - maxlevel_.clear(); - weakness_.clear(); - xdot_.clear(); - ydot_.clear(); - gcf_.clear(); - // parvalue_.clear(); for (unsigned int k = 0; k < numVF_; k++) { if (fscanf(fp, "%d\n", &flag_numeric) != 1 || fscanf(fp, "%d\n", &aux) != 1 || @@ -564,38 +552,38 @@ bool P4InputVF::load() fclose(fp); return false; } else { - numeric_.push_back(((flag_numeric == 0) ? false : true)); - precision_.push_back(aux); - epsilon_.emplace_back(scanbuf); - testsep_.push_back(((flag_testsep == 0) ? false : true)); + numeric_[k] = ((flag_numeric == 0) ? false : true); + precision_[k] = aux; + epsilon_[k] = QString{scanbuf}; + testsep_[k] = ((flag_testsep == 0) ? false : true); } if (fscanf(fp, "%d\n", &aux) != 1) { reset(1); fclose(fp); return false; } else { - taylorlevel_.push_back(aux); + taylorlevel_[k] = aux; } if (fscanf(fp, "%d\n", &aux) != 1) { reset(1); fclose(fp); return false; } else { - numericlevel_.push_back(aux); + numericlevel_[k] = aux; } if (fscanf(fp, "%d\n", &aux) != 1) { reset(1); fclose(fp); return false; } else { - maxlevel_.push_back(aux); + maxlevel_[k] = aux; } if (fscanf(fp, "%d\n", &aux) != 1) { reset(1); fclose(fp); return false; } else { - weakness_.push_back(aux); + weakness_[k] = aux; } if (fscanf(fp, "%[^\n]\n", scanbuf) != 1) { @@ -603,19 +591,19 @@ bool P4InputVF::load() fclose(fp); return false; } - xdot_.emplace_back(scanbuf); + xdot_[k] = QString{scanbuf}; if (fscanf(fp, "%[^\n]\n", scanbuf) != 1) { reset(1); fclose(fp); return false; } - ydot_.emplace_back(scanbuf); + ydot_[k] = QString{scanbuf}; if (fscanf(fp, "%[^\n]\n", scanbuf) != 1) { reset(1); fclose(fp); return false; } - gcf_.emplace_back(scanbuf); + gcf_[k] = QString{scanbuf}; if (xdot_[k] == "(null)") xdot_[k] = ""; @@ -636,10 +624,13 @@ bool P4InputVF::load() auxvec.emplace_back(scanbuf); } parvalue_[k] = auxvec; - /*for (i = numParams_; i < MAXNUMPARAMS; i++) - parvalue_[k].push_back(QString{});*/ + for (unsigned int i = numParams_; i < MAXNUMPARAMS; i++) + parvalue_[k].push_back(QString{}); } } + selected_.clear(); + selected_.push_back(0); + numSelected_ = 1; fclose(fp); diff --git a/QtCreator/p4/P4SeparatingCurvesDlg.cpp b/QtCreator/p4/P4SeparatingCurvesDlg.cpp index 2b68b5ce..b7ab1922 100644 --- a/QtCreator/p4/P4SeparatingCurvesDlg.cpp +++ b/QtCreator/p4/P4SeparatingCurvesDlg.cpp @@ -30,10 +30,10 @@ #include "P4Application.hpp" #include "P4FindDlg.hpp" +#include "P4InputSphere.hpp" #include "P4InputVF.hpp" #include "P4ParentStudy.hpp" #include "P4ViewDlg.hpp" -#include "P4InputSphere.hpp" #include "main.hpp" P4SeparatingCurvesDlg::P4SeparatingCurvesDlg(P4FindDlg *parent) @@ -184,10 +184,13 @@ P4SeparatingCurvesDlg::P4SeparatingCurvesDlg(P4FindDlg *parent) QObject::connect(edt_numpoints_, &QLineEdit::editingFinished, this, &P4SeparatingCurvesDlg::onNumpointsEditingFinished); + QObject::connect(gThisVF, &P4InputVF::loadSignal, this, + &P4SeparatingCurvesDlg::updateDlgData); + #ifdef TOOLTIPS - btn_add_->setToolTip( - "Adds a new separating curve to the list.\nEnter a Maple expression " - "after pressing the button."); + btn_add_->setToolTip("Adds a new separating curve to the list.\nEnter " + "a Maple expression " + "after pressing the button."); btn_del_->setToolTip( "Deletes the selected separating curve from the list."); btn_edit_->setToolTip("Edits the separating curve Maple expression."); diff --git a/QtCreator/p4/P4VectorFieldDlg.cpp b/QtCreator/p4/P4VectorFieldDlg.cpp index fa406c09..d2b45f48 100644 --- a/QtCreator/p4/P4VectorFieldDlg.cpp +++ b/QtCreator/p4/P4VectorFieldDlg.cpp @@ -202,9 +202,12 @@ void P4VectorFieldDlg::getDataFromDlg() void P4VectorFieldDlg::updateDlgData() { - edt_xprime_->setText(gThisVF->xdot_.back()); - edt_yprime_->setText(gThisVF->ydot_.back()); - edt_gcf_->setText(gThisVF->gcf_.back()); + if (!gThisVF->xdot_.empty()) + edt_xprime_->setText(gThisVF->xdot_[0]); + if (!gThisVF->ydot_.empty()) + edt_yprime_->setText(gThisVF->ydot_[0]); + if (!gThisVF->gcf_.empty()) + edt_gcf_->setText(gThisVF->gcf_[0]); // setLineEditCommonValue(edt_xprime_, gThisVF->xdot_); // setLineEditCommonValue(edt_yprime_, gThisVF->ydot_); // setLineEditCommonValue(edt_gcf_, gThisVF->gcf_);