EvalDataManager.cpp 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. #include "EvalDataManager.h"
  2. #include "ProjectManager.h"
  3. EvalDataManager::EvalDataManager(QObject *parent) : QObject(parent) { }
  4. QList<NodeMatrixInfo> EvalDataManager::dataSample(SchemePlanManager::SchemeProcessInfo process, CMind *mind1,
  5. CMind *mind2)
  6. {
  7. QList<NodeMatrixInfo> list;
  8. if (mind1->levels() < 2) {
  9. return list;
  10. }
  11. unsigned seed = 1;
  12. srand(seed);
  13. for (int lev = 1; lev < mind1->levels(); lev++) {
  14. QList<CNodeData> nodes = mind1->nodesInLevel(lev);
  15. for (int i = 0; i < nodes.count(); i++) {
  16. CNodeData node = nodes[i]; // 父节点
  17. QList<CNodeData> subNodes = mind1->subNodes(node);
  18. for (int i = 0; i < subNodes.count(); i++) {
  19. CNodeData subNode = subNodes[i]; // 子节点
  20. }
  21. }
  22. }
  23. return list;
  24. // 权重数据
  25. if (process.type == SchemePlanManager::ImportWeightData) {
  26. // 来自专家数据, 子指标间的权重比
  27. if (process.dSource == SchemePlanManager::FromExpert) {
  28. for (int lev = 1; lev < mind1->levels(); lev++) {
  29. QList<CNodeData> nodes = mind1->nodesInLevel(lev);
  30. for (CNodeData node : nodes) {
  31. QList<CNodeData> subNodes = mind1->subNodes(node);
  32. for (int i = 0; i < subNodes.count(); i++) {
  33. CNodeData vNode = subNodes[i];
  34. for (int j = i; j < subNodes.count(); j++) {
  35. CNodeData hNode = subNodes[j];
  36. NodeMatrixInfo data;
  37. data.engineerId = node.projectId;
  38. data.mark = QString("%1").arg(lev);
  39. data.abscissa = QString("%1").arg(hNode.id);
  40. data.ordinate = QString("%1").arg(vNode.id);
  41. if (i == j) {
  42. data.nodeValue = "1";
  43. list.append(data);
  44. continue;
  45. }
  46. int r = rand() % 8 + 2;
  47. data.nodeValue = QString("%1").arg(r);
  48. list.append(data);
  49. NodeMatrixInfo data1;
  50. data1.engineerId = node.projectId;
  51. data1.mark = QString("%1").arg(lev);
  52. data1.abscissa = QString("%1").arg(vNode.id);
  53. data1.ordinate = QString("%1").arg(hNode.id);
  54. data1.nodeValue = QString("1/%1").arg(r);
  55. list.append(data1);
  56. }
  57. }
  58. }
  59. }
  60. } else if (process.dSource == SchemePlanManager::FromMeasurement) {
  61. for (int i = 0; i < mind1->nodeList().count(); i++) {
  62. CNodeData node = mind1->nodeList()[i];
  63. NodeMatrixInfo data;
  64. data.engineerId = node.projectId;
  65. data.abscissa = QString("%1").arg(node.id);
  66. int r = rand() % 8 + 2;
  67. data.nodeValue = QString("%1").arg(r);
  68. list.append(data);
  69. }
  70. }
  71. } else if (process.type == SchemePlanManager::ImportEvalData) {
  72. if (process.indexType == ProjectManager::TechIndex) {
  73. for (int i = 0; i < mind1->nodeList().count(); i++) {
  74. CNodeData hNode = mind1->nodeList()[i];
  75. for (int j = 0; j < mind2->nodeList().count(); j++) {
  76. CNodeData vNode = mind2->nodeList()[j];
  77. NodeMatrixInfo data;
  78. data.engineerId = hNode.projectId;
  79. data.abscissa = QString("%1").arg(hNode.id);
  80. data.ordinate = QString("%1").arg(vNode.id);
  81. int r = rand() % 8 + 2;
  82. data.nodeValue = QString("%1").arg(r);
  83. list.append(data);
  84. }
  85. }
  86. }
  87. }
  88. return list;
  89. }