program clown 1 year ago
parent
commit
e802ddb713

+ 10 - 7
QFD/view/PlotView.cpp

@@ -159,27 +159,30 @@ void PlotView::drawHistogram(bool horizontal)
     QVector<double> ticks;
     QVector<QString> labels;
     QVector<double> fossilData;
+    double maxValue = 0;
     for (int i = 0; i < m_sourceData.size(); ++i) {
         ticks << i + 1;
         labels << m_sourceData.at(i).name;
         fossilData << m_sourceData.at(i).value;
+        maxValue = qMax(maxValue, m_sourceData.at(i).value);
     }
+
     QSharedPointer<QCPAxisTickerText> textTicker(new QCPAxisTickerText);
     textTicker->addTicks(ticks, labels);
 
     keyAxis->setTicker(textTicker);  // 设置为文字轴
 
-    keyAxis->setTickLabelRotation(60);  // 轴刻度文字旋转60度
-    keyAxis->setSubTicks(false);        // 不显示子刻度
-    keyAxis->setTickLength(0, 4);       // 轴内外刻度的长度分别是0,4,也就是轴内的刻度线不显示
-    keyAxis->setRange(0, ticks.size() + 1);  // 设置范围
+    keyAxis->setTickLabelRotation(horizontal ? 15 : 75);  // 轴刻度文字旋转60度
+    keyAxis->setSubTicks(false);                          // 不显示子刻度
+    keyAxis->setTickLength(0, 4);  // 轴内外刻度的长度分别是0,4,也就是轴内的刻度线不显示
+    keyAxis->setRange(0, ticks.size() + 2);  // 设置范围
     keyAxis->setUpperEnding(QCPLineEnding::esSpikeArrow);
 
     if (!m_title.isEmpty()) {
         keyAxis->setLabel(m_title);
     }
 
-    valueAxis->setRange(0, 1.1);
+    valueAxis->setRange(0, 1.1 * maxValue);
     valueAxis->setPadding(35);  // 轴的内边距,可以到QCustomPlot之开始(一)看图解
     valueAxis->setUpperEnding(QCPLineEnding::esSpikeArrow);
     fossil->setData(ticks, fossilData);
@@ -221,10 +224,10 @@ void PlotView::drawCurve()
 
     keyAxis->setTicker(textTicker);  // 设置为文字轴
 
-    keyAxis->setTickLabelRotation(60);   // 轴刻度文字旋转60度
+    keyAxis->setTickLabelRotation(75);   // 轴刻度文字旋转60度
     keyAxis->setSubTicks(false);         // 不显示子刻度
     keyAxis->setTickLength(0, 4);        // 轴内外刻度的长度分别是0,4,也就是轴内的刻度线不显示
-    keyAxis->setRange(0, x.size() + 1);  // 设置范围
+    keyAxis->setRange(0, x.size() + 2);  // 设置范围
     keyAxis->setUpperEnding(QCPLineEnding::esSpikeArrow);
 
     if (!m_title.isEmpty()) {

+ 1 - 1
QFD/widgets/CreateProjWidget.cpp

@@ -204,7 +204,7 @@ void CreateProjWidget::initLayout()
 
     // 总体布局
     m_layout = new QVBoxLayout(this);
-    m_layout->setContentsMargins(50, 20, 50, 20);
+    m_layout->setContentsMargins(20, 20, 20, 20);
     m_layout->addWidget(m_summary);
     m_summaryLayout = new QGridLayout();
     m_layout->addLayout(m_summaryLayout);

+ 38 - 27
QFD/widgets/EvalReportWidget.cpp

@@ -99,8 +99,8 @@ void EvalReportWidget::initLayouts()
         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);
-        m_gridLayout->addWidget(m_indexPlot);
+        m_gridLayout->addWidget(m_indexTab, 1, 0);
+        m_gridLayout->addWidget(m_indexPlot, 1, 1);
     } else {
         m_techTitle = new QLabel(this);
         m_techTitle->setText("指标得分");
@@ -108,8 +108,8 @@ void EvalReportWidget::initLayouts()
         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);
