123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137 |
- #include "view/MainWindow.h"
- #include "helper/GenerateMiniDump.h"
- #include <QApplication>
- #include <QTranslator>
- #include <QScreen>
- #include <QDesktopWidget>
- #include <QTextCodec>
- #include <locale>
- #include <QSettings>
- #include "FileUtil.h"
- #include "ImportDataUtil.h"
- #include "dbService/ClassSet.h"
- #include "algorithm/GreyClusterEvaluation.h"
- #include <algorithm/MatterElementAnalysis.h>
- void test()
- {
- MEAMat mat;
- MEARangeMat ranges;
- // 样本1
- 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 };
- // 样本2
- 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 };
- qDebug() << mat[0].size() << mat[1].size();
- // 等级1
- ranges << QVector<MEARange> {
- { 0, 0, 1 }, { 1, 50, 100 }, { 2, 0, 1 }, { 3, 60, 100 }, { 4, 3, 100 }, { 5, 0, 30 }, { 6, 0, 60 },
- { 7, 0, 1 }, { 8, 0, 30 }, { 9, 0, 60 }, { 10, 2, 100 }, { 11, 0, 60 }, { 12, 0, 30 }, { 13, 0, 1 },
- { 14, 60, 100 }, { 15, 0, 1 }, { 16, 0, 30 }, { 17, 0, 5 }, { 18, 50, 100 }, { 19, 0, 1 },
- };
- // 等级1
- ranges << QVector<MEARange> {
- { 0, 2, 3 }, { 1, 5, 100 }, { 2, 1, 2 }, { 3, 45, 60 }, { 4, 2, 3 }, { 5, 30, 50 }, { 6, 60, 80 },
- { 7, 1, 1.5 }, { 8, 30, 50 }, { 9, 60, 80 }, { 10, 1.5, 2 }, { 11, 60, 80 }, { 12, 30, 50 }, { 13, 1, 3 },
- { 14, 45, 60 }, { 15, 1, 2 }, { 16, 30, 50 }, { 17, 5, 10 }, { 18, 30, 50 }, { 19, 1, 2 },
- };
- ranges << QVector<MEARange> {
- { 1, 3, 4 }, { 1, 20, 30 }, { 2, 2, 3 }, { 3, 30, 45 }, { 4, 1, 2 }, { 5, 50, 80 }, { 6, 80, 95 },
- { 7, 1.5, 2 }, { 8, 50, 80 }, { 9, 80, 95 }, { 10, 1, 1.5 }, { 11, 80, 95 }, { 12, 50, 80 }, { 13, 3, 5 },
- { 14, 30, 45 }, { 15, 2, 3 }, { 16, 50, 80 }, { 17, 10, 20 }, { 18, 20, 30 }, { 19, 2, 3 },
- };
- // 2
- ranges << QVector<MEARange> { { 0, 5, 100 }, { 1, 0, 20 }, { 2, 3, 100 }, { 3, 0, 30 }, { 4, 0, 1 },
- { 5, 80, 100 }, { 6, 95, 100 }, { 7, 2, 100 }, { 8, 80, 100 }, { 9, 95, 100 },
- { 10, 0, 1 }, { 11, 95, 100 }, { 12, 80, 100 }, { 13, 5, 100 }, { 14, 0, 30 },
- { 15, 3, 100 }, { 16, 80, 100 }, { 17, 20, 100 }, { 18, 0, 20 }, { 19, 3, 100 } };
- // 等级范围p
- ranges << QVector<MEARange> {
- { 0, 0, 140 }, { 1, 120, 0 }, { 2, 0, 140 }, { 3, 140, 0 }, { 4, 140, 0 }, { 5, 0, 100 }, { 6, 0, 100 },
- { 7, 0, 140 }, { 8, 0, 100 }, { 9, 0, 100 }, { 10, 0, 100 }, { 11, 0, 100 }, { 12, 0, 100 }, { 13, 0, 140 },
- { 14, 140, 0 }, { 15, 0, 140 }, { 16, 0, 100 }, { 17, 0, 140 }, { 18, 140, 0 }, { 19, 0, 140 },
- };
- // 等级
- MatterElementAnalysis me(mat, ranges);
- me.evaluate({ 0.05558152, 0.01462673, 0.12860136, 0.0567758, 0.02524748, 0.05098171, 0.31008254,
- 0.12573223, 0.01327194, 0.01461917, 0.01931854, 0.05014989, 0.06026197, 0.01258931,
- 0.0281506, 0.00588096, 0.01585843, 0.00331298, 0.00740806, 0.00154762 });
- QVector<int> index = me.getBestIndex();
- qDebug() << index;
- }
- void cTest() { }
- int main(int argc, char *argv[])
- {
- DUMP_FILE_HOOK_HANLE;
- QTextCodec::setCodecForLocale(QTextCodec::codecForName("UTF-8"));
- std::locale::global(std::locale(""));
- #ifndef QT_NO_OPENGL
- QCoreApplication::setAttribute(Qt::AA_ShareOpenGLContexts, true);
- #endif
- QCoreApplication::setAttribute(Qt::AA_DontCreateNativeWidgetSiblings, true);
- QCoreApplication::setAttribute(Qt::AA_DisableShaderDiskCache, true);
- // Set application attributes
- #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
- QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps, true);
- QApplication::setAttribute(Qt::AA_EnableHighDpiScaling, true);
- #endif
- QCoreApplication::setAttribute(Qt::AA_CompressHighFrequencyEvents, true);
- QApplication a(argc, argv);
- a.setApplicationVersion("2.0");
- a.setApplicationName("QFD2");
- a.setApplicationDisplayName("伪装防护评估系统软件");
- Q_INIT_RESOURCE(qfluentwidgets);
- QTranslator *translator = new QTranslator();
- translator->load(QLocale::system(), ":/resource/i18n/qfluentwidgets_zh.qm");
- QCoreApplication::installTranslator(translator);
- MainWindow *w = new MainWindow;
- // test();
- // 居中显示窗体
- w->move((QApplication::primaryScreen()->availableGeometry().width() - w->width()) / 2,
- (QApplication::primaryScreen()->availableGeometry().height() - w->height()) / 2);
- QSettings config("config.ini", QSettings::IniFormat);
- config.setIniCodec("UTF-8");
- int roleType = config.value("USERCONFIG/RoleType", "").toInt();
- if (roleType == 0) {
- w->show();
- } else {
- qDebug() << "---------------------";
- // TODO 导入文件入库操作
- bool result = FileUtil().importEngineerFile();
- if (result) {
- ImportDataUtil().importSystemData();
- w->show();
- } else {
- delete w;
- qDebug() << "----";
- qApp->exit();
- }
- }
- // w.show();
- QFont font;
- font.setPointSize(14);
- a.setFont(font);
- // cTest();
- int ret = a.exec();
- delete w;
- return ret;
- }
|