#include "EvalReportWidget.h" #include "DataTableWidget.h" #include "ProjectManager.h" #include "view/PlotView.h" #include "CustomPieChart.h" #include "common/ExportReportManager.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include static QSize kFigureSize = QSize(600, 600); EvalReportWidget::EvalReportWidget(ProjectInfo *proj, int indexType, QWidget *parent) : QWidget(parent), m_proj(proj), m_indexType(indexType) { initWidgets(); initLayouts(); loadAlgs(); loadData(); m_exportMngr = new ExportReportManager(this); m_exportMngr->setProj(m_proj); m_exportMngr->setEvalType(ProjectManager::evalTypeOfIndexType(indexType)); } EvalReportWidget::~EvalReportWidget() { delete m_exportMngr; } void EvalReportWidget::exportReport() { m_exportMngr->exportReport(); return; if (m_indexType == ProjectManager::OptimalIndex) { // 方案优选 QString path = "D:/FireFly/QFD2/bin/dataset/方案优选评估报告.docx"; QDesktopServices::openUrl(QUrl::fromLocalFile(path)); } else if (m_indexType == ProjectManager::EfficiencyIndex) { QString path = "D:/FireFly/QFD2/bin/dataset/综合效能评估报告.docx"; QDesktopServices::openUrl(QUrl::fromLocalFile(path)); } } void EvalReportWidget::initWidgets() { m_view = new QWidget; QSize s = kFigureSize; m_indexTitle = new QLabel(this); m_indexTab = new QTabWidget(this); m_indexTab->setFixedSize(s); connect(m_indexTab, SIGNAL(currentChanged(int)), this, SLOT(slotIndexTabIndexChanged(int))); QVector data; m_indexPlot = new PlotView(PlotView::HistogramVertical, data, "", this); m_indexPlot->setFixedSize(s); m_techTitle = new QLabel(this); m_techTable = new QTableView(this); m_techTable->horizontalHeader()->setStyleSheet("QHeaderView::section{background:rgb(244,244,244);color: black;}"); m_techTable->verticalHeader()->setStyleSheet("QHeaderView::section{background:rgb(244,244,244);color: black;}"); m_techTable->setAlternatingRowColors(true); m_techTable->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch); DataTableItemModel *techModel = new DataTableItemModel(); m_techTable->setModel(techModel); m_techTable->setFixedSize(s); m_techPlot = new PlotView(PlotView::HistogramHorizontal, data, "", this); m_techPlot->setFixedSize(s); m_schemeTitle = new QLabel(this); m_schemeTable = new QTableView(this); m_schemeTable->horizontalHeader()->setStyleSheet("QHeaderView::section{background:rgb(244,244,244);color: black;}"); m_schemeTable->verticalHeader()->setStyleSheet("QHeaderView::section{background:rgb(244,244,244);color: black;}"); m_schemeTable->setAlternatingRowColors(true); m_schemeTable->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch); DataTableItemModel *schemeModel = new DataTableItemModel(); m_schemeTable->setModel(schemeModel); m_schemeTable->setFixedSize(s); m_schemePlot = new PlotView(PlotView::HistogramVertical, data, "", this); m_schemePlot->setFixedSize(s); m_EffiTab = new QTabWidget(this); m_EffiTab->setFixedSize(s); connect(m_EffiTab, SIGNAL(currentChanged(int)), this, SLOT(slotEffiTabIndexChanged(int))); QStringList plots = { "折线图", "横向柱状图", "竖向柱状图", "曲线图", "面积图", "饼图" }; m_indexCombo = new QComboBox(this); m_indexCombo->setFixedSize(QSize(150, 35)); m_indexCombo->addItems(plots); m_indexCombo->setCurrentIndex(1); connect(m_indexCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(slotSelectIndexPlotType(int))); // plots = QStringList { "竖向柱状图" }; m_techCombo = new QComboBox(this); m_techCombo->setFixedSize(QSize(150, 35)); m_techCombo->addItems(plots); m_techCombo->setCurrentIndex(1); connect(m_techCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(slotSelectTechPlotType(int))); m_schemeCombo = new QComboBox(this); m_schemeCombo->setFixedSize(QSize(150, 35)); m_schemeCombo->addItems(plots); m_schemeCombo->setCurrentIndex(2); connect(m_schemeCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(slotSelectSchemePlotType(int))); m_lastSchemeLev = new QPushButton("上一级指标"); m_nextSchemeLev = new QPushButton("下一级指标"); connect(m_lastSchemeLev, &QPushButton::clicked, this, &EvalReportWidget::slotLastSchemeLev); connect(m_nextSchemeLev, &QPushButton::clicked, this, &EvalReportWidget::slotNextSchemeLev); } void EvalReportWidget::initLayouts() { m_layout = new QVBoxLayout(m_view); m_gridLayout = new QGridLayout(); m_layout->addLayout(m_gridLayout); QFont ft("Microsoft YaHei", 12); QStringList plots = { "折线图", "横向柱状图", "竖向柱状图", "曲线图", "面积图" }; if (m_indexType != ProjectManager::TechIndex) { m_indexTitle = new QLabel(this); m_indexTitle->setText("指标权重"); m_indexTitle->setFont(ft); m_indexTitle->setContentsMargins(0, 10, 0, 10); m_gridLayout->addWidget(m_indexTitle, 0, 0); m_gridLayout->addWidget(m_indexCombo, 0, 1); m_gridLayout->addWidget(m_indexTab, 1, 0); m_gridLayout->addWidget(m_indexPlot, 1, 1); } else { m_techTitle = new QLabel(this); m_techTitle->setText("技术措施重要度"); m_techTitle->setFont(ft); m_techTitle->setContentsMargins(0, 10, 0, 10); m_gridLayout->addWidget(m_techTitle, 0, 0); m_gridLayout->addWidget(m_techCombo, 0, 1); m_gridLayout->addWidget(m_techTable, 1, 0); m_gridLayout->addWidget(m_techPlot, 1, 1); } if (m_indexType == ProjectManager::OptimalIndex || m_indexType == ProjectManager::EfficiencyIndex) { m_schemeTitle = new QLabel(this); m_schemeTitle->setFont(ft); m_schemeTitle->setFixedHeight(100); m_schemeTitle->setContentsMargins(0, 50, 0, 10); if (m_indexType == ProjectManager::OptimalIndex) { m_schemeTitle->setText("方案得分"); m_gridLayout->addWidget(m_schemeTitle, 2, 0); m_gridLayout->addWidget(m_schemeTable, 3, 0); } else { m_schemeTitle->setText("效能分析"); m_gridLayout->addWidget(m_schemeTitle, 2, 0); m_gridLayout->addWidget(m_EffiTab, 3, 0); QHBoxLayout *lay = new QHBoxLayout(); lay->addWidget(m_lastSchemeLev); lay->addSpacing(20); lay->addWidget(m_nextSchemeLev); m_gridLayout->addLayout(lay, 4, 0); } m_gridLayout->addWidget(m_schemeCombo, 2, 1, Qt::AlignBottom); m_gridLayout->addWidget(m_schemePlot, 3, 1); } QScrollArea *scroll = new QScrollArea; scroll->setAlignment(Qt::AlignLeft); scroll->setWidget(m_view); QVBoxLayout *layout = new QVBoxLayout(this); layout->setMargin(0); layout->addWidget(scroll); } void EvalReportWidget::loadAlgs() { QList processList; SchemeProcessService().QueryAllByProjectIdAndIndexType(processList, m_proj->id, m_indexType); for (SchemePlanManager::SchemeProcessInfo process : processList) { QString algName = SchemePlanManager::nameOfAlgorithm(process.algorithm); if (process.type == SchemePlanManager::CalculateWeight) { m_weightAlg = process.algorithm; m_indexTitle->setText(m_indexTitle->text() + " (" + algName + ") "); } else if (process.type == SchemePlanManager::RunEvaluate) { m_evalAlg = process.algorithm; // m_techTitle->setText(m_techTitle->text() + " (" + algName + ") "); m_schemeTitle->setText(m_schemeTitle->text() + " (" + algName + ") "); } } } void EvalReportWidget::loadData() { QList nodeList; CNodeDataService().QueryAllValid(nodeList, m_proj->id, m_indexType); m_mind = new CMind(this); m_mind->setNodeList(nodeList); if (checkDataComplete() == false) { return; } if (m_indexType != ProjectManager::TechIndex) { showIndexWeight(); } else { showTechScore(); } if (m_indexType == ProjectManager::OptimalIndex) { showSchemeScore(); } if (m_indexType == ProjectManager::EfficiencyIndex) { showEffiResult(); } } bool EvalReportWidget::checkDataComplete() { QString indexName = ProjectManager::nameOfIndexType((ProjectManager::IndexType)m_indexType); bool ret = NodeMatrixService().hasMeasureData(m_proj->id, indexName); if (ret == true) { return true; } QList cfgList; ret = UserConfigService().QueryUserConfigListInfoByEngineerId(&cfgList, m_proj->id); if (ret == false || cfgList.size() <= 0) { return false; } bool expertDataComplete = true; for (UserConfig *cfg : cfgList) { ret = NodeMatrixService().hasExpertData(m_proj->id, indexName, cfg->userId); if (ret == false) { expertDataComplete = false; break; } } return expertDataComplete; } void EvalReportWidget::showIndexWeight() { int levels = m_mind->levels(); if (levels < 2) { return; } MindWeightInfo info; int indexType = m_indexType; if (indexType == ProjectManager::TechIndex) { indexType = ProjectManager::AbilityIndex; } bool ret = MindWeightService().queryWeightData(&info, m_proj->id, indexType); if (ret == false) { return; } if (info.id < 0) { qDebug() << __FUNCTION__ << __LINE__ << "未找到指标权重数据" << endl; return; } QMap weightData; QStringList weightList = info.weight.split(";"); for (QString keyValueStr : weightList) { QStringList keyValue = keyValueStr.split(":"); if (keyValue.size() == 2) { weightData[keyValue.first()] = keyValue.last().toDouble(); } } for (int i = 2; i <= levels; i++) { QTableView *t = new QTableView(); t->horizontalHeader()->setStyleSheet("QHeaderView::section{background:rgb(244,244,244);color: black;}"); t->verticalHeader()->setStyleSheet("QHeaderView::section{background:rgb(244,244,244);color: black;}"); t->setAlternatingRowColors(true); t->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch); // t->verticalHeader()->setDefaultAlignment(Qt::AlignCenter); // t->setSelectionMode(QAbstractItemView::SingleSelection); DataTableItemModel *model = new DataTableItemModel(); t->setModel(model); QStandardItem *hHeader = new QStandardItem("权重"); model->setHorizontalHeaderItem(0, hHeader); QList nodeList = m_mind->nodesInLevel(i); for (int j = 0; j < nodeList.size(); j++) { CNodeData node = nodeList[j]; QStandardItem *vHeader = new QStandardItem(node.name); model->setVerticalHeaderItem(j, vHeader); QStandardItem *item = new QStandardItem(); item->setText(QString("%1").arg(weightData[node.name])); item->setEditable(false); model->setItem(j, 0, item); } m_indexTab->addTab(t, QString("第%1级指标").arg(i)); } } void EvalReportWidget::showIndexWeightPlot() { QTableView *table = (QTableView *)m_indexTab->currentWidget(); if (table == nullptr) { return; } DataTableItemModel *model = (DataTableItemModel *)table->model(); if (model == nullptr) { return; } QVector values; for (int i = 0; i < model->rowCount(); i++) { QStandardItem *header = model->verticalHeaderItem(i); QStandardItem *item = model->item(i, 0); PlotView::Data data { header->text(), item->text().toDouble() }; values.append(data); } if (m_indexPlot != nullptr) { m_gridLayout->removeWidget(m_indexPlot); m_indexPlot->deleteLater(); m_indexPlot = nullptr; } if (m_indexPie != nullptr) { m_gridLayout->removeWidget(m_indexPie); m_indexPie->deleteLater(); m_indexPie = nullptr; } if (m_indexCombo->currentIndex() < 5) { PlotView::PlotType type = (PlotView::PlotType)m_indexCombo->currentIndex(); m_indexPlot = new PlotView(type, values, "", this); m_indexPlot->setFixedSize(kFigureSize); m_indexPlot->plot(); m_gridLayout->addWidget(m_indexPlot, 1, 1); } else { QStringList tagList; QList dataList; QList colorList; for (int i = 0; i < values.size(); i++) { tagList.append(""); double t = values[i].value; dataList.append(t); QColor color(20 + 200 / values.size() * i, 70 * (1.6 - i / values.size()), 150, 255); colorList.append(color); } m_indexPie = new CustomPieChart("", tagList, dataList, colorList); m_indexPie->setFixedSize(kFigureSize); m_gridLayout->addWidget(m_indexPie, 1, 1); } } void EvalReportWidget::showTechScore() { int levels = m_mind->levels(); if (levels < 2) { return; } DataTableItemModel *model = (DataTableItemModel *)m_techTable->model(); if (model == nullptr) { return; } MindScoreInfo info; bool ret = MindScoreService().queryScoreData(&info, m_proj->id); if (ret == false || info.id < 0) { return; } QMap scoreData; QStringList keyValueStringList = info.score.split(";"); for (QString keyValueString : keyValueStringList) { QStringList keyValue = keyValueString.split(":"); if (keyValue.size() == 2) { scoreData[keyValue.first()] = keyValue.last(); } } QStandardItem *hHeader = new QStandardItem("重要度"); model->setHorizontalHeaderItem(0, hHeader); QList nodeList = m_mind->leaves(); QVector values; for (int j = 0; j < nodeList.size(); j++) { CNodeData node = nodeList[j]; QStandardItem *vHeader = new QStandardItem(node.name); model->setVerticalHeaderItem(j, vHeader); QStandardItem *item = new QStandardItem(); item->setText(scoreData[node.name]); item->setEditable(false); model->setItem(j, 0, item); PlotView::Data data { vHeader->text(), item->text().toDouble() }; values.append(data); } makePlotClear(m_techPlot); m_techPlot->updateData(values); } void EvalReportWidget::showTechScorePlot() { DataTableItemModel *model = (DataTableItemModel *)m_techTable->model(); if (model == nullptr) { return; } QVector values; for (int i = 0; i < model->rowCount(); i++) { QStandardItem *header = model->verticalHeaderItem(i); QStandardItem *item = model->item(i, 0); PlotView::Data data { header->text(), item->text().toDouble() }; values.append(data); } if (m_techPlot != nullptr) { m_gridLayout->removeWidget(m_techPlot); m_techPlot->deleteLater(); m_techPlot = nullptr; } if (m_techPie != nullptr) { m_gridLayout->removeWidget(m_techPie); m_techPie->deleteLater(); m_techPie = nullptr; } if (m_techCombo->currentIndex() < 5) { PlotView::PlotType type = (PlotView::PlotType)m_techCombo->currentIndex(); m_techPlot = new PlotView(type, values, "", this); m_techPlot->setFixedSize(kFigureSize); m_techPlot->plot(); m_gridLayout->addWidget(m_techPlot, 1, 1); } else { QStringList tagList; QList dataList; QList colorList; for (int i = 0; i < values.size(); i++) { tagList.append(""); double t = values[i].value; dataList.append(t); QColor color(20 + 200 / values.size() * i, 70 * (1.6 - i / values.size()), 150, 255); colorList.append(color); } m_techPie = new CustomPieChart("", tagList, dataList, colorList); m_techPie->setFixedSize(kFigureSize); m_gridLayout->addWidget(m_techPie, 1, 1); } } void EvalReportWidget::showSchemeScore() { int levels = m_mind->levels(); if (levels < 2) { return; } DataTableItemModel *model = (DataTableItemModel *)m_schemeTable->model(); if (model == nullptr) { return; } QList schemeList; QVector values; if (m_indexType == ProjectManager::EfficiencyIndex) { SchemeInfoService().QuerySchemeInfoByEngineerId(&schemeList, m_proj->id, 1); } if (m_indexType == ProjectManager::OptimalIndex) { SchemeInfoService().QuerySchemeInfoByEngineerId(&schemeList, m_proj->id, 0); QStandardItem *hHeader = new QStandardItem("得分"); model->setHorizontalHeaderItem(0, hHeader); for (int i = 0; i < schemeList.size(); i++) { SchemaEval *scheme = schemeList[i]; QStandardItem *vHeader = new QStandardItem(scheme->name); model->setVerticalHeaderItem(i, vHeader); QStandardItem *item = new QStandardItem(QString::number(scheme->score, 'f', 2)); item->setEditable(false); PlotView::Data data { vHeader->text(), scheme->score }; model->setItem(i, 0, item); values.append(data); } } makePlotClear(m_schemePlot); m_schemePlot->updateData(values); } void EvalReportWidget::showSchemeScorePlot() { DataTableItemModel *model = (DataTableItemModel *)m_schemeTable->model(); if (model == nullptr) { return; } QVector values; for (int i = 0; i < model->rowCount(); i++) { QStandardItem *header = model->verticalHeaderItem(i); QStandardItem *item = model->item(i, 0); PlotView::Data data { header->text(), item->text().toDouble() }; values.append(data); } if (m_schemePlot != nullptr) { m_gridLayout->removeWidget(m_schemePlot); m_schemePlot->deleteLater(); m_schemePlot = nullptr; } if (m_schemePie != nullptr) { m_gridLayout->removeWidget(m_schemePie); m_schemePie->deleteLater(); m_schemePie = nullptr; } if (m_schemeCombo->currentIndex() < 5) { PlotView::PlotType type = (PlotView::PlotType)m_schemeCombo->currentIndex(); m_schemePlot = new PlotView(type, values, "", this); m_schemePlot->setFixedSize(kFigureSize); m_schemePlot->plot(); m_gridLayout->addWidget(m_schemePlot, 3, 1); } else { QStringList tagList; QList dataList; QList colorList; for (int i = 0; i < values.size(); i++) { tagList.append(""); double t = values[i].value; dataList.append(t); QColor color(20 + 200 / values.size() * i, 70 * (1.6 - i / values.size()), 150, 255); colorList.append(color); } m_schemePie = new CustomPieChart("", tagList, dataList, colorList); m_schemePie->setFixedSize(kFigureSize); m_gridLayout->addWidget(m_schemePie, 3, 1); } } void EvalReportWidget::showEffiResult() { showEffiResultLev(); return; m_EffiTab->clear(); QList gradeInfoList; int type = m_evalAlg == SchemePlanManager::MEA ? 0 : 1; bool gradeRet = GradeInfoService().QueryGradeByProjectIdAndType(&gradeInfoList, m_proj->id, type); if (gradeRet == false) { return; } QStringList gradeNames; for (int i = 0; i < gradeInfoList.size(); ++i) { gradeNames.append(gradeInfoList[i]->gradeValue); } QList effList; bool effRet = EffectResultService().queryDataList(effList, m_proj->id); if (effRet == false) { return; } QMap>> effData; QMap schemeNames; int levels = 0; for (EffectResult effect : effList) { if (effData.keys().contains(effect.schemeId) == false) { effData[effect.schemeId] = QMap>(); schemeNames[effect.schemeId] = effect.schemeName; } QStringList values = effect.value.split(","); levels = values.size(); QList valueList; for (int v = 0; v < values.size(); ++v) { valueList.append(values[v].toDouble()); } effData[effect.schemeId][effect.indexName] = valueList; } for (int i = 0; i < effData.keys().size(); i++) { QTableView *t = new QTableView(); t->horizontalHeader()->setStyleSheet("QHeaderView::section{background:rgb(244,244,244);color: black;}"); t->verticalHeader()->setStyleSheet("QHeaderView::section{background:rgb(244,244,244);color: black;}"); t->setAlternatingRowColors(true); t->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch); DataTableItemModel *model = new DataTableItemModel(); t->setModel(model); for (int lev = 0; lev < levels; lev++) { QStandardItem *hHeader = new QStandardItem(gradeNames[lev]); model->setHorizontalHeaderItem(lev, hHeader); } QStandardItem *vHeader = new QStandardItem("综合"); model->setVerticalHeaderItem(0, vHeader); QList nodeList = m_mind->nodesInLevel(m_mind->levels()); for (int j = 0; j < nodeList.size(); j++) { CNodeData node = nodeList[j]; QStandardItem *vHeader = new QStandardItem(node.name); model->setVerticalHeaderItem(j + 1, vHeader); } for (int r = 0; r < model->rowCount(); ++r) { QStandardItem *vHeader = model->verticalHeaderItem(r); QList rowValues = effData[effData.keys()[i]][vHeader->text()]; for (int c = 0; c < model->columnCount(); ++c) { QStandardItem *item = new QStandardItem(); if (effData.keys().size() > i && rowValues.size() > c) { QString text = QString("%1").arg(rowValues[c]); if (std::isnan(rowValues[c])) { text = "0"; } item->setText(text); } item->setEditable(false); model->setItem(r, c, item); } } m_EffiTab->addTab(t, schemeNames[effData.keys()[i]]); } } void EvalReportWidget::makePlotClear(PlotView *plotView) { plotView->clearGraphs(); plotView->clearItems(); plotView->clearMask(); plotView->clearPlottables(); } void EvalReportWidget::showEffiResultLev() { if (m_mind->levels() < 2) { return; } // 获取指标权重 MindWeightInfo info; int indexType = m_indexType; if (indexType == ProjectManager::TechIndex) { indexType = ProjectManager::AbilityIndex; } bool ret = MindWeightService().queryWeightData(&info, m_proj->id, indexType); if (ret == false) { return; } if (info.id < 0) { qDebug() << __FUNCTION__ << __LINE__ << "未找到指标权重数据" << endl; return; } QMap weightData; QStringList weightList = info.weight.split(";"); for (QString keyValueStr : weightList) { QStringList keyValue = keyValueStr.split(":"); if (keyValue.size() == 2) { weightData[keyValue.first()] = keyValue.last().toDouble(); } } int curTabIndex = m_EffiTab->currentIndex(); m_EffiTab->clear(); QList gradeInfoList; int type = m_evalAlg == SchemePlanManager::MEA ? 0 : 1; bool gradeRet = GradeInfoService().QueryGradeByProjectIdAndType(&gradeInfoList, m_proj->id, type); if (gradeRet == false) { return; } QStringList gradeNames; for (int i = 0; i < gradeInfoList.size(); ++i) { gradeNames.append(gradeInfoList[i]->gradeValue); } QList effList; bool effRet = EffectResultService().queryDataList(effList, m_proj->id); if (effRet == false) { return; } QMap>> effData; QMap schemeNames; int levels = 0; // 效能分级 for (EffectResult effect : effList) { if (effData.keys().contains(effect.schemeId) == false) { effData[effect.schemeId] = QMap>(); schemeNames[effect.schemeId] = effect.schemeName; } QStringList values = effect.value.split(","); levels = values.size(); QList valueList; for (int v = 0; v < values.size(); ++v) { valueList.append(values[v].toDouble()); } effData[effect.schemeId][effect.indexName] = valueList; } for (int i = 0; i < effData.keys().size(); i++) { QTableView *t = new QTableView(); t->horizontalHeader()->setStyleSheet("QHeaderView::section{background:rgb(244,244,244);color: black;}"); t->verticalHeader()->setStyleSheet("QHeaderView::section{background:rgb(244,244,244);color: black;}"); t->setAlternatingRowColors(true); t->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch); DataTableItemModel *model = new DataTableItemModel(); t->setModel(model); for (int lev = 0; lev < levels; lev++) { QStandardItem *hHeader = new QStandardItem(gradeNames[lev]); model->setHorizontalHeaderItem(lev, hHeader); } QStandardItem *vHeader = new QStandardItem("综合"); model->setVerticalHeaderItem(0, vHeader); QList nodeList = m_mind->nodesInLevel(m_curSchemeLev); for (int j = 0; j < nodeList.size(); j++) { CNodeData node = nodeList[j]; QStandardItem *vHeader = new QStandardItem(node.name); model->setVerticalHeaderItem(j + 1, vHeader); } for (int r = 0; r < model->rowCount(); ++r) { QStandardItem *vHeader = model->verticalHeaderItem(r); QList rowValues; if (m_curSchemeLev == m_mind->levels() || r == 0) { rowValues = effData[effData.keys()[i]][vHeader->text()]; } else { QList subNodes = m_mind->leavesOfNode(nodeList[r - 1]); for (int l = 0; l < levels; l++) { double sumValue = 0; double sumWeight = 0; for (int n = 0; n < subNodes.count(); n++) { QList subNodeValues = effData[effData.keys()[i]][subNodes[n].name]; double weight = weightData[subNodes[n].name]; sumValue += subNodeValues[l] * weight; sumWeight += weight; } double finalValue = 0; if (sumWeight > 0) { finalValue = sumValue / sumWeight; } rowValues.append(finalValue); } } for (int c = 0; c < model->columnCount(); ++c) { QStandardItem *item = new QStandardItem(); if (effData.keys().size() > i && rowValues.size() > c) { QString text = QString("%1").arg(rowValues[c]); if (std::isnan(rowValues[c])) { text = "0"; } item->setText(text); } item->setEditable(false); model->setItem(r, c, item); } } m_EffiTab->addTab(t, schemeNames[effData.keys()[i]]); } if (curTabIndex >= 0) { m_EffiTab->setCurrentIndex(curTabIndex); } } void EvalReportWidget::slotSelectIndexPlotType(int) { showIndexWeightPlot(); } void EvalReportWidget::slotSelectTechPlotType(int) { showTechScorePlot(); } void EvalReportWidget::slotSelectSchemePlotType(int) { if (m_indexType == ProjectManager::OptimalIndex) { showSchemeScorePlot(); } if (m_indexType == ProjectManager::EfficiencyIndex) { slotEffiTabIndexChanged(m_EffiTab->currentIndex()); } } void EvalReportWidget::slotIndexTabIndexChanged(int) { showIndexWeightPlot(); } void EvalReportWidget::slotEffiTabIndexChanged(int index) { QTableView *table = (QTableView *)m_EffiTab->currentWidget(); if (table == nullptr) { return; } DataTableItemModel *model = (DataTableItemModel *)table->model(); if (model == nullptr) { return; } QVector values; for (int i = 0; i < model->columnCount(); i++) { QStandardItem *header = model->horizontalHeaderItem(i); QStandardItem *item = model->item(0, i); if (item != nullptr) { PlotView::Data data { header->text(), item->text().toDouble() }; values.append(data); } } if (m_schemePlot != nullptr) { m_gridLayout->removeWidget(m_schemePlot); m_schemePlot->deleteLater(); m_schemePlot = nullptr; } if (m_schemePie != nullptr) { m_gridLayout->removeWidget(m_schemePie); m_schemePie->deleteLater(); m_schemePie = nullptr; } if (m_schemeCombo->currentIndex() < 5) { PlotView::PlotType type = (PlotView::PlotType)m_schemeCombo->currentIndex(); m_schemePlot = new PlotView(type, values, "", this); m_schemePlot->setFixedSize(kFigureSize); m_schemePlot->plot(); m_gridLayout->addWidget(m_schemePlot, 3, 1); } else { QStringList tagList; QList dataList; QList colorList; for (int i = 0; i < values.size(); i++) { tagList.append(""); double t = values[i].value; dataList.append(t); QColor color(20 + 200 / values.size() * i, 70 * (1.6 - i / values.size()), 150, 255); colorList.append(color); } m_schemePie = new CustomPieChart("", tagList, dataList, colorList); m_schemePie->setFixedSize(kFigureSize); m_gridLayout->addWidget(m_schemePie, 3, 1); } } void EvalReportWidget::slotLastSchemeLev() { if (m_curSchemeLev > 2) { m_curSchemeLev--; } showEffiResultLev(); } void EvalReportWidget::slotNextSchemeLev() { if (m_curSchemeLev < m_mind->levels()) { m_curSchemeLev++; } showEffiResultLev(); }