Pārlūkot izejas kodu

修改评估方案算法选项

chengxr 1 gadu atpakaļ
vecāks
revīzija
9813a06779

+ 1 - 8
QFD/common/SchemePlanManager.cpp

@@ -97,14 +97,7 @@ QList<SchemePlanManager::Algorithm> SchemePlanManager::processOptionalAlgorithms
     case OptimizeIndex:
         return { PrincipalComponents };
     case CalculateWeight: {
-        if (process.indexType == ProjectManager::AbilityIndex) {
-            return { Entropy, AHP };
-        } else if (process.indexType == ProjectManager::OptimalIndex) {
-            return { HWM, SPA };
-        } else if (process.indexType == ProjectManager::EfficiencyIndex) {
-            return {};
-        }
-        return {};
+        return { AHP, Entropy, PrincipalComponents };
     }
     case RunEvaluate: {
         if (process.indexType == ProjectManager::TechIndex) {

+ 4 - 7
QFD/shemeFlow/FlowGraphNodeWidget.cpp

@@ -116,7 +116,7 @@ bool FlowGraphCommonNodeWidget::isTitleHidden() const
     QList<SchemePlanManager::SchemeDataSource> dsrc = SchemePlanManager::processOptionalDataSource(m_process);
     bool opt                                        = SchemePlanManager::processIsOptional(m_process);
 
-    return (algs.count() > 1 || dsrc.count() > 1 || opt);
+    return (algs.count() > 0 || dsrc.count() > 0 || opt);
 }
 
 void FlowGraphCommonNodeWidget::initWidget()
@@ -159,11 +159,11 @@ void FlowGraphCommonNodeWidget::loadInfo()
 
     /// 标题
     /// 在其他子控件都不显示时, 将标题居中显示
-    m_label->setHidden(algs.count() > 1 || dsrc.count() > 1 || opt);
+    m_label->setHidden(algs.count() > 0 || dsrc.count() > 0 || opt);
     m_label->setText(title());
 
     /// 算法选择组件
-    m_algCombo->setHidden(algs.count() < 2);
+    m_algCombo->setHidden(algs.count() < 1);
     m_algCombo->clear();
     for (SchemePlanManager::Algorithm alg : algs) {
         m_algCombo->addItem(SchemePlanManager::stringFromAlgorithm(alg));
@@ -175,7 +175,7 @@ void FlowGraphCommonNodeWidget::loadInfo()
     m_algCombo->setCurrentIndex(algIndex);
 
     /// 数据来源选择组件
-    m_dataCombo->setHidden(dsrc.count() < 2);
+    m_dataCombo->setHidden(dsrc.count() < 1);
     m_dataCombo->clear();
     for (SchemePlanManager::SchemeDataSource scr : dsrc) {
         m_dataCombo->addItem(SchemePlanManager::stringFromDataSource(scr));
@@ -194,7 +194,6 @@ void FlowGraphCommonNodeWidget::loadInfo()
 
     m_spinBox->setHidden(m_process.indexType != ProjectManager::EfficiencyIndex
                          || m_process.type != SchemePlanManager::RunEvaluate);
-    m_spinBox->setEnabled(m_process.algorithm == SchemePlanManager::GCE);
     m_spinBox->setValue(m_process.efficiencyGrades);
 }
 
@@ -211,7 +210,6 @@ QList<SchemePlanManager::Algorithm> FlowGraphCommonNodeWidget::optionalAlgs() co
 QList<SchemePlanManager::SchemeDataSource> FlowGraphCommonNodeWidget::optionaldSource() const
 {
     return SchemePlanManager::processOptionalDataSource(m_process);
-    ;
 }
 
 bool FlowGraphCommonNodeWidget::isOptional() const
@@ -223,7 +221,6 @@ void FlowGraphCommonNodeWidget::slotAlgComboChanged(int index)
 {
     QList<SchemePlanManager::Algorithm> list = optionalAlgs();
     m_process.algorithm                      = list.at(index);
-    m_spinBox->setEnabled(m_process.algorithm == SchemePlanManager::GCE);
     emit sigProcessChanged(m_process);
 }
 

+ 1 - 1
QFD/shemeFlow/FlowTemplateDataModel.h

@@ -506,7 +506,7 @@ public:
 
     QString name() const override { return QString("FlowCommonData"); }
 
-    unsigned int nPorts(PortType const) const override { return 0; }
+    unsigned int nPorts(PortType const) const override { return 2; }
 
     NodeDataType dataType(PortType const, PortIndex const) const override { return FlowCommonData().type(); }
 

+ 2 - 11
QFD/view/ProjectView.cpp

@@ -64,8 +64,6 @@ void ProjectView::initWidgets()
     m_title->setText(m_proj->projectName);
     QFont ft("Microsoft YaHei", 14);
     m_title->setFont(ft);
-    m_export = new PushButton("导出", this);
-    m_export->setToolTip("导出资源包");
     m_close = new PushButton("关闭", this);
     m_close->setToolTip("关闭项目");
     m_tree = new TreeWidget(this);
@@ -117,10 +115,9 @@ void ProjectView::initLayout()
     m_layout->addLayout(m_contentLayout);
 
     m_headerLayout->addWidget(m_title);
-    m_headerLayout->addStretch();
-    m_headerLayout->addWidget(m_export);
+    m_headerLayout->addSpacing(20);
     m_headerLayout->addWidget(m_close);
-    m_headerLayout->addSpacing(10);
+    m_headerLayout->addStretch();
 
     m_contentLayout->addWidget(m_tree);
     m_contentLayout->addWidget(m_seperator);
@@ -129,7 +126,6 @@ void ProjectView::initLayout()
 
 void ProjectView::connectSigalsAndSlots()
 {
-    connect(m_export, &PushButton::clicked, this, &ProjectView::exportClicked);
     connect(m_close, &PushButton::clicked, this, &ProjectView::sigClose);
     connect(m_tree, &TreeWidget::itemClicked, this, &ProjectView::itemClicked);
 }
@@ -156,8 +152,3 @@ void ProjectView::itemClicked(QTreeWidgetItem *item, int column)
 
     showEvalWidget(eval, taskIndex);
 }
-
-void ProjectView::exportClicked()
-{
-    qDebug() << __FUNCTION__ << __LINE__ << endl;
-}

+ 1 - 3
QFD/view/ProjectView.h

@@ -43,7 +43,6 @@ private:
 
 private slots:
     void itemClicked(QTreeWidgetItem *item, int column);
-    void exportClicked();
 
 private:
     ProjectInfo *m_proj = nullptr;
@@ -53,14 +52,13 @@ private:
     QHBoxLayout *m_contentLayout = nullptr;
 
     QLabel *m_title      = nullptr;
-    PushButton *m_export = nullptr;
     PushButton *m_close  = nullptr;
     TreeWidget *m_tree   = nullptr;
     QWidget *m_seperator = nullptr;
 
     QStackedWidget *m_stack                = nullptr;
     IndexSystemWidget *m_indexSystem       = nullptr;
-    SchemePlanWidget *m_schemeDesign     = nullptr;
+    SchemePlanWidget *m_schemeDesign       = nullptr;
     DataCollectionWidget *m_dataCollection = nullptr;
     DataProcessingWidget *m_dataProcessing = nullptr;
 };

