Skip to content

Commit

Permalink
Updated scatter plot to append or replace a QList. Enabled OpenGL aga…
Browse files Browse the repository at this point in the history
…in for performance
  • Loading branch information
Arthur Glowacki committed Jul 11, 2024
1 parent d6e5b30 commit e9f4019
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/mvc/ScanCorrCoefDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ void ScanCorrCoefDialog::onRun()
{
bool use_elements = _ck_use_elements->isChecked();
bool use_scalers = _ck_use_scalers->isChecked();
bool use_rois = _ck_use_rois->isChecked();
//bool use_rois = _ck_use_rois->isChecked();

std::vector<std::string> total_names;
std::vector<std::pair<std::string, std::string>> el_pair_names;
Expand Down
19 changes: 14 additions & 5 deletions src/mvc/ScatterPlotView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ ScatterPlotView::ScatterPlotView(bool display_log10, bool black_background, QWid
val = 1;
}
_scatter_series->setMarkerSize(val);
//_scatter_series->setUseOpenGL(true); // causes exception when deconstructor called.
_scatter_series->setUseOpenGL(true); // causes exception when deconstructor called.
_chart->addSeries(_scatter_series);
_display_log10 = display_log10;
if (_display_log10)
Expand Down Expand Up @@ -496,7 +496,6 @@ void ScatterPlotView::_updatePlot()
if (_getXY_Maps(x_map, y_map))
{
_chart->removeSeries(_scatter_series);
_scatter_series->clear();

if (_display_log10)
{
Expand Down Expand Up @@ -536,18 +535,28 @@ void ScatterPlotView::_updatePlot()
x_arr.resize(x_map.cols() * x_map.rows());
y_arr.resize(x_map.cols() * x_map.rows());
int n = 0;

QList<QPointF> plist;
for (int y = 0; y < x_map.rows(); y++)
{
for (int x = 0; x < x_map.cols(); x++)
{
x_arr(n) = (double)x_map(y, x);
y_arr(n) = (double)y_map(y, x);
_scatter_series->append(x_map(y,x), y_map(y,x));
plist.append(QPointF(x_map(y,x),y_map(y,x)));
n++;
}
}

int namt = x_map.size() * y_map.size();
int oamt = _scatter_series->points().size();
if(namt != oamt)
{
_scatter_series->clear();
_scatter_series->append(plist);
}
else
{
_scatter_series->replace(plist);
}
double corr_coef = find_coefficient(x_arr, y_arr);
_lb_corr_coef->setText(QString::number(corr_coef));
_scatter_series->setBorderColor(Qt::transparent);
Expand Down

0 comments on commit e9f4019

Please sign in to comment.