diff --git a/CMakeLists.txt b/CMakeLists.txt index 5f420f563e5486d58294e7b59120f7506d143965..093960cc3ba40a0766469ea90a342825846e277e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -37,7 +37,6 @@ add_subdirectory(Tests/UnitTests/TestCore) add_subdirectory(ThirdParty/RootMinimizers) add_subdirectory(Fit) add_subdirectory(Tests/UnitTests/TestFit) -add_subdirectory(Tests/FunctionalTests) # functional tests (make check) if(ROOT_FOUND AND BORNAGAIN_APP) add_subdirectory(App) @@ -47,8 +46,10 @@ if(BORNAGAIN_GUI) add_subdirectory(GUI) endif() +add_subdirectory(Tests/FunctionalTests) # functional tests (make check) + if(BORNAGAIN_MAN) - add_subdirectory(Doc/UserManual) + add_subdirectory(Doc/UserManual) endif() add_subdirectory(cmake) # trick to print the message diff --git a/GUI/CMakeLists.txt b/GUI/CMakeLists.txt index 6defccd8fb3fae926075c770836bdee5c004eebf..b1f0264650ef1686bd3d968aff8ad300f21932c0 100644 --- a/GUI/CMakeLists.txt +++ b/GUI/CMakeLists.txt @@ -15,3 +15,6 @@ add_subdirectory(externals/qcustomplot) add_subdirectory(externals/qtpropertybrowser) add_subdirectory(coregui) add_subdirectory(main) + +set(BornAgainGUI_INCLUDE_DIRS ${BornAgainGUI_INCLUDE_DIRS} PARENT_SCOPE) +set(BornAgainGUI_LIBRARY ${BornAgainGUI_LIBRARY} PARENT_SCOPE) diff --git a/GUI/coregui/CMakeLists.txt b/GUI/coregui/CMakeLists.txt index 985bb690a1a1ae549effad194d8b95ce108c5270..7a634e13c43a9b15afcaa06096bb0a8c08678c3c 100644 --- a/GUI/coregui/CMakeLists.txt +++ b/GUI/coregui/CMakeLists.txt @@ -99,12 +99,9 @@ qt5_use_modules(${library_name} Widgets Core Gui Script Designer PrintSupport) include_directories( ${qcustomplot_INCLUDE_DIRS} ${qtpropertybrowser_INCLUDE_DIRS} -# ${GQt_INCLUDE_DIRS} -# ${QtRoot_INCLUDE_DIRS} ${Boost_INCLUDE_DIRS} ${BornAgainCore_INCLUDE_DIRS} ${BornAgainFit_INCLUDE_DIRS} -# ${ROOT_INCLUDE_DIR} ${ManhattanStyle_INCLUDE_DIRS} ${EIGEN3_INCLUDE_DIR} ${PYTHON_INCLUDE_DIRS} @@ -122,8 +119,6 @@ target_link_libraries(${library_name} ) # --- Installation --- - -#install (TARGETS ${executable_name} DESTINATION ${destination_bin} COMPONENT Applications) install (TARGETS ${library_name} DESTINATION ${destination_lib} COMPONENT Libraries) # system libraries: ROOT installation diff --git a/GUI/coregui/Models/GUIObjectBuilder.h b/GUI/coregui/Models/GUIObjectBuilder.h index da7657f9f9be23ede9106e2855c5b351a2d58f59..0e63420e7b9355e111168a03c594bd52712caf52 100644 --- a/GUI/coregui/Models/GUIObjectBuilder.h +++ b/GUI/coregui/Models/GUIObjectBuilder.h @@ -30,7 +30,7 @@ class GUIObjectBuilder : public ISampleVisitor { public: GUIObjectBuilder(); - ~GUIObjectBuilder(){} + virtual ~GUIObjectBuilder(){} ParameterizedItem *populateSampleModel(SessionModel *sampleModel, ISample *sample); diff --git a/GUI/main/CMakeLists.txt b/GUI/main/CMakeLists.txt index 4a241c68e8ecabca264d6f683d181d16f525d75c..7fa0d4ec505241cd325f379c412402fc83ba3466 100644 --- a/GUI/main/CMakeLists.txt +++ b/GUI/main/CMakeLists.txt @@ -7,7 +7,7 @@ endif() set(executable_name BornAgain) include_directories( - ${CMAKE_SOURCE_DIR}/GUI/coregui/mainwindow + ${BornAgainGUI_INCLUDE_DIRS} ${ManhattanStyle_INCLUDE_DIRS} ) diff --git a/Tests/FunctionalTests/CMakeLists.txt b/Tests/FunctionalTests/CMakeLists.txt index a8e8d8a5d8932eb51bdf9a0afd7a56c198b5c4e5..4899a6520eb2834b0734dc09213f31b0e8c51810 100644 --- a/Tests/FunctionalTests/CMakeLists.txt +++ b/Tests/FunctionalTests/CMakeLists.txt @@ -19,10 +19,10 @@ execute_process(COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR}/T #COPY_IF_DIFFERENT( ${CMAKE_SOURCE_DIR}/Tests/FunctionalTests/TestPyFit ${CMAKE_BINARY_DIR}/Tests/FunctionalTests/TestPyFit ${SRC_FILES} IncludeTargets "Includes") if(BORNAGAIN_GUI) -# add_subdirectory(TestGUI) + add_subdirectory(TestGUI) endif() -#add_subdirectory(TestCore) +add_subdirectory(TestCore) #add_subdirectory(TestFit) #if(BORNAGAIN_PYTHON) # add_subdirectory(TestPyCore) diff --git a/Tests/FunctionalTests/TestCore/CMakeLists.txt b/Tests/FunctionalTests/TestCore/CMakeLists.txt index 04773072944867f38cc2ea6456f58c893eb8fe3d..bbcba1c1697ebdea9cef781dd38123793a7774fd 100644 --- a/Tests/FunctionalTests/TestCore/CMakeLists.txt +++ b/Tests/FunctionalTests/TestCore/CMakeLists.txt @@ -6,31 +6,31 @@ set(CMAKE_CXX_FLAGS "-DSTANDALONE") set(list_of_tests "IsGISAXS01" - "IsGISAXS02" - "IsGISAXS03BA" - "IsGISAXS03DWBA" - "IsGISAXS03BAsize" - "IsGISAXS041DDL" - "IsGISAXS042DDL" - "IsGISAXS06L1" - "IsGISAXS06L2" - "IsGISAXS06L3" - "IsGISAXS06L4" - "IsGISAXS07" - "IsGISAXS08a" - "IsGISAXS08b" - "IsGISAXS09a" - "IsGISAXS09b" - "IsGISAXS10" - "IsGISAXS11" - "IsGISAXS15" - "FormFactors" - "MesoCrystal1" - "PolDWBAMagCylinders1" - "PolDWBAMagCylinders2" - "LayerRoughness" - "Ripple2" - "Ripple1" +# "IsGISAXS02" +# "IsGISAXS03BA" +# "IsGISAXS03DWBA" +# "IsGISAXS03BAsize" +# "IsGISAXS041DDL" +# "IsGISAXS042DDL" +# "IsGISAXS06L1" +# "IsGISAXS06L2" +# "IsGISAXS06L3" +# "IsGISAXS06L4" +# "IsGISAXS07" +# "IsGISAXS08a" +# "IsGISAXS08b" +# "IsGISAXS09a" +# "IsGISAXS09b" +# "IsGISAXS10" +# "IsGISAXS11" +# "IsGISAXS15" +# "FormFactors" +# "MesoCrystal1" +# "PolDWBAMagCylinders1" +# "PolDWBAMagCylinders2" +# "LayerRoughness" +# "Ripple2" +# "Ripple1" ) # for some reason these flags doesn't propagated here by SetUpWindows.cmake diff --git a/Tests/FunctionalTests/TestGUI/CMakeLists.txt b/Tests/FunctionalTests/TestGUI/CMakeLists.txt index 00217d02355ee37e2ffb8d6bae0b4abd21ce5633..1f7af5194f8801e37aaaf37d3e5a59842637c7fb 100644 --- a/Tests/FunctionalTests/TestGUI/CMakeLists.txt +++ b/Tests/FunctionalTests/TestGUI/CMakeLists.txt @@ -2,7 +2,30 @@ find_package(Qt5Widgets REQUIRED) -message("YYY ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_SOURCE_DIR}") -#add_subdirectory(GUIExample01) +set(list_of_tests + "TestGUI01" +) + +# for some reason these flags doesn't propagated here by SetUpWindows.cmake +if(MSVC) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHsc ") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /EHsc ") +endif() + +include_directories( + ${Boost_INCLUDE_DIRS} + ${BornAgainCore_INCLUDE_DIRS} + ${BornAgainGUI_INCLUDE_DIRS} + ${EIGEN3_INCLUDE_DIR} + ${GSL_INCLUDE_DIR} +) + +foreach(_test ${list_of_tests}) + BORNAGAIN_EXECUTABLE(${_test} LOCATIONS ${_test} EXCLUDE_FROM_ALL LIBRARIES ${BornAgainCore_LIBRARY} ${BornAgainGUI_LIBRARY}) + qt5_use_modules(${_test} Widgets Core Gui Script Designer PrintSupport) + + BORNAGAIN_ADD_TEST(${_test} INPUT_DIR ${CMAKE_BINARY_DIR}/Tests/ReferenceData/BornAgain/) +endforeach() + diff --git a/Tests/FunctionalTests/TestGUI/GUIExample01/CMakeLists.txt b/Tests/FunctionalTests/TestGUI/GUIExample01/CMakeLists.txt deleted file mode 100644 index d48644def8bc5b577a2d844d8a919806c13fafcd..0000000000000000000000000000000000000000 --- a/Tests/FunctionalTests/TestGUI/GUIExample01/CMakeLists.txt +++ /dev/null @@ -1,106 +0,0 @@ -cmake_minimum_required(VERSION 2.8.9 FATAL_ERROR) - -if(POLICY CMP0020) -cmake_policy(SET CMP0020 NEW) -endif() - -set(executable_name GUIExample01) - -# --- source and include files --- -set(include_dirs -# ${CMAKE_CURRENT_SOURCE_DIR}/mainwindow - ${CMAKE_SOURCE_DIR}/GUI/coregui/utils - ${CMAKE_SOURCE_DIR}/GUI/coregui/Models -# ${CMAKE_CURRENT_SOURCE_DIR}/Views -# ${CMAKE_CURRENT_SOURCE_DIR}/Views/Components/widgetbox -# ${CMAKE_CURRENT_SOURCE_DIR}/Views/Components/SampleDesigner -# ${CMAKE_CURRENT_SOURCE_DIR}/Views/Components/JobQueueWidgets -# ${CMAKE_CURRENT_SOURCE_DIR}/Views/Components/OutputDataWidgets - ${CMAKE_SOURCE_DIR}/GUI/coregui/Views/Components/MaterialEditor -# ${CMAKE_CURRENT_SOURCE_DIR}/Views/Components/InstrumentWidgets -) -include_directories(${include_dirs}) - -file(GLOB source_files - "*.cpp" - "${CMAKE_SOURCE_DIR}/GUI/coregui/utils/*.cpp" - "${CMAKE_SOURCE_DIR}/GUI/coregui/Models/*.cpp" -# "Views/*.cpp" -# "Views/Components/SampleDesigner/*.cpp" -# "Views/Components/JobQueueWidgets/*.cpp" -# "Views/Components/OutputDataWidgets/*.cpp" - "${CMAKE_SOURCE_DIR}/GUI/coregui/Views/Components/MaterialEditor/*.cpp" -# "Views/Components/InstrumentWidgets/*.cpp" -) - -#set(source_widgetbox -# "Views/Components/widgetbox/widgetboxcategorylistview.cpp" -# "Views/Components/widgetbox/widgetboxtreewidget.cpp" -# "Views/Components/widgetbox/widgetbox.cpp" -# "Views/Components/widgetbox/widgetbox_dnditem.cpp" -#) -#list(APPEND source_files ${source_widgetbox}) - -file(GLOB include_files -# "mainwindow/*.h" - "${CMAKE_SOURCE_DIR}/GUI/coregui/utils/*.h" - "${CMAKE_SOURCE_DIR}/GUI/coregui/Models/*.h" -# "Views/*.h" -# "Views/Components/SampleDesigner/*.h" -# "Views/Components/JobQueueWidgets/*.h" -# "Views/Components/OutputDataWidgets/*.h" - "${CMAKE_SOURCE_DIR}/GUI/coregui/Views/Components/MaterialEditor/*.h" -# "Views/Components/InstrumentWidgets/*.h" -) - -#set(include_widgetbox -# "Views/Components/widgetbox/widgetboxcategorylistview.h" -# "Views/Components/widgetbox/widgetboxtreewidget.h" -# "Views/Components/widgetbox/widgetbox.h" -# "Views/Components/widgetbox/widgetbox_dnditem.h" -# "Views/Components/widgetbox/widgetbox_global.h" -#) -#list(APPEND include_files ${include_widgetbox}) - - -#set(resource_files -# "coregui.qrc" -## "qttools/qtpropertybrowser/qtpropertybrowser.qrc" -# "Views/Components/SampleDesigner/SampleDesigner.qrc" -# "Views/Components/widgetbox/widgetbox.qrc" -#) - -message("XXX 1.1 ${executable_name} ${source_files} ${include_files}") - -set(CMAKE_AUTOMOC ON) -qt5_add_resources(RC_SRCS ${resource_files}) -add_definitions(-DQT_DISABLE_DEPRECATED_BEFORE=0x040900) - -#add_executable(${executable_name} ${source_files} ${RC_SRCS} ${include_files}) -add_executable(${executable_name} ${source_files} ${include_files}) - -qt5_use_modules(${executable_name} Widgets Core Gui Script Designer PrintSupport) - -# --- dependencies --- -include_directories( -# ${qcustomplot_INCLUDE_DIRS} - ${qtpropertybrowser_INCLUDE_DIRS} - ${Boost_INCLUDE_DIRS} - ${BornAgainCore_INCLUDE_DIRS} - ${BornAgainFit_INCLUDE_DIRS} -# ${ManhattanStyle_INCLUDE_DIRS} - ${EIGEN3_INCLUDE_DIR} - ${PYTHON_INCLUDE_DIRS} -) - - -target_link_libraries(${executable_name} -# ${ManhattanStyle_LIBRARY} -# ${qcustomplot_LIBRARY} - ${qtpropertybrowser_LIBRARY} - ${PYTHON_LIBRARY} - ${Boost_LIBRARIES} - ${BornAgainCore_LIBRARY} - ${BornAgainFit_LIBRARY} -) - diff --git a/Tests/FunctionalTests/TestGUI/GUIExample01/GUIExample01.cpp b/Tests/FunctionalTests/TestGUI/GUIExample01/GUIExample01.cpp deleted file mode 100644 index 3af9e7f0235e05966a571165f4a86ac210cb277e..0000000000000000000000000000000000000000 --- a/Tests/FunctionalTests/TestGUI/GUIExample01/GUIExample01.cpp +++ /dev/null @@ -1,9 +0,0 @@ -#include <iostream> - -int main() -{ - std::cout << "Hello World" << std::endl; - return 0; -} - - diff --git a/Tests/FunctionalTests/TestGUI/TestGUI01/CMakeLists.txt b/Tests/FunctionalTests/TestGUI/TestGUI01/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..a0533c5c95702bd3f3cfb99ba4928e7357686126 --- /dev/null +++ b/Tests/FunctionalTests/TestGUI/TestGUI01/CMakeLists.txt @@ -0,0 +1,16 @@ + +set(executable_name TestGUI01) + +include_directories( + ${CMAKE_SOURCE_DIR}/GUI/coregui/mainwindow + ${ManhattanStyle_INCLUDE_DIRS} +) + +add_executable(${executable_name} TestGUI01.cpp) + +target_link_libraries(${executable_name} + ${BornAgainCore_LIBRARY} + ${BornAgainFit_LIBRARY} + ${BornAgainGUI_LIBRARY} +) + diff --git a/Tests/FunctionalTests/TestGUI/TestGUI01/TestGUI01.cpp b/Tests/FunctionalTests/TestGUI/TestGUI01/TestGUI01.cpp new file mode 100644 index 0000000000000000000000000000000000000000..fd558ca9402770c0dabed1f970941f2a3ee58247 --- /dev/null +++ b/Tests/FunctionalTests/TestGUI/TestGUI01/TestGUI01.cpp @@ -0,0 +1,72 @@ +#include <iostream> +#include "SimulationRegistry.h" +#include "GUIObjectBuilder.h" +#include "SessionModel.h" +#include "MaterialEditor.h" +#include "MaterialModel.h" +#include "Instrument.h" +#include "DomainObjectBuilder.h" +#include "ParameterizedItem.h" + + +int test() +{ + + SimulationRegistry sim_registry; + Simulation *simulation = sim_registry.createSimulation("isgisaxs01"); + simulation->runSimulation(); + + Instrument *instrument = new Instrument(simulation->getInstrument()); + ISample *sample = simulation->getSample()->clone(); + + OutputData<double> *data = simulation->getIntensityData(); + std::cout << data->totalSum(); + + // + SessionModel *sampleModel = new SessionModel(SessionXML::SampleModelTag); + SessionModel *instrumentModel = new SessionModel(SessionXML::InstrumentModelTag); + + MaterialModel *materialModel = new MaterialModel(); + MaterialEditor *materialEditor = new MaterialEditor(materialModel); + + GUIObjectBuilder guiBuilder; + guiBuilder.populateSampleModel(sampleModel, sample); + guiBuilder.populateInstrumentModel(instrumentModel, instrument); + + + // building sample back + QModelIndex sampleIndex = sampleModel->index(0, 0, QModelIndex()); + ParameterizedItem *sampleItem = sampleModel->itemForIndex(sampleIndex); + Q_ASSERT(sampleItem); + DomainObjectBuilder builder; + MultiLayer *new_sample = builder.buildMultiLayer(*sampleItem); + new_sample->printSampleTree(); + + // building multilayer back + QModelIndex instrumentIndex = instrumentModel->index(0, 0, QModelIndex()); + ParameterizedItem *instrumentItem = sampleModel->itemForIndex(instrumentIndex); + Q_ASSERT(sampleItem); + Instrument *new_instrument = builder.buildInstrument(*instrumentItem); + + // running simulation again + Simulation *new_simulation = new Simulation; + new_simulation->setSample(*new_sample); + new_simulation->setInstrument(*new_instrument); + + new_simulation->runSimulation(); + OutputData<double> *new_data = new_simulation->getIntensityData(); + std::cout << new_data->totalSum(); + + return 0; +} + +int main() +{ + + + + + return test(); +} + +