main.cpp 5.2 KB

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