Browse Source

导出指标体系截图。

Ulricy 1 year ago
parent
commit
b0e135c004

+ 173 - 4
QFD/common/ExportReportManager.cpp

@@ -2,6 +2,7 @@
 
 #include "ProjectManager.h"
 #include "SchemePlanManager.h"
+#include "CMindView.h"
 
 #include <view/PlotView.h>
 
@@ -231,6 +232,48 @@ void ExportReportManager::insertDemandIndex()
     }
 
     delete mind;
+
+    CMindView *m = new CMindView();
+    m->setNodeList(nodeList);
+    m->refreshItems();
+
+    int sceneWidth    = m->sceneRect().width();
+    int sceneHeight   = m->sceneRect().height();
+    QRectF sourceRect = QRectF(0, 0, sceneWidth, sceneHeight);
+    QRectF targetRect = QRectF(10, 10, sceneWidth, sceneHeight);
+
+    QPixmap pixmap(QSize(sceneWidth + 20, sceneHeight + 20));
+    pixmap.fill(QColor(244, 244, 255));
+    QPainter painter(&pixmap);
+    painter.setRenderHints(QPainter::Antialiasing);
+    m->scene()->render(&painter, targetRect, sourceRect);
+    delete m;
+
+    QString imgName = QString("%1_%2_index").arg(m_proj->id).arg(1);
+    QString path    = saveImage(imgName, pixmap);
+
+    QImageWriter writer(path);
+    writer.setFormat("PNG");
+    ret = writer.write(pixmap.toImage());
+    if (ret) {
+        QAxObject *bmWeightPic = m_word->getDocument()->querySubObject("Bookmarks(QVariant)", "bmIndexPic");
+        if (bmWeightPic != nullptr) {
+            bmWeightPic->dynamicCall("Select(void)");
+            QAxObject *range        = bmWeightPic->querySubObject("Range");
+            QAxObject *inlineShapes = range->querySubObject("InlineShapes");
+            QAxObject *shape        = inlineShapes->querySubObject("AddPicture(const QString&)", path);
+            if (shape != nullptr) {
+                int w = pixmap.width();
+                int h = pixmap.height();
+                if (w > 400) {
+                    h = h * 400 / w;
+                    w = 400;
+                }
+                shape->setProperty("Width", w);
+                shape->setProperty("Height", h);
+            }
+        }
+    }
 }
 
 void ExportReportManager::insertDemandTechIndex()
@@ -282,6 +325,48 @@ void ExportReportManager::insertDemandTechIndex()
     }
 
     delete mind;
+
+    CMindView *m = new CMindView();
+    m->setNodeList(nodeList);
+    m->refreshItems();
+
+    int sceneWidth    = m->sceneRect().width();
+    int sceneHeight   = m->sceneRect().height();
+    QRectF sourceRect = QRectF(0, 0, sceneWidth, sceneHeight);
+    QRectF targetRect = QRectF(10, 10, sceneWidth, sceneHeight);
+
+    QPixmap pixmap(QSize(sceneWidth + 20, sceneHeight + 20));
+    pixmap.fill(QColor(244, 244, 255));
+    QPainter painter(&pixmap);
+    painter.setRenderHints(QPainter::Antialiasing);
+    m->scene()->render(&painter, targetRect, sourceRect);
+    delete m;
+
+    QString imgName = QString("%1_%2_index").arg(m_proj->id).arg(2);
+    QString path    = saveImage(imgName, pixmap);
+
+    QImageWriter writer(path);
+    writer.setFormat("PNG");
+    ret = writer.write(pixmap.toImage());
+    if (ret) {
+        QAxObject *bmWeightPic = m_word->getDocument()->querySubObject("Bookmarks(QVariant)", "bmTechPic");
+        if (bmWeightPic != nullptr) {
+            bmWeightPic->dynamicCall("Select(void)");
+            QAxObject *range        = bmWeightPic->querySubObject("Range");
+            QAxObject *inlineShapes = range->querySubObject("InlineShapes");
+            QAxObject *shape        = inlineShapes->querySubObject("AddPicture(const QString&)", path);
+            if (shape != nullptr) {
+                int w = pixmap.width();
+                int h = pixmap.height();
+                if (w > 400) {
+                    h = h * 400 / w;
+                    w = 400;
+                }
+                shape->setProperty("Width", w);
+                shape->setProperty("Height", h);
+            }
+        }
+    }
 }
 
 void ExportReportManager::insertDemandWeight()
@@ -371,7 +456,7 @@ void ExportReportManager::insertDemandWeight()
         return;
     }
 
