Format all files
This commit is contained in:
@@ -38,29 +38,29 @@
|
||||
* Derek Christ
|
||||
*/
|
||||
|
||||
#include <QFileInfo>
|
||||
#include <QtAlgorithms>
|
||||
#include <QPainter>
|
||||
#include <QDebug>
|
||||
#include <stdio.h>
|
||||
#include <iostream>
|
||||
#include <QApplication>
|
||||
#include <QFile>
|
||||
#include <QTextStream>
|
||||
#include <QFileDialog>
|
||||
#include "evaluationtool.h"
|
||||
#include "ui_evaluationtool.h"
|
||||
#include <QApplication>
|
||||
#include <QDebug>
|
||||
#include <QFile>
|
||||
#include <QFileDialog>
|
||||
#include <QFileInfo>
|
||||
#include <QPainter>
|
||||
#include <QTextStream>
|
||||
#include <QtAlgorithms>
|
||||
#include <iostream>
|
||||
#include <stdio.h>
|
||||
|
||||
EvaluationTool::EvaluationTool(PythonCaller &pythonCaller, QWidget *parent) :
|
||||
EvaluationTool::EvaluationTool(PythonCaller& pythonCaller, QWidget* parent) :
|
||||
QWidget(parent),
|
||||
ui(new Ui::EvaluationTool), pythonCaller(pythonCaller)
|
||||
ui(new Ui::EvaluationTool),
|
||||
pythonCaller(pythonCaller)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
traceFilesModel = new QStandardItemModel(this);
|
||||
ui->listView->setModel(traceFilesModel);
|
||||
selectMetrics = new SelectMetrics(this);
|
||||
QObject::connect(selectMetrics, SIGNAL(getSelectedMetrics()), this,
|
||||
SLOT(getSelectedMetrics()));
|
||||
QObject::connect(selectMetrics, SIGNAL(getSelectedMetrics()), this, SLOT(getSelectedMetrics()));
|
||||
}
|
||||
|
||||
EvaluationTool::~EvaluationTool()
|
||||
@@ -88,9 +88,11 @@ void EvaluationTool::showAndEvaluateMetrics(QList<QString> paths)
|
||||
std::vector<std::string> EvaluationTool::getMetrics()
|
||||
{
|
||||
std::vector<std::string> metrics;
|
||||
for (int row = 0; row < traceFilesModel->rowCount(); ++row) {
|
||||
TraceFileItem *item = static_cast<TraceFileItem *>(traceFilesModel->item(row));
|
||||
std::vector<std::string> result = PythonCaller::availableMetrics(item->getPath().toStdString());
|
||||
for (int row = 0; row < traceFilesModel->rowCount(); ++row)
|
||||
{
|
||||
TraceFileItem* item = static_cast<TraceFileItem*>(traceFilesModel->item(row));
|
||||
std::vector<std::string> result =
|
||||
PythonCaller::availableMetrics(item->getPath().toStdString());
|
||||
if (result.size() > metrics.size()) // TODO use std::set
|
||||
metrics = result;
|
||||
}
|
||||
@@ -106,11 +108,12 @@ void EvaluationTool::cleanUpUI()
|
||||
|
||||
void EvaluationTool::fillFileList(QList<QString> paths)
|
||||
{
|
||||
std::sort(paths.begin(), paths.end(), [] (const QString & path1,
|
||||
const QString & path2) {
|
||||
return QFileInfo(path1).baseName() < QFileInfo(path2).baseName();
|
||||
});
|
||||
for (const QString &path : paths) {
|
||||
std::sort(paths.begin(),
|
||||
paths.end(),
|
||||
[](const QString& path1, const QString& path2)
|
||||
{ return QFileInfo(path1).baseName() < QFileInfo(path2).baseName(); });
|
||||
for (const QString& path : paths)
|
||||
{
|
||||
traceFilesModel->appendRow(new TraceFileItem(path));
|
||||
}
|
||||
}
|
||||
@@ -125,7 +128,8 @@ void EvaluationTool::on_btn_calculateMetrics_clicked()
|
||||
void EvaluationTool::getSelectedMetrics()
|
||||
{
|
||||
std::vector<long> selectedMetrics;
|
||||
for (QCheckBox *metric : selectMetrics->metrics) {
|
||||
for (QCheckBox* metric : selectMetrics->metrics)
|
||||
{
|
||||
selectedMetrics.push_back(metric->isChecked());
|
||||
}
|
||||
calculateMetrics(selectedMetrics);
|
||||
@@ -134,11 +138,13 @@ void EvaluationTool::getSelectedMetrics()
|
||||
void EvaluationTool::calculateMetrics(std::vector<long> selectedMetrics)
|
||||
{
|
||||
ui->traceMetricTreeWidget->clear();
|
||||
for (int row = 0; row < traceFilesModel->rowCount(); ++row) {
|
||||
TraceFileItem *item = static_cast<TraceFileItem *>(traceFilesModel->item(row));
|
||||
for (int row = 0; row < traceFilesModel->rowCount(); ++row)
|
||||
{
|
||||
TraceFileItem* item = static_cast<TraceFileItem*>(traceFilesModel->item(row));
|
||||
if (item->checkState() == Qt::Checked)
|
||||
{
|
||||
TraceCalculatedMetrics result = pythonCaller.evaluateMetrics(item->getPath().toStdString(), selectedMetrics);
|
||||
TraceCalculatedMetrics result =
|
||||
pythonCaller.evaluateMetrics(item->getPath().toStdString(), selectedMetrics);
|
||||
calculatedMetrics.push_back(result);
|
||||
ui->traceMetricTreeWidget->addTraceMetricResults(result);
|
||||
}
|
||||
@@ -146,7 +152,7 @@ void EvaluationTool::calculateMetrics(std::vector<long> selectedMetrics)
|
||||
ui->traceMetricTreeWidget->expandAll();
|
||||
}
|
||||
|
||||
EvaluationTool::TraceFileItem::TraceFileItem(const QString &path)
|
||||
EvaluationTool::TraceFileItem::TraceFileItem(const QString& path)
|
||||
{
|
||||
this->path = path;
|
||||
setText(QFileInfo(this->path).baseName());
|
||||
@@ -157,15 +163,18 @@ EvaluationTool::TraceFileItem::TraceFileItem(const QString &path)
|
||||
|
||||
void EvaluationTool::on_btn_exportCSV_clicked()
|
||||
{
|
||||
if (calculatedMetrics.size() > 0) {
|
||||
QString filename = QFileDialog::getSaveFileName(this, "Export to CSV", "",
|
||||
"Comma separated Values(*.csv)");
|
||||
if (filename != "") {
|
||||
if (calculatedMetrics.size() > 0)
|
||||
{
|
||||
QString filename = QFileDialog::getSaveFileName(
|
||||
this, "Export to CSV", "", "Comma separated Values(*.csv)");
|
||||
if (filename != "")
|
||||
{
|
||||
QFile file(filename);
|
||||
file.open(QIODevice::WriteOnly | QIODevice::Text);
|
||||
QTextStream out(&file);
|
||||
out << calculatedMetrics[0].toCSVHeader() << "\n";
|
||||
for (TraceCalculatedMetrics &metrics : calculatedMetrics) {
|
||||
for (TraceCalculatedMetrics& metrics : calculatedMetrics)
|
||||
{
|
||||
out << metrics.toCSVLine() << "\n";
|
||||
}
|
||||
file.close();
|
||||
@@ -187,7 +196,7 @@ void EvaluationTool::genPlots()
|
||||
|
||||
for (int row = 0; row < traceFilesModel->rowCount(); ++row)
|
||||
{
|
||||
TraceFileItem *item = static_cast<TraceFileItem *>(traceFilesModel->item(row));
|
||||
TraceFileItem* item = static_cast<TraceFileItem*>(traceFilesModel->item(row));
|
||||
if (item->checkState() == Qt::Checked)
|
||||
{
|
||||
ui->traceMetricTreeWidget->addTracePlotResults(
|
||||
|
||||
Reference in New Issue
Block a user