+ 7 - 4
QFD/widgets/EvalWidget.cpp

@@ -2,6 +2,8 @@
 
 #include "dbService/ClassSet.h"
 
+#include <Widgets/Button.h>
+
 #include <QLabel>
 #include <QLayout>
 #include <QTabWidget>
@@ -65,12 +67,13 @@ void EvalWidget::initWidgets()
 
 void EvalWidget::initLayout()
 {
-    m_layout        = new QVBoxLayout(this);
-    m_contentLayout = new QHBoxLayout();
-
-    m_layout->addWidget(m_title);
+    m_layout    = new QVBoxLayout(this);
+    m_topLayout = new QHBoxLayout(this);
+    m_layout->addLayout(m_topLayout);
     m_layout->addWidget(m_seperator);
+    m_contentLayout = new QHBoxLayout();
     m_layout->addLayout(m_contentLayout);
 
+    m_topLayout->addWidget(m_title);
     m_contentLayout->addWidget(m_tab);
 }

+ 2 - 0
QFD/widgets/EvalWidget.h

@@ -6,6 +6,7 @@
 #include "ProjectManager.h"
 
 class ProjectInfo;
+class PushButton;
 
 class QVBoxLayout;
 class QHBoxLayout;
@@ -40,6 +41,7 @@ protected:
     QTabWidget *m_tab = nullptr;
 
     QVBoxLayout *m_layout        = nullptr;
+    QHBoxLayout *m_topLayout     = nullptr;
     QHBoxLayout *m_contentLayout = nullptr;
 
     QLabel *m_title      = nullptr;