-        m_gridLayout->addWidget(m_techPlot);
+        m_gridLayout->addWidget(m_techTable, 1, 0);
+        m_gridLayout->addWidget(m_techPlot, 1, 1);
     }
 
     if (m_indexType == ProjectManager::OptimalIndex || m_indexType == ProjectManager::EfficiencyIndex) {
@@ -125,8 +125,8 @@ void EvalReportWidget::initLayouts()
         m_schemeTitle->setContentsMargins(0, 50, 0, 10);
         m_gridLayout->addWidget(m_schemeTitle, 2, 0);
         m_gridLayout->addWidget(m_schemeCombo, 2, 1, Qt::AlignBottom);
-        m_gridLayout->addWidget(m_schemeTable);
-        m_gridLayout->addWidget(m_schemePlot);
+        m_gridLayout->addWidget(m_schemeTable, 3, 0);
+        m_gridLayout->addWidget(m_schemePlot, 3, 1);
     }
 
     QScrollArea *scroll = new QScrollArea;
@@ -208,6 +208,35 @@ void EvalReportWidget::showIndexWeight()
     }
 }
 
+void EvalReportWidget::showIndexWeightPlot()
+{
+    QTableView *table = (QTableView *)m_indexTab->currentWidget();
+    if (table == nullptr) {
+        return;
+    }
+    DataTableItemModel *model = (DataTableItemModel *)table->model();
+    if (model == nullptr) {
+        return;
+    }
+
+    QVector<PlotView::Data> 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);
+    }
+
+    m_gridLayout->removeWidget(m_indexPlot);
+    m_indexPlot->deleteLater();
+
+    PlotView::PlotType type = (PlotView::PlotType)m_indexCombo->currentIndex();
+    m_indexPlot             = new PlotView(type, values, "", this);
+    m_indexPlot->setFixedSize(600, 600);
+    m_indexPlot->plot();
+    m_gridLayout->addWidget(m_indexPlot, 1, 1);
+}
+
 void EvalReportWidget::showTechScore()
 {
     int levels = m_mind->levels();
@@ -289,10 +318,9 @@ void EvalReportWidget::makePlotClear(PlotView *plotView)
     plotView->clearPlottables();
 }
 
-void EvalReportWidget::slotSelectIndexPlotType(int type)
+void EvalReportWidget::slotSelectIndexPlotType(int)
 {
-    makePlotClear(m_indexPlot);
-    m_indexPlot->updateType(PlotView::PlotType(type));
+    showIndexWeightPlot();
 }
 
 void EvalReportWidget::slotSelectTechPlotType(int type)
@@ -309,22 +337,5 @@ void EvalReportWidget::slotSelectSchemePlotType(int type)
 
 void EvalReportWidget::slotIndexTabIndexChanged(int)
 {
-    QTableView *table = (QTableView *)m_indexTab->currentWidget();
-    if (table == nullptr) {
-        return;
-    }
-    DataTableItemModel *model = (DataTableItemModel *)table->model();
-    if (model == nullptr) {
-        return;
-    }
-
-    QVector<PlotView::Data> 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);
-    }
-    makePlotClear(m_indexPlot);
-    m_indexPlot->updateData(values);
+    showIndexWeightPlot();
 }

+ 3 - 0
QFD/widgets/EvalReportWidget.h

@@ -30,7 +30,10 @@ private:
     void loadData();
 
     void showIndexWeight();
+    void showIndexWeightPlot();
+
     void showTechScore();
+
     void showSchemeScore();
 
     void makePlotClear(PlotView *plotView);

+ 12 - 1
QFD/widgets/GreyClusteringConfigWidget.cpp

@@ -102,7 +102,7 @@ void GreyClusteringConfigWidget::initFormLayout()
         ui->grayFormLayout->addRow(iter.key() + ":", le);
     }
 
-    qDebug() << ui->grayFormLayout->rowCount();
+    //    qDebug() << ui->grayFormLayout->rowCount();
 
     connect(ui->graySaveBtn, &QToolButton::clicked, this, &GreyClusteringConfigWidget::onConfirmClick);
     connect(ui->editGrayBtn, &QToolButton::clicked, [=]() { ui->stackedWidget->setCurrentIndex(0); });
