Skip to content

Commit

Permalink
fmk - bug fix, fixing segmentation fault with RecordSelectionPlot des…
Browse files Browse the repository at this point in the history
…tructor
  • Loading branch information
fmckenna committed Jul 1, 2024
1 parent 8c71115 commit 09a0396
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 8 deletions.
1 change: 0 additions & 1 deletion EVENTS/peerNGA/PEER_NGA_Records.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
PEER_NGA_Records::PEER_NGA_Records(GeneralInformationWidget* generalInfoWidget, QWidget *parent) : SimCenterAppWidget(parent), groundMotionsFolder(QDir::tempPath())
{
setupUI(generalInfoWidget);

setupConnections();
}

Expand Down
44 changes: 38 additions & 6 deletions EVENTS/peerNGA/RecordSelectionPlot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,13 @@
#include <QPushButton>
#include <QtCharts/QLegendMarker>

RecordSelectionPlot::RecordSelectionPlot(QWidget *parent) : QWidget(parent)
RecordSelectionPlot::RecordSelectionPlot(QWidget *parent) :
QWidget(parent),
addMean(false),addPlus(false),addMinus(false), addTarget(false)
{
QVBoxLayout* layout = new QVBoxLayout(this);

spectraChart.setTitle("Response Spectra");
spectraChart.addSeries(&meanSeries);
spectraChart.addSeries(&plusSigmaSeries);
spectraChart.addSeries(&minusSigmaSeries);
spectraChart.addSeries(&targetSeries);

QPen meanPen;
meanPen.setColor(Qt::black);
Expand Down Expand Up @@ -73,10 +71,28 @@ RecordSelectionPlot::RecordSelectionPlot(QWidget *parent) : QWidget(parent)

this->setMinimumWidth(200);
this->setMinimumHeight(200);

}


RecordSelectionPlot::~RecordSelectionPlot() {
meanSeries.clear();
plusSigmaSeries.clear();
minusSigmaSeries.clear();
targetSeries.clear();
spectraChart.removeSeries(&meanSeries);
spectraChart.removeSeries(&plusSigmaSeries);
spectraChart.removeSeries(&minusSigmaSeries);
spectraChart.removeSeries(&targetSeries);
}

void RecordSelectionPlot::setMean(QVector<double> periods, QVector<double> sa)
{
if (addMean == false) {
addMean = true;
spectraChart.addSeries(&meanSeries);
}

meanSeries.clear();

for(int i = 0; i < periods.size(); i++)
Expand All @@ -97,7 +113,11 @@ void RecordSelectionPlot::setMean(QVector<double> periods, QVector<double> sa)

void RecordSelectionPlot::setMeanPlusSigma(QVector<double> periods, QVector<double> sa)
{
plusSigmaSeries.clear();
if (addPlus == false) {
addPlus = true;
spectraChart.addSeries(&plusSigmaSeries);
}
plusSigmaSeries.clear();

for(int i = 0; i < periods.size(); i++)
{
Expand All @@ -108,6 +128,10 @@ void RecordSelectionPlot::setMeanPlusSigma(QVector<double> periods, QVector<doub

void RecordSelectionPlot::setMeanMinusSigma(QVector<double> periods, QVector<double> sa)
{
if (addMinus == false) {
addMinus = true;
spectraChart.addSeries(&minusSigmaSeries);
}
minusSigmaSeries.clear();

for(int i = 0; i < periods.size(); i++)
Expand All @@ -119,6 +143,14 @@ void RecordSelectionPlot::setMeanMinusSigma(QVector<double> periods, QVector<dou

void RecordSelectionPlot::setTargetSpectrum(QVector<double> periods, QVector<double> sa)
{

if (addTarget == false) {
addTarget = true;
spectraChart.addSeries(&targetSeries);
/*
spectraChart.addSeries(&plusSigmaSeries);
*/
}
targetSeries.clear();

for(int i = 0; i < periods.size(); i++)
Expand Down
6 changes: 5 additions & 1 deletion EVENTS/peerNGA/RecordSelectionPlot.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ class RecordSelectionPlot : public QWidget
Q_OBJECT
public:
explicit RecordSelectionPlot(QWidget *parent = nullptr);
~RecordSelectionPlot();
void setMean(QVector<double> periods, QVector<double> sa);
void setMeanPlusSigma(QVector<double> periods, QVector<double> sa);
void setMeanMinusSigma(QVector<double> periods, QVector<double> sa);
Expand Down Expand Up @@ -43,7 +44,10 @@ public slots:
QtCharts::QLogValueAxis yAxis;
QList<QtCharts::QLineSeries*> currentSelectedSeries;
#endif

bool addMean;
bool addPlus;
bool addMinus;
bool addTarget;
};

#endif // RECORDSELECTIONPLOT_H

0 comments on commit 09a0396

Please sign in to comment.