diff --git a/CMakeLists.txt b/CMakeLists.txt index 68aeb2fcd82304d5d284d1113feca9374fe3f5d9..acd22c9ba7a6ae88b6875bbd91c6cc1e59c3ac4c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,23 +5,25 @@ cmake_minimum_required(VERSION 3.2) ## Options -option(test "Build all tests." OFF) +option(create_test "Build all tests." OFF) option(release_type "Set the type of the releas (Debug/Release)." Release) ## Use modern C++! set(CMAKE_CXX_STANDARD 17) set(CMAKE_BUILD_TYPE Release) + + +## PkgConfig find_package(PkgConfig REQUIRED) -message(" - Build type is set to ${CMAKE_BUILD_TYPE}") # @todo Check versions of glib etc. librarys. # On Ubuntu 19.10 there are warnings which are not present in Ubuntu 18.04 -set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated-declarations") +# set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated-declarations") -# Add qpong lib +# Add qpong lib for core qpong functionality add_subdirectory(qpong_core) include_directories(qpong_core) @@ -32,7 +34,7 @@ add_subdirectory(gtk_qpong_app) # Add some unit tests # not many yet ^^ -if (test) +if (create_test) add_subdirectory(libs/googletest) add_subdirectory(tests) endif() diff --git a/Jenkinsfile b/Jenkinsfile deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/gtk_qpong_app/CMakeLists.txt b/gtk_qpong_app/CMakeLists.txt index ca6bf863e556ecb1849087de6da2ecf3c926094d..bafe30a2e44db8c7e4e56c7e308eeef8513ea929 100644 --- a/gtk_qpong_app/CMakeLists.txt +++ b/gtk_qpong_app/CMakeLists.txt @@ -1,20 +1,26 @@ - +# Specific settings for macOS if(APPLE) link_directories("/usr/local/lib") message("ATTENTION: You probably have to export the PKG_CONFIG_PATH.") message("For example: export PKG_CONFIG_PATH=\"/usr/local/lib:/usr/local/opt/zlib/lib/pkgconfig\"") endif() + +# Setup GTK configuration pkg_check_modules(GTKMM gtkmm-3.0) link_directories(${GTKMM_LIBRARY_DIRS}) # get all GTKMM dependencies and configuration include_directories(${GTKMM_INCLUDE_DIRS}) -include_directories(/usr/local/include) + +if(APPLE) + include_directories(/usr/local/include) +endif() + # create the application -add_executable(qpong.app +add_executable( qpong.app main.cpp QWindow.cpp QDrawingArea.cpp @@ -27,7 +33,7 @@ find_package(Threads) # link all necessary libs to the target -target_link_libraries(qpong.app +target_link_libraries( qpong.app qpong_core ${CMAKE_THREAD_LIBS_INIT} ${GTKMM_LIBRARIES} diff --git a/gtk_qpong_app/QWindow.cpp b/gtk_qpong_app/QWindow.cpp index f48201d53ad510953d5d7e0a3fc01ae5bce9fd7f..2943cbe0130f79bb4ecba30186a8ef06f354b376 100644 --- a/gtk_qpong_app/QWindow.cpp +++ b/gtk_qpong_app/QWindow.cpp @@ -41,7 +41,7 @@ void QWindow::simulation() // Limit the speed of the simulation. auto dt = std::chrono::system_clock::now() - start; auto dtMillis = std::chrono::duration_cast<std::chrono::milliseconds>(dt).count(); - constexpr int propTime = 60; + constexpr int propTime = 6; if (dtMillis < propTime) { std::this_thread::sleep_for(std::chrono::milliseconds(propTime - dtMillis)); @@ -58,7 +58,7 @@ void render(QWindow *w) { using namespace std::chrono_literals; auto start = std::chrono::system_clock::now(); - std::this_thread::sleep_for(20ms); + std::this_thread::sleep_for(15ms); w->updateView(); renderRate = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now() - start).count(); } while (true); diff --git a/qpong_core/CMakeLists.txt b/qpong_core/CMakeLists.txt index f91805b3f7bd8e53a3745a0029918f4a0b2db7a7..72fb06b4ec9f7868c98f2d452169de5597d423ab 100644 --- a/qpong_core/CMakeLists.txt +++ b/qpong_core/CMakeLists.txt @@ -1,8 +1,10 @@ -include_directories(/usr/local/include) +if(APPLE) + include_directories(/usr/local/include) +endif() ## library for the app should be GTK independent ## -add_library(qpong_core +add_library( qpong_core Particle.cpp ImageBuffer.cpp Player.cpp diff --git a/qpong_core/Common.hpp b/qpong_core/Common.hpp index 38e29633e9df47ccb70a6ed0eeb21ad406c14ac7..61b8638739fd57f22e663bee81fd178be62ffc9d 100644 --- a/qpong_core/Common.hpp +++ b/qpong_core/Common.hpp @@ -9,8 +9,8 @@ namespace QPong { -constexpr int arrayWidth = 256; -constexpr int arrayHeight = 256; +constexpr int arrayWidth = 384; +constexpr int arrayHeight = 384; constexpr int numberOfThreads = 8; constexpr unsigned arraySize = arrayWidth * arrayHeight; diff --git a/qpong_core/Particle.hpp b/qpong_core/Particle.hpp index c0540e9cfd12cd88e10fa72c562218c25525a8b1..3af6f5a01eefbe4c530b74a934af60449d2a4b1b 100644 --- a/qpong_core/Particle.hpp +++ b/qpong_core/Particle.hpp @@ -1,7 +1,6 @@ /// /// @file Particle.hpp /// @author Armin Co -/// /// @brief Particle class header. /// @@ -50,17 +49,6 @@ public: private: - std::complex<double> *m_psi; - fftw_plan m_planForward; - fftw_plan m_planBackward; - bool m_ready; - - std::map<Player::Id, std::shared_ptr<Player>> m_players; - - ImageBuffer *m_bufPositionRepresentation; - ImageBuffer *m_bufMomentumRepresentation; - - /// @brief Update the array at the ArrayCanvas /// void updateMomentumImage(); @@ -83,6 +71,19 @@ private: double removeParticle(int index, double cx); + std::complex<double> *m_psi; + fftw_plan m_planForward; + fftw_plan m_planBackward; + bool m_ready; + + std::map<Player::Id, std::shared_ptr<Player>> m_players; + + ImageBuffer *m_bufPositionRepresentation; + ImageBuffer *m_bufMomentumRepresentation; + + + + Particle() = delete; }; diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index a7a3d1af22b8171529d7b5449a3c3d4ae4a5804b..96d720ab04f3f49a2e341775d0c736d24cd82b4a 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -1,7 +1,9 @@ enable_testing() + include_directories(${gtest_SOURCE_DIR}/include ${gtest_SOURCE_DIR}) add_executable(runUnitTests test_qpong.cpp) + target_link_libraries(runUnitTests gtest gtest_main) target_link_libraries(runUnitTests qpong_core) -add_test(NAME a-test COMMAND runUnitTests) +add_test(NAME a-test COMMAND ./tests/runUnitTests) diff --git a/tests/test_qpong.cpp b/tests/test_qpong.cpp index c91a2487c50bb5d4fd9433fb6599ab5a64aeb578..e3b198245e2ec5b7776831ea8c27f56c06356cfc 100644 --- a/tests/test_qpong.cpp +++ b/tests/test_qpong.cpp @@ -43,16 +43,20 @@ TEST(ImageBuffer, getValue) } -TEST(addInts, addNumbers) +TEST(addInts, positiveValues) { - int a{ 1 }; - int b{ 3 }; - - EXPECT_EQ(4, addInts(a,b)); - EXPECT_EQ(4, addInts(a,b)); - EXPECT_EQ(4, addInts(a,b)); - EXPECT_EQ(4, addInts(a,b)); - EXPECT_EQ(4, addInts(a,b)); + int a {1}; + int b {3}; + + ASSERT_EQ(addInts(a, b), 4); } +TEST(addInts, shouldBreak) +{ + EXPECT_NE(3+1, 0) << "Yes yes, because it is just a test!"; +} +TEST(addInts, negativeValues) +{ + ASSERT_EQ(-3 + -5, -8); +} \ No newline at end of file