+ 30 - 22
QFD/widgets/SchemeFlowWidget.cpp

@@ -109,39 +109,51 @@ void SchemeFlowWidget::setType(int t)
     refresh();
 }
 
-QList<SchemePlanManager::SchemeProcessType> SchemeFlowWidget::schemeTemplate(int indexType)
+QList<SchemePlanManager::SchemeProcessInfo> SchemeFlowWidget::schemeTemplate(int projId, int indexType)
 {
     /// 方案流程模板
-    QList<SchemePlanManager::SchemeProcessType> scheme;
+
+    QList<SchemePlanManager::SchemeProcessType> types;
     switch (indexType) {
     case ProjectManager::AbilityIndex: {
-        scheme = { SchemePlanManager::IndexSystem,    SchemePlanManager::ImportWeightData,
-                   SchemePlanManager::OptimizeIndex,  SchemePlanManager::CalculateWeight,
-                   SchemePlanManager::ShowEvalResult, SchemePlanManager::GenerateReport };
+        types = { SchemePlanManager::IndexSystem,    SchemePlanManager::ImportWeightData,
+                  SchemePlanManager::OptimizeIndex,  SchemePlanManager::CalculateWeight,
+                  SchemePlanManager::ShowEvalResult, SchemePlanManager::GenerateReport };
+        //        types = { SchemePlanManager::IndexSystem };
         break;
     }
     case ProjectManager::TechIndex: {
-        scheme = { SchemePlanManager::IndexSystem, SchemePlanManager::ImportEvalData, SchemePlanManager::RunEvaluate,
-                   SchemePlanManager::ShowEvalResult, SchemePlanManager::GenerateReport };
+        types = { SchemePlanManager::IndexSystem, SchemePlanManager::ImportEvalData, SchemePlanManager::RunEvaluate,
+                  SchemePlanManager::ShowEvalResult, SchemePlanManager::GenerateReport };
         break;
     }
     case ProjectManager::OptimalIndex: {
-        scheme = { SchemePlanManager::IndexSystem,    SchemePlanManager::ImportWeightData,
-                   SchemePlanManager::OptimizeIndex,  SchemePlanManager::CalculateWeight,
-                   SchemePlanManager::ImportEvalData, SchemePlanManager::RunEvaluate,
-                   SchemePlanManager::ShowEvalResult, SchemePlanManager::GenerateReport };
+        types = { SchemePlanManager::IndexSystem,    SchemePlanManager::ImportWeightData,
+                  SchemePlanManager::OptimizeIndex,  SchemePlanManager::CalculateWeight,
+                  SchemePlanManager::ImportEvalData, SchemePlanManager::RunEvaluate,
+                  SchemePlanManager::ShowEvalResult, SchemePlanManager::GenerateReport };
         break;
     }
     case ProjectManager::EfficiencyIndex: {
-        scheme = { SchemePlanManager::IndexSystem,    SchemePlanManager::ImportWeightData,
-                   SchemePlanManager::OptimizeIndex,  SchemePlanManager::CalculateWeight,
-                   SchemePlanManager::ImportEvalData, SchemePlanManager::RunEvaluate,
-                   SchemePlanManager::ShowEvalResult, SchemePlanManager::GenerateReport };
+        types = { SchemePlanManager::IndexSystem,    SchemePlanManager::ImportWeightData,
+                  SchemePlanManager::OptimizeIndex,  SchemePlanManager::CalculateWeight,
+                  SchemePlanManager::ImportEvalData, SchemePlanManager::RunEvaluate,
+                  SchemePlanManager::ShowEvalResult, SchemePlanManager::GenerateReport };
         break;
     }
     }
 
-    return scheme;
+    QList<SchemePlanManager::SchemeProcessInfo> schemes;
+    for (int i = 0; i < types.count(); i++) {
+        SchemePlanManager::SchemeProcessInfo process;
+        process.projectId = projId;
+        process.indexType = indexType;
+        process.type      = types[i];
+        process.step      = i;
+        schemes.append(process);
+    }
+
+    return schemes;
 }
 
 void SchemeFlowWidget::initWidget()
@@ -173,17 +185,13 @@ void SchemeFlowWidget::refresh()
     int space     = 50;  // 流程图节点间距
     NodeId lastId = -1;
 
