Skip to content

Commit 242fc3e

Browse files
committed
keep previous fits
1 parent 1f2dba7 commit 242fc3e

5 files changed

+46
-9
lines changed

constants.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
#define REV_SEG_FAILURE -96
1313
#define FILE_FAILURE -95
1414
//app version
15-
const QString VERSION = "1.2";
15+
const QString VERSION = "1.3";
1616
//dcca fluctuation vector
1717
const std::string defaultDCCA = "abs";
1818
const std::string corrDCCA = "sign";
@@ -43,6 +43,7 @@ const QString strRHODCCA = "rhoDCCA";
4343
const QString dataFilter = "*.txt *.dat *.csv";
4444
//plots colours
4545
const QVector<QColor> colours = {Qt::red, Qt::blue, Qt::green, Qt::black, Qt::magenta, Qt::cyan};
46+
const QVector<Qt::PenStyle> lineStyles = {Qt::SolidLine, Qt::DashLine, Qt::DotLine, Qt::DashDotLine, Qt::DashDotDotLine};
4647
//font dimensions
4748
const int fontBig = 14;
4849
const int fontSmall = 12;

plot_window.cpp

+10-4
Original file line numberDiff line numberDiff line change
@@ -199,11 +199,11 @@ void PlotWindow::onRefitClick()
199199
refitWin->setWindowModality(Qt::ApplicationModal);
200200
refitWin->show();
201201
disableButtons();
202-
connect(refitWin, SIGNAL(inputsInserted(int, int)), this, SLOT(newFitPlot(int, int)));
202+
connect(refitWin, SIGNAL(inputsInserted(int, int, int, int)), this, SLOT(newFitPlot(int, int, int, int)));
203203
connect(refitWin, SIGNAL(destroyed()), this, SLOT(enableButtons()));
204204
}
205205

206-
void PlotWindow::newFitPlot(int start, int end)
206+
void PlotWindow::newFitPlot(int start, int end, int keep, int clear)
207207
{
208208
if(end < start){
209209
int tmp = end;
@@ -212,8 +212,13 @@ void PlotWindow::newFitPlot(int start, int end)
212212
}
213213
double HIntercept = 0.0, H = 0.0;
214214
refitData(start, end, &H, &HIntercept);
215-
for(int i = 1; i < plt->graphCount(); i++)
216-
plt->removeGraph(i);
215+
if(clear == 1){
216+
for(int i = 1; i < plt->graphCount(); i++)
217+
plt->removeGraph(i);
218+
}
219+
if(keep == 0 && plt->graphCount() != 1){
220+
plt->removeGraph(plt->graphCount()-1);
221+
}
217222
int len = end - start + 1;
218223
QVector<double> n(len), Hfit(len);
219224
for(int i = 0; i < len; i++){
@@ -224,6 +229,7 @@ void PlotWindow::newFitPlot(int start, int end)
224229
plt->graph(plt->graphCount()-1)->setData(n, Hfit);
225230
QPen pen;
226231
pen.setWidth(2);
232+
pen.setStyle(lineStyles[(plt->graphCount()-1)%lineStyles.size()]);
227233
plt->graph(plt->graphCount()-1)->setPen(pen);
228234
plt->graph(plt->graphCount()-1)->setName("H = "+QString::number(H));
229235
plt->graph(plt->graphCount()-1)->rescaleAxes(true);

plot_window.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ private slots:
3434
void onReplotClick();
3535
void onSavePlotClick();
3636
virtual void onSaveTxtClick();
37-
void newFitPlot(int start, int end);
37+
void newFitPlot(int start, int end, int keep, int clear);
3838
void enableButtons();
3939
private:
4040
void addButtons();

refit_window.cpp

+26-2
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,25 @@ RefitWindow::RefitWindow(QWidget *parent) : QWidget(parent)
2525
maxWin->setGeometry(2*padX+5*xWidth, padY, xWidth, yHeight);
2626
maxWinTxt = new QLineEdit(this);
2727
maxWinTxt->setGeometry(4*padX+5*xWidth, padY, xWidth, yHeight);
28+
//checkboxes
29+
keepFits = new QCheckBox(this);
30+
keepFits->setGeometry(padX, padY*2+yHeight, xWidth, yHeight*2/3);
31+
connect(keepFits, SIGNAL(clicked()), this, SLOT(onKeepFitsClick()));
32+
keepTxt = new QLabel("Keep previous fit", this);
33+
keepTxt->setGeometry(padX+xWidth, padY*2+yHeight, xWidth*4, yHeight*2/3);
34+
clearFits = new QCheckBox(this);
35+
clearFits->setGeometry(padX, padY*3+yHeight*5/3, xWidth, yHeight*2/3);
36+
connect(clearFits, SIGNAL(clicked()), this, SLOT(onClearFitsClick()));
37+
clearTxt = new QLabel("Clear previous fits", this);
38+
clearTxt->setGeometry(padX+xWidth, padY*3+yHeight*5/3, xWidth*4, yHeight*2/3);
2839
}
2940

3041
RefitWindow::~RefitWindow(){}
3142

3243
void RefitWindow::setDimensions()
3344
{
3445
xDim = 240;
35-
yDim = 80;
46+
yDim = 120;
3647
xWidth = 30;
3748
yHeight = 30;
3849
padX = 10;
@@ -46,7 +57,10 @@ void RefitWindow::onOKClick()
4657
QRegExp rgx("^[0-9]+$");
4758
if((!win1.isEmpty() && win1.contains(rgx)) &&
4859
(!win2.isEmpty() && win2.contains(rgx))){
49-
emit inputsInserted(win1.toInt(), win2.toInt());
60+
int k, c;
61+
keepFits->isChecked() ? k = 1 : k = 0;
62+
clearFits->isChecked() ? c = 1 : c = 0;
63+
emit inputsInserted(win1.toInt(), win2.toInt(), k, c);
5064
close();
5165
}else{
5266
QMessageBox messageBox;
@@ -55,3 +69,13 @@ void RefitWindow::onOKClick()
5569
messageBox.setFixedSize(ERROR_BOX_SIZE, ERROR_BOX_SIZE);
5670
}
5771
}
72+
73+
void RefitWindow::onKeepFitsClick()
74+
{
75+
clearFits->setChecked(false);
76+
}
77+
78+
void RefitWindow::onClearFitsClick()
79+
{
80+
keepFits->setChecked(false);
81+
}

refit_window.h

+7-1
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,11 @@ Q_OBJECT
1111
explicit RefitWindow(QWidget *parent=nullptr);
1212
~RefitWindow();
1313
signals:
14-
void inputsInserted(int mw, int Mw);
14+
void inputsInserted(int mw, int Mw, int keep, int clear);
1515
private slots:
1616
void onOKClick();
17+
void onKeepFitsClick();
18+
void onClearFitsClick();
1719
private:
1820
void setDimensions();
1921

@@ -23,6 +25,10 @@ private slots:
2325
QLabel *maxWin;
2426
QLineEdit *minWinTxt;
2527
QLineEdit *maxWinTxt;
28+
QLabel *keepTxt;
29+
QCheckBox *keepFits;
30+
QLabel *clearTxt;
31+
QCheckBox *clearFits;
2632

2733
int xDim;
2834
int yDim;

0 commit comments

Comments
 (0)