diff --git a/.clang-format b/.clang-format new file mode 100644 index 0000000..b3b525e --- /dev/null +++ b/.clang-format @@ -0,0 +1,104 @@ +--- +Language: Cpp +Standard: Cpp11 +UseTab: Never +TabWidth: 4 +IndentWidth: 4 +AccessModifierOffset: -4 +ContinuationIndentWidth: 4 +ColumnLimit: 79 +ConstructorInitializerIndentWidth: 0 +BinPackArguments: false +BinPackParameters: false +AlignAfterOpenBracket: Align +AlignConsecutiveAssignments: true +AlignConsecutiveDeclarations: true +AlignOperands: true +AlignEscapedNewlines: Right +AlignTrailingComments: true +AllowAllArgumentsOnNextLine: false +AllowAllConstructorInitializersOnNextLine: false +ConstructorInitializerAllOnOneLineOrOnePerLine: false +AllowAllParametersOfDeclarationOnNextLine: false +AllowShortBlocksOnASingleLine: false +AllowShortCaseLabelsOnASingleLine: false +AllowShortFunctionsOnASingleLine: None +AllowShortIfStatementsOnASingleLine: Never +AllowShortLoopsOnASingleLine: false +AlwaysBreakAfterReturnType: None +AlwaysBreakBeforeMultilineStrings: true +AlwaysBreakTemplateDeclarations: Yes +BreakBeforeBraces: Custom +BraceWrapping: + AfterClass: true + AfterControlStatement: false + AfterEnum: true + AfterFunction: true + AfterNamespace: true + AfterObjCDeclaration: true + AfterStruct: true + AfterUnion: true + AfterExternBlock: true + BeforeCatch: false + BeforeElse: false + IndentBraces: false + SplitEmptyFunction: true + SplitEmptyRecord: true + SplitEmptyNamespace: true +BreakBeforeBinaryOperators: None +BreakBeforeInheritanceComma: false +BreakInheritanceList: BeforeColon +BreakBeforeTernaryOperators: true +BreakConstructorInitializers: BeforeComma +BreakAfterJavaFieldAnnotations: false +BreakStringLiterals: true +CompactNamespaces: false +Cpp11BracedListStyle: true +DerivePointerAlignment: false +DisableFormat: false +ExperimentalAutoDetectBinPacking: false +FixNamespaceComments: false +IndentCaseLabels: false +IndentPPDirectives: BeforeHash +IndentWrappedFunctionNames: true +KeepEmptyLinesAtTheStartOfBlocks: true +MaxEmptyLinesToKeep: 1 +NamespaceIndentation: All +PointerAlignment: Left +ReflowComments: true +SortIncludes: false +SortUsingDeclarations: true +SpaceAfterCStyleCast: true +SpaceAfterTemplateKeyword: false +SpaceBeforeAssignmentOperators: true +SpaceBeforeCpp11BracedList: false +SpaceBeforeCtorInitializerColon: true +SpaceBeforeInheritanceColon: true +SpaceBeforeParens: ControlStatements +SpaceBeforeRangeBasedForLoopColon: true +SpaceInEmptyParentheses: false +SpacesBeforeTrailingComments: 1 +SpacesInAngles: false +SpacesInContainerLiterals: false +SpacesInCStyleCastParentheses: false +SpacesInParentheses: false +SpacesInSquareBrackets: false +PenaltyBreakAssignment: 100 +PenaltyBreakBeforeFirstCallParameter: 19 +PenaltyBreakComment: 300 +PenaltyBreakFirstLessLess: 120 +PenaltyBreakString: 1000 +PenaltyBreakTemplateDeclaration: 10 +PenaltyExcessCharacter: 1000000 +PenaltyReturnTypeOnItsOwnLine: 1000 +CommentPragmas: '' +MacroBlockBegin: '' +MacroBlockEnd: '' +ForEachMacros: + - foreach + - Q_FOREACH + - BOOST_FOREACH +StatementMacros: + - Q_UNUSED + - QT_REQUIRE_VERSION +... diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..7b80d1c --- /dev/null +++ b/.editorconfig @@ -0,0 +1,19 @@ +root = true + +[*] +charset = utf-8 +end_of_line = lf +trim_trailing_whitespace = true +insert_final_newline = true + +[*.{c,h,cc,hh,cpp,hpp,cxx,hxx}] +indent_style = space +indent_size = 4 + +[*.py] +indent_style = space +indent_size = 4 + +[*.yml] +indent_style = space +indent_size = 2 diff --git a/.gitignore b/.gitignore index 13ad7d5..841e5ce 100644 --- a/.gitignore +++ b/.gitignore @@ -15,4 +15,81 @@ CMakeCache.txt *.ilk *.pdb *.lib -.vscode \ No newline at end of file +.vscode + +*_autogen +*.dir +*.stamp +*.stamp.depend + +GeneratedFiles/ +desktop.ini +*.swp +*.opensdf +*.sdf +*.suo +*.exe +*.psess +*.vsp +*.ipch +*.sln +*.vcxproj +*.vcxproj.filters +*.vcxproj.vspscc +.gitignore.swp +*.bak_* +*.ini + +# ignore editor ~ files +.tags* +Doxyfile +Makefile +cmake_install.cmake +doxygen_sqlite3.db +*~ +.idea/ + +/CMakeFiles +/doc +/html +/Debug +/Release +/build* +/Build* +/.vscode +*.kate-swp + +# astyle original files +*.orig +*.user +*.obj +*.dll +*.qm +*.avi +*moc_* +*.tlog +*.log +*.ilk + +*.lib +*.lastbuildstate +*.stamp +*.depend +*.pdb +*.exp +*.db +*.opendb +CMakeFiles +/BioTracker/*.vspx +*.cache +*.csv +build +*.dll +*.qm +*.ilk +*.pdb +*.lib +*.json +*.ini +*.xml +*.csv \ No newline at end of file diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 4680e4f..5c37377 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,69 +1,30 @@ stages: - build - package - - deploy + - trigger +.centos: + tags: [linux, docker] + image: git.imp.fu-berlin.de:5000/bioroboticslab/auto/ci/centos:latest -.base ubuntu-18.04: &base_ubuntu_18_04 - tags: [ linux, docker ] - image: git.imp.fu-berlin.de:5000/bioroboticslab/robofish/docker:ubuntu-18.04 - -.base windows: &base_windows - tags: [ windows, docker ] - image: git.imp.fu-berlin.de:5000/bioroboticslab/robofish/docker:windows +.windows: + tags: [windows, docker] + image: git.imp.fu-berlin.de:5000/bioroboticslab/auto/ci/windows:latest-devel + before_script: + - . $Profile.AllUsersAllHosts +.release: &release + CMAKE_BUILD_TYPE: Release -.build ubuntu-18.04: &build_ubuntu_18_04 +.build: &build stage: build - <<: *base_ubuntu_18_04 - variables: - CC: gcc-8 - CXX: g++-8 artifacts: paths: - build expire_in: 1 day - -.build windows: &build_windows - stage: build - <<: *base_windows - artifacts: - paths: - - build - expire_in: 1 day - before_script: - - C:/VsDevEnv.ps1 -arch=amd64 - -build ubuntu-18.04: - <<: *build_ubuntu_18_04 - script: - - cmake -Bbuild -H. -DCMAKE_BUILD_TYPE=Release -G Ninja - - ninja -C build - -build windows: - <<: *build_windows - script: - - cmake -Bbuild "-H." -DCMAKE_BUILD_TYPE=Release -G Ninja -DCMAKE_PREFIX_PATH="$Env:VCPKG_INSTALL_DIR" - - ninja -C build - -build windows[cuda]: - <<: *build_windows script: - - cmake -Bbuild "-H." -DCMAKE_BUILD_TYPE=Release -G Ninja -DCMAKE_PREFIX_PATH="$Env:VCPKG_CUDA_INSTALL_DIR" - - ninja -C build - -build windows[debug]: - <<: *build_windows - script: - - cmake -Bbuild "-H." -DCMAKE_BUILD_TYPE=Debug -G Ninja -DCMAKE_PREFIX_PATH="$Env:VCPKG_INSTALL_DIR" - - ninja -C build - -build windows[debug,cuda]: - <<: *build_windows - script: - - cmake -Bbuild "-H." -DCMAKE_BUILD_TYPE=Debug -G Ninja -DCMAKE_PREFIX_PATH="$Env:VCPKG_CUDA_INSTALL_DIR" - - ninja -C build - + - ./ci/configure.py + - ./ci/compile.py .package: &package stage: package @@ -72,35 +33,35 @@ build windows[debug,cuda]: - build/*.tar.xz expire_in: 1 week script: - - ninja -C build package - -package ubuntu-18.04: - <<: *base_ubuntu_18_04 - dependencies: - - build ubuntu-18.04 - <<: *package + - ./ci/package.py -package windows: - <<: *base_windows - dependencies: - - build windows - <<: *package +"build: [centos]": + extends: .centos + <<: *build + variables: + <<: [*release] -package windows[cuda]: - <<: *base_windows - dependencies: - - build windows[cuda] - <<: *package +"build: [windows]": + extends: .windows + <<: *build + variables: + <<: [*release] -package windows[debug]: - <<: *base_windows +"package: [centos]": + extends: .centos dependencies: - - build windows[debug] + - "build: [centos]" <<: *package -package windows[debug,cuda]: - <<: *base_windows +"package: [windows]": + extends: .windows dependencies: - - build windows[debug,cuda] + - "build: [windows]" <<: *package +trigger biotracker/utility: + stage: trigger + only: + - master + trigger: + project: bioroboticslab/biotracker/utility diff --git a/CMakeLists.txt b/CMakeLists.txt index 1e8bac5..116dfea 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,10 +1,10 @@ -cmake_minimum_required(VERSION 3.12) +cmake_minimum_required(VERSION 3.13) -exec_program("git" ${CMAKE_CURRENT_SOURCE_DIR} ARGS "describe --tags --abbrev=0" OUTPUT_VARIABLE GIT_TAG) +exec_program("git" ${CMAKE_CURRENT_SOURCE_DIR} ARGS "describe --dirty --always --exclude '*'" OUTPUT_VARIABLE SOURCE_VERSION) -project(BT_Interfaces - VERSION ${GIT_TAG} - LANGUAGES CXX) +project(biotracker-interfaces + LANGUAGES CXX +) include(GNUInstallDirs) @@ -13,33 +13,19 @@ set(INSTALL_LIBDIR ${CMAKE_INSTALL_LIBDIR} CACHE PATH "Installation directory fo set(INSTALL_INCLUDEDIR ${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME} CACHE PATH "Installation directory for header files") set(INSTALL_CONFIGDIR ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME} CACHE STRING "Installation directory for cmake configuration files") -set(TN BT_Interfaces) -add_library(${TN} SHARED) -set_target_properties(${TN} PROPERTIES OUTPUT_NAME bt_interfaces) -if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") - set_target_properties(${TN} PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS true) +list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/cmake) +include(Headers) + +find_package(OpenCV 4 QUIET) +if(NOT OpenCV_FOUND) + find_package(OpenCV 3 REQUIRED) endif() - -include(Src/CMakeLists.txt) -install( - TARGETS - BT_Interfaces - EXPORT - ${PROJECT_NAME}Targets - RUNTIME DESTINATION "${INSTALL_BINDIR}" - LIBRARY DESTINATION "${INSTALL_LIBDIR}" - ARCHIVE DESTINATION "${INSTALL_LIBDIR}" -) -foreach(file ${BT_Interfaces_PUBLIC_HEADERS}) - file(RELATIVE_PATH rel_path "${CMAKE_CURRENT_LIST_DIR}/Src" ${file}) - get_filename_component(install_path ${rel_path} DIRECTORY) - install(FILES ${file} DESTINATION "${INSTALL_INCLUDEDIR}/${install_path}") -endforeach() +add_subdirectory(Src) export( TARGETS - BT_Interfaces + ${PROJECT_NAME} FILE "${PROJECT_BINARY_DIR}/${PROJECT_NAME}Targets.cmake" ) @@ -52,8 +38,8 @@ include(CMakePackageConfigHelpers) write_basic_package_version_file( ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake - VERSION ${PROJECT_VERSION} - COMPATIBILITY AnyNewerVersion + VERSION ${SOURCE_VERSION} + COMPATIBILITY ExactVersion ) configure_package_config_file( @@ -69,14 +55,7 @@ install( DESTINATION ${INSTALL_CONFIGDIR} ) -install( - FILES - ${CMAKE_CURRENT_SOURCE_DIR}/cmake/Deploy.cmake - ${CMAKE_CURRENT_SOURCE_DIR}/cmake/Windeployqt.cmake - DESTINATION ${INSTALL_CONFIGDIR}/Modules/${PROJECT_NAME} -) - set(CPACK_GENERATOR "TXZ") -set(CPACK_PACKAGE_VERSION ${GIT_TAG}) +set(CPACK_PACKAGE_VERSION "${SOURCE_VERSION}") include(CPack) diff --git a/Src/CMakeLists.txt b/Src/CMakeLists.txt index 40dfe2a..6580775 100644 --- a/Src/CMakeLists.txt +++ b/Src/CMakeLists.txt @@ -2,73 +2,90 @@ #### Biotracker: Interfaces ############################################################## -target_include_directories(${TN} PUBLIC +set(target ${PROJECT_NAME}) +add_library(${target} SHARED) +if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") + set_target_properties(${target} PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS true) +endif() + +install( + TARGETS + ${PROJECT_NAME} + EXPORT + ${PROJECT_NAME}Targets + RUNTIME DESTINATION "${INSTALL_BINDIR}" + LIBRARY DESTINATION "${INSTALL_LIBDIR}" + ARCHIVE DESTINATION "${INSTALL_LIBDIR}" +) + +target_include_directories(${target} PUBLIC $ $ ) -find_package(Qt5 REQUIRED COMPONENTS Core Gui Widgets OpenGL Xml Network) -target_link_libraries(${TN} Qt5::Core Qt5::Gui Qt5::Xml Qt5::Network Qt5::Widgets) +find_package(Qt5 REQUIRED COMPONENTS Core Gui Widgets OpenGL) +target_link_libraries(${target} Qt5::Core Qt5::Gui Qt5::Widgets) -find_package(OpenCV 3 REQUIRED) -target_link_libraries(${TN} ${OpenCV_LIBS}) +target_link_libraries(${target} ${OpenCV_LIBS}) -set_target_properties(${TN} PROPERTIES POSITION_INDEPENDENT_CODE ON) -set_target_properties(${TN} PROPERTIES AUTOMOC ON AUTOUIC ON AUTORCC ON) -set_target_properties(${TN} PROPERTIES +set_target_properties(${target} PROPERTIES AUTOMOC ON AUTOUIC ON AUTORCC ON) +set_target_properties(${target} PROPERTIES CXX_STANDARD 17 CXX_STANDARD_REQUIRED YES CXX_EXTENSIONS NO ) -target_compile_definitions(${TN} PRIVATE BT_INTERFACES_EXPORT) +target_compile_definitions(${target} PRIVATE BT_INTERFACES_EXPORT) -target_sources(${TN} -PRIVATE - "${CMAKE_CURRENT_LIST_DIR}/Interfaces/ENUMS.cpp" - "${CMAKE_CURRENT_LIST_DIR}/Interfaces/IBioTrackerContext.cpp" - "${CMAKE_CURRENT_LIST_DIR}/Interfaces/IBioTrackerPlugin.cpp" - "${CMAKE_CURRENT_LIST_DIR}/Interfaces/IController/IController.cpp" - "${CMAKE_CURRENT_LIST_DIR}/Interfaces/IModel/IModel.cpp" - "${CMAKE_CURRENT_LIST_DIR}/Interfaces/IModel/IModelAreaDescriptor.cpp" - "${CMAKE_CURRENT_LIST_DIR}/Interfaces/IModel/IModelDataExporter.cpp" - "${CMAKE_CURRENT_LIST_DIR}/Interfaces/IModel/IModelTrackedComponent.cpp" - "${CMAKE_CURRENT_LIST_DIR}/Interfaces/IModel/IModelTrackedComponentFactory.cpp" - "${CMAKE_CURRENT_LIST_DIR}/Interfaces/IModel/IModelTrackedTrajectory.cpp" - "${CMAKE_CURRENT_LIST_DIR}/Interfaces/IModel/IModelTrackingAlgorithm.cpp" - "${CMAKE_CURRENT_LIST_DIR}/Interfaces/IModel/IObject.cpp" - "${CMAKE_CURRENT_LIST_DIR}/Interfaces/IModel/Serializable.cpp" - "${CMAKE_CURRENT_LIST_DIR}/Interfaces/IView/IView.cpp" - "${CMAKE_CURRENT_LIST_DIR}/Interfaces/IView/IViewGraphicsPixmapItem.cpp" - "${CMAKE_CURRENT_LIST_DIR}/Interfaces/IView/IViewGraphicsScene.cpp" - "${CMAKE_CURRENT_LIST_DIR}/Interfaces/IView/IViewGraphicsView.cpp" - "${CMAKE_CURRENT_LIST_DIR}/Interfaces/IView/IViewMainWindow.cpp" - "${CMAKE_CURRENT_LIST_DIR}/Interfaces/IView/IViewOpenGLWidget.cpp" - "${CMAKE_CURRENT_LIST_DIR}/Interfaces/IView/IViewTrackedComponent.cpp" - "${CMAKE_CURRENT_LIST_DIR}/Interfaces/IView/IViewWidget.cpp" +target_sources(${target} + PRIVATE + "Interfaces/ENUMS.cpp" + "Interfaces/IBioTrackerContext.cpp" + "Interfaces/IBioTrackerPlugin.cpp" + "Interfaces/IController/IController.cpp" + "Interfaces/IModel/IModel.cpp" + "Interfaces/IModel/IModelAreaDescriptor.h" + "Interfaces/IModel/IModelDataExporter.cpp" + "Interfaces/IModel/IModelTrackedComponent.cpp" + "Interfaces/IModel/IModelTrackedComponentFactory.cpp" + "Interfaces/IModel/IModelTrackedTrajectory.cpp" + "Interfaces/IModel/IModelTrackingAlgorithm.cpp" + "Interfaces/IModel/IObject.cpp" + "Interfaces/IModel/Serializable.cpp" + "Interfaces/IView/IView.cpp" + "Interfaces/IView/IViewGraphicsPixmapItem.cpp" + "Interfaces/IView/IViewGraphicsScene.cpp" + "Interfaces/IView/IViewGraphicsView.cpp" + "Interfaces/IView/IViewMainWindow.cpp" + "Interfaces/IView/IViewOpenGLWidget.cpp" + "Interfaces/IView/IViewTrackedComponent.cpp" + "Interfaces/IView/IViewWidget.cpp" ) -set(${TN}_PUBLIC_HEADERS - "${CMAKE_CURRENT_LIST_DIR}/Interfaces/API.h" - "${CMAKE_CURRENT_LIST_DIR}/Interfaces/ENUMS.h" - "${CMAKE_CURRENT_LIST_DIR}/Interfaces/IBioTrackerContext.h" - "${CMAKE_CURRENT_LIST_DIR}/Interfaces/IBioTrackerPlugin.h" - "${CMAKE_CURRENT_LIST_DIR}/Interfaces/IController/IController.h" - "${CMAKE_CURRENT_LIST_DIR}/Interfaces/IModel/IModel.h" - "${CMAKE_CURRENT_LIST_DIR}/Interfaces/IModel/IModelAreaDescriptor.h" - "${CMAKE_CURRENT_LIST_DIR}/Interfaces/IModel/IModelDataExporter.h" - "${CMAKE_CURRENT_LIST_DIR}/Interfaces/IModel/IModelTrackedComponent.h" - "${CMAKE_CURRENT_LIST_DIR}/Interfaces/IModel/IModelTrackedComponentFactory.h" - "${CMAKE_CURRENT_LIST_DIR}/Interfaces/IModel/IModelTrackedTrajectory.h" - "${CMAKE_CURRENT_LIST_DIR}/Interfaces/IModel/IModelTrackingAlgorithm.h" - "${CMAKE_CURRENT_LIST_DIR}/Interfaces/IModel/IObject.h" - "${CMAKE_CURRENT_LIST_DIR}/Interfaces/IModel/Serializable.h" - "${CMAKE_CURRENT_LIST_DIR}/Interfaces/IView/IView.h" - "${CMAKE_CURRENT_LIST_DIR}/Interfaces/IView/IViewGraphicsPixmapItem.h" - "${CMAKE_CURRENT_LIST_DIR}/Interfaces/IView/IViewGraphicsScene.h" - "${CMAKE_CURRENT_LIST_DIR}/Interfaces/IView/IViewGraphicsView.h" - "${CMAKE_CURRENT_LIST_DIR}/Interfaces/IView/IViewMainWindow.h" - "${CMAKE_CURRENT_LIST_DIR}/Interfaces/IView/IViewOpenGLWidget.h" - "${CMAKE_CURRENT_LIST_DIR}/Interfaces/IView/IViewTrackedComponent.h" - "${CMAKE_CURRENT_LIST_DIR}/Interfaces/IView/IViewWidget.h" +install_headers( + HEADERS + "Interfaces/API.h" + "Interfaces/ENUMS.h" + "Interfaces/IBioTrackerContext.h" + "Interfaces/IBioTrackerPlugin.h" + "Interfaces/IController/IController.h" + "Interfaces/IModel/IModel.h" + "Interfaces/IModel/IModelAreaDescriptor.h" + "Interfaces/IModel/IModelDataExporter.h" + "Interfaces/IModel/IModelTrackedComponent.h" + "Interfaces/IModel/IModelTrackedComponentFactory.h" + "Interfaces/IModel/IModelTrackedTrajectory.h" + "Interfaces/IModel/IModelTrackingAlgorithm.h" + "Interfaces/IModel/IObject.h" + "Interfaces/IModel/Serializable.h" + "Interfaces/IView/IView.h" + "Interfaces/IView/IViewGraphicsPixmapItem.h" + "Interfaces/IView/IViewGraphicsScene.h" + "Interfaces/IView/IViewGraphicsView.h" + "Interfaces/IView/IViewMainWindow.h" + "Interfaces/IView/IViewOpenGLWidget.h" + "Interfaces/IView/IViewTrackedComponent.h" + "Interfaces/IView/IViewWidget.h" + DESTINATION "${INSTALL_INCLUDEDIR}" ) + diff --git a/Src/Interfaces/API.h b/Src/Interfaces/API.h index 1ed37d7..d6a816a 100644 --- a/Src/Interfaces/API.h +++ b/Src/Interfaces/API.h @@ -1,6 +1,6 @@ #pragma once -#include +#include #if defined(BT_INTERFACES_EXPORT) #define BT_INTERFACES_API Q_DECL_EXPORT diff --git a/Src/Interfaces/ENUMS.h b/Src/Interfaces/ENUMS.h index bafbf8f..ff9275f 100644 --- a/Src/Interfaces/ENUMS.h +++ b/Src/Interfaces/ENUMS.h @@ -1,5 +1,4 @@ -#ifndef ENUMS_H -#define ENUMS_H +#pragma once #include #include @@ -8,36 +7,34 @@ class BT_INTERFACES_API ENUMS : public QObject { Q_OBJECT public: - - - enum CONTROLLERTYPE : unsigned int{ - NO_CTR, - MAINWINDOW, - TEXTUREOBJECT, - PLAYER, - COMPONENT, - TRACKING, - GRAPHICSVIEW, - TRACKEDCOMPONENTCORE, - PLUGIN, - DATAEXPORT, - ANNOTATIONS, - AREADESCRIPTOR, - COREPARAMETER, - COMMANDS, - NOTIFICATION - }; + enum CONTROLLERTYPE : unsigned int + { + NO_CTR, + MAINWINDOW, + TEXTUREOBJECT, + PLAYER, + COMPONENT, + TRACKING, + GRAPHICSVIEW, + TRACKEDCOMPONENTCORE, + PLUGIN, + DATAEXPORT, + ANNOTATIONS, + AREADESCRIPTOR, + COREPARAMETER, + COMMANDS, + NOTIFICATION + }; Q_ENUM(CONTROLLERTYPE) - enum COREPERMISSIONS : unsigned int{ - COMPONENTVIEW, - COMPONENTMOVE, - COMPONENTREMOVE, - COMPONENTSWAP, - COMPONENTADD, - COMPONENTROTATE - }; - Q_ENUM(COREPERMISSIONS) + enum COREPERMISSIONS : unsigned int + { + COMPONENTVIEW, + COMPONENTMOVE, + COMPONENTREMOVE, + COMPONENTSWAP, + COMPONENTADD, + COMPONENTROTATE + }; + Q_ENUM(COREPERMISSIONS) }; - -#endif // ENUMS_H diff --git a/Src/Interfaces/IBioTrackerContext.cpp b/Src/Interfaces/IBioTrackerContext.cpp index 9eb71ed..9f833c6 100644 --- a/Src/Interfaces/IBioTrackerContext.cpp +++ b/Src/Interfaces/IBioTrackerContext.cpp @@ -3,11 +3,9 @@ #include "QDebug" - -IBioTrackerContext::IBioTrackerContext(QObject *parent) : - QObject(parent) +IBioTrackerContext::IBioTrackerContext(QObject* parent) +: QObject(parent) { - } void IBioTrackerContext::createApplication() @@ -16,23 +14,21 @@ void IBioTrackerContext::createApplication() connectController(); } - void IBioTrackerContext::createAppController() { - } -IController *IBioTrackerContext::requestController(ENUMS::CONTROLLERTYPE ctrtype) +IController* IBioTrackerContext::requestController( + ENUMS::CONTROLLERTYPE ctrtype) { return m_ControllersMap.value(ctrtype); } void IBioTrackerContext::connectController() { - } -void IBioTrackerContext::addController(IController *ctr) +void IBioTrackerContext::addController(IController* ctr) { m_ControllersMap.insert(ctr->getControllerType(), ctr); } diff --git a/Src/Interfaces/IBioTrackerContext.h b/Src/Interfaces/IBioTrackerContext.h index 8c3f247..424336f 100644 --- a/Src/Interfaces/IBioTrackerContext.h +++ b/Src/Interfaces/IBioTrackerContext.h @@ -1,5 +1,4 @@ -#ifndef IBIOTRACKERCONTEXT_H -#define IBIOTRACKERCONTEXT_H +#pragma once #include #include "QMap" @@ -12,23 +11,21 @@ class BT_INTERFACES_API IBioTrackerContext : public QObject { Q_OBJECT public: - IBioTrackerContext(QObject *parent = 0); - ~IBioTrackerContext() {} + IBioTrackerContext(QObject* parent = 0); + ~IBioTrackerContext() + { + } void createApplication(); - IController * requestController(ENUMS::CONTROLLERTYPE ctrtype); + IController* requestController(ENUMS::CONTROLLERTYPE ctrtype); protected: virtual void createAppController(); virtual void connectController(); - void addController(IController * ctr); -protected: - QMap m_ControllersMap; - - + void addController(IController* ctr); +protected: + QMap m_ControllersMap; }; - -#endif // IBIOTRACKERCONTEXT_H diff --git a/Src/Interfaces/IBioTrackerPlugin.cpp b/Src/Interfaces/IBioTrackerPlugin.cpp index 6e00a55..8236841 100644 --- a/Src/Interfaces/IBioTrackerPlugin.cpp +++ b/Src/Interfaces/IBioTrackerPlugin.cpp @@ -1,9 +1,30 @@ #include "IBioTrackerPlugin.h" -IView *IBioTrackerPlugin::getTrackerParameterWidget() { return nullptr; }; -IView *IBioTrackerPlugin::getTrackerElementsWidget() { return nullptr; }; -IModel *IBioTrackerPlugin::getTrackerComponentModel() { return nullptr; }; -void IBioTrackerPlugin::sendCorePermissions() { return; }; -IModelTrackedComponentFactory *IBioTrackerPlugin::getComponentFactory() { return nullptr; }; -void IBioTrackerPlugin::connectInterfaces() { return; }; -void IBioTrackerPlugin::receiveAreaDescriptor(IModelAreaDescriptor *areaDescr) { return; }; \ No newline at end of file +IView* IBioTrackerPlugin::getTrackerParameterWidget() +{ + return nullptr; +}; +IView* IBioTrackerPlugin::getTrackerElementsWidget() +{ + return nullptr; +}; +IModel* IBioTrackerPlugin::getTrackerComponentModel() +{ + return nullptr; +}; +void IBioTrackerPlugin::sendCorePermissions() +{ + return; +}; +IModelTrackedComponentFactory* IBioTrackerPlugin::getComponentFactory() +{ + return nullptr; +}; +void IBioTrackerPlugin::connectInterfaces() +{ + return; +}; +void IBioTrackerPlugin::receiveAreaDescriptor(IModelAreaDescriptor* areaDescr) +{ + return; +}; \ No newline at end of file diff --git a/Src/Interfaces/IBioTrackerPlugin.h b/Src/Interfaces/IBioTrackerPlugin.h index 43d0288..8e828fe 100644 --- a/Src/Interfaces/IBioTrackerPlugin.h +++ b/Src/Interfaces/IBioTrackerPlugin.h @@ -1,7 +1,8 @@ -#ifndef IBIOTRACKERPLUGIN_H -#define IBIOTRACKERPLUGIN_H +#pragma once -#include "QObject" +#include +#include +#include #include "Interfaces/IController/IController.h" #include "Interfaces/IModel/IModelDataExporter.h" @@ -11,62 +12,61 @@ #include "memory" #include - class BT_INTERFACES_API IBioTrackerPlugin : public QObject { Q_OBJECT public: - ~IBioTrackerPlugin() {} + ~IBioTrackerPlugin() + { + } - virtual void createPlugin() = 0; + virtual void init() = 0; - /** - * Hook for the tracker options to add to the GUI - */ - virtual IView *getTrackerParameterWidget(); - /** - * Hook for the tracking data visualization of the tracker - */ - virtual IView *getTrackerElementsWidget(); - /** - * Hook for the tracking data to visualize and export in the core app - */ - virtual IModel *getTrackerComponentModel(); - /** - * Hook for the core permissions - */ + /** + * Hook for the tracker options to add to the GUI + */ + virtual IView* getTrackerParameterWidget(); + /** + * Hook for the tracking data visualization of the tracker + */ + virtual IView* getTrackerElementsWidget(); + /** + * Hook for the tracking data to visualize and export in the core app + */ + virtual IModel* getTrackerComponentModel(); + /** + * Hook for the core permissions + */ virtual void sendCorePermissions(); - /** - * Hook for the component factory to deserialize in the core app - */ - virtual IModelTrackedComponentFactory *getComponentFactory(); + /** + * Hook for the component factory to deserialize in the core app + */ + virtual IModelTrackedComponentFactory* getComponentFactory(); private: virtual void connectInterfaces(); Q_SIGNALS: - virtual void emitCvMat(std::shared_ptr mat, QString name) = 0; - /** - * Will be sent when tracking is doen to multiple components of the core app - * An example is the visualisation which is then updated - */ - virtual void emitTrackingDone(uint framenumber) = 0; - virtual void emitChangeDisplayImage(QString str) = 0; - virtual void emitCorePermission(std::pair) = 0; + void trackingImageNamesChanged(QVector imageNames); + void trackingImagesChanged(QMap images); -public Q_SLOTS: - virtual void receiveCurrentFrameFromMainApp(std::shared_ptr mat, uint frameNumber) = 0; - /** - * Recieves area descriptor data for rectification (px to cm) and for tracking arena boundary - */ - virtual void receiveAreaDescriptor(IModelAreaDescriptor *areaDescr); + /** + * Will be sent when tracking is doen to multiple components of the core + * app An example is the visualisation which is then updated + */ + void emitTrackingDone(uint framenumber); + void emitCorePermission(std::pair); -//private Q_SLOTS: -// virtual void receiveCvMatFromController(std::shared_ptr mat, QString name) = 0; +public Q_SLOTS: + virtual void receiveCurrentFrameFromMainApp(cv::Mat mat, + uint frameNumber) = 0; + /** + * Recieves area descriptor data for rectification (px to cm) and for + * tracking arena boundary + */ + virtual void receiveAreaDescriptor(IModelAreaDescriptor* areaDescr); }; #define IBioTrackerPlugin_iid "de.fu-berlin.mi.biorobotics.IBioTrackerPlugin" Q_DECLARE_INTERFACE(IBioTrackerPlugin, IBioTrackerPlugin_iid) - -#endif // IBIOTRACKERPLUGIN_H diff --git a/Src/Interfaces/IController/IController.cpp b/Src/Interfaces/IController/IController.cpp index 9c898cd..8447ff4 100644 --- a/Src/Interfaces/IController/IController.cpp +++ b/Src/Interfaces/IController/IController.cpp @@ -1,25 +1,25 @@ #include "IController.h" - -IController::IController(QObject *parent, IBioTrackerContext *context, ENUMS::CONTROLLERTYPE ctr) : QObject(parent), - m_BioTrackerContext(context), - m_ControllerType(ctr) +IController::IController(QObject* parent, + IBioTrackerContext* context, + ENUMS::CONTROLLERTYPE ctr) +: QObject(parent) +, m_BioTrackerContext(context) +, m_ControllerType(ctr) { - } -void IController::cleanup() { - +void IController::cleanup() +{ } -IBioTrackerContext *IController::getBioTrackerContext() +IBioTrackerContext* IController::getBioTrackerContext() { return m_BioTrackerContext.data(); } void IController::connectModelToController() { - } void IController::createComponents() @@ -34,19 +34,23 @@ void IController::connectComponents() connectControllerToController(); } -void IController::addView(IView *view) { +void IController::addView(IView* view) +{ m_View = view; } -void IController::addModel(IModel *model) { +void IController::addModel(IModel* model) +{ m_Model = model; } -IModel *IController::getModel() { +IModel* IController::getModel() +{ return m_Model.data(); } -IView *IController::getView() { +IView* IController::getView() +{ return m_View; } diff --git a/Src/Interfaces/IController/IController.h b/Src/Interfaces/IController/IController.h index e557ae3..0bef854 100644 --- a/Src/Interfaces/IController/IController.h +++ b/Src/Interfaces/IController/IController.h @@ -12,10 +12,14 @@ #include "Interfaces/ENUMS.h" #include -class BT_INTERFACES_API IController : public QObject { +class BT_INTERFACES_API IController : public QObject +{ Q_OBJECT - public: - explicit IController(QObject *parent = 0, IBioTrackerContext *context = 0, ENUMS::CONTROLLERTYPE ctr = ENUMS::CONTROLLERTYPE::NO_CTR); +public: + explicit IController( + QObject* parent = 0, + IBioTrackerContext* context = 0, + ENUMS::CONTROLLERTYPE ctr = ENUMS::CONTROLLERTYPE::NO_CTR); /** * @brief @@ -29,28 +33,27 @@ class BT_INTERFACES_API IController : public QObject { virtual void cleanup(); - void addView(IView *view); - void addModel(IModel *model); - IModel *getModel(); - IView *getView(); + void addView(IView* view); + void addModel(IModel* model); + IModel* getModel(); + IView* getView(); ENUMS::CONTROLLERTYPE getControllerType(); - IBioTrackerContext *getBioTrackerContext(); + IBioTrackerContext* getBioTrackerContext(); protected: - virtual void createModel() = 0; - virtual void createView() = 0; - virtual void connectModelToController() = 0; + virtual void createModel() = 0; + virtual void createView() = 0; + virtual void connectModelToController() = 0; virtual void connectControllerToController() = 0; protected: - QPointer< IBioTrackerContext > m_BioTrackerContext; + QPointer m_BioTrackerContext; - IView *m_View; + IView* m_View; QPointer m_Model; ENUMS::CONTROLLERTYPE m_ControllerType; - }; #endif // ICONTROLLER_H diff --git a/Src/Interfaces/IModel/IModel.cpp b/Src/Interfaces/IModel/IModel.cpp index 3de1fa4..a6ba791 100644 --- a/Src/Interfaces/IModel/IModel.cpp +++ b/Src/Interfaces/IModel/IModel.cpp @@ -1,9 +1,10 @@ #include "IModel.h" -IModel::IModel(QObject *parent) : QObject(parent) { - +IModel::IModel(QObject* parent) +: QObject(parent) +{ } -IModel::~IModel() { - +IModel::~IModel() +{ } diff --git a/Src/Interfaces/IModel/IModel.h b/Src/Interfaces/IModel/IModel.h index 82b36cb..da1c2f2 100644 --- a/Src/Interfaces/IModel/IModel.h +++ b/Src/Interfaces/IModel/IModel.h @@ -1,21 +1,19 @@ -#ifndef IMODEL_H -#define IMODEL_H +#pragma once #include #include "memory" #include -class BT_INTERFACES_API IModel : public QObject { +class BT_INTERFACES_API IModel : public QObject +{ Q_OBJECT - public: - explicit IModel(QObject *parent = 0); +public: + explicit IModel(QObject* parent = 0); ~IModel(); - Q_SIGNALS: +Q_SIGNALS: void notifyView(); - public Q_SLOTS: +public Q_SLOTS: }; - -#endif // IMODEL_H diff --git a/Src/Interfaces/IModel/IModelAreaDescriptor.cpp b/Src/Interfaces/IModel/IModelAreaDescriptor.cpp deleted file mode 100644 index e69de29..0000000 diff --git a/Src/Interfaces/IModel/IModelAreaDescriptor.h b/Src/Interfaces/IModel/IModelAreaDescriptor.h index 011668f..de4cb92 100644 --- a/Src/Interfaces/IModel/IModelAreaDescriptor.h +++ b/Src/Interfaces/IModel/IModelAreaDescriptor.h @@ -2,34 +2,35 @@ #include "IModel.h" #include -#include +#include -class BT_INTERFACES_API IModelAreaDescriptor :public IModel +class BT_INTERFACES_API IModelAreaDescriptor : public IModel { - Q_OBJECT + Q_OBJECT public: - IModelAreaDescriptor(QObject *parent = 0) : IModel(parent) {}; - //~IModelAreaDescriptor(); - -public: - - virtual bool inTrackingArea(cv::Point2f point_cm) = 0; - - /** - * Transform the provided pixel coordinates into world coordinates and return world coordinates. - * @param: pixelCoords, a list of points. - * @return: world coordinates in as a list. - */ - virtual cv::Point2f pxToCm(cv::Point point_px) = 0; + IModelAreaDescriptor(QObject* parent = 0) + : IModel(parent){}; + //~IModelAreaDescriptor(); - /** - * Transform the provided pixel point into world coordinates and return world point. - * @param: point, a pixel point, used opencv point - * @return: world point. - */ - virtual cv::Point2f cmToPx(cv::Point2f point_cm) = 0; public: + virtual bool inTrackingArea(cv::Point2f point_cm) = 0; + + /** + * Transform the provided pixel coordinates into world coordinates and + * return world coordinates. + * @param: pixelCoords, a list of points. + * @return: world coordinates in as a list. + */ + virtual cv::Point2f pxToCm(cv::Point point_px) = 0; + + /** + * Transform the provided pixel point into world coordinates and return + * world point. + * @param: point, a pixel point, used opencv point + * @return: world point. + */ + virtual cv::Point2f cmToPx(cv::Point2f point_cm) = 0; +public: }; - diff --git a/Src/Interfaces/IModel/IModelDataExporter.cpp b/Src/Interfaces/IModel/IModelDataExporter.cpp index 672137e..ce63934 100644 --- a/Src/Interfaces/IModel/IModelDataExporter.cpp +++ b/Src/Interfaces/IModel/IModelDataExporter.cpp @@ -1,13 +1,10 @@ #include "IModelDataExporter.h" - - -IModelDataExporter::IModelDataExporter(QObject *parent) : - IModel(parent) +IModelDataExporter::IModelDataExporter(QObject* parent) +: IModel(parent) { } - IModelDataExporter::~IModelDataExporter() { } diff --git a/Src/Interfaces/IModel/IModelDataExporter.h b/Src/Interfaces/IModel/IModelDataExporter.h index 4d4f7ac..da6d1e0 100644 --- a/Src/Interfaces/IModel/IModelDataExporter.h +++ b/Src/Interfaces/IModel/IModelDataExporter.h @@ -6,36 +6,41 @@ #include #include /** -* Interface for the data exporters in the core app -* Besides serializing to files also includes deserializing from files -* Current exporters are CSV, generic and JSON. -*/ -class BT_INTERFACES_API IModelDataExporter :public IModel + * Interface for the data exporters in the core app + * Besides serializing to files also includes deserializing from files + * Current exporters are CSV, generic and JSON. + */ +class BT_INTERFACES_API IModelDataExporter : public IModel { - Q_OBJECT + Q_OBJECT public: - IModelDataExporter(QObject *parent = 0); - ~IModelDataExporter(); + IModelDataExporter(QObject* parent = 0); + ~IModelDataExporter(); - virtual void open(IModelTrackedTrajectory *root) = 0; - virtual void write(int idx) = 0; - virtual void writeAll(std::string f) = 0; - virtual void close() = 0; - virtual void finalizeAndReInit() = 0; - void setFps(float fps) { _fps = fps; }; - void setTitle(std::string title) { _title = title; }; - virtual void finalize() = 0; + virtual void open(IModelTrackedTrajectory* root) = 0; + virtual void write(int idx) = 0; + virtual void writeAll(std::string f) = 0; + virtual void close() = 0; + virtual void finalizeAndReInit() = 0; + void setFps(float fps) + { + _fps = fps; + }; + void setTitle(std::string title) + { + _title = title; + }; + virtual void finalize() = 0; - virtual void loadFile(std::string file) = 0; - virtual QString getSuffix() = 0; + virtual void loadFile(std::string file) = 0; + virtual QString getSuffix() = 0; public: - IModelTrackedTrajectory *_root; - float _fps; - std::string _title; + IModelTrackedTrajectory* _root; + float _fps; + std::string _title; signals: - void fileWritten(QFileInfo file); + void fileWritten(QFileInfo file); }; - diff --git a/Src/Interfaces/IModel/IModelTrackedComponent.cpp b/Src/Interfaces/IModel/IModelTrackedComponent.cpp index 1dd5f65..381fd37 100644 --- a/Src/Interfaces/IModel/IModelTrackedComponent.cpp +++ b/Src/Interfaces/IModel/IModelTrackedComponent.cpp @@ -6,52 +6,46 @@ IModelTrackedComponentFactory* factory = nullptr; -IModelTrackedComponent::IModelTrackedComponent(QObject *parent) : - IModel(parent) +IModelTrackedComponent::IModelTrackedComponent(QObject* parent) +: IModel(parent) { - } -IModelComponentEuclidian2D::IModelComponentEuclidian2D(QObject *parent) : - IModelTrackedComponent(parent) +IModelComponentEuclidian2D::IModelComponentEuclidian2D(QObject* parent) +: IModelTrackedComponent(parent) { - } -IModelComponentTemporal2D::IModelComponentTemporal2D(QObject *parent) : - IModelComponentEuclidian2D(parent) +IModelComponentTemporal2D::IModelComponentTemporal2D(QObject* parent) +: IModelComponentEuclidian2D(parent) { - } -IModelTrackedPoint::IModelTrackedPoint(QObject *parent) : - IModelComponentTemporal2D(parent) +IModelTrackedPoint::IModelTrackedPoint(QObject* parent) +: IModelComponentTemporal2D(parent) { - } -IModelTrackedPolygon::IModelTrackedPolygon(QObject *parent) : - IModelComponentTemporal2D(parent) +IModelTrackedPolygon::IModelTrackedPolygon(QObject* parent) +: IModelComponentTemporal2D(parent) { - } -IModelTrackedEllipse::IModelTrackedEllipse(QObject *parent) : - IModelTrackedPoint(parent) +IModelTrackedEllipse::IModelTrackedEllipse(QObject* parent) +: IModelTrackedPoint(parent) { - } -IModelTrackedRectangle::IModelTrackedRectangle(QObject *parent) : - IModelTrackedPoint(parent) +IModelTrackedRectangle::IModelTrackedRectangle(QObject* parent) +: IModelTrackedPoint(parent) { - } -QDataStream &operator<<(QDataStream &ds, const QList &data) { +QDataStream& operator<<(QDataStream& ds, + const QList& data) +{ ds << qint64(data.size()); - for (int i = 0; imetaObject()->className()); else @@ -61,43 +55,41 @@ QDataStream &operator<<(QDataStream &ds, const QList &d return ds; } -QDataStream &operator >> (QDataStream &ds, QList &data) { +QDataStream& operator>>(QDataStream& ds, QList& data) +{ qint64 s; ds >> s; - for (int i = 0; i> cn; - std::string sss = cn.toStdString(); - IModelTrackedComponent* cp = static_cast(factory->getNewTrackedElement(cn)); + std::string sss = cn.toStdString(); + IModelTrackedComponent* cp = static_cast( + factory->getNewTrackedElement(cn)); ds >> (*cp); data.append(cp); } return ds; } -QDataStream &operator<<(QDataStream &ds, const IModelTrackedComponent &data) { - for (int i = 0; ipropertyCount(); ++i) - { - if (data.metaObject()->property(i).isStored(&data)) - { +QDataStream& operator<<(QDataStream& ds, const IModelTrackedComponent& data) +{ + for (int i = 0; i < data.metaObject()->propertyCount(); ++i) { + if (data.metaObject()->property(i).isStored(&data)) { QVariant v = data.metaObject()->property(i).read(&data); - ds << data.metaObject()->property(i).read(&data); - } - } - return ds; + ds << data.metaObject()->property(i).read(&data); + } + } + return ds; } -QDataStream &operator>>(QDataStream &ds, IModelTrackedComponent &data) { - QVariant var; - for (int i = 0; ipropertyCount(); ++i) - { - if (data.metaObject()->property(i).isStored(&data)) - { - ds >> var; - data.metaObject()->property(i).write(&data, var); - } - } - return ds; +QDataStream& operator>>(QDataStream& ds, IModelTrackedComponent& data) +{ + QVariant var; + for (int i = 0; i < data.metaObject()->propertyCount(); ++i) { + if (data.metaObject()->property(i).isStored(&data)) { + ds >> var; + data.metaObject()->property(i).write(&data, var); + } + } + return ds; } - diff --git a/Src/Interfaces/IModel/IModelTrackedComponent.h b/Src/Interfaces/IModel/IModelTrackedComponent.h index a3bffa1..4bdca42 100644 --- a/Src/Interfaces/IModel/IModelTrackedComponent.h +++ b/Src/Interfaces/IModel/IModelTrackedComponent.h @@ -1,5 +1,4 @@ -#ifndef ITRACKEDCOMPONENT_H -#define ITRACKEDCOMPONENT_H +#pragma once #include "IModel.h" #include @@ -9,131 +8,168 @@ #include #include - /** -* This is the common interface for all TrackedComponents (IModelTrackedTrajectory and any leaf class). -* It is part of the Composite Pattern and is the equivalent to the abstract Component class. -* This class is derived from IModel from the Model-View-Controller structure. -* A TrackedComponent has a QObject as parent and it -* has a methode called operate() that needs to be implemented -* by all derivatives of this interface class. -*/ + * This is the common interface for all TrackedComponents + * (IModelTrackedTrajectory and any leaf class). It is part of the Composite + * Pattern and is the equivalent to the abstract Component class. This class is + * derived from IModel from the Model-View-Controller structure. A + * TrackedComponent has a QObject as parent and it has a methode called + * operate() that needs to be implemented by all derivatives of this interface + * class. + */ /* -* Blank component -*/ + * Blank component + */ class BT_INTERFACES_API IModelTrackedComponent : public IModel { - Q_OBJECT - /* - Q_PROPERTY-System: http://doc.qt.io/qt-5/properties.html - */ - Q_PROPERTY(bool valid READ getValid() WRITE setValid STORED true) - Q_PROPERTY(double id READ getId() WRITE setId STORED true) + Q_OBJECT + /* + Q_PROPERTY-System: http://doc.qt.io/qt-5/properties.html + */ + Q_PROPERTY(bool valid READ getValid() WRITE setValid STORED true) + Q_PROPERTY(double id READ getId() WRITE setId STORED true) public: - /** - * The constructor of the IModelTrackedComponent class is able to receive a QObject as parent. - */ - IModelTrackedComponent(QObject *parent = 0); - /* - Getters, Setters & Checkers - */ - virtual void setValid(bool v) { _valid = v; }; - virtual void setId(int id) { _id = id; }; - virtual void setFixed(bool fixed) { _fixed = fixed; }; - virtual void setParent(IModelTrackedComponent *p) { _parentNode = p; }; - virtual int getId() { return _id; }; - virtual bool getValid() { return _valid; }; - virtual bool getFixed() { return _fixed; }; - - /** - * The methode operate() must be implemented by every derivative of this class. - */ - virtual void operate() = 0; + /** + * The constructor of the IModelTrackedComponent class is able to receive a + * QObject as parent. + */ + IModelTrackedComponent(QObject* parent = 0); + /* + Getters, Setters & Checkers + */ + virtual void setValid(bool v) + { + _valid = v; + }; + virtual void setId(int id) + { + _id = id; + }; + virtual void setFixed(bool fixed) + { + _fixed = fixed; + }; + virtual void setParent(IModelTrackedComponent* p) + { + _parentNode = p; + }; + virtual int getId() + { + return _id; + }; + virtual bool getValid() + { + return _valid; + }; + virtual bool getFixed() + { + return _fixed; + }; + + /** + * The methode operate() must be implemented by every derivative of this + * class. + */ + virtual void operate() = 0; protected: - int _id; /**< id of the component */ - bool _valid; /**< validity of the component; if invalid -> not visualized */ - bool _fixed; /**< fix status; if fixed the tracked should not change state*/ - IModelTrackedComponent *_parentNode = nullptr; /**< parent */ + int _id; /**< id of the component */ + bool + _valid; /**< validity of the component; if invalid -> not visualized */ + bool + _fixed; /**< fix status; if fixed the tracked should not change state*/ + IModelTrackedComponent* _parentNode = nullptr; /**< parent */ }; - Q_DECLARE_METATYPE(QList) /** -* Serialization operator for multiple components. -*/ -QDataStream &operator<<(QDataStream &ds, const QList &data); + * Serialization operator for multiple components. + */ +QDataStream& operator<<(QDataStream& ds, + const QList& data); /** -* Deserialization operator for multiple components. -*/ -QDataStream &operator>>(QDataStream &ds, QList &data); + * Deserialization operator for multiple components. + */ +QDataStream& operator>>(QDataStream& ds, QList& data); /** -* Serialization operator for one component. -*/ -QDataStream &operator<<(QDataStream &out, const IModelTrackedComponent &painting); + * Serialization operator for one component. + */ +QDataStream& operator<<(QDataStream& out, + const IModelTrackedComponent& painting); /** -* Deserialization operator for one component. -*/ -QDataStream &operator>>(QDataStream &in, IModelTrackedComponent &painting); - -/***************************************************************************//** -* This is a node of the Composite Pattern -* This class is derived from IModelTrackedComponent. -* It includes positional data like x,y-coordinates (in px and _coordinateUnit), the orientation in rad and deg -* and the width and height (in px and _coordinateUnit) -*******************************************************************************/ - -class BT_INTERFACES_API IModelComponentEuclidian2D : public IModelTrackedComponent { + * Deserialization operator for one component. + */ +QDataStream& operator>>(QDataStream& in, IModelTrackedComponent& painting); + +/***************************************************************************/ /** + * This is a node of the Composite Pattern + * This class is derived from IModelTrackedComponent. + * It includes positional data like x,y-coordinates (in px and _coordinateUnit), the orientation in rad and deg + * and the width and height (in px and _coordinateUnit) + *******************************************************************************/ + +class BT_INTERFACES_API IModelComponentEuclidian2D +: public IModelTrackedComponent +{ public: - Q_OBJECT - /* - Q_PROPERTY-System: http://doc.qt.io/qt-5/properties.html - */ - Q_PROPERTY(QString coordinateUnit READ getCoordinateUnit() WRITE setCoordinateUnit STORED true) - Q_PROPERTY(float x READ getX() WRITE setX STORED hasX) - Q_PROPERTY(float y READ getY() WRITE setY STORED hasY) - Q_PROPERTY(float w READ getW() WRITE setW STORED hasW) - Q_PROPERTY(float h READ getH() WRITE setH STORED hasH) - Q_PROPERTY(float wpx READ getWpx() WRITE setWpx STORED hasWpx) - Q_PROPERTY(float hpx READ getHpx() WRITE setHpx STORED hasHpx) - Q_PROPERTY(float rad READ getRad() WRITE setRad STORED hasRad) - Q_PROPERTY(float deg READ getDeg() WRITE setDeg STORED hasDeg) - Q_PROPERTY(float xpx READ getXpx() WRITE setXpx STORED hasXpx) - Q_PROPERTY(float ypx READ getYpx() WRITE setYpx STORED hasYpx) + Q_OBJECT + /* + Q_PROPERTY-System: http://doc.qt.io/qt-5/properties.html + */ + Q_PROPERTY(QString coordinateUnit READ getCoordinateUnit() + WRITE setCoordinateUnit STORED true) + Q_PROPERTY(float x READ getX() WRITE setX STORED hasX) + Q_PROPERTY(float y READ getY() WRITE setY STORED hasY) + Q_PROPERTY(float w READ getW() WRITE setW STORED hasW) + Q_PROPERTY(float h READ getH() WRITE setH STORED hasH) + Q_PROPERTY(float wpx READ getWpx() WRITE setWpx STORED hasWpx) + Q_PROPERTY(float hpx READ getHpx() WRITE setHpx STORED hasHpx) + Q_PROPERTY(float rad READ getRad() WRITE setRad STORED hasRad) + Q_PROPERTY(float deg READ getDeg() WRITE setDeg STORED hasDeg) + Q_PROPERTY(float xpx READ getXpx() WRITE setXpx STORED hasXpx) + Q_PROPERTY(float ypx READ getYpx() WRITE setYpx STORED hasYpx) public: - /** - * The constructor of the IModelTrackedComponent class is able to receive a QObject as parent. - * It should not be implemented as it is a not a leaf or a composite - */ - IModelComponentEuclidian2D(QObject *parent = 0); + /** + * The constructor of the IModelTrackedComponent class is able to receive a + * QObject as parent. It should not be implemented as it is a not a leaf or + * a composite + */ + IModelComponentEuclidian2D(QObject* parent = 0); /* Returns a human-readable string about coordinate units. - * Freely enter something like "px", "cm" or "um". This will be annotated in the output. + * Freely enter something like "px", "cm" or "um". This will be annotated + * in the output. + */ + virtual QString getCoordinateUnit() + { + return "cm"; + }; + virtual void setCoordinateUnit(QString c) + { + _coordinateUnit = c; + }; + + /* + Getters, Setters & Checkers */ - virtual QString getCoordinateUnit() { return "cm"; }; - virtual void setCoordinateUnit(QString c) { _coordinateUnit = c; }; - - /* - Getters, Setters & Checkers - */ - virtual void setX(float x) = 0; - virtual void setY(float y) = 0; - virtual void setW(float w) = 0; - virtual void setH(float h) = 0; - virtual void setXpx(float h) = 0; - virtual void setYpx(float h) = 0; - virtual void setWpx(float h) = 0; - virtual void setHpx(float h) = 0; - virtual void setRad(float r) = 0; - virtual void setDeg(float d) = 0; - - virtual float getX() = 0; - virtual float getY() = 0; - virtual float getW() = 0; - virtual float getH() = 0; + virtual void setX(float x) = 0; + virtual void setY(float y) = 0; + virtual void setW(float w) = 0; + virtual void setH(float h) = 0; + virtual void setXpx(float h) = 0; + virtual void setYpx(float h) = 0; + virtual void setWpx(float h) = 0; + virtual void setHpx(float h) = 0; + virtual void setRad(float r) = 0; + virtual void setDeg(float d) = 0; + + virtual float getX() = 0; + virtual float getY() = 0; + virtual float getW() = 0; + virtual float getH() = 0; virtual float getXpx() = 0; virtual float getYpx() = 0; virtual float getWpx() = 0; @@ -141,10 +177,10 @@ class BT_INTERFACES_API IModelComponentEuclidian2D : public IModelTrackedCompone virtual float getRad() = 0; virtual float getDeg() = 0; - virtual bool hasX() = 0; - virtual bool hasY() = 0; - virtual bool hasW() = 0; - virtual bool hasH() = 0; + virtual bool hasX() = 0; + virtual bool hasY() = 0; + virtual bool hasW() = 0; + virtual bool hasH() = 0; virtual bool hasXpx() = 0; virtual bool hasYpx() = 0; virtual bool hasWpx() = 0; @@ -153,189 +189,198 @@ class BT_INTERFACES_API IModelComponentEuclidian2D : public IModelTrackedCompone virtual bool hasDeg() = 0; protected: - QString _coordinateUnit; /**< coordinate unit, will be saved in exported file */ - float _x; /**< x-coordinate in coordinate unit*/ - float _y; /**< y-coordinate in coordinate unit*/ - float _w; /**< width in coordinate unit*/ - float _h; /**< height in coordinate unit*/ - float _rad; /**< orientation in rad */ - float _deg; /**< orientation in deg */ - float _xpx; /**< x-coordinate in px */ - float _ypx; /**< y-coordinate in px */ - float _wpx; /**< width in px */ - float _hpx; /**< height in px */ + QString _coordinateUnit; /**< coordinate unit, will be saved in exported + file */ + float _x; /**< x-coordinate in coordinate unit*/ + float _y; /**< y-coordinate in coordinate unit*/ + float _w; /**< width in coordinate unit*/ + float _h; /**< height in coordinate unit*/ + float _rad; /**< orientation in rad */ + float _deg; /**< orientation in deg */ + float _xpx; /**< x-coordinate in px */ + float _ypx; /**< y-coordinate in px */ + float _wpx; /**< width in px */ + float _hpx; /**< height in px */ }; -/***************************************************************************//** -* This is a node of the Composite Pattern -* This class is derived from IModelComponentEuclidian2D. -* It expands it from 2D to 3D. -* Reserved for future 3D tracking. -*******************************************************************************/ -class BT_INTERFACES_API IModelComponentEuclidian3D : public IModelComponentEuclidian2D { +/***************************************************************************/ /** + * This is a node of the Composite Pattern + * This class is derived from IModelComponentEuclidian2D. + * It expands it from 2D to 3D. + * Reserved for future 3D tracking. + *******************************************************************************/ +class BT_INTERFACES_API IModelComponentEuclidian3D +: public IModelComponentEuclidian2D +{ public: - Q_OBJECT - /* - Q_PROPERTY-System: http://doc.qt.io/qt-5/properties.html - */ - Q_PROPERTY(float z READ getZ() WRITE setZ STORED hasZ) - Q_PROPERTY(float zpx READ getZpx() WRITE setZpx STORED hasZpx) - Q_PROPERTY(float d READ getD() WRITE setD STORED hasD) - Q_PROPERTY(float dpx READ getDpx() WRITE setDpx STORED hasDpx) - Q_PROPERTY(float rada2 READ getRadAxis2() WRITE setRadAxis2 STORED hasRadAxis2) - Q_PROPERTY(float rada3 READ getRadAxis3() WRITE setRadAxis3 STORED hasRadAxis3) + Q_OBJECT + /* + Q_PROPERTY-System: http://doc.qt.io/qt-5/properties.html + */ + Q_PROPERTY(float z READ getZ() WRITE setZ STORED hasZ) + Q_PROPERTY(float zpx READ getZpx() WRITE setZpx STORED hasZpx) + Q_PROPERTY(float d READ getD() WRITE setD STORED hasD) + Q_PROPERTY(float dpx READ getDpx() WRITE setDpx STORED hasDpx) + Q_PROPERTY(float rada2 READ getRadAxis2() + WRITE setRadAxis2 STORED hasRadAxis2) + Q_PROPERTY(float rada3 READ getRadAxis3() + WRITE setRadAxis3 STORED hasRadAxis3) public: - /* - Getters, Setters & Checkers - */ - virtual void setZ(float z) = 0; - virtual void setZpx(float z) = 0; - virtual void setD(float h) = 0; - virtual void setDpx(float d) = 0; - virtual void setRadAxis2(float r) = 0; - virtual void setRadAxis3(float r) = 0; - - virtual float getZ() = 0; - virtual float getZpx() = 0; - virtual float getD() = 0; - virtual float getDpx() = 0; + /* + Getters, Setters & Checkers + */ + virtual void setZ(float z) = 0; + virtual void setZpx(float z) = 0; + virtual void setD(float h) = 0; + virtual void setDpx(float d) = 0; + virtual void setRadAxis2(float r) = 0; + virtual void setRadAxis3(float r) = 0; + + virtual float getZ() = 0; + virtual float getZpx() = 0; + virtual float getD() = 0; + virtual float getDpx() = 0; virtual float getRadAxis2() = 0; virtual float getRadAxis3() = 0; - virtual bool hasZ() = 0; - virtual bool hasD() = 0; - virtual bool hasZpx() = 0; - virtual bool hasDpx() = 0; + virtual bool hasZ() = 0; + virtual bool hasD() = 0; + virtual bool hasZpx() = 0; + virtual bool hasDpx() = 0; virtual bool hasRadAxis2() = 0; virtual bool hasRadAxis3() = 0; protected: - float _z; /**< z-coordinate in coordinate unit */ - float _zpx; /**< z-coordinate in px */ - float _d; /**< d in coordinate unit*/ - float _dpx; /**< d in px */ - float _rada2; /**< rotation two */ - float _rada3; /**< rotation three */ + float _z; /**< z-coordinate in coordinate unit */ + float _zpx; /**< z-coordinate in px */ + float _d; /**< d in coordinate unit*/ + float _dpx; /**< d in px */ + float _rada2; /**< rotation two */ + float _rada3; /**< rotation three */ }; -/***************************************************************************//** -* This is a node of the Composite Pattern -* This class is derived from IModelComponentEuclidian2D. -* It expands it to 2D with timestamps. -*******************************************************************************/ -class BT_INTERFACES_API IModelComponentTemporal2D : public IModelComponentEuclidian2D { +/***************************************************************************/ /** + * This is a node of the Composite Pattern + * This class is derived from IModelComponentEuclidian2D. + * It expands it to 2D with timestamps. + *******************************************************************************/ +class BT_INTERFACES_API IModelComponentTemporal2D +: public IModelComponentEuclidian2D +{ public: - Q_OBJECT - /* - Q_PROPERTY-System: http://doc.qt.io/qt-5/properties.html - */ + Q_OBJECT + /* + Q_PROPERTY-System: http://doc.qt.io/qt-5/properties.html + */ Q_PROPERTY(qint64 time READ getTime() WRITE setTime STORED hasTime) - Q_PROPERTY(QString timeString READ getTimeString() WRITE setTimeString STORED hasTimeString) + Q_PROPERTY(QString timeString READ getTimeString() + WRITE setTimeString STORED hasTimeString) public: - /** - * The constructor of the IModelComponentTemporal2D class is able to receive a QObject as parent. - * It should not be implemented as it is a not a leaf nore a composite - */ - IModelComponentTemporal2D(QObject *parent = 0); - - /* - Getters, Setters & Checkers - */ - virtual void setTime(qint64 t) = 0; - virtual qint64 getTime() = 0; - virtual bool hasTime() = 0; - virtual void setTimeString(QString t) = 0; - virtual QString getTimeString() = 0; - virtual bool hasTimeString() = 0; - + /** + * The constructor of the IModelComponentTemporal2D class is able to + * receive a QObject as parent. It should not be implemented as it is a not + * a leaf nore a composite + */ + IModelComponentTemporal2D(QObject* parent = 0); + + /* + Getters, Setters & Checkers + */ + virtual void setTime(qint64 t) = 0; + virtual qint64 getTime() = 0; + virtual bool hasTime() = 0; + virtual void setTimeString(QString t) = 0; + virtual QString getTimeString() = 0; + virtual bool hasTimeString() = 0; }; -/***************************************************************************//** -* This is a leaf of the Composite Pattern -* This class is derived from IModelComponentTemporal2D. -* It includes 2D and time data. -* This interface can be visualized in the core application if the tracking data implements it. -* A circular point will be visualized with the radius of min(width,height) -* The position is the center of the point. -*******************************************************************************/ +/***************************************************************************/ /** + * This is a leaf of the Composite Pattern + * This class is derived from IModelComponentTemporal2D. + * It includes 2D and time data. + * This interface can be visualized in the core application if the tracking data implements it. + * A circular point will be visualized with the radius of min(width,height) + * The position is the center of the point. + *******************************************************************************/ class BT_INTERFACES_API IModelTrackedPoint : public IModelComponentTemporal2D { - Q_OBJECT + Q_OBJECT public: - /** - * The constructor of the IModelTrackedPoint class is able to receive a QObject as parent. - */ - IModelTrackedPoint(QObject *parent = 0); + /** + * The constructor of the IModelTrackedPoint class is able to receive a + * QObject as parent. + */ + IModelTrackedPoint(QObject* parent = 0); }; -/***************************************************************************//** -* This is a leaf of the Composite Pattern -* This class is derived from IModelComponentTemporal2D. -* It includes 2D and time data and a polygon. -* This interface can be visualized in the core application if the tracking data implements it. -* An irregular polygon defined by a list of polygons will be visualized. -*******************************************************************************/ +/***************************************************************************/ /** + * This is a leaf of the Composite Pattern + * This class is derived from IModelComponentTemporal2D. + * It includes 2D and time data and a polygon. + * This interface can be visualized in the core application if the tracking data implements it. + * An irregular polygon defined by a list of polygons will be visualized. + *******************************************************************************/ class BT_INTERFACES_API IModelTrackedPolygon : public IModelComponentTemporal2D { - Q_OBJECT + Q_OBJECT public: - - /** - * The constructor of the IModelTrackedPolygon class is able to receive a QObject as parent. - */ - IModelTrackedPolygon(QObject *parent = 0); - - /* - Getters, Setters & Checkers - */ - virtual void setPolygon(QList polygons) = 0; - virtual QList getPolygon() = 0; - virtual float hasPolygon() = 0; + /** + * The constructor of the IModelTrackedPolygon class is able to receive a + * QObject as parent. + */ + IModelTrackedPolygon(QObject* parent = 0); + + /* + Getters, Setters & Checkers + */ + virtual void setPolygon(QList polygons) = 0; + virtual QList getPolygon() = 0; + virtual float hasPolygon() = 0; protected: - QList _polygon; /**< List of polygons, all will be drawn when vizualized */ + QList + _polygon; /**< List of polygons, all will be drawn when vizualized */ }; -/***************************************************************************//** -* This is a leaf of the Composite Pattern -* This class is derived from IModelComponentTemporal2D. -* It includes 2D and time data. -* This interface can be visualized in the core application if the tracking data implements it. -* An ellipse will be visualized. The position is the center of the ellipse. -*******************************************************************************/ +/***************************************************************************/ /** + * This is a leaf of the Composite Pattern + * This class is derived from IModelComponentTemporal2D. + * It includes 2D and time data. + * This interface can be visualized in the core application if the tracking data implements it. + * An ellipse will be visualized. The position is the center of the ellipse. + *******************************************************************************/ class BT_INTERFACES_API IModelTrackedEllipse : public IModelTrackedPoint { - Q_OBJECT + Q_OBJECT public: - /** - * The constructor of the IModelTrackedEllipse class is able to receive a QObject as parent. - */ - IModelTrackedEllipse(QObject *parent = 0); - + /** + * The constructor of the IModelTrackedEllipse class is able to receive a + * QObject as parent. + */ + IModelTrackedEllipse(QObject* parent = 0); }; -/***************************************************************************//** -* This is a leaf of the Composite Pattern -* This class is derived from IModelComponentTemporal2D. -* It includes 2D and time data. -* This interface can be visualized in the core application if the tracking data implements it. -* A rectangle will be visualized. The position is the center of the rectangle. -*******************************************************************************/ +/***************************************************************************/ /** + * This is a leaf of the Composite Pattern + * This class is derived from IModelComponentTemporal2D. + * It includes 2D and time data. + * This interface can be visualized in the core application if the tracking data implements it. + * A rectangle will be visualized. The position is the center of the rectangle. + *******************************************************************************/ class BT_INTERFACES_API IModelTrackedRectangle : public IModelTrackedPoint { - Q_OBJECT - + Q_OBJECT + public: - /** - * The constructor of the IModelTrackedRectangle class is able to receive a QObject as parent. - */ - IModelTrackedRectangle(QObject *parent = 0); + /** + * The constructor of the IModelTrackedRectangle class is able to receive a + * QObject as parent. + */ + IModelTrackedRectangle(QObject* parent = 0); }; - -#endif // ITRACKEDCOMPONENT_H diff --git a/Src/Interfaces/IModel/IModelTrackedComponentFactory.cpp b/Src/Interfaces/IModel/IModelTrackedComponentFactory.cpp index 454ef19..9b207f5 100644 --- a/Src/Interfaces/IModel/IModelTrackedComponentFactory.cpp +++ b/Src/Interfaces/IModel/IModelTrackedComponentFactory.cpp @@ -1,25 +1,27 @@ #include "IModelTrackedComponentFactory.h" -IModelTrackedComponentFactory::IModelTrackedComponentFactory() { - +IModelTrackedComponentFactory::IModelTrackedComponentFactory() +{ } IModelTrackedComponentFactory::~IModelTrackedComponentFactory() { - } -IModelTrackedComponent *IModelTrackedComponentFactory::getNewTrackedElement(QString name) +IModelTrackedComponent* IModelTrackedComponentFactory::getNewTrackedElement( + QString name) { return createTrackedElement(name); } -IModelTrackedComponent *IModelTrackedComponentFactory::getNewTrackedObject(QString name) +IModelTrackedComponent* IModelTrackedComponentFactory::getNewTrackedObject( + QString name) { return createTrackedObject(name); } -IModelTrackedComponent *IModelTrackedComponentFactory::getNewTrackedTrajectory(QString name) +IModelTrackedComponent* IModelTrackedComponentFactory::getNewTrackedTrajectory( + QString name) { - return createTrackedTrajectory(name); + return createTrackedTrajectory(name); } diff --git a/Src/Interfaces/IModel/IModelTrackedComponentFactory.h b/Src/Interfaces/IModel/IModelTrackedComponentFactory.h index 0df758c..9ee77fb 100644 --- a/Src/Interfaces/IModel/IModelTrackedComponentFactory.h +++ b/Src/Interfaces/IModel/IModelTrackedComponentFactory.h @@ -1,5 +1,4 @@ -#ifndef ITRACKEDCOMPONENTFACTORY_H -#define ITRACKEDCOMPONENTFACTORY_H +#pragma once #include "IModel.h" #include "IModelTrackedComponent.h" @@ -8,20 +7,17 @@ class BT_INTERFACES_API IModelTrackedComponentFactory : public IModel { Q_OBJECT - public: +public: IModelTrackedComponentFactory(); virtual ~IModelTrackedComponentFactory() = 0; - IModelTrackedComponent *getNewTrackedElement(QString name); - IModelTrackedComponent *getNewTrackedObject(QString name); - IModelTrackedComponent *getNewTrackedTrajectory(QString name); - virtual QList getElementTypes() = 0; + IModelTrackedComponent* getNewTrackedElement(QString name); + IModelTrackedComponent* getNewTrackedObject(QString name); + IModelTrackedComponent* getNewTrackedTrajectory(QString name); + virtual QList getElementTypes() = 0; protected: - virtual IModelTrackedComponent *createTrackedElement(QString name) = 0; - virtual IModelTrackedComponent *createTrackedObject(QString name) = 0; - virtual IModelTrackedComponent *createTrackedTrajectory(QString name) = 0; - + virtual IModelTrackedComponent* createTrackedElement(QString name) = 0; + virtual IModelTrackedComponent* createTrackedObject(QString name) = 0; + virtual IModelTrackedComponent* createTrackedTrajectory(QString name) = 0; }; - -#endif // ITRACKEDCOMPONENTFACTORY_H diff --git a/Src/Interfaces/IModel/IModelTrackedTrajectory.cpp b/Src/Interfaces/IModel/IModelTrackedTrajectory.cpp index bc869f6..57336ca 100644 --- a/Src/Interfaces/IModel/IModelTrackedTrajectory.cpp +++ b/Src/Interfaces/IModel/IModelTrackedTrajectory.cpp @@ -3,14 +3,13 @@ int IModelTrackedTrajectory::nextID = -1; -IModelTrackedTrajectory::IModelTrackedTrajectory(QObject *parent) : - IModelTrackedComponent(parent) +IModelTrackedTrajectory::IModelTrackedTrajectory(QObject* parent) +: IModelTrackedComponent(parent) { - _id = ++nextID; + _id = ++nextID; } void IModelTrackedTrajectory::operate() { - // please implement this method in an TrackedObject class - + // please implement this method in an TrackedObject class } diff --git a/Src/Interfaces/IModel/IModelTrackedTrajectory.h b/Src/Interfaces/IModel/IModelTrackedTrajectory.h index 78ebd9b..8050221 100644 --- a/Src/Interfaces/IModel/IModelTrackedTrajectory.h +++ b/Src/Interfaces/IModel/IModelTrackedTrajectory.h @@ -1,76 +1,85 @@ -#ifndef ITRACKEDOTRAJECTORY_H -#define ITRACKEDOTRAJECTORY_H +#pragma once #include "Interfaces/IModel/IModelTrackedComponent.h" /** * This interface class derives from IModelTrackedComponent. - * This class is part of the Composite Pattern and represents the the abstract Composite class. - * Its purpose is to define the responsibility - * for adding, deleting and returning leaf objects. + * This class is part of the Composite Pattern and represents the the abstract + * Composite class. Its purpose is to define the responsibility for adding, + * deleting and returning leaf objects. * * - * Its the Plugin Developers full responsibility to choos an internal data structure. This could be e.g. Map, List or Vector. + * Its the Plugin Developers full responsibility to choos an internal data + * structure. This could be e.g. Map, List or Vector. */ class BT_INTERFACES_API IModelTrackedTrajectory : public IModelTrackedComponent { Q_OBJECT - Q_PROPERTY(QList childNodes READ getChildNodes() WRITE setChildNodes STORED hasChildNodes); -public: - /** - * The constructor. - */ - IModelTrackedTrajectory(QObject *parent); - - /** - * This methode must be implemented by all derivatives. Its purpose is to provide a mechanism for adding Leaf components to this structure. - */ - virtual void add(IModelTrackedComponent *comp, int pos) = 0; - - /** - * This methode must be implemented by all derivatives. Its functionality shall be a mechanism for removing Leaf components from this structure. - */ - virtual bool remove(IModelTrackedComponent *comp) = 0; - - /** - * This methode must be implemented by all derivatives. Its functionality shall be a mechanism for removing all Leaf components from this structure. - */ - virtual void clear() = 0; - - /** - * This methode must be implemented by all derivatives. Its functionality shall be a mechanism for determining the count/number of children. - */ - virtual int size() = 0; + Q_PROPERTY(QList childNodes READ getChildNodes() + WRITE setChildNodes STORED hasChildNodes); - /** - * This should simply return a child object by an index. - */ - virtual IModelTrackedComponent* getChild(int index) = 0; +public: + /** + * The constructor. + */ + IModelTrackedTrajectory(QObject* parent); + + /** + * This methode must be implemented by all derivatives. Its purpose is to + * provide a mechanism for adding Leaf components to this structure. + */ + virtual void add(IModelTrackedComponent* comp, int pos) = 0; + + /** + * This methode must be implemented by all derivatives. Its functionality + * shall be a mechanism for removing Leaf components from this structure. + */ + virtual bool remove(IModelTrackedComponent* comp) = 0; + + /** + * This methode must be implemented by all derivatives. Its functionality + * shall be a mechanism for removing all Leaf components from this + * structure. + */ + virtual void clear() = 0; + + /** + * This methode must be implemented by all derivatives. Its functionality + * shall be a mechanism for determining the count/number of children. + */ + virtual int size() = 0; + + /** + * This should simply return a child object by an index. + */ + virtual IModelTrackedComponent* getChild(int index) = 0; virtual IModelTrackedComponent* getValidChild(int index) = 0; - virtual int validCount() = 0; - + virtual int validCount() = 0; - /** - * This shoudd simply return a last child object (highest index). - */ - virtual IModelTrackedComponent *getLastChild() = 0; + /** + * This shoudd simply return a last child object (highest index). + */ + virtual IModelTrackedComponent* getLastChild() = 0; - virtual void setTime(std::chrono::system_clock::time_point t) { _time = t; }; - virtual std::chrono::system_clock::time_point getTime() { return _time; }; + virtual void setTime(std::chrono::system_clock::time_point t) + { + _time = t; + }; + virtual std::chrono::system_clock::time_point getTime() + { + return _time; + }; - virtual QList getChildNodes() = 0; + virtual QList getChildNodes() = 0; virtual void setChildNodes(QList n) = 0; - virtual bool hasChildNodes() = 0; + virtual bool hasChildNodes() = 0; public: - virtual void operate(); + virtual void operate(); protected: - static int nextID; - std::chrono::system_clock::time_point _time; - + static int nextID; + std::chrono::system_clock::time_point _time; }; - -#endif // ITRACKEDOTRAJECTORY_H diff --git a/Src/Interfaces/IModel/IModelTrackingAlgorithm.cpp b/Src/Interfaces/IModel/IModelTrackingAlgorithm.cpp index cdf89f6..c37c307 100644 --- a/Src/Interfaces/IModel/IModelTrackingAlgorithm.cpp +++ b/Src/Interfaces/IModel/IModelTrackingAlgorithm.cpp @@ -1,27 +1,28 @@ #include "IModelTrackingAlgorithm.h" -IModelTrackingAlgorithm::IModelTrackingAlgorithm(QObject *parent) : - IModel(parent) +IModelTrackingAlgorithm::IModelTrackingAlgorithm(QObject* parent) +: IModel(parent) { - } -//void ITrackingAlgorithm::setTrackedComponentFactory(ITrackedComponentFactory *factory) +// void ITrackingAlgorithm::setTrackedComponentFactory(ITrackedComponentFactory +// *factory) //{ // m_TrackedComponentFactory = factory; //} -//void ITrackingAlgorithm::setTrackedComponent(ITrackedComponent *trackedComponent) +// void ITrackingAlgorithm::setTrackedComponent(ITrackedComponent +// *trackedComponent) //{ // m_TrackedComponent = trackedComponent; //} -//ITrackedComponentFactory *ITrackingAlgorithm::getTrackedComponentFactory() +// ITrackedComponentFactory *ITrackingAlgorithm::getTrackedComponentFactory() //{ // return m_TrackedComponentFactory; //} -//ITrackedComponent *ITrackingAlgorithm::getTrackedComponent() +// ITrackedComponent *ITrackingAlgorithm::getTrackedComponent() //{ // return m_TrackedComponent; //} diff --git a/Src/Interfaces/IModel/IModelTrackingAlgorithm.h b/Src/Interfaces/IModel/IModelTrackingAlgorithm.h index 1841eb8..0223a7c 100644 --- a/Src/Interfaces/IModel/IModelTrackingAlgorithm.h +++ b/Src/Interfaces/IModel/IModelTrackingAlgorithm.h @@ -1,21 +1,16 @@ -#ifndef ITRACKINGALGORITHM_H -#define ITRACKINGALGORITHM_H +#pragma once #include "IModel.h" #include "opencv2/core/core.hpp" -class BT_INTERFACES_API IModelTrackingAlgorithm :public IModel { +class BT_INTERFACES_API IModelTrackingAlgorithm : public IModel +{ Q_OBJECT - public: - IModelTrackingAlgorithm(QObject *parent = 0); +public: + IModelTrackingAlgorithm(QObject* parent = 0); - virtual void doTracking(std::shared_ptr image, uint frameNumber) = 0; + virtual void doTracking(cv::Mat image, uint frameNumber) = 0; signals: void emitTrackingDone(); - void emitChangeDisplayImage(QString str); - - }; - -#endif // ITRACKINGALGORITHM_H diff --git a/Src/Interfaces/IModel/IObject.cpp b/Src/Interfaces/IModel/IObject.cpp index 9f33949..416688b 100644 --- a/Src/Interfaces/IModel/IObject.cpp +++ b/Src/Interfaces/IModel/IObject.cpp @@ -1,6 +1,6 @@ #include "IObject.h" -IObject::IObject() : - IModel(0) { - +IObject::IObject() +: IModel(0) +{ } diff --git a/Src/Interfaces/IModel/IObject.h b/Src/Interfaces/IModel/IObject.h index 0a7d9dc..914b605 100644 --- a/Src/Interfaces/IModel/IObject.h +++ b/Src/Interfaces/IModel/IObject.h @@ -1,14 +1,12 @@ -#ifndef IOBJECT_H -#define IOBJECT_H +#pragma once #include "Interfaces/IModel/IModel.h" // #include "biotracker/util/platform.h" -class BT_INTERFACES_API IObject : public IModel { +class BT_INTERFACES_API IObject : public IModel +{ Q_OBJECT - public: +public: IObject(); }; - -#endif // IOBJECT_H diff --git a/Src/Interfaces/IModel/Serializable.cpp b/Src/Interfaces/IModel/Serializable.cpp index 96c86e5..6d92e2d 100644 --- a/Src/Interfaces/IModel/Serializable.cpp +++ b/Src/Interfaces/IModel/Serializable.cpp @@ -3,26 +3,23 @@ #include #include - -QDataStream &operator<<(QDataStream &ds, const Serializable &data) { - for (int i = 0; ipropertyCount(); ++i) - { - if (data.metaObject()->property(i).isStored(&data)) - { - ds << data.metaObject()->property(i).read(&data); - } - } - return ds; +QDataStream& operator<<(QDataStream& ds, const Serializable& data) +{ + for (int i = 0; i < data.metaObject()->propertyCount(); ++i) { + if (data.metaObject()->property(i).isStored(&data)) { + ds << data.metaObject()->property(i).read(&data); + } + } + return ds; } -QDataStream &operator>>(QDataStream &ds, Serializable &data) { - QVariant var; - for (int i = 0; ipropertyCount(); ++i) - { - if (data.metaObject()->property(i).isStored(&data)) - { - ds >> var; - data.metaObject()->property(i).write(&data, var); - } - } - return ds; +QDataStream& operator>>(QDataStream& ds, Serializable& data) +{ + QVariant var; + for (int i = 0; i < data.metaObject()->propertyCount(); ++i) { + if (data.metaObject()->property(i).isStored(&data)) { + ds >> var; + data.metaObject()->property(i).write(&data, var); + } + } + return ds; } \ No newline at end of file diff --git a/Src/Interfaces/IModel/Serializable.h b/Src/Interfaces/IModel/Serializable.h index 50f629a..5a97516 100644 --- a/Src/Interfaces/IModel/Serializable.h +++ b/Src/Interfaces/IModel/Serializable.h @@ -8,8 +8,8 @@ class BT_INTERFACES_API Serializable : public IModel { - Q_OBJECT + Q_OBJECT }; -QDataStream &operator<<(QDataStream &out, const Serializable &data); -QDataStream &operator>>(QDataStream &in, Serializable &data); +QDataStream& operator<<(QDataStream& out, const Serializable& data); +QDataStream& operator>>(QDataStream& in, Serializable& data); diff --git a/Src/Interfaces/IView/IView.cpp b/Src/Interfaces/IView/IView.cpp index 5743123..6c95ef3 100644 --- a/Src/Interfaces/IView/IView.cpp +++ b/Src/Interfaces/IView/IView.cpp @@ -1,37 +1,41 @@ #include "IView.h" #include "Interfaces/IController/IController.h" -IView::IView(IController *controller, IModel *model): - mController(controller), - mModel(model) +IView::IView(IController* controller, IModel* model) +: mController(controller) +, mModel(model) { - } -void IView::setModel(IModel *model) { +void IView::setModel(IModel* model) +{ mModel = model; } -IView::~IView() { - +IView::~IView() +{ } -IController *IView::getController() { +IController* IView::getController() +{ return mController; } -IModel *IView::getModel() { +IModel* IView::getModel() +{ return mModel; } -const IController *IView::getController() const { - return mController; +const IController* IView::getController() const +{ + return mController; } -const IModel *IView::getModel() const { - return mModel; +const IModel* IView::getModel() const +{ + return mModel; } -void IView::setPermission(std::pair) { - +void IView::setPermission(std::pair) +{ } diff --git a/Src/Interfaces/IView/IView.h b/Src/Interfaces/IView/IView.h index 5897b69..b8fab01 100644 --- a/Src/Interfaces/IView/IView.h +++ b/Src/Interfaces/IView/IView.h @@ -1,29 +1,28 @@ -#ifndef IVIEW_H -#define IVIEW_H +#pragma once #include "Interfaces/IModel/IModel.h" #include "Interfaces/ENUMS.h" #include class IController; -class BT_INTERFACES_API IView { +class BT_INTERFACES_API IView +{ - public: - IView(IController *controller = 0, IModel *model = 0); +public: + IView(IController* controller = 0, IModel* model = 0); virtual ~IView() = 0; - virtual void setNewModel(IModel *model) = 0; - void setPermission(std::pair < ENUMS::COREPERMISSIONS, bool >); + virtual void setNewModel(IModel* model) = 0; + void setPermission(std::pair); - protected: - virtual void connectModelView() = 0; - void setModel(IModel *model); - IController *getController(); - const IController *getController() const; - IModel *getModel(); - const IModel *getModel() const; - private: - IController *mController; - IModel *mModel; -}; +protected: + virtual void connectModelView() = 0; + void setModel(IModel* model); + IController* getController(); + const IController* getController() const; + IModel* getModel(); + const IModel* getModel() const; -#endif // IVIEW_H +private: + IController* mController; + IModel* mModel; +}; diff --git a/Src/Interfaces/IView/IViewGraphicsPixmapItem.cpp b/Src/Interfaces/IView/IViewGraphicsPixmapItem.cpp index 372da22..70549bc 100644 --- a/Src/Interfaces/IView/IViewGraphicsPixmapItem.cpp +++ b/Src/Interfaces/IView/IViewGraphicsPixmapItem.cpp @@ -1,13 +1,14 @@ #include "IViewGraphicsPixmapItem.h" -IViewGraphicsPixmapItem::IViewGraphicsPixmapItem(QObject *parent, IController *controller, IModel *model) : - QObject(parent), - IView(controller, model) +IViewGraphicsPixmapItem::IViewGraphicsPixmapItem(QObject* parent, + IController* controller, + IModel* model) +: QObject(parent) +, IView(controller, model) { - } -void IViewGraphicsPixmapItem::setNewModel(IModel *model) +void IViewGraphicsPixmapItem::setNewModel(IModel* model) { if (getModel() != nullptr) { QObject::disconnect(getModel(), 0, this, 0); @@ -21,4 +22,3 @@ void IViewGraphicsPixmapItem::setNewModel(IModel *model) update(); } - diff --git a/Src/Interfaces/IView/IViewGraphicsPixmapItem.h b/Src/Interfaces/IView/IViewGraphicsPixmapItem.h index 5302abc..2d25246 100644 --- a/Src/Interfaces/IView/IViewGraphicsPixmapItem.h +++ b/Src/Interfaces/IView/IViewGraphicsPixmapItem.h @@ -1,22 +1,23 @@ -#ifndef IGRAPHICSPIXMAPITEM_H -#define IGRAPHICSPIXMAPITEM_H +#pragma once #include "IView.h" #include "QObject" #include "QGraphicsPixmapItem" -class BT_INTERFACES_API IViewGraphicsPixmapItem : public QObject, public QGraphicsPixmapItem, public IView +class BT_INTERFACES_API IViewGraphicsPixmapItem : public QObject, + public QGraphicsPixmapItem, + public IView { Q_OBJECT public: - IViewGraphicsPixmapItem(QObject *parent = 0, IController *controller = 0, IModel *model = 0); + IViewGraphicsPixmapItem(QObject* parent = 0, + IController* controller = 0, + IModel* model = 0); // IView interface public: - void setNewModel(IModel *model) override; + void setNewModel(IModel* model) override; public Q_SLOTS: - virtual void getNotified() = 0; + virtual void getNotified() = 0; }; - -#endif // IGRAPHICSPIXMAPITEM_H diff --git a/Src/Interfaces/IView/IViewGraphicsScene.cpp b/Src/Interfaces/IView/IViewGraphicsScene.cpp index c1bf252..3cc70b6 100644 --- a/Src/Interfaces/IView/IViewGraphicsScene.cpp +++ b/Src/Interfaces/IView/IViewGraphicsScene.cpp @@ -1,18 +1,21 @@ #include "IViewGraphicsScene.h" -IViewGraphicsScene::IViewGraphicsScene(QObject *parent, IController *controller, IModel *model) : - QGraphicsScene(parent), - IView(controller, model) +IViewGraphicsScene::IViewGraphicsScene(QObject* parent, + IController* controller, + IModel* model) +: QGraphicsScene(parent) +, IView(controller, model) { - } -void IViewGraphicsScene::setNewModel(IModel *model) +void IViewGraphicsScene::setNewModel(IModel* model) { - } void IViewGraphicsScene::connectModelView() { - QObject::connect(getModel(), &IModel::notifyView, this, &IViewGraphicsScene::getNotified); + QObject::connect(getModel(), + &IModel::notifyView, + this, + &IViewGraphicsScene::getNotified); } diff --git a/Src/Interfaces/IView/IViewGraphicsScene.h b/Src/Interfaces/IView/IViewGraphicsScene.h index 0ed22f4..4d18b3d 100644 --- a/Src/Interfaces/IView/IViewGraphicsScene.h +++ b/Src/Interfaces/IView/IViewGraphicsScene.h @@ -1,24 +1,24 @@ -#ifndef IVIEWGRAPHICSSCENE_H -#define IVIEWGRAPHICSSCENE_H +#pragma once #include "QGraphicsScene" #include "IView.h" -class BT_INTERFACES_API IViewGraphicsScene : public QGraphicsScene, public IView +class BT_INTERFACES_API IViewGraphicsScene : public QGraphicsScene, + public IView { Q_OBJECT public: - IViewGraphicsScene(QObject *parent = 0, IController *controller = 0, IModel *model = 0); + IViewGraphicsScene(QObject* parent = 0, + IController* controller = 0, + IModel* model = 0); // IView interface public: - virtual void setNewModel(IModel *model) override; + virtual void setNewModel(IModel* model) override; protected: virtual void connectModelView() override; public Q_SLOTS: - virtual void getNotified() = 0; + virtual void getNotified() = 0; }; - -#endif // IVIEWGRAPHICSSCENE_H diff --git a/Src/Interfaces/IView/IViewGraphicsView.cpp b/Src/Interfaces/IView/IViewGraphicsView.cpp index 1efd240..b9e2808 100644 --- a/Src/Interfaces/IView/IViewGraphicsView.cpp +++ b/Src/Interfaces/IView/IViewGraphicsView.cpp @@ -1,19 +1,21 @@ #include "IViewGraphicsView.h" - -IViewGraphicsView::IViewGraphicsView(QWidget *parent, IController *controller, IModel *model) : - QGraphicsView(parent), - IView(controller, model) +IViewGraphicsView::IViewGraphicsView(QWidget* parent, + IController* controller, + IModel* model) +: QGraphicsView(parent) +, IView(controller, model) { - } -void IViewGraphicsView::setNewModel(IModel *model) +void IViewGraphicsView::setNewModel(IModel* model) { - } void IViewGraphicsView::connectModelView() { - QObject::connect(getModel(), &IModel::notifyView, this, &IViewGraphicsView::getNotified); + QObject::connect(getModel(), + &IModel::notifyView, + this, + &IViewGraphicsView::getNotified); } diff --git a/Src/Interfaces/IView/IViewGraphicsView.h b/Src/Interfaces/IView/IViewGraphicsView.h index 05be9e5..40d7040 100644 --- a/Src/Interfaces/IView/IViewGraphicsView.h +++ b/Src/Interfaces/IView/IViewGraphicsView.h @@ -1,5 +1,4 @@ -#ifndef IGRAPHICSVIEW_H -#define IGRAPHICSVIEW_H +#pragma once #include "QGraphicsView" #include "IView.h" @@ -8,17 +7,17 @@ class BT_INTERFACES_API IViewGraphicsView : public QGraphicsView, public IView { Q_OBJECT public: - IViewGraphicsView(QWidget *parent = 0, IController *controller = 0, IModel *model = 0); + IViewGraphicsView(QWidget* parent = 0, + IController* controller = 0, + IModel* model = 0); // IView interface public: - void setNewModel(IModel *model) override; + void setNewModel(IModel* model) override; protected: void connectModelView() override; public Q_SLOTS: - virtual void getNotified() = 0; + virtual void getNotified() = 0; }; - -#endif // IGRAPHICSVIEW_H diff --git a/Src/Interfaces/IView/IViewMainWindow.cpp b/Src/Interfaces/IView/IViewMainWindow.cpp index cea4f77..3c390ed 100644 --- a/Src/Interfaces/IView/IViewMainWindow.cpp +++ b/Src/Interfaces/IView/IViewMainWindow.cpp @@ -1,20 +1,24 @@ #include "IViewMainWindow.h" -IViewMainWindow::IViewMainWindow(QWidget *parent, IController *controller, IModel *model) : - QMainWindow(parent), - IView(controller, model) { - +IViewMainWindow::IViewMainWindow(QWidget* parent, + IController* controller, + IModel* model) +: QMainWindow(parent) +, IView(controller, model) +{ } -IViewMainWindow::~IViewMainWindow() { - +IViewMainWindow::~IViewMainWindow() +{ } -void IViewMainWindow::setNewModel(IModel *model) { +void IViewMainWindow::setNewModel(IModel* model) +{ model = nullptr; setModel(model); } -void IViewMainWindow::connectModelView() { +void IViewMainWindow::connectModelView() +{ // this function is not used in MainWindow } diff --git a/Src/Interfaces/IView/IViewMainWindow.h b/Src/Interfaces/IView/IViewMainWindow.h index 8c0fdb5..5e8a9c9 100644 --- a/Src/Interfaces/IView/IViewMainWindow.h +++ b/Src/Interfaces/IView/IViewMainWindow.h @@ -1,17 +1,17 @@ -#ifndef IVIEWMAINWINDOW_H -#define IVIEWMAINWINDOW_H +#pragma once #include #include "Interfaces/IView/IView.h" -class BT_INTERFACES_API IViewMainWindow : public QMainWindow, public IView { - public: - IViewMainWindow(QWidget *parent = 0, IController *controller = 0, IModel *model = 0); +class BT_INTERFACES_API IViewMainWindow : public QMainWindow, public IView +{ +public: + IViewMainWindow(QWidget* parent = 0, + IController* controller = 0, + IModel* model = 0); ~IViewMainWindow(); - private: - void setNewModel(IModel *model); +private: + void setNewModel(IModel* model); void connectModelView(); }; - -#endif // IVIEWMAINWINDOW_H diff --git a/Src/Interfaces/IView/IViewOpenGLWidget.cpp b/Src/Interfaces/IView/IViewOpenGLWidget.cpp index 2b799f3..1322d22 100644 --- a/Src/Interfaces/IView/IViewOpenGLWidget.cpp +++ b/Src/Interfaces/IView/IViewOpenGLWidget.cpp @@ -1,16 +1,20 @@ #include "IViewOpenGLWidget.h" -IViewOpenGLWidget::IViewOpenGLWidget(QWidget *parent, IController *controller, IModel *model) : - QOpenGLWidget(parent), - IView(controller) { +IViewOpenGLWidget::IViewOpenGLWidget(QWidget* parent, + IController* controller, + IModel* model) +: QOpenGLWidget(parent) +, IView(controller) +{ setNewModel(model); } -IViewOpenGLWidget::~IViewOpenGLWidget() { - +IViewOpenGLWidget::~IViewOpenGLWidget() +{ } -void IViewOpenGLWidget::setNewModel(IModel *model) { +void IViewOpenGLWidget::setNewModel(IModel* model) +{ if (getModel() != nullptr) { QObject::disconnect(getModel(), 0, this, 0); } @@ -24,10 +28,15 @@ void IViewOpenGLWidget::setNewModel(IModel *model) { update(); } -void IViewOpenGLWidget::connectModelView() { - QObject::connect(getModel(), &IModel::notifyView, this, &IViewOpenGLWidget::getNotified); +void IViewOpenGLWidget::connectModelView() +{ + QObject::connect(getModel(), + &IModel::notifyView, + this, + &IViewOpenGLWidget::getNotified); } -void IViewOpenGLWidget::initializeGL() { +void IViewOpenGLWidget::initializeGL() +{ connectModelView(); } diff --git a/Src/Interfaces/IView/IViewOpenGLWidget.h b/Src/Interfaces/IView/IViewOpenGLWidget.h index f2f66f5..07db9df 100644 --- a/Src/Interfaces/IView/IViewOpenGLWidget.h +++ b/Src/Interfaces/IView/IViewOpenGLWidget.h @@ -1,25 +1,26 @@ -#ifndef IVIEWOPENGLWIDGET_H -#define IVIEWOPENGLWIDGET_H +#pragma once #include "Interfaces/IView/IView.h" #include #include #include - -class BT_INTERFACES_API IViewOpenGLWidget: public QOpenGLWidget, protected QOpenGLFunctions, public IView { - public: - IViewOpenGLWidget(QWidget *parent = 0, IController *controller = 0, IModel *model = 0); +class BT_INTERFACES_API IViewOpenGLWidget : public QOpenGLWidget, + protected QOpenGLFunctions, + public IView +{ +public: + IViewOpenGLWidget(QWidget* parent = 0, + IController* controller = 0, + IModel* model = 0); ~IViewOpenGLWidget(); - void setNewModel(IModel *model); + void setNewModel(IModel* model); - public Q_SLOTS: +public Q_SLOTS: virtual void getNotified() = 0; - protected: +protected: void connectModelView(); void initializeGL() override; }; - -#endif // IVIEWOPENGLWIDGET_H diff --git a/Src/Interfaces/IView/IViewTrackedComponent.cpp b/Src/Interfaces/IView/IViewTrackedComponent.cpp index ec38b2c..ea9d971 100644 --- a/Src/Interfaces/IView/IViewTrackedComponent.cpp +++ b/Src/Interfaces/IView/IViewTrackedComponent.cpp @@ -1,23 +1,25 @@ #include "IViewTrackedComponent.h" -IViewTrackedComponent::IViewTrackedComponent(QGraphicsItem *parent, IController *controller, IModel *model) : - QGraphicsObject(parent), - IView(controller, model) +IViewTrackedComponent::IViewTrackedComponent(QGraphicsItem* parent, + IController* controller, + IModel* model) +: QGraphicsObject(parent) +, IView(controller, model) { - } IViewTrackedComponent::~IViewTrackedComponent() { - } -void IViewTrackedComponent::setNewModel(IModel *model) +void IViewTrackedComponent::setNewModel(IModel* model) { - } void IViewTrackedComponent::connectModelView() { - QObject::connect(getModel(), &IModel::notifyView, this, &IViewTrackedComponent::getNotified); + QObject::connect(getModel(), + &IModel::notifyView, + this, + &IViewTrackedComponent::getNotified); } diff --git a/Src/Interfaces/IView/IViewTrackedComponent.h b/Src/Interfaces/IView/IViewTrackedComponent.h index ff7e0da..29eecec 100644 --- a/Src/Interfaces/IView/IViewTrackedComponent.h +++ b/Src/Interfaces/IView/IViewTrackedComponent.h @@ -1,35 +1,36 @@ -#ifndef IVIEWTRACKEDCOMPONENT_H -#define IVIEWTRACKEDCOMPONENT_H +#pragma once #include "IView.h" #include "QGraphicsObject" /** - * This is the common interface for all views representing a TrackedComponents class (IModelTrackedTrajectory and any leaf class). - * This class is derived from IView from the Model-View-Controller structure and visializes the data from its IModel object. - * A IViewTrackedComponent has a QGraphicsItem. + * This is the common interface for all views representing a TrackedComponents + * class (IModelTrackedTrajectory and any leaf class). This class is derived + * from IView from the Model-View-Controller structure and visializes the data + * from its IModel object. A IViewTrackedComponent has a QGraphicsItem. */ -class BT_INTERFACES_API IViewTrackedComponent : public QGraphicsObject, public IView +class BT_INTERFACES_API IViewTrackedComponent : public QGraphicsObject, + public IView { Q_OBJECT public: /** - * The constructor hase a QGraphicsItem object as Parent, an IController object as its controller and an IModel object. + * The constructor hase a QGraphicsItem object as Parent, an IController + * object as its controller and an IModel object. */ - IViewTrackedComponent(QGraphicsItem *parent = 0, IController *controller = 0, IModel *model = 0); + IViewTrackedComponent(QGraphicsItem* parent = 0, + IController* controller = 0, + IModel* model = 0); ~IViewTrackedComponent(); // IView interface public: - void setNewModel(IModel *model) override; + void setNewModel(IModel* model) override; protected: void connectModelView() override; public Q_SLOTS: - virtual void getNotified() = 0; - + virtual void getNotified() = 0; }; - -#endif // IVIEWTRACKEDCOMPONENT_H diff --git a/Src/Interfaces/IView/IViewWidget.cpp b/Src/Interfaces/IView/IViewWidget.cpp index a0a8150..746d4ea 100644 --- a/Src/Interfaces/IView/IViewWidget.cpp +++ b/Src/Interfaces/IView/IViewWidget.cpp @@ -1,18 +1,26 @@ #include "IViewWidget.h" -IViewWidget::IViewWidget(QWidget *parent, IController *controller, IModel *model): - QWidget(parent), - IView(controller) { +IViewWidget::IViewWidget(QWidget* parent, + IController* controller, + IModel* model) +: QWidget(parent) +, IView(controller) +{ setNewModel(model); } -void IViewWidget::setNewModel(IModel *model) { +void IViewWidget::setNewModel(IModel* model) +{ setModel(model); if (getModel() != nullptr) { connectModelView(); } } -void IViewWidget::connectModelView() { - QObject::connect(getModel(), &IModel::notifyView, this, &IViewWidget::getNotified); +void IViewWidget::connectModelView() +{ + QObject::connect(getModel(), + &IModel::notifyView, + this, + &IViewWidget::getNotified); } diff --git a/Src/Interfaces/IView/IViewWidget.h b/Src/Interfaces/IView/IViewWidget.h index fc97f05..4d68532 100644 --- a/Src/Interfaces/IView/IViewWidget.h +++ b/Src/Interfaces/IView/IViewWidget.h @@ -1,21 +1,21 @@ -#ifndef IVIEWWIDGET_H -#define IVIEWWIDGET_H +#pragma once #include #include "Interfaces/IView/IView.h" -class BT_INTERFACES_API IViewWidget : public QWidget, public IView { +class BT_INTERFACES_API IViewWidget : public QWidget, public IView +{ Q_OBJECT - public: - explicit IViewWidget(QWidget *parent = 0, IController *controller = 0, IModel *model = 0); +public: + explicit IViewWidget(QWidget* parent = 0, + IController* controller = 0, + IModel* model = 0); - void setNewModel(IModel *model); + void setNewModel(IModel* model); - public Q_SLOTS: +public Q_SLOTS: virtual void getNotified() = 0; - private: +private: void connectModelView(); }; - -#endif // IVIEWWIDGET_H diff --git a/ci/compile.py b/ci/compile.py new file mode 100755 index 0000000..bf79192 --- /dev/null +++ b/ci/compile.py @@ -0,0 +1,7 @@ +#! /usr/bin/env python3 + +from subprocess import check_call + +if __name__ == "__main__": + command = ["ninja", "-C", "build"] + check_call(command) diff --git a/ci/configure.py b/ci/configure.py new file mode 100755 index 0000000..062d50e --- /dev/null +++ b/ci/configure.py @@ -0,0 +1,26 @@ +#! /usr/bin/env python3 + +from os import environ as env +from subprocess import check_call + + +def define(key: str, value: str): + return ["-D", f"{key}={value}"] + + +def define_env(name: str): + return define(name, env[name]) if name in env else [] + + +if __name__ == "__main__": + command = ["cmake"] + command += ["-S", "."] + command += ["-B", "build"] + command += ["-G", "Ninja"] + command += define_env("CMAKE_BUILD_TYPE") + command += define_env("CMAKE_TOOLCHAIN_FILE") + command += define("CMAKE_SUPPRESS_REGENERATION", "ON") + command += define("CMAKE_SKIP_PACKAGE_ALL_DEPENDENCY", "ON") + command += define_env("VCPKG_TARGET_TRIPLET") + + check_call(command) diff --git a/ci/package.py b/ci/package.py new file mode 100755 index 0000000..fe4032f --- /dev/null +++ b/ci/package.py @@ -0,0 +1,7 @@ +#! /usr/bin/env python3 + +from subprocess import check_call + +if __name__ == "__main__": + command = ["ninja", "-C", "build", "package"] + check_call(command) diff --git a/cmake/Deploy.cmake b/cmake/Deploy.cmake deleted file mode 100644 index 80b144e..0000000 --- a/cmake/Deploy.cmake +++ /dev/null @@ -1,87 +0,0 @@ -if(WIN32) - function(deploy_shared_lib target directory lib) - set(options TO_BUILD) - cmake_parse_arguments(DEPLOY_SHARED_LIB "${options}" "" "" ${ARGN}) - - message("Searching for ${lib}${CMAKE_SHARED_LIBRARY_SUFFIX}") - execute_process( - COMMAND where.exe "${lib}${CMAKE_SHARED_LIBRARY_SUFFIX}" - OUTPUT_VARIABLE _matches - OUTPUT_STRIP_TRAILING_WHITESPACE - RESULT_VARIABLE _res - ) - if(NOT "${_res}" STREQUAL "0") - message(FATAL_ERROR "Failed to find ${lib}${CMAKE_SHARED_LIBRARY_SUFFIX}") - endif() - string(REGEX REPLACE "\n" ";" _matches "${_matches}") - list(GET _matches 0 _lib) - string(REGEX REPLACE "\\\\" "/" _lib "${_lib}") - - if(DEPLOY_SHARED_LIB_TO_BUILD) - # Deploy into build tree - add_custom_command(TARGET ${target} POST_BUILD - COMMAND "${CMAKE_COMMAND}" -E - copy_if_different "${_lib}" \"$\" - COMMENT "Copying ${_lib} to \"$\"" - ) - endif() - - # Deploy into install tree - install(CODE - " - if(\"${directory}\" STREQUAL \"\") - set(_dest \"\${CMAKE_INSTALL_PREFIX}\") - else() - set(_dest \"\${CMAKE_INSTALL_PREFIX}/${directory}\") - endif() - message(\"Copying ${_lib} to \${_dest}\") - execute_process( - COMMAND \"${CMAKE_COMMAND}\" -E - copy \"${_lib}\" \"\${_dest}/\" - ) - " - ) - endfunction() - - include(${CMAKE_CURRENT_LIST_DIR}/Windeployqt.cmake) - - function(deploy_qt5 target directory) - windeployqt(${target} "${directory}") - endfunction() - - function(deploy_cuda target directory) - set(multiValueArgs COMPONENTS) - cmake_parse_arguments(DEPLOY_CUDA "" "" "${multiValueArgs}" ${ARGN}) - - if(${CMAKE_SIZEOF_VOID_P} EQUAL 8) - set(CUDA_SUFFIX "64_${CUDA_VERSION_MAJOR}${CUDA_VERSION_MINOR}") - else() - set(CUDA_SUFFIX "32_${CUDA_VERSION_MAJOR}${CUDA_VERSION_MINOR}") - endif() - - foreach(component ${DEPLOY_CUDA_COMPONENTS}) - deploy_shared_lib(${target} "${directory}" "${component}${CUDA_SUFFIX}") - endforeach() - endfunction() - - function(deploy_cudnn target directory version) - if(${CMAKE_SIZEOF_VOID_P} EQUAL 8) - set(CUDNN_SUFFIX "64_${version}") - else() - set(CUDNN_SUFFIX "32_${version}") - endif() - - deploy_shared_lib(${target} "${directory}" "cudnn${CUDNN_SUFFIX}") - endfunction() - - function(deploy_opencv target directory) - set(multiValueArgs COMPONENTS) - cmake_parse_arguments(DEPLOY_OPENCV "" "" "${multiValueArgs}" ${ARGN}) - - set(CV_SUFFIX "${OpenCV_VERSION_MAJOR}${OpenCV_VERSION_MINOR}${OpenCV_VERSION_PATCH}") - - foreach(component ${DEPLOY_OPENCV_COMPONENTS}) - deploy_shared_lib(${target} "${directory}" "opencv_${component}${CV_SUFFIX}") - endforeach() - endfunction() -endif() \ No newline at end of file diff --git a/cmake/Headers.cmake b/cmake/Headers.cmake new file mode 100644 index 0000000..5e3dfec --- /dev/null +++ b/cmake/Headers.cmake @@ -0,0 +1,8 @@ +function(install_headers) + cmake_parse_arguments(ARGS "" "DESTINATION" "HEADERS" ${ARGN}) + + foreach(file ${ARGS_HEADERS}) + get_filename_component(install_path ${file} DIRECTORY) + install(FILES ${file} DESTINATION "${ARGS_DESTINATION}/${install_path}") + endforeach() +endfunction() diff --git a/cmake/Windeployqt.cmake b/cmake/Windeployqt.cmake deleted file mode 100644 index dae5bbc..0000000 --- a/cmake/Windeployqt.cmake +++ /dev/null @@ -1,112 +0,0 @@ -# The MIT License (MIT) -# -# Copyright (c) 2017 Nathan Osman -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. - -find_package(Qt5Core REQUIRED) - -# Retrieve the absolute path to qmake and then use that path to find -# the windeployqt binary -get_target_property(_qmake_executable Qt5::qmake IMPORTED_LOCATION) -get_filename_component(_qt_bin_dir "${_qmake_executable}" DIRECTORY) -find_program(WINDEPLOYQT_EXECUTABLE windeployqt HINTS "${_qt_bin_dir}") - -# Running this with MSVC 2015 requires CMake 3.6+ -if((MSVC_VERSION VERSION_EQUAL 1900 OR MSVC_VERSION VERSION_GREATER 1900) - AND CMAKE_VERSION VERSION_LESS "3.6") - message(WARNING "Deploying with MSVC 2015+ requires CMake 3.6+") -endif() - -# Add commands that copy the Qt runtime to the target's output directory after -# build and install the Qt runtime to the specified directory -function(windeployqt target directory) - - # Run windeployqt immediately after build - add_custom_command(TARGET ${target} POST_BUILD - COMMAND "${CMAKE_COMMAND}" -E - env PATH="${_qt_bin_dir}" "${WINDEPLOYQT_EXECUTABLE}" - --verbose 0 - --no-compiler-runtime - --no-angle - --no-opengl-sw - \"$\" - ) - - # install(CODE ...) doesn't support generator expressions, but - # file(GENERATE ...) does - store the path in a file - file(GENERATE OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${target}_path" - CONTENT "$" - ) - - # Before installation, run a series of commands that copy each of the Qt - # runtime files to the appropriate directory for installation - install(CODE - " - file(READ \"${CMAKE_CURRENT_BINARY_DIR}/${target}_path\" _file) - execute_process( - COMMAND \"${CMAKE_COMMAND}\" -E - env PATH=\"${_qt_bin_dir}\" \"${WINDEPLOYQT_EXECUTABLE}\" - --dry-run - --no-compiler-runtime - --no-angle - --no-opengl-sw - --list mapping - \${_file} - OUTPUT_VARIABLE _output - OUTPUT_STRIP_TRAILING_WHITESPACE - ) - separate_arguments(_files WINDOWS_COMMAND \${_output}) - while(_files) - list(GET _files 0 _src) - list(GET _files 1 _dest) - if(\"${directory}\" STREQUAL \"\") - set(_dest \"\${CMAKE_INSTALL_PREFIX}/\${_dest}\") - else() - set(_dest \"\${CMAKE_INSTALL_PREFIX}/${directory}/\${_dest}\") - endif() - message(\"Copying \${_src} to \${_dest}\") - execute_process( - COMMAND \"${CMAKE_COMMAND}\" -E - copy \${_src} \"\${_dest}\" - ) - list(REMOVE_AT _files 0 1) - endwhile() - " - ) - - # windeployqt doesn't work correctly with the system runtime libraries, - # so we fall back to one of CMake's own modules for copying them over - set(CMAKE_INSTALL_UCRT_LIBRARIES TRUE) - if("${directory}" STREQUAL "") - set(CMAKE_INSTALL_SYSTEM_RUNTIME_DESTINATION .) - else() - set(CMAKE_INSTALL_SYSTEM_RUNTIME_DESTINATION "${directory}") - endif() - include(InstallRequiredSystemLibraries) - foreach(lib ${CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS}) - add_custom_command(TARGET ${target} POST_BUILD - COMMAND "${CMAKE_COMMAND}" -E - copy_if_different "${lib}" \"$\" - ) - endforeach() - -endfunction() - -mark_as_advanced(WINDEPLOYQT_EXECUTABLE) diff --git a/cmake/BT_InterfacesConfig.cmake.in b/cmake/biotracker-interfacesConfig.cmake.in similarity index 79% rename from cmake/BT_InterfacesConfig.cmake.in rename to cmake/biotracker-interfacesConfig.cmake.in index d064abd..6e710da 100644 --- a/cmake/BT_InterfacesConfig.cmake.in +++ b/cmake/biotracker-interfacesConfig.cmake.in @@ -2,7 +2,7 @@ find_package(Qt5 REQUIRED COMPONENTS Core Gui Widgets OpenGL) -find_package(OpenCV 3 REQUIRED) +find_package(OpenCV @OpenCV_VERSION_MAJOR@ REQUIRED) include(${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@Targets.cmake)