main.cpp 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. #include "view/MainWindow.h"
  2. #include "helper/GenerateMiniDump.h"
  3. #include <QApplication>
  4. #include <QTranslator>
  5. #include <QScreen>
  6. #include <QDesktopWidget>
  7. #include <QTextCodec>
  8. #include <locale>
  9. #include <QSettings>
  10. #include "FileUtil.h"
  11. #include "ImportDataUtil.h"
  12. #include "dbService/ClassSet.h"
  13. #include "algorithm/GreyClusterEvaluation.h"
  14. #include <algorithm/MatterElementAnalysis.h>
  15. #include <windows.h>
  16. void test()
  17. {
  18. MEAMat mat;
  19. MEARangeMat ranges;
  20. // 样本1
  21. mat << QVector<double> { 2, 35, 2, 90, 2.5, 35, 70, 2.5, 35, 30, 2.5, 70, 25, 2, 50, 1, 45, 8, 60, 1 };
  22. // 样本2
  23. mat << QVector<double> { 4, 20, 3, 40, 0.5, 55, 90, 1.2, 55, 70, 1.2, 90, 60, 6, 20, 3, 75, 25, 25, 3 };
  24. qDebug() << mat[0].size() << mat[1].size();
  25. // 等级1
  26. ranges << QVector<MEARange> {
  27. { 0, true, false, 0, 1 }, { 1, true, false, 50, 100 }, { 2, true, false, 0, 1 },
  28. { 3, true, false, 60, 100 }, { 4, true, false, 3, 100 }, { 5, true, false, 0, 30 },
  29. { 6, true, false, 0, 60 }, { 7, true, false, 0, 1 }, { 8, true, false, 0, 30 },
  30. { 9, true, false, 0, 60 }, { 10, true, false, 2, 100 }, { 11, true, false, 0, 60 },
  31. { 12, true, false, 0, 30 }, { 13, true, false, 0, 1 }, { 14, true, false, 60, 100 },
  32. { 15, true, false, 0, 1 }, { 16, true, false, 0, 30 }, { 17, true, false, 0, 5 },
  33. { 18, true, false, 50, 100 }, { 19, true, false, 0, 1 },
  34. };
  35. // 等级1
  36. ranges << QVector<MEARange> {
  37. { 0, true, false, 2, 3 }, { 1, true, false, 5, 100 }, { 2, true, false, 1, 2 },
  38. { 3, true, false, 45, 60 }, { 4, true, false, 2, 3 }, { 5, true, false, 30, 50 },
  39. { 6, true, false, 60, 80 }, { 7, true, false, 1, 1.5 }, { 8, true, false, 30, 50 },
  40. { 9, true, false, 60, 80 }, { 10, true, false, 1.5, 2 }, { 11, true, false, 60, 80 },
  41. { 12, true, false, 30, 50 }, { 13, true, false, 1, 3 }, { 14, true, false, 45, 60 },
  42. { 15, true, false, 1, 2 }, { 16, true, false, 30, 50 }, { 17, true, false, 5, 10 },
  43. { 18, true, false, 30, 50 }, { 19, true, false, 1, 2 },
  44. };
  45. ranges << QVector<MEARange> {
  46. { 1, true, false, 3, 4 }, { 1, true, false, 20, 30 }, { 2, true, false, 2, 3 },
  47. { 3, true, false, 30, 45 }, { 4, true, false, 1, 2 }, { 5, true, false, 50, 80 },
  48. { 6, true, false, 80, 95 }, { 7, true, false, 1.5, 2 }, { 8, true, false, 50, 80 },
  49. { 9, true, false, 80, 95 }, { 10, true, false, 1, 1.5 }, { 11, true, false, 80, 95 },
  50. { 12, true, false, 50, 80 }, { 13, true, false, 3, 5 }, { 14, true, false, 30, 45 },
  51. { 15, true, false, 2, 3 }, { 16, true, false, 50, 80 }, { 17, true, false, 10, 20 },
  52. { 18, true, false, 20, 30 }, { 19, true, false, 2, 3 },
  53. };
  54. // 2
  55. ranges << QVector<MEARange> {
  56. { 0, true, false, 5, 100 }, { 1, true, false, 0, 20 }, { 2, true, false, 3, 100 },
  57. { 3, true, false, 0, 30 }, { 4, true, false, 0, 1 }, { 5, true, false, 80, 100 },
  58. { 6, true, false, 95, 100 }, { 7, true, false, 2, 100 }, { 8, true, false, 80, 100 },
  59. { 9, true, false, 95, 100 }, { 10, true, false, 0, 1 }, { 11, true, false, 95, 100 },
  60. { 12, true, false, 80, 100 }, { 13, true, false, 5, 100 }, { 14, true, false, 0, 30 },
  61. { 15, true, false, 3, 100 }, { 16, true, false, 80, 100 }, { 17, true, false, 20, 100 },
  62. { 18, true, false, 0, 20 }, { 19, true, false, 3, 100 }
  63. };
  64. // 等级范围p
  65. ranges << QVector<MEARange> {
  66. { 0, true, false, 0, 140 }, { 1, true, false, 120, 0 }, { 2, true, false, 0, 140 },
  67. { 3, true, false, 140, 0 }, { 4, true, false, 140, 0 }, { 5, true, false, 0, 100 },
  68. { 6, true, false, 0, 100 }, { 7, true, false, 0, 140 }, { 8, true, false, 0, 100 },
  69. { 9, true, false, 0, 100 }, { 10, true, false, 0, 100 }, { 11, true, false, 0, 100 },
  70. { 12, true, false, 0, 100 }, { 13, true, false, 0, 140 }, { 14, true, false, 140, 0 },
  71. { 15, true, false, 0, 140 }, { 16, true, false, 0, 100 }, { 17, true, false, 0, 140 },
  72. { 18, true, false, 140, 0 }, { 19, true, false, 0, 140 },
  73. };
  74. // 等级
  75. MatterElementAnalysis me(mat, ranges);
  76. me.evaluate({ 0.05558152, 0.01462673, 0.12860136, 0.0567758, 0.02524748, 0.05098171, 0.31008254,
  77. 0.12573223, 0.01327194, 0.01461917, 0.01931854, 0.05014989, 0.06026197, 0.01258931,
  78. 0.0281506, 0.00588096, 0.01585843, 0.00331298, 0.00740806, 0.00154762 });
  79. QVector<int> index = me.getBestIndex();
  80. qDebug() << index;
  81. }
  82. void cTest() { }
  83. int main(int argc, char *argv[])
  84. {
  85. DUMP_FILE_HOOK_HANLE;
  86. QTextCodec::setCodecForLocale(QTextCodec::codecForName("UTF-8"));
  87. std::locale::global(std::locale(""));
  88. #ifndef QT_NO_OPENGL
  89. QCoreApplication::setAttribute(Qt::AA_ShareOpenGLContexts, true);
  90. #endif
  91. QCoreApplication::setAttribute(Qt::AA_DontCreateNativeWidgetSiblings, true);
  92. QCoreApplication::setAttribute(Qt::AA_DisableShaderDiskCache, true);
  93. // Set application attributes
  94. #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
  95. QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps, true);
  96. QApplication::setAttribute(Qt::AA_EnableHighDpiScaling, true);
  97. #endif
  98. QCoreApplication::setAttribute(Qt::AA_CompressHighFrequencyEvents, true);
  99. QApplication a(argc, argv);
  100. a.setApplicationVersion("2.0");
  101. a.setApplicationName("QFD2");
  102. a.setApplicationDisplayName("伪装防护评估系统软件");
  103. Q_INIT_RESOURCE(qfluentwidgets);
  104. QTranslator *translator = new QTranslator();
  105. translator->load(QLocale::system(), ":/resource/i18n/qfluentwidgets_zh.qm");
  106. QCoreApplication::installTranslator(translator);
  107. MainWindow *w = new MainWindow;
  108. // test();
  109. // 居中显示窗体
  110. w->move((QApplication::primaryScreen()->availableGeometry().width() - w->width()) / 2,
  111. (QApplication::primaryScreen()->availableGeometry().height() - w->height()) / 2);
  112. QSettings config("config.ini", QSettings::IniFormat);
  113. config.setIniCodec("UTF-8");
  114. int roleType = config.value("USERCONFIG/RoleType", "").toInt();
  115. if (roleType == 0) {
  116. w->show();
  117. } else {
  118. qDebug() << "---------------------";
  119. // TODO 导入文件入库操作
  120. bool result = FileUtil().importEngineerFile();
  121. if (result) {
  122. ImportDataUtil().importSystemData();
  123. w->show();
  124. } else {
  125. delete w;
  126. qDebug() << "----";
  127. qApp->exit();
  128. }
  129. }
  130. // w.show();
  131. QFont font;
  132. font.setPointSize(14);
  133. a.setFont(font);
  134. setbuf(stdout, NULL);
  135. DWORD processId = GetCurrentProcessId();
  136. qDebug() << __FUNCTION__ << __LINE__ << processId << endl;
  137. printf("Process ID: %u\n", processId);
  138. int ret = a.exec();
  139. delete w;
  140. return ret;
  141. }