-    QString imgName = QString("%1_%2_weight").arg(m_proj->id).arg(1);
+    QString imgName = QString("%1_%2_weight_plot").arg(m_proj->id).arg(1);
     QString path    = saveImage(imgName, pixmap);
 
     QAxObject *bmWeightPic = m_word->getDocument()->querySubObject("Bookmarks(QVariant)", "bmWeightPic");
@@ -469,7 +554,7 @@ void ExportReportManager::insertDemandEval()
         return;
     }
 
-    QString imgName = QString("%1_%2_tech").arg(m_proj->id).arg(1);
+    QString imgName = QString("%1_%2_priority_plot").arg(m_proj->id).arg(1);
     QString path    = saveImage(imgName, pixmap);
 
     QAxObject *bmWeightPic = m_word->getDocument()->querySubObject("Bookmarks(QVariant)", "bmEvalPic");
@@ -601,6 +686,48 @@ void ExportReportManager::insertSchemeIndex()
     }
 
     delete mind;
+
+    CMindView *m = new CMindView();
+    m->setNodeList(nodeList);
+    m->refreshItems();
+
+    int sceneWidth    = m->sceneRect().width();
+    int sceneHeight   = m->sceneRect().height();
+    QRectF sourceRect = QRectF(0, 0, sceneWidth, sceneHeight);
+    QRectF targetRect = QRectF(10, 10, sceneWidth, sceneHeight);
+
+    QPixmap pixmap(QSize(sceneWidth + 20, sceneHeight + 20));
+    pixmap.fill(QColor(244, 244, 255));
+    QPainter painter(&pixmap);
+    painter.setRenderHints(QPainter::Antialiasing);
+    m->scene()->render(&painter, targetRect, sourceRect);
+    delete m;
+
+    QString imgName = QString("%1_%2_index").arg(m_proj->id).arg(4);
+    QString path    = saveImage(imgName, pixmap);
+
+    QImageWriter writer(path);
+    writer.setFormat("PNG");
+    ret = writer.write(pixmap.toImage());
+    if (ret) {
+        QAxObject *bmWeightPic = m_word->getDocument()->querySubObject("Bookmarks(QVariant)", "bmIndexPic");
+        if (bmWeightPic != nullptr) {
+            bmWeightPic->dynamicCall("Select(void)");
+            QAxObject *range        = bmWeightPic->querySubObject("Range");
+            QAxObject *inlineShapes = range->querySubObject("InlineShapes");
+            QAxObject *shape        = inlineShapes->querySubObject("AddPicture(const QString&)", path);
+            if (shape != nullptr) {
+                int w = pixmap.width();
+                int h = pixmap.height();
+                if (w > 400) {
+                    h = h * 400 / w;
+                    w = 400;
+                }
+                shape->setProperty("Width", w);
+                shape->setProperty("Height", h);
+            }
+        }
+    }
 }
 
 void ExportReportManager::insertSchemeData()
@@ -839,7 +966,7 @@ void ExportReportManager::insertSchemeWeightData()
         return;
     }
 
-    QString imgName = QString("%1_%2_weight").arg(m_proj->id).arg(4);
+    QString imgName = QString("%1_%2_weight_plot").arg(m_proj->id).arg(4);
     QString path    = saveImage(imgName, pixmap);
 
     QAxObject *bmWeightPic = m_word->getDocument()->querySubObject("Bookmarks(QVariant)", "bmWeightPic");
@@ -910,6 +1037,48 @@ void ExportReportManager::insertEffiIndex()
     }
 
     delete mind;
+
+    CMindView *m = new CMindView();
+    m->setNodeList(nodeList);
+    m->refreshItems();
+
+    int sceneWidth    = m->sceneRect().width();
+    int sceneHeight   = m->sceneRect().height();
+    QRectF sourceRect = QRectF(0, 0, sceneWidth, sceneHeight);
+    QRectF targetRect = QRectF(10, 10, sceneWidth, sceneHeight);
+
+    QPixmap pixmap(QSize(sceneWidth + 20, sceneHeight + 20));
+    pixmap.fill(QColor(244, 244, 255));
+    QPainter painter(&pixmap);
+    painter.setRenderHints(QPainter::Antialiasing);
+    m->scene()->render(&painter, targetRect, sourceRect);
+    delete m;
+
+    QString imgName = QString("%1_%2_index").arg(m_proj->id).arg(8);
+    QString path    = saveImage(imgName, pixmap);
+
+    QImageWriter writer(path);
+    writer.setFormat("PNG");
+    ret = writer.write(pixmap.toImage());
+    if (ret) {
+        QAxObject *bmWeightPic = m_word->getDocument()->querySubObject("Bookmarks(QVariant)", "bmIndexPic");
+        if (bmWeightPic != nullptr) {
+            bmWeightPic->dynamicCall("Select(void)");
+            QAxObject *range        = bmWeightPic->querySubObject("Range");
+            QAxObject *inlineShapes = range->querySubObject("InlineShapes");
+            QAxObject *shape        = inlineShapes->querySubObject("AddPicture(const QString&)", path);
+            if (shape != nullptr) {
+                int w = pixmap.width();
+                int h = pixmap.height();
+                if (w > 400) {
+                    h = h * 400 / w;
+                    w = 400;
+                }
+                shape->setProperty("Width", w);
+                shape->setProperty("Height", h);
+            }
+        }
+    }
 }
 
 void ExportReportManager::insertEffiAlgInfo()
