Loading GUI/GUI.pro +5 −3 Changes for GUI/GUI.pro: 5 added lines, 3 removed lines. Original line number Diff line number Diff line Loading @@ -14,13 +14,15 @@ TEMPLATE = app SOURCES += main.cpp\ mainwindow.cpp\ statsgen.cpp statsgen.cpp \ controller.cpp HEADERS += mainwindow.h\ statsgen.h\ utils.h utils.h \ controller.h FORMS += mainwindow.ui QMAKE_CXXFLAGS += -std=c++11 QMAKE_CXXFLAGS += -std=c++11 -lpthread GUI/GUI.pro.user +13 −11 Changes for GUI/GUI.pro.user: 13 added lines, 11 removed lines. Original line number Diff line number Diff line <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE QtCreatorProject> <!-- Written by QtCreator 3.5.1, 2018-01-10T12:48:03. --> <!-- Written by QtCreator 3.5.1, 2018-01-24T17:10:28. --> <qtcreator> <data> <variable>EnvironmentId</variable> <value type="QByteArray">{da6987d4-31c4-4f3d-a60d-58ce3b5634b9}</value> <value type="QByteArray">{02a7caed-4b6b-495d-8fef-b11555302a3f}</value> </data> <data> <variable>ProjectExplorer.Project.ActiveTarget</variable> Loading Loading @@ -60,12 +60,12 @@ <valuemap type="QVariantMap"> <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop</value> <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop</value> <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">{1490749a-bd0b-472a-9ead-4692066d8a49}</value> <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">{4457406e-e5e6-438e-9e2a-610fde4151e0}</value> <value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">0</value> <value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value> <value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value> <valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0"> <value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/home/kael/Projet/Statistiques/build-GUI-Desktop-Debug</value> <value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/home/jorand/Documents/Projet_3A/Statistiques/build-GUI-Desktop-Debug</value> <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0"> <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0"> <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value> Loading Loading @@ -126,7 +126,7 @@ <value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">true</value> </valuemap> <valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.1"> <value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/home/kael/Projet/Statistiques/build-GUI-Desktop-Release</value> <value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/home/jorand/Documents/Projet_3A/Statistiques/build-GUI-Desktop-Release</value> <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0"> <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0"> <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value> Loading Loading @@ -236,14 +236,16 @@ <value type="int">13</value> <value type="int">14</value> </valuelist> <value type="int" key="PE.EnvironmentAspect.Base">-1</value> <value type="int" key="PE.EnvironmentAspect.Base">2</value> <valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/> <value type="QString" key="ProjectExplorer.CustomExecutableRunConfiguration.Arguments"></value> <value type="QString" key="ProjectExplorer.CustomExecutableRunConfiguration.Executable"></value> <value type="QString" key="ProjectExplorer.CustomExecutableRunConfiguration.WorkingDirectory">%{buildDir}</value> <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Exécutable personnalisé</value> <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">GUI</value> <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.CustomExecutableRunConfiguration</value> <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4RunConfiguration:/home/jorand/Documents/Projet_3A/Statistiques/GUI/GUI.pro</value> <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.CommandLineArguments"></value> <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.ProFile">GUI.pro</value> <value type="bool" key="Qt4ProjectManager.Qt4RunConfiguration.UseDyldImageSuffix">false</value> <value type="bool" key="Qt4ProjectManager.Qt4RunConfiguration.UseTerminal">false</value> <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.UserWorkingDirectory"></value> <value type="uint" key="RunConfiguration.QmlDebugServerPort">3768</value> <value type="bool" key="RunConfiguration.UseCppDebugger">false</value> <value type="bool" key="RunConfiguration.UseCppDebuggerAuto">true</value> Loading GUI/controller.cpp +1 Changes for GUI/controller.cpp: 1 added line, 0 removed lines. Original line number Diff line number Diff line #include "controller.h" GUI/controller.h +44 Changes for GUI/controller.h: 44 added lines, 0 removed lines. Original line number Diff line number Diff line #ifndef CONTROLLER_H #define CONTROLLER_H #include "statsgen.h" #include "utils.h" #include <QObject> #include <QThread> #include <unordered_map> class Controller : public QObject { Q_OBJECT QThread workerThread; public: Controller(std::string filename) { Statsgen * stats = new Statsgen(); stats->setFilename(filename); stats->setTop(10); stats->setNbThread(3); stats->moveToThread(&workerThread); connect(&workerThread, SIGNAL(finished()), stats, SLOT(deleteLater())); connect(this, SIGNAL(started()), stats, SLOT(generate_stats())); connect(stats, SIGNAL(resultReady(std::unordered_map<int,double>)), this, SLOT(handleResults(std::unordered_map<int,double>))); workerThread.start(); } ~Controller() { workerThread.quit(); workerThread.wait(); } public slots: void handleResults(const std::unordered_map<int, double> & stats_length) { std::wcout << "\nStatistics relative to length: \n" << std::endl; int count = 0; showMap(stats_length, 10, 14000000, false, count); } }; #endif // CONTROLLER_H GUI/mainwindow.cpp +5 −3 Changes for GUI/mainwindow.cpp: 5 added lines, 3 removed lines. Original line number Diff line number Diff line #include "controller.h" #include "mainwindow.h" #include "ui_mainwindow.h" Loading Loading @@ -33,9 +34,10 @@ void MainWindow::findFile() { void MainWindow::startGame() { stats.setFilename(filename.toStdString()); stats.generate_stats(); stats.print_stats(); Controller * test = new Controller(filename.toStdString()); /* QFile file(filename); Loading Loading
GUI/GUI.pro +5 −3 Changes for GUI/GUI.pro: 5 added lines, 3 removed lines. Original line number Diff line number Diff line Loading @@ -14,13 +14,15 @@ TEMPLATE = app SOURCES += main.cpp\ mainwindow.cpp\ statsgen.cpp statsgen.cpp \ controller.cpp HEADERS += mainwindow.h\ statsgen.h\ utils.h utils.h \ controller.h FORMS += mainwindow.ui QMAKE_CXXFLAGS += -std=c++11 QMAKE_CXXFLAGS += -std=c++11 -lpthread
GUI/GUI.pro.user +13 −11 Changes for GUI/GUI.pro.user: 13 added lines, 11 removed lines. Original line number Diff line number Diff line <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE QtCreatorProject> <!-- Written by QtCreator 3.5.1, 2018-01-10T12:48:03. --> <!-- Written by QtCreator 3.5.1, 2018-01-24T17:10:28. --> <qtcreator> <data> <variable>EnvironmentId</variable> <value type="QByteArray">{da6987d4-31c4-4f3d-a60d-58ce3b5634b9}</value> <value type="QByteArray">{02a7caed-4b6b-495d-8fef-b11555302a3f}</value> </data> <data> <variable>ProjectExplorer.Project.ActiveTarget</variable> Loading Loading @@ -60,12 +60,12 @@ <valuemap type="QVariantMap"> <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop</value> <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop</value> <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">{1490749a-bd0b-472a-9ead-4692066d8a49}</value> <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">{4457406e-e5e6-438e-9e2a-610fde4151e0}</value> <value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">0</value> <value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value> <value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value> <valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0"> <value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/home/kael/Projet/Statistiques/build-GUI-Desktop-Debug</value> <value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/home/jorand/Documents/Projet_3A/Statistiques/build-GUI-Desktop-Debug</value> <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0"> <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0"> <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value> Loading Loading @@ -126,7 +126,7 @@ <value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">true</value> </valuemap> <valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.1"> <value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/home/kael/Projet/Statistiques/build-GUI-Desktop-Release</value> <value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/home/jorand/Documents/Projet_3A/Statistiques/build-GUI-Desktop-Release</value> <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0"> <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0"> <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value> Loading Loading @@ -236,14 +236,16 @@ <value type="int">13</value> <value type="int">14</value> </valuelist> <value type="int" key="PE.EnvironmentAspect.Base">-1</value> <value type="int" key="PE.EnvironmentAspect.Base">2</value> <valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/> <value type="QString" key="ProjectExplorer.CustomExecutableRunConfiguration.Arguments"></value> <value type="QString" key="ProjectExplorer.CustomExecutableRunConfiguration.Executable"></value> <value type="QString" key="ProjectExplorer.CustomExecutableRunConfiguration.WorkingDirectory">%{buildDir}</value> <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Exécutable personnalisé</value> <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">GUI</value> <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value> <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.CustomExecutableRunConfiguration</value> <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4RunConfiguration:/home/jorand/Documents/Projet_3A/Statistiques/GUI/GUI.pro</value> <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.CommandLineArguments"></value> <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.ProFile">GUI.pro</value> <value type="bool" key="Qt4ProjectManager.Qt4RunConfiguration.UseDyldImageSuffix">false</value> <value type="bool" key="Qt4ProjectManager.Qt4RunConfiguration.UseTerminal">false</value> <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.UserWorkingDirectory"></value> <value type="uint" key="RunConfiguration.QmlDebugServerPort">3768</value> <value type="bool" key="RunConfiguration.UseCppDebugger">false</value> <value type="bool" key="RunConfiguration.UseCppDebuggerAuto">true</value> Loading
GUI/controller.cpp +1 Changes for GUI/controller.cpp: 1 added line, 0 removed lines. Original line number Diff line number Diff line #include "controller.h"
GUI/controller.h +44 Changes for GUI/controller.h: 44 added lines, 0 removed lines. Original line number Diff line number Diff line #ifndef CONTROLLER_H #define CONTROLLER_H #include "statsgen.h" #include "utils.h" #include <QObject> #include <QThread> #include <unordered_map> class Controller : public QObject { Q_OBJECT QThread workerThread; public: Controller(std::string filename) { Statsgen * stats = new Statsgen(); stats->setFilename(filename); stats->setTop(10); stats->setNbThread(3); stats->moveToThread(&workerThread); connect(&workerThread, SIGNAL(finished()), stats, SLOT(deleteLater())); connect(this, SIGNAL(started()), stats, SLOT(generate_stats())); connect(stats, SIGNAL(resultReady(std::unordered_map<int,double>)), this, SLOT(handleResults(std::unordered_map<int,double>))); workerThread.start(); } ~Controller() { workerThread.quit(); workerThread.wait(); } public slots: void handleResults(const std::unordered_map<int, double> & stats_length) { std::wcout << "\nStatistics relative to length: \n" << std::endl; int count = 0; showMap(stats_length, 10, 14000000, false, count); } }; #endif // CONTROLLER_H
GUI/mainwindow.cpp +5 −3 Changes for GUI/mainwindow.cpp: 5 added lines, 3 removed lines. Original line number Diff line number Diff line #include "controller.h" #include "mainwindow.h" #include "ui_mainwindow.h" Loading Loading @@ -33,9 +34,10 @@ void MainWindow::findFile() { void MainWindow::startGame() { stats.setFilename(filename.toStdString()); stats.generate_stats(); stats.print_stats(); Controller * test = new Controller(filename.toStdString()); /* QFile file(filename); Loading