Skip to content

Commit

Permalink
Fixed missing comma when exporting scatter plot. Export scatter plot …
Browse files Browse the repository at this point in the history
…to ouput/ScatterPlot folder
  • Loading branch information
Arthur Glowacki committed Jul 11, 2024
1 parent 348d984 commit d6e5b30
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 11 deletions.
13 changes: 13 additions & 0 deletions src/mvc/ScanCorrCoefDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ double proc_corr_coef(MapsH5Model* model, std::string analysis_type, double rest
{
data_struct::ArrayXXr<float> x_map;
data_struct::ArrayXXr<float> y_map;
assert(model != nullptr);

data_struct::Fit_Count_Dict<float> fit_counts;
model->getAnalyzedCounts(analysis_type, fit_counts);
Expand Down Expand Up @@ -282,9 +283,21 @@ void ScanCorrCoefDialog::onRun()
}
//}
delete view;

QDir dir = _model->getDir();
dir.cdUp();
dir.cdUp();
dir.cd("output");
dir.mkdir(STR_SCATTER_PLOT);
dir.cd(STR_SCATTER_PLOT);
if (false == QDesktopServices::openUrl(QUrl::fromLocalFile(dir.absolutePath())))
{
logE << "Failed to open dir " << dir.absolutePath().toStdString() << "\n";
}
}
_running = false;
_btn_run->setEnabled(true);
close();

}

Expand Down
2 changes: 1 addition & 1 deletion src/mvc/ScanCorrCoefDialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
#include "mvc/MapsH5Model.h"

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

const QString STR_SCATTER_PLOT = "ScatterPlot";

class ScanCorrCoefDialog : public QWidget
{
Expand Down
11 changes: 3 additions & 8 deletions src/mvc/ScatterPlotView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,8 @@ void ScatterPlotView::exportPngCsv()
dir.cdUp();
dir.cdUp();
dir.cd("output");
dir.mkdir(STR_SCATTER_PLOT);
dir.cd(STR_SCATTER_PLOT);

QString roi_name = _cb_roi->currentText();
QString apath;
Expand All @@ -174,13 +176,6 @@ void ScatterPlotView::exportPngCsv()
{
logE << "Could not save PNG for " << png_path.toStdString() << "\n";
}
else
{
if (false == QDesktopServices::openUrl(QUrl::fromLocalFile(dir.absolutePath())))
{
logE << "Failed to open dir " << dir.absolutePath().toStdString() << "\n";
}
}

QString csv_path = QDir::cleanPath(apath + ".csv");
_exportScatterPlotCSV(csv_path);
Expand Down Expand Up @@ -236,7 +231,7 @@ void ScatterPlotView::_exportScatterPlotCSV(QString filePath)
{
for (int x = 0; x < x_map.cols(); x++)
{
out_stream << x << "," << y << "," << x_map(y, x) << "," << y_map(y, x) << x_motor[x] << ","<< y_motor[y]<< "\n";
out_stream << x << "," << y << "," << x_map(y, x) << "," << y_map(y, x) << "," << x_motor[x] << ","<< y_motor[y]<< "\n";
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/mvc/ScatterPlotView.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ class ScatterPlotView : public QWidget

void setModel(MapsH5Model* model);

MapsH5Model* getModel() { return _model;}

void setAnalysisType(QString curAnalysis);

void setQuantType(QString curAnalysis);
Expand All @@ -55,8 +57,6 @@ class ScatterPlotView : public QWidget

void exportPngCsv();

MapsH5Model* getModel() { return _model; }

QString getAnalysisType() { return _curAnalysis; }

void setXYAxis(QString roi_name, QString x_axis_name, QString y_axis_name);
Expand Down
14 changes: 14 additions & 0 deletions src/mvc/ScatterPlotWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,20 @@ void ScatterPlotWidget::onSavePng()
{
itr->exportPngCsv();
}
MapsH5Model* model = _plot_view_list.front()->getModel();
if(model != nullptr)
{
QDir dir = model->getDir();
dir.cdUp();
dir.cdUp();
dir.cd("output");
dir.mkdir(STR_SCATTER_PLOT);
dir.cd(STR_SCATTER_PLOT);
if (false == QDesktopServices::openUrl(QUrl::fromLocalFile(dir.absolutePath())))
{
logE << "Failed to open dir " << dir.absolutePath().toStdString() << "\n";
}
}
}

//---------------------------------------------------------------------------
Expand Down

0 comments on commit d6e5b30

Please sign in to comment.