Skip to content

Commit

Permalink
Updated properties to scan corr coef dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
Arthur Glowacki committed Mar 17, 2023
1 parent 3ab901f commit 2bd4061
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 52 deletions.
63 changes: 11 additions & 52 deletions src/mvc/ScanCorrCoefDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
#include <mvc/ScanCorrCoefDialog.h>
#include <QDesktopServices>
#include "stats/correlation_coefficient.h"
//#include "core/GlobalThreadPool.h"
#include "mvc/ScatterPlotView.h"

//---------------------------------------------------------------------------
Expand Down Expand Up @@ -94,6 +93,15 @@ void ScanCorrCoefDialog::setRunEnabled(bool val)

//---------------------------------------------------------------------------

void ScanCorrCoefDialog::setViewProps(bool blog10, bool bdark, bool bgrid)
{
_blog10 = blog10;
_bdark = bdark;
_bgrid = bgrid;
}

//---------------------------------------------------------------------------

void ScanCorrCoefDialog::setModel(std::string analysis_type, MapsH5Model* model)
{
_model = model;
Expand Down Expand Up @@ -213,14 +221,13 @@ void ScanCorrCoefDialog::onRun()
int total = el_pair_names.size();
status_callback(0, total);

ScatterPlotView* view = new ScatterPlotView(true, true, nullptr);
ScatterPlotView* view = new ScatterPlotView(_blog10, _bdark, nullptr);
view->setGridLinesVisible(_bgrid);
view->setModel(_model);
view->setAnalysisType(QString(_analysis_type.c_str()));
int cur = 0;
//std::map<int, std::future<double> > job_queue;
for (int i = 0; i < el_pair_names.size(); i++)
{
//job_queue[i] = Global_Thread_Pool::inst()->enqueue([this, i, restrict_coef, el_pair_names] { return proc_corr_coef(_model, _analysis_type, restrict_coef, el_pair_names[i]); });
double val = proc_corr_coef(_model, _analysis_type, restrict_coef, el_pair_names[i]);
if (val > restrict_coef || val < -restrict_coef)
{
Expand All @@ -239,54 +246,6 @@ void ScanCorrCoefDialog::onRun()
}

delete view;
/*
while (job_queue.size() > 0)
{
status_callback(total - job_queue.size(), total);
QCoreApplication::processEvents();
std::vector<int> to_delete;
for (auto& itr : job_queue)
{
std::future_status status = itr.second.wait_for(std::chrono::milliseconds(10));
if (status == std::future_status::ready)
{
std::string key = el_pair_names[itr.first].first + '/' + el_pair_names[itr.first].second;
double val = 0.0;
try
{
val = itr.second.get();
}
catch (std::exception &e)
{
logE << e.what() << "\n";
}
//corr_coef_map[key] = val;
if (val > restrict_coef || val < -restrict_coef)
{
//foundCnt++;
logI << key << " : " << val << "\n";
ScatterPlotView* view = new ScatterPlotView(true, true, nullptr);
view->setModel(_model);
view->setAnalysisType(QString(_analysis_type.c_str()));
view->setXYAxis("", QString(el_pair_names[itr.first].first.c_str()), QString(el_pair_names[itr.first].second.c_str()));
view->resize(1920, 1080);
view->exportPngCsv();
delete view;
}
to_delete.push_back(itr.first);
}
}
for (const auto& itr : to_delete)
{
job_queue.erase(itr);
}
}
status_callback(total - job_queue.size(), total);
QCoreApplication::processEvents();
*/
}
_running = false;
_btn_run->setEnabled(true);
Expand Down
8 changes: 8 additions & 0 deletions src/mvc/ScanCorrCoefDialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ class ScanCorrCoefDialog : public QWidget

void status_callback(size_t cur, size_t total);

void setViewProps(bool blog10, bool bdark, bool bgrid);

void setRunEnabled(bool val);

void setModel(std::string analysis_type, MapsH5Model* model);
Expand Down Expand Up @@ -89,6 +91,12 @@ public slots:

std::string _analysis_type;

bool _blog10;

bool _bdark;

bool _bgrid;

bool _running;

};
Expand Down
1 change: 1 addition & 0 deletions src/mvc/ScatterPlotWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,7 @@ void ScatterPlotWidget::onSavePng()
void ScatterPlotWidget::onScan()
{
_scan_corr_coef_dialog.setModel(_plot_view_list[0]->getAnalysisType().toStdString(), _plot_view_list[0]->getModel());
_scan_corr_coef_dialog.setViewProps(_ck_display_log10->isChecked(), _ck_black_background->isChecked(), _ck_display_grid_lines->isChecked());
_scan_corr_coef_dialog.show();
}

Expand Down

0 comments on commit 2bd4061

Please sign in to comment.