From 8c51cfcb5f10d82f7397ee22880e840fdcb03fc6 Mon Sep 17 00:00:00 2001 From: "Felipe S. Prado" Date: Fri, 21 Oct 2016 12:45:58 +0200 Subject: [PATCH] Select Metrics --- DRAMSys/analyzer/evaluationtool.cpp | 16 ++++------ DRAMSys/analyzer/selectmetrics.cpp | 46 ++++++++++++++++++----------- DRAMSys/analyzer/selectmetrics.h | 5 +++- 3 files changed, 37 insertions(+), 30 deletions(-) diff --git a/DRAMSys/analyzer/evaluationtool.cpp b/DRAMSys/analyzer/evaluationtool.cpp index ba7c949b..004e30af 100644 --- a/DRAMSys/analyzer/evaluationtool.cpp +++ b/DRAMSys/analyzer/evaluationtool.cpp @@ -51,10 +51,8 @@ #include "evaluationtool.h" #include "ui_evaluationtool.h" - using namespace std; - EvaluationTool::EvaluationTool(QWidget *parent) : QWidget(parent), ui(new Ui::EvaluationTool), resourcesRelPath("/../../dram/resources/scripts""") @@ -63,6 +61,8 @@ EvaluationTool::EvaluationTool(QWidget *parent) : traceFilesModel = new QStandardItemModel(this); ui->listView->setModel(traceFilesModel); QObject::connect(ui->traceTestTreeWidget,SIGNAL(setMessage(QString)),this,SLOT(setTestMessage(QString))); + selectMetrics = new SelectMetrics(this); + QObject::connect(selectMetrics, SIGNAL(getSelectedMetrics()), this, SLOT(getSelectedMetrics())); } EvaluationTool::~EvaluationTool() @@ -84,6 +84,7 @@ void EvaluationTool::showAndRunTests(QList paths) fillFileList(paths); show(); ui->toolBox->setCurrentIndex(0); + selectMetrics->setMetrics(getMetrics()); runTests(); } @@ -93,15 +94,12 @@ void EvaluationTool::showAndEvaluateMetrics(QList paths) fillFileList(paths); show(); ui->toolBox->setCurrentIndex(1); - selectMetrics = new SelectMetrics(getMetrics(), this); - QObject::connect(selectMetrics, SIGNAL(getSelectedMetrics()), this, SLOT(getSelectedMetrics())); + selectMetrics->setMetrics(getMetrics()); cout<<"done"< EvaluationTool::getMetrics() { - ui->traceMetricTreeWidget->clear(); - vector metrics; for(int row = 0; row < traceFilesModel->rowCount(); ++row) { @@ -110,7 +108,6 @@ vector EvaluationTool::getMetrics() if(result.size() > metrics.size()) metrics = result; } - return metrics; } @@ -209,11 +206,9 @@ EvaluationTool::TraceFileItem::TraceFileItem(const QString &path) setEditable(false); } - - void EvaluationTool::on_btn_exportCSV_clicked() { - if(calculatedMetrics.size()>0) + if(calculatedMetrics.size() > 0) { QString filename = QFileDialog::getSaveFileName(this, "Export to CSV", "", "Comma separated Values(*.csv)"); if(filename != "") @@ -229,7 +224,6 @@ void EvaluationTool::on_btn_exportCSV_clicked() file.close(); } } - } void EvaluationTool::on_btn_genPlots_clicked() diff --git a/DRAMSys/analyzer/selectmetrics.cpp b/DRAMSys/analyzer/selectmetrics.cpp index 9c8fbef9..9767caa3 100644 --- a/DRAMSys/analyzer/selectmetrics.cpp +++ b/DRAMSys/analyzer/selectmetrics.cpp @@ -38,36 +38,20 @@ #include "ui_selectmetrics.h" #include -SelectMetrics::SelectMetrics(std::vector metrics, QWidget *parent) : +SelectMetrics::SelectMetrics(QWidget *parent) : QDialog(parent), ui(new Ui::SelectMetrics) { ui->setupUi(this); - QVBoxLayout* layout = new QVBoxLayout(); - - for(std::string metric : metrics) - { - QCheckBox * checkBox = new QCheckBox(); - checkBox->setObjectName (QString::fromStdString(metric)); - checkBox->setCheckable (true); - checkBox->setChecked (true); - - checkBox->setGeometry (10, 25, 100, 17); - checkBox->setText (QString::fromStdString(metric)); - this->metrics.push_back(checkBox); - layout->addWidget(checkBox, Qt::AlignLeft); - - } + layout = new QVBoxLayout(); ui->scrollAreaWidgetContents->setLayout(layout); ui->scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded); ui->scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded); - } - void SelectMetrics::on_okButton_clicked() { if(isThereAnyMetricSelected()) @@ -108,6 +92,32 @@ bool SelectMetrics::isThereAnyMetricSelected() return false; } +void SelectMetrics::setMetrics(std::vector metrics) +{ + if(this->metrics.size() != metrics.size()) + { + for(QCheckBox* checkBox : this->metrics) + { + layout->removeWidget(checkBox); + } + + this->metrics.clear(); + + for(std::string metric : metrics) + { + QCheckBox * checkBox = new QCheckBox(); + checkBox->setObjectName (QString::fromStdString(metric)); + checkBox->setCheckable (true); + checkBox->setChecked (true); + + checkBox->setGeometry (10, 25, 100, 17); + checkBox->setText (QString::fromStdString(metric)); + this->metrics.push_back(checkBox); + layout->addWidget(checkBox, Qt::AlignLeft); + } + } +} + SelectMetrics::~SelectMetrics() { delete ui; diff --git a/DRAMSys/analyzer/selectmetrics.h b/DRAMSys/analyzer/selectmetrics.h index 850f27d2..63b82259 100644 --- a/DRAMSys/analyzer/selectmetrics.h +++ b/DRAMSys/analyzer/selectmetrics.h @@ -52,11 +52,13 @@ class SelectMetrics : public QDialog Q_OBJECT public: - explicit SelectMetrics(std::vector metrics, QWidget *parent = 0); + explicit SelectMetrics(QWidget *parent = 0); ~SelectMetrics(); std::vector metrics; + void setMetrics(std::vector metrics); + Q_SIGNALS: void getSelectedMetrics(); @@ -69,6 +71,7 @@ private Q_SLOTS: private: Ui::SelectMetrics *ui; + QVBoxLayout* layout; bool isThereAnyMetricSelected(); };