-    QList<SchemePlanManager::SchemeProcessType> scheme = schemeTemplate(m_indexType);
+    QList<SchemePlanManager::SchemeProcessInfo> scheme = schemeTemplate(m_proj->id, m_indexType);
     for (int i = 0; i < scheme.count(); i++) {
         NodeId id = m_graphModel->addNode(FlowCommonData().type().id);
         m_graphModel->setNodeData(id, NodeRole::Position, QPointF(0, y));
         FlowGraphCommonNodeWidget *w = new FlowGraphCommonNodeWidget();
         connect(w, &FlowGraphCommonNodeWidget::sigProcessChanged, this, &SchemeFlowWidget::slotSchemeProcessEdited);
-        SchemePlanManager::SchemeProcessInfo process;
-        process.projectId = m_proj->id;
-        process.indexType = m_indexType;
-        process.type      = scheme[i];
-        process.step      = i;
+        SchemePlanManager::SchemeProcessInfo process = scheme[i];
         w->setProcess(process);
         if (w->isTitleHidden()) {
             m_graphModel->setNodeData(id, NodeRole::Caption, SchemePlanManager::processName(process));

+ 1 - 4
QFD/widgets/SchemeFlowWidget.h

@@ -46,8 +46,7 @@ public:
 
     void setType(int t);
 
-    static QList<SchemePlanManager::SchemeProcessType> schemeTemplate(int indexType);
-
+    QList<SchemePlanManager::SchemeProcessInfo> schemeTemplate(int projId, int indexType);
 signals:
 
 private:
@@ -64,8 +63,6 @@ private:
     ProjectInfo *m_proj = nullptr;
     int m_indexType     = 0;
 
-    //    GraphicsView *m_view = nullptr;
-
     DataFlowModel *m_graphModel = nullptr;
 
     QHBoxLayout *m_layout = nullptr;

+ 18 - 0
QFD/widgets/SchemePlanWidget.cpp

@@ -4,6 +4,8 @@
 
 #include <CSchemeView.h>
 
+#include <Widgets/Button.h>
+
 #include <QTabWidget>
 #include <QLayout>
 
@@ -12,6 +14,7 @@
 SchemePlanWidget::SchemePlanWidget(ProjectInfo *proj, QWidget *parent) : EvalWidget(proj, parent)
 {
     setTitle("评估方案规划");
+    setupUI();
 }
 
 void SchemePlanWidget::setType(int type)
@@ -20,6 +23,16 @@ void SchemePlanWidget::setType(int type)
     setupTabWidget();
 }
 
+void SchemePlanWidget::setupUI()
+{
+    m_topLayout->addStretch();
+    m_save = new PushButton("保存", this);
+    m_topLayout->addWidget(m_save);
+    m_topLayout->addSpacing(10);
+
+    connect(m_save, &PushButton::clicked, this, &SchemePlanWidget::slotSaveClicked);
+}
+
 void SchemePlanWidget::setupTabWidget()
 {
     m_tab->clear();
@@ -31,3 +44,8 @@ void SchemePlanWidget::setupTabWidget()
         m_tab->addTab(m, s);
     }
 }
+
+void SchemePlanWidget::slotSaveClicked()
+{
+    qDebug() << __FUNCTION__ << __LINE__ << endl;
+}

+ 10 - 0
QFD/widgets/SchemePlanWidget.h

@@ -3,6 +3,8 @@
 
 #include "EvalWidget.h"
 
+class PushButton;
+
 /**
  * @brief The SchemePlanWidget class
  * 方案规划页面
@@ -15,8 +17,16 @@ public:
 
     void setType(int type) override;
 
+    void setupUI();
+
 private:
     void setupTabWidget();
+
+private slots:
+    void slotSaveClicked();
+
+private:
+    PushButton *m_save = nullptr;
 };
 
 #endif  // SCHEMEPLANWIDGET_H

+ 4 - 4
QtNodes/src/DataFlowGraphModel.cpp

@@ -196,13 +196,13 @@ QVariant DataFlowGraphModel::nodeData(NodeId nodeId, NodeRole role) const
     }
 
     case NodeRole::InPortCount:
-        //        result = model->nPorts(PortType::In);
-        result = _inPorts[nodeId];
+        result = model->nPorts(PortType::In);
+        //        result = _inPorts[nodeId];
         break;
 
     case NodeRole::OutPortCount:
-        //        result = model->nPorts(PortType::Out);
-        result = _outPorts[nodeId];
+        result = model->nPorts(PortType::Out);
+        //        result = _outPorts[nodeId];
         break;
 
     case NodeRole::Widget: {