@@ -1210,7 +1379,7 @@ void ExportReportManager::insertEffiWeightData()
         return;
     }
 
-    QString imgName = QString("%1_%2_weight").arg(m_proj->id).arg(4);
+    QString imgName = QString("%1_%2_weight_plot").arg(m_proj->id).arg(8);
     QString path    = saveImage(imgName, pixmap);
 
     QAxObject *bmWeightPic = m_word->getDocument()->querySubObject("Bookmarks(QVariant)", "bmWeightPic");

+ 2 - 0
QFD/common/ExportReportManager.h

@@ -118,11 +118,13 @@ private:
  * 描述项目名称:bmProjName21
  * 表格项目名称:bmProjName22
  * 表格:bmIndexTable
+ * 图片:bmIndexPic
  *
  * 技术措施梳理
  * 描述项目名称:bmProjName21
  * 表格项目名称:bmProjName32
  * 表格:bmTechTable
+ * 图片:bmTechPic
  *
  * 计算
  * 权重算法:bmWeightAlg,指标权重表:bmWeightTable,指标权重图:bmWeightPic

+ 38 - 0
QFD/widgets/IndexSystemWidget.cpp

@@ -76,6 +76,7 @@ void IndexSystemWidget::setupTabWidget()
         if (ret) {
             m->setNodeList(list);
             m->refreshItems();
+            saveIndexPic(list, i);
         }
 
         connect(m, &CMindView::sigEditNode, this, &IndexSystemWidget::slotEditNode);
@@ -139,6 +140,7 @@ bool IndexSystemWidget::hasData(QString indexName) const
 
 void IndexSystemWidget::saveIndexPic()
 {
+    return;
     if (indexList().size() <= 0 || m_tab->currentIndex() < 0) {
         return;
     }
@@ -175,6 +177,40 @@ void IndexSystemWidget::saveIndexPic()
     qDebug() << __FUNCTION__ << __LINE__ << ret << endl;
 }
 
+void IndexSystemWidget::saveIndexPic(QList<CNodeData> nodeList, int indexType)
+{
+    return;
+    QString curPath = QDir::currentPath();
+    QString picDir  = curPath + "/index_pics/" + "/";
+    QDir dir(picDir);
+    if (!dir.exists()) {
+        dir.mkpath(picDir);
+    }
+    QString name     = QString("%1_%2").arg(m_proj->id).arg(indexType);
+    QString filePath = picDir + name + ".png";
+
+    CMindView *m = new CMindView();
+    m->setNodeList(nodeList);
+    m->refreshItems();
+
+    int sceneWidth    = m->sceneRect().width();
+    int sceneHeight   = m->sceneRect().height();
+    QRectF sourceRect = QRectF(0, 0, sceneWidth, sceneHeight);
+    QRectF targetRect = QRectF(10, 10, sceneWidth, sceneHeight);
+
+    QPixmap pixmap(QSize(sceneWidth + 20, sceneHeight + 20));
+    pixmap.fill(QColor(244, 244, 255));
+    QPainter painter(&pixmap);
+    painter.setRenderHints(QPainter::Antialiasing);
+    m->scene()->render(&painter, targetRect, sourceRect);
+    delete m;
+
+    QImageWriter writer(filePath);
+    writer.setFormat("PNG");
+    bool ret = writer.write(pixmap.toImage());
+    qDebug() << __FUNCTION__ << __LINE__ << ret << endl;
+}
+
 void IndexSystemWidget::slotTabCurrentChanged(int c)
 {
     bool ret     = hasData(m_tab->tabText(c));
@@ -185,6 +221,8 @@ void IndexSystemWidget::slotTabCurrentChanged(int c)
         QList<CNodeData> list = m->mind()->nodeList();
         m->setNodeList(list);
     }
+
+    saveIndexPic();
 }
 
 void IndexSystemWidget::slotSelectAllNodes() { }

+ 2 - 0
QFD/widgets/IndexSystemWidget.h

@@ -38,6 +38,8 @@ private:
 
     void saveIndexPic();
 
+    void saveIndexPic(QList<CNodeData> nodeList, int indexType);
+
 signals:
 
 public slots: