|
@@ -1,6 +1,135 @@
|
|
|
#include "EvalSchemeWidget.h"
|
|
|
|
|
|
+#include <CCanvas/CSchemeView.h>
|
|
|
+#include <CCanvas/CSchemeItem.h>
|
|
|
+
|
|
|
+#include <Widgets/Button.h>
|
|
|
+#include <Widgets/Menu.h>
|
|
|
+
|
|
|
+#include <QLayout>
|
|
|
+#include <QMetaEnum>
|
|
|
+
|
|
|
+#include <QDebug>
|
|
|
+
|
|
|
+QString EvalSchemeWidget::nameOfScheme(Scheme s)
|
|
|
+{
|
|
|
+ switch (s) {
|
|
|
+ case Input:
|
|
|
+ return "输入";
|
|
|
+ case Index:
|
|
|
+ return "指标体系";
|
|
|
+ case Collect:
|
|
|
+ return "收集数据";
|
|
|
+ case Process:
|
|
|
+ return "处理数据";
|
|
|
+ case Output:
|
|
|
+ return "输出报告";
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+QString EvalSchemeWidget::nameOfAlgorithm(EvalSchemeWidget::Algorithm a)
|
|
|
+{
|
|
|
+ switch (a) {
|
|
|
+ case Alg1:
|
|
|
+ return "层次分析法";
|
|
|
+ case Alg2:
|
|
|
+ return "集对分析法";
|
|
|
+ case Alg3:
|
|
|
+ return "熵值法";
|
|
|
+ case Alg4:
|
|
|
+ return "物元分析法";
|
|
|
+ case Alg5:
|
|
|
+ return "灰色聚类评估法";
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
EvalSchemeWidget::EvalSchemeWidget(ProjectInfo *proj, int type, QWidget *parent) : EvalWidget(proj, type, parent)
|
|
|
{
|
|
|
setTitle("评估方案规划");
|
|
|
+
|
|
|
+ initWidgets();
|
|
|
+}
|
|
|
+
|
|
|
+void EvalSchemeWidget::initWidgets()
|
|
|
+{
|
|
|
+ m_buttonLayout = new QHBoxLayout();
|
|
|
+
|
|
|
+ // 按照方案枚举值添加按钮
|
|
|
+ QMetaEnum sch = QMetaEnum::fromType<Scheme>();
|
|
|
+ for (int i = 0; i < sch.keyCount(); i++) {
|
|
|
+ Scheme s = Scheme(sch.value(i));
|
|
|
+ PushButton *btn = new PushButton(nameOfScheme(s), this);
|
|
|
+ btn->setFixedWidth(100);
|
|
|
+ m_buttonLayout->addWidget(btn);
|
|
|
+ connect(btn, &PushButton::clicked, [this, s, btn]() { slotSelectScheme(s, btn); });
|
|
|
+ }
|
|
|
+ m_buttonLayout->setSpacing(15);
|
|
|
+ m_buttonLayout->addStretch();
|
|
|
+
|
|
|
+ m_clear = new PushButton("清空");
|
|
|
+ m_buttonLayout->addWidget(m_clear);
|
|
|
+ connect(m_clear, &PushButton::clicked, this, &EvalSchemeWidget::slotClearScheme);
|
|
|
+
|
|
|
+ // 按照算法枚举值添加算法选项
|
|
|
+ m_menu = new RoundMenu("menu", this);
|
|
|
+ QMetaEnum alg = QMetaEnum::fromType<Algorithm>();
|
|
|
+ for (int i = 0; i < alg.keyCount(); i++) {
|
|
|
+ Algorithm t = Algorithm(alg.value(i));
|
|
|
+ QAction *act = new QAction(nameOfAlgorithm(t));
|
|
|
+ m_menu->addAction(act);
|
|
|
+ connect(act, &QAction::triggered, [this, t]() { slotSelectAlgorithm(t); });
|
|
|
+ }
|
|
|
+
|
|
|
+ m_schemeView = new CSchemeView(this);
|
|
|
+
|
|
|
+ m_contentLayout->addLayout(m_buttonLayout);
|
|
|
+ m_contentLayout->addWidget(m_schemeView);
|
|
|
+}
|
|
|
+
|
|
|
+void EvalSchemeWidget::refreshSchemeView()
|
|
|
+{
|
|
|
+ m_schemeView->clear();
|
|
|
+ QMetaEnum sch = QMetaEnum::fromType<Scheme>();
|
|
|
+ for (int i = 0; i < sch.keyCount(); i++) {
|
|
|
+ Scheme s = Scheme(sch.value(i));
|
|
|
+ if (s == Process) {
|
|
|
+ for (Algorithm a : m_algs) {
|
|
|
+ CSchemeItem *item = new CSchemeItem(nameOfAlgorithm(a));
|
|
|
+ m_schemeView->addItem(item);
|
|
|
+ }
|
|
|
+
|
|
|
+ } else {
|
|
|
+ if ((m_scheme & s) == s) {
|
|
|
+ CSchemeItem *item = new CSchemeItem(nameOfScheme(s));
|
|
|
+ m_schemeView->addItem(item);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+void EvalSchemeWidget::slotSelectScheme(EvalSchemeWidget::Scheme sch, PushButton *btn)
|
|
|
+{
|
|
|
+ if (sch == Process) {
|
|
|
+ QPoint pos = btn->mapToGlobal(QPoint()) + QPoint(btn->width(), -10);
|
|
|
+ m_menu->exec(pos, true);
|
|
|
+ } else {
|
|
|
+ m_scheme |= sch;
|
|
|
+ refreshSchemeView();
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+void EvalSchemeWidget::slotSelectAlgorithm(EvalSchemeWidget::Algorithm alg)
|
|
|
+{
|
|
|
+ if (m_algs.contains(alg)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ m_algs.append(alg);
|
|
|
+ refreshSchemeView();
|
|
|
+}
|
|
|
+
|
|
|
+void EvalSchemeWidget::slotClearScheme()
|
|
|
+{
|
|
|
+ m_scheme = 0;
|
|
|
+ m_algs.clear();
|
|
|
+ refreshSchemeView();
|
|
|
}
|