@@ -212,8 +212,18 @@ void GreyClusteringConfigWidget::initClusteringItems()
                     for (int str = 0; str < align; str++) {
                         //[0:0]
                         QStringList lr = valueList.at(str).mid(1, valueList.at(str).size() - 2).split(":");
+                        if (valueList.at(str).left(1) == "[") {
+                            item.value->greyRanges[str].leftClose = true;
+                        } else {
+                            item.value->greyRanges[str].leftClose = false;
+                        }
                         item.value->greyRanges[str].leftValue  = lr.at(0).toDouble();
                         item.value->greyRanges[str].rightValue = lr.at(1).toDouble();
+                        if (valueList.at(str).right(1) == "]") {
+                            item.value->greyRanges[str].rightClose = true;
+                        } else {
+                            item.value->greyRanges[str].rightClose = false;
+                        }
                     }
                 }
             }
@@ -438,6 +448,7 @@ void GreyClusteringConfigWidget::onConfigSaveBtnClick()
             QString str                          = m_model->item(item.row, nodeDepth + r + 1)->text();
             item.value->greyRanges[r].leftClose  = str[0] == "[";
             item.value->greyRanges[r].rightClose = str.right(1) == "]";
+
             QStringList list                     = str.mid(1, str.size() - 2).replace(" ", "").split(",");
             item.value->greyRanges[r].leftValue  = list.at(0).toDouble();
             item.value->greyRanges[r].rightValue = list.at(1).toDouble();

+ 1 - 1
QFD/widgets/GreyClusteringItemDelegate.cpp

@@ -36,7 +36,7 @@ void GreyClusteringItemRangeDelegate::updateEditorGeometry(QWidget *editor, cons
                                                            const QModelIndex & /* index */) const
 {
     QRect rect = option.rect;
-    rect.adjust(-10, -10, 10, 10);
+    rect.adjust(-20, -10, 20, 10);
     editor->setGeometry(rect);
 }
 

+ 30 - 2
QFD/widgets/GreyClusteringItemDelegate.h

@@ -7,6 +7,7 @@
 #include <QLabel>
 #include <QDoubleSpinBox>
 #include <QPushButton>
+#include <QCheckBox>
 
 class RangeSpin : public QFrame
 {
@@ -22,12 +23,21 @@ public:
         QLabel *maxLabel = new QLabel("右");
         m_leftSpin       = new QDoubleSpinBox;
         m_rightSpin      = new QDoubleSpinBox;
+        m_leftChb        = new QCheckBox;
+        m_leftChb->setCheckable(true);
+        m_leftChb->setChecked(true);
+        m_rightChb = new QCheckBox;
+        m_rightChb->setCheckable(true);
+        m_rightChb->setChecked(true);
+
         m_leftSpin->setRange(-1000000, 1000000);
         m_rightSpin->setRange(-1000000, 1000000);
 
         hLayout->addWidget(minLabel);
+        hLayout->addWidget(m_leftChb);
         hLayout->addWidget(m_leftSpin);
         hLayout->addWidget(m_rightSpin);
+        hLayout->addWidget(m_rightChb);
         hLayout->addWidget(maxLabel);
         setLayout(hLayout);
     }
@@ -56,18 +66,36 @@ public:
     {
         if (!value.isEmpty()) {
             QStringList tmp = value.mid(1, value.size() - 2).replace(" ", "").split(",");
+            if (value[0] == "[") {
+                m_leftChb->setChecked(true);
+            } else {
+                m_leftChb->setChecked(false);
+            }
             m_leftSpin->setValue(tmp[0].toDouble());
             m_rightSpin->setValue(tmp[1].toDouble());
+            if (value.right(1) == "]") {
+                m_rightChb->setChecked(true);
+            } else {
+                m_rightChb->setChecked(false);
+            }
         }
     }
 
 private slots:
-    void onConfirm() { m_result = QString("[%1, %2]").arg(m_leftSpin->value()).arg(m_rightSpin->value()); }
+    void onConfirm()
+    {
+        m_result = QString("%1%2, %3%4")
+                           .arg(m_leftChb->isChecked() ? "[" : "(")
+                           .arg(m_leftSpin->value())
+                           .arg(m_rightSpin->value())
+                           .arg(m_rightChb->isChecked() ? "]" : ")");
+    }
 
 private:
     QDoubleSpinBox *m_leftSpin;
     QDoubleSpinBox *m_rightSpin;
-
+    QCheckBox *m_leftChb;
+    QCheckBox *m_rightChb;
     QString m_result;
 };