summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2014-01-03 11:22:06 +0100
committerStanislaw Halik <sthalik@misaki.pl>2014-01-03 11:22:06 +0100
commita3df0c8a8d19655040c7d21812414d7a335def61 (patch)
tree6739401d8e59800731b2faf26e49b8df63664573
parent7307adbc3b8ec2213bc90a91deb1beb9198e7ff2 (diff)
parent519434cd1abb8991635487c6d84bc0d85367fc42 (diff)
Merge branch 'feature/settings-template'
Conflicts: README.md
-rw-r--r--CMakeLists.txt626
-rw-r--r--FTNoIR_Tracker_PT/FTNoIR_PT_Controls.ui214
-rw-r--r--FTNoIR_Tracker_PT/FTNoIR_Tracker_PT.rc61
-rw-r--r--FTNoIR_Tracker_PT/FTNoIR_Tracker_PT_vc10.vcxproj212
-rw-r--r--FTNoIR_Tracker_PT/camera.h12
-rw-r--r--FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp155
-rw-r--r--FTNoIR_Tracker_PT/ftnoir_tracker_pt.h36
-rw-r--r--FTNoIR_Tracker_PT/ftnoir_tracker_pt_dialog.cpp318
-rw-r--r--FTNoIR_Tracker_PT/ftnoir_tracker_pt_dialog.h69
-rw-r--r--FTNoIR_Tracker_PT/ftnoir_tracker_pt_dll.h4
-rw-r--r--FTNoIR_Tracker_PT/ftnoir_tracker_pt_settings.cpp156
-rw-r--r--FTNoIR_Tracker_PT/ftnoir_tracker_pt_settings.h137
-rw-r--r--README.md1
-rw-r--r--bin/settings/default.ini130
-rw-r--r--facetracknoir/curve-config.cpp161
-rw-r--r--facetracknoir/facetracknoir.cpp390
-rw-r--r--facetracknoir/facetracknoir.h38
-rw-r--r--facetracknoir/ftnoir_curves.ui4
-rw-r--r--facetracknoir/ftnoir_keyboardshortcuts.ui53
-rw-r--r--facetracknoir/images/settingsopen16.pngbin686 -> 0 bytes
-rw-r--r--facetracknoir/main-facetracknoir.qrc1
-rw-r--r--facetracknoir/main-settings.hpp56
-rw-r--r--facetracknoir/main.cpp7
-rw-r--r--facetracknoir/options.h317
-rw-r--r--facetracknoir/shortcuts.cpp148
-rw-r--r--facetracknoir/shortcuts.h9
-rw-r--r--facetracknoir/tracker.cpp25
-rw-r--r--facetracknoir/tracker.h51
-rw-r--r--ftnoir_filter_accela/ftnoir_accela_filtercontrols.ui770
-rw-r--r--ftnoir_filter_accela/ftnoir_filter_accela.cpp59
-rw-r--r--ftnoir_filter_accela/ftnoir_filter_accela.h91
-rw-r--r--ftnoir_filter_accela/ftnoir_filter_accela_dialog.cpp237
-rw-r--r--ftnoir_filter_accela/ftnoir_filter_accela_dll.cpp32
-rw-r--r--ftnoir_filter_base/ftnoir_filter_base.h3
-rw-r--r--ftnoir_filter_ewma2/ftnoir_filter_ewma2.cpp43
-rw-r--r--ftnoir_filter_ewma2/ftnoir_filter_ewma2.h50
-rw-r--r--ftnoir_filter_ewma2/ftnoir_filter_ewma2_dialog.cpp126
-rw-r--r--ftnoir_filter_ewma2/ftnoir_filter_ewma_dll.cpp18
-rw-r--r--ftnoir_filter_kalman/ftnoir_filter_kalman.h32
-rw-r--r--ftnoir_filter_kalman/ftnoir_kalman_filtercontrols.ui120
-rw-r--r--ftnoir_filter_kalman/kalman.cpp51
-rw-r--r--ftnoir_protocol_base/ftnoir_protocol_base.h3
-rw-r--r--ftnoir_protocol_fg/ftnoir_fgcontrols.ui321
-rw-r--r--ftnoir_protocol_fg/ftnoir_protocol_fg.cpp41
-rw-r--r--ftnoir_protocol_fg/ftnoir_protocol_fg.h57
-rw-r--r--ftnoir_protocol_fg/ftnoir_protocol_fg_dialog.cpp192
-rw-r--r--ftnoir_protocol_fg/ftnoir_protocol_fg_dll.cpp17
-rw-r--r--ftnoir_protocol_fsuipc/ftnoir_fsuipccontrols.ui277
-rw-r--r--ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc.cpp61
-rw-r--r--ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc.h64
-rw-r--r--ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc_dialog.cpp175
-rw-r--r--ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc_dll.cpp18
-rw-r--r--ftnoir_protocol_ft/ftnoir_protocol_ft.cpp102
-rw-r--r--ftnoir_protocol_ft/ftnoir_protocol_ft.h103
-rw-r--r--ftnoir_protocol_ft/ftnoir_protocol_ft_dialog.cpp224
-rw-r--r--ftnoir_protocol_ft/ftnoir_protocol_ft_dll.cpp18
-rw-r--r--ftnoir_protocol_ftn/ftnoir_protocol_ftn.cpp79
-rw-r--r--ftnoir_protocol_ftn/ftnoir_protocol_ftn.h50
-rw-r--r--ftnoir_protocol_ftn/ftnoir_protocol_ftn_dialog.cpp129
-rw-r--r--ftnoir_protocol_ftn/ftnoir_protocol_ftn_dll.cpp18
-rw-r--r--ftnoir_protocol_libevdev/ftnoir_protocol_libevdev.h5
-rw-r--r--ftnoir_protocol_libevdev/ftnoir_protocol_libevdev_dialog.cpp15
-rw-r--r--ftnoir_protocol_mouse/ftnoir_protocol_mouse.cpp56
-rw-r--r--ftnoir_protocol_mouse/ftnoir_protocol_mouse.h78
-rw-r--r--ftnoir_protocol_mouse/ftnoir_protocol_mouse_dialog.cpp180
-rw-r--r--ftnoir_protocol_mouse/ftnoir_protocol_mouse_dll.cpp18
-rw-r--r--ftnoir_protocol_sc/ftnoir_protocol_sc.cpp173
-rw-r--r--ftnoir_protocol_sc/ftnoir_protocol_sc.h65
-rw-r--r--ftnoir_protocol_sc/ftnoir_protocol_sc_dialog.cpp128
-rw-r--r--ftnoir_protocol_sc/ftnoir_protocol_sc_dll.cpp17
-rw-r--r--ftnoir_protocol_vjoy/ftnoir_protocol_vjoy.h4
-rw-r--r--ftnoir_protocol_vjoy/ftnoir_protocol_vjoy_dialog.cpp15
-rw-r--r--ftnoir_protocol_wine/ftnoir_protocol_wine.h4
-rw-r--r--ftnoir_tracker_aruco/aruco-trackercontrols.ui256
-rw-r--r--ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp310
-rw-r--r--ftnoir_tracker_aruco/ftnoir_tracker_aruco.h55
-rw-r--r--ftnoir_tracker_base/ftnoir_tracker_base.h3
-rw-r--r--ftnoir_tracker_hatire/ftnoir_hatcontrols.ui116
-rw-r--r--ftnoir_tracker_hatire/ftnoir_tracker_hat.cpp241
-rw-r--r--ftnoir_tracker_hatire/ftnoir_tracker_hat.h52
-rw-r--r--ftnoir_tracker_hatire/ftnoir_tracker_hat_dialog.cpp216
-rw-r--r--ftnoir_tracker_hatire/ftnoir_tracker_hat_dialog.h51
-rw-r--r--ftnoir_tracker_hatire/ftnoir_tracker_hat_settings.cpp145
-rw-r--r--ftnoir_tracker_hatire/ftnoir_tracker_hat_settings.h124
-rw-r--r--ftnoir_tracker_ht/ftnoir_tracker_ht.cpp277
-rw-r--r--ftnoir_tracker_ht/ftnoir_tracker_ht.h39
-rw-r--r--ftnoir_tracker_ht/ht-trackercontrols.ui591
-rw-r--r--ftnoir_tracker_ht/stdafx.h1
-rw-r--r--ftnoir_tracker_hydra/ftnoir_tracker_hydra.cpp95
-rw-r--r--ftnoir_tracker_hydra/ftnoir_tracker_hydra.h59
-rw-r--r--ftnoir_tracker_hydra/ftnoir_tracker_hydra_dialog.cpp186
-rw-r--r--ftnoir_tracker_hydra/ftnoir_tracker_hydra_dll.cpp18
-rw-r--r--ftnoir_tracker_joystick/ftnoir_tracker_joystick.cpp22
-rw-r--r--ftnoir_tracker_joystick/ftnoir_tracker_joystick.h55
-rw-r--r--ftnoir_tracker_joystick/ftnoir_tracker_joystick_dialog.cpp152
-rw-r--r--ftnoir_tracker_joystick/ftnoir_tracker_joystick_dll.cpp29
-rw-r--r--ftnoir_tracker_rift/ftnoir_tracker_rift.cpp83
-rw-r--r--ftnoir_tracker_rift/ftnoir_tracker_rift.h50
-rw-r--r--ftnoir_tracker_rift/ftnoir_tracker_rift_dialog.cpp135
-rw-r--r--ftnoir_tracker_rift/ftnoir_tracker_rift_dll.cpp9
-rw-r--r--ftnoir_tracker_udp/ftnoir_tracker_udp.cpp119
-rw-r--r--ftnoir_tracker_udp/ftnoir_tracker_udp.h67
-rw-r--r--ftnoir_tracker_udp/ftnoir_tracker_udp_dialog.cpp128
-rw-r--r--ftnoir_tracker_udp/ftnoir_tracker_udp_dll.cpp27
-rw-r--r--qfunctionconfigurator/functionconfig.h2
105 files changed, 3147 insertions, 8296 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 8e9ade02..776473b6 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,6 +1,8 @@
project(opentrack)
cmake_minimum_required(VERSION 2.8)
+include(CMakeParseArguments)
+
set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH}" "${CMAKE_SOURCE_DIR}/cmake/")
include(GetGitRevisionDescription)
find_package(Git QUIET)
@@ -8,6 +10,8 @@ if(GIT_FOUND)
git_describe(OPENTRACK__COMMIT --tags --always)
endif()
+include_directories(${CMAKE_SOURCE_DIR})
+
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
set(CMAKE_COMPILER_IS_GNUCC TRUE)
set(CMAKE_COMPILER_IS_GNUCXX TRUE)
@@ -110,54 +114,54 @@ if(MINGW)
set(Qt5Gui_gdi32_LIBRARY ${SDK_MINGW_PREFIX}/mingw/lib/libgdi32.a)
endif()
- find_package(OpenCV REQUIRED)
- set(maybe-serial-port)
- if(SDK_HATIRE)
- set(maybe-serial-port SerialPort)
- endif()
+find_package(OpenCV REQUIRED)
+set(maybe-serial-port)
+if(SDK_HATIRE)
+ set(maybe-serial-port SerialPort)
+endif()
- find_package(Qt5 REQUIRED COMPONENTS Core Xml Network Widgets Gui ${maybe-serial-port} QUIET)
- cmake_policy(SET CMP0020 NEW)
- include_directories(${Qt5Core_INCLUDE_DIRS} ${Qt5Xml_INCLUDE_DIRS} ${Qt5Gui_INCLUDE_DIRS} ${Qt5Widgets_INCLUDE_DIRS} ${Qt5Network_INCLUDE_DIRS})
- add_definitions(${Qt5Core_DEFINITIONS} ${Qt5Xml_DEFINITIONS} ${Qt5Gui_DEFINITIONS} ${Qt5Widgets_DEFINITIONS} ${Qt5Network_DEFINITIONS})
+find_package(Qt5 REQUIRED COMPONENTS Core Xml Network Widgets Gui ${maybe-serial-port} QUIET)
+cmake_policy(SET CMP0020 NEW)
+include_directories(${Qt5Core_INCLUDE_DIRS} ${Qt5Xml_INCLUDE_DIRS} ${Qt5Gui_INCLUDE_DIRS} ${Qt5Widgets_INCLUDE_DIRS} ${Qt5Network_INCLUDE_DIRS})
+add_definitions(${Qt5Core_DEFINITIONS} ${Qt5Xml_DEFINITIONS} ${Qt5Gui_DEFINITIONS} ${Qt5Widgets_DEFINITIONS} ${Qt5Network_DEFINITIONS})
- INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR})
- INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/qfunctionconfigurator)
- INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/ftnoir_posewidget)
+INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR})
+INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/qfunctionconfigurator)
+INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/ftnoir_posewidget)
- set(SDK_ARUCO_LIBPATH "" CACHE FILEPATH "Path to Aruco static library")
+set(SDK_ARUCO_LIBPATH "" CACHE FILEPATH "Path to Aruco static library")
- SET(SDK_OPENCV_STATIC FALSE CACHE BOOL "Whether OpenCV is statically linked")
- if(WIN32)
- set(SDK_SIMCONNECT "" CACHE PATH "Path to SimConnect SDK")
- set(SDK_DIRECTX "" CACHE PATH "Path to DirectX SDK")
- set(SDK_FSUIPC "" CACHE PATH "Path to FSUIPC")
- if(SDK_DIRECTX)
- include_directories("${SDK_DIRECTX}/Include")
- link_directories("${SDK_DIRECTX}/Lib")
- endif()
+SET(SDK_OPENCV_STATIC FALSE CACHE BOOL "Whether OpenCV is statically linked")
+if(WIN32)
+ set(SDK_SIMCONNECT "" CACHE PATH "Path to SimConnect SDK")
+ set(SDK_DIRECTX "" CACHE PATH "Path to DirectX SDK")
+ set(SDK_FSUIPC "" CACHE PATH "Path to FSUIPC")
+ if(SDK_DIRECTX)
+ include_directories("${SDK_DIRECTX}/Include")
+ link_directories("${SDK_DIRECTX}/Lib")
endif()
+endif()
- if(NOT WIN32)
- set(SDK_WINE_PREFIX "" CACHE PATH "Path where Wine is installed")
- set(SDK_WINE_NO_WRAPPER FALSE CACHE BOOL "Don't build wrapper, for instance X-Plane is native Linux app")
- endif()
- IF("${CMAKE_SYSTEM}" MATCHES "Linux" OR APPLE)
- set(SDK_XPLANE "" CACHE PATH "Path to X-Plane SDK")
- endif()
+if(NOT WIN32)
+ set(SDK_WINE_PREFIX "" CACHE PATH "Path where Wine is installed")
+ set(SDK_WINE_NO_WRAPPER FALSE CACHE BOOL "Don't build wrapper, for instance X-Plane is native Linux app")
+endif()
+IF("${CMAKE_SYSTEM}" MATCHES "Linux" OR APPLE)
+ set(SDK_XPLANE "" CACHE PATH "Path to X-Plane SDK")
+endif()
- if(SDK_XPLANE)
- INCLUDE_DIRECTORIES("${SDK_XPLANE}/CHeaders" "${SDK_XPLANE}/CHeaders/XPLM")
- endif()
+if(SDK_XPLANE)
+ INCLUDE_DIRECTORIES("${SDK_XPLANE}/CHeaders" "${SDK_XPLANE}/CHeaders/XPLM")
+endif()
- if(WIN32)
- if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_GNUCC)
- set(CMAKE_RC_COMPILER_INIT i686-w64-mingw32-windres)
- SET(CMAKE_RC_COMPILE_OBJECT "<CMAKE_RC_COMPILER> -O coff <DEFINES> -i <SOURCE> -o <OBJECT>")
- endif()
- ENABLE_LANGUAGE(RC)
- endif(WIN32)
+if(WIN32)
+ if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_GNUCC)
+ set(CMAKE_RC_COMPILER_INIT i686-w64-mingw32-windres)
+ SET(CMAKE_RC_COMPILE_OBJECT "<CMAKE_RC_COMPILER> -O coff <DEFINES> -i <SOURCE> -o <OBJECT>")
+ endif()
+ ENABLE_LANGUAGE(RC)
+endif(WIN32)
if(SDK_FSUIPC AND WIN32)
include_directories("${SDK_FSUIPC}")
@@ -174,177 +178,90 @@ else()
include_directories("qxt-mini/")
endif()
endif()
-# main app
-
-file(GLOB opentrack-lib-c "opentrack-api/*.cpp" "facetracknoir/global-settings.cpp")
-file(GLOB opentrack-lib-h "opentrack-api/*.h" "facetracknoir/global-settings.h")
-file(GLOB opentrack-bin-c "facetracknoir/*.cpp" "facetracknoir/*.rc")
-file(GLOB opentrack-bin-h "facetracknoir/*.h")
-file(GLOB opentrack-bin-ui "facetracknoir/*.ui")
-file(GLOB opentrack-bin-rc "facetracknoir/*.qrc")
-QT5_WRAP_UI(opentrack-bin-uih ${opentrack-bin-ui})
-QT5_ADD_RESOURCES(opentrack-bin-rcc ${opentrack-bin-rc})
+# qt being broken as usual
+set(EXTRA-MOCS "${CMAKE_SOURCE_DIR}/facetracknoir/options.h")
+
+function(link_with_dinput8 n)
+ if(WIN32)
+ if(MSVC)
+ target_link_libraries(${n}
+ "${CMAKE_SOURCE_DIR}/dinput/dinput8.lib"
+ "${CMAKE_SOURCE_DIR}/dinput/dxguid.lib"
+ "${CMAKE_SOURCE_DIR}/dinput/strmiids.lib"
+ uuid)
+ else()
+ target_link_libraries(${n} dinput8 dxguid strmiids)
+ endif()
+ endif()
+endfunction()
+
+macro(opentrack_module n dir)
+ file(GLOB ${n}-c "${dir}/*.cpp" "${dir}/*.h" "${dir}/*.rc" ${EXTRA-MOCS})
+ file(GLOB ${n}-ui "${dir}/*.ui")
+ file(GLOB ${n}-rc "${dir}/*.qrc")
+ QT5_WRAP_UI(${n}-uih ${${n}-ui})
+ QT5_ADD_RESOURCES(${n}-rcc ${${n}-rc})
+endmacro()
+
+macro(opentrack_library n)
+ cmake_parse_arguments(foolib "" "LINK;COMPILE" "" ${ARGN})
+ if(NOT " ${foolib_UNPARSED_ARGUMENTS}" STREQUAL " ")
+ message(FATAL_ERROR "opentrack_library bad formals")
+ endif()
+ add_library(${n} SHARED ${${n}-c} ${${n}-uih} ${${n}-rcc})
+ target_link_libraries(${n} ${MY_QT_LIBS})
+ if(CMAKE_COMPILER_IS_GNUCXX AND NOT APPLE)
+ SET_TARGET_PROPERTIES(${n} PROPERTIES
+ LINK_FLAGS "${foolib_LINK} -Wl,--version-script=${CMAKE_SOURCE_DIR}/facetracknoir/${version-script}-version-script.txt"
+ COMPILE_FLAGS "${foolib_COMPILE}"
+ )
+ else()
+ set_target_properties(${n} PROPERTIES LINK_FLAGS "${foolib_LINK}" COMPILE_FLAGS "${foolib_COMPILE}")
+ endif()
+ install(TARGETS ${n} RUNTIME DESTINATION . LIBRARY DESTINATION .)
+endmacro()
-file(GLOB opentrack-pose-widget-c "ftnoir_posewidget/*.cpp")
-file(GLOB opentrack-pose-widget-h "ftnoir_posewidget/*.h")
-file(GLOB opentrack-pose-widget-rc "ftnoir_posewidget/*.qrc")
-QT5_ADD_RESOURCES(opentrack-pose-widget-rcc ${opentrack-pose-widget-rc})
+file(GLOB opentrack-lib-c "opentrack-api/*.cpp" "facetracknoir/global-settings.cpp" "opentrack-api/*.h" "facetracknoir/global-settings.h")
-file(GLOB opentrack-spline-widget-c "qfunctionconfigurator/*.cpp")
-file(GLOB opentrack-spline-widget-h "qfunctionconfigurator/*.h")
+opentrack_module(opentrack-bin facetracknoir)
+opentrack_module(opentrack-pose-widget ftnoir_posewidget)
+opentrack_module(opentrack-spline-widget qfunctionconfigurator)
# filters
-file(GLOB opentrack-filter-accela-c "ftnoir_filter_accela/*.cpp")
-file(GLOB opentrack-filter-accela-h "ftnoir_filter_accela/*.h")
-file(GLOB opentrack-filter-accela-ui "ftnoir_filter_accela/*.ui")
-file(GLOB opentrack-filter-accela-rc "ftnoir_filter_accela/*.qrc")
-QT5_WRAP_UI(opentrack-filter-accela-uih ${opentrack-filter-accela-ui})
-QT5_ADD_RESOURCES(opentrack-filter-accela-rcc ${opentrack-filter-accela-rc})
-
-file(GLOB opentrack-filter-kalman-c "ftnoir_filter_kalman/*.cpp")
-file(GLOB opentrack-filter-kalman-h "ftnoir_filter_kalman/*.h")
-file(GLOB opentrack-filter-kalman-ui "ftnoir_filter_kalman/*.ui")
-file(GLOB opentrack-filter-kalman-rc "ftnoir_filter_kalman/*.qrc")
-QT5_WRAP_UI(opentrack-filter-kalman-uih ${opentrack-filter-kalman-ui})
-QT5_ADD_RESOURCES(opentrack-filter-kalman-rcc ${opentrack-filter-kalman-rc})
-
-file(GLOB opentrack-filter-ewma-c "ftnoir_filter_ewma2/*.cpp")
-file(GLOB opentrack-filter-ewma-h "ftnoir_filter_ewma2/*.h")
-file(GLOB opentrack-filter-ewma-ui "ftnoir_filter_ewma2/*.ui")
-file(GLOB opentrack-filter-ewma-rc "ftnoir_filter_ewma2/*.qrc")
-QT5_WRAP_UI(opentrack-filter-ewma-uih ${opentrack-filter-ewma-ui})
-QT5_ADD_RESOURCES(opentrack-filter-ewma-rcc ${opentrack-filter-ewma-rc})
+opentrack_module(opentrack-filter-accela ftnoir_filter_accela)
+opentrack_module(opentrack-filter-kalman ftnoir_filter_kalman)
+opentrack_module(opentrack-filter-ewma ftnoir_filter_ewma2)
# protocols
-file(GLOB opentrack-proto-fgfs-c "ftnoir_protocol_fg/*.cpp")
-file(GLOB opentrack-proto-fgfs-h "ftnoir_protocol_fg/*.h")
-file(GLOB opentrack-proto-fgfs-ui "ftnoir_protocol_fg/*.ui")
-file(GLOB opentrack-proto-fgfs-rc "ftnoir_protocol_fg/*.qrc")
-QT5_WRAP_UI(opentrack-proto-fgfs-uih ${opentrack-proto-fgfs-ui})
-QT5_ADD_RESOURCES(opentrack-proto-fgfs-rcc ${opentrack-proto-fgfs-rc})
-
-file(GLOB opentrack-proto-fsuipc-c "ftnoir_protocol_fsuipc/*.cpp")
-file(GLOB opentrack-proto-fsuipc-h "ftnoir_protocol_fsuipc/*.h")
-file(GLOB opentrack-proto-fsuipc-ui "ftnoir_protocol_fsuipc/*.ui")
-file(GLOB opentrack-proto-fsuipc-rc "ftnoir_protocol_fsuipc/*.qrc")
-QT5_WRAP_UI(opentrack-proto-fsuipc-uih ${opentrack-proto-fsuipc-ui})
-QT5_ADD_RESOURCES(opentrack-proto-fsuipc-rcc ${opentrack-proto-fsuipc-rc})
-
-file(GLOB opentrack-proto-freetrack-c "ftnoir_protocol_ft/*.cpp")
-file(GLOB opentrack-proto-freetrack-h "ftnoir_protocol_ft/*.h")
-file(GLOB opentrack-proto-freetrack-ui "ftnoir_protocol_ft/*.ui")
-file(GLOB opentrack-proto-freetrack-rc "ftnoir_protocol_ft/*.qrc")
-QT5_WRAP_UI(opentrack-proto-freetrack-uih ${opentrack-proto-freetrack-ui})
-QT5_ADD_RESOURCES(opentrack-proto-freetrack-rcc ${opentrack-proto-freetrack-rc})
-
-file(GLOB opentrack-proto-udp-c "ftnoir_protocol_ftn/*.cpp")
-file(GLOB opentrack-proto-udp-h "ftnoir_protocol_ftn/*.h")
-file(GLOB opentrack-proto-udp-ui "ftnoir_protocol_ftn/*.ui")
-file(GLOB opentrack-proto-udp-rc "ftnoir_protocol_ftn/*.qrc")
-QT5_WRAP_UI(opentrack-proto-udp-uih ${opentrack-proto-udp-ui})
-QT5_ADD_RESOURCES(opentrack-proto-udp-rcc ${opentrack-proto-udp-rc})
-
-file(GLOB opentrack-proto-wine-c "ftnoir_protocol_wine/*.cpp")
-file(GLOB opentrack-proto-wine-h "ftnoir_protocol_wine/*.h")
-file(GLOB opentrack-proto-wine-ui "ftnoir_protocol_wine/*.ui")
-file(GLOB opentrack-proto-wine-rc "ftnoir_protocol_wine/*.qrc")
-QT5_WRAP_UI(opentrack-proto-wine-uih ${opentrack-proto-wine-ui})
-QT5_ADD_RESOURCES(opentrack-proto-wine-rcc ${opentrack-proto-wine-rc})
-
-file(GLOB opentrack-proto-win32-mouse-c "ftnoir_protocol_mouse/*.cpp")
-file(GLOB opentrack-proto-win32-mouse-h "ftnoir_protocol_mouse/*.h")
-file(GLOB opentrack-proto-win32-mouse-ui "ftnoir_protocol_mouse/*.ui")
-file(GLOB opentrack-proto-win32-mouse-rc "ftnoir_protocol_mouse/*.qrc")
-QT5_WRAP_UI(opentrack-proto-win32-mouse-uih ${opentrack-proto-win32-mouse-ui})
-QT5_ADD_RESOURCES(opentrack-proto-win32-mouse-rcc ${opentrack-proto-win32-mouse-rc})
-
-file(GLOB opentrack-proto-simconnect-c "ftnoir_protocol_sc/*.cpp" "ftnoir_protocol_sc/ftnoir-protocol-sc.rc")
-file(GLOB opentrack-proto-simconnect-h "ftnoir_protocol_sc/*.h")
-file(GLOB opentrack-proto-simconnect-ui "ftnoir_protocol_sc/*.ui")
-file(GLOB opentrack-proto-simconnect-rc "ftnoir_protocol_sc/*.qrc")
-QT5_WRAP_UI(opentrack-proto-simconnect-uih ${opentrack-proto-simconnect-ui})
-QT5_ADD_RESOURCES(opentrack-proto-simconnect-rcc ${opentrack-proto-simconnect-rc})
-
-file(GLOB opentrack-proto-vjoy-c "ftnoir_protocol_vjoy/*.cpp")
-file(GLOB opentrack-proto-vjoy-h "ftnoir_protocol_vjoy/*.h")
-file(GLOB opentrack-proto-vjoy-ui "ftnoir_protocol_vjoy/*.ui")
-file(GLOB opentrack-proto-vjoy-rc "ftnoir_protocol_vjoy/*.qrc")
-QT5_WRAP_UI(opentrack-proto-vjoy-uih ${opentrack-proto-vjoy-ui})
-QT5_ADD_RESOURCES(opentrack-proto-vjoy-rcc ${opentrack-proto-vjoy-rc})
-
-file(GLOB opentrack-proto-libevdev-c "ftnoir_protocol_libevdev/*.cpp")
-file(GLOB opentrack-proto-libevdev-h "ftnoir_protocol_libevdev/*.h")
-file(GLOB opentrack-proto-libevdev-ui "ftnoir_protocol_libevdev/*.ui")
-file(GLOB opentrack-proto-libevdev-rc "ftnoir_protocol_libevdev/*.qrc")
-QT5_WRAP_UI(opentrack-proto-libevdev-uih ${opentrack-proto-libevdev-ui})
-QT5_ADD_RESOURCES(opentrack-proto-libevdev-rcc ${opentrack-proto-libevdev-rc})
+opentrack_module(opentrack-proto-fgfs ftnoir_protocol_fg)
+opentrack_module(opentrack-proto-fsuipc ftnoir_protocol_fsuipc)
+opentrack_module(opentrack-proto-freetrack ftnoir_protocol_ft)
+opentrack_module(opentrack-proto-udp ftnoir_protocol_ftn)
+opentrack_module(opentrack-proto-wine ftnoir_protocol_wine)
+opentrack_module(opentrack-proto-win32-mouse ftnoir_protocol_mouse)
+opentrack_module(opentrack-proto-simconnect ftnoir_protocol_sc)
+opentrack_module(opentrack-proto-vjoy ftnoir_protocol_vjoy)
+opentrack_module(opentrack-proto-libevdev ftnoir_protocol_libevdev)
# trackers
-file(GLOB opentrack-tracker-ht-c "ftnoir_tracker_ht/*.cpp")
-file(GLOB opentrack-tracker-ht-h "ftnoir_tracker_ht/*.h")
-file(GLOB opentrack-tracker-ht-ui "ftnoir_tracker_ht/*.ui")
-file(GLOB opentrack-tracker-ht-rc "ftnoir_tracker_ht/*.qrc")
-QT5_WRAP_UI(opentrack-tracker-ht-uih ${opentrack-tracker-ht-ui})
-QT5_ADD_RESOURCES(opentrack-tracker-ht-rcc ${opentrack-tracker-ht-rc})
-
-file(GLOB opentrack-tracker-aruco-c "ftnoir_tracker_aruco/*.cpp")
-file(GLOB opentrack-tracker-aruco-h "ftnoir_tracker_aruco/*.h")
-file(GLOB opentrack-tracker-aruco-ui "ftnoir_tracker_aruco/*.ui")
-file(GLOB opentrack-tracker-aruco-rc "ftnoir_tracker_aruco/*.qrc")
-QT5_WRAP_UI(opentrack-tracker-aruco-uih ${opentrack-tracker-aruco-ui})
-QT5_ADD_RESOURCES(opentrack-tracker-aruco-rcc ${opentrack-tracker-aruco-rc})
-
-file(GLOB opentrack-tracker-pt-c "FTNoIR_Tracker_PT/*.cpp")
-file(GLOB opentrack-tracker-pt-h "FTNoIR_Tracker_PT/*.h")
-file(GLOB opentrack-tracker-pt-ui "FTNoIR_Tracker_PT/*.ui")
-file(GLOB opentrack-tracker-pt-rc "FTNoIR_Tracker_PT/*.qrc")
-QT5_WRAP_UI(opentrack-tracker-pt-uih ${opentrack-tracker-pt-ui})
-QT5_ADD_RESOURCES(opentrack-tracker-pt-rcc ${opentrack-tracker-pt-rc})
-
-file(GLOB opentrack-tracker-udp-c "ftnoir_tracker_udp/*.cpp")
-file(GLOB opentrack-tracker-udp-h "ftnoir_tracker_udp/*.h")
-file(GLOB opentrack-tracker-udp-ui "ftnoir_tracker_udp/*.ui")
-file(GLOB opentrack-tracker-udp-rc "ftnoir_tracker_udp/*.qrc")
-QT5_WRAP_UI(opentrack-tracker-udp-uih ${opentrack-tracker-udp-ui})
-QT5_ADD_RESOURCES(opentrack-tracker-udp-rcc ${opentrack-tracker-udp-rc})
-
-file(GLOB opentrack-tracker-joystick-c "ftnoir_tracker_joystick/*.cpp")
-file(GLOB opentrack-tracker-joystick-h "ftnoir_tracker_joystick/*.h")
-file(GLOB opentrack-tracker-joystick-ui "ftnoir_tracker_joystick/*.ui")
-file(GLOB opentrack-tracker-joystick-rc "ftnoir_tracker_joystick/*.qrc")
-QT5_WRAP_UI(opentrack-tracker-joystick-uih ${opentrack-tracker-joystick-ui})
-QT5_ADD_RESOURCES(opentrack-tracker-joystick-rcc ${opentrack-tracker-joystick-rc})
-
-file(GLOB opentrack-tracker-rift-c "ftnoir_tracker_rift/*.cpp")
-file(GLOB opentrack-tracker-rift-h "ftnoir_tracker_rift/*.h")
-file(GLOB opentrack-tracker-rift-ui "ftnoir_tracker_rift/*.ui")
-file(GLOB opentrack-tracker-rift-rc "ftnoir_tracker_rift/*.qrc")
-QT5_WRAP_UI(opentrack-tracker-rift-uih ${opentrack-tracker-rift-ui})
-QT5_ADD_RESOURCES(opentrack-tracker-rift-rcc ${opentrack-tracker-rift-rc})
-
-file(GLOB opentrack-tracker-hydra-c "ftnoir_tracker_hydra/*.cpp")
-file(GLOB opentrack-tracker-hydra-h "ftnoir_tracker_hydra/*.h")
-file(GLOB opentrack-tracker-hydra-ui "ftnoir_tracker_hydra/*.ui")
-file(GLOB opentrack-tracker-hydra-rc "ftnoir_tracker_hydra/*.qrc")
-QT5_WRAP_UI(opentrack-tracker-hydra-uih ${opentrack-tracker-hydra-ui})
-QT5_ADD_RESOURCES(opentrack-tracker-hydra-rcc ${opentrack-tracker-hydra-rc})
-
-file(GLOB opentrack-tracker-hatire-c "ftnoir_tracker_hatire/*.cpp")
-file(GLOB opentrack-tracker-hatire-h "ftnoir_tracker_hatire/*.h")
-file(GLOB opentrack-tracker-hatire-ui "ftnoir_tracker_hatire/*.ui")
-file(GLOB opentrack-tracker-hatire-rc "ftnoir_tracker_hatire/*.qrc")
-QT5_WRAP_UI(opentrack-tracker-hatire-uih ${opentrack-tracker-hatire-ui})
-QT5_ADD_RESOURCES(opentrack-tracker-hatire-rcc ${opentrack-tracker-hatire-rc})
-
-file(GLOB opentrack-csv-c "ftnoir_csv/*.cpp")
+opentrack_module(opentrack-tracker-ht ftnoir_tracker_ht)
+opentrack_module(opentrack-tracker-aruco ftnoir_tracker_aruco)
+opentrack_module(opentrack-tracker-pt FTNoIR_Tracker_PT)
+opentrack_module(opentrack-tracker-udp ftnoir_tracker_udp)
+opentrack_module(opentrack-tracker-joystick ftnoir_tracker_joystick)
+opentrack_module(opentrack-tracker-rift ftnoir_tracker_rift)
+opentrack_module(opentrack-tracker-hydra ftnoir_tracker_hydra)
+opentrack_module(opentrack-tracker-hatire ftnoir_tracker_hatire)
+
+file(GLOB opentrack-csv-c "ftnoir_csv/*.cpp" "ftnoir_csv/*.h")
# compat lib for POSIX/win32
-file(GLOB opentrack-compat-c "compat/*.cpp")
+file(GLOB opentrack-compat-c "compat/*.cpp" "compat/*.h")
# x-plane plugin
file(GLOB opentrack-xplane-plugin-c "x-plane-plugin/*.c")
@@ -380,13 +297,7 @@ if(QT_USE_FILE)
INCLUDE(${QT_USE_FILE})
endif()
-if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX)
- SET (CMAKE_SHARED_LINKER_FLAGS ${CMAKE_SHARED_LINKER_FLAGS_INIT} -rdynamic CACHE STRING "Flags used by the linker during the creation of dll's.")
- SET (CMAKE_MODULE_LINKER_FLAGS ${CMAKE_MODULE_LINKER_FLAGS_INIT} -rdynamic CACHE STRING "Flags used by the linker during the creation of modules.")
- SET (CMAKE_MODULE_LINKER_FLAGS ${CMAKE_MODULE_LINKER_FLAGS_INIT} -rdynamic CACHE STRING "Flags used by the linker during the creation of modules.")
-endif()
-
-add_library(opentrack-compat SHARED ${opentrack-compat-c} ${opentrack-compat-h})
+add_library(opentrack-compat SHARED ${opentrack-compat-c})
if(NOT WIN32 AND NOT APPLE)
target_link_libraries(opentrack-compat rt)
endif()
@@ -413,121 +324,73 @@ else()
${Qt5Network_LIBRARIES} ${Qt5Xml_LIBRARIES} ${Qt5Core_LIBRARIES} ${maybe-hatire} ${my-qt-deps})
endif()
-add_library(opentrack-csv SHARED ${opentrack-csv-c} ${opentrack-csv-h})
+add_library(opentrack-csv SHARED ${opentrack-csv-c})
target_link_libraries(opentrack-csv ${MY_QT_LIBS})
-add_library(opentrack-pose-widget SHARED ${opentrack-pose-widget-c} ${opentrack-pose-widget-h} ${opentrack-pose-widget-moc} ${opentrack-pose-widget-rcc})
+add_library(opentrack-pose-widget SHARED ${opentrack-pose-widget-c} ${opentrack-pose-widget-rcc})
target_link_libraries(opentrack-pose-widget ${MY_QT_LIBS})
-add_library(opentrack-spline-widget SHARED ${opentrack-spline-widget-c} ${opentrack-spline-widget-h} ${opentrack-spline-widget-moc})
+add_library(opentrack-spline-widget SHARED ${opentrack-spline-widget-c})
target_link_libraries(opentrack-spline-widget ${MY_QT_LIBS})
-add_library(opentrack-filter-accela SHARED ${opentrack-filter-accela-c} ${opentrack-filter-accela-h} ${opentrack-filter-accela-moc} ${opentrack-filter-accela-uih} ${opentrack-filter-accela-rcc})
-target_link_libraries(opentrack-filter-accela ${MY_QT_LIBS})
-
-add_library(opentrack-filter-kalman SHARED ${opentrack-filter-kalman-c} ${opentrack-filter-kalman-h} ${opentrack-filter-kalman-moc} ${opentrack-filter-kalman-uih} ${opentrack-filter-kalman-rcc})
-target_link_libraries(opentrack-filter-kalman ${MY_QT_LIBS} ${OpenCV_LIBS})
-
-if(CMAKE_COMPILER_IS_GNUCXX AND NOT APPLE)
- SET_TARGET_PROPERTIES(opentrack-filter-kalman
- PROPERTIES LINK_FLAGS "-Wl,--version-script=${CMAKE_SOURCE_DIR}/facetracknoir/${version-script}-version-script.txt")
-endif()
-
-if(CMAKE_COMPILER_IS_GNUCXX AND NOT APPLE)
- SET_TARGET_PROPERTIES(opentrack-filter-accela
- PROPERTIES LINK_FLAGS "-Wl,--version-script=${CMAKE_SOURCE_DIR}/facetracknoir/${version-script}-version-script.txt")
-endif()
-
-add_library(opentrack-filter-ewma SHARED ${opentrack-filter-ewma-uih} ${opentrack-filter-ewma-c} ${opentrack-filter-ewma-h} ${opentrack-filter-ewma-moc} ${opentrack-filter-ewma-rcc})
-target_link_libraries(opentrack-filter-ewma ${MY_QT_LIBS})
+opentrack_library(opentrack-filter-accela)
+opentrack_library(opentrack-filter-kalman)
+opentrack_library(opentrack-filter-ewma)
-if(CMAKE_COMPILER_IS_GNUCXX AND NOT APPLE)
- SET_TARGET_PROPERTIES(opentrack-filter-ewma
- PROPERTIES LINK_FLAGS "-Wl,--version-script=${CMAKE_SOURCE_DIR}/facetracknoir/${version-script}-version-script.txt")
-endif()
+target_link_libraries(opentrack-filter-kalman ${OpenCV_LIBS})
-add_library(opentrack-proto-fgfs SHARED ${opentrack-proto-fgfs-c} ${opentrack-proto-fgfs-h} ${opentrack-proto-fgfs-moc} ${opentrack-proto-fgfs-uih} ${opentrack-proto-fgfs-rcc})
-target_link_libraries(opentrack-proto-fgfs ${MY_QT_LIBS})
-if(CMAKE_COMPILER_IS_GNUCXX AND NOT APPLE)
- SET_TARGET_PROPERTIES(opentrack-proto-fgfs
- PROPERTIES LINK_FLAGS "-Wl,--version-script=${CMAKE_SOURCE_DIR}/facetracknoir/${version-script}-version-script.txt")
-endif()
+opentrack_library(opentrack-proto-fgfs)
-if(WIN32 AND SDK_VJOY)
+if(SDK_VJOY)
include_directories(${SDK_VJOY})
- add_library(opentrack-proto-vjoy SHARED ${opentrack-proto-vjoy-c} ${opentrack-proto-vjoy-h} ${opentrack-proto-vjoy-moc} ${opentrack-proto-vjoy-uih} ${opentrack-proto-vjoy-rcc})
+ opentrack_library(opentrack-proto-vjoy)
if(MSVC)
target_link_libraries(opentrack-proto-vjoy ${MY_QT_LIBS} "${SDK_VJOY}/VJoy.lib")
else()
target_link_libraries(opentrack-proto-vjoy ${MY_QT_LIBS} "${SDK_VJOY}/VJoy.dll")
endif()
- if(CMAKE_COMPILER_IS_GNUCXX AND NOT APPLE)
- SET_TARGET_PROPERTIES(opentrack-proto-vjoy
- PROPERTIES LINK_FLAGS "-Wl,--version-script=${CMAKE_SOURCE_DIR}/facetracknoir/${version-script}-version-script.txt -Wl,--enable-stdcall-fixup")
- endif()
endif()
-if(UNIX AND SDK_ENABLE_LIBEVDEV)
- add_library(opentrack-proto-libevdev SHARED ${opentrack-proto-libevdev-c} ${opentrack-proto-libevdev-h} ${opentrack-proto-libevdev-moc} ${opentrack-proto-libevdev-uih} ${opentrack-proto-libevdev-rcc})
- target_link_libraries(opentrack-proto-libevdev ${MY_QT_LIBS} evdev)
- if(CMAKE_COMPILER_IS_GNUCXX AND NOT APPLE)
- SET_TARGET_PROPERTIES(opentrack-proto-libevdev
- PROPERTIES LINK_FLAGS "-Wl,--version-script=${CMAKE_SOURCE_DIR}/facetracknoir/${version-script}-version-script.txt")
- endif()
- install(TARGETS opentrack-proto-libevdev RUNTIME DESTINATION . LIBRARY DESTINATION . )
+if(SDK_ENABLE_LIBEVDEV)
+ opentrack_library(opentrack-proto-libevdev)
+ target_link_libraries(opentrack-proto-libevdev evdev)
endif()
-if(WIN32)
- if(SDK_FSUIPC)
- add_library(opentrack-proto-fsuipc SHARED ${opentrack-proto-fsuipc-c} ${opentrack-proto-fsuipc-h} ${opentrack-proto-fsuipc-moc} ${opentrack-proto-fsuipc-uih} ${opentrack-proto-fsuipc-rcc})
- target_link_libraries(opentrack-proto-fsuipc ${MY_QT_LIBS} "${SDK_FSUIPC}/FSUIPC_User.lib")
- if(MSVC)
- set_target_properties(opentrack-proto-fsuipc PROPERTIES LINK_FLAGS "/NODEFAULTLIB:libc")
- else()
- set_target_properties(opentrack-proto-fsuipc PROPERTIES LINK_FLAGS "-Wl,--exclude-all-symbols")
- endif()
+if(SDK_FSUIPC)
+ if(MSVC)
+ set(link-flags "/NODEFAULTLIB:libc")
endif()
+ opentrack_library(opentrack-proto-fsuipc LINK "${link-flags}")
+ target_link_libraries(opentrack-proto-fsuipc "${SDK_FSUIPC}/FSUIPC_User.lib")
+endif()
- if(SDK_SIMCONNECT)
- add_library(opentrack-proto-simconnect SHARED ${opentrack-proto-simconnect-c} ${opentrack-proto-simconnect-h} ${opentrack-proto-simconnect-moc} ${opentrack-proto-simconnect-uih} ${opentrack-proto-simconnect-rcc})
- target_link_libraries(opentrack-proto-simconnect ${MY_QT_LIBS})
- include_directories("${SDK_SIMCONNECT}/inc")
- target_link_libraries(opentrack-proto-simconnect "${SDK_SIMCONNECT}/lib/SimConnect.lib")
- endif()
+if(SDK_SIMCONNECT)
+ opentrack_library(opentrack-proto-simconnect)
+ include_directories("${SDK_SIMCONNECT}/inc")
+ target_link_libraries(opentrack-proto-simconnect "${SDK_SIMCONNECT}/lib/SimConnect.lib")
+endif()
- add_library(opentrack-proto-freetrack SHARED ${opentrack-proto-freetrack-c} ${opentrack-proto-freetrack-h} ${opentrack-proto-freetrack-moc} ${opentrack-proto-freetrack-uih} ${opentrack-proto-freetrack-rcc})
- target_link_libraries(opentrack-proto-freetrack opentrack-csv ${MY_QT_LIBS} opentrack-compat)
+if(WIN32)
+ opentrack_library(opentrack-proto-freetrack)
+ target_link_libraries(opentrack-proto-freetrack opentrack-csv opentrack-compat)
+ opentrack_library(opentrack-proto-win32-mouse)
+endif()
- add_library(opentrack-proto-win32-mouse SHARED ${opentrack-proto-win32-mouse-c} ${opentrack-proto-win32-mouse-h} ${opentrack-proto-win32-mouse-moc} ${opentrack-proto-win32-mouse-uih} ${opentrack-proto-win32-mouse-rcc})
- target_link_libraries(opentrack-proto-win32-mouse ${MY_QT_LIBS})
- add_library(freetrackclient SHARED ${opentrack-freetrack-c} ${opentrack-freetrack-h})
+if(WIN32)
+ add_library(freetrackclient SHARED ${opentrack-freetrack-c})
if(CMAKE_COMPILER_IS_GNUCC)
set_target_properties(freetrackclient PROPERTIES LINK_FLAGS "-Wl,--enable-stdcall-fixup -fno-lto -Wl,-kill-at" PREFIX "" COMPILE_FLAGS "-fno-lto")
endif()
endif()
-add_library(opentrack-proto-udp SHARED ${opentrack-proto-udp-c} ${opentrack-proto-udp-h} ${opentrack-proto-udp-moc} ${opentrack-proto-udp-uih} ${opentrack-proto-udp-rcc})
-target_link_libraries(opentrack-proto-udp ${MY_QT_LIBS})
-if(CMAKE_COMPILER_IS_GNUCXX AND NOT APPLE)
- SET_TARGET_PROPERTIES(opentrack-proto-udp
- PROPERTIES LINK_FLAGS "-Wl,--version-script=${CMAKE_SOURCE_DIR}/facetracknoir/${version-script}-version-script.txt")
-endif()
+opentrack_library(opentrack-proto-udp)
if(WIN32)
- add_library(opentrack-tracker-joystick SHARED ${opentrack-tracker-joystick-c} ${opentrack-tracker-joystick-h} ${opentrack-tracker-joystick-moc} ${opentrack-tracker-joystick-uih} ${opentrack-tracker-joystick-rcc})
- target_link_libraries(opentrack-tracker-joystick ${MY_QT_LIBS})
- if(CMAKE_COMPILER_IS_GNUCXX AND NOT APPLE)
- SET_TARGET_PROPERTIES(opentrack-tracker-joystick
- PROPERTIES LINK_FLAGS "-Wl,--version-script=${CMAKE_SOURCE_DIR}/facetracknoir/${version-script}-version-script.txt")
- endif()
+ opentrack_library(opentrack-tracker-joystick)
endif()
-if(NOT WIN32 AND SDK_WINE_PREFIX)
- add_library(opentrack-proto-wine SHARED ${opentrack-proto-wine-c} ${opentrack-proto-wine-h} ${opentrack-proto-wine-moc} ${opentrack-proto-wine-uih} ${opentrack-proto-wine-rcc})
- target_link_libraries(opentrack-proto-wine ${MY_QT_LIBS} opentrack-compat opentrack-csv)
- if(CMAKE_COMPILER_IS_GNUCXX AND NOT APPLE)
- SET_TARGET_PROPERTIES(opentrack-proto-wine
- PROPERTIES LINK_FLAGS "-Wl,--version-script=${CMAKE_SOURCE_DIR}/facetracknoir/${version-script}-version-script.txt")
- endif()
+if(SDK_WINE_PREFIX)
+ opentrack_library(opentrack-proto-wine)
+ target_link_libraries(opentrack-proto-wine opentrack-compat opentrack-csv)
if(NOT SDK_WINE_NO_WRAPPER)
set(my-rt -lrt)
if(APPLE)
@@ -549,26 +412,13 @@ if(NOT WIN32 AND SDK_WINE_PREFIX)
endif()
endif()
-if(CMAKE_COMPILER_IS_GNUCXX AND NOT APPLE)
- SET_TARGET_PROPERTIES(opentrack-proto-fgfs
- PROPERTIES LINK_FLAGS "-Wl,--version-script=${CMAKE_SOURCE_DIR}/facetracknoir/${version-script}-version-script.txt")
-endif()
-
-add_library(opentrack-tracker-ht SHARED ${opentrack-tracker-ht-c} ${opentrack-tracker-ht-h} ${opentrack-tracker-ht-moc} ${opentrack-tracker-ht-uih} ${opentrack-tracker-ht-rcc})
-target_link_libraries(opentrack-tracker-ht ${MY_QT_LIBS} opentrack-compat)
-if(CMAKE_COMPILER_IS_GNUCXX AND NOT APPLE)
- SET_TARGET_PROPERTIES(opentrack-tracker-ht
- PROPERTIES LINK_FLAGS "-Wl,--version-script=${CMAKE_SOURCE_DIR}/facetracknoir/${version-script}-version-script.txt")
-endif()
+opentrack_library(opentrack-tracker-ht)
+target_link_libraries(opentrack-tracker-ht opentrack-compat)
if(SDK_ARUCO_LIBPATH)
include_directories(${CMAKE_SOURCE_DIR}/ftnoir_tracker_aruco/include)
- add_library(opentrack-tracker-aruco SHARED ${opentrack-tracker-aruco-c} ${opentrack-tracker-aruco-h} ${opentrack-tracker-aruco-moc} ${opentrack-tracker-aruco-uih} ${opentrack-tracker-aruco-rcc})
- target_link_libraries(opentrack-tracker-aruco ${MY_QT_LIBS} ${SDK_ARUCO_LIBPATH} ${OpenCV_LIBS})
- if(CMAKE_COMPILER_IS_GNUCXX AND NOT APPLE)
- SET_TARGET_PROPERTIES(opentrack-tracker-aruco
- PROPERTIES LINK_FLAGS "-Wl,--version-script=${CMAKE_SOURCE_DIR}/facetracknoir/${version-script}-version-script.txt")
- endif()
+ opentrack_library(opentrack-tracker-aruco)
+ target_link_libraries(opentrack-tracker-aruco ${SDK_ARUCO_LIBPATH} ${OpenCV_LIBS})
if(WIN32 AND MSVC)
target_link_libraries(opentrack-tracker-aruco
"${CMAKE_SOURCE_DIR}/dinput/dxguid.lib"
@@ -578,91 +428,54 @@ if(SDK_ARUCO_LIBPATH)
endif()
if(SDK_HATIRE)
- add_library(opentrack-tracker-hatire SHARED ${opentrack-tracker-hatire-c} ${opentrack-tracker-hatire-h} ${opentrack-tracker-hatire-moc} ${opentrack-tracker-hatire-uih} ${opentrack-tracker-hatire-rcc})
- target_link_libraries(opentrack-tracker-hatire ${MY_QT_LIBS})
- install(TARGETS opentrack-tracker-hatire RUNTIME DESTINATION . LIBRARY DESTINATION . )
- if(CMAKE_COMPILER_IS_GNUCXX AND NOT APPLE)
- SET_TARGET_PROPERTIES(opentrack-tracker-hatire
- PROPERTIES LINK_FLAGS "-Wl,--version-script=${CMAKE_SOURCE_DIR}/facetracknoir/${version-script}-version-script.txt")
- endif()
-endif()
-
-if(WIN32)
- target_link_libraries(opentrack-tracker-ht
- "${CMAKE_SOURCE_DIR}/dinput/dxguid.lib"
- "${CMAKE_SOURCE_DIR}/dinput/strmiids.lib"
- uuid)
- target_link_libraries(opentrack-tracker-joystick
- "${CMAKE_SOURCE_DIR}/dinput/dinput8.lib"
- "${CMAKE_SOURCE_DIR}/dinput/dxguid.lib"
- "${CMAKE_SOURCE_DIR}/dinput/strmiids.lib"
- uuid)
-endif()
-
-add_library(opentrack-tracker-pt SHARED ${opentrack-tracker-pt-c} ${opentrack-tracker-pt-h} ${opentrack-tracker-pt-moc} ${opentrack-tracker-pt-uih} ${opentrack-tracker-pt-rcc})
-target_link_libraries(opentrack-tracker-pt ${MY_QT_LIBS} ${OpenCV_LIBS})
-
-if(APPLE)
- SET_TARGET_PROPERTIES(opentrack-tracker-pt PROPERTIES COMPILE_FLAGS "-std=c++11")
+ opentrack_library(opentrack-tracker-hatire)
endif()
-if(CMAKE_COMPILER_IS_GNUCXX AND NOT APPLE)
- SET_TARGET_PROPERTIES(opentrack-tracker-pt
- PROPERTIES LINK_FLAGS "-Wl,--version-script=${CMAKE_SOURCE_DIR}/facetracknoir/${version-script}-version-script.txt")
-endif()
+link_with_dinput8(opentrack-tracker-ht)
+link_with_dinput8(opentrack-tracker-joystick)
+opentrack_library(opentrack-tracker-pt)
+target_link_libraries(opentrack-tracker-pt ${OpenCV_LIBS})
-if(WIN32)
- target_link_libraries(opentrack-tracker-pt
- "${CMAKE_SOURCE_DIR}/dinput/dxguid.lib"
- "${CMAKE_SOURCE_DIR}/dinput/strmiids.lib"
- uuid)
-endif()
+link_with_dinput8(opentrack-tracker-pt)
-add_library(opentrack-tracker-udp SHARED ${opentrack-tracker-udp-c} ${opentrack-tracker-udp-h} ${opentrack-tracker-udp-moc} ${opentrack-tracker-udp-uih} ${opentrack-tracker-udp-rcc})
-target_link_libraries(opentrack-tracker-udp ${MY_QT_LIBS})
-if(CMAKE_COMPILER_IS_GNUCXX AND NOT APPLE)
- SET_TARGET_PROPERTIES(opentrack-tracker-udp
- PROPERTIES LINK_FLAGS "-Wl,--version-script=${CMAKE_SOURCE_DIR}/facetracknoir/${version-script}-version-script.txt")
-endif()
+opentrack_library(opentrack-tracker-udp)
if(SDK_RIFT)
include_directories("${SDK_RIFT}/Include")
include_directories("${SDK_RIFT}/Src")
- add_library(opentrack-tracker-rift SHARED ${opentrack-tracker-rift-c} ${opentrack-tracker-rift-h} ${opentrack-tracker-rift-moc} ${opentrack-tracker-rift-uih} ${opentrack-tracker-rift-rcc})
- target_link_libraries(opentrack-tracker-rift ${MY_QT_LIBS})
- if(MSVC)
- target_link_libraries(opentrack-tracker-rift "${SDK_RIFT}/Lib/Win32/libovr.lib" winmm.lib setupapi.lib)
- set_target_properties(opentrack-tracker-rift PROPERTIES LINK_FLAGS "/NODEFAULTLIB:LIBCMT")
+ set(link-flags)
+ set(c-flags)
+ if(APPLE)
+ set(link-flags "-framework CoreFoundation -framework CoreGraphics -framework IOKit -framework Quartz")
+ set(c-flags "-fno-strict-aliasing")
+ else()
+ if(MSVC)
+ set(link-flags "/NODEFAULTLIB:LIBCMT")
+ else()
+ set(c-flags "-fno-strict-aliasing")
+ endif()
+ endif()
+ opentrack_library(opentrack-tracker-rift LINK "${link-flags}" COMPILE "${c-flags}")
+ if(MSVC)
+ target_link_libraries(opentrack-tracker-rift "${SDK_RIFT}/Lib/Win32/libovr.lib" winmm.lib setupapi.lib)
+ else()
+ if(WIN32)
+ target_link_libraries(opentrack-tracker-rift "${SDK_RIFT}/libLibOVR.a" winmm setupapi)
+ else()
+ if(NOT APPLE)
+ target_link_libraries(opentrack-tracker-rift "${SDK_RIFT}/libLibOVR.a" udev Xinerama)
else()
- if(WIN32)
- target_link_libraries(opentrack-tracker-rift "${SDK_RIFT}/libLibOVR.a" winmm.lib setupapi.lib)
- else()
- if(NOT APPLE)
- target_link_libraries(opentrack-tracker-rift "${SDK_RIFT}/libLibOVR.a" udev Xinerama)
- else()
- target_link_libraries(opentrack-tracker-rift "${SDK_RIFT}/libLibOVR.a")
- endif()
- endif()
+ target_link_libraries(opentrack-tracker-rift "${SDK_RIFT}/libLibOVR.a")
endif()
- if(CMAKE_COMPILER_IS_GNUCXX AND NOT APPLE)
- SET_TARGET_PROPERTIES(opentrack-tracker-rift
- PROPERTIES
- LINK_FLAGS "-Wl,--version-script=${CMAKE_SOURCE_DIR}/facetracknoir/${version-script}-version-script.txt"
- COMPILE_FLAGS "-fno-strict-aliasing"
- )
- endif()
- if(APPLE)
- SET_TARGET_PROPERTIES(opentrack-tracker-rift
- PROPERTIES LINK_FLAGS "-framework CoreFoundation -framework CoreGraphics -framework IOKit -framework Quartz")
endif()
endif()
+endif()
if(SDK_HYDRA)
include_directories("${SDK_HYDRA}/include")
include_directories("${SDK_HYDRA}/include/sixense_utils")
- add_library(opentrack-tracker-hydra SHARED ${opentrack-tracker-hydra-c} ${opentrack-tracker-hydra-h} ${opentrack-tracker-hydra-moc} ${opentrack-tracker-hydra-uih} ${opentrack-tracker-hydra-rcc})
- target_link_libraries(opentrack-tracker-hydra ${MY_QT_LIBS})
+ opentrack_library(opentrack-tracker-hydra)
if(WIN32)
target_link_libraries(opentrack-tracker-hydra
"${SDK_HYDRA}/lib/win32/release_dll/sixense.lib"
@@ -690,10 +503,6 @@ if(SDK_HYDRA)
)
target_link_libraries(opentrack-tracker-hydra "${SDK_HYDRA}/lib/${sixense-plat}${underscore-sixtyfour}/release${underscore-dll}/libsixense${underscore-sixtyfour}.${soext}" "${SDK_HYDRA}/lib/${sixense-plat}${underscore-sixtyfour}/release${underscore-dll}/libsixense_utils${underscore-sixtyfour}.${soext}")
endif()
- if(CMAKE_COMPILER_IS_GNUCXX AND NOT APPLE)
- SET_TARGET_PROPERTIES(opentrack-tracker-hydra
- PROPERTIES LINK_FLAGS "-Wl,--version-script=${CMAKE_SOURCE_DIR}/facetracknoir/${version-script}-version-script.txt")
- endif()
endif()
if(WIN32 AND NOT SDK_CONSOLE_DEBUG)
@@ -709,7 +518,7 @@ if(UNIX OR APPLE)
target_link_libraries(opentrack-qxt-mini X11)
endif()
endif()
-add_executable(opentrack ${opentrack-win32-executable} ${opentrack-bin-c} ${opentrack-bin-h} ${opentrack-bin-moc} ${opentrack-bin-uih} ${opentrack-bin-rcc})
+add_executable(opentrack ${opentrack-win32-executable} ${opentrack-bin-c} ${opentrack-bin-uih} ${opentrack-bin-rcc})
set_target_properties(opentrack PROPERTIES COMPILE_DEFINITIONS OPENTRACK_VERSION=\"${OPENTRACK__COMMIT}\")
set(OPENTRACK_COMMIT_VERSION \"${OPENTRACK__COMMIT}\")
configure_file("${CMAKE_SOURCE_DIR}/opentrack-version.h" "${CMAKE_BINARY_DIR}/opentrack-version.h" @ONLY NEWLINE_STYLE UNIX)
@@ -718,7 +527,7 @@ if(APPLE)
SET_TARGET_PROPERTIES(opentrack-qxt-mini PROPERTIES LINK_FLAGS "-framework Carbon -framework CoreFoundation")
endif()
-add_library(opentrack-api SHARED ${opentrack-lib-c} ${opentrack-lib-h} ${opentrack-lib-moc})
+add_library(opentrack-api SHARED ${opentrack-lib-c})
target_link_libraries(opentrack-api ${MY_QT_LIBS})
if(CMAKE_COMPILER_IS_GNUCXX AND NOT APPLE)
SET_TARGET_PROPERTIES(opentrack-api PROPERTIES
@@ -740,14 +549,8 @@ if(UNIX OR APPLE)
install(TARGETS opentrack-qxt-mini RUNTIME DESTINATION . LIBRARY DESTINATION . )
endif()
-if(WIN32)
- target_link_libraries(opentrack "${CMAKE_SOURCE_DIR}/dinput/dinput8.lib"
- "${CMAKE_SOURCE_DIR}/dinput/dxguid.lib"
- "${CMAKE_SOURCE_DIR}/dinput/strmiids.lib"
- winmm
- uuid
- )
-endif()
+link_with_dinput8(opentrack)
+
if(MSVC)
SET_TARGET_PROPERTIES(opentrack PROPERTIES LINK_FLAGS "/ENTRY:mainCRTStartup")
endif()
@@ -773,11 +576,13 @@ install(FILES "${CMAKE_SOURCE_DIR}/README.md" DESTINATION .)
if(SDK_XPLANE)
install(TARGETS opentrack-xplane-plugin RUNTIME DESTINATION . LIBRARY DESTINATION . )
endif()
+
if(WIN32)
install(DIRECTORY "${CMAKE_SOURCE_DIR}/bin/tracker-ht" DESTINATION .)
install(TARGETS freetrackclient RUNTIME DESTINATION . LIBRARY DESTINATION . )
endif()
- install(DIRECTORY "${CMAKE_SOURCE_DIR}/3rdparty-notices" DESTINATION .)
+
+install(DIRECTORY "${CMAKE_SOURCE_DIR}/3rdparty-notices" DESTINATION .)
install(FILES "${CMAKE_SOURCE_DIR}/bin/NPClient.dll" "${CMAKE_SOURCE_DIR}/bin/NPClient64.dll" "${CMAKE_SOURCE_DIR}/bin/TrackIR.exe" DESTINATION .)
install(DIRECTORY "${CMAKE_SOURCE_DIR}/bin/settings" "${CMAKE_SOURCE_DIR}/facetracknoir/clientfiles" DESTINATION .)
@@ -785,69 +590,24 @@ install(DIRECTORY "${CMAKE_SOURCE_DIR}/bin/settings" "${CMAKE_SOURCE_DIR}/facetr
if(NOT WIN32 AND SDK_WINE_PREFIX)
install(FILES "${CMAKE_BINARY_DIR}/opentrack-wrapper-wine.exe.so"
DESTINATION .)
- install(TARGETS opentrack-proto-wine RUNTIME DESTINATION . LIBRARY DESTINATION . )
-endif()
-
-install(TARGETS opentrack-tracker-pt RUNTIME DESTINATION . LIBRARY DESTINATION . )
-
-if(SDK_ARUCO_LIBPATH)
- install(TARGETS opentrack-tracker-aruco RUNTIME DESTINATION . LIBRARY DESTINATION . )
endif()
install(TARGETS
- opentrack-proto-fgfs
- opentrack-proto-udp
opentrack-api
opentrack-compat
opentrack-csv
opentrack-pose-widget
opentrack-spline-widget
- opentrack-filter-accela
- opentrack-filter-kalman
- opentrack-filter-ewma
- opentrack-tracker-ht
- opentrack-tracker-udp
RUNTIME DESTINATION . LIBRARY DESTINATION . )
-install(TARGETS
- opentrack
- DESTINATION .
-)
-
-if(WIN32)
- install(TARGETS opentrack-tracker-joystick RUNTIME DESTINATION . LIBRARY DESTINATION . )
-endif()
+install(TARGETS opentrack DESTINATION .)
-if(WIN32 AND SDK_VJOY)
- install(TARGETS opentrack-proto-vjoy RUNTIME DESTINATION . LIBRARY DESTINATION . )
+if(SDK_VJOY)
install(FILES "${SDK_VJOY}/VJoy.dll" DESTINATION .)
endif()
-if(SDK_RIFT)
- install(TARGETS opentrack-tracker-rift RUNTIME DESTINATION . LIBRARY DESTINATION . )
-endif()
-
-if(SDK_HYDRA)
- install(
- TARGETS opentrack-tracker-hydra
- RUNTIME DESTINATION . LIBRARY DESTINATION .
- )
-endif()
-
if(WIN32)
install(FILES "${CMAKE_SOURCE_DIR}/bin/cleye.config" DESTINATION .)
- if(SDK_SIMCONNECT)
- install(TARGETS opentrack-proto-simconnect RUNTIME DESTINATION . LIBRARY DESTINATION . )
- endif()
- install(TARGETS
- opentrack-proto-freetrack
- opentrack-proto-win32-mouse
- RUNTIME DESTINATION . LIBRARY DESTINATION .
- )
- if(SDK_FSUIPC)
- install(TARGETS opentrack-proto-fsuipc RUNTIME DESTINATION . LIBRARY DESTINATION .)
- endif()
-
endif()
if(MSVC)
diff --git a/FTNoIR_Tracker_PT/FTNoIR_PT_Controls.ui b/FTNoIR_Tracker_PT/FTNoIR_PT_Controls.ui
index 9ad4f83c..6cd17e8d 100644
--- a/FTNoIR_Tracker_PT/FTNoIR_PT_Controls.ui
+++ b/FTNoIR_Tracker_PT/FTNoIR_PT_Controls.ui
@@ -9,7 +9,7 @@
<rect>
<x>0</x>
<y>0</y>
- <width>458</width>
+ <width>459</width>
<height>590</height>
</rect>
</property>
@@ -69,12 +69,40 @@
<layout class="QVBoxLayout" name="verticalLayout_6">
<item>
<layout class="QGridLayout" name="gridLayout">
- <item row="1" column="0">
+ <item row="1" column="3">
+ <layout class="QHBoxLayout" name="horizontalLayout_12">
+ <item>
+ <widget class="QSpinBox" name="reset_spin">
+ <property name="toolTip">
+ <string>Time until automatic reset of tracker's internal state when no valid tracking result is found</string>
+ </property>
+ <property name="maximum">
+ <number>9999</number>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="label_42">
+ <property name="text">
+ <string>ms</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item row="2" column="3">
<widget class="QCheckBox" name="dynpose_check">
<property name="toolTip">
<string/>
</property>
<property name="text">
+ <string/>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="2">
+ <widget class="QLabel" name="label_17">
+ <property name="text">
<string>Dynamic Pose Resolution</string>
</property>
</widget>
@@ -89,30 +117,6 @@
</property>
</widget>
</item>
- <item row="0" column="3">
- <layout class="QHBoxLayout" name="horizontalLayout_11">
- <item>
- <widget class="QSpinBox" name="sleep_spin">
- <property name="toolTip">
- <string>Time the tracker thread sleeps after each processed frame</string>
- </property>
- <property name="suffix">
- <string/>
- </property>
- <property name="maximum">
- <number>9999</number>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QLabel" name="label_40">
- <property name="text">
- <string>ms</string>
- </property>
- </widget>
- </item>
- </layout>
- </item>
<item row="1" column="2">
<widget class="QLabel" name="label_43">
<property name="text">
@@ -123,12 +127,15 @@
</property>
</widget>
</item>
- <item row="1" column="3">
- <layout class="QHBoxLayout" name="horizontalLayout_12">
+ <item row="0" column="3">
+ <layout class="QHBoxLayout" name="horizontalLayout_11">
<item>
- <widget class="QSpinBox" name="reset_spin">
+ <widget class="QSpinBox" name="sleep_spin">
<property name="toolTip">
- <string>Time until automatic reset of tracker's internal state when no valid tracking result is found</string>
+ <string>Time the tracker thread sleeps after each processed frame</string>
+ </property>
+ <property name="suffix">
+ <string/>
</property>
<property name="maximum">
<number>9999</number>
@@ -136,7 +143,7 @@
</widget>
</item>
<item>
- <widget class="QLabel" name="label_42">
+ <widget class="QLabel" name="label_40">
<property name="text">
<string>ms</string>
</property>
@@ -144,43 +151,7 @@
</item>
</layout>
</item>
- <item row="0" column="0">
- <widget class="QCheckBox" name="videowidget_check">
- <property name="toolTip">
- <string>Whether to update the content of the VideoWidget</string>
- </property>
- <property name="text">
- <string>Show VideoWidget</string>
- </property>
- </widget>
- </item>
- <item row="1" column="1">
- <spacer name="horizontalSpacer_7">
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>30</width>
- <height>20</height>
- </size>
- </property>
- </spacer>
- </item>
- <item row="0" column="1">
- <spacer name="horizontalSpacer_11">
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>30</width>
- <height>20</height>
- </size>
- </property>
- </spacer>
- </item>
- <item row="2" column="0">
+ <item row="3" column="3">
<widget class="QPushButton" name="reset_button">
<property name="enabled">
<bool>false</bool>
@@ -635,40 +606,7 @@
</layout>
</item>
<item>
- <layout class="QHBoxLayout" name="horizontalLayout_7">
- <item>
- <widget class="QPushButton" name="videowidget_button">
- <property name="enabled">
- <bool>false</bool>
- </property>
- <property name="minimumSize">
- <size>
- <width>130</width>
- <height>0</height>
- </size>
- </property>
- <property name="locale">
- <locale language="English" country="UnitedStates"/>
- </property>
- <property name="text">
- <string>VideoWidget</string>
- </property>
- </widget>
- </item>
- <item>
- <spacer name="horizontalSpacer_12">
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>0</width>
- <height>20</height>
- </size>
- </property>
- </spacer>
- </item>
- </layout>
+ <layout class="QHBoxLayout" name="horizontalLayout_7"/>
</item>
</layout>
</widget>
@@ -848,38 +786,36 @@
</item>
</layout>
</item>
-
- <item>
- <layout class="QHBoxLayout" name="horizontalLayout_secondary">
- <item>
- <widget class="QLabel" name="label_secondary">
- <property name="text">
- <string>Hysteresis</string>
- </property>
- <property name="buddy">
- <cstring>threshold_secondary_slider</cstring>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QSlider" name="threshold_secondary_slider">
- <property name="toolTip">
- <string>Per pixel hysteresis width (leave left if there is little difference between dot and non-dot, move right for increased stability against pixel noise)</string>
- </property>
- <property name="maximum">
- <number>255</number>
- </property>
- <property name="value">
- <number>100</number>
- </property>
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
- </property>
- </widget>
- </item>
- </layout>
- </item>
-
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout_secondary">
+ <item>
+ <widget class="QLabel" name="label_secondary">
+ <property name="text">
+ <string>Hysteresis</string>
+ </property>
+ <property name="buddy">
+ <cstring>threshold_secondary_slider</cstring>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QSlider" name="threshold_secondary_slider">
+ <property name="toolTip">
+ <string>Per pixel hysteresis width (leave left if there is little difference between dot and non-dot, move right for increased stability against pixel noise)</string>
+ </property>
+ <property name="maximum">
+ <number>255</number>
+ </property>
+ <property name="value">
+ <number>100</number>
+ </property>
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
@@ -1778,6 +1714,13 @@
<item>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
+ <widget class="QPushButton" name="btnApply">
+ <property name="text">
+ <string>Apply</string>
+ </property>
+ </widget>
+ </item>
+ <item>
<spacer name="horizontalSpacer_6">
<property name="orientation">
<enum>Qt::Horizontal</enum>
@@ -1816,11 +1759,8 @@
</widget>
<tabstops>
<tabstop>tabWidget</tabstop>
- <tabstop>videowidget_check</tabstop>
<tabstop>sleep_spin</tabstop>
- <tabstop>dynpose_check</tabstop>
<tabstop>reset_spin</tabstop>
- <tabstop>reset_button</tabstop>
<tabstop>chkEnableRoll</tabstop>
<tabstop>chkEnablePitch</tabstop>
<tabstop>chkEnableYaw</tabstop>
diff --git a/FTNoIR_Tracker_PT/FTNoIR_Tracker_PT.rc b/FTNoIR_Tracker_PT/FTNoIR_Tracker_PT.rc
deleted file mode 100644
index 11c5d52f..00000000
--- a/FTNoIR_Tracker_PT/FTNoIR_Tracker_PT.rc
+++ /dev/null
@@ -1,61 +0,0 @@
-// Microsoft Visual C++ generated resource script.
-//
-#include "resource.h"
-
-#define APSTUDIO_READONLY_SYMBOLS
-/////////////////////////////////////////////////////////////////////////////
-//
-// Generated from the TEXTINCLUDE 2 resource.
-//
-#include "afxres.h"
-
-/////////////////////////////////////////////////////////////////////////////
-#undef APSTUDIO_READONLY_SYMBOLS
-
-/////////////////////////////////////////////////////////////////////////////
-// English (U.S.) resources
-
-#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
-LANGUAGE 9, 1
-#pragma code_page(1252)
-
-#ifdef APSTUDIO_INVOKED
-/////////////////////////////////////////////////////////////////////////////
-//
-// TEXTINCLUDE
-//
-
-1 TEXTINCLUDE
-BEGIN
- "resource.h\0"
-END
-
-2 TEXTINCLUDE
-BEGIN
- "#include ""afxres.h""\r\n"
- "\0"
-END
-
-3 TEXTINCLUDE
-BEGIN
- "\r\n"
- "\0"
-END
-
-#endif // APSTUDIO_INVOKED
-
-#endif // English (U.S.) resources
-/////////////////////////////////////////////////////////////////////////////
-
-
-
-#ifndef APSTUDIO_INVOKED
-/////////////////////////////////////////////////////////////////////////////
-//
-// Generated from the TEXTINCLUDE 3 resource.
-//
-
-
-/////////////////////////////////////////////////////////////////////////////
-#endif // not APSTUDIO_INVOKED
-
diff --git a/FTNoIR_Tracker_PT/FTNoIR_Tracker_PT_vc10.vcxproj b/FTNoIR_Tracker_PT/FTNoIR_Tracker_PT_vc10.vcxproj
deleted file mode 100644
index b777077b..00000000
--- a/FTNoIR_Tracker_PT/FTNoIR_Tracker_PT_vc10.vcxproj
+++ /dev/null
@@ -1,212 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
- <ItemGroup Label="ProjectConfigurations">
- <ProjectConfiguration Include="Debug|Win32">
- <Configuration>Debug</Configuration>
- <Platform>Win32</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Release|Win32">
- <Configuration>Release</Configuration>
- <Platform>Win32</Platform>
- </ProjectConfiguration>
- <ProjectConfiguration Include="Template|Win32">
- <Configuration>Template</Configuration>
- <Platform>Win32</Platform>
- </ProjectConfiguration>
- </ItemGroup>
- <PropertyGroup Label="Globals">
- <ProjectName>FTNoIR_Tracker_PT</ProjectName>
- <ProjectGuid>{7A2A2560-9253-4CC8-A9D5-4B9D9C224D9D}</ProjectGuid>
- <RootNamespace>FTNoIR_Tracker_PT</RootNamespace>
- <Keyword>Qt4VSv1.0</Keyword>
- </PropertyGroup>
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
- <ConfigurationType>DynamicLibrary</ConfigurationType>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
- <ConfigurationType>DynamicLibrary</ConfigurationType>
- </PropertyGroup>
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
- <ImportGroup Label="ExtensionSettings">
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- </ImportGroup>
- <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
- <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
- </ImportGroup>
- <PropertyGroup Label="UserMacros" />
- <PropertyGroup>
- <_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
- <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)\bin\</OutDir>
- <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)\$(Configuration)\</IntDir>
- <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(SolutionDir)/bin_dbg\</OutDir>
- <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(SolutionDir)\$(Configuration)\</IntDir>
- <CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
- <CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
- <CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
- <CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
- <CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
- <CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
- <CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Template|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
- <CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Template|Win32'" />
- <CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Template|Win32'" />
- </PropertyGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
- <ClCompile>
- <Optimization>MaxSpeed</Optimization>
- <AdditionalIncludeDirectories>.;.\GeneratedFiles;.\GeneratedFiles\$(Configuration);$(QTDIR)\include;$(QTDIR)\include\QtCore;$(QTDIR)\include\QtGui;$(OPENCV_DIR)\include;$(BOOST_DIR);$(QTDIR)\include\QtOpenGL;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>UNICODE;WIN32;QT_DLL;QT_NO_DEBUG;NDEBUG;QT_CORE_LIB;QT_GUI_LIB;FTNOIR_TRACKER_BASE_LIB;QT_OPENGL_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
- <TreatWChar_tAsBuiltInType>false</TreatWChar_tAsBuiltInType>
- <DebugInformationFormat>
- </DebugInformationFormat>
- </ClCompile>
- <Link>
- <AdditionalDependencies>qtmain.lib;QtCore4.lib;QtGui4.lib;QtOpenGL4.lib;opengl32.lib;glu32.lib;opencv_core242.lib;opencv_imgproc242.lib;opencv_calib3d242.lib;videoInput_vc10.lib;%(AdditionalDependencies)</AdditionalDependencies>
- <OutputFile>$(OutDir)$(ProjectName).dll</OutputFile>
- <AdditionalLibraryDirectories>$(QTDIR)\lib;$(OPENCV_DIR)\x86\vc10\lib;$(ProjectDir)\videoInput;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
- <IgnoreSpecificDefaultLibraries>atlthunk.lib;libcmt;%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
- <GenerateDebugInformation>false</GenerateDebugInformation>
- <SubSystem>Windows</SubSystem>
- </Link>
- </ItemDefinitionGroup>
- <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
- <ClCompile>
- <Optimization>Disabled</Optimization>
- <AdditionalIncludeDirectories>.;.\GeneratedFiles;.\GeneratedFiles\$(Configuration);$(QTDIR)\include;$(QTDIR)\include\QtCore;$(QTDIR)\include\QtGui;$(OPENCV_DIR)\include;$(BOOST_DIR);$(QTDIR)\include\QtOpenGL;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
- <PreprocessorDefinitions>UNICODE;WIN32;QT_DLL;QT_CORE_LIB;QT_GUI_LIB;FTNOIR_TRACKER_BASE_LIB;QT_OPENGL_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
- <TreatWChar_tAsBuiltInType>false</TreatWChar_tAsBuiltInType>
- <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
- </ClCompile>
- <Link>
- <AdditionalDependencies>qtmaind.lib;QtCored4.lib;QtGuid4.lib;QtOpenGLd4.lib;opengl32.lib;glu32.lib;opencv_core242d.lib;opencv_imgproc242d.lib;opencv_calib3d242d.lib;videoInput_vc10.lib;%(AdditionalDependencies)</AdditionalDependencies>
- <OutputFile>$(OutDir)$(ProjectName).dll</OutputFile>
- <AdditionalLibraryDirectories>$(QTDIR)\lib;$(OPENCV_DIR)\x86\vc10\lib;$(ProjectDir)\videoInput;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
- <IgnoreSpecificDefaultLibraries>atlthunk.lib;libcmt;%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
- <GenerateDebugInformation>true</GenerateDebugInformation>
- <SubSystem>Windows</SubSystem>
- </Link>
- </ItemDefinitionGroup>
- <ItemGroup>
- <ClCompile Include="camera.cpp" />
- <ClCompile Include="frame_observer.cpp" />
- <ClCompile Include="ftnoir_tracker_pt.cpp" />
- <ClCompile Include="ftnoir_tracker_pt_dialog.cpp" />
- <ClCompile Include="ftnoir_tracker_pt_dll.cpp" />
- <ClCompile Include="ftnoir_tracker_pt_settings.cpp" />
- <ClCompile Include="point_extractor.cpp" />
- <ClCompile Include="point_tracker.cpp" />
- <ClCompile Include="timer.cpp" />
- <ClCompile Include="trans_calib.cpp" />
- <ClCompile Include="video_widget.cpp" />
- <ClCompile Include="GeneratedFiles\qrc_ftnoir_tracker_pt.cpp">
- <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
- </PrecompiledHeader>
- <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
- </PrecompiledHeader>
- </ClCompile>
- <ClCompile Include="GeneratedFiles\Release\moc_ftnoir_tracker_pt_dialog.cpp">
- <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
- <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Template|Win32'">true</ExcludedFromBuild>
- </ClCompile>
- <ClCompile Include="GeneratedFiles\Release\moc_video_widget.cpp">
- <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
- <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Template|Win32'">true</ExcludedFromBuild>
- </ClCompile>
- <ClCompile Include="GeneratedFiles\Debug\moc_ftnoir_tracker_pt_dialog.cpp">
- <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
- <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Template|Win32'">true</ExcludedFromBuild>
- </ClCompile>
- <ClCompile Include="GeneratedFiles\Debug\moc_video_widget.cpp">
- <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
- <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Template|Win32'">true</ExcludedFromBuild>
- </ClCompile>
- </ItemGroup>
- <ItemGroup>
- <ClInclude Include="camera.h" />
- <ClInclude Include="..\FTNoIR_Tracker_Base\ftnoir_tracker_base.h" />
- <ClInclude Include="..\FTNoIR_Tracker_Base\ftnoir_tracker_base_global.h" />
- <CustomBuild Include="ftnoir_tracker_pt.h">
- <Message Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
- </Message>
- <Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
- </Command>
- <AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(AdditionalInputs)</AdditionalInputs>
- <Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(Outputs)</Outputs>
- <Message Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
- </Message>
- <Command Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
- </Command>
- <AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(AdditionalInputs)</AdditionalInputs>
- <Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(Outputs)</Outputs>
- </CustomBuild>
- <CustomBuild Include="ftnoir_tracker_pt_dialog.h">
- <Message Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Moc%27ing ftnoir_tracker_pt_dialog.h...</Message>
- <Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">"$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" -DUNICODE -DWIN32 -DQT_DLL -DQT_CORE_LIB -DQT_GUI_LIB -DFTNOIR_TRACKER_BASE_LIB -DQT_OPENGL_LIB -D_WINDLL "-I." "-I.\GeneratedFiles" "-I.\GeneratedFiles\$(Configuration)\." "-I$(QTDIR)\include" "-I$(QTDIR)\include\QtCore" "-I$(QTDIR)\include\QtGui" "-I$(OPENCV_DIR)\include" "-I$(BOOST_DIR)\." "-I$(QTDIR)\include\QtOpenGL"</Command>
- <AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(QTDIR)\bin\moc.exe;%(FullPath);%(AdditionalInputs)</AdditionalInputs>
- <Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">.\GeneratedFiles\$(Configuration)\moc_%(Filename).cpp;%(Outputs)</Outputs>
- <Message Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Moc%27ing ftnoir_tracker_pt_dialog.h...</Message>
- <Command Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">"$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" -DUNICODE -DWIN32 -DQT_DLL -DQT_NO_DEBUG -DNDEBUG -DQT_CORE_LIB -DQT_GUI_LIB -DFTNOIR_TRACKER_BASE_LIB -DQT_OPENGL_LIB -D_WINDLL "-I." "-I.\GeneratedFiles" "-I.\GeneratedFiles\$(Configuration)\." "-I$(QTDIR)\include" "-I$(QTDIR)\include\QtCore" "-I$(QTDIR)\include\QtGui" "-I$(OPENCV_DIR)\include" "-I$(BOOST_DIR)\." "-I$(QTDIR)\include\QtOpenGL"</Command>
- <AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(QTDIR)\bin\moc.exe;%(FullPath);%(AdditionalInputs)</AdditionalInputs>
- <Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">.\GeneratedFiles\$(Configuration)\moc_%(Filename).cpp;%(Outputs)</Outputs>
- </CustomBuild>
- <ClInclude Include="frame_observer.h" />
- <ClInclude Include="ftnoir_tracker_pt_settings.h" />
- <ClInclude Include="point_extractor.h" />
- <ClInclude Include="point_tracker.h" />
- <ClInclude Include="resource.h" />
- <ClInclude Include="timer.h" />
- <ClInclude Include="trans_calib.h" />
- <CustomBuild Include="video_widget.h">
- <Message Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Moc%27ing video_widget.h...</Message>
- <Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">"$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" -DUNICODE -DWIN32 -DQT_DLL -DQT_CORE_LIB -DQT_GUI_LIB -DFTNOIR_TRACKER_BASE_LIB -DQT_OPENGL_LIB -D_WINDLL "-I." "-I.\GeneratedFiles" "-I.\GeneratedFiles\$(Configuration)\." "-I$(QTDIR)\include" "-I$(QTDIR)\include\QtCore" "-I$(QTDIR)\include\QtGui" "-I$(OPENCV_DIR)\include" "-I$(BOOST_DIR)\." "-I$(QTDIR)\include\QtOpenGL"</Command>
- <AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(QTDIR)\bin\moc.exe;%(FullPath);%(AdditionalInputs)</AdditionalInputs>
- <Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">.\GeneratedFiles\$(Configuration)\moc_%(Filename).cpp;%(Outputs)</Outputs>
- <Message Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Moc%27ing video_widget.h...</Message>
- <Command Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">"$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" -DUNICODE -DWIN32 -DQT_DLL -DQT_NO_DEBUG -DNDEBUG -DQT_CORE_LIB -DQT_GUI_LIB -DFTNOIR_TRACKER_BASE_LIB -DQT_OPENGL_LIB -D_WINDLL "-I." "-I.\GeneratedFiles" "-I.\GeneratedFiles\$(Configuration)\." "-I$(QTDIR)\include" "-I$(QTDIR)\include\QtCore" "-I$(QTDIR)\include\QtGui" "-I$(OPENCV_DIR)\include" "-I$(BOOST_DIR)\." "-I$(QTDIR)\include\QtOpenGL"</Command>
- <AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(QTDIR)\bin\moc.exe;%(FullPath);%(AdditionalInputs)</AdditionalInputs>
- <Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">.\GeneratedFiles\$(Configuration)\moc_%(Filename).cpp;%(Outputs)</Outputs>
- </CustomBuild>
- <ClInclude Include="GeneratedFiles\ui_FTNoIR_PT_Controls.h" />
- </ItemGroup>
- <ItemGroup>
- <CustomBuild Include="FTNoIR_PT_Controls.ui">
- <Message Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Uic%27ing %(Filename)%(Extension)...</Message>
- <Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">"$(QTDIR)\bin\uic.exe" -o ".\GeneratedFiles\ui_%(Filename).h" "%(FullPath)"
-</Command>
- <AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(QTDIR)\bin\uic.exe;%(AdditionalInputs)</AdditionalInputs>
- <Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">.\GeneratedFiles\ui_%(Filename).h;%(Outputs)</Outputs>
- <Message Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Uic%27ing %(Filename)%(Extension)...</Message>
- <Command Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">"$(QTDIR)\bin\uic.exe" -o ".\GeneratedFiles\ui_%(Filename).h" "%(FullPath)"
-</Command>
- <AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(QTDIR)\bin\uic.exe;%(AdditionalInputs)</AdditionalInputs>
- <Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">.\GeneratedFiles\ui_%(Filename).h;%(Outputs)</Outputs>
- </CustomBuild>
- <CustomBuild Include="ftnoir_tracker_pt.qrc">
- <Message Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Rcc%27ing %(Filename)%(Extension)...</Message>
- <Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">"$(QTDIR)\bin\rcc.exe" -name "%(Filename)" -no-compress "%(FullPath)" -o .\GeneratedFiles\qrc_%(Filename).cpp
-</Command>
- <AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(FullPath);.\Resources\icon.ico;.\Resources\Logo_IR.png;%(AdditionalInputs)</AdditionalInputs>
- <Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">.\GeneratedFiles\qrc_%(Filename).cpp;%(Outputs)</Outputs>
- <Message Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Rcc%27ing %(Filename)%(Extension)...</Message>
- <Command Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">"$(QTDIR)\bin\rcc.exe" -name "%(Filename)" -no-compress "%(FullPath)" -o .\GeneratedFiles\qrc_%(Filename).cpp
-</Command>
- <AdditionalInputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">%(FullPath);.\Resources\icon.ico;.\Resources\Logo_IR.png;%(AdditionalInputs)</AdditionalInputs>
- <Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">.\GeneratedFiles\qrc_%(Filename).cpp;%(Outputs)</Outputs>
- </CustomBuild>
- </ItemGroup>
- <ItemGroup>
- <ResourceCompile Include="FTNoIR_Tracker_PT.rc" />
- </ItemGroup>
- <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
- <ImportGroup Label="ExtensionTargets">
- </ImportGroup>
- <ProjectExtensions>
- <VisualStudio>
- <UserProperties lreleaseOptions="" lupdateOnBuild="0" lupdateOptions="" MocDir=".\GeneratedFiles\$(ConfigurationName)" MocOptions="" QtVersion_x0020_Win32="$(DefaultQtVersion)" RccDir=".\GeneratedFiles" UicDir=".\GeneratedFiles" />
- </VisualStudio>
- </ProjectExtensions>
-</Project> \ No newline at end of file
diff --git a/FTNoIR_Tracker_PT/camera.h b/FTNoIR_Tracker_PT/camera.h
index 78fe8dfb..ea68c387 100644
--- a/FTNoIR_Tracker_PT/camera.h
+++ b/FTNoIR_Tracker_PT/camera.h
@@ -69,13 +69,13 @@ protected:
virtual void _set_fps() = 0;
virtual void _set_res() = 0;
- bool active;
+ float dt_valid;
+ float dt_mean;
int desired_index;
int active_index;
+ bool active;
CamInfo cam_info;
CamInfo cam_desired;
- float dt_valid;
- float dt_mean;
};
@@ -128,9 +128,9 @@ protected:
enum RotationType
{
- CLOCKWISE = -1,
- ZERO = 0,
- COUNTER_CLOCKWISE = 1
+ CLOCKWISE = 0,
+ ZERO = 1,
+ COUNTER_CLOCKWISE = 2
};
// ----------------------------------------------------------------------------
diff --git a/FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp b/FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp
index e3af446f..25a19ee7 100644
--- a/FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp
+++ b/FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp
@@ -23,8 +23,7 @@ const float deg2rad = 1.0/rad2deg;
//-----------------------------------------------------------------------------
Tracker::Tracker()
- : frame_count(0),
- commands(0),
+ : commands(0),
video_widget(NULL),
video_frame(NULL),
tracking_valid(false)
@@ -38,9 +37,10 @@ Tracker::~Tracker()
// terminate tracker thread
set_command(ABORT);
wait();
- // destroy video widget
- show_video_widget = false;
- update_show_video_widget();
+ s.video_widget = false;
+ delete video_widget;
+ video_widget = NULL;
+ if (video_frame->layout()) delete video_frame->layout();
}
void Tracker::set_command(Command command)
@@ -86,10 +86,7 @@ void Tracker::run()
frame = frame_rotation.rotate_frame(frame);
const std::vector<cv::Vec2f>& points = point_extractor.extract_points(frame, dt, has_observers());
tracking_valid = point_tracker.track(points, camera.get_info().f, dt);
- frame_count++;
-#ifdef OPENTRACK_API
video_widget->update_image(frame.clone());
-#endif
}
#ifdef PT_PERF_LOG
log_stream<<"dt: "<<dt;
@@ -97,45 +94,39 @@ void Tracker::run()
log_stream<<"\n";
#endif
}
- msleep(sleep_time);
+ msleep(s.sleep_time);
}
qDebug()<<"Tracker:: Thread stopping";
}
-void Tracker::apply(const TrackerSettings& settings)
+void Tracker::apply(settings& s)
{
qDebug()<<"Tracker:: Applying settings";
QMutexLocker lock(&mutex);
- camera.set_device_index(settings.cam_index);
- camera.set_res(settings.cam_res_x, settings.cam_res_y);
- camera.set_fps(settings.cam_fps);
- camera.set_f(settings.cam_f);
- frame_rotation.rotation = static_cast<RotationType>(settings.cam_roll);
- point_extractor.threshold_val = settings.threshold;
- point_extractor.threshold_secondary_val = settings.threshold_secondary;
- point_extractor.min_size = settings.min_point_size;
- point_extractor.max_size = settings.max_point_size;
- point_tracker.point_model = boost::shared_ptr<PointModel>(new PointModel(settings.M01, settings.M02));
- point_tracker.dynamic_pose_resolution = settings.dyn_pose_res;
- sleep_time = settings.sleep_time;
- point_tracker.dt_reset = settings.reset_time / 1000.0;
- show_video_widget = settings.video_widget;
- update_show_video_widget();
- bEnableRoll = settings.bEnableRoll;
- bEnablePitch = settings.bEnablePitch;
- bEnableYaw = settings.bEnableYaw;
- bEnableX = settings.bEnableX;
- bEnableY = settings.bEnableY;
- bEnableZ = settings.bEnableZ;
-
- t_MH = settings.t_MH;
- R_GC = Matx33f( cos(deg2rad*settings.cam_yaw), 0, sin(deg2rad*settings.cam_yaw),
+ camera.set_device_index(s.cam_index);
+ camera.set_res(s.cam_res_x, s.cam_res_y);
+ camera.set_fps(s.cam_fps);
+ camera.set_f(s.cam_f);
+ frame_rotation.rotation = static_cast<RotationType>(static_cast<int>(s.cam_roll));
+ point_extractor.threshold_val = s.threshold;
+ point_extractor.threshold_secondary_val = s.threshold_secondary;
+ point_extractor.min_size = s.min_point_size;
+ point_extractor.max_size = s.max_point_size;
+ {
+ cv::Vec3f M01(s.m01_x, s.m01_y, s.m01_z);
+ cv::Vec3f M02(s.m02_x, s.m02_y, s.m02_z);
+ point_tracker.point_model = boost::shared_ptr<PointModel>(new PointModel(M01, M02));
+ }
+ point_tracker.dynamic_pose_resolution = s.dyn_pose_res;
+ point_tracker.dt_reset = s.reset_time / 1000.0;
+ t_MH = cv::Vec3f(s.t_MH_x, s.t_MH_y, s.t_MH_z);
+ R_GC = Matx33f( cos(deg2rad*s.cam_yaw), 0, sin(deg2rad*s.cam_yaw),
0, 1, 0,
- -sin(deg2rad*settings.cam_yaw), 0, cos(deg2rad*settings.cam_yaw));
+ -sin(deg2rad*s.cam_yaw), 0, cos(deg2rad*s.cam_yaw));
R_GC = R_GC * Matx33f( 1, 0, 0,
- 0, cos(deg2rad*settings.cam_pitch), sin(deg2rad*settings.cam_pitch),
- 0, -sin(deg2rad*settings.cam_pitch), cos(deg2rad*settings.cam_pitch));
+ 0, cos(deg2rad*s.cam_pitch), sin(deg2rad*s.cam_pitch),
+ 0, -sin(deg2rad*s.cam_pitch), cos(deg2rad*s.cam_pitch));
FrameTrafo X_MH(Matx33f::eye(), t_MH);
X_GH_0 = R_GC * X_MH;
@@ -169,58 +160,27 @@ bool Tracker::get_frame_and_points(cv::Mat& frame_copy, boost::shared_ptr< std::
return true;
}
-void Tracker::update_show_video_widget()
-{
- if (!show_video_widget && video_widget) {
- delete video_widget;
- video_widget = NULL;
- if (video_frame->layout()) delete video_frame->layout();
- }
- else if (video_frame && show_video_widget && !video_widget)
- {
- const int VIDEO_FRAME_WIDTH = 320;
- const int VIDEO_FRAME_HEIGHT = 240;
- video_widget = new PTVideoWidget(video_frame, this);
- QHBoxLayout* video_layout = new QHBoxLayout();
- video_layout->setContentsMargins(0, 0, 0, 0);
- video_layout->addWidget(video_widget);
- video_frame->setLayout(video_layout);
- video_widget->resize(VIDEO_FRAME_WIDTH, VIDEO_FRAME_HEIGHT);
- }
-}
-
-//-----------------------------------------------------------------------------
-// ITracker interface
-void Tracker::Initialize(QFrame *video_frame)
-{
- qDebug("Tracker::Initialize");
- // setup video frame
- this->video_frame = video_frame;
- video_frame->setAttribute(Qt::WA_NativeWindow);
- video_frame->show();
- update_show_video_widget();
- TrackerSettings settings;
- settings.load_ini();
- camera.start();
- apply(settings);
- start();
-}
-
void Tracker::refreshVideo()
{
if (video_widget) video_widget->update_frame_and_points();
}
-#ifdef OPENTRACK_API
void Tracker::StartTracker(QFrame *parent_window)
-#else
-void Tracker::StartTracker(HWND parent_window)
-#endif
{
-#ifdef OPENTRACK_API
- Initialize(parent_window);
-#endif
- reset_command(PAUSE);
+ this->video_frame = parent_window;
+ video_frame->setAttribute(Qt::WA_NativeWindow);
+ video_frame->show();
+ apply(s);
+ video_widget = new PTVideoWidget(video_frame, this);
+ QHBoxLayout* video_layout = new QHBoxLayout(parent_window);
+ video_layout->setContentsMargins(0, 0, 0, 0);
+ video_layout->addWidget(video_widget);
+ video_frame->setLayout(video_layout);
+ video_widget->resize(video_frame->width(), video_frame->height());
+ start();
+ camera.start();
+ start();
+ reset_command(PAUSE);
}
#ifndef OPENTRACK_API
@@ -247,18 +207,12 @@ void Tracker::GetHeadPoseData(THeadPoseData *data)
Matx33f R = X_GH.R * X_GH_0.R.t();
Vec3f t = X_GH.t - X_GH_0.t;
-#ifndef OPENTRACK_API
- // get translation(s)
- if (bEnableX) data->x = t[0] / 10.0; // convert to cm
- if (bEnableY) data->y = t[1] / 10.0;
- if (bEnableZ) data->z = t[2] / 10.0;
-#else
// get translation(s)
- if (bEnableX) data[TX] = t[0] / 10.0; // convert to cm
- if (bEnableY) data[TY] = t[1] / 10.0;
- if (bEnableZ) data[TZ] = t[2] / 10.0;
-#endif
- // translate rotation matrix from opengl (G) to roll-pitch-yaw (E) frame
+ if (s.bEnableX) data[TX] = t[0] / 10.0; // convert to cm
+ if (s.bEnableY) data[TY] = t[1] / 10.0;
+ if (s.bEnableZ) data[TZ] = t[2] / 10.0;
+
+ // translate rotation matrix from opengl (G) to roll-pitch-yaw (E) frame
// -z -> x, y -> z, x -> -y
Matx33f R_EG( 0, 0,-1,
-1, 0, 0,
@@ -271,19 +225,10 @@ void Tracker::GetHeadPoseData(THeadPoseData *data)
alpha = atan2( R(1,0), R(0,0));
gamma = atan2( R(2,1), R(2,2));
-#ifndef OPENTRACK_API
- if (bEnableYaw) data->yaw = rad2deg * alpha;
- if (bEnablePitch) data->pitch = - rad2deg * beta; // FTNoIR expects a minus here
- if (bEnableRoll) data->roll = rad2deg * gamma;
-#else
- if (bEnableYaw) data[Yaw] = rad2deg * alpha;
- if (bEnablePitch) data[Pitch] = - rad2deg * beta; // FTNoIR expects a minus here
- if (bEnableRoll) data[Roll] = rad2deg * gamma;
-#endif
+ if (s.bEnableYaw) data[Yaw] = rad2deg * alpha;
+ if (s.bEnablePitch) data[Pitch] = - rad2deg * beta; // FTNoIR expects a minus here
+ if (s.bEnableRoll) data[Roll] = rad2deg * gamma;
}
-#ifndef OPENTRACK_API
- return true;
-#endif
}
//-----------------------------------------------------------------------------
diff --git a/FTNoIR_Tracker_PT/ftnoir_tracker_pt.h b/FTNoIR_Tracker_PT/ftnoir_tracker_pt.h
index 54edafb2..c7f1dc02 100644
--- a/FTNoIR_Tracker_PT/ftnoir_tracker_pt.h
+++ b/FTNoIR_Tracker_PT/ftnoir_tracker_pt.h
@@ -39,20 +39,11 @@ class Tracker : public ITracker, QThread, public FrameProvider
public:
Tracker();
virtual ~Tracker();
-
- // --- ITracker interface ---
- virtual void Initialize(QFrame *videoframe);
-#ifdef OPENTRACK_API
virtual void StartTracker(QFrame* parent_window);
virtual void GetHeadPoseData(double* data);
-#else
- virtual void StartTracker(HWND parent_window);
- virtual void StopTracker(bool exit);
- virtual bool GetHeadPoseData(THeadPoseData *data);
-#endif
virtual void refreshVideo();
- void apply(const TrackerSettings& settings);
+ void apply(settings& s);
void center();
void reset(); // reset the trackers internal state variables
void run();
@@ -74,20 +65,12 @@ protected:
};
void set_command(Command command);
void reset_command(Command command);
- int commands;
-
- int sleep_time;
+ int commands;
- // --- tracking chain ---
-#ifdef OPENTRACK_API
CVCamera camera;
-#else
- VICamera camera;
-#endif
FrameRotation frame_rotation;
PointExtractor point_extractor;
PointTracker point_tracker;
- bool tracking_valid;
FrameTrafo X_GH_0; // for centering
cv::Vec3f t_MH; // translation from model frame to head frame
@@ -96,22 +79,11 @@ protected:
// --- ui ---
cv::Mat frame; // the output frame for display
- void update_show_video_widget();
- bool show_video_widget;
-#ifdef OPENTRACK_API
PTVideoWidget* video_widget;
-#endif
QFrame* video_frame;
+ bool tracking_valid;
- // --- misc ---
- bool bEnableRoll;
- bool bEnablePitch;
- bool bEnableYaw;
- bool bEnableX;
- bool bEnableY;
- bool bEnableZ;
-
- long frame_count;
+ settings s;
Timer time;
};
diff --git a/FTNoIR_Tracker_PT/ftnoir_tracker_pt_dialog.cpp b/FTNoIR_Tracker_PT/ftnoir_tracker_pt_dialog.cpp
index f8afa790..a88e3a07 100644
--- a/FTNoIR_Tracker_PT/ftnoir_tracker_pt_dialog.cpp
+++ b/FTNoIR_Tracker_PT/ftnoir_tracker_pt_dialog.cpp
@@ -21,8 +21,7 @@ using namespace std;
//-----------------------------------------------------------------------------
TrackerDialog::TrackerDialog()
- : settings_dirty(false),
- tracker(NULL),
+ : tracker(NULL),
video_widget_dialog(NULL),
timer(this),
trans_calib_running(false)
@@ -32,191 +31,112 @@ TrackerDialog::TrackerDialog()
ui.setupUi( this );
- settings.load_ini();
- dialog_settings.load_ini();
-
- // initialize ui values
- ui.videowidget_check->setChecked(settings.video_widget);
- ui.dynpose_check->setChecked(settings.dyn_pose_res);
- ui.sleep_spin->setValue(settings.sleep_time);
- ui.reset_spin->setValue(settings.reset_time);
-
- vector<string> device_names;
+ vector<string> device_names;
get_camera_device_names(device_names);
for (vector<string>::iterator iter = device_names.begin(); iter != device_names.end(); ++iter)
{
ui.camdevice_combo->addItem(iter->c_str());
}
- ui.camdevice_combo->setCurrentIndex(settings.cam_index);
-
- ui.f_dspin->setValue(settings.cam_f);
- ui.res_x_spin->setValue(settings.cam_res_x);
- ui.res_y_spin->setValue(settings.cam_res_y);
- ui.fps_spin->setValue(settings.cam_fps);
-
- ui.camroll_combo->addItem("-90", -1);
- ui.camroll_combo->addItem("0" , 0);
- ui.camroll_combo->addItem("90" , 1);
- int i = ui.camroll_combo->findData(settings.cam_roll);
- ui.camroll_combo->setCurrentIndex(i>=0 ? i : 0);
-
- ui.campitch_spin->setValue(settings.cam_pitch);
- ui.camyaw_spin->setValue(settings.cam_yaw);
- ui.threshold_slider->setValue(settings.threshold);
- ui.threshold_secondary_slider->setValue(settings.threshold_secondary);
-
- ui.chkEnableRoll->setChecked(settings.bEnableRoll);
- ui.chkEnablePitch->setChecked(settings.bEnablePitch);
- ui.chkEnableYaw->setChecked(settings.bEnableYaw);
- ui.chkEnableX->setChecked(settings.bEnableX);
- ui.chkEnableY->setChecked(settings.bEnableY);
- ui.chkEnableZ->setChecked(settings.bEnableZ);
-
- ui.mindiam_spin->setValue(settings.min_point_size);
- ui.maxdiam_spin->setValue(settings.max_point_size);
- ui.model_tabs->setCurrentIndex(dialog_settings.active_model_panel);
- ui.clip_bheight_spin->setValue(dialog_settings.clip_by);
- ui.clip_blength_spin->setValue(dialog_settings.clip_bz);
- ui.clip_theight_spin->setValue(dialog_settings.clip_ty);
- ui.clip_tlength_spin->setValue(dialog_settings.clip_tz);
- ui.cap_width_spin->setValue(dialog_settings.cap_x);
- ui.cap_height_spin->setValue(dialog_settings.cap_y);
- ui.cap_length_spin->setValue(dialog_settings.cap_z);
- ui.m1x_spin->setValue(dialog_settings.M01x);
- ui.m1y_spin->setValue(dialog_settings.M01y);
- ui.m1z_spin->setValue(dialog_settings.M01z);
- ui.m2x_spin->setValue(dialog_settings.M02x);
- ui.m2y_spin->setValue(dialog_settings.M02y);
- ui.m2z_spin->setValue(dialog_settings.M02z);
- ui.tx_spin->setValue(settings.t_MH[0]);
- ui.ty_spin->setValue(settings.t_MH[1]);
- ui.tz_spin->setValue(settings.t_MH[2]);
-
- // connect Qt signals and slots
- connect( ui.videowidget_check,SIGNAL(toggled(bool)), this,SLOT(set_video_widget(bool)) );
- connect( ui.dynpose_check,SIGNAL(toggled(bool)), this,SLOT(set_dyn_pose_res(bool)) );
- connect( ui.sleep_spin,SIGNAL(valueChanged(int)), this,SLOT(set_sleep_time(int)) );
- connect( ui.reset_spin,SIGNAL(valueChanged(int)), this,SLOT(set_reset_time(int)) );
- connect( ui.camdevice_combo,SIGNAL(currentIndexChanged(int)), this,SLOT(set_cam_index(int)) );
- connect( ui.f_dspin,SIGNAL(valueChanged(double)), this,SLOT(set_cam_f(double)) );
- connect( ui.res_x_spin,SIGNAL(valueChanged(int)), this,SLOT(set_cam_res_x(int)) );
- connect( ui.res_y_spin,SIGNAL(valueChanged(int)), this,SLOT(set_cam_res_y(int)) );
- connect( ui.fps_spin,SIGNAL(valueChanged(int)), this,SLOT(set_cam_fps(int)) );
- connect( ui.camroll_combo,SIGNAL(currentIndexChanged(int)), this,SLOT(set_cam_roll(int)) );
- connect( ui.campitch_spin,SIGNAL(valueChanged(int)), this,SLOT(set_cam_pitch(int)) );
- connect( ui.camyaw_spin,SIGNAL(valueChanged(int)), this,SLOT(set_cam_yaw(int)) );
- connect( ui.threshold_slider,SIGNAL(sliderMoved(int)), this,SLOT(set_threshold(int)) );
- connect( ui.threshold_secondary_slider,SIGNAL(sliderMoved(int)), this,SLOT(set_threshold_secondary(int)) );
-
- connect( ui.chkEnableRoll,SIGNAL(toggled(bool)), this,SLOT(set_ena_roll(bool)) );
- connect( ui.chkEnablePitch,SIGNAL(toggled(bool)), this,SLOT(set_ena_pitch(bool)) );
- connect( ui.chkEnableYaw,SIGNAL(toggled(bool)), this,SLOT(set_ena_yaw(bool)) );
- connect( ui.chkEnableX,SIGNAL(toggled(bool)), this,SLOT(set_ena_x(bool)) );
- connect( ui.chkEnableY,SIGNAL(toggled(bool)), this,SLOT(set_ena_y(bool)) );
- connect( ui.chkEnableZ,SIGNAL(toggled(bool)), this,SLOT(set_ena_z(bool)) );
-
- connect( ui.mindiam_spin,SIGNAL(valueChanged(int)), this,SLOT(set_min_point_size(int)) );
- connect( ui.maxdiam_spin,SIGNAL(valueChanged(int)), this,SLOT(set_max_point_size(int)) );
- connect( ui.model_tabs,SIGNAL(currentChanged(int)), this,SLOT(set_model(int)) );
- connect( ui.clip_theight_spin,SIGNAL(valueChanged(int)), this,SLOT(set_clip_t_height(int)) );
- connect( ui.clip_tlength_spin,SIGNAL(valueChanged(int)), this,SLOT(set_clip_t_length(int)) );
- connect( ui.clip_bheight_spin,SIGNAL(valueChanged(int)), this,SLOT(set_clip_b_height(int)) );
- connect( ui.clip_blength_spin,SIGNAL(valueChanged(int)), this,SLOT(set_clip_b_length(int)) );
- connect( ui.cap_width_spin,SIGNAL(valueChanged(int)), this,SLOT(set_cap_width(int)) );
- connect( ui.cap_height_spin,SIGNAL(valueChanged(int)), this,SLOT(set_cap_height(int)) );
- connect( ui.cap_length_spin,SIGNAL(valueChanged(int)), this,SLOT(set_cap_length(int)) );
- connect( ui.m1x_spin,SIGNAL(valueChanged(int)), this,SLOT(set_m1x(int)) );
- connect( ui.m1y_spin,SIGNAL(valueChanged(int)), this,SLOT(set_m1y(int)) );
- connect( ui.m1z_spin,SIGNAL(valueChanged(int)), this,SLOT(set_m1z(int)) );
- connect( ui.m2x_spin,SIGNAL(valueChanged(int)), this,SLOT(set_m2x(int)) );
- connect( ui.m2y_spin,SIGNAL(valueChanged(int)), this,SLOT(set_m2y(int)) );
- connect( ui.m2z_spin,SIGNAL(valueChanged(int)), this,SLOT(set_m2z(int)) );
- connect( ui.tx_spin,SIGNAL(valueChanged(int)), this,SLOT(set_tx(int)) );
- connect( ui.ty_spin,SIGNAL(valueChanged(int)), this,SLOT(set_ty(int)) );
- connect( ui.tz_spin,SIGNAL(valueChanged(int)), this,SLOT(set_tz(int)) );
-
- connect( ui.tcalib_button,SIGNAL(toggled(bool)), this,SLOT(startstop_trans_calib(bool)) );
-
- connect( ui.videowidget_button,SIGNAL(clicked()), this,SLOT(create_video_widget()) );
-
- connect(ui.reset_button, SIGNAL(clicked()), this, SLOT(doReset()));
- //connect(ui.center_button, SIGNAL(clicked()), this, SLOT(doCenter()));
-
- connect(ui.ok_button, SIGNAL(clicked()), this, SLOT(doOK()));
- connect(ui.cancel_button, SIGNAL(clicked()), this, SLOT(doCancel()));
-
- connect(&timer,SIGNAL(timeout()), this,SLOT(poll_tracker_info()));
- timer.start(100);
-}
-TrackerDialog::~TrackerDialog()
-{
- qDebug()<<"TrackerDialog::~TrackerDialog";
-}
+ ui.camroll_combo->addItem("-90");
+ ui.camroll_combo->addItem("0");
+ ui.camroll_combo->addItem("90");
-void TrackerDialog::set_cam_roll(int idx)
-{
- settings.cam_roll = ui.camroll_combo->itemData(idx).toInt();
- settings_changed();
+ tie_setting(s.dyn_pose_res, ui.dynpose_check);
+ tie_setting(s.sleep_time, ui.sleep_spin);
+ tie_setting(s.reset_time, ui.reset_spin);
+
+ tie_setting(s.cam_index, ui.camdevice_combo);
+ tie_setting(s.cam_f, ui.f_dspin);
+ tie_setting(s.cam_res_x, ui.res_x_spin);
+ tie_setting(s.cam_res_y, ui.res_y_spin);
+ tie_setting(s.cam_fps, ui.fps_spin);
+ tie_setting(s.cam_roll, ui.camroll_combo);
+ tie_setting(s.cam_pitch, ui.campitch_spin);
+ tie_setting(s.cam_yaw, ui.camyaw_spin);
+
+ tie_setting(s.threshold_secondary, ui.threshold_secondary_slider);
+ tie_setting(s.threshold, ui.threshold_slider);
+
+ tie_setting(s.bEnableYaw, ui.chkEnableYaw);
+ tie_setting(s.bEnablePitch, ui.chkEnablePitch);
+ tie_setting(s.bEnableRoll, ui.chkEnableRoll);
+ tie_setting(s.bEnableX, ui.chkEnableX);
+ tie_setting(s.bEnableY, ui.chkEnableY);
+ tie_setting(s.bEnableZ, ui.chkEnableZ);
+
+ tie_setting(s.min_point_size, ui.mindiam_spin);
+ tie_setting(s.max_point_size, ui.maxdiam_spin);
+
+ tie_setting(s.clip_by, ui.clip_bheight_spin);
+ tie_setting(s.clip_bz, ui.clip_blength_spin);
+ tie_setting(s.clip_ty, ui.clip_theight_spin);
+ tie_setting(s.clip_tz, ui.clip_tlength_spin);
+
+ tie_setting(s.cap_x, ui.cap_width_spin);
+ tie_setting(s.cap_y, ui.cap_height_spin);
+ tie_setting(s.cap_z, ui.cap_length_spin);
+
+ tie_setting(s.m01_x, ui.m1x_spin);
+ tie_setting(s.m01_y, ui.m1y_spin);
+ tie_setting(s.m01_z, ui.m1z_spin);
+
+ tie_setting(s.m02_x, ui.m2x_spin);
+ tie_setting(s.m02_y, ui.m2y_spin);
+ tie_setting(s.m02_z, ui.m2z_spin);
+
+ tie_setting(s.t_MH_x, ui.tx_spin);
+ tie_setting(s.t_MH_y, ui.ty_spin);
+ tie_setting(s.t_MH_z, ui.tz_spin);
+
+ connect( ui.tcalib_button,SIGNAL(toggled(bool)), this,SLOT(startstop_trans_calib(bool)) );
+ connect(ui.reset_button, SIGNAL(clicked()), this, SLOT(doReset()));
+
+ connect(ui.ok_button, SIGNAL(clicked()), this, SLOT(doOK()));
+ connect(ui.cancel_button, SIGNAL(clicked()), this, SLOT(doCancel()));
+ connect(ui.btnApply, SIGNAL(clicked()), this, SLOT(doApply()));
+
+ ui.model_tabs->setCurrentIndex(s.active_model_panel);
+
+ connect(ui.model_tabs, SIGNAL(currentChanged(int)), this, SLOT(set_model(int)));
+ connect(&timer,SIGNAL(timeout()), this,SLOT(poll_tracker_info()));
+ timer.start(100);
+
+ connect(s.b.get(), SIGNAL(bundleChanged()), this, SLOT(do_apply_without_saving()));
}
void TrackerDialog::set_model_clip()
{
- settings.M01[0] = 0;
- settings.M01[1] = dialog_settings.clip_ty;
- settings.M01[2] = -dialog_settings.clip_tz;
- settings.M02[0] = 0;
- settings.M02[1] = -dialog_settings.clip_by;
- settings.M02[2] = -dialog_settings.clip_bz;
+ s.m01_x = 0;
+ s.m01_y = static_cast<double>(s.clip_ty);
+ s.m01_z = -static_cast<double>(s.clip_tz);
+ s.m02_x = 0;
+ s.m02_y = -static_cast<double>(s.clip_by);
+ s.m02_z = -static_cast<double>(s.clip_bz);
settings_changed();
}
void TrackerDialog::set_model_cap()
{
- settings.M01[0] = -dialog_settings.cap_x;
- settings.M01[1] = -dialog_settings.cap_y;
- settings.M01[2] = -dialog_settings.cap_z;
- settings.M02[0] = dialog_settings.cap_x;
- settings.M02[1] = -dialog_settings.cap_y;
- settings.M02[2] = -dialog_settings.cap_z;
+ s.m01_x = -static_cast<double>(s.cap_x);
+ s.m01_y = -static_cast<double>(s.cap_y);
+ s.m01_z = -static_cast<double>(s.cap_z);
+ s.m02_x = static_cast<double>(s.cap_x);
+ s.m02_y = -static_cast<double>(s.cap_y);
+ s.m02_z = -static_cast<double>(s.cap_z);
settings_changed();
}
void TrackerDialog::set_model_custom()
{
- settings.M01[0] = dialog_settings.M01x;
- settings.M01[1] = dialog_settings.M01y;
- settings.M01[2] = dialog_settings.M01z;
- settings.M02[0] = dialog_settings.M02x;
- settings.M02[1] = dialog_settings.M02y;
- settings.M02[2] = dialog_settings.M02z;
-
settings_changed();
}
void TrackerDialog::set_model(int val)
{
- dialog_settings.active_model_panel = val;
-
- switch (val) {
-
- case TrackerDialogSettings::MODEL_CLIP:
- set_model_clip();
- break;
-
- case TrackerDialogSettings::MODEL_CAP:
- set_model_cap();
- break;
-
- case TrackerDialogSettings::MODEL_CUSTOM:
- set_model_custom();
- break;
-
- default:
- break;
- }
+ s.active_model_panel = val;
}
void TrackerDialog::startstop_trans_calib(bool start)
@@ -231,7 +151,12 @@ void TrackerDialog::startstop_trans_calib(bool start)
{
qDebug()<<"TrackerDialog:: Stoppping translation calibration";
trans_calib_running = false;
- settings.t_MH = trans_calib.get_estimate();
+ {
+ auto tmp = trans_calib.get_estimate();
+ s.t_MH_x = tmp[0];
+ s.t_MH_y = tmp[1];
+ s.t_MH_z = tmp[2];
+ }
settings_changed();
}
}
@@ -244,17 +169,15 @@ void TrackerDialog::trans_calib_step()
tracker->get_pose(&X_CM);
trans_calib.update(X_CM.R, X_CM.t);
cv::Vec3f t_MH = trans_calib.get_estimate();
- //qDebug()<<"TrackerDialog:: Current translation estimate: "<<t_MH[0]<<t_MH[1]<<t_MH[2];
- ui.tx_spin->setValue(t_MH[0]);
- ui.ty_spin->setValue(t_MH[1]);
- ui.tz_spin->setValue(t_MH[2]);
+ s.t_MH_x = t_MH[0];
+ s.t_MH_y = t_MH[1];
+ s.t_MH_z = t_MH[2];
}
}
void TrackerDialog::settings_changed()
{
- settings_dirty = true;
- if (tracker) tracker->apply(settings);
+ if (tracker) tracker->apply(s);
}
void TrackerDialog::doCenter()
@@ -267,25 +190,52 @@ void TrackerDialog::doReset()
if (tracker) tracker->reset();
}
+void TrackerDialog::save()
+{
+ do_apply_without_saving();
+ s.b->save();
+}
+
void TrackerDialog::doOK()
{
- settings.save_ini();
- dialog_settings.save_ini();
+ save();
close();
}
+void TrackerDialog::do_apply_without_saving()
+{
+ switch (s.active_model_panel) {
+ default:
+ case 0:
+ set_model_clip();
+ break;
+ case 1:
+ set_model_cap();
+ break;
+ case 2:
+ set_model_custom();
+ break;
+ }
+ if (tracker) tracker->apply(s);
+}
+
+void TrackerDialog::doApply()
+{
+ save();
+}
+
void TrackerDialog::doCancel()
{
- if (settings_dirty) {
+ if (s.b->modifiedp()) {
int ret = QMessageBox::question ( this, "Settings have changed", "Do you want to save the settings?",
QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel, QMessageBox::Discard );
switch (ret) {
case QMessageBox::Save:
- settings.save_ini();
- dialog_settings.save_ini();
+ save();
close();
break;
case QMessageBox::Discard:
+ s.b->revert();
close();
break;
case QMessageBox::Cancel:
@@ -319,8 +269,6 @@ void TrackerDialog::create_video_widget()
video_widget_dialog->setAttribute( Qt::WA_DeleteOnClose );
connect( video_widget_dialog, SIGNAL(destroyed(QObject*)), this, SLOT(widget_destroyed(QObject*)) );
video_widget_dialog->show();
-
- ui.videowidget_button->setEnabled(false);
}
void TrackerDialog::destroy_video_widget(bool do_delete /*= true*/)
@@ -329,7 +277,6 @@ void TrackerDialog::destroy_video_widget(bool do_delete /*= true*/)
if (do_delete) delete video_widget_dialog;
video_widget_dialog = NULL;
}
- if (tracker) ui.videowidget_button->setEnabled(true);
}
void TrackerDialog::poll_tracker_info()
@@ -369,24 +316,12 @@ void TrackerDialog::poll_tracker_info()
}
}
-
-//-----------------------------------------------------------------------------
-// ITrackerDialog interface
-void TrackerDialog::Initialize(QWidget *parent)
-{
- QPoint offsetpos(200, 200);
- if (parent) {
- this->move(parent->pos() + offsetpos);
- }
- show();
-}
-
void TrackerDialog::registerTracker(ITracker *t)
{
qDebug()<<"TrackerDialog:: Tracker registered";
tracker = static_cast<Tracker*>(t);
- if (isVisible() && settings_dirty) tracker->apply(settings);
- ui.videowidget_button->setEnabled(true);
+ if (isVisible() & s.b->modifiedp())
+ tracker->apply(s);
ui.tcalib_button->setEnabled(true);
//ui.center_button->setEnabled(true);
ui.reset_button->setEnabled(true);
@@ -397,19 +332,12 @@ void TrackerDialog::unRegisterTracker()
qDebug()<<"TrackerDialog:: Tracker un-registered";
tracker = NULL;
destroy_video_widget();
- ui.videowidget_button->setEnabled(false);
ui.tcalib_button->setEnabled(false);
//ui.center_button->setEnabled(false);
ui.reset_button->setEnabled(false);
}
-//-----------------------------------------------------------------------------
-#ifdef OPENTRACK_API
extern "C" FTNOIR_TRACKER_BASE_EXPORT ITrackerDialog* CALLING_CONVENTION GetDialog( )
-#else
-#pragma comment(linker, "/export:GetTrackerDialog=_GetTrackerDialog@0")
-FTNOIR_TRACKER_BASE_EXPORT ITrackerDialogPtr __stdcall GetTrackerDialog( )
-#endif
{
return new TrackerDialog;
}
diff --git a/FTNoIR_Tracker_PT/ftnoir_tracker_pt_dialog.h b/FTNoIR_Tracker_PT/ftnoir_tracker_pt_dialog.h
index de743ad8..0325160d 100644
--- a/FTNoIR_Tracker_PT/ftnoir_tracker_pt_dialog.h
+++ b/FTNoIR_Tracker_PT/ftnoir_tracker_pt_dialog.h
@@ -28,71 +28,24 @@ class TrackerDialog : public QWidget, Ui::UICPTClientControls, public ITrackerDi
Q_OBJECT
public:
TrackerDialog();
- ~TrackerDialog();
-
- // ITrackerDialog interface
- void Initialize(QWidget *parent);
void registerTracker(ITracker *tracker);
void unRegisterTracker();
-
+ void save();
void trans_calib_step();
-protected slots:
- // ugly qt stuff
- void set_video_widget(bool val) { settings.video_widget = val; settings_changed(); }
- void set_dyn_pose_res(bool val) { settings.dyn_pose_res = val; settings_changed(); }
- void set_sleep_time(int val) { settings.sleep_time = val; settings_changed(); }
- void set_reset_time(int val) { settings.reset_time = val; settings_changed(); }
- void set_cam_index(int idx) { settings.cam_index = idx; settings_changed(); }
- void set_cam_f(double val) { settings.cam_f = val; settings_changed(); }
- void set_cam_res_x(int val) { settings.cam_res_x = val; settings_changed(); }
- void set_cam_res_y(int val) { settings.cam_res_y = val; settings_changed(); }
- void set_cam_fps(int val) { settings.cam_fps = val; settings_changed(); }
- void set_cam_roll(int idx);
- void set_cam_pitch(int val) { settings.cam_pitch = val; settings_changed(); }
- void set_cam_yaw(int val) { settings.cam_yaw = val; settings_changed(); }
- void set_min_point_size(int val) { settings.min_point_size = val; settings_changed(); }
- void set_max_point_size(int val) { settings.max_point_size = val; settings_changed(); }
- void set_threshold(int val) { settings.threshold = val; settings_changed(); }
- void set_threshold_secondary(int val) { settings.threshold_secondary = val; settings_changed(); }
- void set_ena_roll(bool val) { settings.bEnableRoll = val; settings_changed(); }
- void set_ena_pitch(bool val) { settings.bEnablePitch = val; settings_changed(); }
- void set_ena_yaw(bool val) { settings.bEnableYaw = val; settings_changed(); }
- void set_ena_x(bool val) { settings.bEnableX = val; settings_changed(); }
- void set_ena_y(bool val) { settings.bEnableY = val; settings_changed(); }
- void set_ena_z(bool val) { settings.bEnableZ = val; settings_changed(); }
-
- void set_clip_t_height(int val) { dialog_settings.clip_ty = val; set_model_clip(); }
- void set_clip_t_length(int val) { dialog_settings.clip_tz = val; set_model_clip(); }
- void set_clip_b_height(int val) { dialog_settings.clip_by = val; set_model_clip(); }
- void set_clip_b_length(int val) { dialog_settings.clip_bz = val; set_model_clip(); }
- void set_cap_width(int val) { dialog_settings.cap_x = val; set_model_cap(); }
- void set_cap_height(int val) { dialog_settings.cap_y = val; set_model_cap(); }
- void set_cap_length(int val) { dialog_settings.cap_z = val; set_model_cap(); }
- void set_m1x(int val) { dialog_settings.M01x = val; set_model_custom(); }
- void set_m1y(int val) { dialog_settings.M01y = val; set_model_custom(); }
- void set_m1z(int val) { dialog_settings.M01z = val; set_model_custom(); }
- void set_m2x(int val) { dialog_settings.M02x = val; set_model_custom(); }
- void set_m2y(int val) { dialog_settings.M02y = val; set_model_custom(); }
- void set_m2z(int val) { dialog_settings.M02z = val; set_model_custom(); }
- void set_tx(int val) { settings.t_MH[0] = val; settings_changed(); }
- void set_ty(int val) { settings.t_MH[1] = val; settings_changed(); }
- void set_tz(int val) { settings.t_MH[2] = val; settings_changed(); }
- void set_model(int model_id);
-
- void doCenter();
- void doReset();
-
+public slots:
+ void doCenter();
+ void doReset();
void doOK();
+ void doApply();
void doCancel();
+ void do_apply_without_saving();
void startstop_trans_calib(bool start);
-
void widget_destroyed(QObject* obj);
-
void create_video_widget();
-
void poll_tracker_info();
+ void set_model(int idx);
protected:
void destroy_video_widget(bool do_delete = true);
@@ -103,15 +56,11 @@ protected:
void settings_changed();
- TrackerSettings settings;
- TrackerDialogSettings dialog_settings;
- bool settings_dirty;
-
+ settings s;
Tracker* tracker;
+ VideoWidgetDialog* video_widget_dialog;
QTimer timer;
- VideoWidgetDialog* video_widget_dialog;
-
TranslationCalibrator trans_calib;
bool trans_calib_running;
diff --git a/FTNoIR_Tracker_PT/ftnoir_tracker_pt_dll.h b/FTNoIR_Tracker_PT/ftnoir_tracker_pt_dll.h
index 18283837..1d30e7e5 100644
--- a/FTNoIR_Tracker_PT/ftnoir_tracker_pt_dll.h
+++ b/FTNoIR_Tracker_PT/ftnoir_tracker_pt_dll.h
@@ -20,10 +20,6 @@ class TrackerDll :
public ITrackerDll
#endif
{
- // ITrackerDll interface
-#ifndef OPENTRACK_API
- void Initialize() {}
-#endif
void getFullName(QString *strToBeFilled);
void getShortName(QString *strToBeFilled);
void getDescription(QString *strToBeFilled);
diff --git a/FTNoIR_Tracker_PT/ftnoir_tracker_pt_settings.cpp b/FTNoIR_Tracker_PT/ftnoir_tracker_pt_settings.cpp
deleted file mode 100644
index 50835cb8..00000000
--- a/FTNoIR_Tracker_PT/ftnoir_tracker_pt_settings.cpp
+++ /dev/null
@@ -1,156 +0,0 @@
-/* Copyright (c) 2012 Patrick Ruoff
- *
- * Permission to use, copy, modify, and/or distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- */
-
-#include "ftnoir_tracker_pt.h"
-#include <QCoreApplication>
-#include <QSettings>
-
-//-----------------------------------------------------------------------------
-void TrackerSettings::load_ini()
-{
- qDebug("TrackerSettings::load_ini()");
-
- QSettings settings("opentrack");
- QString currentFile = settings.value( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString();
- QSettings iniFile( currentFile, QSettings::IniFormat ); // Application settings (in INI-file)
-
- iniFile.beginGroup( "PointTracker" );
-
- cam_index = iniFile.value("CameraId", 0).toInt();
- cam_f = iniFile.value("CameraF", 1).toFloat();
- cam_res_x = iniFile.value("CameraResX", 640).toInt();
- cam_res_y = iniFile.value("CameraResY", 480).toInt();
- cam_fps = iniFile.value("CameraFPS", 30).toInt();
- cam_roll = iniFile.value("CameraRoll", 0).toInt();
- cam_pitch = iniFile.value("CameraPitch", 0).toInt();
- cam_yaw = iniFile.value("CameraYaw", 0).toInt();
- threshold = iniFile.value("PointExtractThreshold", 128).toInt();
- threshold_secondary = iniFile.value("PointExtractThresholdSecondary", 128).toInt();
- min_point_size = iniFile.value("PointExtractMinSize", 2).toInt();
- max_point_size = iniFile.value("PointExtractMaxSize", 50).toInt();
- M01[0] = iniFile.value("PointModelM01x", 0).toFloat();
- M01[1] = iniFile.value("PointModelM01y", 40).toFloat();
- M01[2] = iniFile.value("PointModelM01z", -30).toFloat();
- M02[0] = iniFile.value("PointModelM02x", 0).toFloat();
- M02[1] = iniFile.value("PointModelM02y", -70).toFloat();
- M02[2] = iniFile.value("PointModelM02z", -80).toFloat();
- t_MH[0] = iniFile.value("tMHx", 0).toFloat();
- t_MH[1] = iniFile.value("tMHy", 0).toFloat();
- t_MH[2] = iniFile.value("tMHz", 0).toFloat();
- dyn_pose_res = iniFile.value("DynamicPoseResolution", true).toBool();
- video_widget = iniFile.value("VideoWidget", true).toBool();
- sleep_time = iniFile.value("SleepTime", 10).toInt();
- reset_time = iniFile.value("ResetTime", 1000).toInt();
-
- bEnableRoll = iniFile.value("EnableRoll", 1).toBool();
- bEnablePitch = iniFile.value("EnablePitch", 1).toBool();
- bEnableYaw = iniFile.value("EnableYaw", 1).toBool();
- bEnableX = iniFile.value("EnableX", 1).toBool();
- bEnableY = iniFile.value("EnableY", 1).toBool();
- bEnableZ = iniFile.value("EnableZ", 1).toBool();
-
- iniFile.endGroup();
-}
-
-void TrackerSettings::save_ini() const
-{
- qDebug("TrackerSettings::save_ini()");
-
- QSettings settings("opentrack");
- QString currentFile = settings.value( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString();
- QSettings iniFile( currentFile, QSettings::IniFormat ); // Application settings (in INI-file)
-
- iniFile.beginGroup ( "PointTracker" );
-
- iniFile.setValue("CameraId", cam_index);
- iniFile.setValue("CameraF", cam_f);
- iniFile.setValue("CameraResX", cam_res_x);
- iniFile.setValue("CameraResY", cam_res_y);
- iniFile.setValue("CameraFPS", cam_fps);
- iniFile.setValue("CameraRoll", cam_roll);
- iniFile.setValue("CameraPitch", cam_pitch);
- iniFile.setValue("CameraYaw", cam_yaw);
- iniFile.setValue("PointExtractThreshold", threshold);
- iniFile.setValue("PointExtractThresholdSecondary", threshold_secondary);
- iniFile.setValue("PointExtractMinSize", min_point_size);
- iniFile.setValue("PointExtractMaxSize", max_point_size);
- iniFile.setValue("PointModelM01x", M01[0]);
- iniFile.setValue("PointModelM01y", M01[1]);
- iniFile.setValue("PointModelM01z", M01[2]);
- iniFile.setValue("PointModelM02x", M02[0]);
- iniFile.setValue("PointModelM02y", M02[1]);
- iniFile.setValue("PointModelM02z", M02[2]);
- iniFile.setValue("tMHx", t_MH[0]);
- iniFile.setValue("tMHy", t_MH[1]);
- iniFile.setValue("tMHz", t_MH[2]);
- iniFile.setValue("DynamicPoseResolution", dyn_pose_res);
- iniFile.setValue("VideoWidget", video_widget);
- iniFile.setValue("SleepTime", sleep_time);
- iniFile.setValue("ResetTime", reset_time);
-
- iniFile.setValue( "EnableRoll", bEnableRoll );
- iniFile.setValue( "EnablePitch", bEnablePitch );
- iniFile.setValue( "EnableYaw", bEnableYaw );
- iniFile.setValue( "EnableX", bEnableX );
- iniFile.setValue( "EnableY", bEnableY );
- iniFile.setValue( "EnableZ", bEnableZ );
-
- iniFile.endGroup();
-}
-
-//-----------------------------------------------------------------------------
-void TrackerDialogSettings::load_ini()
-{
- qDebug("TrackerDialogSettings::load_ini()");
-
- QSettings settings("opentrack");
- QString currentFile = settings.value( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString();
- QSettings iniFile( currentFile, QSettings::IniFormat ); // Application settings (in INI-file)
-
- iniFile.beginGroup( "PointTrackerDialog" );
-
- active_model_panel = iniFile.value("ActiveModelPanel", MODEL_CLIP).toInt();
- M01x = iniFile.value("CustomM01x", 0).toInt();
- M01y = iniFile.value("CustomM01y", 40).toInt();
- M01z = iniFile.value("CustomM01z", -30).toInt();
- M02x = iniFile.value("CustomM02x", 0).toInt();
- M02y = iniFile.value("CustomM02y", -70).toInt();
- M02z = iniFile.value("CustomM02z", -80).toInt();
- clip_ty = iniFile.value("ClipTopHeight", 40).toInt();
- clip_tz = iniFile.value("ClipTopLength", 30).toInt();
- clip_by = iniFile.value("ClipBottomHeight", 70).toInt();
- clip_bz = iniFile.value("ClipBottomLength", 80).toInt();
- cap_x = iniFile.value("CapHalfWidth", 40).toInt();
- cap_y = iniFile.value("CapHeight", 60).toInt();
- cap_z = iniFile.value("CapLength", 100).toInt();
-}
-
-void TrackerDialogSettings::save_ini() const
-{
- qDebug("TrackerDialogSettings::save_ini()");
-
- QSettings settings("opentrack");
- QString currentFile = settings.value( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString();
- QSettings iniFile( currentFile, QSettings::IniFormat ); // Application settings (in INI-file)
-
- iniFile.beginGroup ( "PointTrackerDialog" );
-
- iniFile.setValue("ActiveModelPanel", active_model_panel);
- iniFile.setValue("CustomM01x", M01x);
- iniFile.setValue("CustomM01y", M01y);
- iniFile.setValue("CustomM01z", M01z);
- iniFile.setValue("CustomM02x", M02x);
- iniFile.setValue("CustomM02y", M02y);
- iniFile.setValue("CustomM02z", M02z);
- iniFile.setValue("ClipTopHeight", clip_ty);
- iniFile.setValue("ClipTopLength", clip_tz);
- iniFile.setValue("ClipBottomHeight", clip_by);
- iniFile.setValue("ClipBottomLength", clip_bz);
- iniFile.setValue("CapHalfWidth", cap_x);
- iniFile.setValue("CapHeight", cap_y);
- iniFile.setValue("CapLength", cap_z);
-}
diff --git a/FTNoIR_Tracker_PT/ftnoir_tracker_pt_settings.h b/FTNoIR_Tracker_PT/ftnoir_tracker_pt_settings.h
index 91a7a8d5..a828ea48 100644
--- a/FTNoIR_Tracker_PT/ftnoir_tracker_pt_settings.h
+++ b/FTNoIR_Tracker_PT/ftnoir_tracker_pt_settings.h
@@ -11,80 +11,81 @@
#include <opencv2/opencv.hpp>
#include "point_tracker.h"
+#include "facetracknoir/options.h"
+using namespace options;
-//-----------------------------------------------------------------------------
-// Tracker settings and their ini-IO
-struct TrackerSettings
-{
- // camera
- int cam_index;
- float cam_f;
- int cam_res_x;
- int cam_res_y;
- int cam_fps;
- int cam_roll;
- int cam_pitch;
- int cam_yaw;
-
- // point extraction
- int threshold;
- int threshold_secondary;
-
- int min_point_size;
- int max_point_size;
-
- // point tracking
- cv::Vec3f M01;
- cv::Vec3f M02;
- bool dyn_pose_res;
-
- // head to model translation
- cv::Vec3f t_MH;
-
- int sleep_time; // in ms
- int reset_time; // in ms
- bool video_widget;
+struct settings
+{
+ pbundle b;
+ value<int> cam_index,
+ cam_res_x,
+ cam_res_y,
+ cam_fps,
+ cam_roll,
+ cam_pitch,
+ cam_yaw,
+ threshold,
+ threshold_secondary,
+ min_point_size,
+ max_point_size;
+ value<double> cam_f;
- bool bEnableRoll;
- bool bEnablePitch;
- bool bEnableYaw;
- bool bEnableX;
- bool bEnableY;
- bool bEnableZ;
+ value<int> m01_x, m01_y, m01_z;
+ value<int> m02_x, m02_y, m02_z;
+ value<bool> dyn_pose_res, video_widget;
- void load_ini();
- void save_ini() const;
-};
+ value<int> t_MH_x, t_MH_y, t_MH_z;
+ value<int> sleep_time, reset_time;
-//-----------------------------------------------------------------------------
-// Settings specific to the tracker dialog and their ini-IO
-struct TrackerDialogSettings
-{
- enum
- {
- MODEL_CLIP,
- MODEL_CAP,
- MODEL_CUSTOM
- };
- int active_model_panel;
+ value<bool> bEnableYaw, bEnablePitch, bEnableRoll;
+ value<bool> bEnableX, bEnableY, bEnableZ;
- int M01x;
- int M01y;
- int M01z;
- int M02x;
- int M02y;
- int M02z;
- int clip_ty;
- int clip_tz;
- int clip_by;
- int clip_bz;
- int cap_x;
- int cap_y;
- int cap_z;
+ value<int> clip_ty, clip_tz, clip_by, clip_bz;
+ value<int> active_model_panel, cap_x, cap_y, cap_z;
- void load_ini();
- void save_ini() const;
+ settings() :
+ b(bundle("tracker-pt")),
+ cam_index(b, "camera-index", 0),
+ cam_res_x(b, "camera-res-width", 640),
+ cam_res_y(b, "camera-res-height", 480),
+ cam_fps(b, "camera-fps", 30),
+ cam_roll(b, "camera-roll", 1),
+ cam_pitch(b, "camera-pitch", 0),
+ cam_yaw(b, "camera-yaw", 0),
+ threshold(b, "threshold-primary", 128),
+ threshold_secondary(b, "threshold-secondary", 128),
+ min_point_size(b, "min-point-size", 10),
+ max_point_size(b, "max-point-size", 50),
+ cam_f(b, "camera-focal-length", 1),
+ m01_x(b, "m_01-x", 0),
+ m01_y(b, "m_01-y", 0),
+ m01_z(b, "m_01-z", 0),
+ m02_x(b, "m_02-x", 0),
+ m02_y(b, "m_02-y", 0),
+ m02_z(b, "m_02-z", 0),
+ dyn_pose_res(b, "dynamic-pose-resolution", false),
+ video_widget(b, "video-widget", true),
+ t_MH_x(b, "model-centroid-x", 0),
+ t_MH_y(b, "model-centroid-y", 0),
+ t_MH_z(b, "model-centroid-z", 0),
+ sleep_time(b, "sleep-time", 0),
+ reset_time(b, "reset-time", 0),
+ bEnableYaw(b, "enable-yaw", true),
+ bEnablePitch(b, "enable-pitch", true),
+ bEnableRoll(b, "enable-roll", true),
+ bEnableX(b, "enable-x", true),
+ bEnableY(b, "enable-y", true),
+ bEnableZ(b, "enable-z", true),
+ clip_ty(b, "clip-ty", 0),
+ clip_tz(b, "clip-tz", 0),
+ clip_by(b, "clip-by", 0),
+ clip_bz(b, "clip-bz", 0),
+ active_model_panel(b, "active-model-panel", 0),
+ cap_x(b, "cap-x", 0),
+ cap_y(b, "cap-y", 0),
+ cap_z(b, "cap-z", 0)
+ {}
};
-#endif //FTNOIR_TRACKER_PT_SETTINGS_H \ No newline at end of file
+#endif //FTNOIR_TRACKER_PT_SETTINGS_H
diff --git a/README.md b/README.md
index 2044a44b..b8291699 100644
--- a/README.md
+++ b/README.md
@@ -1,3 +1,4 @@
+=======
Windows binary builds are available at <http://ts3.cosaofficial.pl/opentrack/>
Source code access available at <http://github.com/opentrack/opentrack/>
diff --git a/bin/settings/default.ini b/bin/settings/default.ini
index 05ce3af4..e69de29b 100644
--- a/bin/settings/default.ini
+++ b/bin/settings/default.ini
@@ -1,130 +0,0 @@
-[Curves-rx]
-point-count=4
-point-0-x=0
-point-0-y=0
-point-1-x=5
-point-1-y=14
-point-2-x=12.222222328186
-point-2-y=75
-point-3-x=19
-point-3-y=158
-
-[Curves-ry]
-point-count=1
-point-0-x=19
-point-0-y=90
-
-[Curves-ry_alt]
-point-count=4
-point-0-x=0
-point-0-y=0
-point-1-x=4.88888883590698
-point-1-y=16
-point-2-x=8.88888931274414
-point-2-y=36
-point-3-x=12
-point-3-y=69
-
-[Curves-rz]
-point-count=1
-point-0-x=60
-point-0-y=60
-
-[Curves-tx]
-point-count=1
-point-0-x=59.8888893127441
-point-0-y=165
-
-[Curves-ty]
-point-count=1
-point-0-x=60
-point-0-y=165
-
-[Curves-tz]
-point-count=1
-point-0-x=60
-point-0-y=200
-
-[Tracking]
-Smooth=1
-invertYaw=false
-invertPitch=false
-invertRoll=false
-invertX=false
-invertY=false
-invertZ=false
-rx_alt=false
-ry_alt=true
-rz_alt=false
-tx_alt=false
-ty_alt=false
-tz_alt=false
-
-[GameProtocol]
-DLL=FTNoIR_Protocol_FT.dll
-
-[KB_Shortcuts]
-Keycode_Center=199
-Shift_Center=false
-Ctrl_Center=false
-Alt_Center=false
-Keycode_StartStop=207
-Shift_StartStop=false
-Ctrl_StartStop=false
-Alt_StartStop=false
-
-[PPJoy]
-Selection=1
-
-[FSUIPC]
-LocationOfDLL=C:/Program Files/Microsoft Games/Flight Simulator 9/Modules/FSUIPC.dll
-
-[TrackerSource]
-Selection=0
-DLL=FTNoIR_Tracker_SM.dll
-2ndDLL=None
-
-[Filter]
-DLL=FTNoIR_Filter_Accela.dll
-
-[SMTracker]
-FilterLevel=1
-EnableRoll=true
-EnablePitch=true
-EnableYaw=true
-EnableX=true
-EnableY=true
-EnableZ=true
-
-[Accela]
-Reduction=1000
-zoom-slowness=5
-smoothing-factor=1.5
-
-[Curves-Accela-Scaling-Rotation]
-point-count=6
-point-0-x=0
-point-0-y=0
-point-1-x=0.535433053970337
-point-1-y=0.29824560880661
-point-2-x=0.992125988006592
-point-2-y=0.736842095851898
-point-3-x=1.33070862293243
-point-3-y=1.59649121761322
-point-4-x=1.4960629940033
-point-4-y=3.29824566841125
-point-5-x=1.58267712593079
-point-5-y=8
-
-[Curves-Accela-Scaling-Translation]
-point-count=5
-point-0-x=0
-point-0-y=0
-point-1-x=0.346456706523895
-point-1-y=1
-point-2-x=0.559055089950562
-point-2-y=3.15789484977722
-point-3-x=0.700787425041199
-point-3-y=5.54385948181152
-point-4-x=0.795275568962097
-point-4-y=8 \ No newline at end of file
diff --git a/facetracknoir/curve-config.cpp b/facetracknoir/curve-config.cpp
index 2e731892..4b07a165 100644
--- a/facetracknoir/curve-config.cpp
+++ b/facetracknoir/curve-config.cpp
@@ -14,7 +14,23 @@ CurveConfigurationDialog::CurveConfigurationDialog(FaceTrackNoIR *ftnoir, QWidge
// Connect Qt signals to member-functions
connect(ui.buttonBox, SIGNAL(accepted()), this, SLOT(doOK()));
connect(ui.buttonBox, SIGNAL(rejected()), this, SLOT(doCancel()));
- connect(ui.checkBox, SIGNAL(stateChanged(int)), this, SLOT(curveChanged(int)));
+
+ tie_setting(mainApp->s.a_x.altp, ui.tx_altp);
+ tie_setting(mainApp->s.a_y.altp, ui.ty_altp);
+ tie_setting(mainApp->s.a_z.altp, ui.tz_altp);
+ tie_setting(mainApp->s.a_yaw.altp, ui.rx_altp);
+ tie_setting(mainApp->s.a_pitch.altp, ui.ry_altp);
+ tie_setting(mainApp->s.a_roll.altp, ui.rz_altp);
+
+ tie_setting(mainApp->s.tcomp_p, ui.tcomp_enable);
+ tie_setting(mainApp->s.tcomp_tz, ui.tcomp_rz);
+
+ tie_setting(mainApp->s.a_x.zero, ui.pos_tx);
+ tie_setting(mainApp->s.a_y.zero, ui.pos_ty);
+ tie_setting(mainApp->s.a_z.zero, ui.pos_tz);
+ tie_setting(mainApp->s.a_yaw.zero, ui.pos_rx);
+ tie_setting(mainApp->s.a_pitch.zero, ui.pos_ry);
+ tie_setting(mainApp->s.a_roll.zero, ui.pos_rz);
// Load the settings from the current .INI-file
loadSettings();
@@ -47,7 +63,7 @@ void CurveConfigurationDialog::doCancel() {
//
// Ask if changed Settings should be saved
//
- if (settingsDirty) {
+ if (settingsDirty || mainApp->s.b->modifiedp()) {
int ret = QMessageBox::question ( this, "Settings have changed", "Do you want to save the settings?", QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel, QMessageBox::Discard );
qDebug() << "doCancel says: answer =" << ret;
@@ -58,6 +74,7 @@ void CurveConfigurationDialog::doCancel() {
this->close();
break;
case QMessageBox::Discard:
+ mainApp->s.b->revert();
this->close();
break;
case QMessageBox::Cancel:
@@ -77,67 +94,6 @@ void CurveConfigurationDialog::doCancel() {
// Load the current Settings from the currently 'active' INI-file.
//
void CurveConfigurationDialog::loadSettings() {
- qDebug() << "CurveConfigurationDialog::loadSettings says: Starting ";
- QSettings settings("opentrack"); // Registry settings (in HK_USER)
-
- QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString();
- QSettings iniFile( currentFile, QSettings::IniFormat ); // Application settings (in INI-file)
-
- qDebug() << "CurveConfigurationDialog::loadSettings says: iniFile = " << currentFile;
-
- static const char* names[] = {
- "tx_alt",
- "ty_alt",
- "tz_alt",
- "rx_alt",
- "ry_alt",
- "rz_alt"
- };
-
- iniFile.beginGroup("Tracking");
-
- ui.tcomp_rz->setChecked(iniFile.value("tcomp-rz", false).toBool());
- ui.checkBox->setChecked(iniFile.value("compensate", true).toBool());
-
- for (int i = 0; i < 6; i++)
- mainApp->axis(i).altp = iniFile.value(names[i], false).toBool();
-
- QCheckBox* widgets[] = {
- ui.tx_altp,
- ui.ty_altp,
- ui.tz_altp,
- ui.rx_altp,
- ui.ry_altp,
- ui.rz_altp
- };
-
- for (int i = 0; i < 6; i++)
- widgets[i]->setChecked(mainApp->axis(i).altp);
-
- QDoubleSpinBox* widgets2[] = {
- ui.pos_tx,
- ui.pos_ty,
- ui.pos_tz,
- ui.pos_tx,
- ui.pos_ry,
- ui.pos_rz
- };
-
- const char* names2[] = {
- "zero_tx",
- "zero_ty",
- "zero_tz",
- "zero_rx",
- "zero_ry",
- "zero_rz"
- };
-
-
- for (int i = 0; i < 6; i++)
- widgets2[i]->setValue(iniFile.value(names2[i], 0).toDouble());
-
- iniFile.endGroup();
-
QFunctionConfigurator* configs[6] = {
ui.txconfig,
ui.tyconfig,
@@ -156,23 +112,10 @@ void CurveConfigurationDialog::loadSettings() {
ui.rzconfig_alt
};
- QCheckBox* checkboxes[6] = {
- ui.rx_altp,
- ui.ry_altp,
- ui.rz_altp,
- ui.tx_altp,
- ui.ty_altp,
- ui.tz_altp
- };
-
- QDoubleSpinBox* widgets3[] = {
- ui.pos_tx,
- ui.pos_ty,
- ui.pos_tz,
- ui.pos_tx,
- ui.pos_ry,
- ui.pos_rz
- };
+ QSettings settings("opentrack");
+ QString currentFile = settings.value("SettingsFile",
+ QCoreApplication::applicationDirPath() + "/settings/default.ini" )
+ .toString();
for (int i = 0; i < 6; i++)
{
@@ -182,8 +125,6 @@ void CurveConfigurationDialog::loadSettings() {
alt_configs[i]->loadSettings(currentFile);
connect(configs[i], SIGNAL(CurveChanged(bool)), this, SLOT(curveChanged(bool)), Qt::UniqueConnection);
connect(alt_configs[i], SIGNAL(CurveChanged(bool)), this, SLOT(curveChanged(bool)), Qt::UniqueConnection);
- connect(checkboxes[i], SIGNAL(stateChanged(int)), this, SLOT(curveChanged(int)), Qt::UniqueConnection);
- mainApp->axis(i).zero = widgets3[i]->value();
}
settingsDirty = false;
@@ -196,9 +137,11 @@ void CurveConfigurationDialog::save() {
qDebug() << "save() says: started";
- QSettings settings("opentrack"); // Registry settings (in HK_USER)
-
- QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString();
+ QSettings settings("opentrack");
+ QString currentFile =
+ settings.value("SettingsFile",
+ QCoreApplication::applicationDirPath() + "/settings/default.ini" )
+ .toString();
ui.rxconfig->saveSettings(currentFile);
ui.ryconfig->saveSettings(currentFile);
@@ -214,53 +157,5 @@ void CurveConfigurationDialog::save() {
ui.ryconfig_alt->saveSettings(currentFile);
ui.rzconfig_alt->saveSettings(currentFile);
- bool tcomp_rz = false, compensate = true;
-
- QSettings iniFile( currentFile, QSettings::IniFormat ); // Application settings (in INI-file)
-
- iniFile.beginGroup("Tracking");
-
- iniFile.setValue("tcomp-rz", tcomp_rz = ui.tcomp_rz->checkState() != Qt::Unchecked);
- iniFile.setValue("compensate", compensate = (bool) !!ui.checkBox->isChecked());
-
- if (mainApp->tracker)
- {
- mainApp->tracker->compensate = compensate;
- mainApp->tracker->tcomp_rz = tcomp_rz;
- }
-
- iniFile.setValue("rx_alt", ui.rx_altp->checkState() != Qt::Unchecked);
- iniFile.setValue("ry_alt", ui.ry_altp->checkState() != Qt::Unchecked);
- iniFile.setValue("rz_alt", ui.rz_altp->checkState() != Qt::Unchecked);
- iniFile.setValue("tx_alt", ui.tx_altp->checkState() != Qt::Unchecked);
- iniFile.setValue("ty_alt", ui.ty_altp->checkState() != Qt::Unchecked);
- iniFile.setValue("tz_alt", ui.tz_altp->checkState() != Qt::Unchecked);
-
- QDoubleSpinBox* widgets2[] = {
- ui.pos_tx,
- ui.pos_ty,
- ui.pos_tz,
- ui.pos_tx,
- ui.pos_ry,
- ui.pos_rz
- };
-
- const char* names2[] = {
- "zero_tx",
- "zero_ty",
- "zero_tz",
- "zero_rx",
- "zero_ry",
- "zero_rz"
- };
-
- for (int i = 0; i < 6; i++)
- {
- iniFile.setValue(names2[i], widgets2[i]->value());
- mainApp->axis(i).zero = widgets2[i]->value();
- }
-
- iniFile.endGroup();
-
settingsDirty = false;
}
diff --git a/facetracknoir/facetracknoir.cpp b/facetracknoir/facetracknoir.cpp
index 75ac737d..85207b53 100644
--- a/facetracknoir/facetracknoir.cpp
+++ b/facetracknoir/facetracknoir.cpp
@@ -95,6 +95,9 @@ FaceTrackNoIR::FaceTrackNoIR(QWidget *parent) :
keyCenter(this),
keyToggle(this),
#endif
+ b(bundle("opentrack-ui")),
+ s(b),
+ pose(std::vector<axis_opts*>{&s.a_x, &s.a_y, &s.a_z, &s.a_yaw, &s.a_pitch, &s.a_roll}),
timUpdateHeadPose(this),
pTrackerDialog(NULL),
pSecondTrackerDialog(NULL),
@@ -111,6 +114,16 @@ FaceTrackNoIR::FaceTrackNoIR(QWidget *parent) :
tracker = 0;
+ CurveConfigurationDialog* ccd;
+
+ if (!_curve_config)
+ {
+ ccd = new CurveConfigurationDialog( this, this );
+ _curve_config = ccd;
+ } else {
+ ccd = dynamic_cast<CurveConfigurationDialog*>(_curve_config);
+ }
+
QDir::setCurrent(QCoreApplication::applicationDirPath());
connect(ui.btnLoad, SIGNAL(clicked()), this, SLOT(open()));
@@ -124,18 +137,6 @@ FaceTrackNoIR::FaceTrackNoIR(QWidget *parent) :
connect(ui.btnShowServerControls, SIGNAL(clicked()), this, SLOT(showServerControls()));
connect(ui.btnShowFilterControls, SIGNAL(clicked()), this, SLOT(showFilterControls()));
- connect(ui.chkInvertYaw, SIGNAL(stateChanged(int)), this, SLOT(setInvertYaw(int)));
- connect(ui.chkInvertRoll, SIGNAL(stateChanged(int)), this, SLOT(setInvertRoll(int)));
- connect(ui.chkInvertPitch, SIGNAL(stateChanged(int)), this, SLOT(setInvertPitch(int)));
- connect(ui.chkInvertX, SIGNAL(stateChanged(int)), this, SLOT(setInvertX(int)));
- connect(ui.chkInvertY, SIGNAL(stateChanged(int)), this, SLOT(setInvertY(int)));
- connect(ui.chkInvertZ, SIGNAL(stateChanged(int)), this, SLOT(setInvertZ(int)));
-
- connect(ui.btnStartTracker, SIGNAL(clicked()), this, SLOT(startTracker()));
- connect(ui.btnStopTracker, SIGNAL(clicked()), this, SLOT(stopTracker()));
-
- GetCameraNameDX();
-
ui.cbxSecondTrackerSource->addItem(QIcon(), "None");
dlopen_filters.push_back((DynamicLibrary*) NULL);
ui.iconcomboFilter->addItem(QIcon(), "None");
@@ -144,11 +145,25 @@ FaceTrackNoIR::FaceTrackNoIR(QWidget *parent) :
fill_combobox("opentrack-tracker-*.", dlopen_trackers, ui.iconcomboTrackerSource, ui.cbxSecondTrackerSource);
fill_combobox("opentrack-filter-*.", dlopen_filters, ui.iconcomboFilter, NULL);
+ tie_setting(s.a_yaw.invert, ui.chkInvertYaw);
+ tie_setting(s.a_pitch.invert, ui.chkInvertPitch);
+ tie_setting(s.a_roll.invert, ui.chkInvertRoll);
+ tie_setting(s.a_x.invert, ui.chkInvertX);
+ tie_setting(s.a_y.invert, ui.chkInvertY);
+ tie_setting(s.a_z.invert, ui.chkInvertZ);
+ tie_setting(s.tracker_dll, ui.iconcomboTrackerSource);
+ tie_setting(s.tracker2_dll, ui.cbxSecondTrackerSource);
+ tie_setting(s.protocol_dll, ui.iconcomboProtocol);
+ tie_setting(s.filter_dll, ui.iconcomboFilter);
+
+ connect(ui.btnStartTracker, SIGNAL(clicked()), this, SLOT(startTracker()));
+ connect(ui.btnStopTracker, SIGNAL(clicked()), this, SLOT(stopTracker()));
+
+ GetCameraNameDX();
+
connect(ui.iconcomboProfile, SIGNAL(currentIndexChanged(int)), this, SLOT(profileSelected(int)));
connect(&timUpdateHeadPose, SIGNAL(timeout()), this, SLOT(showHeadPose()));
- loadSettings();
-
#ifndef _WIN32
connect(&keyCenter, SIGNAL(activated()), this, SLOT(shortcutRecentered()));
connect(&keyToggle, SIGNAL(activated()), this, SLOT(shortcutToggled()));
@@ -156,6 +171,8 @@ FaceTrackNoIR::FaceTrackNoIR(QWidget *parent) :
connect(&kbd_quit, SIGNAL(activated()), this, SLOT(exit()));
kbd_quit.setEnabled(true);
+
+ fill_profile_cbx();
}
FaceTrackNoIR::~FaceTrackNoIR() {
@@ -245,50 +262,20 @@ void FaceTrackNoIR::open() {
QSettings settings("opentrack");
settings.setValue ("SettingsFile", QFileInfo(fileName).absoluteFilePath());
}
+ fill_profile_cbx();
loadSettings();
}
}
void FaceTrackNoIR::save() {
- QSettings settings("opentrack");
-
- QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString();
- QSettings iniFile( currentFile, QSettings::IniFormat );
-
- iniFile.beginGroup ( "Tracking" );
-
- iniFile.setValue ( "invertYaw", ui.chkInvertYaw->isChecked() );
- iniFile.setValue ( "invertPitch", ui.chkInvertPitch->isChecked() );
- iniFile.setValue ( "invertRoll", ui.chkInvertRoll->isChecked() );
- iniFile.setValue ( "invertX", ui.chkInvertX->isChecked() );
- iniFile.setValue ( "invertY", ui.chkInvertY->isChecked() );
- iniFile.setValue ( "invertZ", ui.chkInvertZ->isChecked() );
- iniFile.endGroup ();
-
- iniFile.beginGroup ( "GameProtocol" );
- {
- DynamicLibrary* proto = dlopen_protocols.value( ui.iconcomboProtocol->currentIndex(), (DynamicLibrary*) NULL);
- iniFile.setValue ( "DLL", proto == NULL ? "" : proto->filename);
- }
- iniFile.endGroup ();
+ b->save();
- iniFile.beginGroup ( "TrackerSource" );
- {
- DynamicLibrary* tracker = dlopen_trackers.value( ui.iconcomboTrackerSource->currentIndex(), (DynamicLibrary*) NULL);
- iniFile.setValue ( "DLL", tracker == NULL ? "" : tracker->filename);
- }
- {
- DynamicLibrary* tracker = dlopen_trackers.value( ui.cbxSecondTrackerSource->currentIndex() - 1, (DynamicLibrary*) NULL);
- iniFile.setValue ( "2ndDLL", tracker == NULL ? "" : tracker->filename);
- }
- iniFile.endGroup ();
+ QSettings settings("opentrack");
- iniFile.beginGroup ( "Filter" );
- {
- DynamicLibrary* filter = dlopen_filters.value( ui.iconcomboFilter->currentIndex(), (DynamicLibrary*) NULL);
- iniFile.setValue ( "DLL", filter == NULL ? "" : filter->filename);
- }
- iniFile.endGroup ();
+ QString currentFile =
+ settings.value("SettingsFile",
+ QCoreApplication::applicationDirPath() + "/settings/default.ini")
+ .toString();
#if defined(__unix) || defined(__linux)
QByteArray bytes = QFile::encodeName(currentFile);
@@ -308,8 +295,7 @@ void FaceTrackNoIR::saveAs()
QString fileName = QFileDialog::getSaveFileName(this, tr("Save file"),
oldFile,
-// QCoreApplication::applicationDirPath() + "/settings",
- tr("Settings file (*.ini);;All Files (*)"));
+ tr("Settings file (*.ini);;All Files (*)"));
if (!fileName.isEmpty()) {
QFileInfo newFileInfo ( fileName );
@@ -325,117 +311,40 @@ void FaceTrackNoIR::saveAs()
}
settings.setValue ("SettingsFile", fileName);
- save();
+ save();
+ }
- loadSettings();
- }
+ fill_profile_cbx();
}
void FaceTrackNoIR::loadSettings() {
- if (looping)
- return;
- looping = true;
- qDebug() << "loadSettings says: Starting ";
- QSettings settings("opentrack");
-
- QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString();
- qDebug() << "Config file now" << currentFile;
- QSettings iniFile( currentFile, QSettings::IniFormat );
-
- QFileInfo pathInfo ( currentFile );
- setWindowTitle(QString( OPENTRACK_VERSION " :: ") + pathInfo.fileName());
-
- QDir settingsDir( pathInfo.dir() );
- QStringList filters;
- filters << "*.ini";
- iniFileList.clear();
- iniFileList = settingsDir.entryList( filters, QDir::Files, QDir::Name );
-
- ui.iconcomboProfile->clear();
- for ( int i = 0; i < iniFileList.size(); i++) {
- ui.iconcomboProfile->addItem(QIcon(":/images/settings16.png"), iniFileList.at(i));
- if (iniFileList.at(i) == pathInfo.fileName()) {
- ui.iconcomboProfile->setItemIcon(i, QIcon(":/images/settingsopen16.png"));
- ui.iconcomboProfile->setCurrentIndex( i );
- }
- }
-
- qDebug() << "loadSettings says: iniFile = " << currentFile;
-
- iniFile.beginGroup ( "Tracking" );
- ui.chkInvertYaw->setChecked (iniFile.value ( "invertYaw", 0 ).toBool());
- ui.chkInvertPitch->setChecked (iniFile.value ( "invertPitch", 0 ).toBool());
- ui.chkInvertRoll->setChecked (iniFile.value ( "invertRoll", 0 ).toBool());
- ui.chkInvertX->setChecked (iniFile.value ( "invertX", 0 ).toBool());
- ui.chkInvertY->setChecked (iniFile.value ( "invertY", 0 ).toBool());
- ui.chkInvertZ->setChecked (iniFile.value ( "invertZ", 0 ).toBool());
- iniFile.endGroup ();
-
- iniFile.beginGroup ( "GameProtocol" );
- QString selectedProtocolName = iniFile.value ( "DLL", "" ).toString();
- iniFile.endGroup ();
-
- for ( int i = 0; i < dlopen_protocols.size(); i++) {
- if (dlopen_protocols.at(i)->filename.compare( selectedProtocolName, Qt::CaseInsensitive ) == 0) {
- ui.iconcomboProtocol->setCurrentIndex( i );
- break;
- }
- }
-
- iniFile.beginGroup ( "TrackerSource" );
- QString selectedTrackerName = iniFile.value ( "DLL", "" ).toString();
- qDebug() << "loadSettings says: selectedTrackerName = " << selectedTrackerName;
- QString secondTrackerName = iniFile.value ( "2ndDLL", "None" ).toString();
- qDebug() << "loadSettings says: secondTrackerName = " << secondTrackerName;
- iniFile.endGroup ();
-
- for ( int i = 0; i < dlopen_trackers.size(); i++) {
- DynamicLibrary* foo = dlopen_trackers.at(i);
- if (foo && foo->filename.compare( selectedTrackerName, Qt::CaseInsensitive ) == 0) {
- ui.iconcomboTrackerSource->setCurrentIndex( i );
- }
- if (foo && foo->filename.compare( secondTrackerName, Qt::CaseInsensitive ) == 0) {
- ui.cbxSecondTrackerSource->setCurrentIndex( i + 1 );
- }
- }
-
- iniFile.beginGroup ( "Filter" );
- QString selectedFilterName = iniFile.value ( "DLL", "" ).toString();
- qDebug() << "createIconGroupBox says: selectedFilterName = " << selectedFilterName;
- iniFile.endGroup ();
-
- for ( int i = 0; i < dlopen_filters.size(); i++) {
- DynamicLibrary* foo = dlopen_filters.at(i);
- if (foo && foo->filename.compare( selectedFilterName, Qt::CaseInsensitive ) == 0) {
- ui.iconcomboFilter->setCurrentIndex( i );
- break;
- }
- }
-
- CurveConfigurationDialog* ccd;
-
- if (!_curve_config)
- {
- ccd = new CurveConfigurationDialog( this, this );
- _curve_config = ccd;
- } else {
- ccd = dynamic_cast<CurveConfigurationDialog*>(_curve_config);
- }
-
- ccd->loadSettings();
+ b->reload();
+ (dynamic_cast<CurveConfigurationDialog*>(_curve_config))->loadSettings();
+}
- looping = false;
+void FaceTrackNoIR::updateButtonState(bool running)
+{
+ bool e = !running;
+ ui.iconcomboProfile->setEnabled ( e );
+ ui.btnLoad->setEnabled ( e );
+ ui.btnSaveAs->setEnabled ( e );
+ ui.btnStartTracker->setEnabled ( e );
+ ui.btnStopTracker->setEnabled ( running );
+ ui.iconcomboProtocol->setEnabled ( e );
+ ui.btnShowServerControls->setEnabled ( e );
+ ui.iconcomboFilter->setEnabled ( e );
+ ui.iconcomboTrackerSource->setEnabled(e);
+ ui.cbxSecondTrackerSource->setEnabled(e);
+
+ ui.btnStartTracker->setEnabled(e);
+ ui.btnStopTracker->setEnabled(running);
}
-void FaceTrackNoIR::startTracker( ) {
+void FaceTrackNoIR::startTracker( ) {
+ b->save();
+ loadSettings();
bindKeyboardShortcuts();
- ui.iconcomboProfile->setEnabled ( false );
- ui.btnLoad->setEnabled ( false );
- ui.btnSave->setEnabled ( false );
- ui.btnSaveAs->setEnabled ( false );
- ui.btnShowFilterControls->setEnabled ( true );
-
if (Libraries)
delete Libraries;
Libraries = new SelectedLibraries(this);
@@ -457,54 +366,19 @@ void FaceTrackNoIR::startTracker( ) {
delete tracker;
}
- QSettings settings("opentrack");
- QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString();
- QSettings iniFile( currentFile, QSettings::IniFormat );
-
- for (int i = 0; i < 6; i++)
{
- axis(i).curve.loadSettings(iniFile);
- axis(i).curveAlt.loadSettings(iniFile);
- }
+ QSettings settings("opentrack");
+ QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString();
+ QSettings iniFile( currentFile, QSettings::IniFormat );
- static const char* names[] = {
- "tx_alt",
- "ty_alt",
- "tz_alt",
- "rx_alt",
- "ry_alt",
- "rz_alt",
- };
-
- static const char* invert_names[] = {
- "invertX",
- "invertY",
- "invertZ",
- "invertYaw",
- "invertPitch",
- "invertRoll"
- };
-
- iniFile.beginGroup("Tracking");
-
- for (int i = 0; i < 6; i++) {
- axis(i).altp = iniFile.value(names[i], false).toBool();
- axis(i).invert = iniFile.value(invert_names[i], false).toBool() ? 1 : -1;
+ for (int i = 0; i < 6; i++)
+ {
+ axis(i).curve.loadSettings(iniFile);
+ axis(i).curveAlt.loadSettings(iniFile);
+ }
}
- tracker = new Tracker ( this );
-
- tracker->compensate = iniFile.value("compensate", true).toBool();
- tracker->tcomp_rz = iniFile.value("tcomp-rz", false).toBool();
-
- iniFile.endGroup();
-
- tracker->setInvertAxis(Yaw, ui.chkInvertYaw->isChecked() );
- tracker->setInvertAxis(Pitch, ui.chkInvertPitch->isChecked() );
- tracker->setInvertAxis(Roll, ui.chkInvertRoll->isChecked() );
- tracker->setInvertAxis(TX, ui.chkInvertX->isChecked() );
- tracker->setInvertAxis(TY, ui.chkInvertY->isChecked() );
- tracker->setInvertAxis(TZ, ui.chkInvertZ->isChecked() );
+ tracker = new Tracker ( this, s );
if (pTrackerDialog && Libraries->pTracker) {
pTrackerDialog->registerTracker( Libraries->pTracker );
@@ -517,21 +391,12 @@ void FaceTrackNoIR::startTracker( ) {
ui.video_frame->show();
- ui.btnStartTracker->setEnabled ( false );
- ui.btnStopTracker->setEnabled ( true );
-
- ui.iconcomboTrackerSource->setEnabled ( false );
- ui.cbxSecondTrackerSource->setEnabled ( false );
- ui.iconcomboProtocol->setEnabled ( false );
- ui.btnShowServerControls->setEnabled ( false );
- ui.iconcomboFilter->setEnabled ( false );
-
- GetCameraNameDX();
-
timUpdateHeadPose.start(50);
+
+ updateButtonState(true);
}
-void FaceTrackNoIR::stopTracker( ) {
+void FaceTrackNoIR::stopTracker( ) {
ui.game_name->setText("Not connected");
#if defined(_WIN32)
if (keybindingWorker)
@@ -555,39 +420,16 @@ void FaceTrackNoIR::stopTracker( ) {
pFilterDialog->unregisterFilter();
if ( tracker ) {
- qDebug() << "Done with tracking";
tracker->should_quit = true;
tracker->wait();
-
- qDebug() << "stopTracker says: Deleting tracker!";
delete tracker;
- qDebug() << "stopTracker says: Tracker deleted!";
tracker = 0;
if (Libraries) {
delete Libraries;
Libraries = NULL;
}
}
- ui.btnStartTracker->setEnabled ( true );
- ui.btnStopTracker->setEnabled ( false );
- ui.iconcomboProtocol->setEnabled ( true );
- ui.iconcomboTrackerSource->setEnabled ( true );
- ui.cbxSecondTrackerSource->setEnabled ( true );
- ui.iconcomboFilter->setEnabled ( true );
-
- ui.btnShowServerControls->setEnabled ( true );
- ui.video_frame->hide();
-
- ui.iconcomboProfile->setEnabled ( true );
- ui.btnLoad->setEnabled ( true );
- ui.btnSave->setEnabled ( true );
- ui.btnSaveAs->setEnabled ( true );
- ui.btnShowFilterControls->setEnabled ( true );
-}
-
-void FaceTrackNoIR::setInvertAxis(Axis axis, int invert ) {
- if (tracker)
- tracker->setInvertAxis (axis, (invert != 0)?true:false );
+ updateButtonState(false);
}
void FaceTrackNoIR::showHeadPose() {
@@ -625,7 +467,6 @@ void FaceTrackNoIR::showHeadPose() {
}
}
-/** toggles Engine Controls Dialog **/
void FaceTrackNoIR::showTrackerSettings() {
if (pTrackerDialog) {
delete pTrackerDialog;
@@ -641,7 +482,7 @@ void FaceTrackNoIR::showTrackerSettings() {
foo->setFixedSize(foo->size());
if (Libraries && Libraries->pTracker)
pTrackerDialog->registerTracker(Libraries->pTracker);
- pTrackerDialog->Initialize(this);
+ dynamic_cast<QWidget*>(pTrackerDialog)->show();
}
}
}
@@ -661,7 +502,7 @@ void FaceTrackNoIR::showSecondTrackerSettings() {
foo->setFixedSize(foo->size());
if (Libraries && Libraries->pSecondTracker)
pSecondTrackerDialog->registerTracker(Libraries->pSecondTracker);
- pSecondTrackerDialog->Initialize(this);
+ dynamic_cast<QWidget*>(pSecondTrackerDialog)->show();
}
}
}
@@ -679,7 +520,7 @@ void FaceTrackNoIR::showServerControls() {
if (pProtocolDialog) {
auto foo = dynamic_cast<QWidget*>(pProtocolDialog);
foo->setFixedSize(foo->size());
- pProtocolDialog->Initialize(this);
+ dynamic_cast<QWidget*>(pProtocolDialog)->show();
}
}
}
@@ -697,9 +538,9 @@ void FaceTrackNoIR::showFilterControls() {
if (pFilterDialog) {
auto foo = dynamic_cast<QWidget*>(pFilterDialog);
foo->setFixedSize(foo->size());
- pFilterDialog->Initialize(this);
if (Libraries && Libraries->pFilter)
pFilterDialog->registerFilter(Libraries->pFilter);
+ dynamic_cast<QWidget*>(pFilterDialog)->show();
}
}
}
@@ -730,34 +571,55 @@ void FaceTrackNoIR::exit() {
QCoreApplication::exit(0);
}
-void FaceTrackNoIR::profileSelected(int index)
+void FaceTrackNoIR::fill_profile_cbx()
{
if (looping)
return;
+ looping = true;
+ QSettings settings("opentrack");
+ QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString();
+ qDebug() << "Config file now" << currentFile;
+ QFileInfo pathInfo ( currentFile );
+ setWindowTitle(QString( OPENTRACK_VERSION " :: ") + pathInfo.fileName());
+ QDir settingsDir( pathInfo.dir() );
+ QStringList filters;
+ filters << "*.ini";
+ auto iniFileList = settingsDir.entryList( filters, QDir::Files, QDir::Name );
+ ui.iconcomboProfile->clear();
+ for ( int i = 0; i < iniFileList.size(); i++) {
+ ui.iconcomboProfile->addItem(QIcon(":/images/settings16.png"), iniFileList.at(i));
+ if (iniFileList.at(i) == pathInfo.fileName()) {
+ ui.iconcomboProfile->setCurrentIndex( i );
+ }
+ }
+ looping = false;
+}
+
+void FaceTrackNoIR::profileSelected(int index)
+{
QSettings settings("opentrack");
QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString();
QFileInfo pathInfo ( currentFile );
-
- settings.setValue ("SettingsFile", pathInfo.absolutePath() + "/" + iniFileList.value(index, ""));
+ settings.setValue ("SettingsFile", pathInfo.absolutePath() + "/" + ui.iconcomboProfile->itemText(index));
loadSettings();
}
#if !defined(_WIN32)
-void FaceTrackNoIR::bind_keyboard_shortcut(QxtGlobalShortcut& key, const QString label, QSettings& iniFile)
+void FaceTrackNoIR::bind_keyboard_shortcut(QxtGlobalShortcut& key, key_opts& k)
{
- const int idx = iniFile.value("Key_index_" + label, 0).toInt();
key.setShortcut(QKeySequence::fromString(""));
key.setDisabled();
- QString seq(global_key_sequences.value(idx, ""));
+ const int idx = k.key_index;
if (idx > 0)
{
+ QString seq(global_key_sequences.value(idx, ""));
if (!seq.isEmpty())
{
- if (iniFile.value(QString("Shift_%1").arg(label), false).toBool())
+ if (k.shift)
seq = "Shift+" + seq;
- if (iniFile.value(QString("Alt_%1").arg(label), false).toBool())
+ if (k.alt)
seq = "Alt+" + seq;
- if (iniFile.value(QString("Ctrl_%1").arg(label), false).toBool())
+ if (k.ctrl)
seq = "Ctrl+" + seq;
key.setShortcut(QKeySequence::fromString(seq, QKeySequence::PortableText));
key.setEnabled();
@@ -767,39 +629,31 @@ void FaceTrackNoIR::bind_keyboard_shortcut(QxtGlobalShortcut& key, const QString
}
}
#else
-static void bind_keyboard_shortcut(Key& key, const QString label, QSettings& iniFile)
+static void bind_keyboard_shortcut(Key& key, key_opts& k)
{
- const int idx = iniFile.value("Key_index_" + label, 0).toInt();
+ int idx = k.key_index;
if (idx > 0)
{
key.keycode = 0;
key.shift = key.alt = key.ctrl = 0;
if (idx < global_windows_key_sequences.size())
key.keycode = global_windows_key_sequences[idx];
- key.shift = iniFile.value(QString("Shift_%1").arg(label), false).toBool();
- key.alt = iniFile.value(QString("Alt_%1").arg(label), false).toBool();
- key.ctrl = iniFile.value(QString("Ctrl_%1").arg(label), false).toBool();
+ key.shift = k.shift;
+ key.alt = k.alt;
+ key.ctrl = k.ctrl;
}
}
#endif
void FaceTrackNoIR::bindKeyboardShortcuts()
{
- QSettings settings("opentrack");
-
- QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString();
- QSettings iniFile( currentFile, QSettings::IniFormat );
- iniFile.beginGroup ( "KB_Shortcuts" );
-
#if !defined(_WIN32)
- bind_keyboard_shortcut(keyCenter, "Center", iniFile);
- bind_keyboard_shortcut(keyToggle, "Toggle", iniFile);
+ bind_keyboard_shortcut(keyCenter, s.center_key);
+ bind_keyboard_shortcut(keyToggle, s.toggle_key);
#else
- bind_keyboard_shortcut(keyCenter, "Center", iniFile);
- bind_keyboard_shortcut(keyToggle, "Toggle", iniFile);
+ bind_keyboard_shortcut(keyCenter, s.center_key);
+ bind_keyboard_shortcut(keyToggle, s.toggle_key);
#endif
- iniFile.endGroup ();
-
if (tracker) /* running already */
{
#if defined(_WIN32)
@@ -822,9 +676,7 @@ void FaceTrackNoIR::shortcutRecentered()
qDebug() << "Center";
if (tracker)
- {
tracker->do_center = true;
- }
}
void FaceTrackNoIR::shortcutToggled()
@@ -832,7 +684,5 @@ void FaceTrackNoIR::shortcutToggled()
QApplication::beep();
qDebug() << "Toggle";
if (tracker)
- {
tracker->enabled = !tracker->enabled;
- }
}
diff --git a/facetracknoir/facetracknoir.h b/facetracknoir/facetracknoir.h
index 72ccebd8..53b83754 100644
--- a/facetracknoir/facetracknoir.h
+++ b/facetracknoir/facetracknoir.h
@@ -39,6 +39,7 @@
#include <QString>
#include <QByteArray>
#include <QShortcut>
+#include <vector>
#if !defined(_WIN32)
# include "qxt-mini/QxtGlobalShortcut"
#else
@@ -50,6 +51,11 @@
#include "ui_facetracknoir.h"
+#include "facetracknoir/options.h"
+using namespace options;
+
+#include "facetracknoir/main-settings.hpp"
+
#include "global-settings.h"
#include "tracker.h"
#include "facetracknoir/shortcuts.h"
@@ -100,6 +106,8 @@ public:
QxtGlobalShortcut keyCenter;
QxtGlobalShortcut keyToggle;
#endif
+ pbundle b;
+ main_settings s;
public slots:
void shortcutRecentered();
void shortcutToggled();
@@ -108,7 +116,6 @@ private:
HeadPoseData pose;
Ui::OpentrackUI ui;
QTimer timUpdateHeadPose; // Timer to display headpose
- QStringList iniFileList; // List of INI-files, that are present in the Settings folder
ITrackerDialog* pTrackerDialog; // Pointer to Tracker dialog instance (in DLL)
ITrackerDialog* pSecondTrackerDialog; // Pointer to the second Tracker dialog instance (in DLL)
@@ -122,6 +129,7 @@ private:
void GetCameraNameDX();
void loadSettings();
+ void updateButtonState(bool);
QList<DynamicLibrary*> dlopen_filters;
QList<DynamicLibrary*> dlopen_trackers;
@@ -129,18 +137,18 @@ private:
QShortcut kbd_quit;
#ifndef _WIN32
- void bind_keyboard_shortcut(QxtGlobalShortcut& key, const QString label, QSettings& iniFile);
+ void bind_keyboard_shortcut(QxtGlobalShortcut&, key_opts& k);
#endif
- volatile bool looping;
+ bool looping;
+
+ void fill_profile_cbx();
private slots:
- //file menu
void open();
void save();
void saveAs();
void exit();
- // void setIcon(int index);
void profileSelected(int index);
void showTrackerSettings();
@@ -151,30 +159,10 @@ private slots:
void showKeyboardShortcuts();
void showCurveConfiguration();
- void setInvertAxis( Axis axis, int invert );
- void setInvertYaw(int invert) {
- setInvertAxis(Yaw, invert);
- }
- void setInvertPitch(int invert) {
- setInvertAxis(Pitch, invert);
- }
- void setInvertRoll(int invert) {
- setInvertAxis(Roll, invert);
- }
- void setInvertX(int invert) {
- setInvertAxis(TX, invert);
- }
- void setInvertY(int invert) {
- setInvertAxis(TY, invert);
- }
- void setInvertZ(int invert) {
- setInvertAxis(TZ, invert);
- }
void showHeadPose();
void startTracker();
void stopTracker();
-
};
#endif // FaceTrackNoIR_H
diff --git a/facetracknoir/ftnoir_curves.ui b/facetracknoir/ftnoir_curves.ui
index 5355dd20..9b5c8d07 100644
--- a/facetracknoir/ftnoir_curves.ui
+++ b/facetracknoir/ftnoir_curves.ui
@@ -761,7 +761,7 @@
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
- <widget class="QCheckBox" name="checkBox">
+ <widget class="QCheckBox" name="tcomp_enable">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
@@ -816,7 +816,7 @@
<tabstop>tx_altp</tabstop>
<tabstop>ty_altp</tabstop>
<tabstop>tz_altp</tabstop>
- <tabstop>checkBox</tabstop>
+ <tabstop>tcomp_enable</tabstop>
<tabstop>tabWidget</tabstop>
<tabstop>pos_tx</tabstop>
<tabstop>buttonBox</tabstop>
diff --git a/facetracknoir/ftnoir_keyboardshortcuts.ui b/facetracknoir/ftnoir_keyboardshortcuts.ui
index 565c0e77..1477d56d 100644
--- a/facetracknoir/ftnoir_keyboardshortcuts.ui
+++ b/facetracknoir/ftnoir_keyboardshortcuts.ui
@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
- <width>335</width>
- <height>120</height>
+ <width>360</width>
+ <height>124</height>
</rect>
</property>
<property name="sizePolicy">
@@ -191,53 +191,10 @@
</property>
</widget>
</item>
- <item row="3" column="0" colspan="2">
- <widget class="QPushButton" name="btnCancel">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="minimumSize">
- <size>
- <width>100</width>
- <height>0</height>
- </size>
- </property>
- <property name="maximumSize">
- <size>
- <width>100</width>
- <height>16777215</height>
- </size>
- </property>
- <property name="text">
- <string>Cancel</string>
- </property>
- </widget>
- </item>
<item row="3" column="3" colspan="2">
- <widget class="QPushButton" name="btnOK">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="minimumSize">
- <size>
- <width>100</width>
- <height>0</height>
- </size>
- </property>
- <property name="maximumSize">
- <size>
- <width>100</width>
- <height>16777215</height>
- </size>
- </property>
- <property name="text">
- <string>OK</string>
+ <widget class="QDialogButtonBox" name="buttonBox">
+ <property name="standardButtons">
+ <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
diff --git a/facetracknoir/images/settingsopen16.png b/facetracknoir/images/settingsopen16.png
deleted file mode 100644
index 5bf65f0d..00000000
--- a/facetracknoir/images/settingsopen16.png
+++ /dev/null
Binary files differ
diff --git a/facetracknoir/main-facetracknoir.qrc b/facetracknoir/main-facetracknoir.qrc
index eb5ad991..6cb2e300 100644
--- a/facetracknoir/main-facetracknoir.qrc
+++ b/facetracknoir/main-facetracknoir.qrc
@@ -2,7 +2,6 @@
<qresource prefix="/">
<file>uielements/tools.png</file>
<file>images/settings16.png</file>
- <file>images/settingsopen16.png</file>
<file>uielements/curves.png</file>
<file>images/facetracknoir.png</file>
</qresource>
diff --git a/facetracknoir/main-settings.hpp b/facetracknoir/main-settings.hpp
new file mode 100644
index 00000000..c9b5ff66
--- /dev/null
+++ b/facetracknoir/main-settings.hpp
@@ -0,0 +1,56 @@
+#pragma once
+
+#include <QString>
+#include "facetracknoir/options.h"
+using namespace options;
+
+struct key_opts {
+ value<int> key_index;
+ value<bool> ctrl, alt, shift;
+ key_opts(pbundle b, const QString& name) :
+ key_index(b, QString("key-index-%1").arg(name), 0),
+ ctrl(b, QString("key-ctrl-%1").arg(name), 0),
+ alt(b, QString("key-alt-%1").arg(name), 0),
+ shift(b, QString("key-shift-%1").arg(name), 0)
+ {}
+};
+
+struct axis_opts {
+ value<double> zero;
+ value<bool> invert, altp;
+ axis_opts(pbundle b, QString pfx) :
+ zero(b, n(pfx, "zero-pos"), 0),
+ invert(b, n(pfx, "invert-axis"), false),
+ altp(b, n(pfx, "alt-axis-sign"), false)
+ {}
+private:
+ static inline QString n(QString pfx, QString name) {
+ return QString("%1-%2").arg(pfx, name);
+ }
+};
+
+struct main_settings {
+ pbundle b;
+ key_opts center_key;
+ key_opts toggle_key;
+ value<QString> tracker_dll, tracker2_dll, filter_dll, protocol_dll;
+ axis_opts a_x, a_y, a_z, a_yaw, a_pitch, a_roll;
+ value<bool> tcomp_p, tcomp_tz;
+ main_settings(pbundle b) :
+ b(b),
+ center_key(b, "center"),
+ toggle_key(b, "toggle"),
+ tracker_dll(b, "tracker-dll", ""),
+ tracker2_dll(b, "tracker2-dll", ""),
+ filter_dll(b, "filter-dll", ""),
+ protocol_dll(b, "protocol-dll", ""),
+ a_x(b, "x"),
+ a_y(b, "y"),
+ a_z(b, "z"),
+ a_yaw(b, "yaw"),
+ a_pitch(b, "pitch"),
+ a_roll(b, "roll"),
+ tcomp_p(b, "compensate-translation", true),
+ tcomp_tz(b, "compensate-translation-disable-z-axis", false)
+ {}
+};
diff --git a/facetracknoir/main.cpp b/facetracknoir/main.cpp
index 5ba3fcd5..3143a093 100644
--- a/facetracknoir/main.cpp
+++ b/facetracknoir/main.cpp
@@ -30,6 +30,7 @@
#include <QList>
#include <QDir>
#include <QStringList>
+#include <memory>
#if defined(_WIN32) && defined(_MSC_VER)
# include <windows.h>
@@ -61,11 +62,9 @@ int main(int argc, char** argv)
#endif
QApplication::setAttribute(Qt::AA_X11InitThreads, true);
QApplication app(argc, argv);
- FaceTrackNoIR w;
- QDesktopWidget desktop;
+ auto w = std::make_shared<FaceTrackNoIR>();
- w.move(desktop.screenGeometry().width()/2-w.width()/2, 100);
- w.show();
+ w->show();
app.exec();
return 0;
diff --git a/facetracknoir/options.h b/facetracknoir/options.h
new file mode 100644
index 00000000..bc53a456
--- /dev/null
+++ b/facetracknoir/options.h
@@ -0,0 +1,317 @@
+/* Copyright (c) 2013 Stanislaw Halik
+ *
+ * Permission to use, copy, modify, and/or distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ */
+
+#pragma once
+
+#include <QObject>
+#include <QSettings>
+#include <QMap>
+#include <QString>
+#include <QVariant>
+#include <QMutex>
+#include <QMutexLocker>
+#include <memory>
+#include <cassert>
+#include <QWidget>
+#include <QComboBox>
+#include <QCheckBox>
+#include <QDoubleSpinBox>
+#include <QSpinBox>
+#include <QSlider>
+#include <QLineEdit>
+#include <QLabel>
+#include <QCoreApplication>
+
+#ifdef __GNUC__
+# define ov override
+#else
+# define ov
+#endif
+
+#include <QDebug>
+
+namespace options {
+ template<typename T>
+ inline T qcruft_to_t (const QVariant& t);
+
+ template<>
+ inline int qcruft_to_t<int>(const QVariant& t)
+ {
+ return t.toInt();
+ }
+
+ template<>
+ inline QString qcruft_to_t<QString>(const QVariant& t)
+ {
+ return t.toString();
+ }
+
+ template<>
+ inline bool qcruft_to_t<bool>(const QVariant& t)
+ {
+ return t.toBool();
+ }
+
+ template<>
+ inline double qcruft_to_t<double>(const QVariant& t)
+ {
+ return t.toDouble();
+ }
+
+ template<>
+ inline QVariant qcruft_to_t<QVariant>(const QVariant& t)
+ {
+ return t;
+ }
+
+ // snapshot of qsettings group at given time
+ class group {
+ private:
+ QMap<QString, QVariant> map;
+ QString name;
+ public:
+ group(const QString& name) : name(name)
+ {
+ QSettings settings(group::org);
+ QString currentFile =
+ settings.value("SettingsFile",
+ QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString();
+ QSettings iniFile(currentFile, QSettings::IniFormat);
+ iniFile.beginGroup(name);
+ for (auto& k : iniFile.childKeys())
+ map[k] = iniFile.value(k);
+ iniFile.endGroup();
+ }
+ static constexpr const char* org = "opentrack";
+ void save() {
+ QSettings settings(group::org);
+ QString currentFile =
+ settings.value("SettingsFile",
+ QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString();
+ QSettings s(currentFile, QSettings::IniFormat);
+ s.beginGroup(name);
+ for (auto& k : map.keys())
+ s.setValue(k, map[k]);
+ s.endGroup();
+ }
+ template<typename T>
+ T get(const QString& k) {
+ return qcruft_to_t<T>(map.value(k));
+ }
+
+ void put(const QString& s, const QVariant& d)
+ {
+ map[s] = d;
+ }
+ bool contains(const QString& s)
+ {
+ return map.contains(s);
+ }
+ };
+
+ class impl_bundle : public QObject {
+ Q_OBJECT
+ private:
+ QMutex mtx;
+ const QString group_name;
+ group saved;
+ group transient;
+ impl_bundle(const impl_bundle&) = delete;
+ impl_bundle& operator=(const impl_bundle&) = delete;
+ bool modified;
+ public:
+ impl_bundle(const QString& group_name) :
+ mtx(QMutex::Recursive),
+ group_name(group_name),
+ saved(group_name),
+ transient(saved),
+ modified(false)
+ {
+ }
+ void reload() {
+ QMutexLocker l(&mtx);
+ saved = group(group_name);
+ transient = saved;
+ emit reloaded();
+ }
+
+ std::shared_ptr<impl_bundle> make(const QString& name) {
+ return std::make_shared<impl_bundle>(name);
+ }
+ void store(const QString& name, const QVariant& datum)
+ {
+ QMutexLocker l(&mtx);
+ if (!transient.contains(name) || datum != transient.get<QVariant>(name))
+ {
+ modified = true;
+ transient.put(name, datum);
+ emit bundleChanged();
+ }
+ }
+ bool contains(const QString& name)
+ {
+ QMutexLocker l(&mtx);
+ return transient.contains(name);
+ }
+ template<typename T>
+ T get(const QString& name) {
+ QMutexLocker l(&mtx);
+ return transient.get<T>(name);
+ }
+ void save()
+ {
+ QMutexLocker l(&mtx);
+ modified = false;
+ saved = transient;
+ transient.save();
+ }
+ void revert()
+ {
+ QMutexLocker l(&mtx);
+ modified = false;
+ transient = saved;
+ emit bundleChanged();
+ }
+
+ bool modifiedp() {
+ QMutexLocker l(&mtx);
+ return modified;
+ }
+ signals:
+ void bundleChanged();
+ void reloaded();
+ };
+
+ typedef std::shared_ptr<impl_bundle> pbundle;
+
+ class base_value : public QObject {
+ Q_OBJECT
+ public:
+ base_value(pbundle b, const QString& name) : b(b), self_name(name) {
+ connect(b.get(), SIGNAL(reloaded()), this, SLOT(reread_value()));
+ }
+ protected:
+ virtual QVariant operator=(const QVariant& datum) = 0;
+ pbundle b;
+ QString self_name;
+ public slots:
+ void reread_value()
+ {
+ this->operator=(b->get<QVariant>(self_name));
+ }
+ public slots:
+#define DEFINE_SLOT(t) void setValue(t datum) { this->operator=(qVariantFromValue(datum)); }
+ DEFINE_SLOT(double)
+ DEFINE_SLOT(int)
+ DEFINE_SLOT(QString)
+ DEFINE_SLOT(bool)
+ signals:
+#define DEFINE_SIGNAL(t) void valueChanged(t);
+ DEFINE_SIGNAL(double)
+ DEFINE_SIGNAL(int)
+ DEFINE_SIGNAL(QString)
+ DEFINE_SIGNAL(bool)
+ };
+
+ template<typename T>
+ class value : public base_value {
+ private:
+ T def;
+ protected:
+ QVariant operator=(const QVariant& datum) {
+ auto foo = qcruft_to_t<T>(datum);
+ b->store(self_name, qVariantFromValue<T>(foo));
+ emit valueChanged(foo);
+ return datum;
+ }
+ public:
+ static constexpr const Qt::ConnectionType CONNTYPE = Qt::QueuedConnection;
+ value(pbundle b, const QString& name, T def) :
+ base_value(b, name), def(def)
+ {
+ if (!b->contains(name) || b->get<QVariant>(name).type() == QVariant::Invalid)
+ {
+ this->operator=(qVariantFromValue<T>(def));
+ }
+ }
+ operator T() { return b->get<T>(self_name); }
+ QVariant operator=(const T& datum)
+ {
+ return this->operator =(qVariantFromValue<T>(datum));
+ }
+ };
+
+ template<typename T, typename Q>
+ inline void tie_setting(value<T>&, Q*);
+
+ template<>
+ inline void tie_setting(value<int>& v, QComboBox* cb)
+ {
+ base_value::connect(cb, SIGNAL(currentIndexChanged(int)), &v, SLOT(setValue(int)), v.CONNTYPE);
+ base_value::connect(&v, SIGNAL(valueChanged(int)), cb, SLOT(setCurrentIndex(int)), v.CONNTYPE);
+ cb->setCurrentIndex(v);
+ }
+
+ template<>
+ inline void tie_setting(value<QString>& v, QComboBox* cb)
+ {
+ base_value::connect(cb, SIGNAL(currentTextChanged(QString)), &v, SLOT(setValue(QString)), v.CONNTYPE);
+ base_value::connect(&v, SIGNAL(valueChanged(QString)), cb, SLOT(setCurrentText(QString)), v.CONNTYPE);
+ cb->setCurrentText(v);
+ }
+
+ template<>
+ inline void tie_setting(value<bool>& v, QCheckBox* cb)
+ {
+ base_value::connect(cb, SIGNAL(toggled(bool)), &v, SLOT(setValue(bool)), v.CONNTYPE);
+ base_value::connect(&v, SIGNAL(valueChanged(bool)), cb, SLOT(setChecked(bool)), v.CONNTYPE);
+ cb->setChecked(v);
+ }
+
+ template<>
+ inline void tie_setting(value<double>& v, QDoubleSpinBox* dsb)
+ {
+ base_value::connect(dsb, SIGNAL(valueChanged(double)), &v, SLOT(setValue(double)), v.CONNTYPE);
+ base_value::connect(&v, SIGNAL(valueChanged(double)), dsb, SLOT(setValue(double)), v.CONNTYPE);
+ dsb->setValue(v);
+ }
+
+ template<>
+ inline void tie_setting(value<int>& v, QSpinBox* sb)
+ {
+ base_value::connect(sb, SIGNAL(valueChanged(int)), &v, SLOT(setValue(int)), v.CONNTYPE);
+ base_value::connect(&v, SIGNAL(valueChanged(int)), sb, SLOT(setValue(int)), v.CONNTYPE);
+ sb->setValue(v);
+ }
+
+ template<>
+ inline void tie_setting(value<int>& v, QSlider* sl)
+ {
+ base_value::connect(sl, SIGNAL(valueChanged(int)), &v, SLOT(setValue(int)), v.CONNTYPE);
+ base_value::connect(&v, SIGNAL(valueChanged(int)), sl, SLOT(setValue(int)), v.CONNTYPE);
+ sl->setValue(v);
+ }
+
+ template<>
+ inline void tie_setting(value<QString>& v, QLineEdit* le)
+ {
+ base_value::connect(le, SIGNAL(textChanged(QString)), &v, SLOT(setValue(QString)), v.CONNTYPE);
+ base_value::connect(&v, SIGNAL(valueChanged(QString)),le, SLOT(setText(QString)), v.CONNTYPE);
+ le->setText(v);
+ }
+
+ template<>
+ inline void tie_setting(value<QString>& v, QLabel* lb)
+ {
+ base_value::connect(&v, SIGNAL(valueChanged(QString)), lb, SLOT(setText(QString)), v.CONNTYPE);
+ lb->setText(v);
+ }
+
+ inline pbundle bundle(const QString& group) {
+ return std::make_shared<impl_bundle>(group);
+ }
+}
diff --git a/facetracknoir/shortcuts.cpp b/facetracknoir/shortcuts.cpp
index 6a972aa3..2f117ea4 100644
--- a/facetracknoir/shortcuts.cpp
+++ b/facetracknoir/shortcuts.cpp
@@ -12,63 +12,55 @@ KeyboardShortcutDialog::KeyboardShortcutDialog( FaceTrackNoIR *ftnoir, QWidget *
mainApp = ftnoir; // Preserve a pointer to FTNoIR
// Connect Qt signals to member-functions
- connect(ui.btnOK, SIGNAL(clicked()), this, SLOT(doOK()));
- connect(ui.btnCancel, SIGNAL(clicked()), this, SLOT(doCancel()));
+ connect(ui.buttonBox, SIGNAL(accepted()), this, SLOT(doOK()));
+ connect(ui.buttonBox, SIGNAL(rejected()), this, SLOT(doCancel()));
for ( int i = 0; i < global_key_sequences.size(); i++) {
ui.cbxCenterKey->addItem(global_key_sequences.at(i));
ui.cbxToggleKey->addItem(global_key_sequences.at(i));
}
- loadSettings();
-}
+ tie_setting(mainApp->s.center_key.key_index, ui.cbxCenterKey);
+ tie_setting(mainApp->s.center_key.alt, ui.chkCenterAlt);
+ tie_setting(mainApp->s.center_key.shift, ui.chkCenterShift);
+ tie_setting(mainApp->s.center_key.ctrl, ui.chkCenterCtrl);
-//
-// Destructor for server-dialog
-//
-KeyboardShortcutDialog::~KeyboardShortcutDialog() {
- qDebug() << "~KeyboardShortcutDialog() says: started";
+ tie_setting(mainApp->s.toggle_key.key_index, ui.cbxToggleKey);
+ tie_setting(mainApp->s.toggle_key.alt, ui.chkToggleAlt);
+ tie_setting(mainApp->s.toggle_key.shift, ui.chkToggleShift);
+ tie_setting(mainApp->s.toggle_key.ctrl, ui.chkToggleCtrl);
}
//
// OK clicked on server-dialog
//
void KeyboardShortcutDialog::doOK() {
- save();
+ mainApp->b->save();
this->close();
if (mainApp->tracker)
mainApp->bindKeyboardShortcuts();
}
-void KeyboardShortcutDialog::showEvent ( QShowEvent * ) {
- loadSettings();
-}
-
-//
-// Cancel clicked on server-dialog
-//
void KeyboardShortcutDialog::doCancel() {
//
// Ask if changed Settings should be saved
//
- if (settingsDirty) {
- int ret = QMessageBox::question ( this, "Settings have changed", "Do you want to save the settings?", QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel, QMessageBox::Discard );
+ if (mainApp->b->modifiedp()) {
+ int ret = QMessageBox::question ( this, "Settings have changed", "Do you want to save the settings?", QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel);
qDebug() << "doCancel says: answer =" << ret;
switch (ret) {
case QMessageBox::Save:
- save();
+ mainApp->b->save();
this->close();
break;
case QMessageBox::Discard:
- this->close();
+ mainApp->b->revert();
+ close();
break;
case QMessageBox::Cancel:
- // Cancel was clicked
- break;
default:
- // should never be reached
break;
}
}
@@ -77,114 +69,6 @@ void KeyboardShortcutDialog::doCancel() {
}
}
-void KeyboardShortcutDialog::loadSettings() {
- QSettings settings("opentrack"); // Registry settings (in HK_USER)
-
- QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString();
- QSettings iniFile( currentFile, QSettings::IniFormat ); // Application settings (in INI-file)
-
- qDebug() << "loadSettings says: iniFile = " << currentFile;
-
- iniFile.beginGroup ( "KB_Shortcuts" );
-
- const char* names[] = {
- "Center", "Toggle"
- };
-
- QComboBox* comboboxen[] = {
- ui.cbxCenterKey,
- ui.cbxToggleKey
- };
-
- QCheckBox* boxen[2][3] = {
- {
- ui.chkCenterShift,
- ui.chkCenterCtrl,
- ui.chkCenterAlt
- },
- {
- ui.chkToggleShift,
- ui.chkToggleCtrl,
- ui.chkToggleAlt
- }
- };
-
- const char* modnames[] = {
- "Shift", "Ctrl", "Alt"
- };
-
- const char* keynames[] = {
- "Center", "Toggle"
- };
-
- const int KEY_COUNT = 2;
- const int MODIFIERS = 3;
-
- for (int i = 0; i < KEY_COUNT; i++)
- {
- for (int m = 0; m < MODIFIERS; m++)
- {
- boxen[i][m]->setChecked (iniFile.value ( QString("%1_%2").arg(modnames[m], keynames[i]), 0).toBool());
- }
- comboboxen[i]->setCurrentIndex(iniFile.value(QString("Key_index_%1").arg(names[i]), 0).toInt());
- }
-
- iniFile.endGroup ();
-
- settingsDirty = false;
-}
-
-void KeyboardShortcutDialog::save() {
- const char* keynames[] = {
- "Center", "Toggle"
- };
-
- QComboBox* comboboxen[] = {
- ui.cbxCenterKey,
- ui.cbxToggleKey
- };
-
- const char* modnames[] = {
- "Shift", "Ctrl", "Alt"
- };
-
- QCheckBox* boxen[2][3] = {
- {
- ui.chkCenterShift,
- ui.chkCenterCtrl,
- ui.chkCenterAlt
- },
- {
- ui.chkToggleShift,
- ui.chkToggleCtrl,
- ui.chkToggleAlt
- }
- };
-
- const int MODIFIERS = 3;
- const int KEY_COUNT = 2;
-
- QSettings settings("opentrack"); // Registry settings (in HK_USER)
-
- QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString();
- QSettings iniFile( currentFile, QSettings::IniFormat ); // Application settings (in INI-file)
-
- iniFile.beginGroup ( "KB_Shortcuts" );
-
- for (int i = 0; i < KEY_COUNT; i++)
- {
- for (int m = 0; m < MODIFIERS; m++)
- {
- iniFile.setValue(QString("%1_%2").arg(modnames[m], keynames[i]), boxen[i][m]->isChecked());
- }
- iniFile.setValue(QString("Key_index_%1").arg(keynames[i]), comboboxen[i]->currentIndex());
- }
-
- iniFile.endGroup();
-
- settingsDirty = false;
-}
-
#if defined(_WIN32)
#include <windows.h>
diff --git a/facetracknoir/shortcuts.h b/facetracknoir/shortcuts.h
index a98211a8..f8c34be7 100644
--- a/facetracknoir/shortcuts.h
+++ b/facetracknoir/shortcuts.h
@@ -15,16 +15,9 @@ class KeyboardShortcutDialog: public QWidget
Q_OBJECT
public:
- explicit KeyboardShortcutDialog( FaceTrackNoIR *ftnoir, QWidget *parent );
- virtual ~KeyboardShortcutDialog();
- void showEvent (QShowEvent *);
-
+ KeyboardShortcutDialog( FaceTrackNoIR *ftnoir, QWidget *parent );
private:
Ui::UICKeyboardShortcutDialog ui;
- void loadSettings();
- void save();
-
- bool settingsDirty;
FaceTrackNoIR *mainApp;
private slots:
diff --git a/facetracknoir/tracker.cpp b/facetracknoir/tracker.cpp
index 590d44bf..ae4398ff 100644
--- a/facetracknoir/tracker.cpp
+++ b/facetracknoir/tracker.cpp
@@ -22,14 +22,13 @@
# include <windows.h>
#endif
-Tracker::Tracker( FaceTrackNoIR *parent ) :
+Tracker::Tracker(FaceTrackNoIR *parent , main_settings& s) :
+ mainApp(parent),
+ s(s),
should_quit(false),
do_center(false),
- enabled(true),
- compensate(true),
- tcomp_rz(false)
+ enabled(true)
{
- mainApp = parent;
}
Tracker::~Tracker()
@@ -37,18 +36,18 @@ Tracker::~Tracker()
}
static void get_curve(double pos, double& out, THeadPoseDOF& axis) {
- bool altp = (pos < 0) && axis.altp;
+ bool altp = (pos < 0) && axis.opts.altp;
if (altp) {
- out = axis.invert * axis.curveAlt.getValue(pos);
+ out = (axis.opts.invert ? -1 : 1) * axis.curveAlt.getValue(pos);
axis.curve.setTrackingActive( false );
axis.curveAlt.setTrackingActive( true );
}
else {
- out = axis.invert * axis.curve.getValue(pos);
+ out = (axis.opts.invert ? -1 : 1) * axis.curve.getValue(pos);
axis.curve.setTrackingActive( true );
axis.curveAlt.setTrackingActive( false );
}
- out += axis.zero;
+ out += axis.opts.zero;
}
static void t_compensate(double* input, double* output, bool rz)
@@ -131,7 +130,7 @@ void Tracker::run() {
do_center = false;
if (Libraries->pFilter)
- Libraries->pFilter->Initialize();
+ Libraries->pFilter->reset();
}
T6DOF target_camera, target_camera2, new_camera;
@@ -154,8 +153,8 @@ void Tracker::run() {
get_curve(new_camera.axes[i], output_camera.axes[i], mainApp->axis(i));
}
- if (compensate)
- t_compensate(output_camera.axes, output_camera.axes, tcomp_rz);
+ if (mainApp->s.tcomp_p)
+ t_compensate(output_camera.axes, output_camera.axes, mainApp->s.tcomp_tz);
if (Libraries->pProtocol) {
Libraries->pProtocol->sendHeadposeToGame( output_camera.axes ); // degrees & centimeters
@@ -188,5 +187,3 @@ void Tracker::getOutputHeadPose( double *data ) {
for (int i = 0; i < 6; i++)
data[i] = output_camera.axes[i];
}
-
-void Tracker::setInvertAxis(Axis axis, bool invert) { mainApp->axis(axis).invert = invert? -1.0 : 1.0; }
diff --git a/facetracknoir/tracker.h b/facetracknoir/tracker.h
index 987b5a24..404a8f24 100644
--- a/facetracknoir/tracker.h
+++ b/facetracknoir/tracker.h
@@ -12,53 +12,43 @@
#include <QMutex>
#include "global-settings.h"
#include <ftnoir_tracker_base/ftnoir_tracker_types.h>
+#include <vector>
#include <qfunctionconfigurator/functionconfig.h>
#include "tracker_types.h"
+#include "facetracknoir/main-settings.hpp"
+#include "facetracknoir/options.h"
+using namespace options;
class FaceTrackNoIR; // pre-define parent-class to avoid circular includes
class THeadPoseDOF {
private:
- THeadPoseDOF(const THeadPoseDOF &) {}
- THeadPoseDOF& operator=(const THeadPoseDOF&) { return *this; }
+ THeadPoseDOF(const THeadPoseDOF &) = delete;
+ THeadPoseDOF& operator=(const THeadPoseDOF&) = delete;
public:
- THeadPoseDOF() :
- headPos(0),
- invert(0),
- altp(false),
- zero(0)
- {
- }
-
THeadPoseDOF(QString primary,
QString secondary,
int maxInput1,
int maxOutput1,
int maxInput2,
- int maxOutput2) :
+ int maxOutput2,
+ axis_opts* opts) :
headPos(0),
- invert(1),
curve(primary, maxInput1, maxOutput1),
curveAlt(secondary, maxInput2, maxOutput2),
- zero(0)
+ opts(*opts)
{
QSettings settings("opentrack");
QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString();
QSettings iniFile( currentFile, QSettings::IniFormat );
curve.loadSettings(iniFile);
curveAlt.loadSettings(iniFile);
-
- iniFile.beginGroup("Tracking");
- altp = iniFile.value(secondary).toBool();
- iniFile.endGroup();
}
volatile double headPos;
- volatile float invert;
FunctionConfig curve;
FunctionConfig curveAlt;
- volatile bool altp;
- volatile double zero;
+ axis_opts& opts;
};
class Tracker : public QThread {
@@ -67,24 +57,21 @@ class Tracker : public QThread {
private:
FaceTrackNoIR *mainApp;
QMutex mtx;
+ main_settings& s;
protected:
void run();
public:
- Tracker( FaceTrackNoIR *parent );
+ Tracker( FaceTrackNoIR *parent, main_settings& s);
~Tracker();
- void setInvertAxis(Axis axis, bool invert);
-
void getHeadPose(double *data);
void getOutputHeadPose(double *data);
volatile bool should_quit;
volatile bool do_center;
volatile bool enabled;
- volatile bool compensate;
- volatile bool tcomp_rz;
T6DOF output_camera;
};
@@ -92,14 +79,14 @@ public:
class HeadPoseData {
public:
THeadPoseDOF* axes[6];
- HeadPoseData()
+ HeadPoseData(std::vector<axis_opts*> opts)
{
- axes[TX] = new THeadPoseDOF("tx","tx_alt", 25, 100, 25, 100);
- axes[TY] = new THeadPoseDOF("ty","ty_alt", 25, 100, 25, 100);
- axes[TZ] = new THeadPoseDOF("tz","tz_alt", 25, 100, 25, 100);
- axes[Yaw] = new THeadPoseDOF("rx", "rx_alt", 180, 180, 180, 180);
- axes[Pitch] = new THeadPoseDOF("ry", "ry_alt", 90, 90, 90, 90);
- axes[Roll] = new THeadPoseDOF("rz", "rz_alt", 180, 180, 180, 180);
+ axes[TX] = new THeadPoseDOF("tx","tx_alt", 25, 100, 25, 100, opts[TX]);
+ axes[TY] = new THeadPoseDOF("ty","ty_alt", 25, 100, 25, 100, opts[TY]);
+ axes[TZ] = new THeadPoseDOF("tz","tz_alt", 25, 100, 25, 100, opts[TZ]);
+ axes[Yaw] = new THeadPoseDOF("rx", "rx_alt", 180, 180, 180, 180, opts[Yaw]);
+ axes[Pitch] = new THeadPoseDOF("ry", "ry_alt", 90, 90, 90, 90, opts[Pitch]);
+ axes[Roll] = new THeadPoseDOF("rz", "rz_alt", 180, 180, 180, 180, opts[Roll]);
}
~HeadPoseData()
{
diff --git a/ftnoir_filter_accela/ftnoir_accela_filtercontrols.ui b/ftnoir_filter_accela/ftnoir_accela_filtercontrols.ui
index fb6a9565..4ea78c9f 100644
--- a/ftnoir_filter_accela/ftnoir_accela_filtercontrols.ui
+++ b/ftnoir_filter_accela/ftnoir_accela_filtercontrols.ui
@@ -9,8 +9,8 @@
<rect>
<x>0</x>
<y>0</y>
- <width>347</width>
- <height>339</height>
+ <width>202</width>
+ <height>241</height>
</rect>
</property>
<property name="sizePolicy">
@@ -21,8 +21,8 @@
</property>
<property name="minimumSize">
<size>
- <width>347</width>
- <height>268</height>
+ <width>0</width>
+ <height>0</height>
</size>
</property>
<property name="maximumSize">
@@ -47,555 +47,246 @@
<property name="styleSheet">
<string notr="true"/>
</property>
- <layout class="QGridLayout" name="gridLayout">
- <property name="margin">
- <number>6</number>
- </property>
- <property name="spacing">
- <number>4</number>
- </property>
+ <layout class="QFormLayout" name="formLayout">
<item row="0" column="0">
- <widget class="QGroupBox" name="groupbox2">
- <property name="enabled">
- <bool>true</bool>
+ <widget class="QLabel" name="label_2">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Fixed" vsizetype="Expanding">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Rotation</string>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1">
+ <widget class="QDoubleSpinBox" name="rotation_alpha">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Expanding" vsizetype="Maximum">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
+ </property>
+ <property name="correctionMode">
+ <enum>QAbstractSpinBox::CorrectToPreviousValue</enum>
+ </property>
+ <property name="decimals">
+ <number>4</number>
+ </property>
+ <property name="minimum">
+ <double>0.100000000000000</double>
+ </property>
+ <property name="maximum">
+ <double>65535.000000000000000</double>
+ </property>
+ <property name="value">
+ <double>1.000000000000000</double>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="0">
+ <widget class="QLabel" name="label_3">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Fixed" vsizetype="Expanding">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Translation</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1">
+ <widget class="QDoubleSpinBox" name="translation_alpha">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Expanding" vsizetype="Maximum">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
+ </property>
+ <property name="decimals">
+ <number>4</number>
+ </property>
+ <property name="minimum">
+ <double>0.100000000000000</double>
+ </property>
+ <property name="maximum">
+ <double>65535.000000000000000</double>
+ </property>
+ <property name="value">
+ <double>1.000000000000000</double>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="0">
+ <widget class="QLabel" name="label_11">
+ <property name="text">
+ <string>Order #2</string>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="1">
+ <widget class="QDoubleSpinBox" name="order_2nd">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Expanding" vsizetype="Maximum">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
+ </property>
+ <property name="correctionMode">
+ <enum>QAbstractSpinBox::CorrectToPreviousValue</enum>
+ </property>
+ <property name="decimals">
+ <number>4</number>
+ </property>
+ <property name="minimum">
+ <double>0.100000000000000</double>
+ </property>
+ <property name="maximum">
+ <double>65535.000000000000000</double>
+ </property>
+ <property name="value">
+ <double>1.000000000000000</double>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="0">
+ <widget class="QLabel" name="label_12">
+ <property name="text">
+ <string>Order #3</string>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="1">
+ <widget class="QDoubleSpinBox" name="order_3rd">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Expanding" vsizetype="Maximum">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
+ </property>
+ <property name="correctionMode">
+ <enum>QAbstractSpinBox::CorrectToPreviousValue</enum>
+ </property>
+ <property name="decimals">
+ <number>4</number>
+ </property>
+ <property name="minimum">
+ <double>0.100000000000000</double>
+ </property>
+ <property name="maximum">
+ <double>65535.000000000000000</double>
</property>
+ <property name="value">
+ <double>1.000000000000000</double>
+ </property>
+ </widget>
+ </item>
+ <item row="4" column="0">
+ <widget class="QLabel" name="lblSensYaw_6">
<property name="sizePolicy">
- <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
+ <sizepolicy hsizetype="Fixed" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
- <width>0</width>
+ <width>25</width>
<height>0</height>
</size>
</property>
- <property name="title">
- <string>Basic settings</string>
+ <property name="maximumSize">
+ <size>
+ <width>150</width>
+ <height>16777215</height>
+ </size>
+ </property>
+ <property name="styleSheet">
+ <string notr="true">color:#0;
+background:none;</string>
+ </property>
+ <property name="text">
+ <string>Deadband</string>
+ </property>
+ </widget>
+ </item>
+ <item row="4" column="1">
+ <widget class="QDoubleSpinBox" name="deadzone">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Expanding" vsizetype="Maximum">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
- <layout class="QFormLayout" name="formLayout_2">
- <property name="fieldGrowthPolicy">
- <enum>QFormLayout::ExpandingFieldsGrow</enum>
- </property>
- <item row="0" column="0">
- <widget class="QLabel" name="label_2">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Fixed" vsizetype="Expanding">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="text">
- <string>Rotation</string>
- </property>
- <property name="alignment">
- <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
- </property>
- </widget>
- </item>
- <item row="0" column="1">
- <widget class="QDoubleSpinBox" name="rotation_alpha">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Expanding" vsizetype="Maximum">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="alignment">
- <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
- </property>
- <property name="correctionMode">
- <enum>QAbstractSpinBox::CorrectToPreviousValue</enum>
- </property>
- <property name="decimals">
- <number>4</number>
- </property>
- <property name="minimum">
- <double>0.100000000000000</double>
- </property>
- <property name="maximum">
- <double>65535.000000000000000</double>
- </property>
- <property name="value">
- <double>1.000000000000000</double>
- </property>
- </widget>
- </item>
- <item row="1" column="0">
- <widget class="QLabel" name="label_3">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Fixed" vsizetype="Expanding">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="text">
- <string>Translation</string>
- </property>
- </widget>
- </item>
- <item row="1" column="1">
- <widget class="QDoubleSpinBox" name="translation_alpha">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Expanding" vsizetype="Maximum">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="alignment">
- <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
- </property>
- <property name="decimals">
- <number>4</number>
- </property>
- <property name="minimum">
- <double>0.100000000000000</double>
- </property>
- <property name="maximum">
- <double>65535.000000000000000</double>
- </property>
- <property name="value">
- <double>1.000000000000000</double>
- </property>
- </widget>
- </item>
- <item row="2" column="0">
- <widget class="QLabel" name="label_11">
- <property name="text">
- <string>Order #2</string>
- </property>
- </widget>
- </item>
- <item row="2" column="1">
- <widget class="QDoubleSpinBox" name="order_2nd">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Expanding" vsizetype="Maximum">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="alignment">
- <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
- </property>
- <property name="correctionMode">
- <enum>QAbstractSpinBox::CorrectToPreviousValue</enum>
- </property>
- <property name="decimals">
- <number>4</number>
- </property>
- <property name="minimum">
- <double>0.100000000000000</double>
- </property>
- <property name="maximum">
- <double>65535.000000000000000</double>
- </property>
- <property name="value">
- <double>1.000000000000000</double>
- </property>
- </widget>
- </item>
- <item row="3" column="0">
- <widget class="QLabel" name="label_12">
- <property name="text">
- <string>Order #3</string>
- </property>
- </widget>
- </item>
- <item row="3" column="1">
- <widget class="QDoubleSpinBox" name="order_3rd">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Expanding" vsizetype="Maximum">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="alignment">
- <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
- </property>
- <property name="correctionMode">
- <enum>QAbstractSpinBox::CorrectToPreviousValue</enum>
- </property>
- <property name="decimals">
- <number>4</number>
- </property>
- <property name="minimum">
- <double>0.100000000000000</double>
- </property>
- <property name="maximum">
- <double>65535.000000000000000</double>
- </property>
- <property name="value">
- <double>1.000000000000000</double>
- </property>
- </widget>
- </item>
- <item row="4" column="0">
- <widget class="QLabel" name="lblSensYaw_6">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Fixed" vsizetype="Expanding">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="minimumSize">
- <size>
- <width>25</width>
- <height>0</height>
- </size>
- </property>
- <property name="maximumSize">
- <size>
- <width>150</width>
- <height>16777215</height>
- </size>
- </property>
- <property name="styleSheet">
- <string notr="true">color:#0;
-background:none;</string>
- </property>
- <property name="text">
- <string>Deadband</string>
- </property>
- </widget>
- </item>
- <item row="4" column="1">
- <widget class="QDoubleSpinBox" name="deadzone">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Expanding" vsizetype="Maximum">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="alignment">
- <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
- </property>
- <property name="decimals">
- <number>3</number>
- </property>
- <property name="minimum">
- <double>0.000000000000000</double>
- </property>
- <property name="maximum">
- <double>3.000000000000000</double>
- </property>
- <property name="singleStep">
- <double>0.050000000000000</double>
- </property>
- <property name="value">
- <double>0.000000000000000</double>
- </property>
- </widget>
- </item>
- <item row="5" column="0">
- <widget class="QLabel" name="label_10">
- <property name="text">
- <string>Exponent</string>
- </property>
- </widget>
- </item>
- <item row="5" column="1">
- <widget class="QDoubleSpinBox" name="expt">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="decimals">
- <number>3</number>
- </property>
- <property name="minimum">
- <double>0.050000000000000</double>
- </property>
- <property name="maximum">
- <double>100.000000000000000</double>
- </property>
- <property name="singleStep">
- <double>0.050000000000000</double>
- </property>
- </widget>
- </item>
- </layout>
+ <property name="decimals">
+ <number>3</number>
+ </property>
+ <property name="minimum">
+ <double>0.000000000000000</double>
+ </property>
+ <property name="maximum">
+ <double>3.000000000000000</double>
+ </property>
+ <property name="singleStep">
+ <double>0.050000000000000</double>
+ </property>
+ <property name="value">
+ <double>0.000000000000000</double>
+ </property>
</widget>
</item>
- <item row="0" column="1">
- <widget class="QGroupBox" name="groupBox">
+ <item row="5" column="0">
+ <widget class="QLabel" name="label_10">
+ <property name="text">
+ <string>Exponent</string>
+ </property>
+ </widget>
+ </item>
+ <item row="5" column="1">
+ <widget class="QDoubleSpinBox" name="expt">
<property name="sizePolicy">
- <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
+ <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
- <property name="title">
- <string>Axis speed</string>
- </property>
- <layout class="QFormLayout" name="formLayout">
- <property name="fieldGrowthPolicy">
- <enum>QFormLayout::ExpandingFieldsGrow</enum>
- </property>
- <property name="horizontalSpacing">
- <number>20</number>
- </property>
- <property name="verticalSpacing">
- <number>0</number>
- </property>
- <property name="leftMargin">
- <number>5</number>
- </property>
- <property name="topMargin">
- <number>0</number>
- </property>
- <property name="rightMargin">
- <number>10</number>
- </property>
- <property name="bottomMargin">
- <number>2</number>
- </property>
- <item row="0" column="0">
- <widget class="QLabel" name="label">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="text">
- <string>X</string>
- </property>
- </widget>
- </item>
- <item row="0" column="1">
- <widget class="QDoubleSpinBox" name="doubleSpinBox">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="decimals">
- <number>4</number>
- </property>
- <property name="minimum">
- <double>0.100000000000000</double>
- </property>
- <property name="maximum">
- <double>3.000000000000000</double>
- </property>
- <property name="singleStep">
- <double>0.100000000000000</double>
- </property>
- <property name="value">
- <double>1.000000000000000</double>
- </property>
- </widget>
- </item>
- <item row="1" column="0">
- <widget class="QLabel" name="label_4">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="text">
- <string>Y</string>
- </property>
- </widget>
- </item>
- <item row="1" column="1">
- <widget class="QDoubleSpinBox" name="doubleSpinBox_2">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="decimals">
- <number>4</number>
- </property>
- <property name="minimum">
- <double>0.100000000000000</double>
- </property>
- <property name="maximum">
- <double>3.000000000000000</double>
- </property>
- <property name="singleStep">
- <double>0.100000000000000</double>
- </property>
- <property name="value">
- <double>1.000000000000000</double>
- </property>
- </widget>
- </item>
- <item row="3" column="0">
- <widget class="QLabel" name="label_5">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="text">
- <string>Z</string>
- </property>
- </widget>
- </item>
- <item row="3" column="1">
- <widget class="QDoubleSpinBox" name="doubleSpinBox_3">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="decimals">
- <number>4</number>
- </property>
- <property name="minimum">
- <double>0.100000000000000</double>
- </property>
- <property name="maximum">
- <double>3.000000000000000</double>
- </property>
- <property name="singleStep">
- <double>0.100000000000000</double>
- </property>
- <property name="value">
- <double>1.000000000000000</double>
- </property>
- </widget>
- </item>
- <item row="4" column="0">
- <widget class="QLabel" name="label_6">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="text">
- <string>Yaw</string>
- </property>
- </widget>
- </item>
- <item row="4" column="1">
- <widget class="QDoubleSpinBox" name="doubleSpinBox_4">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="accelerated">
- <bool>false</bool>
- </property>
- <property name="decimals">
- <number>4</number>
- </property>
- <property name="minimum">
- <double>0.100000000000000</double>
- </property>
- <property name="maximum">
- <double>3.000000000000000</double>
- </property>
- <property name="singleStep">
- <double>0.100000000000000</double>
- </property>
- <property name="value">
- <double>1.000000000000000</double>
- </property>
- </widget>
- </item>
- <item row="5" column="0">
- <widget class="QLabel" name="label_7">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="text">
- <string>Pitch</string>
- </property>
- </widget>
- </item>
- <item row="5" column="1">
- <widget class="QDoubleSpinBox" name="doubleSpinBox_5">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="accelerated">
- <bool>false</bool>
- </property>
- <property name="decimals">
- <number>4</number>
- </property>
- <property name="minimum">
- <double>0.100000000000000</double>
- </property>
- <property name="maximum">
- <double>3.000000000000000</double>
- </property>
- <property name="singleStep">
- <double>0.100000000000000</double>
- </property>
- <property name="value">
- <double>1.000000000000000</double>
- </property>
- </widget>
- </item>
- <item row="6" column="0">
- <widget class="QLabel" name="label_8">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="text">
- <string>Roll</string>
- </property>
- </widget>
- </item>
- <item row="6" column="1">
- <widget class="QDoubleSpinBox" name="doubleSpinBox_6">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="accelerated">
- <bool>false</bool>
- </property>
- <property name="decimals">
- <number>4</number>
- </property>
- <property name="minimum">
- <double>0.100000000000000</double>
- </property>
- <property name="maximum">
- <double>3.000000000000000</double>
- </property>
- <property name="singleStep">
- <double>0.100000000000000</double>
- </property>
- <property name="value">
- <double>1.000000000000000</double>
- </property>
- </widget>
- </item>
- </layout>
+ <property name="decimals">
+ <number>3</number>
+ </property>
+ <property name="minimum">
+ <double>0.050000000000000</double>
+ </property>
+ <property name="maximum">
+ <double>100.000000000000000</double>
+ </property>
+ <property name="singleStep">
+ <double>0.050000000000000</double>
+ </property>
</widget>
</item>
- <item row="1" column="1">
+ <item row="6" column="0" colspan="2">
<widget class="QLabel" name="label_9">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
@@ -640,8 +331,14 @@ background:none;</string>
</property>
</widget>
</item>
- <item row="2" column="1">
+ <item row="7" column="0" colspan="2">
<widget class="QDialogButtonBox" name="buttonBox">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Maximum" vsizetype="Maximum">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
@@ -649,21 +346,6 @@ background:none;</string>
</item>
</layout>
</widget>
- <tabstops>
- <tabstop>rotation_alpha</tabstop>
- <tabstop>translation_alpha</tabstop>
- <tabstop>order_2nd</tabstop>
- <tabstop>order_3rd</tabstop>
- <tabstop>deadzone</tabstop>
- <tabstop>expt</tabstop>
- <tabstop>doubleSpinBox</tabstop>
- <tabstop>doubleSpinBox_2</tabstop>
- <tabstop>doubleSpinBox_3</tabstop>
- <tabstop>doubleSpinBox_4</tabstop>
- <tabstop>doubleSpinBox_5</tabstop>
- <tabstop>doubleSpinBox_6</tabstop>
- <tabstop>buttonBox</tabstop>
- </tabstops>
<resources/>
<connections/>
<slots>
diff --git a/ftnoir_filter_accela/ftnoir_filter_accela.cpp b/ftnoir_filter_accela/ftnoir_filter_accela.cpp
index 1046c268..1e12e4de 100644
--- a/ftnoir_filter_accela/ftnoir_filter_accela.cpp
+++ b/ftnoir_filter_accela/ftnoir_filter_accela.cpp
@@ -10,55 +10,10 @@
#include <QDebug>
#include <QMutexLocker>
#include "facetracknoir/global-settings.h"
-
using namespace std;
-FTNoIR_Filter::FTNoIR_Filter()
-{
- first_run = true;
- loadSettings();
-}
-
-FTNoIR_Filter::~FTNoIR_Filter()
-{
-
-}
-
-void FTNoIR_Filter::loadSettings() {
- QSettings settings("opentrack"); // Registry settings (in HK_USER)
-
- QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString();
- QSettings iniFile( currentFile, QSettings::IniFormat ); // Application settings (in INI-file)
-
- iniFile.beginGroup ( "Accela" );
- rotation_alpha = iniFile.value("rotation-alpha", ACCELA_SMOOTHING_ROTATION).toDouble();
- translation_alpha = iniFile.value("translation-alpha", ACCELA_SMOOTHING_TRANSLATION).toDouble();
- second_order_alpha = iniFile.value("second-order-alpha", ACCELA_SECOND_ORDER_ALPHA).toDouble();
- third_order_alpha = iniFile.value("third-order-alpha", ACCELA_THIRD_ORDER_ALPHA).toDouble();
- deadzone = iniFile.value("deadzone", 0.0).toDouble();
- // bigger means less filtering
- static const double init_scaling[] = {
- 1, // X
- 1, // Y
- 1, // Z
- 1, // Yaw
- 1, // Pitch
- 1 // Roll
- };
- for (int i = 0; i < 6; i++)
- {
- scaling[i] = iniFile.value(QString("axis-%1").arg(QString::number(i)), init_scaling[i]).toDouble();
- }
- expt = iniFile.value("exponent", 2.0).toDouble();
-
- iniFile.endGroup();
-}
-
-void FTNoIR_Filter::receiveSettings()
+FTNoIR_Filter::FTNoIR_Filter() : first_run(true)
{
- QMutexLocker foo(&mutex);
-
- loadSettings();
}
static inline double parabola(const double a, const double x, const double dz, const double expt)
@@ -131,13 +86,13 @@ void FTNoIR_Filter::FilterHeadPoseData(const double* target_camera_position,
const double vec2 = target_camera_position[i] - last_output[1][i];
const double vec3 = target_camera_position[i] - last_output[2][i];
const int sign = vec < 0 ? -1 : 1;
- const double a = i >= 3 ? rotation_alpha : translation_alpha;
- const double a2 = a * second_order_alpha;
- const double a3 = a * third_order_alpha;
+ const double a = i >= 3 ? s.rotation_alpha : s.translation_alpha;
+ const double a2 = a * s.second_order_alpha;
+ const double a3 = a * s.third_order_alpha;
const double velocity =
- parabola(a, vec * scaling[i], deadzone, expt) +
- parabola(a2, vec2 * scaling[i], deadzone, expt) +
- parabola(a3, vec3 * scaling[i], deadzone, expt);
+ parabola(a, vec, s.deadzone, s.expt) +
+ parabola(a2, vec2, s.deadzone, s.expt) +
+ parabola(a3, vec3, s.deadzone, s.expt);
const double result = last_output[0][i] + velocity;
const bool done = sign > 0 ? result >= target_camera_position[i] : result <= target_camera_position[i];
new_camera_position[i] = done ? target_camera_position[i] : result;
diff --git a/ftnoir_filter_accela/ftnoir_filter_accela.h b/ftnoir_filter_accela/ftnoir_filter_accela.h
index d91a5e42..e8f077c3 100644
--- a/ftnoir_filter_accela/ftnoir_filter_accela.h
+++ b/ftnoir_filter_accela/ftnoir_filter_accela.h
@@ -1,31 +1,4 @@
-/********************************************************************************
-* FaceTrackNoIR This program is a private project of some enthusiastic *
-* gamers from Holland, who don't like to pay much for *
-* head-tracking. *
-* *
-* Copyright (C) 2012 Wim Vriend (Developing) *
-* Ron Hendriks (Researching and Testing) *
-* *
-* Homepage *
-* *
-* This program is free software; you can redistribute it and/or modify it *
-* under the terms of the GNU General Public License as published by the *
-* Free Software Foundation; either version 3 of the License, or (at your *
-* option) any later version. *
-* *
-* This program is distributed in the hope that it will be useful, but *
-* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY *
-* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for *
-* more details. *
-* *
-* You should have received a copy of the GNU General Public License along *
-* with this program; if not, see <http://www.gnu.org/licenses/>. *
-* *
-********************************************************************************/
#pragma once
-#ifndef INCLUDED_FTN_FILTER_H
-#define INCLUDED_FTN_FILTER_H
-
#include "ftnoir_filter_base/ftnoir_filter_base.h"
#include "ui_ftnoir_accela_filtercontrols.h"
#include "facetracknoir/global-settings.h"
@@ -37,28 +10,44 @@
#define ACCELA_SECOND_ORDER_ALPHA 100.0
#define ACCELA_THIRD_ORDER_ALPHA 180.0
-//*******************************************************************************************************
-// FaceTrackNoIR Filter class.
-//*******************************************************************************************************
+#include <facetracknoir/options.h>
+using namespace options;
+
+struct settings {
+ pbundle b;
+ value<double> rotation_alpha,
+ translation_alpha,
+ second_order_alpha,
+ third_order_alpha,
+ deadzone,
+ expt;
+ settings() :
+ b(bundle("Accela")),
+ rotation_alpha(b, "rotation-alpha", ACCELA_SMOOTHING_ROTATION),
+ translation_alpha(b, "translation-alpha", ACCELA_SMOOTHING_TRANSLATION),
+ second_order_alpha(b, "second-order-alpha", ACCELA_SECOND_ORDER_ALPHA),
+ third_order_alpha(b, "third-order-alpha", ACCELA_THIRD_ORDER_ALPHA),
+ deadzone(b, "deadzone", 0),
+ expt(b, "exponent", 2)
+ {}
+};
+
class FTNoIR_Filter : public IFilter
{
public:
FTNoIR_Filter();
- virtual ~FTNoIR_Filter();
void FilterHeadPoseData(const double* target_camera_position, double *new_camera_position);
- void Initialize() {
+ void reset() {
first_run = true;
}
- void receiveSettings();
+ void receiveSettings() {
+ s.b->reload();
+ }
+
private:
+ settings s;
QMutex mutex;
- void loadSettings();
bool first_run;
- double rotation_alpha, translation_alpha;
- double second_order_alpha, third_order_alpha;
- double scaling[6];
- double deadzone;
- double expt;
double last_input[6];
double last_output[3][6];
QElapsedTimer timer;
@@ -74,43 +63,27 @@ class FilterControls: public QWidget, public IFilterDialog
{
Q_OBJECT
public:
- explicit FilterControls();
- virtual ~FilterControls();
- void showEvent (QShowEvent *);
- void Initialize(QWidget *parent);
+ FilterControls();
+ void reset(QWidget *);
void registerFilter(IFilter* filter);
void unregisterFilter();
private:
Ui::AccelaUICFilterControls ui;
- void loadSettings();
+ void discard();
void save();
- bool settingsDirty;
FTNoIR_Filter* accela_filter;
+ settings s;
private slots:
void doOK();
void doCancel();
- void settingChanged(bool) { settingsDirty = true; }
- void settingChanged(int) { settingsDirty = true; }
- void settingChanged(double) { settingsDirty = true; }
};
-//*******************************************************************************************************
-// FaceTrackNoIR Filter DLL. Functions used to get general info on the Filter
-//*******************************************************************************************************
class FTNoIR_FilterDll : public Metadata
{
public:
- FTNoIR_FilterDll();
- ~FTNoIR_FilterDll();
-
void getFullName(QString *strToBeFilled) { *strToBeFilled = QString("Accela Filter Mk4"); }
void getShortName(QString *strToBeFilled) { *strToBeFilled = QString("Accela Mk4"); }
void getDescription(QString *strToBeFilled) { *strToBeFilled = QString("Accela filter Mk4"); }
void getIcon(QIcon *icon){ *icon = QIcon(":/images/filter-16.png"); }
};
-
-
-#endif //INCLUDED_FTN_FILTER_H
-//END
-
diff --git a/ftnoir_filter_accela/ftnoir_filter_accela_dialog.cpp b/ftnoir_filter_accela/ftnoir_filter_accela_dialog.cpp
index a14db280..6d1ad384 100644
--- a/ftnoir_filter_accela/ftnoir_filter_accela_dialog.cpp
+++ b/ftnoir_filter_accela/ftnoir_filter_accela_dialog.cpp
@@ -1,27 +1,3 @@
-/********************************************************************************
-* FaceTrackNoIR This program is a private project of some enthusiastic *
-* gamers from Holland, who don't like to pay much for *
-* head-tracking. *
-* *
-* Copyright (C) 2013 Wim Vriend (Developing) *
-* Ron Hendriks (Researching and Testing) *
-* *
-* Homepage *
-* *
-* This program is free software; you can redistribute it and/or modify it *
-* under the terms of the GNU General Public License as published by the *
-* Free Software Foundation; either version 3 of the License, or (at your *
-* option) any later version. *
-* *
-* This program is distributed in the hope that it will be useful, but *
-* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY *
-* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for *
-* more details. *
-* *
-* You should have received a copy of the GNU General Public License along *
-* with this program; if not, see <http://www.gnu.org/licenses/>. *
-* *
-********************************************************************************/
#include "ftnoir_filter_accela/ftnoir_filter_accela.h"
#include <cmath>
#include <QDebug>
@@ -29,61 +5,19 @@
#include <QDoubleSpinBox>
#include "facetracknoir/global-settings.h"
-//*******************************************************************************************************
-// FaceTrackNoIR Filter Settings-dialog.
-//*******************************************************************************************************
-//
-// Constructor for server-settings-dialog
-//
FilterControls::FilterControls() :
- QWidget(), accela_filter(NULL)
+ accela_filter(nullptr)
{
ui.setupUi( this );
-
- // Load the settings from the current .INI-file
- loadSettings();
connect(ui.buttonBox, SIGNAL(accepted()), this, SLOT(doOK()));
connect(ui.buttonBox, SIGNAL(rejected()), this, SLOT(doCancel()));
- connect(ui.rotation_alpha, SIGNAL(valueChanged(double)), this, SLOT(settingChanged(double)));
- connect(ui.translation_alpha, SIGNAL(valueChanged(double)), this, SLOT(settingChanged(double)));
-
- QDoubleSpinBox* boxen[] = {
- ui.doubleSpinBox,
- ui.doubleSpinBox_2,
- ui.doubleSpinBox_3,
- ui.doubleSpinBox_4,
- ui.doubleSpinBox_5,
- ui.doubleSpinBox_6,
- };
-
- for (int i = 0; i < 6; i++)
- {
- connect(boxen[i], SIGNAL(valueChanged(double)), this, SLOT(settingChanged(double)));
- }
-
- connect(ui.expt, SIGNAL(valueChanged(double)), this, SLOT(settingChanged(double)));
-
- qDebug() << "FilterControls() says: started";
-}
-
-//
-// Destructor for server-dialog
-//
-FilterControls::~FilterControls() {
- qDebug() << "~FilterControls() says: started";
-}
-//
-// Initialize tracker-client-dialog
-//
-void FilterControls::Initialize(QWidget *parent) {
- loadSettings();
-
- QPoint offsetpos(100, 100);
- if (parent) {
- this->move(parent->pos() + offsetpos);
- }
- show();
+ tie_setting(s.rotation_alpha, ui.rotation_alpha);
+ tie_setting(s.translation_alpha, ui.translation_alpha);
+ tie_setting(s.second_order_alpha, ui.order_2nd);
+ tie_setting(s.third_order_alpha, ui.order_3rd);
+ tie_setting(s.deadzone, ui.deadzone);
+ tie_setting(s.expt, ui.expt);
}
void FilterControls::registerFilter(IFilter* filter)
@@ -96,153 +30,50 @@ void FilterControls::unregisterFilter()
accela_filter = NULL;
}
-//
-// OK clicked on server-dialog
-//
void FilterControls::doOK() {
save();
this->close();
}
-// override show event
-void FilterControls::showEvent ( QShowEvent * ) {
-}
-
-//
-// Cancel clicked on server-dialog
-//
void FilterControls::doCancel() {
- //
- // Ask if changed Settings should be saved
- //
- if (settingsDirty) {
- int ret = QMessageBox::question ( this, "Settings have changed", "Do you want to save the settings?", QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel, QMessageBox::Discard );
-
- qDebug() << "doCancel says: answer =" << ret;
-
- switch (ret) {
- case QMessageBox::Save:
- save();
- this->close();
- break;
- case QMessageBox::Discard:
- this->close();
- break;
- case QMessageBox::Cancel:
- // Cancel was clicked
- break;
- default:
- // should never be reached
- break;
- }
- }
- else {
- this->close();
- }
-}
-
-//
-// Load the current Settings from the currently 'active' INI-file.
-//
-void FilterControls::loadSettings() {
- QSettings settings("opentrack"); // Registry settings (in HK_USER)
-
- QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString();
- QSettings iniFile( currentFile, QSettings::IniFormat ); // Application settings (in INI-file)
-
- qDebug() << "FTNoIR_Filter::loadSettings2 says: iniFile = " << currentFile;
-
- //qDebug() << "FTNoIR_Filter::loadSettings2 says: size = " << NUM_OF(defScaleRotation);
-
- iniFile.beginGroup ( "Accela" );
- ui.rotation_alpha->setValue(iniFile.value("rotation-alpha", ACCELA_SMOOTHING_ROTATION).toDouble());
- ui.translation_alpha->setValue(iniFile.value("translation-alpha", ACCELA_SMOOTHING_TRANSLATION).toDouble());
- ui.order_2nd->setValue(iniFile.value("second-order-alpha", ACCELA_SECOND_ORDER_ALPHA).toDouble());
- ui.order_3rd->setValue(iniFile.value("third-order-alpha", ACCELA_THIRD_ORDER_ALPHA).toDouble());
- ui.deadzone->setValue(iniFile.value("deadzone", 0).toDouble());
-
- // bigger means less filtering
- static const double init_scaling[] = {
- 1.5, // X
- 1.5, // Y
- 1, // Z
- 0.8, // Yaw
- 0.9, // Pitch
- 1.25 // Roll
- };
-
- QDoubleSpinBox* boxen[] = {
- ui.doubleSpinBox,
- ui.doubleSpinBox_2,
- ui.doubleSpinBox_3,
- ui.doubleSpinBox_4,
- ui.doubleSpinBox_5,
- ui.doubleSpinBox_6,
- };
-
- for (int i = 0; i < 6; i++)
+ if (!s.b->modifiedp())
{
- boxen[i]->setValue(iniFile.value(QString("axis-%1").arg(QString::number(i)), init_scaling[i]).toDouble());
+ close();
+ return;
}
+ int ret =
+ QMessageBox::question( this,
+ "Settings have changed",
+ "Do you want to save the settings?",
+ QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel);
+
+ switch (ret) {
+ case QMessageBox::Save:
+ save();
+ this->close();
+ break;
+ case QMessageBox::Discard:
+ this->discard();
+ this->close();
+ break;
+ case QMessageBox::Cancel:
+ default:
+ break;
+ }
+}
- ui.expt->setValue(iniFile.value("exponent", 2.0).toDouble());
-
- iniFile.endGroup();
- settingsDirty = false;
+void FilterControls::discard()
+{
+ s.b->revert();
}
-//
-// Save the current Settings to the currently 'active' INI-file.
-//
void FilterControls::save() {
- QSettings settings("opentrack"); // Registry settings (in HK_USER)
-
- QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString();
- {
- QSettings iniFile( currentFile, QSettings::IniFormat ); // Application settings (in INI-file)
-
- qDebug() << "FTNoIR_Filter::save() says: iniFile = " << currentFile;
-
- iniFile.beginGroup ( "Accela" );
- iniFile.setValue("rotation-alpha", ui.rotation_alpha->value());
- iniFile.setValue("translation-alpha", ui.translation_alpha->value());
- iniFile.setValue("deadzone", ui.deadzone->value());
- iniFile.setValue("exponent", ui.expt->value());
- iniFile.setValue("second-order-alpha", ui.order_2nd->value());
- iniFile.setValue("third-order-alpha", ui.order_3rd->value());
-
- QDoubleSpinBox* boxen[] = {
- ui.doubleSpinBox,
- ui.doubleSpinBox_2,
- ui.doubleSpinBox_3,
- ui.doubleSpinBox_4,
- ui.doubleSpinBox_5,
- ui.doubleSpinBox_6,
- };
-
- for (int i = 0; i < 6; i++)
- {
- iniFile.setValue(QString("axis-%1").arg(QString::number(i)), boxen[i]->value());
- }
- iniFile.endGroup();
- }
-
- settingsDirty = false;
-
+ s.b->save();
if (accela_filter)
accela_filter->receiveSettings();
}
-////////////////////////////////////////////////////////////////////////////////
-// Factory function that creates instances if the Filter-settings dialog object.
-
-// Export both decorated and undecorated names.
-// GetFilterDialog - Undecorated name, which can be easily used with GetProcAddress
-// Win32 API function.
-// _GetFilterDialog@0 - Common name decoration for __stdcall functions in C language.
-//#pragma comment(linker, "/export:GetFilterDialog=_GetFilterDialog@0")
-
extern "C" FTNOIR_FILTER_BASE_EXPORT IFilterDialog* CALLING_CONVENTION GetDialog()
{
return new FilterControls;
diff --git a/ftnoir_filter_accela/ftnoir_filter_accela_dll.cpp b/ftnoir_filter_accela/ftnoir_filter_accela_dll.cpp
index d4a11028..a024e789 100644
--- a/ftnoir_filter_accela/ftnoir_filter_accela_dll.cpp
+++ b/ftnoir_filter_accela/ftnoir_filter_accela_dll.cpp
@@ -1,38 +1,6 @@
-/********************************************************************************
-* FaceTrackNoIR This program is a private project of some enthusiastic *
-* gamers from Holland, who don't like to pay much for *
-* head-tracking. *
-* *
-* Copyright (C) 2012 Wim Vriend (Developing) *
-* Ron Hendriks (Researching and Testing) *
-* *
-* Homepage *
-* *
-* This program is free software; you can redistribute it and/or modify it *
-* under the terms of the GNU General Public License as published by the *
-* Free Software Foundation; either version 3 of the License, or (at your *
-* option) any later version. *
-* *
-* This program is distributed in the hope that it will be useful, but *
-* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY *
-* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for *
-* more details. *
-* *
-* You should have received a copy of the GNU General Public License along *
-* with this program; if not, see <http://www.gnu.org/licenses/>. *
-* *
-********************************************************************************/
#include "ftnoir_filter_accela.h"
#include "facetracknoir/global-settings.h"
-FTNoIR_FilterDll::FTNoIR_FilterDll() {
-}
-
-FTNoIR_FilterDll::~FTNoIR_FilterDll()
-{
-
-}
-
extern "C" FTNOIR_FILTER_BASE_EXPORT Metadata* CALLING_CONVENTION GetMetadata()
{
return new FTNoIR_FilterDll;
diff --git a/ftnoir_filter_base/ftnoir_filter_base.h b/ftnoir_filter_base/ftnoir_filter_base.h
index 800e5deb..fbb0441d 100644
--- a/ftnoir_filter_base/ftnoir_filter_base.h
+++ b/ftnoir_filter_base/ftnoir_filter_base.h
@@ -14,7 +14,7 @@ struct IFilter
{
virtual ~IFilter() = 0;
virtual void FilterHeadPoseData(const double *target_camera_position, double *new_camera_position) = 0;
- virtual void Initialize() = 0;
+ virtual void reset() = 0;
};
inline IFilter::~IFilter() { }
@@ -22,7 +22,6 @@ inline IFilter::~IFilter() { }
struct IFilterDialog
{
virtual ~IFilterDialog() {}
- virtual void Initialize(QWidget *parent) = 0;
virtual void registerFilter(IFilter* tracker) = 0;
virtual void unregisterFilter() = 0;
};
diff --git a/ftnoir_filter_ewma2/ftnoir_filter_ewma2.cpp b/ftnoir_filter_ewma2/ftnoir_filter_ewma2.cpp
index 5f66be96..4f07443a 100644
--- a/ftnoir_filter_ewma2/ftnoir_filter_ewma2.cpp
+++ b/ftnoir_filter_ewma2/ftnoir_filter_ewma2.cpp
@@ -37,46 +37,13 @@
//
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-FTNoIR_Filter::FTNoIR_Filter()
+FTNoIR_Filter::FTNoIR_Filter() : first_run(true), alpha_smoothing(0.02)
{
- first_run = true;
- alpha_smoothing = 0.02f; // this is a constant for now, might be a parameter later
- loadSettings(); // Load the Settings
}
-FTNoIR_Filter::~FTNoIR_Filter()
+void FTNoIR_Filter::receiveSettings()
{
-}
-
-void FTNoIR_Filter::receiveSettings(double smin, double smax, double sexpt)
-{
- QMutexLocker foo(&mutex);
-
- kMinSmoothing = smin;
- kMaxSmoothing = smax;
- kSmoothingScaleCurve = sexpt;
-}
-
-//
-// Load the current Settings from the currently 'active' INI-file.
-//
-void FTNoIR_Filter::loadSettings() {
- qDebug() << "FTNoIR_Filter::loadSettings says: Starting ";
- QSettings settings("opentrack"); // Registry settings (in HK_USER)
-
- QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString();
- QSettings iniFile( currentFile, QSettings::IniFormat ); // Application settings (in INI-file)
-
- qDebug() << "FTNoIR_Filter::loadSettings says: iniFile = " << currentFile;
-
- //
- // The EWMA2-filter-settings are in the Tracking group: this is because they used to be on the Main Form of FaceTrackNoIR
- //
- iniFile.beginGroup ( "Tracking" );
- kMinSmoothing = iniFile.value ( "minSmooth", 15 ).toInt();
- kMaxSmoothing = iniFile.value ( "maxSmooth", 50 ).toInt();
- kSmoothingScaleCurve = iniFile.value ( "powCurve", 10 ).toInt();
- iniFile.endGroup ();
+ s.b->reload();
}
void FTNoIR_Filter::FilterHeadPoseData(const double *target_camera_position,
@@ -97,15 +64,13 @@ void FTNoIR_Filter::FilterHeadPoseData(const double *target_camera_position,
return;
}
- QMutexLocker foo(&mutex);
-
for (int i=0;i<6;i++) {
// Calculate the delta.
delta=target_camera_position[i]-current_camera_position[i];
// Normalise the delta.
delta=std::min<double>(std::max<double>(fabs(delta)/scale[i],0.0),1.0);
// Calculate the new alpha from the normalized delta.
- new_alpha=1.0/(kMinSmoothing+((1.0-pow(delta,kSmoothingScaleCurve))*(kMaxSmoothing-kMinSmoothing)));
+ new_alpha=1.0/(s.kMinSmoothing+((1.0-pow(delta,s.kSmoothingScaleCurve))*(s.kMaxSmoothing-s.kMinSmoothing)));
// Update the smoothed alpha.
alpha[i]=(alpha_smoothing*new_alpha)+((1.0-alpha_smoothing)*alpha[i]);
}
diff --git a/ftnoir_filter_ewma2/ftnoir_filter_ewma2.h b/ftnoir_filter_ewma2/ftnoir_filter_ewma2.h
index 86e4b65c..e50a4284 100644
--- a/ftnoir_filter_ewma2/ftnoir_filter_ewma2.h
+++ b/ftnoir_filter_ewma2/ftnoir_filter_ewma2.h
@@ -31,36 +31,35 @@
#include "ui_ftnoir_ewma_filtercontrols.h"
#include <QWidget>
#include <QMutex>
+#include "facetracknoir/options.h"
+using namespace options;
+
+struct settings {
+ pbundle b;
+ value<int> kMinSmoothing, kMaxSmoothing, kSmoothingScaleCurve;
+ settings() :
+ b(bundle("ewma-filter")),
+ kMinSmoothing(b, "min-smoothing", 15),
+ kMaxSmoothing(b, "max-smoothing", 50),
+ kSmoothingScaleCurve(b, "smoothing-scale-curve", 10)
+ {}
+};
+
-//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-//
-// EWMA Filter: Exponentially Weighted Moving Average filter with dynamic smoothing parameter
-//
-//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
class FTNoIR_Filter : public IFilter
{
public:
FTNoIR_Filter();
- virtual ~FTNoIR_Filter();
- void Initialize() {}
-
+ void reset() {}
void FilterHeadPoseData(const double *target_camera_position,
double *new_camera_position);
- void receiveSettings(double smin, double smax, double sexpt);
-
+ void receiveSettings();
private:
- void loadSettings(); // Load the settings from the INI-file
- double newHeadPose; // Structure with new headpose
-
bool first_run;
double alpha_smoothing;
double alpha[6];
-
- double kMinSmoothing;
- double kMaxSmoothing;
- double kSmoothingScaleCurve;
double current_camera_position[6];
- QMutex mutex;
+ settings s;
};
//*******************************************************************************************************
@@ -72,28 +71,19 @@ class FilterControls: public QWidget, public IFilterDialog
{
Q_OBJECT
public:
- explicit FilterControls();
- virtual ~FilterControls();
- void showEvent (QShowEvent *);
- void Initialize(QWidget *parent);
+ FilterControls();
void registerFilter(IFilter* flt);
void unregisterFilter();
private:
Ui::UICFilterControls ui;
- void loadSettings();
void save();
-
- /** helper **/
- bool settingsDirty;
-
+ settings s;
FTNoIR_Filter* pFilter;
private slots:
void doOK();
void doCancel();
- void settingChanged() { settingsDirty = true; }
- void settingChanged( int ) { settingsDirty = true; }
};
//*******************************************************************************************************
@@ -102,8 +92,6 @@ private slots:
class FTNoIR_FilterDll : public Metadata
{
public:
- FTNoIR_FilterDll();
- ~FTNoIR_FilterDll();
void getFullName(QString *strToBeFilled) { *strToBeFilled = QString("EWMA Filter Mk2"); }
void getShortName(QString *strToBeFilled) { *strToBeFilled = QString("EWMA"); }
void getDescription(QString *strToBeFilled) { *strToBeFilled = QString("Exponentially Weighted Moving Average filter with dynamic smoothing parameter"); }
diff --git a/ftnoir_filter_ewma2/ftnoir_filter_ewma2_dialog.cpp b/ftnoir_filter_ewma2/ftnoir_filter_ewma2_dialog.cpp
index c304eb0a..7ab2b09c 100644
--- a/ftnoir_filter_ewma2/ftnoir_filter_ewma2_dialog.cpp
+++ b/ftnoir_filter_ewma2/ftnoir_filter_ewma2_dialog.cpp
@@ -28,56 +28,17 @@
#include "facetracknoir/global-settings.h"
#include "ui_ftnoir_ewma_filtercontrols.h"
-//*******************************************************************************************************
-// FaceTrackNoIR Filter Settings-dialog.
-//*******************************************************************************************************
-//
-// Constructor for server-settings-dialog
-//
FilterControls::FilterControls() :
QWidget(), pFilter(NULL)
{
- ui.setupUi( this );
+ ui.setupUi( this );
- QPoint offsetpos(100, 100);
- //if (parent) {
- // this->move(parent->pos() + offsetpos);
- //}
+ connect(ui.btnOK, SIGNAL(clicked()), this, SLOT(doOK()));
+ connect(ui.btnCancel, SIGNAL(clicked()), this, SLOT(doCancel()));
- // Connect Qt signals to member-functions
- connect(ui.btnOK, SIGNAL(clicked()), this, SLOT(doOK()));
- connect(ui.btnCancel, SIGNAL(clicked()), this, SLOT(doCancel()));
-
- // Connect sliders for reduction factor
- connect(ui.minSmooth, SIGNAL(valueChanged(int)), this, SLOT(settingChanged(int)));
- connect(ui.maxSmooth, SIGNAL(valueChanged(int)), this, SLOT(settingChanged(int)));
- connect(ui.powCurve, SIGNAL(valueChanged(int)), this, SLOT(settingChanged(int)));
-
- qDebug() << "FilterControls() says: started";
-
- // Load the settings from the current .INI-file
- loadSettings();
-}
-
-//
-// Destructor for server-dialog
-//
-FilterControls::~FilterControls() {
- qDebug() << "~FilterControls() says: started";
-}
-
-//
-// Initialize tracker-client-dialog
-//
-void FilterControls::Initialize(QWidget *parent) {
- //
- //
- //
- QPoint offsetpos(100, 100);
- if (parent) {
- this->move(parent->pos() + offsetpos);
- }
- show();
+ tie_setting(s.kMaxSmoothing, ui.maxSmooth);
+ tie_setting(s.kMinSmoothing, ui.minSmooth);
+ tie_setting(s.kSmoothingScaleCurve, ui.powCurve);
}
void FilterControls::registerFilter(IFilter* flt)
@@ -90,44 +51,31 @@ void FilterControls::unregisterFilter()
pFilter = NULL;
}
-//
-// OK clicked on server-dialog
-//
void FilterControls::doOK() {
save();
this->close();
}
-// override show event
-void FilterControls::showEvent ( QShowEvent * ) {
- loadSettings();
-}
-
-//
-// Cancel clicked on server-dialog
-//
void FilterControls::doCancel() {
//
// Ask if changed Settings should be saved
//
- if (settingsDirty) {
- int ret = QMessageBox::question ( this, "Settings have changed", "Do you want to save the settings?", QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel, QMessageBox::Discard );
+ if (s.b->modifiedp()) {
+ int ret = QMessageBox::question ( this, "Settings have changed", "Do you want to save the settings?", QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel);
qDebug() << "doCancel says: answer =" << ret;
switch (ret) {
case QMessageBox::Save:
- save();
+ save();
this->close();
break;
case QMessageBox::Discard:
+ s.b->revert();
this->close();
break;
case QMessageBox::Cancel:
- // Cancel was clicked
- break;
default:
- // should never be reached
break;
}
}
@@ -136,62 +84,12 @@ void FilterControls::doCancel() {
}
}
-//
-// Load the current Settings from the currently 'active' INI-file.
-//
-void FilterControls::loadSettings() {
- qDebug() << "FilterControls::loadSettings says: Starting ";
- QSettings settings("opentrack"); // Registry settings (in HK_USER)
-
- QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString();
- QSettings iniFile( currentFile, QSettings::IniFormat ); // Application settings (in INI-file)
-
- qDebug() << "FilterControls::loadSettings says: iniFile = " << currentFile;
-
- //
- // The EWMA2-filter-settings are in the Tracking group: this is because they used to be on the Main Form of FaceTrackNoIR
- //
- iniFile.beginGroup ( "Tracking" );
- ui.minSmooth->setValue (iniFile.value ( "minSmooth", 15 ).toInt());
- ui.maxSmooth->setValue (iniFile.value ( "maxSmooth", 50 ).toInt());
- ui.powCurve->setValue (iniFile.value ( "powCurve", 10 ).toInt());
- iniFile.endGroup ();
-
- settingsDirty = false;
-}
-
-//
-// Save the current Settings to the currently 'active' INI-file.
-//
void FilterControls::save() {
- QSettings settings("opentrack"); // Registry settings (in HK_USER)
-
- QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString();
- QSettings iniFile( currentFile, QSettings::IniFormat ); // Application settings (in INI-file)
-
- double smooth_min, smooth_max, smooth_expt;
-
- iniFile.beginGroup ( "Tracking" );
- iniFile.setValue ( "minSmooth", smooth_min = ui.minSmooth->value() );
- iniFile.setValue ( "powCurve", smooth_expt = ui.powCurve->value() );
- iniFile.setValue ( "maxSmooth", smooth_max = ui.maxSmooth->value() );
- iniFile.endGroup ();
-
- settingsDirty = false;
-
+ s.b->save();
if (pFilter)
- pFilter->receiveSettings(smooth_min, smooth_max, smooth_expt);
+ pFilter->receiveSettings();
}
-////////////////////////////////////////////////////////////////////////////////
-// Factory function that creates instances if the Filter-settings dialog object.
-
-// Export both decorated and undecorated names.
-// GetFilterDialog - Undecorated name, which can be easily used with GetProcAddress
-// Win32 API function.
-// _GetFilterDialog@0 - Common name decoration for __stdcall functions in C language.
-//#pragma comment(linker, "/export:GetFilterDialog=_GetFilterDialog@0")
-
extern "C" FTNOIR_FILTER_BASE_EXPORT IFilterDialog* CALLING_CONVENTION GetDialog( )
{
return new FilterControls;
diff --git a/ftnoir_filter_ewma2/ftnoir_filter_ewma_dll.cpp b/ftnoir_filter_ewma2/ftnoir_filter_ewma_dll.cpp
index 087ede1b..6ef7768e 100644
--- a/ftnoir_filter_ewma2/ftnoir_filter_ewma_dll.cpp
+++ b/ftnoir_filter_ewma2/ftnoir_filter_ewma_dll.cpp
@@ -23,26 +23,8 @@
* *
********************************************************************************/
#include "ftnoir_filter_ewma2.h"
-#include <QDebug>
#include "facetracknoir/global-settings.h"
-FTNoIR_FilterDll::FTNoIR_FilterDll() {
-}
-
-FTNoIR_FilterDll::~FTNoIR_FilterDll()
-{
-
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// Factory function that creates instances if the Filter object.
-
-// Export both decorated and undecorated names.
-// GetFilterDll - Undecorated name, which can be easily used with GetProcAddress
-// Win32 API function.
-// _GetFilterDll@0 - Common name decoration for __stdcall functions in C language.
-//#pragma comment(linker, "/export:GetFilterDll=_GetFilterDll@0")
-
extern "C" FTNOIR_FILTER_BASE_EXPORT Metadata* CALLING_CONVENTION GetMetadata()
{
return new FTNoIR_FilterDll;
diff --git a/ftnoir_filter_kalman/ftnoir_filter_kalman.h b/ftnoir_filter_kalman/ftnoir_filter_kalman.h
index da6df2b1..f2a1b4ec 100644
--- a/ftnoir_filter_kalman/ftnoir_filter_kalman.h
+++ b/ftnoir_filter_kalman/ftnoir_filter_kalman.h
@@ -21,14 +21,14 @@
#include <QWidget>
#include <QElapsedTimer>
#include <QObject>
+#include "facetracknoir/options.h"
+using namespace options;
class FTNOIR_FILTER_BASE_EXPORT FTNoIR_Filter : public IFilter
{
public:
FTNoIR_Filter();
- ~FTNoIR_Filter() virt_override {
- }
- void Initialize() virt_override;
+ void reset() virt_override;
void FilterHeadPoseData(const double *target_camera_position,
double *new_camera_position) virt_override;
cv::KalmanFilter kalman;
@@ -39,9 +39,6 @@ public:
qint64 timedelta;
};
-void kalman_load_settings(FTNoIR_Filter&);
-void kalman_save_settings(FTNoIR_Filter&);
-
class FTNOIR_FILTER_BASE_EXPORT FTNoIR_FilterDll : public Metadata
{
public:
@@ -55,39 +52,18 @@ class FTNOIR_FILTER_BASE_EXPORT FilterControls: public QWidget, public IFilterDi
{
Q_OBJECT
public:
- explicit FilterControls() : settingsDirty(false) {
+ FilterControls() {
ui.setupUi(this);
- QSettings settings("Abbequerque Inc.", "FaceTrackNoIR"); // Registry settings (in HK_USER)
-
- QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/Settings/default.ini" ).toString();
- QSettings iniFile( currentFile, QSettings::IniFormat ); // Application settings (in INI-file)
-
- iniFile.beginGroup("ftnoir-filter-kalman");
- iniFile.endGroup();
connect(ui.btnOk, SIGNAL(clicked()), this, SLOT(doOK()));
connect(ui.btnCancel, SIGNAL(clicked()), this, SLOT(doCancel()));
show();
}
- ~FilterControls() {}
- void showEvent ( QShowEvent * ) virt_override {
- show();
- }
-
- void Initialize(QWidget *) virt_override {
- show();
- raise();
- }
-
- bool settingsDirty;
Ui::KalmanUICFilterControls ui;
virtual void registerFilter(IFilter*) virt_override {}
virtual void unregisterFilter() virt_override {}
public slots:
void doOK();
void doCancel();
- void settingsChanged(double) {
- settingsDirty = true;
- }
};
#endif
diff --git a/ftnoir_filter_kalman/ftnoir_kalman_filtercontrols.ui b/ftnoir_filter_kalman/ftnoir_kalman_filtercontrols.ui
index 7b71712a..d1cff81e 100644
--- a/ftnoir_filter_kalman/ftnoir_kalman_filtercontrols.ui
+++ b/ftnoir_filter_kalman/ftnoir_kalman_filtercontrols.ui
@@ -63,126 +63,6 @@
<string>Cancel</string>
</property>
</widget>
- <widget class="QLabel" name="label_2">
- <property name="geometry">
- <rect>
- <x>9</x>
- <y>30</y>
- <width>169</width>
- <height>16</height>
- </rect>
- </property>
- <property name="text">
- <string>process-noise-covariance</string>
- </property>
- </widget>
- <widget class="QDoubleSpinBox" name="post">
- <property name="geometry">
- <rect>
- <x>180</x>
- <y>26</y>
- <width>150</width>
- <height>22</height>
- </rect>
- </property>
- <property name="alignment">
- <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
- </property>
- <property name="decimals">
- <number>14</number>
- </property>
- <property name="maximum">
- <double>1.000000000000000</double>
- </property>
- <property name="singleStep">
- <double>0.000001000000000</double>
- </property>
- <property name="value">
- <double>0.500000000000000</double>
- </property>
- </widget>
- <widget class="QDoubleSpinBox" name="pnoise">
- <property name="geometry">
- <rect>
- <x>180</x>
- <y>6</y>
- <width>150</width>
- <height>22</height>
- </rect>
- </property>
- <property name="alignment">
- <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
- </property>
- <property name="decimals">
- <number>14</number>
- </property>
- <property name="maximum">
- <double>1.000000000000000</double>
- </property>
- <property name="singleStep">
- <double>0.000001000000000</double>
- </property>
- <property name="value">
- <double>0.500000000000000</double>
- </property>
- </widget>
- <widget class="QLabel" name="label">
- <property name="geometry">
- <rect>
- <x>9</x>
- <y>10</y>
- <width>165</width>
- <height>16</height>
- </rect>
- </property>
- <property name="text">
- <string>post-error-matrix</string>
- </property>
- <property name="alignment">
- <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
- </property>
- <property name="margin">
- <number>0</number>
- </property>
- </widget>
- <widget class="QLabel" name="label_3">
- <property name="geometry">
- <rect>
- <x>9</x>
- <y>55</y>
- <width>109</width>
- <height>16</height>
- </rect>
- </property>
- <property name="text">
- <string>accel-coefficient</string>
- </property>
- </widget>
- <widget class="QDoubleSpinBox" name="accl">
- <property name="geometry">
- <rect>
- <x>181</x>
- <y>47</y>
- <width>150</width>
- <height>22</height>
- </rect>
- </property>
- <property name="alignment">
- <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
- </property>
- <property name="decimals">
- <number>6</number>
- </property>
- <property name="maximum">
- <double>1000000000.000000000000000</double>
- </property>
- <property name="singleStep">
- <double>0.000001000000000</double>
- </property>
- <property name="value">
- <double>1.000000000000000</double>
- </property>
- </widget>
</widget>
<resources/>
<connections/>
diff --git a/ftnoir_filter_kalman/kalman.cpp b/ftnoir_filter_kalman/kalman.cpp
index 629cfcc8..bef6ddad 100644
--- a/ftnoir_filter_kalman/kalman.cpp
+++ b/ftnoir_filter_kalman/kalman.cpp
@@ -9,34 +9,13 @@
#include <QDebug>
#include <math.h>
-void kalman_load_settings(FTNoIR_Filter&) {
- QSettings settings("Abbequerque Inc.", "FaceTrackNoIR"); // Registry settings (in HK_USER)
-
- QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/Settings/default.ini" ).toString();
- QSettings iniFile( currentFile, QSettings::IniFormat ); // Application settings (in INI-file)
-
- iniFile.beginGroup("ftnoir-filter-kalman");
- iniFile.endGroup();
-}
-
-void kalman_save_settings(FilterControls&) {
- QSettings settings("Abbequerque Inc.", "FaceTrackNoIR"); // Registry settings (in HK_USER)
-
- QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/Settings/default.ini" ).toString();
- QSettings iniFile( currentFile, QSettings::IniFormat ); // Application settings (in INI-file)
-
- iniFile.beginGroup("ftnoir-filter-kalman");
- iniFile.endGroup();
-}
-
FTNoIR_Filter::FTNoIR_Filter() {
- kalman_load_settings(*this);
- Initialize();
+ reset();
}
// the following was written by Donovan Baarda <abo@minkirri.apana.org.au>
// https://sourceforge.net/p/facetracknoir/discussion/1150909/thread/418615e1/?limit=25#af75/084b
-void FTNoIR_Filter::Initialize() {
+void FTNoIR_Filter::reset() {
const double accel_variance = 1e-3;
const double noise_variance = 5e2;
kalman.init(12, 6, 0, CV_64F);
@@ -135,35 +114,11 @@ void FTNoIR_Filter::FilterHeadPoseData(const double* target_camera_position,
}
void FilterControls::doOK() {
- kalman_save_settings(*this);
close();
}
void FilterControls::doCancel() {
- if (settingsDirty) {
- int ret = QMessageBox::question ( this, "Settings have changed", "Do you want to save the settings?", QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel, QMessageBox::Discard );
-
- qDebug() << "doCancel says: answer =" << ret;
-
- switch (ret) {
- case QMessageBox::Save:
- kalman_save_settings(*this);
- this->close();
- break;
- case QMessageBox::Discard:
- this->close();
- break;
- case QMessageBox::Cancel:
- // Cancel was clicked
- break;
- default:
- // should never be reached
- break;
- }
- }
- else {
- this->close();
- }
+ close();
}
extern "C" FTNOIR_FILTER_BASE_EXPORT Metadata* CALLING_CONVENTION GetMetadata()
diff --git a/ftnoir_protocol_base/ftnoir_protocol_base.h b/ftnoir_protocol_base/ftnoir_protocol_base.h
index e4ca1977..d2f85ec0 100644
--- a/ftnoir_protocol_base/ftnoir_protocol_base.h
+++ b/ftnoir_protocol_base/ftnoir_protocol_base.h
@@ -50,9 +50,6 @@ inline IProtocol::~IProtocol() { }
struct IProtocolDialog
{
virtual ~IProtocolDialog() {}
- virtual void Initialize(QWidget *parent) = 0;
- virtual void showEvent ( QShowEvent * event ) = 0;
-
virtual void registerProtocol(IProtocol *protocol) = 0;
virtual void unRegisterProtocol() = 0;
};
diff --git a/ftnoir_protocol_fg/ftnoir_fgcontrols.ui b/ftnoir_protocol_fg/ftnoir_fgcontrols.ui
index fd0df6b0..f3b54486 100644
--- a/ftnoir_protocol_fg/ftnoir_fgcontrols.ui
+++ b/ftnoir_protocol_fg/ftnoir_fgcontrols.ui
@@ -9,8 +9,8 @@
<rect>
<x>0</x>
<y>0</y>
- <width>518</width>
- <height>208</height>
+ <width>404</width>
+ <height>112</height>
</rect>
</property>
<property name="windowTitle">
@@ -26,239 +26,101 @@
<property name="autoFillBackground">
<bool>false</bool>
</property>
- <layout class="QVBoxLayout" name="_vertical_layout">
- <item>
- <layout class="QGridLayout" name="gridLayout">
- <item row="2" column="4">
- <widget class="QSpinBox" name="spinIPFourthNibble">
- <property name="maximumSize">
- <size>
- <width>60</width>
- <height>16777215</height>
- </size>
- </property>
- <property name="maximum">
- <number>255</number>
- </property>
- <property name="singleStep">
- <number>1</number>
- </property>
- </widget>
- </item>
- <item row="2" column="1">
- <widget class="QSpinBox" name="spinIPFirstNibble">
- <property name="maximumSize">
- <size>
- <width>60</width>
- <height>16777215</height>
- </size>
- </property>
- <property name="maximum">
- <number>255</number>
- </property>
- <property name="singleStep">
- <number>1</number>
- </property>
- </widget>
- </item>
- <item row="2" column="2">
- <widget class="QSpinBox" name="spinIPSecondNibble">
- <property name="maximumSize">
- <size>
- <width>60</width>
- <height>16777215</height>
- </size>
- </property>
- <property name="maximum">
- <number>255</number>
- </property>
- <property name="singleStep">
- <number>1</number>
- </property>
- </widget>
- </item>
- <item row="2" column="3">
- <widget class="QSpinBox" name="spinIPThirdNibble">
- <property name="maximumSize">
- <size>
- <width>60</width>
- <height>16777215</height>
- </size>
- </property>
- <property name="maximum">
- <number>255</number>
- </property>
- <property name="singleStep">
- <number>1</number>
- </property>
- </widget>
- </item>
- <item row="2" column="0">
- <widget class="QLabel" name="label_4">
- <property name="text">
- <string>IP-address remote PC</string>
- </property>
- </widget>
- </item>
- <item row="1" column="0">
- <widget class="QCheckBox" name="chkLocalPC">
- <property name="layoutDirection">
- <enum>Qt::RightToLeft</enum>
- </property>
- <property name="text">
- <string>Local PC only</string>
- </property>
- </widget>
- </item>
- <item row="3" column="0">
- <widget class="QLabel" name="label_5">
- <property name="text">
- <string>Port-number</string>
- </property>
- </widget>
- </item>
- <item row="3" column="1">
- <widget class="QSpinBox" name="spinPortNumber">
- <property name="minimum">
- <number>1000</number>
- </property>
- <property name="maximum">
- <number>10000</number>
- </property>
- </widget>
- </item>
- </layout>
+ <layout class="QGridLayout" name="gridLayout">
+ <item row="0" column="0">
+ <widget class="QLabel" name="label_4">
+ <property name="text">
+ <string>IP-address remote PC</string>
+ </property>
+ </widget>
</item>
- <item>
- <spacer name="verticalSpacer">
- <property name="orientation">
- <enum>Qt::Vertical</enum>
+ <item row="0" column="1">
+ <widget class="QSpinBox" name="spinIPFirstNibble">
+ <property name="maximumSize">
+ <size>
+ <width>60</width>
+ <height>16777215</height>
+ </size>
+ </property>
+ <property name="maximum">
+ <number>255</number>
</property>
- <property name="sizeHint" stdset="0">
+ <property name="singleStep">
+ <number>1</number>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="2">
+ <widget class="QSpinBox" name="spinIPSecondNibble">
+ <property name="maximumSize">
<size>
- <width>20</width>
- <height>40</height>
+ <width>60</width>
+ <height>16777215</height>
</size>
</property>
- </spacer>
+ <property name="maximum">
+ <number>255</number>
+ </property>
+ <property name="singleStep">
+ <number>1</number>
+ </property>
+ </widget>
</item>
- <item>
- <layout class="QVBoxLayout" name="verticalLayout">
- <item>
- <widget class="QLabel" name="label_2">
- <property name="text">
- <string>If FlightGear is on the same PC as FaceTrackNoIR, tick the 'Local PC only' box.</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QLabel" name="label">
- <property name="text">
- <string>Otherwise: enter IP-address and port-number for the remote PC.</string>
- </property>
- <property name="wordWrap">
- <bool>true</bool>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QLabel" name="label_3">
- <property name="text">
- <string>Remember: you may have to change firewall-settings too!</string>
- </property>
- </widget>
- </item>
- </layout>
+ <item row="0" column="3">
+ <widget class="QSpinBox" name="spinIPThirdNibble">
+ <property name="maximumSize">
+ <size>
+ <width>60</width>
+ <height>16777215</height>
+ </size>
+ </property>
+ <property name="maximum">
+ <number>255</number>
+ </property>
+ <property name="singleStep">
+ <number>1</number>
+ </property>
+ </widget>
</item>
- <item>
- <layout class="QHBoxLayout" name="horizontalLayout">
- <item>
- <spacer name="horizontalSpacer_2">
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>40</width>
- <height>20</height>
- </size>
- </property>
- </spacer>
- </item>
- <item>
- <layout class="QHBoxLayout" name="horizontalLayout_2">
- <property name="sizeConstraint">
- <enum>QLayout::SetDefaultConstraint</enum>
- </property>
- <item>
- <widget class="QPushButton" name="btnOK">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="minimumSize">
- <size>
- <width>100</width>
- <height>0</height>
- </size>
- </property>
- <property name="maximumSize">
- <size>
- <width>100</width>
- <height>16777215</height>
- </size>
- </property>
- <property name="text">
- <string>OK</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QPushButton" name="btnCancel">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="minimumSize">
- <size>
- <width>100</width>
- <height>0</height>
- </size>
- </property>
- <property name="maximumSize">
- <size>
- <width>100</width>
- <height>16777215</height>
- </size>
- </property>
- <property name="text">
- <string>Cancel</string>
- </property>
- </widget>
- </item>
- </layout>
- </item>
- <item>
- <spacer name="horizontalSpacer">
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="sizeType">
- <enum>QSizePolicy::Fixed</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>10</width>
- <height>20</height>
- </size>
- </property>
- </spacer>
- </item>
- </layout>
+ <item row="0" column="4">
+ <widget class="QSpinBox" name="spinIPFourthNibble">
+ <property name="maximumSize">
+ <size>
+ <width>60</width>
+ <height>16777215</height>
+ </size>
+ </property>
+ <property name="maximum">
+ <number>255</number>
+ </property>
+ <property name="singleStep">
+ <number>1</number>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="0">
+ <widget class="QLabel" name="label_5">
+ <property name="text">
+ <string>Port-number</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1">
+ <widget class="QSpinBox" name="spinPortNumber">
+ <property name="minimum">
+ <number>1000</number>
+ </property>
+ <property name="maximum">
+ <number>10000</number>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="2" colspan="3">
+ <widget class="QDialogButtonBox" name="buttonBox">
+ <property name="standardButtons">
+ <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
+ </property>
+ </widget>
</item>
</layout>
</widget>
@@ -268,9 +130,6 @@
<tabstop>spinIPThirdNibble</tabstop>
<tabstop>spinIPFourthNibble</tabstop>
<tabstop>spinPortNumber</tabstop>
- <tabstop>btnOK</tabstop>
- <tabstop>btnCancel</tabstop>
- <tabstop>chkLocalPC</tabstop>
</tabstops>
<resources/>
<connections/>
diff --git a/ftnoir_protocol_fg/ftnoir_protocol_fg.cpp b/ftnoir_protocol_fg/ftnoir_protocol_fg.cpp
index 08e7370b..0ef6b50f 100644
--- a/ftnoir_protocol_fg/ftnoir_protocol_fg.cpp
+++ b/ftnoir_protocol_fg/ftnoir_protocol_fg.cpp
@@ -26,41 +26,14 @@
* It is based on the (Linux) example made by Melchior FRANZ. *
********************************************************************************/
#include "ftnoir_protocol_fg.h"
-#include <QFile>
#include "facetracknoir/global-settings.h"
#include <ftnoir_tracker_base/ftnoir_tracker_types.h>
// For Todd and Arda Kutlu
-FTNoIR_Protocol::FTNoIR_Protocol()
+void FTNoIR_Protocol::reloadSettings()
{
- loadSettings();
-}
-
-FTNoIR_Protocol::~FTNoIR_Protocol()
-{
-}
-
-void FTNoIR_Protocol::loadSettings() {
- QSettings settings("opentrack"); // Registry settings (in HK_USER)
-
- QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString();
- QSettings iniFile( currentFile, QSettings::IniFormat ); // Application settings (in INI-file)
-
- iniFile.beginGroup ( "FG" );
-
- bool blnLocalPC = iniFile.value ( "LocalPCOnly", 1 ).toBool();
- if (blnLocalPC) {
- destIP = QHostAddress::LocalHost;
- }
- else {
- QString destAddr = iniFile.value ( "IP-1", 192 ).toString() + "." + iniFile.value ( "IP-2", 168 ).toString() + "." + iniFile.value ( "IP-3", 2 ).toString() + "." + iniFile.value ( "IP-4", 1 ).toString();
- destIP = QHostAddress( destAddr );
- }
- destPort = iniFile.value ( "PortNumber", 5542 ).toInt();
-
- iniFile.endGroup ();
-
+ s.b->reload();
}
void FTNoIR_Protocol::sendHeadposeToGame(const double* headpose) {
@@ -71,13 +44,15 @@ void FTNoIR_Protocol::sendHeadposeToGame(const double* headpose) {
FlightData.h = headpose[Yaw];
FlightData.r = headpose[Roll];
FlightData.status = 1;
+ QHostAddress destIP(QString("%1.%2.%3.%4").arg(
+ QString::number(static_cast<int>(s.ip1)),
+ QString::number(static_cast<int>(s.ip2)),
+ QString::number(static_cast<int>(s.ip3)),
+ QString::number(static_cast<int>(s.ip4))));
+ int destPort = s.port;
(void) outSocket.writeDatagram(reinterpret_cast<const char*>(&FlightData), sizeof(FlightData), destIP, static_cast<quint16>(destPort));
}
-//
-// Check if the Client DLL exists and load it (to test it), if so.
-// Returns 'true' if all seems OK.
-//
bool FTNoIR_Protocol::checkServerInstallationOK()
{
return outSocket.bind(QHostAddress::Any, 0, QUdpSocket::ShareAddress | QUdpSocket::ReuseAddressHint);
diff --git a/ftnoir_protocol_fg/ftnoir_protocol_fg.h b/ftnoir_protocol_fg/ftnoir_protocol_fg.h
index 9a4f304c..dca1f245 100644
--- a/ftnoir_protocol_fg/ftnoir_protocol_fg.h
+++ b/ftnoir_protocol_fg/ftnoir_protocol_fg.h
@@ -26,36 +26,43 @@
* It is based on the (Linux) example made by Melchior FRANZ. *
********************************************************************************/
#pragma once
-#ifndef INCLUDED_FGSERVER_H
-#define INCLUDED_FGSERVER_H
-
#include "ftnoir_protocol_base/ftnoir_protocol_base.h"
#include "ui_ftnoir_fgcontrols.h"
#include "fgtypes.h"
#include <QThread>
#include <QUdpSocket>
#include <QMessageBox>
-#include <QSettings>
#include "facetracknoir/global-settings.h"
+#include "facetracknoir/options.h"
+using namespace options;
-#define FT_PROGRAMID "FT_ProgramID"
+struct settings {
+ pbundle b;
+ value<int> ip1, ip2, ip3, ip4;
+ value<int> port;
+ settings() :
+ b(bundle("flightgear-proto")),
+ ip1(b, "ip1", 192),
+ ip2(b, "ip2", 168),
+ ip3(b, "ip3", 0),
+ ip4(b, "ip4", 2),
+ port(b, "port", 5542)
+ {}
+};
class FTNoIR_Protocol : public IProtocol
{
public:
- FTNoIR_Protocol();
- virtual ~FTNoIR_Protocol();
bool checkServerInstallationOK();
void sendHeadposeToGame(const double *headpose);
QString getGameName() {
return "FlightGear";
}
+ void reloadSettings();
private:
+ settings s;
TFlightGearData FlightData;
- QUdpSocket outSocket; // Send to FligthGear
- QHostAddress destIP; // Destination IP-address
- int destPort; // Destination port-number
- void loadSettings();
+ QUdpSocket outSocket;
};
// Widget that has controls for FTNoIR protocol client-settings.
@@ -63,51 +70,27 @@ class FGControls: public QWidget, public IProtocolDialog
{
Q_OBJECT
public:
-
- explicit FGControls();
- virtual ~FGControls();
- void showEvent ( QShowEvent * event );
-
- void Initialize(QWidget *parent);
+ FGControls();
void registerProtocol(IProtocol *protocol) {
theProtocol = (FTNoIR_Protocol *) protocol; // Accept the pointer to the Protocol
}
void unRegisterProtocol() {
theProtocol = NULL; // Reset the pointer
}
-
private:
Ui::UICFGControls ui;
- void loadSettings();
- void save();
-
- /** helper **/
- bool settingsDirty;
FTNoIR_Protocol *theProtocol;
-
+ settings s;
private slots:
void doOK();
void doCancel();
- void chkLocalPCOnlyChanged();
- void settingChanged() { settingsDirty = true; }
};
-//*******************************************************************************************************
-// FaceTrackNoIR Protocol DLL. Functions used to get general info on the Protocol
-//*******************************************************************************************************
class FTNoIR_ProtocolDll : public Metadata
{
public:
- FTNoIR_ProtocolDll();
- ~FTNoIR_ProtocolDll();
-
void getFullName(QString *strToBeFilled) { *strToBeFilled = QString("FlightGear"); }
void getShortName(QString *strToBeFilled) { *strToBeFilled = QString("FlightGear"); }
void getDescription(QString *strToBeFilled) { *strToBeFilled = QString("FlightGear UDP protocol"); }
-
void getIcon(QIcon *icon) { *icon = QIcon(":/images/flightgear.png"); }
};
-
-
-#endif//INCLUDED_FGSERVER_H
-//END
diff --git a/ftnoir_protocol_fg/ftnoir_protocol_fg_dialog.cpp b/ftnoir_protocol_fg/ftnoir_protocol_fg_dialog.cpp
index 45123540..887020c5 100644
--- a/ftnoir_protocol_fg/ftnoir_protocol_fg_dialog.cpp
+++ b/ftnoir_protocol_fg/ftnoir_protocol_fg_dialog.cpp
@@ -37,179 +37,51 @@
//
// Constructor for server-settings-dialog
//
-FGControls::FGControls() :
-QWidget()
+FGControls::FGControls() : theProtocol(nullptr)
{
ui.setupUi( this );
- QPoint offsetpos(100, 100);
- //if (parent) {
- // this->move(parent->pos() + offsetpos);
- //}
+ tie_setting(s.ip1, ui.spinIPFirstNibble);
+ tie_setting(s.ip2, ui.spinIPSecondNibble);
+ tie_setting(s.ip3, ui.spinIPThirdNibble);
+ tie_setting(s.ip4, ui.spinIPFourthNibble);
+ tie_setting(s.port, ui.spinPortNumber);
- // Connect Qt signals to member-functions
- connect(ui.btnOK, SIGNAL(clicked()), this, SLOT(doOK()));
- connect(ui.btnCancel, SIGNAL(clicked()), this, SLOT(doCancel()));
- connect(ui.chkLocalPC, SIGNAL(stateChanged(int)), this, SLOT(chkLocalPCOnlyChanged()));
- connect(ui.spinIPFirstNibble, SIGNAL(valueChanged(int)), this, SLOT(settingChanged()));
- connect(ui.spinIPSecondNibble, SIGNAL(valueChanged(int)), this, SLOT(settingChanged()));
- connect(ui.spinIPThirdNibble, SIGNAL(valueChanged(int)), this, SLOT(settingChanged()));
- connect(ui.spinIPFourthNibble, SIGNAL(valueChanged(int)), this, SLOT(settingChanged()));
- connect(ui.spinPortNumber, SIGNAL(valueChanged(int)), this, SLOT(settingChanged()));
-
- theProtocol = NULL;
-
- // Load the settings from the current .INI-file
- loadSettings();
-}
-
-//
-// Destructor for server-dialog
-//
-FGControls::~FGControls() {
- qDebug() << "~FGControls() says: started";
-}
-
-//
-// Initialize tracker-client-dialog
-//
-void FGControls::Initialize(QWidget *parent) {
-
- QPoint offsetpos(100, 100);
- if (parent) {
- this->move(parent->pos() + offsetpos);
- }
- show();
+ connect(ui.buttonBox, SIGNAL(accepted()), this, SLOT(doOK()));
+ connect(ui.buttonBox, SIGNAL(rejected()), this, SLOT(doCancel()));
}
-//
-// OK clicked on server-dialog
-//
void FGControls::doOK() {
- save();
+ s.b->save();
this->close();
+ if (theProtocol)
+ theProtocol->reloadSettings();
}
-// override show event
-void FGControls::showEvent ( QShowEvent * ) {
- loadSettings();
-}
-
-//
-// Cancel clicked on server-dialog
-//
void FGControls::doCancel() {
- //
- // Ask if changed Settings should be saved
- //
- if (settingsDirty) {
- int ret = QMessageBox::question ( this, "Settings have changed", "Do you want to save the settings?", QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel, QMessageBox::Discard );
-
- qDebug() << "doCancel says: answer =" << ret;
-
- switch (ret) {
- case QMessageBox::Save:
- save();
- this->close();
- break;
- case QMessageBox::Discard:
- this->close();
- break;
- case QMessageBox::Cancel:
- // Cancel was clicked
- break;
- default:
- // should never be reached
- break;
- }
- }
- else {
- this->close();
- }
-}
-
-//
-// Load the current Settings from the currently 'active' INI-file.
-//
-void FGControls::loadSettings() {
-// qDebug() << "loadSettings says: Starting ";
- QSettings settings("opentrack"); // Registry settings (in HK_USER)
-
- QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString();
- QSettings iniFile( currentFile, QSettings::IniFormat ); // Application settings (in INI-file)
-
-// qDebug() << "loadSettings says: iniFile = " << currentFile;
-
- iniFile.beginGroup ( "FG" );
- ui.chkLocalPC->setChecked (iniFile.value ( "LocalPCOnly", 1 ).toBool());
-
- ui.spinIPFirstNibble->setValue( iniFile.value ( "IP-1", 192 ).toInt() );
- ui.spinIPSecondNibble->setValue( iniFile.value ( "IP-2", 168 ).toInt() );
- ui.spinIPThirdNibble->setValue( iniFile.value ( "IP-3", 2 ).toInt() );
- ui.spinIPFourthNibble->setValue( iniFile.value ( "IP-4", 1 ).toInt() );
-
- ui.spinPortNumber->setValue( iniFile.value ( "PortNumber", 5542 ).toInt() );
- iniFile.endGroup ();
-
- chkLocalPCOnlyChanged();
- settingsDirty = false;
-}
-
-//
-// Save the current Settings to the currently 'active' INI-file.
-//
-void FGControls::save() {
- QSettings settings("opentrack"); // Registry settings (in HK_USER)
-
- QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString();
- QSettings iniFile( currentFile, QSettings::IniFormat ); // Application settings (in INI-file)
-
- iniFile.beginGroup ( "FG" );
- iniFile.setValue ( "LocalPCOnly", ui.chkLocalPC->isChecked() );
- iniFile.setValue ( "IP-1", ui.spinIPFirstNibble->value() );
- iniFile.setValue ( "IP-2", ui.spinIPSecondNibble->value() );
- iniFile.setValue ( "IP-3", ui.spinIPThirdNibble->value() );
- iniFile.setValue ( "IP-4", ui.spinIPFourthNibble->value() );
- iniFile.setValue ( "PortNumber", ui.spinPortNumber->value() );
- iniFile.endGroup ();
-
- settingsDirty = false;
+ if (s.b->modifiedp()) {
+ int ret = QMessageBox::question ( this, "Settings have changed", "Do you want to save the settings?", QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel );
+ switch (ret) {
+ case QMessageBox::Save:
+ s.b->save();
+ if (theProtocol)
+ theProtocol->reloadSettings();
+ this->close();
+ break;
+ case QMessageBox::Discard:
+ s.b->revert();
+ close();
+ break;
+ case QMessageBox::Cancel:
+ default:
+ break;
+ }
+ }
+ else {
+ this->close();
+ }
}
-//
-// Handle change of the checkbox.
-//
-void FGControls::chkLocalPCOnlyChanged() {
-
- if ( ui.chkLocalPC->isChecked() ) {
- ui.spinIPFirstNibble->setValue( 127 );
- ui.spinIPFirstNibble->setEnabled ( false );
- ui.spinIPSecondNibble->setValue( 0 );
- ui.spinIPSecondNibble->setEnabled ( false );
- ui.spinIPThirdNibble->setValue( 0 );
- ui.spinIPThirdNibble->setEnabled ( false );
- ui.spinIPFourthNibble->setValue( 1 );
- ui.spinIPFourthNibble->setEnabled ( false );
- }
- else {
- ui.spinIPFirstNibble->setEnabled ( true );
- ui.spinIPSecondNibble->setEnabled ( true );
- ui.spinIPThirdNibble->setEnabled ( true );
- ui.spinIPFourthNibble->setEnabled ( true );
- }
-
- settingsDirty = true;
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// Factory function that creates instances if the Protocol-settings dialog object.
-
-// Export both decorated and undecorated names.
-// GetProtocolDialog - Undecorated name, which can be easily used with GetProcAddress
-// Win32 API function.
-// _GetProtocolDialog@0 - Common name decoration for __stdcall functions in C language.
-//#pragma comment(linker, "/export:GetProtocolDialog=_GetProtocolDialog@0")
-
extern "C" FTNOIR_PROTOCOL_BASE_EXPORT IProtocolDialog* CALLING_CONVENTION GetDialog( )
{
return new FGControls;
diff --git a/ftnoir_protocol_fg/ftnoir_protocol_fg_dll.cpp b/ftnoir_protocol_fg/ftnoir_protocol_fg_dll.cpp
index 6c7e7c52..3125f136 100644
--- a/ftnoir_protocol_fg/ftnoir_protocol_fg_dll.cpp
+++ b/ftnoir_protocol_fg/ftnoir_protocol_fg_dll.cpp
@@ -26,23 +26,6 @@
#include <QDebug>
#include "facetracknoir/global-settings.h"
-FTNoIR_ProtocolDll::FTNoIR_ProtocolDll() {
-}
-
-FTNoIR_ProtocolDll::~FTNoIR_ProtocolDll()
-{
-
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// Factory function that creates instances if the Protocol object.
-
-// Export both decorated and undecorated names.
-// GetProtocolDll - Undecorated name, which can be easily used with GetProcAddress
-// Win32 API function.
-// _GetProtocolDll@0 - Common name decoration for __stdcall functions in C language.
-//#pragma comment(linker, "/export:GetProtocolDll=_GetProtocolDll@0")
-
extern "C" FTNOIR_PROTOCOL_BASE_EXPORT Metadata* CALLING_CONVENTION GetMetadata()
{
return new FTNoIR_ProtocolDll;
diff --git a/ftnoir_protocol_fsuipc/ftnoir_fsuipccontrols.ui b/ftnoir_protocol_fsuipc/ftnoir_fsuipccontrols.ui
index 9ccfa119..1ce77862 100644
--- a/ftnoir_protocol_fsuipc/ftnoir_fsuipccontrols.ui
+++ b/ftnoir_protocol_fsuipc/ftnoir_fsuipccontrols.ui
@@ -9,8 +9,8 @@
<rect>
<x>0</x>
<y>0</y>
- <width>541</width>
- <height>139</height>
+ <width>512</width>
+ <height>100</height>
</rect>
</property>
<property name="windowTitle">
@@ -26,198 +26,101 @@
<property name="autoFillBackground">
<bool>false</bool>
</property>
- <layout class="QVBoxLayout" name="_vertical_layout">
- <item>
- <layout class="QHBoxLayout">
- <item>
- <widget class="QLabel" name="textLabel2">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Minimum" vsizetype="Fixed">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="text">
- <string>Location of FSUIPC.dll:</string>
- </property>
- <property name="alignment">
- <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
- </property>
- <property name="wordWrap">
- <bool>false</bool>
- </property>
- </widget>
- </item>
- <item>
- <spacer name="horizontalSpacer_3">
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>40</width>
- <height>20</height>
- </size>
- </property>
- </spacer>
- </item>
- </layout>
+ <layout class="QGridLayout" name="gridLayout">
+ <item row="2" column="1">
+ <widget class="QPushButton" name="btnCancel">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>100</width>
+ <height>0</height>
+ </size>
+ </property>
+ <property name="maximumSize">
+ <size>
+ <width>100</width>
+ <height>16777215</height>
+ </size>
+ </property>
+ <property name="text">
+ <string>Cancel</string>
+ </property>
+ </widget>
</item>
- <item>
- <layout class="QHBoxLayout" name="horizontalLayout_3">
- <item>
- <widget class="QLabel" name="txtLocationOfDLL">
- <property name="minimumSize">
- <size>
- <width>230</width>
- <height>0</height>
- </size>
- </property>
- <property name="toolTip">
- <string>Location of FSUIPC.dll</string>
- </property>
- <property name="frameShape">
- <enum>QFrame::Box</enum>
- </property>
- <property name="frameShadow">
- <enum>QFrame::Sunken</enum>
- </property>
- <property name="lineWidth">
- <number>1</number>
- </property>
- <property name="text">
- <string>Location of FSUIPC.dll</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QPushButton" name="btnFindDLL">
- <property name="maximumSize">
- <size>
- <width>35</width>
- <height>16777215</height>
- </size>
- </property>
- <property name="text">
- <string>...</string>
- </property>
- </widget>
- </item>
- </layout>
+ <item row="0" column="0">
+ <widget class="QLabel" name="txtLocationOfDLL">
+ <property name="minimumSize">
+ <size>
+ <width>230</width>
+ <height>0</height>
+ </size>
+ </property>
+ <property name="toolTip">
+ <string>Location of FSUIPC.dll</string>
+ </property>
+ <property name="frameShape">
+ <enum>QFrame::Box</enum>
+ </property>
+ <property name="frameShadow">
+ <enum>QFrame::Sunken</enum>
+ </property>
+ <property name="lineWidth">
+ <number>1</number>
+ </property>
+ <property name="text">
+ <string>Location of FSUIPC.dll</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="0" colspan="2">
+ <widget class="QLabel" name="label">
+ <property name="text">
+ <string>The DLL should be located in the Modules/ directory of MS FS 2004</string>
+ </property>
+ </widget>
</item>
- <item>
- <spacer name="verticalSpacer">
- <property name="orientation">
- <enum>Qt::Vertical</enum>
+ <item row="2" column="0">
+ <widget class="QPushButton" name="btnOK">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
</property>
- <property name="sizeHint" stdset="0">
+ <property name="minimumSize">
<size>
- <width>20</width>
- <height>40</height>
+ <width>100</width>
+ <height>0</height>
</size>
</property>
- </spacer>
- </item>
- <item>
- <layout class="QVBoxLayout" name="verticalLayout">
- <item>
- <widget class="QLabel" name="label">
- <property name="text">
- <string>The DLL should be placed in the Modules folder of MS Flight Simulator</string>
- </property>
- </widget>
- </item>
- </layout>
+ <property name="maximumSize">
+ <size>
+ <width>100</width>
+ <height>16777215</height>
+ </size>
+ </property>
+ <property name="text">
+ <string>OK</string>
+ </property>
+ </widget>
</item>
- <item>
- <layout class="QHBoxLayout" name="horizontalLayout">
- <item>
- <spacer name="horizontalSpacer_2">
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>40</width>
- <height>20</height>
- </size>
- </property>
- </spacer>
- </item>
- <item>
- <layout class="QHBoxLayout" name="horizontalLayout_2">
- <property name="sizeConstraint">
- <enum>QLayout::SetDefaultConstraint</enum>
- </property>
- <item>
- <widget class="QPushButton" name="btnOK">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="minimumSize">
- <size>
- <width>100</width>
- <height>0</height>
- </size>
- </property>
- <property name="maximumSize">
- <size>
- <width>100</width>
- <height>16777215</height>
- </size>
- </property>
- <property name="text">
- <string>OK</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QPushButton" name="btnCancel">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="minimumSize">
- <size>
- <width>100</width>
- <height>0</height>
- </size>
- </property>
- <property name="maximumSize">
- <size>
- <width>100</width>
- <height>16777215</height>
- </size>
- </property>
- <property name="text">
- <string>Cancel</string>
- </property>
- </widget>
- </item>
- </layout>
- </item>
- <item>
- <spacer name="horizontalSpacer">
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="sizeType">
- <enum>QSizePolicy::Fixed</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>10</width>
- <height>20</height>
- </size>
- </property>
- </spacer>
- </item>
- </layout>
+ <item row="0" column="1">
+ <widget class="QPushButton" name="btnFindDLL">
+ <property name="maximumSize">
+ <size>
+ <width>35</width>
+ <height>16777215</height>
+ </size>
+ </property>
+ <property name="text">
+ <string>...</string>
+ </property>
+ </widget>
</item>
</layout>
</widget>
diff --git a/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc.cpp b/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc.cpp
index 986ccc65..632d502a 100644
--- a/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc.cpp
+++ b/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc.cpp
@@ -30,9 +30,6 @@
/** constructor **/
FTNoIR_Protocol::FTNoIR_Protocol()
{
- loadSettings();
- ProgramName = "Microsoft FS2004";
-
prevPosX = 0.0f;
prevPosY = 0.0f;
prevPosZ = 0.0f;
@@ -41,12 +38,8 @@ FTNoIR_Protocol::FTNoIR_Protocol()
prevRotZ = 0.0f;
}
-/** destructor **/
FTNoIR_Protocol::~FTNoIR_Protocol()
{
- //
- // Free the DLL
- //
FSUIPCLib.unload();
}
@@ -69,38 +62,20 @@ double local_x;
return (int) y;
}
-//
-// Load the current Settings from the currently 'active' INI-file.
-//
-void FTNoIR_Protocol::loadSettings() {
- QSettings settings("opentrack"); // Registry settings (in HK_USER)
-
- QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString();
- QSettings iniFile( currentFile, QSettings::IniFormat ); // Application settings (in INI-file)
-
- iniFile.beginGroup ( "FSUIPC" );
- LocationOfDLL = iniFile.value ( "LocationOfDLL", FSUIPC_FILENAME ).toString();
- qDebug() << "FSUIPCServer::loadSettings() says: Location of DLL = " << LocationOfDLL;
- iniFile.endGroup ();
-}
-
-//
-// Update Headpose in Game.
-//
void FTNoIR_Protocol::sendHeadposeToGame(const double *headpose ) {
-DWORD result;
-TFSState pitch;
-TFSState yaw;
-TFSState roll;
-WORD FSZoom;
+ DWORD result;
+ TFSState pitch;
+ TFSState yaw;
+ TFSState roll;
+ WORD FSZoom;
-float virtPosX;
-float virtPosY;
-float virtPosZ;
+ float virtPosX;
+ float virtPosY;
+ float virtPosZ;
-float virtRotX;
-float virtRotY;
-float virtRotZ;
+ float virtRotX;
+ float virtRotY;
+ float virtRotZ;
// qDebug() << "FSUIPCServer::run() says: started!";
@@ -168,9 +143,6 @@ float virtRotZ;
prevRotZ = virtRotZ;
}
-//
-// Returns 'true' if all seems OK.
-//
bool FTNoIR_Protocol::checkServerInstallationOK()
{
qDebug() << "checkServerInstallationOK says: Starting Function";
@@ -178,7 +150,7 @@ bool FTNoIR_Protocol::checkServerInstallationOK()
//
// Load the DLL.
//
- FSUIPCLib.setFileName( LocationOfDLL );
+ FSUIPCLib.setFileName( s.LocationOfDLL );
if (FSUIPCLib.load() != true) {
qDebug() << "checkServerInstallationOK says: Error loading FSUIPC DLL";
return false;
@@ -190,15 +162,6 @@ bool FTNoIR_Protocol::checkServerInstallationOK()
return true;
}
-///////////////////////////////////////////////////////////////////////////////
-// Factory function that creates instances if the Protocol object.
-
-// Export both decorated and undecorated names.
-// GetProtocol - Undecorated name, which can be easily used with GetProcAddress
-// Win32 API function.
-// _GetProtocol@0 - Common name decoration for __stdcall functions in C language.
-//#pragma comment(linker, "/export:GetProtocol=_GetProtocol@0")
-
extern "C" FTNOIR_PROTOCOL_BASE_EXPORT FTNoIR_Protocol* CALLING_CONVENTION GetConstructor(void)
{
return new FTNoIR_Protocol;
diff --git a/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc.h b/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc.h
index 87c6a3a4..ff8d3b7f 100644
--- a/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc.h
+++ b/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc.h
@@ -41,12 +41,20 @@
#include <QDebug>
#include <QFile>
#include <QFileDialog>
+#include "facetracknoir/options.h"
+using namespace options;
#define FSUIPC_FILENAME "C:\\Program Files\\Microsoft Games\\Flight Simulator 9\\Modules\\FSUIPC.dll"
-//
-// Define the structures necessary for the FSUIPC_Write calls
-//
+struct settings {
+ pbundle b;
+ value<QString> LocationOfDLL;
+ settings() :
+ b(bundle("proto-fsuipc")),
+ LocationOfDLL(b, "dll-location", FSUIPC_FILENAME)
+ {}
+};
+
#pragma pack(push,1) // All fields in structure must be byte aligned.
typedef struct
{
@@ -59,70 +67,42 @@ class FTNoIR_Protocol : public IProtocol
{
public:
FTNoIR_Protocol();
- virtual ~FTNoIR_Protocol();
+ virtual ~FTNoIR_Protocol() virt_override;
bool checkServerInstallationOK();
void sendHeadposeToGame(const double* headpose);
QString getGameName() {
return "Microsoft Flight Simulator X";
}
private:
- // Private properties
- QString ProgramName;
QLibrary FSUIPCLib;
- QString LocationOfDLL;
- float prevPosX, prevPosY, prevPosZ, prevRotX, prevRotY, prevRotZ;
-
+ double prevPosX, prevPosY, prevPosZ, prevRotX, prevRotY, prevRotZ;
static int scale2AnalogLimits( float x, float min_x, float max_x );
- void loadSettings();
+ settings s;
};
-// Widget that has controls for FTNoIR protocol client-settings.
class FSUIPCControls: public QWidget, public IProtocolDialog
{
Q_OBJECT
public:
-
- explicit FSUIPCControls();
- virtual ~FSUIPCControls();
- void showEvent ( QShowEvent * event );
- void Initialize(QWidget *parent);
- void registerProtocol(IProtocol *protocol) {
- theProtocol = (FTNoIR_Protocol *) protocol; // Accept the pointer to the Protocol
- }
- void unRegisterProtocol() {
- theProtocol = NULL; // Reset the pointer
- }
-
+ FSUIPCControls();
+ void registerProtocol(IProtocol *) {}
+ void unRegisterProtocol() {}
private:
Ui::UICFSUIPCControls ui;
- void loadSettings();
- void save();
-
- /** helper **/
- bool settingsDirty;
- FTNoIR_Protocol *theProtocol;
-
+ settings s;
private slots:
void doOK();
void doCancel();
- void settingChanged() { settingsDirty = true; };
void getLocationOfDLL();
};
-//*******************************************************************************************************
-// FaceTrackNoIR Protocol DLL. Functions used to get general info on the Protocol
-//*******************************************************************************************************
class FTNoIR_ProtocolDll : public Metadata
{
public:
- FTNoIR_ProtocolDll();
- ~FTNoIR_ProtocolDll();
-
- void getFullName(QString *strToBeFilled) { *strToBeFilled = QString("FS2002/FS2004"); };
- void getShortName(QString *strToBeFilled) { *strToBeFilled = QString("FSUIPC"); };
- void getDescription(QString *strToBeFilled) { *strToBeFilled = QString("Microsoft FS2004 protocol"); };
-
- void getIcon(QIcon *icon) { *icon = QIcon(":/images/fs9.png"); };
+ void getFullName(QString *strToBeFilled) { *strToBeFilled = QString("FS2002/FS2004"); }
+ void getShortName(QString *strToBeFilled) { *strToBeFilled = QString("FSUIPC"); }
+ void getDescription(QString *strToBeFilled) { *strToBeFilled = QString("Microsoft FS2004 protocol"); }
+ void getIcon(QIcon *icon) { *icon = QIcon(":/images/fs9.png"); }
};
diff --git a/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc_dialog.cpp b/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc_dialog.cpp
index 985915b4..bae3d5df 100644
--- a/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc_dialog.cpp
+++ b/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc_dialog.cpp
@@ -25,160 +25,57 @@
#include "ftnoir_protocol_fsuipc.h"
#include "facetracknoir/global-settings.h"
-//*******************************************************************************************************
-// FaceTrackNoIR Client Settings-dialog.
-//*******************************************************************************************************
-
-//
-// Constructor for server-settings-dialog
-//
FSUIPCControls::FSUIPCControls() :
-QWidget()
+ QWidget()
{
- ui.setupUi( this );
-
- // Connect Qt signals to member-functions
- connect(ui.btnOK, SIGNAL(clicked()), this, SLOT(doOK()));
- connect(ui.btnCancel, SIGNAL(clicked()), this, SLOT(doCancel()));
- connect(ui.btnFindDLL, SIGNAL(clicked()), this, SLOT(getLocationOfDLL()));
-
- theProtocol = NULL;
-
- // Load the settings from the current .INI-file
- loadSettings();
-}
-
-//
-// Destructor for server-dialog
-//
-FSUIPCControls::~FSUIPCControls() {
- qDebug() << "~FSUIPCControls() says: started";
-}
-
-//
-// Initialize tracker-client-dialog
-//
-void FSUIPCControls::Initialize(QWidget *parent) {
+ ui.setupUi( this );
+ connect(ui.btnOK, SIGNAL(clicked()), this, SLOT(doOK()));
+ connect(ui.btnCancel, SIGNAL(clicked()), this, SLOT(doCancel()));
+ connect(ui.btnFindDLL, SIGNAL(clicked()), this, SLOT(getLocationOfDLL()));
- QPoint offsetpos(100, 100);
- if (parent) {
- this->move(parent->pos() + offsetpos);
- }
- show();
+ tie_setting(s.LocationOfDLL, ui.txtLocationOfDLL);
}
-//
-// OK clicked on server-dialog
-//
void FSUIPCControls::doOK() {
- save();
- this->close();
+ s.b->save();
+ this->close();
}
-// override show event
-void FSUIPCControls::showEvent ( QShowEvent * event ) {
- loadSettings();
-}
-
-//
-// Cancel clicked on server-dialog
-//
void FSUIPCControls::doCancel() {
- //
- // Ask if changed Settings should be saved
- //
- if (settingsDirty) {
- int ret = QMessageBox::question ( this, "Settings have changed", "Do you want to save the settings?", QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel, QMessageBox::Discard );
-
- qDebug() << "doCancel says: answer =" << ret;
-
- switch (ret) {
- case QMessageBox::Save:
- save();
- this->close();
- break;
- case QMessageBox::Discard:
- this->close();
- break;
- case QMessageBox::Cancel:
- // Cancel was clicked
- break;
- default:
- // should never be reached
- break;
- }
- }
- else {
- this->close();
- }
+ if (s.b->modifiedp()) {
+ int ret = QMessageBox::question ( this, "Settings have changed", "Do you want to save the settings?", QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel, QMessageBox::Discard );
+
+ qDebug() << "doCancel says: answer =" << ret;
+
+ switch (ret) {
+ case QMessageBox::Save:
+ s.b->save();
+ this->close();
+ break;
+ case QMessageBox::Discard:
+ s.b->revert();
+ this->close();
+ break;
+ case QMessageBox::Cancel:
+ default:
+ break;
+ }
+ }
+ else {
+ this->close();
+ }
}
-//
-// Load the current Settings from the currently 'active' INI-file.
-//
-void FSUIPCControls::loadSettings() {
-
- qDebug() << "loadSettings says: Starting ";
- QSettings settings("opentrack"); // Registry settings (in HK_USER)
-
- QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString();
- QSettings iniFile( currentFile, QSettings::IniFormat ); // Application settings (in INI-file)
-
- qDebug() << "loadSettings says: iniFile = " << currentFile;
-
- iniFile.beginGroup ( "FSUIPC" );
- ui.txtLocationOfDLL->setText(iniFile.value ( "LocationOfDLL", FSUIPC_FILENAME ).toString() );
- iniFile.endGroup ();
-
- settingsDirty = false;
-}
-
-//
-// Save the current Settings to the currently 'active' INI-file.
-//
-void FSUIPCControls::save() {
-
- qDebug() << "save() says: started";
-
- QSettings settings("opentrack"); // Registry settings (in HK_USER)
-
- QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString();
- QSettings iniFile( currentFile, QSettings::IniFormat ); // Application settings (in INI-file)
-
- iniFile.beginGroup ( "FSUIPC" );
- iniFile.setValue ( "LocationOfDLL", ui.txtLocationOfDLL->text() );
- iniFile.endGroup ();
-
- settingsDirty = false;
-}
-
-//
-// Show the Dialog to set the DLL's location
-//
void FSUIPCControls::getLocationOfDLL()
{
- //
- // Get the new filename of the INI-file.
- //
- QString fileName = QFileDialog::getOpenFileName(this, tr("Locate file"),
- ui.txtLocationOfDLL->text(),
- tr("FSUIPC DLL file (FSUIPC*.dll);;All Files (*)"));
- if (!fileName.isEmpty()) {
- ui.txtLocationOfDLL->setText( fileName );
- settingsDirty = true;
- }
+ QString fileName = QFileDialog::getOpenFileName(this, tr("Locate file"),
+ ui.txtLocationOfDLL->text(),
+ tr("FSUIPC DLL file (FSUIPC*.dll);;All Files (*)"));
+ if (!fileName.isEmpty()) {
+ s.LocationOfDLL = fileName;
+ }
}
-
-////////////////////////////////////////////////////////////////////////////////
-// Factory function that creates instances if the Protocol-settings dialog object.
-
-// Export both decorated and undecorated names.
-// GetProtocolDialog - Undecorated name, which can be easily used with GetProcAddress
-// Win32 API function.
-// _GetProtocolDialog@0 - Common name decoration for __stdcall functions in C language.
-//#pragma comment(linker, "/export:GetProtocolDialog=_GetProtocolDialog@0")
-
extern "C" FTNOIR_PROTOCOL_BASE_EXPORT IProtocolDialog* CALLING_CONVENTION GetDialog(void)
{
return new FSUIPCControls;
diff --git a/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc_dll.cpp b/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc_dll.cpp
index b0ca2eee..57b174c5 100644
--- a/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc_dll.cpp
+++ b/ftnoir_protocol_fsuipc/ftnoir_protocol_fsuipc_dll.cpp
@@ -23,26 +23,8 @@
* *
********************************************************************************/
#include "ftnoir_protocol_fsuipc.h"
-#include <QDebug>
#include "facetracknoir/global-settings.h"
-FTNoIR_ProtocolDll::FTNoIR_ProtocolDll() {
-}
-
-FTNoIR_ProtocolDll::~FTNoIR_ProtocolDll()
-{
-
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// Factory function that creates instances if the Protocol object.
-
-// Export both decorated and undecorated names.
-// GetProtocolDll - Undecorated name, which can be easily used with GetProcAddress
-// Win32 API function.
-// _GetProtocolDll@0 - Common name decoration for __stdcall functions in C language.
-//#pragma comment(linker, "/export:GetProtocolDll=_GetProtocolDll@0")
-
extern "C" FTNOIR_PROTOCOL_BASE_EXPORT Metadata* CALLING_CONVENTION GetMetadata(void)
{
return new FTNoIR_ProtocolDll;
diff --git a/ftnoir_protocol_ft/ftnoir_protocol_ft.cpp b/ftnoir_protocol_ft/ftnoir_protocol_ft.cpp
index 84d1d20b..5c086c10 100644
--- a/ftnoir_protocol_ft/ftnoir_protocol_ft.cpp
+++ b/ftnoir_protocol_ft/ftnoir_protocol_ft.cpp
@@ -24,78 +24,30 @@
* FTServer FTServer is the Class, that communicates headpose-data *
* to games, using the FreeTrackClient.dll. *
********************************************************************************/
-#include <algorithm>
#include "ftnoir_protocol_ft.h"
#include "ftnoir_csv/csv.h"
-/** constructor **/
FTNoIR_Protocol::FTNoIR_Protocol() :
shm(FT_MM_DATA, FREETRACK_MUTEX, sizeof(FTMemMap))
{
pMemData = (FTMemMap*) shm.mem;
- useTIRViews = false;
- useDummyExe = false;
- intUsedInterface = 0;
-
- loadSettings();
-
- ProgramName = "";
- intGameID = 0;
-
- viewsStart = 0;
- viewsStop = 0;
+ ProgramName = "";
+ intGameID = 0;
+ viewsStart = 0;
+ viewsStop = 0;
}
-/** destructor **/
FTNoIR_Protocol::~FTNoIR_Protocol()
{
-
- qDebug()<< "~FTNoIR_Protocol: Destructor started.";
-
- //
- // Stop if started
- //
- if (viewsStop != NULL) {
- qDebug()<< "~FTNoIR_Protocol: Stopping TIRViews.";
- viewsStop();
- FTIRViewsLib.unload();
- }
- dummyTrackIR.terminate();
+ if (viewsStop != NULL) {
+ viewsStop();
+ FTIRViewsLib.unload();
+ }
+ dummyTrackIR.terminate();
dummyTrackIR.kill();
dummyTrackIR.waitForFinished(50);
-
}
-//
-// Read the game-data from CSV
-//
-
-
-//
-// Load the current Settings from the currently 'active' INI-file.
-//
-void FTNoIR_Protocol::loadSettings() {
- QSettings settings("opentrack"); // Registry settings (in HK_USER)
-
- QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString();
- QSettings iniFile( currentFile, QSettings::IniFormat ); // Application settings (in INI-file)
-
- iniFile.beginGroup ( "FT" );
- intUsedInterface = iniFile.value ( "UsedInterface", 0 ).toInt();
- iniFile.endGroup ();
-
- //
- // Use the settings-section from the deprecated fake-TIR protocol, as they are most likely to be found there.
- //
- iniFile.beginGroup ( "FTIR" );
- useTIRViews = iniFile.value ( "useTIRViews", 0 ).toBool();
- useDummyExe = iniFile.value ( "useDummyExe", 0 ).toBool();
- iniFile.endGroup ();
-}
-
-//
-// Update Headpose in Game.
-//
void FTNoIR_Protocol::sendHeadposeToGame(const double* headpose) {
float virtPosX;
float virtPosY;
@@ -112,7 +64,7 @@ void FTNoIR_Protocol::sendHeadposeToGame(const double* headpose) {
float headRotX;
float headRotY;
float headRotZ;
- headRotX = virtRotX = getRadsFromDegrees(headpose[Pitch]) * (useDummyExe ? 2.0 : 1.0);
+ headRotX = virtRotX = getRadsFromDegrees(headpose[Pitch]) * (s.useDummyExe ? 2.0 : 1.0);
headRotY = virtRotY = getRadsFromDegrees(headpose[Yaw]);
headRotZ = virtRotZ = getRadsFromDegrees(headpose[Roll]);
headPosX = virtPosX = headpose[TX] * 10;
@@ -149,13 +101,6 @@ void FTNoIR_Protocol::sendHeadposeToGame(const double* headpose) {
pMemData->data.Y3 = 0;
pMemData->data.Y4 = 0;
- //
- // Check if the handle that was sent to the Game, was changed (on x64, this will be done by the ED-API)
- // If the "Report Program Name" command arrives (which is a '1', for now), raise the event from here!
- //
- //
- // The game-ID was changed?
- //
if (intGameID != pMemData->GameID)
{
QString gamename;
@@ -167,8 +112,7 @@ void FTNoIR_Protocol::sendHeadposeToGame(const double* headpose) {
}
pMemData->data.DataID += 1;
-
- shm.unlock();
+ shm.unlock();
}
void FTNoIR_Protocol::start_tirviews() {
@@ -212,6 +156,10 @@ bool FTNoIR_Protocol::checkServerInstallationOK()
QSettings settingsTIR("NaturalPoint", "NATURALPOINT\\NPClient Location"); // Registry settings (in HK_USER)
QString aLocation; // Location of Client DLL
+
+ if (!shm.success())
+ return false;
+
qDebug() << "checkServerInstallationOK says: Starting Function";
//
@@ -219,8 +167,8 @@ bool FTNoIR_Protocol::checkServerInstallationOK()
//
aLocation = QCoreApplication::applicationDirPath() + "/";
- qDebug() << "checkServerInstallationOK says: used interface = " << intUsedInterface;
- switch (intUsedInterface) {
+ qDebug() << "checkServerInstallationOK says: used interface = " << s.intUsedInterface;
+ switch (s.intUsedInterface) {
case 0: // Use both interfaces
settings.setValue( "Path" , aLocation );
settingsTIR.setValue( "Path" , aLocation );
@@ -241,20 +189,17 @@ bool FTNoIR_Protocol::checkServerInstallationOK()
//
// TIRViews must be started first, or the NPClient DLL will never be loaded.
//
- if (useTIRViews) {
+ if (s.useTIRViews) {
start_tirviews();
}
//
// Check if TIRViews or dummy TrackIR.exe is required for this game
//
- if (useDummyExe) {
+ if (s.useDummyExe) {
start_dummy();
}
- if (!shm.success())
- return false;
-
pMemData->data.DataID = 1;
pMemData->data.CamWidth = 100;
pMemData->data.CamHeight = 250;
@@ -264,15 +209,6 @@ bool FTNoIR_Protocol::checkServerInstallationOK()
return true;
}
-////////////////////////////////////////////////////////////////////////////////
-// Factory function that creates instances if the Protocol object.
-
-// Export both decorated and undecorated names.
-// GetProtocol - Undecorated name, which can be easily used with GetProcAddress
-// Win32 API function.
-// _GetProtocol@0 - Common name decoration for __stdcall functions in C language.
-//#pragma comment(linker, "/export:GetProtocol=_GetProtocol@0")
-
extern "C" FTNOIR_PROTOCOL_BASE_EXPORT IProtocol* CALLING_CONVENTION GetConstructor()
{
return new FTNoIR_Protocol;
diff --git a/ftnoir_protocol_ft/ftnoir_protocol_ft.h b/ftnoir_protocol_ft/ftnoir_protocol_ft.h
index e13d260f..8f27b071 100644
--- a/ftnoir_protocol_ft/ftnoir_protocol_ft.h
+++ b/ftnoir_protocol_ft/ftnoir_protocol_ft.h
@@ -25,9 +25,6 @@
* to games, using the FreeTrackClient.dll. *
********************************************************************************/
#pragma once
-#ifndef INCLUDED_FTSERVER_H
-#define INCLUDED_FTSERVER_H
-
#include "ftnoir_protocol_base/ftnoir_protocol_base.h"
#include "ui_ftnoir_ftcontrols.h"
#include "facetracknoir/global-settings.h"
@@ -43,7 +40,20 @@
#include <QMutex>
#include <QMutexLocker>
#include "compat/compat.h"
-//#include "math.h"
+#include "facetracknoir/options.h"
+using namespace options;
+
+struct settings {
+ pbundle b;
+ value<int> intUsedInterface;
+ value<bool> useTIRViews, useDummyExe;
+ settings() :
+ b(bundle("proto-freetrack")),
+ intUsedInterface(b, "used-interfaces", 0),
+ useTIRViews(b, "use-memory-hacks", false),
+ useDummyExe(b, "ezca-mode", false)
+ {}
+};
//typedef char *(WINAPI *importProvider)(void);
typedef void (WINAPI *importTIRViewsStart)(void);
@@ -52,90 +62,59 @@ typedef void (WINAPI *importTIRViewsStop)(void);
class FTNoIR_Protocol : public IProtocol
{
public:
- FTNoIR_Protocol();
+ FTNoIR_Protocol();
virtual ~FTNoIR_Protocol();
- bool checkServerInstallationOK( );
+ bool checkServerInstallationOK( );
void sendHeadposeToGame( const double *headpose );
QString getGameName() {
QMutexLocker foo(&game_name_mutex);
return connected_game;
}
-
private:
- importTIRViewsStart viewsStart; // Functions inside TIRViews.dll
- importTIRViewsStop viewsStop;
+ importTIRViewsStart viewsStart; // Functions inside TIRViews.dll
+ importTIRViewsStop viewsStop;
- FTMemMap *pMemData;
+ FTMemMap *pMemData;
QString game_name;
PortableLockedShm shm;
- // Private properties
- QString ProgramName;
- QLibrary FTIRViewsLib;
- QProcess dummyTrackIR;
- int intGameID;
- int intUsedInterface; // Determine which interface to use (or to hide from the game)
- bool useTIRViews; // Needs to be in the Settings dialog
- bool useDummyExe;
- float getRadsFromDegrees ( float degrees ) { return (degrees * 0.017453f); }
- void loadSettings();
+ // Private properties
+ QString ProgramName;
+ QLibrary FTIRViewsLib;
+ QProcess dummyTrackIR;
+ static inline double getRadsFromDegrees ( double degrees )
+ {
+ return degrees * 0.017453;
+ }
+ int intGameID;
void start_tirviews();
void start_dummy();
-
QString connected_game;
QMutex game_name_mutex;
+ settings s;
};
-// Widget that has controls for FTNoIR protocol client-settings.
class FTControls: public QWidget, public IProtocolDialog
{
Q_OBJECT
public:
-
- explicit FTControls();
- virtual ~FTControls();
- void showEvent ( QShowEvent * event );
- void Initialize(QWidget *parent);
- void registerProtocol(IProtocol *protocol) {
- theProtocol = (FTNoIR_Protocol *) protocol; // Accept the pointer to the Protocol
- }
- void unRegisterProtocol() {
- theProtocol = NULL; // Reset the pointer
- }
-
+ explicit FTControls();
+ void registerProtocol(IProtocol *protocol) {}
+ void unRegisterProtocol() {}
private:
- Ui::UICFTControls ui;
- void loadSettings();
- void save();
-
- /** helper **/
- bool settingsDirty;
- FTNoIR_Protocol *theProtocol;
-
+ Ui::UICFTControls ui;
+ settings s;
private slots:
- void selectDLL();
- void doOK();
- void doCancel();
- void settingChanged() { settingsDirty = true; }
- void settingChanged(int) { settingsDirty = true; }
+ void selectDLL();
+ void doOK();
+ void doCancel();
};
-//*******************************************************************************************************
-// FaceTrackNoIR Protocol DLL. Functions used to get general info on the Protocol
-//*******************************************************************************************************
class FTNoIR_ProtocolDll : public Metadata
{
public:
- FTNoIR_ProtocolDll();
- ~FTNoIR_ProtocolDll();
-
- void getFullName(QString *strToBeFilled) { *strToBeFilled = QString("FreeTrack 2.0"); }
- void getShortName(QString *strToBeFilled) { *strToBeFilled = QString("FreeTrack 2.0"); }
- void getDescription(QString *strToBeFilled) { *strToBeFilled = QString("Enhanced FreeTrack protocol"); }
-
- void getIcon(QIcon *icon) { *icon = QIcon(":/images/freetrack.png"); }
+ void getFullName(QString *strToBeFilled) { *strToBeFilled = QString("FreeTrack 2.0"); }
+ void getShortName(QString *strToBeFilled) { *strToBeFilled = QString("FreeTrack 2.0"); }
+ void getDescription(QString *strToBeFilled) { *strToBeFilled = QString("Enhanced FreeTrack protocol"); }
+ void getIcon(QIcon *icon) { *icon = QIcon(":/images/freetrack.png"); }
};
-
-
-#endif//INCLUDED_FTSERVER_H
-//END
diff --git a/ftnoir_protocol_ft/ftnoir_protocol_ft_dialog.cpp b/ftnoir_protocol_ft/ftnoir_protocol_ft_dialog.cpp
index df13a6dc..b414561d 100644
--- a/ftnoir_protocol_ft/ftnoir_protocol_ft_dialog.cpp
+++ b/ftnoir_protocol_ft/ftnoir_protocol_ft_dialog.cpp
@@ -34,185 +34,87 @@
// Constructor for server-settings-dialog
//
FTControls::FTControls() :
-QWidget()
+ QWidget()
{
- QString aFileName; // File Path and Name
+ QString aFileName; // File Path and Name
- ui.setupUi( this );
+ ui.setupUi( this );
- // Connect Qt signals to member-functions
+ // Connect Qt signals to member-functions
connect(ui.buttonBox, SIGNAL(accepted()), this, SLOT(doOK()));
connect(ui.buttonBox, SIGNAL(rejected()), this, SLOT(doCancel()));
- connect(ui.bntLocateNPClient, SIGNAL(clicked()), this, SLOT(selectDLL()));
- connect(ui.chkTIRViews, SIGNAL(stateChanged(int)), this, SLOT(settingChanged()));
- connect(ui.chkStartDummy, SIGNAL(stateChanged(int)), this, SLOT(settingChanged()));
- connect(ui.cbxSelectInterface, SIGNAL(currentIndexChanged(int)), this, SLOT(settingChanged( int )));
-
- ui.cbxSelectInterface->addItem("Enable both");
- ui.cbxSelectInterface->addItem("Use FreeTrack, hide TrackIR");
- ui.cbxSelectInterface->addItem("Use TrackIR, hide FreeTrack");
-
- theProtocol = NULL;
-
- // Load the settings from the current .INI-file
- loadSettings();
-
-
- aFileName = QCoreApplication::applicationDirPath() + "/TIRViews.dll";
- if ( !QFile::exists( aFileName ) ) {
- ui.chkTIRViews->setChecked( false );
- ui.chkTIRViews->setEnabled ( false );
-
- //
- // Best do this save() last, or it will continually reset the settings... :-(
- //
- save();
- }
- else {
- ui.chkTIRViews->setEnabled ( true );
- }
-
-
-}
-
-//
-// Destructor for server-dialog
-//
-FTControls::~FTControls() {
- qDebug() << "~FTControls() says: started";
+ connect(ui.bntLocateNPClient, SIGNAL(clicked()), this, SLOT(selectDLL()));
+
+ tie_setting(s.intUsedInterface, ui.cbxSelectInterface);
+ tie_setting(s.useDummyExe, ui.chkStartDummy);
+ tie_setting(s.useTIRViews, ui.chkTIRViews);
+
+ ui.cbxSelectInterface->addItem("Enable both");
+ ui.cbxSelectInterface->addItem("Use FreeTrack, hide TrackIR");
+ ui.cbxSelectInterface->addItem("Use TrackIR, hide FreeTrack");
+
+ aFileName = QCoreApplication::applicationDirPath() + "/TIRViews.dll";
+ if ( !QFile::exists( aFileName ) ) {
+ ui.chkTIRViews->setChecked( false );
+ ui.chkTIRViews->setEnabled ( false );
+ }
+ else {
+ ui.chkTIRViews->setEnabled ( true );
+ }
}
-//
-// Initialize tracker-client-dialog
-//
-void FTControls::Initialize(QWidget *parent) {
-
- QPoint offsetpos(100, 100);
- if (parent) {
- this->move(parent->pos() + offsetpos);
- }
- show();
-}
-
-//
-// OK clicked on server-dialog
-//
void FTControls::doOK() {
- save();
- this->close();
-}
-
-// override show event
-void FTControls::showEvent ( QShowEvent * event ) {
- loadSettings();
+ s.b->save();
+ this->close();
}
-//
-// Cancel clicked on server-dialog
-//
void FTControls::doCancel() {
- //
- // Ask if changed Settings should be saved
- //
- if (settingsDirty) {
- int ret = QMessageBox::question ( this, "Settings have changed", "Do you want to save the settings?", QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel, QMessageBox::Discard );
-
- qDebug() << "doCancel says: answer =" << ret;
-
- switch (ret) {
- case QMessageBox::Save:
- save();
- this->close();
- break;
- case QMessageBox::Discard:
- this->close();
- break;
- case QMessageBox::Cancel:
- // Cancel was clicked
- break;
- default:
- // should never be reached
- break;
- }
- }
- else {
- this->close();
- }
-}
-
-//
-// Load the current Settings from the currently 'active' INI-file.
-//
-void FTControls::loadSettings() {
- qDebug() << "loadSettings says: Starting ";
- QSettings settings("opentrack"); // Registry settings (in HK_USER)
-
- QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString();
- QSettings iniFile( currentFile, QSettings::IniFormat ); // Application settings (in INI-file)
-
- qDebug() << "loadSettings says: iniFile = " << currentFile;
-
- iniFile.beginGroup ( "FT" );
- ui.cbxSelectInterface->setCurrentIndex( iniFile.value ( "UsedInterface", 0 ).toInt() );
- iniFile.endGroup ();
-
- iniFile.beginGroup ( "FTIR" );
- ui.chkTIRViews->setChecked (iniFile.value ( "useTIRViews", 0 ).toBool());
- ui.chkStartDummy->setChecked (iniFile.value ( "useDummyExe", 0 ).toBool());
- iniFile.endGroup ();
-
- settingsDirty = false;
+ //
+ // Ask if changed Settings should be saved
+ //
+ if (s.b->modifiedp()) {
+ int ret = QMessageBox::question ( this, "Settings have changed", "Do you want to save the settings?", QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel);
+
+ qDebug() << "doCancel says: answer =" << ret;
+
+ switch (ret) {
+ case QMessageBox::Save:
+ s.b->save();
+ this->close();
+ break;
+ case QMessageBox::Discard:
+ s.b->revert();
+ this->close();
+ break;
+ case QMessageBox::Cancel:
+ // Cancel was clicked
+ break;
+ default:
+ // should never be reached
+ break;
+ }
+ }
+ else {
+ this->close();
+ }
}
-//
-// Save the current Settings to the currently 'active' INI-file.
-//
-void FTControls::save() {
- QSettings settings("opentrack"); // Registry settings (in HK_USER)
-
- QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString();
- QSettings iniFile( currentFile, QSettings::IniFormat ); // Application settings (in INI-file)
-
- iniFile.beginGroup ( "FT" );
- iniFile.setValue ( "UsedInterface", ui.cbxSelectInterface->currentIndex());
- iniFile.endGroup ();
-
- iniFile.beginGroup ( "FTIR" );
- iniFile.setValue ( "useTIRViews", ui.chkTIRViews->isChecked() );
- iniFile.setValue ( "useDummyExe", ui.chkStartDummy->isChecked() );
- iniFile.endGroup ();
-
- settingsDirty = false;
-}
-
-//
-// Select a NPClient.dll file, to repair the Location in the Registry.
-// Several program distribute their own version of this file.
-//
void FTControls::selectDLL() {
QString fileName = QFileDialog::getOpenFileName( this, tr("Select the desired NPClient DLL"), QCoreApplication::applicationDirPath() + "/NPClient.dll", tr("Dll file (*.dll);;All Files (*)"));
- //
- // Write the location of the file in the required Registry-key.
- //
- if (! fileName.isEmpty() ) {
- if (fileName.endsWith("NPClient.dll", Qt::CaseInsensitive) ) {
- QSettings settingsTIR("NaturalPoint", "NATURALPOINT\\NPClient Location"); // Registry settings (in HK_USER)
- QString aLocation = fileName.left(fileName.length() - 12); // Location of Client DLL
-
- settingsTIR.setValue( "Path" , aLocation );
- }
- }
+ //
+ // Write the location of the file in the required Registry-key.
+ //
+ if (! fileName.isEmpty() ) {
+ if (fileName.endsWith("NPClient.dll", Qt::CaseInsensitive) ) {
+ QSettings settingsTIR("NaturalPoint", "NATURALPOINT\\NPClient Location"); // Registry settings (in HK_USER)
+ QString aLocation = fileName.left(fileName.length() - 12); // Location of Client DLL
+
+ settingsTIR.setValue( "Path" , aLocation );
+ }
+ }
}
-
-////////////////////////////////////////////////////////////////////////////////
-// Factory function that creates instances if the Protocol-settings dialog object.
-
-// Export both decorated and undecorated names.
-// GetProtocolDialog - Undecorated name, which can be easily used with GetProcAddress
-// Win32 API function.
-// _GetProtocolDialog@0 - Common name decoration for __stdcall functions in C language.
extern "C" FTNOIR_PROTOCOL_BASE_EXPORT IProtocolDialog* CALLING_CONVENTION GetDialog( )
{
return new FTControls;
diff --git a/ftnoir_protocol_ft/ftnoir_protocol_ft_dll.cpp b/ftnoir_protocol_ft/ftnoir_protocol_ft_dll.cpp
index f4e4a40e..38f11211 100644
--- a/ftnoir_protocol_ft/ftnoir_protocol_ft_dll.cpp
+++ b/ftnoir_protocol_ft/ftnoir_protocol_ft_dll.cpp
@@ -23,24 +23,8 @@
* *
********************************************************************************/
#include "ftnoir_protocol_ft.h"
-#include <QDebug>
-FTNoIR_ProtocolDll::FTNoIR_ProtocolDll() {
-}
-
-FTNoIR_ProtocolDll::~FTNoIR_ProtocolDll()
-{
-
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// Factory function that creates instances if the Protocol object.
-
-// Export both decorated and undecorated names.
-// GetProtocolDll - Undecorated name, which can be easily used with GetProcAddress
-// Win32 API function.
-// _GetProtocolDll@0 - Common name decoration for __stdcall functions in C language.
extern "C" FTNOIR_PROTOCOL_BASE_EXPORT Metadata* CALLING_CONVENTION GetMetadata()
{
return new FTNoIR_ProtocolDll;
-} \ No newline at end of file
+}
diff --git a/ftnoir_protocol_ftn/ftnoir_protocol_ftn.cpp b/ftnoir_protocol_ftn/ftnoir_protocol_ftn.cpp
index 80cbfa0a..e93a751e 100644
--- a/ftnoir_protocol_ftn/ftnoir_protocol_ftn.cpp
+++ b/ftnoir_protocol_ftn/ftnoir_protocol_ftn.cpp
@@ -32,86 +32,23 @@
/** constructor **/
FTNoIR_Protocol::FTNoIR_Protocol()
{
- loadSettings();
- outSocket = 0;
}
-/** destructor **/
-FTNoIR_Protocol::~FTNoIR_Protocol()
-{
- if (outSocket != 0) {
- outSocket->close();
- delete outSocket;
- }
-}
-
-//
-// Load the current Settings from the currently 'active' INI-file.
-//
-void FTNoIR_Protocol::loadSettings() {
- QSettings settings("opentrack"); // Registry settings (in HK_USER)
-
- QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString();
- QSettings iniFile( currentFile, QSettings::IniFormat ); // Application settings (in INI-file)
-
- iniFile.beginGroup ( "FTN" );
-
- QString destAddr = iniFile.value ( "IP-1", 192 ).toString() + "." + iniFile.value ( "IP-2", 168 ).toString() + "." + iniFile.value ( "IP-3", 2 ).toString() + "." + iniFile.value ( "IP-4", 1 ).toString();
- destIP = QHostAddress( destAddr );
- destPort = iniFile.value ( "PortNumber", 5550 ).toInt();
-
- iniFile.endGroup ();
-}
-
-//
-// Update Headpose in Game.
-//
void FTNoIR_Protocol::sendHeadposeToGame(const double *headpose) {
- int no_bytes;
- double test_data[6];
- //
- // Copy the Raw measurements directly to the client.
- //
- for (int i = 0; i < 6; i++)
- test_data[i] = headpose[i];
- //
- // Try to send an UDP-message to the receiver
- //
-
- //! [1]
- if (outSocket != 0) {
- no_bytes = outSocket->writeDatagram((const char *) test_data, sizeof( test_data ), destIP, destPort);
- if ( no_bytes > 0) {
-// qDebug() << "FTNServer::writePendingDatagrams says: bytes send =" << no_bytes << sizeof( double );
- }
- else {
- qDebug() << "FTNServer::writePendingDatagrams says: nothing sent!";
- }
- }
+ int destPort = s.port;
+ QHostAddress destIP(QString("%1.%2.%3.%4").arg(
+ QString::number(static_cast<int>(s.ip1)),
+ QString::number(static_cast<int>(s.ip2)),
+ QString::number(static_cast<int>(s.ip3)),
+ QString::number(static_cast<int>(s.ip4))));
+ outSocket.writeDatagram((const char *) headpose, sizeof( double[6] ), destIP, destPort);
}
-//
-// Check if the Client DLL exists and load it (to test it), if so.
-// Returns 'true' if all seems OK.
-//
bool FTNoIR_Protocol::checkServerInstallationOK()
{
- if (outSocket == 0) {
- outSocket = new QUdpSocket();
- }
-
- return true;
+ return outSocket.bind(QHostAddress::Any, 0, QUdpSocket::ShareAddress | QUdpSocket::ReuseAddressHint);
}
-////////////////////////////////////////////////////////////////////////////////
-// Factory function that creates instances if the Protocol object.
-
-// Export both decorated and undecorated names.
-// GetProtocol - Undecorated name, which can be easily used with GetProcAddress
-// Win32 API function.
-// _GetProtocol@0 - Common name decoration for __stdcall functions in C language.
-//#pragma comment(linker, "/export:GetProtocol=_GetProtocol@0")
-
extern "C" FTNOIR_PROTOCOL_BASE_EXPORT IProtocol* CALLING_CONVENTION GetConstructor()
{
return new FTNoIR_Protocol;
diff --git a/ftnoir_protocol_ftn/ftnoir_protocol_ftn.h b/ftnoir_protocol_ftn/ftnoir_protocol_ftn.h
index 9aee73ac..99e6c6a1 100644
--- a/ftnoir_protocol_ftn/ftnoir_protocol_ftn.h
+++ b/ftnoir_protocol_ftn/ftnoir_protocol_ftn.h
@@ -26,8 +26,6 @@
* It is based on the (Linux) example made by Melchior FRANZ. *
********************************************************************************/
#pragma once
-#ifndef INCLUDED_FTNSERVER_H
-#define INCLUDED_FTNSERVER_H
#include "ftnoir_protocol_base/ftnoir_protocol_base.h"
#include "ftnoir_tracker_base/ftnoir_tracker_base.h"
@@ -35,26 +33,36 @@
#include <QThread>
#include <QUdpSocket>
#include <QMessageBox>
-#include <QSettings>
#include <math.h>
#include "facetracknoir/global-settings.h"
+#include "facetracknoir/options.h"
+using namespace options;
+
+struct settings {
+ pbundle b;
+ value<int> ip1, ip2, ip3, ip4, port;
+ settings() :
+ b(bundle("udp-proto")),
+ ip1(b, "ip1", 192),
+ ip2(b, "ip2", 168),
+ ip3(b, "ip3", 0),
+ ip4(b, "ip4", 2),
+ port(b, "port", 4242)
+ {}
+};
class FTNoIR_Protocol : public IProtocol
{
public:
FTNoIR_Protocol();
- virtual ~FTNoIR_Protocol();
bool checkServerInstallationOK();
void sendHeadposeToGame(const double *headpose);
QString getGameName() {
return "UDP Tracker";
}
-
private:
- QUdpSocket *outSocket; // Send to FaceTrackNoIR
- QHostAddress destIP; // Destination IP-address
- int destPort; // Destination port-number
- void loadSettings();
+ QUdpSocket outSocket;
+ settings s;
};
// Widget that has controls for FTNoIR protocol client-settings.
@@ -62,43 +70,23 @@ class FTNControls: public QWidget, public IProtocolDialog
{
Q_OBJECT
public:
-
- explicit FTNControls();
- virtual ~FTNControls();
- void showEvent (QShowEvent *);
- void Initialize(QWidget *parent);
+ FTNControls();
void registerProtocol(IProtocol *) {}
void unRegisterProtocol() {}
-
private:
Ui::UICFTNControls ui;
- void loadSettings();
- void save();
-
- /** helper **/
- bool settingsDirty;
-
+ settings s;
private slots:
void doOK();
void doCancel();
- void settingChanged() { settingsDirty = true; }
};
-//*******************************************************************************************************
-// FaceTrackNoIR Protocol DLL. Functions used to get general info on the Protocol
-//*******************************************************************************************************
class FTNoIR_ProtocolDll : public Metadata
{
public:
- FTNoIR_ProtocolDll();
- ~FTNoIR_ProtocolDll();
-
void getFullName(QString *strToBeFilled) { *strToBeFilled = QString("UDP"); }
void getShortName(QString *strToBeFilled) { *strToBeFilled = QString("UDP"); }
void getDescription(QString *strToBeFilled) { *strToBeFilled = QString("opentrack UDP protocol"); }
void getIcon(QIcon *icon) { *icon = QIcon(":/images/facetracknoir.png"); }
};
-
-#endif//INCLUDED_FTNSERVER_H
-//END
diff --git a/ftnoir_protocol_ftn/ftnoir_protocol_ftn_dialog.cpp b/ftnoir_protocol_ftn/ftnoir_protocol_ftn_dialog.cpp
index 3b4e851c..ce4b3cb0 100644
--- a/ftnoir_protocol_ftn/ftnoir_protocol_ftn_dialog.cpp
+++ b/ftnoir_protocol_ftn/ftnoir_protocol_ftn_dialog.cpp
@@ -23,96 +23,48 @@
* *
********************************************************************************/
#include "ftnoir_protocol_ftn.h"
-#include <QDebug>
#include "facetracknoir/global-settings.h"
-//*******************************************************************************************************
-// FaceTrackNoIR Client Settings-dialog.
-//*******************************************************************************************************
-
-//
-// Constructor for server-settings-dialog
-//
FTNControls::FTNControls() :
-QWidget()
+ QWidget()
{
- ui.setupUi( this );
-
- QPoint offsetpos(100, 100);
- //if (parent) {
- // this->move(parent->pos() + offsetpos);
- //}
-
- // Connect Qt signals to member-functions
- connect(ui.btnOK, SIGNAL(clicked()), this, SLOT(doOK()));
- connect(ui.btnCancel, SIGNAL(clicked()), this, SLOT(doCancel()));
- connect(ui.spinIPFirstNibble, SIGNAL(valueChanged(int)), this, SLOT(settingChanged()));
- connect(ui.spinIPSecondNibble, SIGNAL(valueChanged(int)), this, SLOT(settingChanged()));
- connect(ui.spinIPThirdNibble, SIGNAL(valueChanged(int)), this, SLOT(settingChanged()));
- connect(ui.spinIPFourthNibble, SIGNAL(valueChanged(int)), this, SLOT(settingChanged()));
- connect(ui.spinPortNumber, SIGNAL(valueChanged(int)), this, SLOT(settingChanged()));
+ ui.setupUi( this );
- // Load the settings from the current .INI-file
- loadSettings();
-}
+ tie_setting(s.ip1, ui.spinIPFirstNibble);
+ tie_setting(s.ip2, ui.spinIPSecondNibble);
+ tie_setting(s.ip3, ui.spinIPThirdNibble);
+ tie_setting(s.ip4, ui.spinIPFourthNibble);
+ tie_setting(s.port, ui.spinPortNumber);
-//
-// Destructor for server-dialog
-//
-FTNControls::~FTNControls() {
- qDebug() << "~FTNControls() says: started";
-}
-
-//
-// Initialize tracker-client-dialog
-//
-void FTNControls::Initialize(QWidget *parent) {
-
- QPoint offsetpos(100, 100);
- if (parent) {
- this->move(parent->pos() + offsetpos);
- }
- show();
+ connect(ui.btnOK, SIGNAL(clicked()), this, SLOT(doOK()));
+ connect(ui.btnCancel, SIGNAL(clicked()), this, SLOT(doCancel()));
}
//
// OK clicked on server-dialog
//
void FTNControls::doOK() {
- save();
+ s.b->save();
this->close();
}
-// override show event
-void FTNControls::showEvent ( QShowEvent * ) {
- loadSettings();
-}
-
//
// Cancel clicked on server-dialog
//
void FTNControls::doCancel() {
- //
- // Ask if changed Settings should be saved
- //
- if (settingsDirty) {
- int ret = QMessageBox::question ( this, "Settings have changed", "Do you want to save the settings?", QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel, QMessageBox::Discard );
-
- qDebug() << "doCancel says: answer =" << ret;
-
+ if (s.b->modifiedp()) {
+ int ret = QMessageBox::question ( this, "Settings have changed", "Do you want to save the settings?", QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel);
switch (ret) {
case QMessageBox::Save:
- save();
+ s.b->save();
this->close();
break;
case QMessageBox::Discard:
+ s.b->revert();
this->close();
break;
case QMessageBox::Cancel:
- // Cancel was clicked
- break;
default:
- // should never be reached
break;
}
}
@@ -121,59 +73,6 @@ void FTNControls::doCancel() {
}
}
-//
-// Load the current Settings from the currently 'active' INI-file.
-//
-void FTNControls::loadSettings() {
-// qDebug() << "loadSettings says: Starting ";
- QSettings settings("opentrack"); // Registry settings (in HK_USER)
-
- QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString();
- QSettings iniFile( currentFile, QSettings::IniFormat ); // Application settings (in INI-file)
-
-// qDebug() << "loadSettings says: iniFile = " << currentFile;
-
- iniFile.beginGroup ( "FTN" );
- ui.spinIPFirstNibble->setValue( iniFile.value ( "IP-1", 192 ).toInt() );
- ui.spinIPSecondNibble->setValue( iniFile.value ( "IP-2", 168 ).toInt() );
- ui.spinIPThirdNibble->setValue( iniFile.value ( "IP-3", 2 ).toInt() );
- ui.spinIPFourthNibble->setValue( iniFile.value ( "IP-4", 1 ).toInt() );
-
- ui.spinPortNumber->setValue( iniFile.value ( "PortNumber", 5550 ).toInt() );
- iniFile.endGroup ();
-
- settingsDirty = false;
-}
-
-//
-// Save the current Settings to the currently 'active' INI-file.
-//
-void FTNControls::save() {
- QSettings settings("opentrack"); // Registry settings (in HK_USER)
-
- QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString();
- QSettings iniFile( currentFile, QSettings::IniFormat ); // Application settings (in INI-file)
-
- iniFile.beginGroup ( "FTN" );
- iniFile.setValue ( "IP-1", ui.spinIPFirstNibble->value() );
- iniFile.setValue ( "IP-2", ui.spinIPSecondNibble->value() );
- iniFile.setValue ( "IP-3", ui.spinIPThirdNibble->value() );
- iniFile.setValue ( "IP-4", ui.spinIPFourthNibble->value() );
- iniFile.setValue ( "PortNumber", ui.spinPortNumber->value() );
- iniFile.endGroup ();
-
- settingsDirty = false;
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// Factory function that creates instances if the Protocol-settings dialog object.
-
-// Export both decorated and undecorated names.
-// GetProtocolDialog - Undecorated name, which can be easily used with GetProcAddress
-// Win32 API function.
-// _GetProtocolDialog@0 - Common name decoration for __stdcall functions in C language.
-//#pragma comment(linker, "/export:GetProtocolDialog=_GetProtocolDialog@0")
-
extern "C" FTNOIR_PROTOCOL_BASE_EXPORT IProtocolDialog* CALLING_CONVENTION GetDialog( )
{
return new FTNControls;
diff --git a/ftnoir_protocol_ftn/ftnoir_protocol_ftn_dll.cpp b/ftnoir_protocol_ftn/ftnoir_protocol_ftn_dll.cpp
index acd3b990..99689432 100644
--- a/ftnoir_protocol_ftn/ftnoir_protocol_ftn_dll.cpp
+++ b/ftnoir_protocol_ftn/ftnoir_protocol_ftn_dll.cpp
@@ -23,26 +23,8 @@
* *
********************************************************************************/
#include "ftnoir_protocol_ftn.h"
-#include <QDebug>
#include "facetracknoir/global-settings.h"
-FTNoIR_ProtocolDll::FTNoIR_ProtocolDll() {
-}
-
-FTNoIR_ProtocolDll::~FTNoIR_ProtocolDll()
-{
-
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// Factory function that creates instances if the Protocol object.
-
-// Export both decorated and undecorated names.
-// GetProtocolDll - Undecorated name, which can be easily used with GetProcAddress
-// Win32 API function.
-// _GetProtocolDll@0 - Common name decoration for __stdcall functions in C language.
-//#pragma comment(linker, "/export:GetProtocolDll=_GetProtocolDll@0")
-
extern "C" FTNOIR_PROTOCOL_BASE_EXPORT Metadata* CALLING_CONVENTION GetMetadata()
{
return new FTNoIR_ProtocolDll;
diff --git a/ftnoir_protocol_libevdev/ftnoir_protocol_libevdev.h b/ftnoir_protocol_libevdev/ftnoir_protocol_libevdev.h
index aabd3e51..f92bb7bb 100644
--- a/ftnoir_protocol_libevdev/ftnoir_protocol_libevdev.h
+++ b/ftnoir_protocol_libevdev/ftnoir_protocol_libevdev.h
@@ -9,7 +9,6 @@
#include "ui_ftnoir_libevdev_controls.h"
#include <QMessageBox>
-#include <QSettings>
#include "facetracknoir/global-settings.h"
extern "C" {
@@ -41,10 +40,6 @@ class LibevdevControls: public QWidget, public IProtocolDialog
public:
explicit LibevdevControls();
- virtual ~LibevdevControls();
- void showEvent ( QShowEvent *) {}
-
- void Initialize(QWidget *);
void registerProtocol(IProtocol *) {}
void unRegisterProtocol() {}
diff --git a/ftnoir_protocol_libevdev/ftnoir_protocol_libevdev_dialog.cpp b/ftnoir_protocol_libevdev/ftnoir_protocol_libevdev_dialog.cpp
index 6665a3d2..bb54c354 100644
--- a/ftnoir_protocol_libevdev/ftnoir_protocol_libevdev_dialog.cpp
+++ b/ftnoir_protocol_libevdev/ftnoir_protocol_libevdev_dialog.cpp
@@ -8,21 +8,6 @@ LibevdevControls::LibevdevControls() : QWidget()
connect(ui.btnCancel, SIGNAL(clicked()), this, SLOT(doCancel()));
}
-LibevdevControls::~LibevdevControls() {
-}
-
-//
-// Initialize tracker-client-dialog
-//
-void LibevdevControls::Initialize(QWidget *parent) {
-
- QPoint offsetpos(100, 100);
- if (parent) {
- this->move(parent->pos() + offsetpos);
- }
- show();
-}
-
void LibevdevControls::doOK() {
save();
this->close();
diff --git a/ftnoir_protocol_mouse/ftnoir_protocol_mouse.cpp b/ftnoir_protocol_mouse/ftnoir_protocol_mouse.cpp
index 64e010a8..cc8aa11e 100644
--- a/ftnoir_protocol_mouse/ftnoir_protocol_mouse.cpp
+++ b/ftnoir_protocol_mouse/ftnoir_protocol_mouse.cpp
@@ -29,38 +29,12 @@
#include "ftnoir_protocol_mouse.h"
#include "facetracknoir/global-settings.h"
-/** constructor **/
-FTNoIR_Protocol::FTNoIR_Protocol()
-{
- loadSettings();
-}
-
-/** destructor **/
-FTNoIR_Protocol::~FTNoIR_Protocol()
-{
-}
-
-//
-// Load the current Settings from the currently 'active' INI-file.
-//
-void FTNoIR_Protocol::loadSettings() {
- QSettings settings("opentrack"); // Registry settings (in HK_USER)
-
- QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString();
- QSettings iniFile( currentFile, QSettings::IniFormat ); // Application settings (in INI-file)
-
- iniFile.beginGroup ( "Mouse" );
- Mouse_X = (FTN_AngleName) (iniFile.value ( "Mouse_X", 0 ).toInt());
- Mouse_Y = (FTN_AngleName) (iniFile.value ( "Mouse_Y", 0 ).toInt());
- iniFile.endGroup ();
-}
-
-//
-// Update Headpose in Game.
-//
void FTNoIR_Protocol::sendHeadposeToGame(const double *headpose ) {
- float fMouse_X = 0;
- float fMouse_Y = 0;
+ double fMouse_X = 0;
+ double fMouse_Y = 0;
+
+ int Mouse_X = s.Mouse_X;
+ int Mouse_Y = s.Mouse_Y;
if (Mouse_X > 0 && Mouse_X <= 6)
fMouse_X = headpose[Mouse_X-1] / (Mouse_X < 3 ? 100 : 180);
@@ -77,24 +51,16 @@ void FTNoIR_Protocol::sendHeadposeToGame(const double *headpose ) {
}
}
-//
-// Returns 'true' if all seems OK.
-//
+void FTNoIR_Protocol::reload()
+{
+ s.b->reload();
+}
+
bool FTNoIR_Protocol::checkServerInstallationOK()
{
-
- return true;
+ return true;
}
-////////////////////////////////////////////////////////////////////////////////
-// Factory function that creates instances if the Protocol object.
-
-// Export both decorated and undecorated names.
-// GetProtocol - Undecorated name, which can be easily used with GetProcAddress
-// Win32 API function.
-// _GetProtocol@0 - Common name decoration for __stdcall functions in C language.
-//#pragma comment(linker, "/export:GetProtocol=_GetProtocol@0")
-
extern "C" FTNOIR_PROTOCOL_BASE_EXPORT IProtocol* CALLING_CONVENTION GetConstructor()
{
return new FTNoIR_Protocol;
diff --git a/ftnoir_protocol_mouse/ftnoir_protocol_mouse.h b/ftnoir_protocol_mouse/ftnoir_protocol_mouse.h
index 1ce72f69..01f283d3 100644
--- a/ftnoir_protocol_mouse/ftnoir_protocol_mouse.h
+++ b/ftnoir_protocol_mouse/ftnoir_protocol_mouse.h
@@ -41,37 +41,34 @@
#include <windows.h>
#include <winuser.h>
#include "facetracknoir/global-settings.h"
+#include "facetracknoir/options.h"
+using namespace options;
+
+struct settings {
+ pbundle b;
+ value<int> Mouse_X, Mouse_Y;
+ settings() :
+ b(bundle("mouse-proto")),
+ Mouse_X(b, "mouse-x", 0),
+ Mouse_Y(b, "mouse-y", 0)
+ {}
+};
#define MOUSE_AXIS_MIN 0
#define MOUSE_AXIS_MAX 65535
-enum FTN_AngleName {
- FTN_YAW = Yaw,
- FTN_PITCH = Pitch,
- FTN_ROLL = Roll,
- FTN_X = TX,
- FTN_Y = TY,
- FTN_Z = TZ
-};
-
class FTNoIR_Protocol : public IProtocol
{
public:
- FTNoIR_Protocol();
- virtual ~FTNoIR_Protocol();
+ FTNoIR_Protocol() {}
bool checkServerInstallationOK();
void sendHeadposeToGame( const double *headpose);
QString getGameName() {
return "Mouse tracker";
}
+ void reload();
private:
- HANDLE h;
- INPUT MouseStruct;
-
- FTN_AngleName Mouse_X; // Map one of the 6DOF's to this Mouse direction
- FTN_AngleName Mouse_Y;
- FTN_AngleName Mouse_Wheel;
- void loadSettings();
+ struct settings s;
};
// Widget that has controls for FTNoIR protocol client-settings.
@@ -79,31 +76,20 @@ class MOUSEControls: public QWidget, public IProtocolDialog
{
Q_OBJECT
public:
-
- explicit MOUSEControls();
- virtual ~MOUSEControls();
- void showEvent ( QShowEvent * event );
- void Initialize(QWidget *parent);
- void registerProtocol(IProtocol *protocol) {
- theProtocol = (FTNoIR_Protocol *) protocol; // Accept the pointer to the Protocol
- }
- void unRegisterProtocol() {
- theProtocol = NULL; // Reset the pointer
- }
-
+ MOUSEControls();
+ void registerProtocol(IProtocol *protocol) {
+ _proto = (FTNoIR_Protocol *) protocol;
+ }
+ void unRegisterProtocol() {
+ _proto = NULL;
+ }
private:
- Ui::UICMOUSEControls ui;
- void loadSettings();
- void save();
-
- /** helper **/
- bool settingsDirty;
- FTNoIR_Protocol *theProtocol;
-
+ Ui::UICMOUSEControls ui;
+ settings s;
+ FTNoIR_Protocol* _proto;
private slots:
- void doOK();
- void doCancel();
- void settingChanged( int setting ) { settingsDirty = true; }
+ void doOK();
+ void doCancel();
};
//*******************************************************************************************************
@@ -112,13 +98,9 @@ private slots:
class FTNoIR_ProtocolDll : public Metadata
{
public:
- FTNoIR_ProtocolDll();
- ~FTNoIR_ProtocolDll();
-
- void getFullName(QString *strToBeFilled) { *strToBeFilled = QString("Mouse Look"); }
- void getShortName(QString *strToBeFilled) { *strToBeFilled = QString("Mouse Look"); }
- void getDescription(QString *strToBeFilled) { *strToBeFilled = QString("Mouse Look protocol"); }
-
+ void getFullName(QString *strToBeFilled) { *strToBeFilled = QString("Mouse Look"); }
+ void getShortName(QString *strToBeFilled) { *strToBeFilled = QString("Mouse Look"); }
+ void getDescription(QString *strToBeFilled) { *strToBeFilled = QString("Mouse Look protocol"); }
void getIcon(QIcon *icon) { *icon = QIcon(":/images/mouse.png"); }
};
diff --git a/ftnoir_protocol_mouse/ftnoir_protocol_mouse_dialog.cpp b/ftnoir_protocol_mouse/ftnoir_protocol_mouse_dialog.cpp
index c8d62a58..cc62b004 100644
--- a/ftnoir_protocol_mouse/ftnoir_protocol_mouse_dialog.cpp
+++ b/ftnoir_protocol_mouse/ftnoir_protocol_mouse_dialog.cpp
@@ -23,158 +23,68 @@
* *
********************************************************************************/
#include "ftnoir_protocol_mouse.h"
-#include <QDebug>
#include "facetracknoir/global-settings.h"
-//*******************************************************************************************************
-// FaceTrackNoIR Client Settings-dialog.
-//*******************************************************************************************************
-
-//
-// Constructor for server-settings-dialog
-//
-MOUSEControls::MOUSEControls() :
-QWidget()
+MOUSEControls::MOUSEControls() : _proto(nullptr)
{
- ui.setupUi( this );
- ui.cbxSelectMouse_X->addItem("None");
+ ui.setupUi( this );
+ ui.cbxSelectMouse_X->addItem("None");
ui.cbxSelectMouse_X->addItem("X");
- ui.cbxSelectMouse_X->addItem("Y");
- ui.cbxSelectMouse_X->addItem("Z");
- ui.cbxSelectMouse_X->addItem("Yaw");
+ ui.cbxSelectMouse_X->addItem("Y");
+ ui.cbxSelectMouse_X->addItem("Z");
+ ui.cbxSelectMouse_X->addItem("Yaw");
ui.cbxSelectMouse_X->addItem("Pitch");
- ui.cbxSelectMouse_X->addItem("Roll");
+ ui.cbxSelectMouse_X->addItem("Roll");
- ui.cbxSelectMouse_Y->addItem("None");
- ui.cbxSelectMouse_Y->addItem("X");
- ui.cbxSelectMouse_Y->addItem("Y");
- ui.cbxSelectMouse_Y->addItem("Z");
+ ui.cbxSelectMouse_Y->addItem("None");
+ ui.cbxSelectMouse_Y->addItem("X");
+ ui.cbxSelectMouse_Y->addItem("Y");
+ ui.cbxSelectMouse_Y->addItem("Z");
ui.cbxSelectMouse_Y->addItem("Yaw");
- ui.cbxSelectMouse_Y->addItem("Pitch");
- ui.cbxSelectMouse_Y->addItem("Roll");
- // Connect Qt signals to member-functions
- connect(ui.btnOK, SIGNAL(clicked()), this, SLOT(doOK()));
- connect(ui.btnCancel, SIGNAL(clicked()), this, SLOT(doCancel()));
- connect(ui.cbxSelectMouse_X, SIGNAL(currentIndexChanged(int)), this, SLOT(settingChanged( int )));
- connect(ui.cbxSelectMouse_Y, SIGNAL(currentIndexChanged(int)), this, SLOT(settingChanged( int )));
- theProtocol = NULL;
- // Load the settings from the current .INI-file
- loadSettings();
-}
-
-//
-// Destructor for server-dialog
-//
-MOUSEControls::~MOUSEControls() {
- qDebug() << "~MOUSEControls() says: started";
-}
+ ui.cbxSelectMouse_Y->addItem("Pitch");
+ ui.cbxSelectMouse_Y->addItem("Roll");
-//
-// Initialize tracker-client-dialog
-//
-void MOUSEControls::Initialize(QWidget *parent) {
+ connect(ui.btnOK, SIGNAL(clicked()), this, SLOT(doOK()));
+ connect(ui.btnCancel, SIGNAL(clicked()), this, SLOT(doCancel()));
- QPoint offsetpos(100, 100);
- if (parent) {
- this->move(parent->pos() + offsetpos);
- }
- show();
+ tie_setting(s.Mouse_X, ui.cbxSelectMouse_X);
+ tie_setting(s.Mouse_Y, ui.cbxSelectMouse_Y);
}
-//
-// OK clicked on server-dialog
-//
void MOUSEControls::doOK() {
- save();
- this->close();
-}
-
-// override show event
-void MOUSEControls::showEvent ( QShowEvent * event ) {
- loadSettings();
+ s.b->save();
+ if (_proto)
+ _proto->reload();
+ this->close();
}
-//
-// Cancel clicked on server-dialog
-//
void MOUSEControls::doCancel() {
- //
- // Ask if changed Settings should be saved
- //
- if (settingsDirty) {
- int ret = QMessageBox::question ( this, "Settings have changed", "Do you want to save the settings?", QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel, QMessageBox::Discard );
-
- qDebug() << "doCancel says: answer =" << ret;
-
- switch (ret) {
- case QMessageBox::Save:
- save();
- this->close();
- break;
- case QMessageBox::Discard:
- this->close();
- break;
- case QMessageBox::Cancel:
- // Cancel was clicked
- break;
- default:
- // should never be reached
- break;
- }
- }
- else {
- this->close();
- }
-}
-
-//
-// Load the current Settings from the currently 'active' INI-file.
-//
-void MOUSEControls::loadSettings() {
- qDebug() << "loadSettings says: Starting ";
- QSettings settings("opentrack"); // Registry settings (in HK_USER)
-
- QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString();
- QSettings iniFile( currentFile, QSettings::IniFormat ); // Application settings (in INI-file)
-
- qDebug() << "loadSettings says: iniFile = " << currentFile;
-
- iniFile.beginGroup ( "Mouse" );
- ui.cbxSelectMouse_X->setCurrentIndex(iniFile.value ( "Mouse_X", 0 ).toInt() );
- ui.cbxSelectMouse_Y->setCurrentIndex(iniFile.value ( "Mouse_Y", 0 ).toInt() );
- iniFile.endGroup ();
-
- settingsDirty = false;
+ if (s.b->modifiedp()) {
+ int ret = QMessageBox::question ( this, "Settings have changed", "Do you want to save the settings?", QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel);
+
+ qDebug() << "doCancel says: answer =" << ret;
+
+ switch (ret) {
+ case QMessageBox::Save:
+ s.b->save();
+ this->close();
+ if (_proto)
+ _proto->reload();
+ break;
+ case QMessageBox::Discard:
+ s.b->revert();
+ this->close();
+ break;
+ case QMessageBox::Cancel:
+ default:
+ break;
+ }
+ }
+ else {
+ this->close();
+ }
}
-//
-// Save the current Settings to the currently 'active' INI-file.
-//
-void MOUSEControls::save() {
- qDebug() << "save() says: started";
-
- QSettings settings("opentrack"); // Registry settings (in HK_USER)
-
- QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString();
- QSettings iniFile( currentFile, QSettings::IniFormat ); // Application settings (in INI-file)
-
- iniFile.beginGroup ( "Mouse" );
- iniFile.setValue ( "Mouse_X", ui.cbxSelectMouse_X->currentIndex() );
- iniFile.setValue ( "Mouse_Y", ui.cbxSelectMouse_Y->currentIndex() );
- iniFile.endGroup ();
-
- settingsDirty = false;
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// Factory function that creates instances if the Protocol-settings dialog object.
-
-// Export both decorated and undecorated names.
-// GetProtocolDialog - Undecorated name, which can be easily used with GetProcAddress
-// Win32 API function.
-// _GetProtocolDialog@0 - Common name decoration for __stdcall functions in C language.
-//#pragma comment(linker, "/export:GetProtocolDialog=_GetProtocolDialog@0")
-
extern "C" FTNOIR_PROTOCOL_BASE_EXPORT IProtocolDialog* CALLING_CONVENTION GetDialog( )
{
return new MOUSEControls;
diff --git a/ftnoir_protocol_mouse/ftnoir_protocol_mouse_dll.cpp b/ftnoir_protocol_mouse/ftnoir_protocol_mouse_dll.cpp
index d142934d..54f6b307 100644
--- a/ftnoir_protocol_mouse/ftnoir_protocol_mouse_dll.cpp
+++ b/ftnoir_protocol_mouse/ftnoir_protocol_mouse_dll.cpp
@@ -23,26 +23,8 @@
* *
********************************************************************************/
#include "ftnoir_protocol_mouse.h"
-#include <QDebug>
#include "facetracknoir/global-settings.h"
-FTNoIR_ProtocolDll::FTNoIR_ProtocolDll() {
-}
-
-FTNoIR_ProtocolDll::~FTNoIR_ProtocolDll()
-{
-
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// Factory function that creates instances if the Protocol object.
-
-// Export both decorated and undecorated names.
-// GetProtocolDll - Undecorated name, which can be easily used with GetProcAddress
-// Win32 API function.
-// _GetProtocolDll@0 - Common name decoration for __stdcall functions in C language.
-//#pragma comment(linker, "/export:GetProtocolDll=_GetProtocolDll@0")
-
extern "C" FTNOIR_PROTOCOL_BASE_EXPORT Metadata* CALLING_CONVENTION GetMetadata()
{
return new FTNoIR_ProtocolDll;
diff --git a/ftnoir_protocol_sc/ftnoir_protocol_sc.cpp b/ftnoir_protocol_sc/ftnoir_protocol_sc.cpp
index 9c144b5d..2714e980 100644
--- a/ftnoir_protocol_sc/ftnoir_protocol_sc.cpp
+++ b/ftnoir_protocol_sc/ftnoir_protocol_sc.cpp
@@ -50,15 +50,12 @@ float FTNoIR_Protocol::prevSCRotZ = 0.0f;
static QLibrary SCClientLib;
-/** constructor **/
FTNoIR_Protocol::FTNoIR_Protocol()
{
- ProgramName = "Microsoft FSX";
blnSimConnectActive = false;
hSimConnect = 0;
}
-/** destructor **/
FTNoIR_Protocol::~FTNoIR_Protocol()
{
qDebug() << "~FTNoIR_Protocol says: inside" << FTNoIR_Protocol::hSimConnect;
@@ -69,18 +66,8 @@ FTNoIR_Protocol::~FTNoIR_Protocol()
qDebug() << "~FTNoIR_Protocol says: close SUCCEEDED";
}
}
-// SCClientLib.unload(); Generates crash when tracker is ended...
}
-//
-// Load the current Settings from the currently 'active' INI-file.
-//
-void FTNoIR_Protocol::loadSettings() {
-}
-
-//
-// Update Headpose in Game.
-//
void FTNoIR_Protocol::sendHeadposeToGame( const double *headpose ) {
virtSCRotX = -headpose[Pitch]; // degrees
virtSCRotY = -headpose[Yaw];
@@ -90,14 +77,8 @@ void FTNoIR_Protocol::sendHeadposeToGame( const double *headpose ) {
virtSCPosY = headpose[TY]/100.f;
virtSCPosZ = -headpose[TZ]/100.f;
- //
- // It's only useful to send data, if the connection was made.
- //
if (!blnSimConnectActive) {
if (SUCCEEDED(simconnect_open(&hSimConnect, "FaceTrackNoIR", NULL, 0, 0, 0))) {
- qDebug() << "FTNoIR_Protocol::sendHeadposeToGame() says: SimConnect active!";
-
- //set up the events we want to listen for
HRESULT hr;
simconnect_subscribetosystemevent(hSimConnect, EVENT_PING, "Frame");
@@ -105,39 +86,11 @@ void FTNoIR_Protocol::sendHeadposeToGame( const double *headpose ) {
hr = simconnect_mapclienteventtosimevent(hSimConnect, EVENT_INIT, "");
hr = simconnect_addclienteventtonotificationgroup(hSimConnect, GROUP0, EVENT_INIT, false);
hr = simconnect_setnotificationgrouppriority(hSimConnect, GROUP0, SIMCONNECT_GROUP_PRIORITY_HIGHEST);
- ////hr = SimConnect_MapInputEventToClientEvent(hSimConnect, INPUT0, "VK_COMMA", EVENT_INIT);
- ////hr = SimConnect_SetInputGroupState(hSimConnect, INPUT0, SIMCONNECT_STATE_ON);
-
blnSimConnectActive = true;
}
}
- else {
- //
- // Write the 6DOF-data to FSX
-// //
-// // Only do this when the data has changed. This way, the HAT-switch can be used when tracking is OFF.
-// //
-// if ((prevPosX != virtPosX) || (prevPosY != virtPosY) || (prevPosZ != virtPosZ) ||
-// (prevRotX != virtRotX) || (prevRotY != virtRotY) || (prevRotZ != virtRotZ)) {
-//// if (S_OK == simconnect_set6DOF(hSimConnect, virtPosX, virtPosY, virtPosZ, virtRotX, virtRotZ, virtRotY)) {
-//// qDebug() << "FTNoIR_Protocol::run() says: SimConnect data written!";
-//// }
-// }
-//
-// prevPosX = virtPosX;
-// prevPosY = virtPosY;
-// prevPosZ = virtPosZ;
-// prevRotX = virtRotX;
-// prevRotY = virtRotY;
-// prevRotZ = virtRotZ;
-
- if (SUCCEEDED(simconnect_calldispatch(hSimConnect, processNextSimconnectEvent, NULL))) {
- qDebug() << "FTNoIR_Protocol::sendHeadposeToGame() says: Dispatching";
- }
- else {
- qDebug() << "FTNoIR_Protocol::sendHeadposeToGame() says: Error Dispatching!";
- }
- }
+ else
+ (void) (simconnect_calldispatch(hSimConnect, processNextSimconnectEvent, NULL));
}
class ActivationContext {
@@ -181,31 +134,17 @@ private:
HANDLE hactctx;
};
-//
-// Returns 'true' if all seems OK.
-//
bool FTNoIR_Protocol::checkServerInstallationOK()
{
if (!SCClientLib.isLoaded())
{
- qDebug() << "SCCheckClientDLL says: Starting Function";
-
- QSettings settings("opentrack");
- QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString();
- QSettings iniFile( currentFile, QSettings::IniFormat ); // Application settings (in INI-file)
- iniFile.beginGroup ( "FSX" );
- int act = iniFile.value("version", 0).toInt();
- iniFile.endGroup();
-
- ActivationContext ctx(142 + act);
+ ActivationContext ctx(142 + static_cast<int>(s.sxs_manifest));
SCClientLib.setFileName("SimConnect.dll");
if (!SCClientLib.load()) {
qDebug() << "SC load" << SCClientLib.errorString();
return false;
}
- } else {
- qDebug() << "SimConnect already loaded";
}
//
@@ -266,97 +205,47 @@ bool FTNoIR_Protocol::checkServerInstallationOK()
void CALLBACK FTNoIR_Protocol::processNextSimconnectEvent(SIMCONNECT_RECV* pData, DWORD cbData, void *pContext)
{
-// HRESULT hr;
-
switch(pData->dwID)
{
- case SIMCONNECT_RECV_ID_EVENT:
- {
- SIMCONNECT_RECV_EVENT *evt = (SIMCONNECT_RECV_EVENT*)pData;
-
- qDebug() << "FTNoIR_Protocol::processNextSimconnectEvent() says: SimConnect active!";
- //switch(evt->uEventID)
- //{
- // //case EVENT_CAMERA_RIGHT:
-
- // // cameraBank = normalize180( cameraBank + 5.0f);
-
- // // hr = SimConnect_CameraSetRelative6DOF(hSimConnect, 0.0f, 0.0f, 0.0f,
- // // SIMCONNECT_CAMERA_IGNORE_FIELD,SIMCONNECT_CAMERA_IGNORE_FIELD, cameraBank);
-
- // // printf("\nCamera Bank = %f", cameraBank);
- // // break;
-
- // //case EVENT_CAMERA_LEFT:
- // //
- // // cameraBank = normalize180( cameraBank - 5.0f);
-
- // // hr = SimConnect_CameraSetRelative6DOF(hSimConnect, 0.0f, 0.0f, 0.0f,
- // // SIMCONNECT_CAMERA_IGNORE_FIELD,SIMCONNECT_CAMERA_IGNORE_FIELD, cameraBank);
- // //
- // // printf("\nCamera Bank = %f", cameraBank);
- // // break;
-
- // //default:
- // // break;
- //}
- //break;
+ default:
+ break;
+ case SIMCONNECT_RECV_ID_EVENT_FRAME:
+ {
+ if ((prevSCPosX != virtSCPosX) || (prevSCPosY != virtSCPosY) || (prevSCPosZ != virtSCPosZ) ||
+ (prevSCRotX != virtSCRotX) || (prevSCRotY != virtSCRotY) || (prevSCRotZ != virtSCRotZ)) {
+ (void) simconnect_set6DOF(hSimConnect, virtSCPosX, virtSCPosY, virtSCPosZ, virtSCRotX, virtSCRotZ, virtSCRotY);
}
- case SIMCONNECT_RECV_ID_EVENT_FRAME:
- {
-// qDebug() << "FTNoIR_Protocol::processNextSimconnectEvent() says: Frame event!";
- if ((prevSCPosX != virtSCPosX) || (prevSCPosY != virtSCPosY) || (prevSCPosZ != virtSCPosZ) ||
- (prevSCRotX != virtSCRotX) || (prevSCRotY != virtSCRotY) || (prevSCRotZ != virtSCRotZ)) {
- if (S_OK == simconnect_set6DOF(hSimConnect, virtSCPosX, virtSCPosY, virtSCPosZ, virtSCRotX, virtSCRotZ, virtSCRotY)) {
- // qDebug() << "FTNoIR_Protocol::run() says: SimConnect data written!";
- }
- }
- prevSCPosX = virtSCPosX;
- prevSCPosY = virtSCPosY;
- prevSCPosZ = virtSCPosZ;
- prevSCRotX = virtSCRotX;
- prevSCRotY = virtSCRotY;
- prevSCRotZ = virtSCRotZ;
- }
+ prevSCPosX = virtSCPosX;
+ prevSCPosY = virtSCPosY;
+ prevSCPosZ = virtSCPosZ;
+ prevSCRotX = virtSCRotX;
+ prevSCRotY = virtSCRotY;
+ prevSCRotZ = virtSCRotZ;
+ }
+ case SIMCONNECT_RECV_ID_EXCEPTION:
+ {
+ SIMCONNECT_RECV_EXCEPTION *except = (SIMCONNECT_RECV_EXCEPTION*)pData;
- case SIMCONNECT_RECV_ID_EXCEPTION:
+ switch (except->dwException)
{
- SIMCONNECT_RECV_EXCEPTION *except = (SIMCONNECT_RECV_EXCEPTION*)pData;
-
- switch (except->dwException)
- {
- case SIMCONNECT_EXCEPTION_ERROR:
- printf("\nCamera error");
- break;
-
- default:
- printf("\nException");
- break;
- }
+ case SIMCONNECT_EXCEPTION_ERROR:
+ qDebug() << "Camera error";
break;
- }
- case SIMCONNECT_RECV_ID_QUIT:
- {
- qDebug() << "FTNoIR_Protocol::processNextSimconnectEvent() says: Quit event!";
-// quit = 1;
+ default:
+ qDebug() << "Exception";
break;
}
+ break;
+ }
- default:
- break;
+ case SIMCONNECT_RECV_ID_QUIT:
+ {
+ break;
+ }
}
}
-////////////////////////////////////////////////////////////////////////////////
-// Factory function that creates instances if the Protocol object.
-
-// Export both decorated and undecorated names.
-// GetProtocol - Undecorated name, which can be easily used with GetProcAddress
-// Win32 API function.
-// _GetProtocol@0 - Common name decoration for __stdcall functions in C language.
-//#pragma comment(linker, "/export:GetProtocol=_GetProtocol@0")
-
extern "C" FTNOIR_PROTOCOL_BASE_EXPORT IProtocol* CALLING_CONVENTION GetConstructor()
{
return new FTNoIR_Protocol;
diff --git a/ftnoir_protocol_sc/ftnoir_protocol_sc.h b/ftnoir_protocol_sc/ftnoir_protocol_sc.h
index e17cabb5..a13c0097 100644
--- a/ftnoir_protocol_sc/ftnoir_protocol_sc.h
+++ b/ftnoir_protocol_sc/ftnoir_protocol_sc.h
@@ -27,8 +27,6 @@
* must be treated as such... *
********************************************************************************/
#pragma once
-#ifndef INCLUDED_SCSERVER_H
-#define INCLUDED_SCSERVER_H
#undef _WIN32_WINNT
#define _WIN32_WINNT 0x0502
#include "facetracknoir/global-settings.h"
@@ -48,7 +46,8 @@
#include <QProcess>
#include <QDebug>
#include <QFile>
-//#include "math.h"
+#include "facetracknoir/options.h"
+using namespace options;
typedef HRESULT (WINAPI *importSimConnect_Open)(HANDLE * phSimConnect, LPCSTR szName, HWND hWnd, DWORD UserEventWin32, HANDLE hEventHandle, DWORD ConfigIndex);
typedef HRESULT (WINAPI *importSimConnect_Close)(HANDLE hSimConnect);
@@ -77,6 +76,15 @@ enum INPUT_ID
INPUT0=0,
};
+struct settings {
+ pbundle b;
+ value<int> sxs_manifest;
+ settings() :
+ b(bundle("proto-simconnect")),
+ sxs_manifest(b, "sxs-manifest-version", 0)
+ {}
+};
+
class FTNoIR_Protocol : public IProtocol
{
public:
@@ -87,11 +95,7 @@ public:
QString getGameName() {
return "FS2004/FSX";
}
-
private:
- // Private properties
- QString ProgramName;
-
static float virtSCPosX;
static float virtSCPosY;
static float virtSCPosZ;
@@ -121,7 +125,7 @@ private:
static HANDLE hSimConnect; // Handle to SimConnect
static void CALLBACK processNextSimconnectEvent(SIMCONNECT_RECV* pData, DWORD cbData, void *pContext);
- void loadSettings();
+ settings s;
};
// Widget that has controls for FTNoIR protocol client-settings.
@@ -129,31 +133,15 @@ class SCControls: public QWidget, public IProtocolDialog
{
Q_OBJECT
public:
-
- explicit SCControls();
- virtual ~SCControls();
- void showEvent ( QShowEvent * event );
- void Initialize(QWidget *parent);
- void registerProtocol(IProtocol *protocol) {
- theProtocol = (FTNoIR_Protocol *) protocol; // Accept the pointer to the Protocol
- }
- void unRegisterProtocol() {
- theProtocol = NULL; // Reset the pointer
- }
-
+ SCControls();
+ void registerProtocol(IProtocol *protocol) {}
+ void unRegisterProtocol() {}
private:
- Ui::UICSCControls ui;
- void loadSettings();
- void save();
-
- /** helper **/
- bool settingsDirty;
- FTNoIR_Protocol *theProtocol;
-
+ Ui::UICSCControls ui;
+ settings s;
private slots:
- void doOK();
- void doCancel();
- void settingChanged() { settingsDirty = true; };
+ void doOK();
+ void doCancel();
};
//*******************************************************************************************************
@@ -162,15 +150,8 @@ private slots:
class FTNoIR_ProtocolDll : public Metadata
{
public:
- FTNoIR_ProtocolDll();
- ~FTNoIR_ProtocolDll();
-
- void getFullName(QString *strToBeFilled) { *strToBeFilled = QString("FSX SimConnect"); };
- void getShortName(QString *strToBeFilled) { *strToBeFilled = QString("SimConnect"); };
- void getDescription(QString *strToBeFilled) { *strToBeFilled = QString("Microsoft SimConnect protocol"); };
-
- void getIcon(QIcon *icon) { *icon = QIcon(":/images/fsx.png"); };
+ void getFullName(QString *strToBeFilled) { *strToBeFilled = QString("FSX SimConnect"); }
+ void getShortName(QString *strToBeFilled) { *strToBeFilled = QString("SimConnect"); }
+ void getDescription(QString *strToBeFilled) { *strToBeFilled = QString("Microsoft SimConnect protocol"); }
+ void getIcon(QIcon *icon) { *icon = QIcon(":/images/fsx.png"); }
};
-
-#endif//INCLUDED_SCSERVER_H
-//END
diff --git a/ftnoir_protocol_sc/ftnoir_protocol_sc_dialog.cpp b/ftnoir_protocol_sc/ftnoir_protocol_sc_dialog.cpp
index fb822145..6af87285 100644
--- a/ftnoir_protocol_sc/ftnoir_protocol_sc_dialog.cpp
+++ b/ftnoir_protocol_sc/ftnoir_protocol_sc_dialog.cpp
@@ -26,13 +26,6 @@
#include <QDebug>
#include "facetracknoir/global-settings.h"
-//*******************************************************************************************************
-// FaceTrackNoIR Client Settings-dialog.
-//*******************************************************************************************************
-
-//
-// Constructor for server-settings-dialog
-//
SCControls::SCControls() :
QWidget()
{
@@ -41,115 +34,38 @@ QWidget()
// Connect Qt signals to member-functions
connect(ui.buttonBox, SIGNAL(accepted()), this, SLOT(doOK()));
connect(ui.buttonBox, SIGNAL(rejected()), this, SLOT(doCancel()));
- //connect(ui.cbxSelectPPJoyNumber, SIGNAL(currentIndexChanged(int)), this, SLOT(virtualJoystickSelected( int )));
-
- theProtocol = NULL;
- // Load the settings from the current .INI-file
- loadSettings();
+ tie_setting(s.sxs_manifest, ui.comboBox);
}
-//
-// Destructor for server-dialog
-//
-SCControls::~SCControls() {
- qDebug() << "~SCControls() says: started";
-}
-
-//
-// Initialize tracker-client-dialog
-//
-void SCControls::Initialize(QWidget *parent) {
-
- QPoint offsetpos(100, 100);
- if (parent) {
- this->move(parent->pos() + offsetpos);
- }
- show();
-}
-
-//
-// OK clicked on server-dialog
-//
void SCControls::doOK() {
- save();
+ s.b->save();
this->close();
}
-// override show event
-void SCControls::showEvent ( QShowEvent * event ) {
- loadSettings();
-}
-
-//
-// Cancel clicked on server-dialog
-//
void SCControls::doCancel() {
- //
- // Ask if changed Settings should be saved
- //
- if (settingsDirty) {
- int ret = QMessageBox::question ( this, "Settings have changed", "Do you want to save the settings?", QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel, QMessageBox::Discard );
-
- qDebug() << "doCancel says: answer =" << ret;
-
- switch (ret) {
- case QMessageBox::Save:
- save();
- this->close();
- break;
- case QMessageBox::Discard:
- this->close();
- break;
- case QMessageBox::Cancel:
- // Cancel was clicked
- break;
- default:
- // should never be reached
- break;
- }
- }
- else {
- this->close();
- }
-}
-
-//
-// Load the current Settings from the currently 'active' INI-file.
-//
-void SCControls::loadSettings() {
- QSettings settings("opentrack");
- QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString();
- QSettings iniFile( currentFile, QSettings::IniFormat ); // Application settings (in INI-file)
- iniFile.beginGroup ( "FSX" );
- int act = iniFile.value("version", 0).toInt();
- iniFile.endGroup();
- ui.comboBox->setCurrentIndex(act);
- settingsDirty = false;
+ if (s.b->modifiedp()) {
+ int ret = QMessageBox::question ( this, "Settings have changed", "Do you want to save the settings?", QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel);
+
+ switch (ret) {
+ case QMessageBox::Save:
+ s.b->save();
+ this->close();
+ break;
+ case QMessageBox::Discard:
+ s.b->revert();
+ this->close();
+ break;
+ case QMessageBox::Cancel:
+ default:
+ break;
+ }
+ }
+ else {
+ this->close();
+ }
}
-//
-// Save the current Settings to the currently 'active' INI-file.
-//
-void SCControls::save() {
- QSettings settings("opentrack");
- QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString();
- QSettings iniFile( currentFile, QSettings::IniFormat ); // Application settings (in INI-file)
- iniFile.beginGroup ( "FSX" );
- iniFile.setValue("version", ui.comboBox->currentIndex());
- iniFile.endGroup();
- settingsDirty = false;
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// Factory function that creates instances if the Protocol-settings dialog object.
-
-// Export both decorated and undecorated names.
-// GetProtocolDialog - Undecorated name, which can be easily used with GetProcAddress
-// Win32 API function.
-// _GetProtocolDialog@0 - Common name decoration for __stdcall functions in C language.
-//#pragma comment(linker, "/export:GetProtocolDialog=_GetProtocolDialog@0")
-
extern "C" FTNOIR_PROTOCOL_BASE_EXPORT IProtocolDialog* CALLING_CONVENTION GetDialog( )
{
return new SCControls;
diff --git a/ftnoir_protocol_sc/ftnoir_protocol_sc_dll.cpp b/ftnoir_protocol_sc/ftnoir_protocol_sc_dll.cpp
index 59a921b8..0a52fa96 100644
--- a/ftnoir_protocol_sc/ftnoir_protocol_sc_dll.cpp
+++ b/ftnoir_protocol_sc/ftnoir_protocol_sc_dll.cpp
@@ -26,23 +26,6 @@
#include <QDebug>
#include "facetracknoir/global-settings.h"
-FTNoIR_ProtocolDll::FTNoIR_ProtocolDll() {
-}
-
-FTNoIR_ProtocolDll::~FTNoIR_ProtocolDll()
-{
-
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// Factory function that creates instances if the Protocol object.
-
-// Export both decorated and undecorated names.
-// GetProtocolDll - Undecorated name, which can be easily used with GetProcAddress
-// Win32 API function.
-// _GetProtocolDll@0 - Common name decoration for __stdcall functions in C language.
-//#pragma comment(linker, "/export:GetProtocolDll=_GetProtocolDll@0")
-
extern "C" FTNOIR_PROTOCOL_BASE_EXPORT Metadata* CALLING_CONVENTION GetMetadata()
{
return new FTNoIR_ProtocolDll;
diff --git a/ftnoir_protocol_vjoy/ftnoir_protocol_vjoy.h b/ftnoir_protocol_vjoy/ftnoir_protocol_vjoy.h
index c4db29e4..873b4e3c 100644
--- a/ftnoir_protocol_vjoy/ftnoir_protocol_vjoy.h
+++ b/ftnoir_protocol_vjoy/ftnoir_protocol_vjoy.h
@@ -60,10 +60,6 @@ class VJoyControls: public QWidget, public IProtocolDialog
public:
explicit VJoyControls();
- virtual ~VJoyControls();
- void showEvent ( QShowEvent *) {}
-
- void Initialize(QWidget *);
void registerProtocol(IProtocol *l) {}
void unRegisterProtocol() {}
diff --git a/ftnoir_protocol_vjoy/ftnoir_protocol_vjoy_dialog.cpp b/ftnoir_protocol_vjoy/ftnoir_protocol_vjoy_dialog.cpp
index 0009553b..febb7b18 100644
--- a/ftnoir_protocol_vjoy/ftnoir_protocol_vjoy_dialog.cpp
+++ b/ftnoir_protocol_vjoy/ftnoir_protocol_vjoy_dialog.cpp
@@ -8,21 +8,6 @@ VJoyControls::VJoyControls() : QWidget()
connect(ui.btnCancel, SIGNAL(clicked()), this, SLOT(doCancel()));
}
-VJoyControls::~VJoyControls() {
-}
-
-//
-// Initialize tracker-client-dialog
-//
-void VJoyControls::Initialize(QWidget *parent) {
-
- QPoint offsetpos(100, 100);
- if (parent) {
- this->move(parent->pos() + offsetpos);
- }
- show();
-}
-
void VJoyControls::doOK() {
save();
this->close();
diff --git a/ftnoir_protocol_wine/ftnoir_protocol_wine.h b/ftnoir_protocol_wine/ftnoir_protocol_wine.h
index d7276b8e..50d2bc0c 100644
--- a/ftnoir_protocol_wine/ftnoir_protocol_wine.h
+++ b/ftnoir_protocol_wine/ftnoir_protocol_wine.h
@@ -33,7 +33,6 @@
#include "ftnoir_csv/csv.h"
#include "ui_ftnoir_winecontrols.h"
#include <QMessageBox>
-#include <QSettings>
#include <QLibrary>
#include <QProcess>
#include <QDebug>
@@ -70,10 +69,7 @@ class FTControls: public QWidget, public IProtocolDialog
{
Q_OBJECT
public:
-
FTControls();
- void showEvent ( QShowEvent * ) {show();}
- void Initialize(QWidget *) {show();}
void registerProtocol(IProtocol *) {}
void unRegisterProtocol() {}
diff --git a/ftnoir_tracker_aruco/aruco-trackercontrols.ui b/ftnoir_tracker_aruco/aruco-trackercontrols.ui
index 710a33e1..3bf141de 100644
--- a/ftnoir_tracker_aruco/aruco-trackercontrols.ui
+++ b/ftnoir_tracker_aruco/aruco-trackercontrols.ui
@@ -9,12 +9,12 @@
<rect>
<x>0</x>
<y>0</y>
- <width>704</width>
- <height>339</height>
+ <width>630</width>
+ <height>315</height>
</rect>
</property>
<property name="sizePolicy">
- <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
+ <sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
@@ -32,78 +32,8 @@
<property name="spacing">
<number>-1</number>
</property>
- <item row="0" column="0">
- <widget class="QLabel" name="label">
- <property name="text">
- <string>Horizontal FOV</string>
- </property>
- </widget>
- </item>
- <item row="0" column="3" rowspan="3" colspan="2">
- <widget class="QGroupBox" name="groupBox">
- <property name="title">
- <string>Enable axes</string>
- </property>
- <layout class="QFormLayout" name="formLayout">
- <property name="horizontalSpacing">
- <number>-1</number>
- </property>
- <property name="leftMargin">
- <number>6</number>
- </property>
- <property name="topMargin">
- <number>0</number>
- </property>
- <property name="rightMargin">
- <number>6</number>
- </property>
- <property name="bottomMargin">
- <number>0</number>
- </property>
- <item row="0" column="0">
- <widget class="QCheckBox" name="rx">
- <property name="text">
- <string>RX</string>
- </property>
- </widget>
- </item>
- <item row="0" column="1">
- <widget class="QCheckBox" name="tx">
- <property name="text">
- <string>TX</string>
- </property>
- </widget>
- </item>
- <item row="1" column="0">
- <widget class="QCheckBox" name="ry">
- <property name="text">
- <string>RY</string>
- </property>
- </widget>
- </item>
- <item row="1" column="1">
- <widget class="QCheckBox" name="ty">
- <property name="text">
- <string>TY</string>
- </property>
- </widget>
- </item>
- <item row="2" column="0">
- <widget class="QCheckBox" name="rz">
- <property name="text">
- <string>RZ</string>
- </property>
- </widget>
- </item>
- <item row="2" column="1">
- <widget class="QCheckBox" name="tz">
- <property name="text">
- <string>TZ</string>
- </property>
- </widget>
- </item>
- </layout>
- </widget>
+ <item row="2" column="1" colspan="2">
+ <widget class="QComboBox" name="cameraName"/>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_2">
@@ -112,9 +42,6 @@
</property>
</widget>
</item>
- <item row="2" column="1" colspan="2">
- <widget class="QComboBox" name="cameraName"/>
- </item>
<item row="0" column="1" colspan="2">
<widget class="QDoubleSpinBox" name="cameraFOV">
<property name="locale">
@@ -131,6 +58,20 @@
</property>
</widget>
</item>
+ <item row="7" column="1">
+ <widget class="QCheckBox" name="red_only">
+ <property name="text">
+ <string>Recommended!</string>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="0">
+ <widget class="QLabel" name="label_3">
+ <property name="text">
+ <string>Camera name</string>
+ </property>
+ </widget>
+ </item>
<item row="1" column="1" colspan="2">
<widget class="QComboBox" name="cameraFPS">
<item>
@@ -155,13 +96,6 @@
</item>
</widget>
</item>
- <item row="6" column="0">
- <widget class="QLabel" name="label_4">
- <property name="text">
- <string>Resolution</string>
- </property>
- </widget>
- </item>
<item row="6" column="2" rowspan="4" colspan="3">
<widget class="QLabel" name="label_6">
<property name="sizePolicy">
@@ -193,13 +127,6 @@
</property>
</widget>
</item>
- <item row="10" column="4">
- <widget class="QDialogButtonBox" name="buttonBox">
- <property name="standardButtons">
- <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
- </property>
- </widget>
- </item>
<item row="6" column="1">
<widget class="QComboBox" name="resolution">
<item>
@@ -224,39 +151,109 @@
</item>
</widget>
</item>
- <item row="2" column="0">
- <widget class="QLabel" name="label_3">
+ <item row="7" column="0">
+ <widget class="QLabel" name="label_10">
<property name="text">
- <string>Camera name</string>
+ <string>Red channel only</string>
</property>
</widget>
</item>
- <item row="7" column="0">
- <widget class="QLabel" name="label_10">
+ <item row="10" column="4">
+ <widget class="QDialogButtonBox" name="buttonBox">
+ <property name="standardButtons">
+ <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="0">
+ <widget class="QLabel" name="label">
<property name="text">
- <string>Red channel only</string>
+ <string>Horizontal FOV</string>
</property>
</widget>
</item>
- <item row="7" column="1">
- <widget class="QCheckBox" name="red_only">
+ <item row="6" column="0">
+ <widget class="QLabel" name="label_4">
<property name="text">
- <string>Recommended!</string>
+ <string>Resolution</string>
</property>
</widget>
</item>
- <item row="8" column="1">
+ <item row="0" column="3" rowspan="3" colspan="2">
+ <widget class="QGroupBox" name="groupBox">
+ <property name="title">
+ <string>Enable axes</string>
+ </property>
+ <layout class="QFormLayout" name="formLayout">
+ <property name="horizontalSpacing">
+ <number>-1</number>
+ </property>
+ <property name="leftMargin">
+ <number>6</number>
+ </property>
+ <property name="topMargin">
+ <number>0</number>
+ </property>
+ <property name="rightMargin">
+ <number>6</number>
+ </property>
+ <property name="bottomMargin">
+ <number>0</number>
+ </property>
+ <item row="0" column="0">
+ <widget class="QCheckBox" name="rx">
+ <property name="text">
+ <string>RX</string>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1">
+ <widget class="QCheckBox" name="tx">
+ <property name="text">
+ <string>TX</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="0">
+ <widget class="QCheckBox" name="ry">
+ <property name="text">
+ <string>RY</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1">
+ <widget class="QCheckBox" name="ty">
+ <property name="text">
+ <string>TY</string>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="0">
+ <widget class="QCheckBox" name="rz">
+ <property name="text">
+ <string>RZ</string>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="1">
+ <widget class="QCheckBox" name="tz">
+ <property name="text">
+ <string>TZ</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item row="8" column="1" rowspan="3">
<widget class="QGroupBox" name="groupBox_2">
<property name="title">
- <string>Head centroid position</string>
+ <string>Head position</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
</property>
- <layout class="QFormLayout" name="formLayout_2">
- <property name="formAlignment">
- <set>Qt::AlignHCenter|Qt::AlignTop</set>
- </property>
+ <layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<widget class="QLabel" name="label_5">
<property name="text">
@@ -266,6 +263,12 @@
</item>
<item row="0" column="1">
<widget class="QDoubleSpinBox" name="cx">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Minimum" vsizetype="Minimum">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
<property name="minimum">
<double>-200.000000000000000</double>
</property>
@@ -283,6 +286,12 @@
</item>
<item row="1" column="1">
<widget class="QDoubleSpinBox" name="cy">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Minimum" vsizetype="Minimum">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
<property name="minimum">
<double>-200.000000000000000</double>
</property>
@@ -300,6 +309,12 @@
</item>
<item row="2" column="1">
<widget class="QDoubleSpinBox" name="cz">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Minimum" vsizetype="Minimum">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
<property name="minimum">
<double>-200.000000000000000</double>
</property>
@@ -308,32 +323,6 @@
</property>
</widget>
</item>
- <item row="3" column="0">
- <widget class="QLabel" name="label_9">
- <property name="text">
- <string>Pitch</string>
- </property>
- </widget>
- </item>
- <item row="3" column="1">
- <widget class="QDoubleSpinBox" name="pitch_deg">
- <property name="suffix">
- <string>°</string>
- </property>
- <property name="decimals">
- <number>2</number>
- </property>
- <property name="minimum">
- <double>-60.000000000000000</double>
- </property>
- <property name="maximum">
- <double>60.000000000000000</double>
- </property>
- <property name="value">
- <double>0.000000000000000</double>
- </property>
- </widget>
- </item>
</layout>
</widget>
</item>
@@ -347,7 +336,6 @@
<tabstop>cx</tabstop>
<tabstop>cy</tabstop>
<tabstop>cz</tabstop>
- <tabstop>pitch_deg</tabstop>
<tabstop>rx</tabstop>
<tabstop>ry</tabstop>
<tabstop>rz</tabstop>
diff --git a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp
index 9408de02..b4f35c6f 100644
--- a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp
+++ b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.cpp
@@ -99,47 +99,8 @@ static resolution_tuple resolution_choices[] = {
{ 0, 0 }
};
-void Tracker::load_settings()
+Tracker::Tracker() : stop(false), layout(nullptr), videoWidget(nullptr)
{
- QMutexLocker foo(&mtx);
- QSettings settings("opentrack");
- QString currentFile = settings.value( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString();
- QSettings iniFile( currentFile, QSettings::IniFormat );
-
- iniFile.beginGroup( "aruco-Tracker" );
- fov = iniFile.value("fov", 56).toFloat();
- force_fps = iniFile.value("fps", 0).toInt();
- camera_index = iniFile.value("camera-index", -1).toInt();
- int res = iniFile.value("resolution", 0).toInt();
- if (res < 0 || res >= (int)(sizeof(resolution_choices) / sizeof(resolution_tuple)))
- res = 0;
- resolution_tuple r = resolution_choices[res];
- force_width = r.width;
- force_height = r.height;
- enableRX = iniFile.value("enable-rx", true).toBool();
- enableRY = iniFile.value("enable-ry", true).toBool();
- enableRZ = iniFile.value("enable-rz", true).toBool();
- enableTX = iniFile.value("enable-tx", true).toBool();
- enableTY = iniFile.value("enable-ty", true).toBool();
- enableTZ = iniFile.value("enable-tz", true).toBool();
-
- for (int i = 0; i < 3; i++)
- {
- headpos[i] = iniFile.value(QString("headpos-%1").arg(i), 0).toDouble();
- }
- headpitch = iniFile.value("pitch", 0).toDouble();
- red_only = iniFile.value("red-only", true).toBool();
-
- iniFile.endGroup();
-}
-
-Tracker::Tracker()
-{
- layout = nullptr;
- stop = false;
- videoWidget = NULL;
- enableRX = enableRY = enableRZ = enableTX = enableTY = enableTZ = true;
- load_settings();
}
Tracker::~Tracker()
@@ -166,7 +127,6 @@ void Tracker::StartTracker(QFrame* videoframe)
delete videoframe->layout();
videoframe->setLayout(layout);
videoWidget->show();
- load_settings();
start();
for (int i = 0; i < 6; i++)
pose[i] = 0;
@@ -177,13 +137,35 @@ void Tracker::StartTracker(QFrame* videoframe)
void Tracker::run()
{
- camera = cv::VideoCapture(camera_index);
- if (force_width)
- camera.set(CV_CAP_PROP_FRAME_WIDTH, force_width);
- if (force_height)
- camera.set(CV_CAP_PROP_FRAME_HEIGHT, force_height);
- if (force_fps)
- camera.set(CV_CAP_PROP_FPS, force_fps);
+ int res = s.resolution;
+ if (res < 0 || res >= (int)(sizeof(resolution_choices) / sizeof(resolution_tuple)))
+ res = 0;
+ resolution_tuple r = resolution_choices[res];
+ int fps;
+ switch (static_cast<int>(s.force_fps))
+ {
+ default:
+ case 0:
+ fps = 0;
+ break;
+ case 1:
+ fps = 30;
+ break;
+ case 2:
+ fps = 60;
+ break;
+ case 3:
+ fps = 120;
+ break;
+ }
+ camera = cv::VideoCapture(s.camera_index);
+ if (r.width)
+ {
+ camera.set(CV_CAP_PROP_FRAME_WIDTH, r.width);
+ camera.set(CV_CAP_PROP_FRAME_HEIGHT, r.height);
+ }
+ if (fps)
+ camera.set(CV_CAP_PROP_FPS, fps);
aruco::MarkerDetector detector;
detector.setDesiredSpeed(3);
@@ -206,7 +188,7 @@ void Tracker::run()
auto freq = cv::getTickFrequency();
auto last_time = cv::getTickCount();
- int fps = 0;
+ int cur_fps = 0;
int last_fps = 0;
cv::Point2f last_centroid;
@@ -216,7 +198,7 @@ void Tracker::run()
continue;
auto tm = cv::getTickCount();
color_.copyTo(color);
- if (red_only)
+ if (s.red_only)
{
cv::Mat channel[3];
cv::split(color, channel);
@@ -227,8 +209,8 @@ void Tracker::run()
const int scale = frame.cols > 480 ? 2 : 1;
detector.setThresholdParams(scale > 1 ? 11 : 7, 4);
- const float focal_length_w = 0.5 * grayscale.cols / tan(0.5 * fov * HT_PI / 180);
- const float focal_length_h = 0.5 * grayscale.rows / tan(0.5 * fov * grayscale.rows / grayscale.cols * HT_PI / 180.0);
+ const float focal_length_w = 0.5 * grayscale.cols / tan(0.5 * s.fov * HT_PI / 180);
+ const float focal_length_h = 0.5 * grayscale.rows / tan(0.5 * s.fov * grayscale.rows / grayscale.cols * HT_PI / 180.0);
cv::Mat intrinsics = cv::Mat::eye(3, 3, CV_32FC1);
intrinsics.at<float> (0, 0) = focal_length_w;
intrinsics.at<float> (1, 1) = focal_length_h;
@@ -275,12 +257,12 @@ void Tracker::run()
if ((long) (time / freq) != (long) (last_time / freq))
{
- last_fps = fps;
- fps = 0;
+ last_fps = cur_fps;
+ cur_fps = 0;
last_time = time;
}
- fps++;
+ cur_fps++;
char buf[128];
@@ -296,18 +278,18 @@ void Tracker::run()
const float size = 7;
cv::Mat obj_points(4,3,CV_32FC1);
- obj_points.at<float>(1,0)=-size + headpos[0];
- obj_points.at<float>(1,1)=-size + headpos[1];
- obj_points.at<float>(1,2)=0 + headpos[2];
- obj_points.at<float>(2,0)=size + headpos[0];
- obj_points.at<float>(2,1)=-size + headpos[1];
- obj_points.at<float>(2,2)=0 + headpos[2];
- obj_points.at<float>(3,0)=size + headpos[0];
- obj_points.at<float>(3,1)=size + headpos[1];
- obj_points.at<float>(3,2)=0 + headpos[2];
- obj_points.at<float>(0,0)=-size + headpos[0];
- obj_points.at<float>(0,1)=size + headpos[1];
- obj_points.at<float>(0,2)=0 + headpos[2];
+ obj_points.at<float>(1,0)=-size + s.headpos_x;
+ obj_points.at<float>(1,1)=-size + s.headpos_y;
+ obj_points.at<float>(1,2)=0 + s.headpos_z;
+ obj_points.at<float>(2,0)=size + s.headpos_x;
+ obj_points.at<float>(2,1)=-size + s.headpos_y;
+ obj_points.at<float>(2,2)=0 + s.headpos_z;
+ obj_points.at<float>(3,0)=size + s.headpos_x;
+ obj_points.at<float>(3,1)=size + s.headpos_y;
+ obj_points.at<float>(3,2)=0 + s.headpos_z;
+ obj_points.at<float>(0,0)=-size + s.headpos_x;
+ obj_points.at<float>(0,1)=size + s.headpos_y;
+ obj_points.at<float>(0,2)=0 + s.headpos_z;
last_roi = cv::Rect(65535, 65535, 0, 0);
@@ -341,22 +323,12 @@ void Tracker::run()
cv::Rodrigues(rvec, rotation_matrix);
{
- const double beta = headpitch * HT_PI / 180;
- double pitch[] = {
- 1, 0, 0,
- 0, cos(beta), -sin(beta),
- 0, sin(beta), cos(beta)
- };
- cv::Mat rot(3, 3, CV_64F, pitch);
- cv::Mat tvec2 = rot * tvec;
- rotation_matrix = rot * rotation_matrix;
-
cv::Vec3d euler = cv::RQDecomp3x3(rotation_matrix, junk1, junk2);
QMutexLocker lck(&mtx);
for (int i = 0; i < 3; i++)
- pose[i] = tvec2.at<double>(i);
+ pose[i] = tvec.at<double>(i);
pose[Yaw] = euler[1];
pose[Pitch] = -euler[0];
@@ -389,17 +361,17 @@ void Tracker::GetHeadPoseData(double *data)
{
QMutexLocker lck(&mtx);
- if (enableRX)
+ if (s.eyaw)
data[Yaw] = pose[Yaw];
- if (enableRY)
+ if (s.epitch)
data[Pitch] = pose[Pitch];
- if (enableRZ)
+ if (s.eroll)
data[Roll] = pose[Roll];
- if (enableTX)
+ if (s.ex)
data[TX] = pose[TX];
- if (enableTY)
+ if (s.ey)
data[TY] = pose[TY];
- if (enableTZ)
+ if (s.ez)
data[TZ] = pose[TZ];
}
@@ -468,178 +440,50 @@ TrackerControls::TrackerControls()
tracker = nullptr;
ui.setupUi(this);
setAttribute(Qt::WA_NativeWindow, true);
- connect(ui.cameraName, SIGNAL(currentIndexChanged(int)), this, SLOT(settingChanged(int)));
- connect(ui.cameraFPS, SIGNAL(currentIndexChanged(int)), this, SLOT(settingChanged(int)));
- connect(ui.cameraFOV, SIGNAL(valueChanged(double)), this, SLOT(settingChanged(double)));
- connect(ui.rx, SIGNAL(stateChanged(int)), this, SLOT(settingChanged(int)));
- connect(ui.ry, SIGNAL(stateChanged(int)), this, SLOT(settingChanged(int)));
- connect(ui.rz, SIGNAL(stateChanged(int)), this, SLOT(settingChanged(int)));
- connect(ui.tx, SIGNAL(stateChanged(int)), this, SLOT(settingChanged(int)));
- connect(ui.ty, SIGNAL(stateChanged(int)), this, SLOT(settingChanged(int)));
- connect(ui.tz, SIGNAL(stateChanged(int)), this, SLOT(settingChanged(int)));
- connect(ui.cx, SIGNAL(valueChanged(double)), this, SLOT(settingChanged(double)));
- connect(ui.cy, SIGNAL(valueChanged(double)), this, SLOT(settingChanged(double)));
- connect(ui.cz, SIGNAL(valueChanged(double)), this, SLOT(settingChanged(double)));
- //connect(ui.buttonCancel, SIGNAL(clicked()), this, SLOT(doCancel()));
- //connect(ui.buttonOK, SIGNAL(clicked()), this, SLOT(doOK()));
- //connect(ui.buttonSettings, SIGNAL(clicked()), this, SLOT(cameraSettings()));
+ tie_setting(s.camera_index, ui.cameraName);
+ tie_setting(s.resolution, ui.resolution);
+ tie_setting(s.force_fps, ui.cameraFPS);
+ tie_setting(s.fov, ui.cameraFOV);
+ tie_setting(s.eyaw, ui.rx);
+ tie_setting(s.epitch, ui.ry);
+ tie_setting(s.eroll, ui.rz);
+ tie_setting(s.ex, ui.tx);
+ tie_setting(s.ey, ui.ty);
+ tie_setting(s.ez, ui.tz);
+ tie_setting(s.headpos_x, ui.cx);
+ tie_setting(s.headpos_y, ui.cy);
+ tie_setting(s.headpos_z, ui.cz);
+ tie_setting(s.red_only, ui.red_only);
connect(ui.buttonBox, SIGNAL(accepted()), this, SLOT(doOK()));
connect(ui.buttonBox, SIGNAL(rejected()), this, SLOT(doCancel()));
- loadSettings();
- settingsDirty = false;
-}
-
-TrackerControls::~TrackerControls()
-{
-}
-
-void TrackerControls::showEvent(QShowEvent *)
-{
-}
-
-void TrackerControls::Initialize(QWidget*)
-{
- loadSettings();
- show();
-}
-
-void TrackerControls::loadSettings()
-{
- ui.cameraName->clear();
- QList<QString> names = get_camera_names();
- names.prepend("Any available");
- ui.cameraName->addItems(names);
- QSettings settings("opentrack");
- QString currentFile = settings.value( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString();
- QSettings iniFile( currentFile, QSettings::IniFormat );
- iniFile.beginGroup( "aruco-Tracker" );
- ui.cameraName->setCurrentIndex(iniFile.value("camera-index", -1).toInt() + 1);
- ui.cameraFOV->setValue(iniFile.value("fov", 56).toFloat());
- int fps;
- switch (iniFile.value("fps", 0).toInt())
- {
- default:
- case 0:
- fps = 0;
- break;
- case 30:
- fps = 1;
- break;
- case 60:
- fps = 2;
- break;
- case 120:
- fps = 3;
- break;
- }
- ui.cameraFPS->setCurrentIndex(fps);
- ui.rx->setCheckState(iniFile.value("enable-rx", true).toBool() ? Qt::Checked : Qt::Unchecked);
- ui.ry->setCheckState(iniFile.value("enable-ry", true).toBool() ? Qt::Checked : Qt::Unchecked);
- ui.rz->setCheckState(iniFile.value("enable-rz", true).toBool() ? Qt::Checked : Qt::Unchecked);
- ui.tx->setCheckState(iniFile.value("enable-tx", true).toBool() ? Qt::Checked : Qt::Unchecked);
- ui.ty->setCheckState(iniFile.value("enable-ty", true).toBool() ? Qt::Checked : Qt::Unchecked);
- ui.tz->setCheckState(iniFile.value("enable-tz", true).toBool() ? Qt::Checked : Qt::Unchecked);
- ui.resolution->setCurrentIndex(iniFile.value("resolution", 0).toInt());
-
- QDoubleSpinBox* headpos[] = {
- ui.cx,
- ui.cy,
- ui.cz
- };
-
- for (int i = 0; i < 3; i++)
- {
- headpos[i]->setValue(iniFile.value(QString("headpos-%1").arg(i)).toDouble());
- }
-
- ui.pitch_deg->setValue(iniFile.value("pitch", 0).toDouble());
- ui.red_only->setChecked(iniFile.value("red-only", true).toBool());
- iniFile.endGroup();
- settingsDirty = false;
-}
-
-void TrackerControls::save()
-{
- QSettings settings("opentrack");
- QString currentFile = settings.value( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString();
- QSettings iniFile( currentFile, QSettings::IniFormat );
-
- iniFile.beginGroup( "aruco-Tracker" );
- iniFile.setValue("fov", ui.cameraFOV->value());
- int fps;
- switch (ui.cameraFPS->currentIndex())
- {
- case 0:
- default:
- fps = 0;
- break;
- case 1:
- fps = 30;
- break;
- case 2:
- fps = 60;
- break;
- case 3:
- fps = 120;
- break;
- }
- iniFile.setValue("fps", fps);
- iniFile.setValue("camera-index", ui.cameraName->currentIndex() - 1);
- iniFile.setValue("enable-rx", ui.rx->checkState() != Qt::Unchecked ? true : false);
- iniFile.setValue("enable-ry", ui.ry->checkState() != Qt::Unchecked ? true : false);
- iniFile.setValue("enable-rz", ui.rz->checkState() != Qt::Unchecked ? true : false);
- iniFile.setValue("enable-tx", ui.tx->checkState() != Qt::Unchecked ? true : false);
- iniFile.setValue("enable-ty", ui.ty->checkState() != Qt::Unchecked ? true : false);
- iniFile.setValue("enable-tz", ui.tz->checkState() != Qt::Unchecked ? true : false);
- iniFile.setValue("resolution", ui.resolution->currentIndex());
- iniFile.setValue("pitch", ui.pitch_deg->value());
-
- QDoubleSpinBox* headpos[] = {
- ui.cx,
- ui.cy,
- ui.cz
- };
-
- for (int i = 0; i < 3; i++)
- {
- iniFile.setValue(QString("headpos-%1").arg(i), headpos[i]->value());
- }
- iniFile.setValue("red-only", ui.red_only->isChecked());
- iniFile.endGroup();
- settingsDirty = false;
- if (tracker)
- tracker->load_settings();
+ ui.cameraName->addItems(get_camera_names());
}
void TrackerControls::doOK()
{
- save();
+ s.b->save();
this->close();
}
void TrackerControls::doCancel()
{
- if (settingsDirty) {
+ if (s.b->modifiedp()) {
int ret = QMessageBox::question ( this,
"Settings have changed",
"Do you want to save the settings?",
- QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel,
- QMessageBox::Discard );
+ QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel );
switch (ret) {
case QMessageBox::Save:
- save();
+ s.b->save();
this->close();
break;
case QMessageBox::Discard:
+ s.b->revert();
this->close();
break;
case QMessageBox::Cancel:
- // Cancel was clicked
- break;
- default:
- // should never be reached
- break;
+ break;
}
}
else {
diff --git a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.h b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.h
index 545ad5d0..2ff40c77 100644
--- a/ftnoir_tracker_aruco/ftnoir_tracker_aruco.h
+++ b/ftnoir_tracker_aruco/ftnoir_tracker_aruco.h
@@ -18,6 +18,33 @@
#include <QDialog>
#include <opencv2/opencv.hpp>
#include <opencv/highgui.h>
+#include "facetracknoir/options.h"
+using namespace options;
+
+struct settings {
+ pbundle b;
+ value<double> fov, headpos_x, headpos_y, headpos_z;
+ value<int> camera_index, force_fps, resolution;
+ value<bool> red_only;
+ value<bool> eyaw, epitch, eroll, ex, ey, ez;
+ settings() :
+ b(bundle("aruco-tracker")),
+ fov(b, "field-of-view", 56),
+ headpos_x(b, "headpos-x", 0),
+ headpos_y(b, "headpos-y", 0),
+ headpos_z(b, "headpos-z", 0),
+ camera_index(b, "camera-index", 0),
+ force_fps(b, "force-fps", 0),
+ resolution(b, "force-resolution", 0),
+ red_only(b, "red-only", false),
+ eyaw(b, "enable-y", true),
+ epitch(b, "enable-p", true),
+ eroll(b, "enable-r", true),
+ ex(b, "enable-x", true),
+ ey(b, "enable-y", true),
+ ez(b, "enable-z", true)
+ {}
+};
class Tracker : protected QThread, public ITracker
{
@@ -27,22 +54,16 @@ public:
virtual ~Tracker();
void StartTracker(QFrame* frame);
void GetHeadPoseData(double *data);
- bool enableTX, enableTY, enableTZ, enableRX, enableRY, enableRZ;
void run();
- void load_settings();
private:
QMutex mtx;
- ArucoVideoWidget* videoWidget;
- QHBoxLayout* layout;
volatile bool stop;
- float fov;
- int camera_index;
- int force_fps, force_width, force_height;
+ QHBoxLayout* layout;
+ ArucoVideoWidget* videoWidget;
+ settings s;
double pose[6];
cv::Mat frame;
- double headpos[3], headpitch;
cv::VideoCapture camera;
- volatile bool red_only;
};
// Widget that has controls for FTNoIR protocol client-settings.
@@ -50,32 +71,20 @@ class TrackerControls : public QWidget, public ITrackerDialog
{
Q_OBJECT
public:
-
- explicit TrackerControls();
- virtual ~TrackerControls();
- void showEvent (QShowEvent *);
-
- void Initialize(QWidget *);
+ TrackerControls();
void registerTracker(ITracker * x) {
tracker = dynamic_cast<Tracker*>(x);
}
void unRegisterTracker() {
tracker = nullptr;
}
-
private:
Ui::Form ui;
- void loadSettings();
- void save();
- bool settingsDirty;
Tracker* tracker;
-
+ settings s;
private slots:
void doOK();
void doCancel();
- void settingChanged() { settingsDirty = true; }
- void settingChanged(int) { settingsDirty = true; }
- void settingChanged(double) { settingsDirty = true; }
};
#endif
diff --git a/ftnoir_tracker_base/ftnoir_tracker_base.h b/ftnoir_tracker_base/ftnoir_tracker_base.h
index 16f76cf3..b8e16e9d 100644
--- a/ftnoir_tracker_base/ftnoir_tracker_base.h
+++ b/ftnoir_tracker_base/ftnoir_tracker_base.h
@@ -58,8 +58,7 @@ inline ITracker::~ITracker() { }
struct ITrackerDialog
{
virtual ~ITrackerDialog() {}
- virtual void Initialize(QWidget *parent) = 0;
- virtual void registerTracker(ITracker *tracker) = 0;
+ virtual void registerTracker(ITracker *tracker) = 0;
virtual void unRegisterTracker() = 0;
};
diff --git a/ftnoir_tracker_hatire/ftnoir_hatcontrols.ui b/ftnoir_tracker_hatire/ftnoir_hatcontrols.ui
index 4446ca85..8a6bae62 100644
--- a/ftnoir_tracker_hatire/ftnoir_hatcontrols.ui
+++ b/ftnoir_tracker_hatire/ftnoir_hatcontrols.ui
@@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>307</width>
- <height>509</height>
+ <height>567</height>
</rect>
</property>
<property name="minimumSize">
@@ -126,47 +126,47 @@
<property name="spacing">
<number>4</number>
</property>
- <item row="0" column="0">
- <widget class="QLabel" name="label_5">
+ <item row="0" column="1">
+ <widget class="QComboBox" name="cbSerialPort">
<property name="sizePolicy">
- <sizepolicy hsizetype="Maximum" vsizetype="Preferred">
+ <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
- <width>65536</width>
+ <width>65535</width>
<height>16777215</height>
</size>
</property>
- <property name="text">
- <string>Serial port</string>
+ <property name="editable">
+ <bool>false</bool>
+ </property>
+ <property name="sizeAdjustPolicy">
+ <enum>QComboBox::AdjustToMinimumContentsLength</enum>
+ </property>
+ <property name="modelColumn">
+ <number>0</number>
</property>
</widget>
</item>
- <item row="0" column="1">
- <widget class="QComboBox" name="cbSerialPort">
+ <item row="0" column="0">
+ <widget class="QLabel" name="label_5">
<property name="sizePolicy">
- <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
+ <sizepolicy hsizetype="Maximum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
- <width>65535</width>
+ <width>65536</width>
<height>16777215</height>
</size>
</property>
- <property name="editable">
- <bool>false</bool>
- </property>
- <property name="sizeAdjustPolicy">
- <enum>QComboBox::AdjustToMinimumContentsLength</enum>
- </property>
- <property name="modelColumn">
- <number>0</number>
+ <property name="text">
+ <string>Serial port</string>
</property>
</widget>
</item>
@@ -1030,45 +1030,6 @@ p, li { white-space: pre-wrap; }
<string>About</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_4">
- <item row="0" column="0">
- <widget class="QLabel" name="label_info_2">
- <property name="text">
- <string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
-&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
-p, li { white-space: pre-wrap; }
-&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;&quot;&gt;
-&lt;p style=&quot; margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-size:8pt; font-weight:600;&quot;&gt;FTNoIR HAT Plugin&lt;br /&gt;by FuraX49&lt;/span&gt;&lt;/p&gt;
-&lt;p style=&quot; margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;a href=&quot;http://hatire.sourceforge.net/&quot;&gt;&lt;span style=&quot; font-size:8pt; font-weight:600; text-decoration: underline; color:#0000ff;&quot;&gt;Manual (external)&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
- </property>
- <property name="openExternalLinks">
- <bool>true</bool>
- </property>
- </widget>
- </item>
- <item row="0" column="1" rowspan="2" colspan="2">
- <widget class="QPushButton" name="btn_icone">
- <property name="autoFillBackground">
- <bool>false</bool>
- </property>
- <property name="text">
- <string/>
- </property>
- <property name="icon">
- <iconset>
- <normalon>:/images/hat_logo.png</normalon>
- </iconset>
- </property>
- <property name="iconSize">
- <size>
- <width>128</width>
- <height>128</height>
- </size>
- </property>
- <property name="flat">
- <bool>true</bool>
- </property>
- </widget>
- </item>
<item row="1" column="0">
<widget class="QLabel" name="label_version">
<property name="font">
@@ -1123,6 +1084,45 @@ p, li { white-space: pre-wrap; }
</property>
</widget>
</item>
+ <item row="0" column="2" rowspan="2">
+ <widget class="QPushButton" name="btn_icone">
+ <property name="autoFillBackground">
+ <bool>false</bool>
+ </property>
+ <property name="text">
+ <string/>
+ </property>
+ <property name="icon">
+ <iconset>
+ <normalon>:/images/hat_logo.png</normalon>
+ </iconset>
+ </property>
+ <property name="iconSize">
+ <size>
+ <width>128</width>
+ <height>128</height>
+ </size>
+ </property>
+ <property name="flat">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="0" colspan="2">
+ <widget class="QLabel" name="label_info_2">
+ <property name="text">
+ <string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
+&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
+p, li { white-space: pre-wrap; }
+&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;&quot;&gt;
+&lt;p style=&quot; margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-size:8pt; font-weight:600;&quot;&gt;FTNoIR HAT Plugin&lt;br /&gt;by FuraX49&lt;/span&gt;&lt;/p&gt;
+&lt;p style=&quot; margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;a href=&quot;http://hatire.sourceforge.net/&quot;&gt;&lt;span style=&quot; font-size:8pt; font-weight:600; text-decoration: underline; color:#0000ff;&quot;&gt;Manual (external)&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
+ </property>
+ <property name="openExternalLinks">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
</layout>
</widget>
</widget>
diff --git a/ftnoir_tracker_hatire/ftnoir_tracker_hat.cpp b/ftnoir_tracker_hatire/ftnoir_tracker_hat.cpp
index f902b207..6fef2db0 100644
--- a/ftnoir_tracker_hatire/ftnoir_tracker_hat.cpp
+++ b/ftnoir_tracker_hatire/ftnoir_tracker_hat.cpp
@@ -39,7 +39,6 @@ FTNoIR_Tracker::FTNoIR_Tracker()
HAT.Trans[1]=0;
HAT.Trans[2]=0;
-
// prepare & reserve QByteArray
dataRead.resize(4096);
dataRead.clear();
@@ -47,8 +46,6 @@ FTNoIR_Tracker::FTNoIR_Tracker()
Begin.append((char) 0xAA);
End.append((char) 0x55);
End.append((char) 0x55);
-
- settings.load_ini();
}
FTNoIR_Tracker::~FTNoIR_Tracker()
@@ -64,20 +61,18 @@ FTNoIR_Tracker::~FTNoIR_Tracker()
//send CENTER to Arduino
void FTNoIR_Tracker::notifyCenter() {
- sendcmd(sCmdCenter);
+ sendcmd(static_cast<QString>(settings.CmdCenter).toLatin1());
}
//send ZERO to Arduino
bool FTNoIR_Tracker::notifyZeroed() {
- sendcmd(sCmdZero);
+ sendcmd(static_cast<QString>(settings.CmdZero).toLatin1());
return true;
}
-
-
//send RESET to Arduino
void FTNoIR_Tracker::reset() {
- sendcmd(sCmdReset);
+ sendcmd(static_cast<QString>(settings.CmdReset).toLatin1());
}
@@ -266,39 +261,91 @@ void FTNoIR_Tracker::StopTracker( bool exit )
#else
void FTNoIR_Tracker::StartTracker(QFrame*)
{
+ static const int databits_lookup[] = {
+ QSerialPort::Data5,
+ QSerialPort::Data6,
+ QSerialPort::Data7,
+ QSerialPort::Data8,
+ QSerialPort::UnknownDataBits
+ };
+
+ struct Local {
+ static int idx(int max, int value)
+ {
+ if (value < 0)
+ return 0;
+ if (max > value)
+ return value;
+ return max - 1;
+ }
+ };
+
+ static const int parity_lookup[] = {
+ QSerialPort::NoParity,
+ QSerialPort::EvenParity,
+ QSerialPort::OddParity,
+ QSerialPort::SpaceParity,
+ QSerialPort::MarkParity,
+ QSerialPort::UnknownParity
+ };
+
+ static const int stopbits_lookup[] = {
+ QSerialPort::OneStop,
+ QSerialPort::OneAndHalfStop,
+ QSerialPort::TwoStop,
+ QSerialPort::UnknownStopBits
+ };
+
+ static const int flowctl_lookup[] = {
+ QSerialPort::NoFlowControl,
+ QSerialPort::HardwareControl,
+ QSerialPort::SoftwareControl,
+ };
+
+ static const int baudrate_lookup[] = {
+ QSerialPort::Baud1200,
+ QSerialPort::Baud2400,
+ QSerialPort::Baud4800,
+ QSerialPort::Baud9600,
+ QSerialPort::Baud19200,
+ QSerialPort::Baud38400,
+ QSerialPort::Baud57600,
+ QSerialPort::Baud115200,
+ QSerialPort::UnknownBaud
+ };
+
CptError=0;
dataRead.clear();
frame_cnt=0;
-
- settings.load_ini();
- applysettings(settings);
ComPort = new QSerialPort(this);
- ComPort->setPortName(sSerialPortName);
- if (ComPort->open(QIODevice::ReadWrite ) == true) {
+ {
+ ComPort->setPortName(QSerialPortInfo::availablePorts().value(settings.SerialPortName).portName());
+ }
+ if (ComPort->open(QIODevice::ReadWrite ) == true) {
connect(ComPort, SIGNAL(readyRead()), this, SLOT(SerialRead()));
if (
- ComPort->setBaudRate((QSerialPort::BaudRate)iBaudRate)
- && ComPort->setDataBits((QSerialPort::DataBits)iDataBits)
- && ComPort->setParity((QSerialPort::Parity)iParity)
- && ComPort->setStopBits((QSerialPort::StopBits)iStopBits)
- && ComPort->setFlowControl((QSerialPort::FlowControl)iFlowControl)
+ ComPort->setBaudRate(baudrate_lookup[Local::idx(8, settings.pBaudRate)])
+ && ComPort->setDataBits((QSerialPort::DataBits)databits_lookup[Local::idx(4, settings.pDataBits)])
+ && ComPort->setParity((QSerialPort::Parity)parity_lookup[Local::idx(5, settings.pParity)])
+ && ComPort->setStopBits((QSerialPort::StopBits)stopbits_lookup[Local::idx(3, settings.pStopBits)])
+ && ComPort->setFlowControl((QSerialPort::FlowControl)flowctl_lookup[Local::idx(3, settings.pFlowControl)])
&& ComPort->clear(QSerialPort::AllDirections)
- && ComPort->setDataErrorPolicy(QSerialPort::IgnorePolicy)
- ) {
+ && ComPort->setDataErrorPolicy(QSerialPort::IgnorePolicy)
+ ){
// Wait init arduino sequence
- for (int i = 1; i <=iDelayInit; i+=50) {
+ for (int i = 1; i <=settings.DelayInit; i+=50) {
if (ComPort->waitForReadyRead(50)) break;
}
- sendcmd(sCmdInit);
+ sendcmd(static_cast<QString>(settings.CmdInit).toLatin1());
// Wait init MPU sequence
- for (int i = 1; i <=iDelayStart; i+=50) {
+ for (int i = 1; i <=settings.DelayStart; i+=50) {
if (ComPort->waitForReadyRead(50)) break;
}
// Send START cmd to IMU
- sendcmd(sCmdStart);
+ sendcmd(static_cast<QString>(settings.CmdStart).toLatin1());
// Wait start MPU sequence
- for (int i = 1; i <=iDelaySeq; i+=50) {
+ for (int i = 1; i <=settings.DelaySeq; i+=50) {
if (ComPort->waitForReadyRead(50)) break;
}
} else {
@@ -329,7 +376,7 @@ void FTNoIR_Tracker::GetHeadPoseData(THeadPoseData *data)
while (dataRead.length()>=30) {
if ((dataRead.startsWith(Begin) && ( dataRead.mid(28,2)==End )) ) { // .Begin==0xAAAA .End==0x5555
QDataStream datastream(dataRead.left(30));
- if (bBigEndian) datastream.setByteOrder(QDataStream::BigEndian );
+ if (settings.BigEndian) datastream.setByteOrder(QDataStream::BigEndian );
else datastream.setByteOrder(QDataStream::LittleEndian );
datastream>>ArduinoData;
frame_cnt++;
@@ -356,137 +403,55 @@ void FTNoIR_Tracker::GetHeadPoseData(THeadPoseData *data)
CptError=0;
return;
}
-#ifdef OPENTRACK_API
data[frame_cnt] = (long) HAT.Code;
- if (bEnableYaw) {
- if (bInvertYaw ) data[Yaw] = (double) HAT.Rot[iYawAxe] * -1.0f;
- else data[Yaw] = (double) HAT.Rot[iYawAxe];
+ struct Fun {
+ static int clamp3(int foo)
+ {
+ if (foo > 2)
+ return 2;
+ if (foo < 0)
+ return 0;
+ return foo;
+ }
+ };
+
+ if (settings.EnableYaw) {
+ if (settings.InvertYaw) data[Yaw] = (double) HAT.Rot[Fun::clamp3(settings.YawAxe)] * -1.0f;
+ else data[Yaw] = (double) HAT.Rot[Fun::clamp3(settings.YawAxe)];
}
- if (bEnablePitch) {
- if (bInvertPitch) data[Pitch] = (double) HAT.Rot[iPitchAxe] * -1.0f;
- else data[Pitch] = (double) HAT.Rot[iPitchAxe];
+ if (settings.EnablePitch) {
+ if (settings.InvertPitch) data[Pitch] = (double) HAT.Rot[Fun::clamp3(settings.PitchAxe)] * -1.0f;
+ else data[Pitch] = (double) HAT.Rot[Fun::clamp3(settings.InvertPitch)];
}
- if (bEnableRoll) {
- if (bInvertRoll) data[Roll] = (double) HAT.Rot[iRollAxe] * -1.0f;
- else data[Roll] = (double) HAT.Rot[iRollAxe];
+ if (settings.EnableRoll) {
+ if (settings.InvertRoll) data[Roll] = (double) HAT.Rot[Fun::clamp3(settings.RollAxe)] * -1.0f;
+ else data[Roll] = (double) HAT.Rot[Fun::clamp3(settings.RollAxe)];
}
- if (bEnableX) {
- if (bInvertX) data[TX] =(double) HAT.Trans[iXAxe]* -1.0f;
- else data[TX] = HAT.Trans[iXAxe];
+ if (settings.EnableX) {
+ if (settings.InvertX) data[TX] =(double) HAT.Trans[Fun::clamp3(settings.XAxe)]* -1.0f;
+ else data[TX] = HAT.Trans[Fun::clamp3(settings.XAxe)];
}
- if (bEnableY) {
- if (bInvertY) data[TY] =(double) HAT.Trans[iYAxe]* -1.0f;
- else data[TY] = HAT.Trans[iYAxe];
+ if (settings.EnableY) {
+ if (settings.InvertY) data[TY] =(double) HAT.Trans[Fun::clamp3(settings.YAxe)]* -1.0f;
+ else data[TY] = HAT.Trans[Fun::clamp3(settings.YAxe)];
}
- if (bEnableZ) {
- if (bInvertZ) data[TZ] = HAT.Trans[iZAxe]* -1.0f;
- else data[TZ] = HAT.Trans[iZAxe];
+ if (settings.EnableZ) {
+ if (settings.InvertZ) data[TZ] = HAT.Trans[Fun::clamp3(settings.ZAxe)]* -1.0f;
+ else data[TZ] = HAT.Trans[Fun::clamp3(settings.ZAxe)];
}
-#else
- data->frame_number = (long) HAT.Code;
-
- if (bEnableYaw) {
- if (bInvertYaw ) data->yaw = (double) HAT.Rot[iYawAxe] * -1.0f;
- else data->yaw = (double) HAT.Rot[iYawAxe];
- }
-
- if (bEnablePitch) {
- if (bInvertPitch)data->pitch = (double) HAT.Rot[iPitchAxe] * -1.0f;
- else data->pitch = (double) HAT.Rot[iPitchAxe];
- }
-
- if (bEnableRoll) {
- if (bInvertRoll) data->roll = (double) HAT.Rot[iRollAxe] * -1.0f;
- else data->roll = (double) HAT.Rot[iRollAxe];
- }
-
- if (bEnableX) {
- if (bInvertX) data->x = (double) HAT.Trans[iXAxe]* -1.0f;
- else data->x = (double) HAT.Trans[iXAxe];
- }
-
- if (bEnableY) {
- if (bInvertY) data->y = (double) HAT.Trans[iYAxe]* -1.0f;
- else data->y = (double) HAT.Trans[iYAxe];
- }
-
- if (bEnableZ) {
- if (bInvertZ) data->z = (double) HAT.Trans[iZAxe]* -1.0f;
- else data->z = (double) HAT.Trans[iZAxe];
- }
-#endif
-
- // For debug
- //data->x=dataRead.length();
- //data->y=CptError;
}
-
-
-//
-// Apply modification Settings
-//
void FTNoIR_Tracker::applysettings(const TrackerSettings& settings){
QMutexLocker lck(&mutex);
- sSerialPortName= settings.SerialPortName;
-
- bEnableRoll = settings.EnableRoll;
- bEnablePitch = settings.EnablePitch;
- bEnableYaw = settings.EnableYaw;
- bEnableX = settings.EnableX;
- bEnableY = settings.EnableY;
- bEnableZ = settings.EnableZ;
-
- bInvertRoll = settings.InvertRoll;
- bInvertPitch = settings.InvertPitch;
- bInvertYaw = settings.InvertYaw;
- bInvertX = settings.InvertX;
- bInvertY = settings.InvertY;
- bInvertZ = settings.InvertZ;
-
- iRollAxe= settings.RollAxe;
- iPitchAxe= settings.PitchAxe;
- iYawAxe= settings.YawAxe;
- iXAxe= settings.XAxe;
- iYAxe= settings.YAxe;
- iZAxe= settings.ZAxe;
-
- iBaudRate=settings.pBaudRate;
- iDataBits=settings.pDataBits;
- iParity=settings.pParity;
- iStopBits=settings.pStopBits;
- iFlowControl=settings.pFlowControl;
-
- sCmdStart= settings.CmdStart.toLatin1();
- sCmdStop= settings.CmdStop.toLatin1();
- sCmdInit= settings.CmdInit.toLatin1();
- sCmdReset= settings.CmdReset.toLatin1();
- sCmdCenter= settings.CmdCenter.toLatin1();
- sCmdZero= settings.CmdZero.toLatin1();
-
- iDelayInit=settings.DelayInit;
- iDelayStart=settings.DelayStart;
- iDelaySeq=settings.DelaySeq;
-
- bBigEndian=settings.BigEndian;
+ settings.b->reload();
}
-
-
-////////////////////////////////////////////////////////////////////////////////
-// Factory function that creates instances if the Tracker object.
-
-// Export both decorated and undecorated names.
-// GetTracker - Undecorated name, which can be easily used with GetProcAddress
-// Win32 API function.
-// _GetTracker@0 - Common name decoration for __stdcall functions in C language.
-////////////////////////////////////////////////////////////////////////////////
#ifdef OPENTRACK_API
extern "C" FTNOIR_TRACKER_BASE_EXPORT ITracker* CALLING_CONVENTION GetConstructor()
#else
diff --git a/ftnoir_tracker_hatire/ftnoir_tracker_hat.h b/ftnoir_tracker_hatire/ftnoir_tracker_hat.h
index ec1125b9..0dbc4c8c 100644
--- a/ftnoir_tracker_hatire/ftnoir_tracker_hat.h
+++ b/ftnoir_tracker_hatire/ftnoir_tracker_hat.h
@@ -16,7 +16,6 @@
#include <QtSerialPort/QSerialPortInfo>
#include <QMutex>
#include <QMutexLocker>
-#include <QSettings>
#define VER_FILEVERSION_STR "Version 2.0.7\0"
@@ -27,15 +26,8 @@ public:
FTNoIR_Tracker();
~FTNoIR_Tracker();
-#ifdef OPENTRACK_API
virtual void StartTracker(QFrame*);
virtual void GetHeadPoseData(double* data);
-#else
- void Initialize( QFrame *videoframe );
- virtual void StartTracker(HWND parent_window);
- virtual void StopTracker(bool exit);
- virtual bool GetHeadPoseData(THeadPoseData *data);
-#endif
void applysettings(const TrackerSettings& settings);
void notifyCenter();
bool notifyZeroed();
@@ -62,51 +54,7 @@ private:
int frame_cnt;
TrackerSettings settings;
-
- bool bEnableRoll;
- bool bEnablePitch;
- bool bEnableYaw;
- bool bEnableX;
- bool bEnableY;
- bool bEnableZ;
-
- bool bInvertRoll;
- bool bInvertPitch;
- bool bInvertYaw;
- bool bInvertX;
- bool bInvertY;
- bool bInvertZ;
-
- int iRollAxe;
- int iPitchAxe;
- int iYawAxe;
- int iXAxe;
- int iYAxe;
- int iZAxe;
-
- QByteArray sCmdStart;
- QByteArray sCmdStop;
- QByteArray sCmdInit;
- QByteArray sCmdReset;
- QByteArray sCmdCenter;
- QByteArray sCmdZero;
-
- int iDelayInit;
- int iDelayStart;
- int iDelaySeq;
-
- bool bBigEndian;
-
- QString sSerialPortName;
- QSerialPort::BaudRate iBaudRate;
- QSerialPort::DataBits iDataBits;
- QSerialPort::Parity iParity;
- QSerialPort::StopBits iStopBits;
- QSerialPort::FlowControl iFlowControl;
-
int CptError;
-
-
};
diff --git a/ftnoir_tracker_hatire/ftnoir_tracker_hat_dialog.cpp b/ftnoir_tracker_hatire/ftnoir_tracker_hat_dialog.cpp
index 14b6ef0d..2ef75b89 100644
--- a/ftnoir_tracker_hatire/ftnoir_tracker_hat_dialog.cpp
+++ b/ftnoir_tracker_hatire/ftnoir_tracker_hat_dialog.cpp
@@ -37,11 +37,10 @@
//
// Constructor for server-settings-dialog
//
-TrackerControls::TrackerControls() : theTracker(NULL), settingsDirty(false), timer(this)
+TrackerControls::TrackerControls() : theTracker(NULL), timer(this)
{
ui.setupUi( this );
- settings.load_ini();
ui.label_version->setText(VER_FILEVERSION_STR);
@@ -49,21 +48,13 @@ TrackerControls::TrackerControls() : theTracker(NULL), settingsDirty(false), tim
ui.cbSerialPort->clear();
foreach (QSerialPortInfo PortInfo , QSerialPortInfo::availablePorts() ) {
ui.cbSerialPort->addItem(PortInfo.portName());
- }
-
+ }
// Stop if no SerialPort dispo
if (ui.cbSerialPort->count()<1) {
QMessageBox::critical(this,"FaceTrackNoIR Error", "No SerialPort avaible");
} else {
-
- int indxport =ui.cbSerialPort->findText(settings.SerialPortName,Qt::MatchExactly );
- if (indxport!=-1) {
- ui.cbSerialPort->setCurrentIndex(indxport);
- } else {
- QMessageBox::warning(this,"FaceTrackNoIR Error", "Selected SerialPort modified");
- ui.cbSerialPort-> setCurrentIndex(indxport);
- }
+ ui.cbSerialPort->setCurrentIndex(settings.SerialPortName);
}
// Serial config
ui.QCB_Serial_baudRate->clear();
@@ -72,122 +63,79 @@ TrackerControls::TrackerControls() : theTracker(NULL), settingsDirty(false), tim
ui.QCB_Serial_baudRate->addItem(QLatin1String("38400"),QSerialPort::Baud38400);
ui.QCB_Serial_baudRate->addItem(QLatin1String("57600"),QSerialPort:: Baud57600);
ui.QCB_Serial_baudRate->addItem(QLatin1String("115200"),QSerialPort::Baud115200);
- ui.QCB_Serial_baudRate->setCurrentIndex(ui.QCB_Serial_baudRate->findData(settings.pBaudRate));
ui.QCB_Serial_dataBits->clear();
ui.QCB_Serial_dataBits->addItem(QLatin1String("5"), QSerialPort::Data5);
ui.QCB_Serial_dataBits->addItem(QLatin1String("6"), QSerialPort::Data6);
ui.QCB_Serial_dataBits->addItem(QLatin1String("7"), QSerialPort::Data7);
ui.QCB_Serial_dataBits->addItem(QLatin1String("8"), QSerialPort::Data8);
- ui.QCB_Serial_dataBits->setCurrentIndex(ui.QCB_Serial_dataBits->findData(settings.pDataBits));
ui.QCB_Serial_parity->clear();
ui.QCB_Serial_parity->addItem(QLatin1String("None"), QSerialPort::NoParity);
ui.QCB_Serial_parity->addItem(QLatin1String("Even"), QSerialPort::EvenParity);
ui.QCB_Serial_parity->addItem(QLatin1String("Odd"), QSerialPort::OddParity);
- ui.QCB_Serial_parity->addItem(QLatin1String("Mark"), QSerialPort::MarkParity);
ui.QCB_Serial_parity->addItem(QLatin1String("Space"), QSerialPort::SpaceParity);
- ui.QCB_Serial_parity->setCurrentIndex(ui.QCB_Serial_parity->findData(settings.pParity));
+ ui.QCB_Serial_parity->addItem(QLatin1String("Mark"), QSerialPort::MarkParity);
ui.QCB_Serial_stopBits->clear();
- ui.QCB_Serial_stopBits->addItem(QLatin1String("1"), QSerialPort::OneStop);
- ui.QCB_Serial_stopBits->addItem(QLatin1String("1.5"), QSerialPort::OneAndHalfStop);
- ui.QCB_Serial_stopBits->addItem(QLatin1String("2"), QSerialPort::TwoStop);
- ui.QCB_Serial_stopBits->setCurrentIndex(ui.QCB_Serial_stopBits->findData(settings.pStopBits));
+ ui.QCB_Serial_stopBits->addItem(QLatin1String("1"));
+ ui.QCB_Serial_stopBits->addItem(QLatin1String("1.5"));
+ ui.QCB_Serial_stopBits->addItem(QLatin1String("2"));
ui.QCB_Serial_flowControl->clear();
- ui.QCB_Serial_flowControl->addItem(QLatin1String("None"), QSerialPort::NoFlowControl);
- ui.QCB_Serial_flowControl->addItem(QLatin1String("RTS/CTS"), QSerialPort::HardwareControl);
- ui.QCB_Serial_flowControl->addItem(QLatin1String("XON/XOFF"), QSerialPort::SoftwareControl);
- ui.QCB_Serial_flowControl->setCurrentIndex(ui.QCB_Serial_flowControl->findData(settings.pFlowControl));
-
-
- ui.chkEnableRoll->setChecked(settings.EnableRoll);
- ui.chkEnablePitch->setChecked(settings.EnablePitch);
- ui.chkEnableYaw->setChecked(settings.EnableYaw);
- ui.chkEnableX->setChecked(settings.EnableX);
- ui.chkEnableY->setChecked(settings.EnableY);
- ui.chkEnableZ->setChecked(settings.EnableZ);
-
- ui.chkInvertRoll->setChecked(settings.InvertRoll);
- ui.chkInvertPitch->setChecked(settings.InvertPitch);
- ui.chkInvertYaw->setChecked(settings.InvertYaw);
- ui.chkInvertX->setChecked(settings.InvertX);
- ui.chkInvertY->setChecked(settings.InvertY);
- ui.chkInvertZ->setChecked(settings.InvertZ);
-
-
- ui.cb_roll->setCurrentIndex(settings.RollAxe);
- ui.cb_pitch->setCurrentIndex(settings.PitchAxe);
- ui.cb_yaw->setCurrentIndex(settings.YawAxe);
- ui.cb_x->setCurrentIndex(settings.XAxe);
- ui.cb_y->setCurrentIndex(settings.YAxe);
- ui.cb_z->setCurrentIndex(settings.ZAxe);
-
- ui.le_cmd_start->setText(settings.CmdStart);
- ui.le_cmd_stop->setText(settings.CmdStop);
- ui.le_cmd_init->setText(settings.CmdInit);
- ui.le_cmd_reset->setText(settings.CmdReset);
- ui.le_cmd_center->setText(settings.CmdCenter);
- ui.le_cmd_zero->setText(settings.CmdZero);
-
- ui.spb_BeforeInit->setValue(settings.DelayInit);
- ui.spb_BeforeStart->setValue(settings.DelayStart);
- ui.spb_AfterStart->setValue(settings.DelaySeq);
-
- ui.cb_Endian->setChecked(settings.BigEndian);
-
+ ui.QCB_Serial_flowControl->addItem(QLatin1String("None"));
+ ui.QCB_Serial_flowControl->addItem(QLatin1String("RTS/CTS"));
+ ui.QCB_Serial_flowControl->addItem(QLatin1String("XON/XOFF"));
+
+ tie_setting(settings.EnableRoll, ui.chkEnableRoll);
+ tie_setting(settings.EnablePitch, ui.chkEnablePitch);
+ tie_setting(settings.EnableYaw, ui.chkEnableYaw);
+ tie_setting(settings.EnableX, ui.chkEnableX);
+ tie_setting(settings.EnableY, ui.chkEnableY);
+ tie_setting(settings.EnableZ, ui.chkEnableZ);
+
+ tie_setting(settings.InvertRoll, ui.chkInvertRoll);
+ tie_setting(settings.InvertPitch, ui.chkInvertPitch);
+ tie_setting(settings.InvertYaw, ui.chkInvertYaw);
+ tie_setting(settings.InvertX, ui.chkInvertX);
+ tie_setting(settings.InvertY, ui.chkInvertY);
+ tie_setting(settings.InvertZ, ui.chkInvertZ);
+
+ tie_setting(settings.RollAxe, ui.cb_roll);
+ tie_setting(settings.RollAxe, ui.cb_roll);
+ tie_setting(settings.RollAxe, ui.cb_roll);
+
+ tie_setting(settings.XAxe, ui.cb_x);
+ tie_setting(settings.YAxe, ui.cb_y);
+ tie_setting(settings.ZAxe, ui.cb_z);
+
+ tie_setting(settings.CmdStart, ui.le_cmd_start);
+ tie_setting(settings.CmdStop, ui.le_cmd_stop);
+ tie_setting(settings.CmdInit, ui.le_cmd_init);
+ tie_setting(settings.CmdReset, ui.le_cmd_reset);
+ tie_setting(settings.CmdCenter, ui.le_cmd_center);
+ tie_setting(settings.CmdZero, ui.le_cmd_zero);
+
+ tie_setting(settings.DelayInit, ui.spb_BeforeInit);
+ tie_setting(settings.DelayStart, ui.spb_BeforeStart);
+ tie_setting(settings.DelaySeq, ui.spb_AfterStart);
+
+ tie_setting(settings.BigEndian, ui.cb_Endian);
+
+ tie_setting(settings.pBaudRate, ui.QCB_Serial_baudRate);
+ tie_setting(settings.pDataBits, ui.QCB_Serial_dataBits);
+ tie_setting(settings.pParity, ui.QCB_Serial_parity);
+ tie_setting(settings.pStopBits, ui.QCB_Serial_stopBits);
+ tie_setting(settings.pFlowControl, ui.QCB_Serial_flowControl);
+
+ tie_setting(settings.SerialPortName, ui.cbSerialPort);
// Connect Qt signals to member-functions
connect(ui.btnOK, SIGNAL(clicked()), this, SLOT(doOK()));
connect(ui.btnCancel, SIGNAL(clicked()), this, SLOT(doCancel()));
connect(ui.btnSave, SIGNAL(clicked()), this, SLOT(doSave()));
-
- connect(ui.cbSerialPort, SIGNAL(currentIndexChanged(QString)), this,SLOT(set_mod_port(QString)) );
-
- connect( ui.chkEnableRoll,SIGNAL(toggled(bool)), this,SLOT(set_ena_roll(bool)) );
- connect( ui.chkEnablePitch,SIGNAL(toggled(bool)), this,SLOT(set_ena_pitch(bool)) );
- connect( ui.chkEnableYaw,SIGNAL(toggled(bool)), this,SLOT(set_ena_yaw(bool)) );
- connect( ui.chkEnableX,SIGNAL(toggled(bool)), this,SLOT(set_ena_x(bool)) );
- connect( ui.chkEnableY,SIGNAL(toggled(bool)), this,SLOT(set_ena_y(bool)) );
- connect( ui.chkEnableZ,SIGNAL(toggled(bool)), this,SLOT(set_ena_z(bool)) );
-
- connect( ui.chkInvertRoll,SIGNAL(toggled(bool)), this,SLOT(set_inv_roll(bool)) );
- connect( ui.chkInvertPitch,SIGNAL(toggled(bool)), this,SLOT(set_inv_pitch(bool)) );
- connect( ui.chkInvertYaw,SIGNAL(toggled(bool)), this,SLOT(set_inv_yaw(bool)) );
- connect( ui.chkInvertX,SIGNAL(toggled(bool)), this,SLOT(set_inv_x(bool)) );
- connect( ui.chkInvertY,SIGNAL(toggled(bool)), this,SLOT(set_inv_y(bool)) );
- connect( ui.chkInvertZ,SIGNAL(toggled(bool)), this,SLOT(set_inv_z(bool)) );
-
- connect(ui.cb_roll, SIGNAL(currentIndexChanged(int)), this,SLOT(set_rot_roll(int)));
- connect(ui.cb_pitch, SIGNAL(currentIndexChanged(int)),this,SLOT(set_rot_pitch(int)));
- connect(ui.cb_yaw, SIGNAL(currentIndexChanged(int)), this,SLOT(set_rot_yaw(int)));
- connect(ui.cb_x, SIGNAL(currentIndexChanged(int)), this,SLOT(set_acc_x(int)));
- connect(ui.cb_y, SIGNAL(currentIndexChanged(int)), this,SLOT(set_acc_y(int)));
- connect(ui.cb_z, SIGNAL(currentIndexChanged(int)), this,SLOT(set_acc_z(int)));
-
- connect(ui.le_cmd_start, SIGNAL(textEdited (QString )), this,SLOT(set_cmd_start(QString)));
- connect(ui.le_cmd_stop, SIGNAL(textEdited ( QString )), this,SLOT(set_cmd_stop(QString)));
- connect(ui.le_cmd_init, SIGNAL(textChanged ( QString )), this,SLOT(set_cmd_init(QString)));
- connect(ui.le_cmd_reset, SIGNAL(textChanged ( QString )), this,SLOT(set_cmd_reset(QString)));
- connect(ui.le_cmd_center, SIGNAL(textChanged ( QString )),this,SLOT(set_cmd_center(QString)));
- connect(ui.le_cmd_zero, SIGNAL(textChanged ( QString )),this,SLOT(set_cmd_zero(QString)));
-
- connect(ui.spb_BeforeInit, SIGNAL(valueChanged ( int )), this,SLOT(set_DelayInit(int)));
- connect(ui.spb_BeforeStart, SIGNAL(valueChanged ( int )), this,SLOT(set_DelayStart(int)));
- connect(ui.spb_AfterStart, SIGNAL(valueChanged ( int )), this,SLOT(set_DelaySeq(int)));
-
- connect( ui.cb_Endian,SIGNAL(toggled(bool)), this,SLOT(set_endian(bool)) );
-
-
- connect(ui.QCB_Serial_baudRate, SIGNAL(currentIndexChanged(int)), this,SLOT(set_mod_baud(int)) );
- connect(ui.QCB_Serial_dataBits, SIGNAL(currentIndexChanged(int)), this,SLOT(set_mod_dataBits(int)) );
- connect(ui.QCB_Serial_parity, SIGNAL(currentIndexChanged(int)), this,SLOT(set_mod_parity(int)) );
- connect(ui.QCB_Serial_stopBits, SIGNAL(currentIndexChanged(int)), this,SLOT(set_mod_stopBits(int)) );
- connect(ui.QCB_Serial_flowControl, SIGNAL(currentIndexChanged(int)), this,SLOT(set_mod_flowControl(int)) );
-
connect(ui.btnReset, SIGNAL(clicked()), this, SLOT(doReset()));
connect(ui.btnCenter, SIGNAL(clicked()), this, SLOT(doCenter()));
connect(ui.btnZero, SIGNAL(clicked()), this, SLOT(doZero()));
@@ -196,37 +144,8 @@ TrackerControls::TrackerControls() : theTracker(NULL), settingsDirty(false), tim
connect(ui.btn_icone, SIGNAL(clicked()), this, SLOT(doSerialInfo()));
connect(&timer,SIGNAL(timeout()), this,SLOT(poll_tracker_info()));
-
-}
-
-//
-// Destructor for server-dialog
-//
-TrackerControls::~TrackerControls() {
-}
-
-//
-// Initialize tracker-client-dialog
-//
-void TrackerControls::Initialize(QWidget *parent) {
- QPoint offsetpos(100, 100);
- if (parent) {
- this->move(parent->pos() + offsetpos);
- }
- show();
}
-
-//
-// Apply online settings to tracker
-//
-void TrackerControls::settings_changed()
-{
- settingsDirty = true;
- if (theTracker) theTracker->applysettings(settings);
-}
-
-
//
// Center asked to ARDUINO
//
@@ -299,8 +218,9 @@ void TrackerControls::WriteMsgInfo(const QByteArray &MsgInfo)
void TrackerControls::doSave() {
- settingsDirty=false;
- settings.save_ini();
+ settings.b->save();
+ if (theTracker)
+ theTracker->applysettings(settings);
}
@@ -308,8 +228,9 @@ void TrackerControls::doSave() {
// OK clicked on server-dialog
//
void TrackerControls::doOK() {
- settingsDirty=false;
- settings.save_ini();
+ settings.b->save();
+ if (theTracker)
+ theTracker->applysettings(settings);
this->close();
}
@@ -320,14 +241,15 @@ void TrackerControls::doCancel() {
//
// Ask if changed Settings should be saved
//
- if (settingsDirty) {
- int ret = QMessageBox::question ( this, "Settings have changed", "Do you want to save the settings?", QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel, QMessageBox::Discard );
+ if (settings.b->modifiedp()) {
+ int ret = QMessageBox::question ( this, "Settings have changed", "Do you want to save the settings?", QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel);
switch (ret) {
case QMessageBox::Save:
- settings.save_ini();
+ settings.b->save();
close();
break;
case QMessageBox::Discard:
+ settings.b->revert();
close();
break;
case QMessageBox::Cancel:
@@ -348,7 +270,7 @@ void TrackerControls::registerTracker(ITracker *tracker) {
theTracker = static_cast<FTNoIR_Tracker*>(tracker);
connect(theTracker, SIGNAL(sendMsgInfo(QByteArray)),this , SLOT(WriteMsgInfo(QByteArray)));
- if (isVisible() && settingsDirty) theTracker->applysettings(settings);
+ if (isVisible() && settings.b->modifiedp()) theTracker->applysettings(settings);
ui.cbSerialPort->setEnabled(false);
ui.pteINFO->clear();
@@ -367,16 +289,6 @@ void TrackerControls::unRegisterTracker() {
ui.lab_vtps->setText("");
}
-
-
-
-////////////////////////////////////////////////////////////////////////////////
-// Factory function that creates instances if the Tracker-settings dialog object.
-
-// Export both decorated and undecorated names.
-// GetTrackerDialog - Undecorated name, which can be easily used with GetProcAddress
-// Win32 API function.
-// _GetTrackerDialog@0 - Common name decoration for __stdcall functions in C language.
#ifdef OPENTRACK_API
extern "C" FTNOIR_TRACKER_BASE_EXPORT ITrackerDialog* CALLING_CONVENTION GetDialog( )
#else
diff --git a/ftnoir_tracker_hatire/ftnoir_tracker_hat_dialog.h b/ftnoir_tracker_hatire/ftnoir_tracker_hat_dialog.h
index e413ded6..fe16e5e8 100644
--- a/ftnoir_tracker_hatire/ftnoir_tracker_hat_dialog.h
+++ b/ftnoir_tracker_hatire/ftnoir_tracker_hat_dialog.h
@@ -21,63 +21,18 @@ class TrackerControls: public QWidget, public ITrackerDialog
Q_OBJECT
public:
explicit TrackerControls();
- virtual ~TrackerControls();
- void Initialize(QWidget *parent) virt_override;
void registerTracker(ITracker *tracker) virt_override;
void unRegisterTracker() virt_override;
-
private:
Ui::UIHATControls ui;
FTNoIR_Tracker *theTracker;
QTime last_time;
-public slots:
+public slots:
void WriteMsgInfo(const QByteArray &MsgInfo);
protected slots:
- void set_mod_port(const QString & val) { settings.SerialPortName =val; settings_changed(); }
- void set_ena_roll(bool val) { settings.EnableRoll = val; settings_changed(); }
- void set_ena_pitch(bool val) { settings.EnablePitch = val; settings_changed(); }
- void set_ena_yaw(bool val) { settings.EnableYaw = val; settings_changed(); }
- void set_ena_x(bool val) { settings.EnableX = val; settings_changed(); }
- void set_ena_y(bool val) { settings.EnableY = val; settings_changed(); }
- void set_ena_z(bool val) { settings.EnableZ = val; settings_changed(); }
-
- void set_inv_roll(bool val) { settings.InvertRoll = val; settings_changed(); }
- void set_inv_pitch(bool val) { settings.InvertPitch = val; settings_changed(); }
- void set_inv_yaw(bool val) { settings.InvertYaw = val; settings_changed(); }
- void set_inv_x(bool val) { settings.InvertX = val; settings_changed(); }
- void set_inv_y(bool val) { settings.InvertY = val; settings_changed(); }
- void set_inv_z(bool val) { settings.InvertZ = val; settings_changed(); }
-
-
- void set_rot_roll(int val) { settings.RollAxe = val; settings_changed(); }
- void set_rot_pitch(int val) { settings.PitchAxe = val; settings_changed(); }
- void set_rot_yaw(int val) { settings.YawAxe = val; settings_changed(); }
- void set_acc_x(int val) { settings.XAxe = val; settings_changed(); }
- void set_acc_y(int val) { settings.YAxe = val; settings_changed(); }
- void set_acc_z(int val) { settings.ZAxe = val; settings_changed(); }
-
- void set_cmd_start(const QString &val) { settings.CmdStart = val; settings_changed(); }
- void set_cmd_stop(const QString &val) { settings.CmdStop = val; settings_changed(); }
- void set_cmd_init(const QString &val) { settings.CmdInit = val; settings_changed(); }
- void set_cmd_reset(const QString &val) { settings.CmdReset = val; settings_changed(); }
- void set_cmd_center(const QString &val) { settings.CmdCenter = val; settings_changed(); }
- void set_cmd_zero(const QString &val) { settings.CmdZero = val; settings_changed(); }
-
- void set_DelayInit(int val) { settings.DelayInit = val; settings_changed(); }
- void set_DelayStart(int val) { settings.DelayStart = val; settings_changed(); }
- void set_DelaySeq(int val) { settings.DelaySeq = val; settings_changed(); }
-
- void set_endian(bool val) { settings.BigEndian = val; settings_changed(); }
-
- void set_mod_baud(int val) { settings.pBaudRate = static_cast<QSerialPort::BaudRate>(ui.QCB_Serial_baudRate->itemData(val).toInt()) ; settings_changed(); }
- void set_mod_dataBits(int val) { settings.pDataBits = static_cast<QSerialPort::DataBits>(ui.QCB_Serial_dataBits->itemData(val).toInt()) ; settings_changed(); }
- void set_mod_parity(int val) { settings.pParity = static_cast<QSerialPort::Parity>(ui.QCB_Serial_parity->itemData(val).toInt()) ; settings_changed(); }
- void set_mod_stopBits(int val) { settings.pStopBits = static_cast<QSerialPort::StopBits>(ui.QCB_Serial_stopBits->itemData(val).toInt()); settings_changed(); }
- void set_mod_flowControl(int val) { settings.pFlowControl = static_cast<QSerialPort::FlowControl>(ui.QCB_Serial_flowControl->itemData(val).toInt()) ; settings_changed(); }
-
- void doOK();
+ void doOK();
void doCancel();
void doSave();
void doReset();
@@ -88,8 +43,6 @@ protected slots:
void doSerialInfo();
protected:
- bool settingsDirty;
- void settings_changed();
TrackerSettings settings;
QTimer timer;
};
diff --git a/ftnoir_tracker_hatire/ftnoir_tracker_hat_settings.cpp b/ftnoir_tracker_hatire/ftnoir_tracker_hat_settings.cpp
deleted file mode 100644
index 0be912f2..00000000
--- a/ftnoir_tracker_hatire/ftnoir_tracker_hat_settings.cpp
+++ /dev/null
@@ -1,145 +0,0 @@
-/********************************************************************************
-* FaceTrackNoIR This program is a private project of some enthusiastic *
-* gamers from Holland, who don't like to pay much for *
-* head-tracking. *
-* *
-* Copyright (C) 2012 Wim Vriend (Developing) *
-* Ron Hendriks (Researching and Testing) *
-* Homepage: http://facetracknoir.sourceforge.net/home/default.htm *
-* *
-* Copyright (C) 2012 FuraX49 (HAT Tracker plugins) *
-* Homepage: http://hatire.sourceforge.net *
-* *
-* This program is free software; you can redistribute it and/or modify it *
-* under the terms of the GNU General Public License as published by the *
-* Free Software Foundation; either version 3 of the License, or (at your *
-* option) any later version. *
-* *
-* This program is distributed in the hope that it will be useful, but *
-* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY *
-* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for *
-* more details. *
-* *
-* You should have received a copy of the GNU General Public License along *
-* with this program; if not, see <http://www.gnu.org/licenses/>. *
-* *
-********************************************************************************/
-#include <QCoreApplication>
-#include <QSettings>
-#include <QVariant>
-
-#include "ftnoir_tracker_hat_settings.h"
-
-void TrackerSettings::load_ini()
-{
- QSettings settings("opentrack"); // Registry settings (in HK_USER)
- QString currentFile = settings.value( "SettingsFile", QCoreApplication::applicationDirPath() + "/Settings/default.ini" ).toString();
- QSettings iniFile( currentFile, QSettings::IniFormat ); // Application settings (in INI-file)
-
- iniFile.beginGroup( "HAT" );
-
- SerialPortName=iniFile.value ( "PortName" ).toString();
-
- EnableRoll = iniFile.value( "EnableRoll", 1 ).toBool();
- EnablePitch = iniFile.value( "EnablePitch", 1 ).toBool();
- EnableYaw = iniFile.value( "EnableYaw", 1 ).toBool();
- EnableX = iniFile.value( "EnableX", 0 ).toBool();
- EnableY = iniFile.value( "EnableY", 0 ).toBool();
- EnableZ = iniFile.value( "EnableZ", 0 ).toBool();
-
-
- InvertRoll = iniFile.value( "InvertRoll", 1 ).toBool();
- InvertPitch = iniFile.value( "InvertPitch", 1 ).toBool();
- InvertYaw = iniFile.value( "InvertYaw", 1 ).toBool();
- InvertX = iniFile.value( "InvertX", 0 ).toBool();
- InvertY = iniFile.value( "InvertY", 0 ).toBool();
- InvertZ = iniFile.value( "InvertZ", 0 ).toBool();
-
-
- RollAxe=iniFile.value("RollAxe",1).toInt();
- PitchAxe=iniFile.value("PitchAxe",2).toInt();
- YawAxe=iniFile.value("YawAxe",0).toInt();
- XAxe=iniFile.value("XAxe",1).toInt();
- YAxe=iniFile.value("YAxe",2).toInt();
- ZAxe=iniFile.value("ZAxe",0).toInt();
-
-
- CmdStart=iniFile.value ( "CmdStart").toString();
- CmdStop=iniFile.value ( "CmdStop" ).toString();
- CmdInit=iniFile.value ( "CmdInit" ).toString();
- CmdReset=iniFile.value ( "CmdReset" ).toString();
- CmdCenter=iniFile.value ( "CmdCenter" ).toString();
- CmdZero=iniFile.value ( "CmdZero" ).toString();
-
- DelayInit=iniFile.value("DelayInit",0).toInt();
- DelayStart=iniFile.value("DelayStart",0).toInt();
- DelaySeq=iniFile.value("DelaySeq",0).toInt();
-
- BigEndian=iniFile.value("BigEndian",0).toBool();
-
-
- pBaudRate=static_cast<QSerialPort::BaudRate>(iniFile.value("BaudRate",QSerialPort::Baud115200).toInt());
- pDataBits=static_cast<QSerialPort::DataBits>(iniFile.value("DataBits",QSerialPort::Data8).toInt());
- pParity=static_cast<QSerialPort::Parity>(iniFile.value("Parity",QSerialPort::NoParity).toInt());
- pStopBits=static_cast<QSerialPort::StopBits>(iniFile.value("StopBits",QSerialPort::OneStop).toInt());
- pFlowControl=static_cast<QSerialPort::FlowControl>(iniFile.value("FlowControl",QSerialPort::HardwareControl).toInt());
-
- iniFile.endGroup();
-}
-
-
-void TrackerSettings::save_ini() const
-{
-
- QSettings settings("opentrack"); // Registry settings (in HK_USER)
- QString currentFile = settings.value( "SettingsFile", QCoreApplication::applicationDirPath() + "/Settings/default.ini" ).toString();
- QSettings iniFile( currentFile, QSettings::IniFormat ); // Application settings (in INI-file)
-
- iniFile.beginGroup ( "HAT" );
-
- iniFile.setValue ( "PortName",SerialPortName );
-
- iniFile.setValue( "EnableRoll", EnableRoll );
- iniFile.setValue( "EnablePitch", EnablePitch );
- iniFile.setValue( "EnableYaw", EnableYaw );
- iniFile.setValue( "EnableX", EnableX );
- iniFile.setValue( "EnableY", EnableY );
- iniFile.setValue( "EnableZ", EnableZ );
-
- iniFile.setValue( "InvertRoll", InvertRoll );
- iniFile.setValue( "InvertPitch", InvertPitch );
- iniFile.setValue( "InvertYaw", InvertYaw );
- iniFile.setValue( "InvertX", InvertX );
- iniFile.setValue( "InvertY", InvertY );
- iniFile.setValue( "InvertZ", InvertZ );
-
- iniFile.setValue ( "RollAxe", RollAxe );
- iniFile.setValue ( "PitchAxe", PitchAxe );
- iniFile.setValue ( "YawAxe",YawAxe );
- iniFile.setValue ( "XAxe", XAxe );
- iniFile.setValue ( "YAxe", YAxe );
- iniFile.setValue ( "ZAxe", ZAxe );
-
- iniFile.setValue ( "CmdStart",CmdStart.toLatin1());
- iniFile.setValue ( "CmdStop",CmdStop.toLatin1());
- iniFile.setValue ( "CmdInit",CmdInit.toLatin1());
- iniFile.setValue ( "CmdReset",CmdReset.toLatin1());
- iniFile.setValue ( "CmdCenter",CmdCenter.toLatin1() );
- iniFile.setValue ( "CmdZero",CmdZero.toLatin1() );
-
- iniFile.setValue ( "DelayInit",DelayInit);
- iniFile.setValue ( "DelayStart",DelayStart);
- iniFile.setValue ( "DelaySeq",DelaySeq);
-
- iniFile.setValue("BigEndian",BigEndian);
-
- iniFile.setValue("BaudRate",pBaudRate);
- iniFile.setValue("DataBits",pDataBits);
- iniFile.setValue("Parity",pParity);
- iniFile.setValue("StopBits",pStopBits);
- iniFile.setValue("FlowControl",pFlowControl);
-
-
- iniFile.endGroup();
-}
-
diff --git a/ftnoir_tracker_hatire/ftnoir_tracker_hat_settings.h b/ftnoir_tracker_hatire/ftnoir_tracker_hat_settings.h
index 2e84bde8..4c0fcb8d 100644
--- a/ftnoir_tracker_hatire/ftnoir_tracker_hat_settings.h
+++ b/ftnoir_tracker_hatire/ftnoir_tracker_hat_settings.h
@@ -5,61 +5,81 @@
* copyright notice and this permission notice appear in all copies.
*/
-#ifndef FTNOIR_TRACKER_HAT_SETTINGS_H
-#define FTNOIR_TRACKER_HAT_SETTINGS_H
+#pragma once
#include <QtSerialPort/QSerialPort>
+#include "facetracknoir/options.h"
+#include <ftnoir_tracker_base/ftnoir_tracker_types.h>
+using namespace options;
-//-----------------------------------------------------------------------------
struct TrackerSettings
{
-
- void load_ini();
- void save_ini() const;
-
- bool EnableRoll;
- bool EnablePitch;
- bool EnableYaw;
- bool EnableX;
- bool EnableY;
- bool EnableZ;
-
- bool InvertRoll;
- bool InvertPitch;
- bool InvertYaw;
- bool InvertX;
- bool InvertY;
- bool InvertZ;
-
-
- int RollAxe;
- int PitchAxe;
- int YawAxe;
- int XAxe;
- int YAxe;
- int ZAxe;
-
- QString CmdStart;
- QString CmdStop;
- QString CmdInit;
- QString CmdReset;
- QString CmdCenter;
- QString CmdZero;
-
- int DelayInit;
- int DelayStart;
- int DelaySeq;
-
- bool BigEndian;
-
- QString SerialPortName;
- QSerialPort::BaudRate pBaudRate;
- QSerialPort::DataBits pDataBits;
- QSerialPort::Parity pParity;
- QSerialPort::StopBits pStopBits;
- QSerialPort::FlowControl pFlowControl;
-
+ pbundle b;
+ value<bool> EnableRoll,
+ EnablePitch,
+ EnableYaw,
+ EnableX,
+ EnableY,
+ EnableZ,
+ InvertRoll,
+ InvertPitch,
+ InvertYaw,
+ InvertX,
+ InvertY,
+ InvertZ;
+ value<int> RollAxe,
+ PitchAxe,
+ YawAxe,
+ XAxe,
+ YAxe,
+ ZAxe;
+ value<bool> BigEndian;
+ value<QString> CmdStart,
+ CmdStop,
+ CmdInit,
+ CmdReset,
+ CmdCenter,
+ CmdZero;
+ value<int> SerialPortName, DelayInit, DelayStart, DelaySeq;
+ // unfortunately, no way to distinguish this and enum type
+ // hence, string type used -sh
+ value<int> pBaudRate, pDataBits, pParity, pStopBits, pFlowControl;
+ TrackerSettings() :
+ b(bundle("HAT")),
+ EnableRoll(b, "EnableRoll", true),
+ EnablePitch(b, "EnablePitch", true),
+ EnableYaw(b, "EnableYaw", true),
+ EnableX(b, "EnableX", true),
+ EnableY(b, "EnableY", true),
+ EnableZ(b, "EnableZ", true),
+ InvertRoll(b, "InvertRoll", false),
+ InvertPitch(b, "InvertPitch", false),
+ InvertYaw(b, "InvertYaw", false),
+ InvertX(b, "InvertX", false),
+ InvertY(b, "InvertY", false),
+ InvertZ(b, "InvertZ", false),
+ RollAxe(b, "RollAe", 2),
+ PitchAxe(b, "PitchAxe", 1),
+ YawAxe(b, "YawAxe", 0),
+ XAxe(b, "XAxe", 0),
+ YAxe(b, "YAxe", 1),
+ ZAxe(b, "ZAxe", 2),
+ BigEndian(b, "BigEndian", false),
+ CmdStart(b, "CmdStart", ""),
+ CmdStop(b, "CmdStop", ""),
+ CmdInit(b, "CmdInit", ""),
+ CmdReset(b, "CmdReset", ""),
+ CmdCenter(b, "CmdCenter", ""),
+ CmdZero(b, "CmdZero", ""),
+ SerialPortName(b, "PortName", 0),
+ DelayInit(b, "DelayInit", 0),
+ DelayStart(b, "DelayStart", 0),
+ DelaySeq(b, "DelaySeq", 0),
+ pBaudRate(b, "BaudRate", 0),
+ pDataBits(b, "DataBits", 0),
+ pParity(b, "Parity", 0),
+ pStopBits(b, "StopBits", 0),
+ pFlowControl(b, "FlowControl", 0)
+ {
+ }
};
-
-
-#endif //FTNOIR_TRACKER_HAT_SETTINGS_H \ No newline at end of file
diff --git a/ftnoir_tracker_ht/ftnoir_tracker_ht.cpp b/ftnoir_tracker_ht/ftnoir_tracker_ht.cpp
index f9f03fae..1773b018 100644
--- a/ftnoir_tracker_ht/ftnoir_tracker_ht.cpp
+++ b/ftnoir_tracker_ht/ftnoir_tracker_ht.cpp
@@ -88,23 +88,34 @@ static resolution_tuple resolution_choices[] = {
{ 0, 0 }
};
-static void load_settings(ht_config_t* config, Tracker* tracker)
+void Tracker::load_settings(ht_config_t* config)
{
- QSettings settings("opentrack");
- QString currentFile = settings.value( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString();
- QSettings iniFile( currentFile, QSettings::IniFormat );
+ int nframes = 0;
+ switch (static_cast<int>(s.fps))
+ {
+ default:
+ case 0:
+ nframes = 0;
+ break;
+ case 1:
+ nframes = 30;
+ break;
+ case 2:
+ nframes = 60;
+ break;
+ case 3:
+ nframes = 120;
+ break;
+ }
- iniFile.beginGroup( "HT-Tracker" );
config->classification_delay = 500;
- config->field_of_view = iniFile.value("fov", 52).toFloat();
+ config->field_of_view = s.fov;
config->pyrlk_pyramids = 0;
config->pyrlk_win_size_w = config->pyrlk_win_size_h = 21;
config->max_keypoints = 350;
config->keypoint_distance = 3.4;
- //config->force_width = 640;
- //config->force_height = 480;
- config->force_fps = iniFile.value("fps", 0).toInt();
- config->camera_index = iniFile.value("camera-index", -1).toInt();
+ config->force_fps = nframes;
+ config->camera_index = s.camera_idx - 1;
config->ransac_num_iters = 100;
config->ransac_max_reprojection_error = 8;
config->ransac_max_inlier_error = 8;
@@ -112,38 +123,24 @@ static void load_settings(ht_config_t* config, Tracker* tracker)
config->ransac_max_mean_error = 6.5;
config->debug = 0;
config->ransac_min_features = 0.72;
- int res = iniFile.value("resolution", 0).toInt();
+ int res = s.resolution;
if (res < 0 || res >= (int)(sizeof(resolution_choices) / sizeof(resolution_tuple)))
res = 0;
resolution_tuple r = resolution_choices[res];
config->force_width = r.width;
config->force_height = r.height;
config->flandmark_delay = 325;
- qDebug() << "width" << r.width << "height" << r.height;
- if (tracker)
- {
- tracker->enableRX = iniFile.value("enable-rx", true).toBool();
- tracker->enableRY = iniFile.value("enable-ry", true).toBool();
- tracker->enableRZ = iniFile.value("enable-rz", true).toBool();
- tracker->enableTX = iniFile.value("enable-tx", true).toBool();
- tracker->enableTY = iniFile.value("enable-ty", true).toBool();
- tracker->enableTZ = iniFile.value("enable-tz", true).toBool();
- }
-
for (int i = 0; i < 5; i++)
- config->dist_coeffs[i] = iniFile.value(QString("dc%1").arg(i), 0).toDouble();
-
- iniFile.endGroup();
+ config->dist_coeffs[i] = 0;
}
-Tracker::Tracker() : lck_shm(HT_SHM_NAME, HT_MUTEX_NAME, sizeof(ht_shm_t))
+Tracker::Tracker() :
+ lck_shm(HT_SHM_NAME, HT_MUTEX_NAME, sizeof(ht_shm_t)),
+ shm(reinterpret_cast<ht_shm_t*>(lck_shm.mem)),
+ videoWidget(nullptr),
+ layout(nullptr)
{
- videoWidget = NULL;
- layout = NULL;
- enableRX = enableRY = enableRZ = enableTX = enableTY = enableTZ = true;
- shm = (ht_shm_t*) lck_shm.mem;
shm->terminate = 0;
- load_settings(&shm->config, this);
shm->result.filled = false;
}
@@ -174,7 +171,7 @@ void Tracker::StartTracker(QFrame* videoframe)
videoframe->setLayout(layout);
videoWidget->show();
this->layout = layout;
- load_settings(&shm->config, this);
+ load_settings(&shm->config);
shm->frame.channels = shm->frame.width = shm->frame.height = 0;
shm->pause = shm->terminate = shm->running = false;
shm->timer = 0;
@@ -197,19 +194,19 @@ void Tracker::GetHeadPoseData(double *data)
shm->frame.width = 0;
}
if (shm->result.filled) {
- if (enableRX)
+ if (s.enableRX)
data[Yaw] = shm->result.rotx;
- if (enableRY) {
+ if (s.enableRY) {
data[Pitch] = shm->result.roty;
}
- if (enableRZ) {
+ if (s.enableRZ) {
data[Roll] = shm->result.rotz;
}
- if (enableTX)
+ if (s.enableTX)
data[TX] = shm->result.tx;
- if (enableTY)
+ if (s.enableTY)
data[TY] = shm->result.ty;
- if (enableTZ)
+ if (s.enableTZ)
data[TZ] = shm->result.tz;
if (fabs(data[Yaw]) > 60 || fabs(data[Pitch]) > 50 || fabs(data[Roll]) > 40)
{
@@ -242,31 +239,16 @@ void TrackerDll::getIcon(QIcon *icon)
*icon = QIcon(":/images/ht.png");
}
-
-//-----------------------------------------------------------------------------
-//#pragma comment(linker, "/export:GetTrackerDll=_GetTrackerDll@0")
-
extern "C" FTNOIR_TRACKER_BASE_EXPORT Metadata* CALLING_CONVENTION GetMetadata()
{
return new TrackerDll;
}
-//#pragma comment(linker, "/export:GetTracker=_GetTracker@0")
-
extern "C" FTNOIR_TRACKER_BASE_EXPORT ITracker* CALLING_CONVENTION GetConstructor()
{
return new Tracker;
}
-////////////////////////////////////////////////////////////////////////////////
-// Factory function that creates instances if the Tracker-settings dialog object.
-
-// Export both decorated and undecorated names.
-// GetTrackerDialog - Undecorated name, which can be easily used with GetProcAddress
-// Win32 API function.
-// _GetTrackerDialog@0 - Common name decoration for __stdcall functions in C language.
-//#pragma comment(linker, "/export:GetTrackerDialog=_GetTrackerDialog@0")
-
extern "C" FTNOIR_TRACKER_BASE_EXPORT ITrackerDialog* CALLING_CONVENTION GetDialog( )
{
return new TrackerControls;
@@ -275,162 +257,53 @@ extern "C" FTNOIR_TRACKER_BASE_EXPORT ITrackerDialog* CALLING_CONVENTION GetDial
TrackerControls::TrackerControls()
{
ui.setupUi(this);
- setAttribute(Qt::WA_NativeWindow, true);
- connect(ui.cameraName, SIGNAL(currentIndexChanged(int)), this, SLOT(settingChanged(int)));
- connect(ui.cameraFPS, SIGNAL(currentIndexChanged(int)), this, SLOT(settingChanged(int)));
- connect(ui.cameraFOV, SIGNAL(valueChanged(double)), this, SLOT(settingChanged(double)));
- connect(ui.rx, SIGNAL(clicked()), this, SLOT(settingChanged()));
- connect(ui.ry, SIGNAL(clicked()), this, SLOT(settingChanged()));
- connect(ui.rz, SIGNAL(clicked()), this, SLOT(settingChanged()));
- connect(ui.tx, SIGNAL(clicked()), this, SLOT(settingChanged()));
- connect(ui.ty, SIGNAL(clicked()), this, SLOT(settingChanged()));
- connect(ui.tz, SIGNAL(clicked()), this, SLOT(settingChanged()));
- connect(ui.buttonCancel, SIGNAL(clicked()), this, SLOT(doCancel()));
- connect(ui.buttonOK, SIGNAL(clicked()), this, SLOT(doOK()));
- //connect(ui.buttonSettings, SIGNAL(clicked()), this, SLOT(cameraSettings()));
- loadSettings();
- settingsDirty = false;
-}
-
-TrackerControls::~TrackerControls()
-{
-}
-
-void TrackerControls::showEvent(QShowEvent *)
-{
-}
-
-void TrackerControls::Initialize(QWidget*)
-{
- loadSettings();
- show();
-}
-
-void TrackerControls::loadSettings()
-{
- ui.cameraName->clear();
- QList<QString> names = get_camera_names();
- names.prepend("Any available");
- ui.cameraName->addItems(names);
- QSettings settings("opentrack");
- QString currentFile = settings.value( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString();
- QSettings iniFile( currentFile, QSettings::IniFormat );
- iniFile.beginGroup( "HT-Tracker" );
- ui.cameraName->setCurrentIndex(iniFile.value("camera-index", -1).toInt() + 1);
- ui.cameraFOV->setValue(iniFile.value("fov", 52).toFloat());
- int fps;
- switch (iniFile.value("fps", 0).toInt())
- {
- default:
- case 0:
- fps = 0;
- break;
- case 30:
- fps = 1;
- break;
- case 60:
- fps = 2;
- break;
- case 120:
- fps = 3;
- break;
- }
- ui.cameraFPS->setCurrentIndex(fps);
- ui.rx->setCheckState(iniFile.value("enable-rx", true).toBool() ? Qt::Checked : Qt::Unchecked);
- ui.ry->setCheckState(iniFile.value("enable-ry", true).toBool() ? Qt::Checked : Qt::Unchecked);
- ui.rz->setCheckState(iniFile.value("enable-rz", true).toBool() ? Qt::Checked : Qt::Unchecked);
- ui.tx->setCheckState(iniFile.value("enable-tx", true).toBool() ? Qt::Checked : Qt::Unchecked);
- ui.ty->setCheckState(iniFile.value("enable-ty", true).toBool() ? Qt::Checked : Qt::Unchecked);
- ui.tz->setCheckState(iniFile.value("enable-tz", true).toBool() ? Qt::Checked : Qt::Unchecked);
- ui.resolution->setCurrentIndex(iniFile.value("resolution", 0).toInt());
-
- ui.doubleSpinBox->setValue(iniFile.value("dc0").toDouble());
- ui.doubleSpinBox_2->setValue(iniFile.value("dc1").toDouble());
- ui.doubleSpinBox_3->setValue(iniFile.value("dc2").toDouble());
- ui.doubleSpinBox_4->setValue(iniFile.value("dc3").toDouble());
- ui.doubleSpinBox_5->setValue(iniFile.value("dc4").toDouble());
-
- iniFile.endGroup();
- settingsDirty = false;
-}
-
-void TrackerControls::save()
-{
- QSettings settings("opentrack");
- QString currentFile = settings.value( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString();
- QSettings iniFile( currentFile, QSettings::IniFormat );
-
- iniFile.beginGroup( "HT-Tracker" );
- iniFile.setValue("fov", ui.cameraFOV->value());
- int fps;
- switch (ui.cameraFPS->currentIndex())
- {
- case 0:
- default:
- fps = 0;
- break;
- case 1:
- fps = 30;
- break;
- case 2:
- fps = 60;
- break;
- case 3:
- fps = 120;
- break;
- }
- iniFile.setValue("fps", fps);
- iniFile.setValue("camera-index", ui.cameraName->currentIndex() - 1);
- iniFile.setValue("enable-rx", ui.rx->checkState() != Qt::Unchecked ? true : false);
- iniFile.setValue("enable-ry", ui.ry->checkState() != Qt::Unchecked ? true : false);
- iniFile.setValue("enable-rz", ui.rz->checkState() != Qt::Unchecked ? true : false);
- iniFile.setValue("enable-tx", ui.tx->checkState() != Qt::Unchecked ? true : false);
- iniFile.setValue("enable-ty", ui.ty->checkState() != Qt::Unchecked ? true : false);
- iniFile.setValue("enable-tz", ui.tz->checkState() != Qt::Unchecked ? true : false);
- iniFile.setValue("resolution", ui.resolution->currentIndex());
-
- iniFile.setValue("dc0", ui.doubleSpinBox->value());
- iniFile.setValue("dc1", ui.doubleSpinBox_2->value());
- iniFile.setValue("dc2", ui.doubleSpinBox_3->value());
- iniFile.setValue("dc3", ui.doubleSpinBox_4->value());
- iniFile.setValue("dc4", ui.doubleSpinBox_5->value());
-
- iniFile.endGroup();
- settingsDirty = false;
+ ui.cameraName->clear();
+ QList<QString> names = get_camera_names();
+ names.prepend("Any available");
+ ui.cameraName->addItems(names);
+ tie_setting(s.camera_idx, ui.cameraName);
+ tie_setting(s.fps, ui.cameraFPS);
+ tie_setting(s.fov, ui.cameraFOV);
+ tie_setting(s.enableTX, ui.tx);
+ tie_setting(s.enableTY, ui.ty);
+ tie_setting(s.enableTZ, ui.tz);
+ tie_setting(s.enableRX, ui.rx);
+ tie_setting(s.enableRY, ui.ry);
+ tie_setting(s.enableRZ, ui.rz);
+ tie_setting(s.resolution, ui.resolution);
+ connect(ui.buttonBox, SIGNAL(rejected()), this, SLOT(doCancel()));
+ connect(ui.buttonBox, SIGNAL(accepted()), this, SLOT(doOK()));
}
void TrackerControls::doOK()
{
- save();
+ s.b->save();
this->close();
}
void TrackerControls::doCancel()
{
- if (settingsDirty) {
- int ret = QMessageBox::question ( this,
- "Settings have changed",
- "Do you want to save the settings?",
- QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel,
- QMessageBox::Discard );
-
- switch (ret) {
- case QMessageBox::Save:
- save();
- this->close();
- break;
- case QMessageBox::Discard:
- this->close();
- break;
- case QMessageBox::Cancel:
- // Cancel was clicked
- break;
- default:
- // should never be reached
- break;
- }
- }
- else {
- this->close();
- }
+ if (!s.b->modifiedp())
+ {
+ close();
+ return;
+ }
+ int ret = QMessageBox::question ( this,
+ "Settings have changed",
+ "Do you want to save the settings?",
+ QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel);
+
+ switch (ret) {
+ case QMessageBox::Save:
+ s.b->save();
+ this->close();
+ break;
+ case QMessageBox::Discard:
+ s.b->revert();
+ this->close();
+ break;
+ default:
+ case QMessageBox::Cancel:
+ break;
+ }
}
diff --git a/ftnoir_tracker_ht/ftnoir_tracker_ht.h b/ftnoir_tracker_ht/ftnoir_tracker_ht.h
index 404dbf6e..583249dc 100644
--- a/ftnoir_tracker_ht/ftnoir_tracker_ht.h
+++ b/ftnoir_tracker_ht/ftnoir_tracker_ht.h
@@ -15,6 +15,28 @@
#include "ht_video_widget.h"
#include "compat/compat.h"
#include <QObject>
+#include "facetracknoir/options.h"
+using namespace options;
+
+struct settings {
+ pbundle b;
+ value<bool> enableTX, enableTY, enableTZ, enableRX, enableRY, enableRZ;
+ value<double> fov;
+ value<int> fps, camera_idx, resolution;
+ settings() :
+ b(bundle("HT-Tracker")),
+ enableTX(b, "enable-tx", true),
+ enableTY(b, "enable-ty", true),
+ enableTZ(b, "enable-tz", true),
+ enableRX(b, "enable-rx", true),
+ enableRY(b, "enable-ry", true),
+ enableRZ(b, "enable-rz", true),
+ fov(b, "fov", 56),
+ fps(b, "fps", 0),
+ camera_idx(b, "camera-index", 0),
+ resolution(b, "resolution", 0)
+ {}
+};
class Tracker : public QObject, public ITracker
{
@@ -24,10 +46,11 @@ public:
virtual ~Tracker();
void StartTracker(QFrame* frame);
void GetHeadPoseData(double *data);
- bool enableTX, enableTY, enableTZ, enableRX, enableRY, enableRZ;
- ht_shm_t* shm;
+ void load_settings(ht_config_t* config);
private:
+ settings s;
PortableLockedShm lck_shm;
+ ht_shm_t* shm;
QProcess subprocess;
HTVideoWidget* videoWidget;
QHBoxLayout* layout;
@@ -38,27 +61,17 @@ class TrackerControls : public QWidget, public ITrackerDialog
{
Q_OBJECT
public:
-
explicit TrackerControls();
- virtual ~TrackerControls();
- void showEvent (QShowEvent *);
-
- void Initialize(QWidget *);
void registerTracker(ITracker *) {}
void unRegisterTracker() {}
private:
Ui::Form ui;
- void loadSettings();
- void save();
- bool settingsDirty;
+ settings s;
private slots:
void doOK();
void doCancel();
- void settingChanged() { settingsDirty = true; }
- void settingChanged(int) { settingsDirty = true; }
- void settingChanged(double) { settingsDirty = true; }
};
#endif
diff --git a/ftnoir_tracker_ht/ht-trackercontrols.ui b/ftnoir_tracker_ht/ht-trackercontrols.ui
index 6153637a..198cca7f 100644
--- a/ftnoir_tracker_ht/ht-trackercontrols.ui
+++ b/ftnoir_tracker_ht/ht-trackercontrols.ui
@@ -9,8 +9,8 @@
<rect>
<x>0</x>
<y>0</y>
- <width>593</width>
- <height>280</height>
+ <width>527</width>
+ <height>144</height>
</rect>
</property>
<property name="sizePolicy">
@@ -28,420 +28,195 @@
<property name="windowTitle">
<string>HT tracker settings</string>
</property>
- <widget class="QLabel" name="label">
- <property name="geometry">
- <rect>
- <x>10</x>
- <y>10</y>
- <width>141</width>
- <height>16</height>
- </rect>
- </property>
- <property name="text">
- <string>Horizontal FOV</string>
- </property>
- </widget>
- <widget class="QDoubleSpinBox" name="cameraFOV">
- <property name="geometry">
- <rect>
- <x>130</x>
- <y>10</y>
- <width>251</width>
- <height>22</height>
- </rect>
- </property>
- <property name="locale">
- <locale language="English" country="UnitedStates"/>
- </property>
- <property name="minimum">
- <double>35.000000000000000</double>
- </property>
- <property name="maximum">
- <double>180.000000000000000</double>
- </property>
- <property name="value">
- <double>52.000000000000000</double>
- </property>
- </widget>
- <widget class="QLabel" name="label_2">
- <property name="geometry">
- <rect>
- <x>10</x>
- <y>40</y>
- <width>137</width>
- <height>16</height>
- </rect>
- </property>
- <property name="text">
- <string>Frames per second</string>
- </property>
- </widget>
- <widget class="QComboBox" name="cameraFPS">
- <property name="geometry">
- <rect>
- <x>130</x>
- <y>40</y>
- <width>251</width>
- <height>22</height>
- </rect>
- </property>
- <item>
- <property name="text">
- <string notr="true">Default</string>
- </property>
+ <layout class="QGridLayout" name="gridLayout">
+ <item row="0" column="1">
+ <widget class="QDoubleSpinBox" name="cameraFOV">
+ <property name="locale">
+ <locale language="English" country="UnitedStates"/>
+ </property>
+ <property name="minimum">
+ <double>35.000000000000000</double>
+ </property>
+ <property name="maximum">
+ <double>180.000000000000000</double>
+ </property>
+ <property name="value">
+ <double>52.000000000000000</double>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="0">
+ <widget class="QLabel" name="label">
+ <property name="text">
+ <string>Horizontal FOV</string>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="2" rowspan="3">
+ <widget class="QGroupBox" name="groupBox">
+ <property name="title">
+ <string>Enable axes</string>
+ </property>
+ <widget class="QCheckBox" name="rx">
+ <property name="geometry">
+ <rect>
+ <x>10</x>
+ <y>20</y>
+ <width>70</width>
+ <height>17</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>RX</string>
+ </property>
+ </widget>
+ <widget class="QCheckBox" name="ry">
+ <property name="geometry">
+ <rect>
+ <x>10</x>
+ <y>40</y>
+ <width>70</width>
+ <height>17</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>RY</string>
+ </property>
+ </widget>
+ <widget class="QCheckBox" name="rz">
+ <property name="geometry">
+ <rect>
+ <x>10</x>
+ <y>60</y>
+ <width>70</width>
+ <height>17</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>RZ</string>
+ </property>
+ </widget>
+ <widget class="QCheckBox" name="tx">
+ <property name="geometry">
+ <rect>
+ <x>60</x>
+ <y>20</y>
+ <width>70</width>
+ <height>17</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>TX</string>
+ </property>
+ </widget>
+ <widget class="QCheckBox" name="ty">
+ <property name="geometry">
+ <rect>
+ <x>60</x>
+ <y>40</y>
+ <width>70</width>
+ <height>17</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>TY</string>
+ </property>
+ </widget>
+ <widget class="QCheckBox" name="tz">
+ <property name="geometry">
+ <rect>
+ <x>60</x>
+ <y>60</y>
+ <width>70</width>
+ <height>17</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>TZ</string>
+ </property>
+ </widget>
+ </widget>
</item>
- <item>
- <property name="text">
- <string>30</string>
- </property>
+ <item row="1" column="0">
+ <widget class="QLabel" name="label_2">
+ <property name="text">
+ <string>Frames per second</string>
+ </property>
+ </widget>
</item>
- <item>
- <property name="text">
- <string>60</string>
- </property>
+ <item row="1" column="1">
+ <widget class="QComboBox" name="cameraFPS">
+ <item>
+ <property name="text">
+ <string notr="true">Default</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>30</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>60</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>120</string>
+ </property>
+ </item>
+ </widget>
</item>
- <item>
- <property name="text">
- <string>120</string>
- </property>
+ <item row="2" column="0">
+ <widget class="QLabel" name="label_3">
+ <property name="text">
+ <string>Camera name</string>
+ </property>
+ </widget>
</item>
- </widget>
- <widget class="QLabel" name="label_3">
- <property name="geometry">
- <rect>
- <x>10</x>
- <y>70</y>
- <width>133</width>
- <height>16</height>
- </rect>
- </property>
- <property name="text">
- <string>Camera name</string>
- </property>
- </widget>
- <widget class="QPushButton" name="buttonOK">
- <property name="geometry">
- <rect>
- <x>430</x>
- <y>250</y>
- <width>75</width>
- <height>23</height>
- </rect>
- </property>
- <property name="text">
- <string>OK</string>
- </property>
- </widget>
- <widget class="QPushButton" name="buttonCancel">
- <property name="geometry">
- <rect>
- <x>510</x>
- <y>250</y>
- <width>75</width>
- <height>23</height>
- </rect>
- </property>
- <property name="text">
- <string>Cancel</string>
- </property>
- </widget>
- <widget class="QGroupBox" name="groupBox">
- <property name="geometry">
- <rect>
- <x>390</x>
- <y>10</y>
- <width>101</width>
- <height>81</height>
- </rect>
- </property>
- <property name="title">
- <string>Enable axes</string>
- </property>
- <widget class="QCheckBox" name="rx">
- <property name="geometry">
- <rect>
- <x>10</x>
- <y>20</y>
- <width>70</width>
- <height>17</height>
- </rect>
- </property>
- <property name="text">
- <string>RX</string>
- </property>
- </widget>
- <widget class="QCheckBox" name="ry">
- <property name="geometry">
- <rect>
- <x>10</x>
- <y>40</y>
- <width>70</width>
- <height>17</height>
- </rect>
- </property>
- <property name="text">
- <string>RY</string>
- </property>
- </widget>
- <widget class="QCheckBox" name="rz">
- <property name="geometry">
- <rect>
- <x>10</x>
- <y>60</y>
- <width>70</width>
- <height>17</height>
- </rect>
- </property>
- <property name="text">
- <string>RZ</string>
- </property>
- </widget>
- <widget class="QCheckBox" name="tx">
- <property name="geometry">
- <rect>
- <x>60</x>
- <y>20</y>
- <width>70</width>
- <height>17</height>
- </rect>
- </property>
- <property name="text">
- <string>TX</string>
- </property>
- </widget>
- <widget class="QCheckBox" name="ty">
- <property name="geometry">
- <rect>
- <x>60</x>
- <y>40</y>
- <width>70</width>
- <height>17</height>
- </rect>
- </property>
- <property name="text">
- <string>TY</string>
- </property>
- </widget>
- <widget class="QCheckBox" name="tz">
- <property name="geometry">
- <rect>
- <x>60</x>
- <y>60</y>
- <width>70</width>
- <height>17</height>
- </rect>
- </property>
- <property name="text">
- <string>TZ</string>
- </property>
- </widget>
- </widget>
- <widget class="QComboBox" name="cameraName">
- <property name="geometry">
- <rect>
- <x>130</x>
- <y>70</y>
- <width>251</width>
- <height>22</height>
- </rect>
- </property>
- </widget>
- <widget class="QLabel" name="label_4">
- <property name="geometry">
- <rect>
- <x>10</x>
- <y>100</y>
- <width>128</width>
- <height>16</height>
- </rect>
- </property>
- <property name="text">
- <string>Resolution</string>
- </property>
- </widget>
- <widget class="QComboBox" name="resolution">
- <property name="geometry">
- <rect>
- <x>130</x>
- <y>100</y>
- <width>251</width>
- <height>22</height>
- </rect>
- </property>
- <item>
- <property name="text">
- <string>640x480</string>
- </property>
+ <item row="2" column="1">
+ <widget class="QComboBox" name="cameraName"/>
</item>
- <item>
- <property name="text">
- <string>320x240</string>
- </property>
+ <item row="3" column="0">
+ <widget class="QLabel" name="label_4">
+ <property name="text">
+ <string>Resolution</string>
+ </property>
+ </widget>
</item>
- <item>
- <property name="text">
- <string>320x200</string>
- </property>
+ <item row="3" column="1">
+ <widget class="QComboBox" name="resolution">
+ <item>
+ <property name="text">
+ <string>640x480</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>320x240</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>320x200</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Default (not recommended!)</string>
+ </property>
+ </item>
+ </widget>
</item>
- <item>
- <property name="text">
- <string>Default (not recommended!)</string>
- </property>
+ <item row="4" column="2">
+ <widget class="QDialogButtonBox" name="buttonBox">
+ <property name="standardButtons">
+ <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
+ </property>
+ </widget>
</item>
- </widget>
- <widget class="QDoubleSpinBox" name="doubleSpinBox">
- <property name="geometry">
- <rect>
- <x>130</x>
- <y>130</y>
- <width>171</width>
- <height>22</height>
- </rect>
- </property>
- <property name="frame">
- <bool>true</bool>
- </property>
- <property name="buttonSymbols">
- <enum>QAbstractSpinBox::NoButtons</enum>
- </property>
- <property name="decimals">
- <number>24</number>
- </property>
- <property name="minimum">
- <double>-1000.000000000000000</double>
- </property>
- <property name="maximum">
- <double>1000.000000000000000</double>
- </property>
- <property name="singleStep">
- <double>0.000000000000000</double>
- </property>
- </widget>
- <widget class="QLabel" name="label_5">
- <property name="geometry">
- <rect>
- <x>10</x>
- <y>130</y>
- <width>111</width>
- <height>16</height>
- </rect>
- </property>
- <property name="text">
- <string>Distortion coefficients</string>
- </property>
- </widget>
- <widget class="QDoubleSpinBox" name="doubleSpinBox_2">
- <property name="geometry">
- <rect>
- <x>130</x>
- <y>160</y>
- <width>171</width>
- <height>22</height>
- </rect>
- </property>
- <property name="frame">
- <bool>true</bool>
- </property>
- <property name="buttonSymbols">
- <enum>QAbstractSpinBox::NoButtons</enum>
- </property>
- <property name="decimals">
- <number>24</number>
- </property>
- <property name="minimum">
- <double>-1000.000000000000000</double>
- </property>
- <property name="maximum">
- <double>1000.000000000000000</double>
- </property>
- <property name="singleStep">
- <double>0.000000000000000</double>
- </property>
- </widget>
- <widget class="QDoubleSpinBox" name="doubleSpinBox_3">
- <property name="geometry">
- <rect>
- <x>130</x>
- <y>190</y>
- <width>171</width>
- <height>22</height>
- </rect>
- </property>
- <property name="frame">
- <bool>true</bool>
- </property>
- <property name="buttonSymbols">
- <enum>QAbstractSpinBox::NoButtons</enum>
- </property>
- <property name="decimals">
- <number>24</number>
- </property>
- <property name="minimum">
- <double>-1000.000000000000000</double>
- </property>
- <property name="maximum">
- <double>1000.000000000000000</double>
- </property>
- <property name="singleStep">
- <double>0.000000000000000</double>
- </property>
- </widget>
- <widget class="QDoubleSpinBox" name="doubleSpinBox_4">
- <property name="geometry">
- <rect>
- <x>130</x>
- <y>220</y>
- <width>171</width>
- <height>22</height>
- </rect>
- </property>
- <property name="frame">
- <bool>true</bool>
- </property>
- <property name="buttonSymbols">
- <enum>QAbstractSpinBox::NoButtons</enum>
- </property>
- <property name="decimals">
- <number>24</number>
- </property>
- <property name="minimum">
- <double>-1000.000000000000000</double>
- </property>
- <property name="maximum">
- <double>1000.000000000000000</double>
- </property>
- <property name="singleStep">
- <double>0.000000000000000</double>
- </property>
- </widget>
- <widget class="QDoubleSpinBox" name="doubleSpinBox_5">
- <property name="geometry">
- <rect>
- <x>130</x>
- <y>250</y>
- <width>171</width>
- <height>22</height>
- </rect>
- </property>
- <property name="frame">
- <bool>true</bool>
- </property>
- <property name="buttonSymbols">
- <enum>QAbstractSpinBox::NoButtons</enum>
- </property>
- <property name="decimals">
- <number>24</number>
- </property>
- <property name="minimum">
- <double>-1000.000000000000000</double>
- </property>
- <property name="maximum">
- <double>1000.000000000000000</double>
- </property>
- <property name="singleStep">
- <double>0.000000000000000</double>
- </property>
- </widget>
+ </layout>
</widget>
<resources/>
<connections/>
diff --git a/ftnoir_tracker_ht/stdafx.h b/ftnoir_tracker_ht/stdafx.h
index 0e532c9f..6f1539b7 100644
--- a/ftnoir_tracker_ht/stdafx.h
+++ b/ftnoir_tracker_ht/stdafx.h
@@ -4,7 +4,6 @@
#include <QImage>
#include <QLabel>
#include <QCoreApplication>
-#include <QSettings>
#include <QIcon>
#include <QHBoxLayout>
#include <QTimer>
diff --git a/ftnoir_tracker_hydra/ftnoir_tracker_hydra.cpp b/ftnoir_tracker_hydra/ftnoir_tracker_hydra.cpp
index 31e3f319..70af2893 100644
--- a/ftnoir_tracker_hydra/ftnoir_tracker_hydra.cpp
+++ b/ftnoir_tracker_hydra/ftnoir_tracker_hydra.cpp
@@ -9,22 +9,9 @@
#endif
#include <sixense.h>
#include <sixense_math.hpp>
-#if 0
-#include <sixense_utils/derivatives.hpp>
-#include <sixense_utils/button_states.hpp>
-#include <sixense_utils/event_triggers.hpp>
-#include <sixense_utils/controller_manager/controller_manager.hpp>
-#endif
-Hydra_Tracker::Hydra_Tracker()
+Hydra_Tracker::Hydra_Tracker() : should_quit(false)
{
- bEnableRoll = true;
- bEnablePitch = true;
- bEnableYaw = true;
- bEnableX = true;
- bEnableY = true;
- bEnableZ = true;
- should_quit = false;
for (int i = 0; i < 6; i++)
newHeadPose[i] = 0;
}
@@ -35,48 +22,18 @@ Hydra_Tracker::~Hydra_Tracker()
sixenseExit();
}
-/*
-void controller_manager_setup_callback( sixenseUtils::ControllerManager::setup_step step ) {
-
- QMessageBox::warning(0,"OpenTrack Info", "controller manager callback",QMessageBox::Ok,QMessageBox::NoButton);
- if( sixenseUtils::getTheControllerManager()->isMenuVisible() ) {
- // Ask the controller manager what the next instruction string should be.
- std::string controller_manager_text_string = sixenseUtils::getTheControllerManager()->getStepString();
- QMessageBox::warning(0,"OpenTrack Info", controller_manager_text_string.c_str(),QMessageBox::Ok,QMessageBox::NoButton);
- // We could also load the supplied controllermanager textures using the filename: sixenseUtils::getTheControllerManager()->getTextureFileName();
-
- }
-}*/
-
void Hydra_Tracker::StartTracker(QFrame*)
{
- //QMessageBox::warning(0,"FaceTrackNoIR Notification", "Tracking loading settings...",QMessageBox::Ok,QMessageBox::NoButton);
- loadSettings();
-
- // Init sixense
- //QMessageBox::warning(0,"OpenTrack Info", "sixense init",QMessageBox::Ok,QMessageBox::NoButton);
sixenseInit();
- //QMessageBox::warning(0,"OpenTrack Info", "sixense init complete, setting controller manager",QMessageBox::Ok,QMessageBox::NoButton);
- // Init the controller manager. This makes sure the controllers are present, assigned to left and right hands, and that
- // the hemisphere calibration is complete.
- //sixenseUtils::getTheControllerManager()->setGameType( sixenseUtils::ControllerManager::ONE_PLAYER_TWO_CONTROLLER );
- //sixenseUtils::getTheControllerManager()->registerSetupCallback( controller_manager_setup_callback );
- //QMessageBox::warning(0,"OpenTrack Info", "controller manager callback registered",QMessageBox::Ok,QMessageBox::NoButton);
- return;
}
-
void Hydra_Tracker::GetHeadPoseData(double *data)
{
sixenseSetActiveBase(0);
sixenseAllControllerData acd;
sixenseGetAllNewestData( &acd );
- //sixenseUtils::getTheControllerManager()->update( &acd );
-
- //sixenseControllerData cd;
- //Rotation quat = Rotation(acd.controllers[0].rot_quat[1],acd.controllers[0].rot_quat[2],acd.controllers[0].rot_quat[3],acd.controllers[0].rot_quat[0]);
- sixenseMath::Matrix4 mat = sixenseMath::Matrix4(acd.controllers[0].rot_mat);// sixenseMath::Quat(acd.controllers[0].rot_quat[1],acd.controllers[0].rot_quat[2],acd.controllers[0].rot_quat[3],acd.controllers[0].rot_quat[0]);
+ sixenseMath::Matrix4 mat = sixenseMath::Matrix4(acd.controllers[0].rot_mat);
float ypr[3];
@@ -90,62 +47,26 @@ void Hydra_Tracker::GetHeadPoseData(double *data)
newHeadPose[TY] = acd.controllers[0].pos[1]/50.0f;
newHeadPose[TZ] = acd.controllers[0].pos[2]/50.0f;
- if (bEnableX) {
+ if (s.bEnableX) {
data[TX] = newHeadPose[TX];
}
- if (bEnableY) {
+ if (s.bEnableY) {
data[TY] = newHeadPose[TY];
}
- if (bEnableY) {
+ if (s.bEnableY) {
data[TZ] = newHeadPose[TZ];
}
-
- if (bEnableYaw) {
+ if (s.bEnableYaw) {
data[Yaw] = newHeadPose[Yaw] * 57.295781f;
}
- if (bEnablePitch) {
+ if (s.bEnablePitch) {
data[Pitch] = newHeadPose[Pitch] * 57.295781f;
}
- if (bEnableRoll) {
+ if (s.bEnableRoll) {
data[Roll] = newHeadPose[Roll] * 57.295781f;
}
}
-
-//
-// Load the current Settings from the currently 'active' INI-file.
-//
-void Hydra_Tracker::loadSettings() {
-
- qDebug() << "FTNoIR_Tracker::loadSettings says: Starting ";
- QSettings settings("opentrack"); // Registry settings (in HK_USER)
-
- QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString();
- QSettings iniFile( currentFile, QSettings::IniFormat ); // Application settings (in INI-file)
-
- qDebug() << "FTNoIR_Tracker::loadSettings says: iniFile = " << currentFile;
-
- iniFile.beginGroup ( "Hydra" );
- bEnableRoll = iniFile.value ( "EnableRoll", 1 ).toBool();
- bEnablePitch = iniFile.value ( "EnablePitch", 1 ).toBool();
- bEnableYaw = iniFile.value ( "EnableYaw", 1 ).toBool();
- bEnableX = iniFile.value ( "EnableX", 1 ).toBool();
- bEnableY = iniFile.value ( "EnableY", 1 ).toBool();
- bEnableZ = iniFile.value ( "EnableZ", 1 ).toBool();
-
- iniFile.endGroup ();
-}
-
-
-////////////////////////////////////////////////////////////////////////////////
-// Factory function that creates instances if the Tracker object.
-
-// Export both decorated and undecorated names.
-// GetTracker - Undecorated name, which can be easily used with GetProcAddress
-// Win32 API function.
-// _GetTracker@0 - Common name decoration for __stdcall functions in C language.
-//#pragma comment(linker, "/export:GetTracker=_GetTracker@0")
-
extern "C" FTNOIR_TRACKER_BASE_EXPORT ITracker* CALLING_CONVENTION GetConstructor()
{
return new Hydra_Tracker;
diff --git a/ftnoir_tracker_hydra/ftnoir_tracker_hydra.h b/ftnoir_tracker_hydra/ftnoir_tracker_hydra.h
index 240f0687..05a8b076 100644
--- a/ftnoir_tracker_hydra/ftnoir_tracker_hydra.h
+++ b/ftnoir_tracker_hydra/ftnoir_tracker_hydra.h
@@ -1,86 +1,65 @@
#include "ftnoir_tracker_base/ftnoir_tracker_base.h"
#include "ui_ftnoir_hydra_clientcontrols.h"
#include <QMessageBox>
-#include <QSettings>
#include <QWaitCondition>
#include <math.h>
#include "facetracknoir/global-settings.h"
+#include "facetracknoir/options.h"
+using namespace options;
+
+struct settings {
+ pbundle b;
+ value<bool> bEnableRoll, bEnablePitch, bEnableYaw, bEnableX, bEnableY, bEnableZ;
+ settings() :
+ b(bundle("tracker-hydra")),
+ bEnableRoll(b, "enable-rz", true),
+ bEnablePitch(b, "enable-ry", true),
+ bEnableYaw(b, "enable-rx", true),
+ bEnableX(b, "enable-tx", true),
+ bEnableY(b, "enable-ty", true),
+ bEnableZ(b, "enable-tz", true)
+ {}
+};
+
class Hydra_Tracker : public ITracker
{
public:
Hydra_Tracker();
~Hydra_Tracker();
-
void StartTracker(QFrame *) virt_override;
void GetHeadPoseData(double *data) virt_override;
- void loadSettings();
volatile bool should_quit;
protected:
void run(); // qthread override run method
-
private:
+ settings s;
bool isCalibrated;
-
double newHeadPose[6]; // Structure with new headpose
- bool bEnableRoll;
- bool bEnablePitch;
- bool bEnableYaw;
-
- bool bEnableX;
- bool bEnableY;
- bool bEnableZ;
-
QMutex mutex;
-
virtual int preferredHz() virt_override { return 250; }
};
-// Widget that has controls for FTNoIR protocol client-settings.
class TrackerControls: public QWidget, public ITrackerDialog
{
Q_OBJECT
public:
-
explicit TrackerControls();
- ~TrackerControls();
- void showEvent (QShowEvent *);
-
- void Initialize(QWidget *parent);
void registerTracker(ITracker *) {}
void unRegisterTracker() {}
-
private:
+ settings s;
Ui::UIHydraControls ui;
- void loadSettings();
- void save();
-
- /** helper **/
- bool settingsDirty;
-
private slots:
void doOK();
void doCancel();
- void settingChanged() { settingsDirty = true; }
- void settingChanged(int) { settingsDirty = true; }
};
-//*******************************************************************************************************
-// FaceTrackNoIR Tracker DLL. Functions used to get general info on the Tracker
-//*******************************************************************************************************
class FTNoIR_TrackerDll : public Metadata
{
public:
- FTNoIR_TrackerDll();
- ~FTNoIR_TrackerDll();
-
void getFullName(QString *strToBeFilled);
void getShortName(QString *strToBeFilled);
void getDescription(QString *strToBeFilled);
void getIcon(QIcon *icon);
-
-private:
- QString trackerFullName; // Trackers' name and description
- QString trackerShortName;
- QString trackerDescription;
};
diff --git a/ftnoir_tracker_hydra/ftnoir_tracker_hydra_dialog.cpp b/ftnoir_tracker_hydra/ftnoir_tracker_hydra_dialog.cpp
index fa674662..4a2deb9f 100644
--- a/ftnoir_tracker_hydra/ftnoir_tracker_hydra_dialog.cpp
+++ b/ftnoir_tracker_hydra/ftnoir_tracker_hydra_dialog.cpp
@@ -1,37 +1,6 @@
-/********************************************************************************
-* FaceTrackNoIR This program is a private project of some enthusiastic *
-* gamers from Holland, who don't like to pay much for *
-* head-tracking. *
-* *
-* Copyright (C) 2012 Wim Vriend (Developing) *
-* Ron Hendriks (Researching and Testing) *
-* *
-* Homepage: http://facetracknoir.sourceforge.net/home/default.htm *
-* *
-* This program is free software; you can redistribute it and/or modify it *
-* under the terms of the GNU General Public License as published by the *
-* Free Software Foundation; either version 3 of the License, or (at your *
-* option) any later version. *
-* *
-* This program is distributed in the hope that it will be useful, but *
-* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY *
-* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for *
-* more details. *
-* *
-* You should have received a copy of the GNU General Public License along *
-* with this program; if not, see <http://www.gnu.org/licenses/>. *
-* *
-********************************************************************************/
#include "ftnoir_tracker_hydra.h"
#include "facetracknoir/global-settings.h"
-//*******************************************************************************************************
-// FaceTrackNoIR Client Settings-dialog.
-//*******************************************************************************************************
-
-//
-// Constructor for server-settings-dialog
-//
TrackerControls::TrackerControls() :
QWidget()
{
@@ -41,139 +10,46 @@ QWidget()
connect(ui.buttonBox, SIGNAL(accepted()), this, SLOT(doOK()));
connect(ui.buttonBox, SIGNAL(rejected()), this, SLOT(doCancel()));
- connect(ui.chkEnableRoll, SIGNAL(stateChanged(int)), this, SLOT(settingChanged(int)));
- connect(ui.chkEnablePitch, SIGNAL(stateChanged(int)), this, SLOT(settingChanged(int)));
- connect(ui.chkEnableYaw, SIGNAL(stateChanged(int)), this, SLOT(settingChanged(int)));
-#if 0
- connect(ui.chkEnableX, SIGNAL(stateChanged(int)), this, SLOT(settingChanged(int)));
- connect(ui.chkEnableY, SIGNAL(stateChanged(int)), this, SLOT(settingChanged(int)));
- connect(ui.chkEnableZ, SIGNAL(stateChanged(int)), this, SLOT(settingChanged(int)));
-#endif
- // Load the settings from the current .INI-file
- loadSettings();
-}
-
-//
-// Destructor for server-dialog
-//
-TrackerControls::~TrackerControls() {
- qDebug() << "~TrackerControls() says: started";
+ tie_setting(s.bEnableYaw, ui.chkEnableYaw);
+ tie_setting(s.bEnablePitch, ui.chkEnablePitch);
+ tie_setting(s.bEnableRoll, ui.chkEnableRoll);
+ tie_setting(s.bEnableX, ui.chkEnableX);
+ tie_setting(s.bEnableY, ui.chkEnableY);
+ tie_setting(s.bEnableZ, ui.chkEnableZ);
}
-//
-// Initialize tracker-client-dialog
-//
-void TrackerControls::Initialize(QWidget *parent) {
-
- QPoint offsetpos(100, 100);
- if (parent) {
- this->move(parent->pos() + offsetpos);
- }
- show();
-}
-
-//
-// OK clicked on server-dialog
-//
void TrackerControls::doOK() {
- save();
+ s.b->save();
this->close();
}
-// override show event
-void TrackerControls::showEvent ( QShowEvent * ) {
- loadSettings();
-}
-
-//
-// Cancel clicked on server-dialog
-//
void TrackerControls::doCancel() {
- //
- // Ask if changed Settings should be saved
- //
- if (settingsDirty) {
- int ret = QMessageBox::question ( this, "Settings have changed", "Do you want to save the settings?", QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel, QMessageBox::Discard );
-
- qDebug() << "doCancel says: answer =" << ret;
-
- switch (ret) {
- case QMessageBox::Save:
- save();
- this->close();
- break;
- case QMessageBox::Discard:
- this->close();
- break;
- case QMessageBox::Cancel:
- // Cancel was clicked
- break;
- default:
- // should never be reached
- break;
- }
- }
- else {
- this->close();
- }
+ if (!s.b->modifiedp())
+ {
+ close();
+ return;
+ }
+ int ret = QMessageBox::question (this,
+ "Settings have changed",
+ "Do you want to save the settings?",
+ QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel);
+
+ switch (ret) {
+ case QMessageBox::Save:
+ s.b->save();
+ this->close();
+ break;
+ case QMessageBox::Discard:
+ s.b->revert();
+ this->close();
+ break;
+ default:
+ case QMessageBox::Cancel:
+ // Cancel was clicked
+ break;
+ }
}
-
-//
-// Load the current Settings from the currently 'active' INI-file.
-//
-void TrackerControls::loadSettings() {
-
-// qDebug() << "loadSettings says: Starting ";
- QSettings settings("opentrack"); // Registry settings (in HK_USER)
-
- QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString();
- QSettings iniFile( currentFile, QSettings::IniFormat ); // Application settings (in INI-file)
-
-// qDebug() << "loadSettings says: iniFile = " << currentFile;
-
- iniFile.beginGroup ( "Hydra" );
- ui.chkEnableRoll->setChecked(iniFile.value ( "EnableRoll", 1 ).toBool());
- ui.chkEnablePitch->setChecked(iniFile.value ( "EnablePitch", 1 ).toBool());
- ui.chkEnableYaw->setChecked(iniFile.value ( "EnableYaw", 1 ).toBool());
- ui.chkEnableX->setChecked(iniFile.value ( "EnableX", 1 ).toBool());
- ui.chkEnableY->setChecked(iniFile.value ( "EnableY", 1 ).toBool());
- ui.chkEnableZ->setChecked(iniFile.value ( "EnableZ", 1 ).toBool());
-
- iniFile.endGroup ();
-
- settingsDirty = false;
-}
-
-//
-// Save the current Settings to the currently 'active' INI-file.
-//
-void TrackerControls::save() {
- QSettings settings("opentrack"); // Registry settings (in HK_USER)
-
- QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString();
- QSettings iniFile( currentFile, QSettings::IniFormat ); // Application settings (in INI-file)
-
- iniFile.beginGroup ( "Hydra" );
- iniFile.setValue ( "EnableRoll", ui.chkEnableRoll->isChecked() );
- iniFile.setValue ( "EnablePitch", ui.chkEnablePitch->isChecked() );
- iniFile.setValue ( "EnableYaw", ui.chkEnableYaw->isChecked() );
- iniFile.setValue ( "EnableX", ui.chkEnableX->isChecked() );
- iniFile.setValue ( "EnableY", ui.chkEnableY->isChecked() );
- iniFile.setValue ( "EnableZ", ui.chkEnableZ->isChecked() );
- iniFile.endGroup ();
-
- settingsDirty = false;
-}
-////////////////////////////////////////////////////////////////////////////////
-// Factory function that creates instances if the Tracker-settings dialog object.
-
-// Export both decorated and undecorated names.
-// GetTrackerDialog - Undecorated name, which can be easily used with GetProcAddress
-// Win32 API function.
-// _GetTrackerDialog@0 - Common name decoration for __stdcall functions in C language.
-//#pragma comment(linker, "/export:GetTrackerDialog=_GetTrackerDialog@0")
-
extern "C" FTNOIR_TRACKER_BASE_EXPORT ITrackerDialog* CALLING_CONVENTION GetDialog( )
{
return new TrackerControls;
diff --git a/ftnoir_tracker_hydra/ftnoir_tracker_hydra_dll.cpp b/ftnoir_tracker_hydra/ftnoir_tracker_hydra_dll.cpp
index db6f658c..a2cc7c01 100644
--- a/ftnoir_tracker_hydra/ftnoir_tracker_hydra_dll.cpp
+++ b/ftnoir_tracker_hydra/ftnoir_tracker_hydra_dll.cpp
@@ -3,31 +3,19 @@
#include <QDebug>
#include "facetracknoir/global-settings.h"
-FTNoIR_TrackerDll::FTNoIR_TrackerDll() {
- //populate the description strings
- trackerFullName = "Hydra";
- trackerShortName = "Hydra";
- trackerDescription = "Hydra";
-}
-
-FTNoIR_TrackerDll::~FTNoIR_TrackerDll()
-{
-
-}
-
void FTNoIR_TrackerDll::getFullName(QString *strToBeFilled)
{
- *strToBeFilled = trackerFullName;
+ *strToBeFilled = "Hydra";
}
void FTNoIR_TrackerDll::getShortName(QString *strToBeFilled)
{
- *strToBeFilled = trackerShortName;
+ *strToBeFilled = "Hydra";
}
void FTNoIR_TrackerDll::getDescription(QString *strToBeFilled)
{
- *strToBeFilled = trackerDescription;
+ *strToBeFilled = "Hydra";
}
void FTNoIR_TrackerDll::getIcon(QIcon *icon)
diff --git a/ftnoir_tracker_joystick/ftnoir_tracker_joystick.cpp b/ftnoir_tracker_joystick/ftnoir_tracker_joystick.cpp
index 5be6b3db..28fc034a 100644
--- a/ftnoir_tracker_joystick/ftnoir_tracker_joystick.cpp
+++ b/ftnoir_tracker_joystick/ftnoir_tracker_joystick.cpp
@@ -10,24 +10,24 @@ static BOOL CALLBACK EnumJoysticksCallback2( const DIDEVICEINSTANCE* pdidInstanc
self->def = *pdidInstance;
- return self->iter++ == self->joyid ? DIENUM_STOP : DIENUM_CONTINUE;
+ return self->iter++ == self->s.joyid ? DIENUM_STOP : DIENUM_CONTINUE;
}
FTNoIR_Tracker::FTNoIR_Tracker() :
g_pDI(nullptr),
g_pJoystick(nullptr),
- joyid(-1),
iter(-1),
mtx(QMutex::Recursive)
{
for (int i = 0; i < 6; i++)
- axes[i] = min_[i] = max_[i] = 0;
+ *s.axes[i] = min_[i] = max_[i] = 0;
GUID bar = {0};
preferred = bar;
}
void FTNoIR_Tracker::reload()
{
+ s.b->reload();
QMutexLocker foo(&mtx);
if (g_pJoystick)
{
@@ -100,7 +100,6 @@ void FTNoIR_Tracker::StartTracker(QFrame* frame)
QMutexLocker foo(&mtx);
this->frame = frame;
iter = 0;
- loadSettings();
auto hr = CoInitialize( nullptr );
DI_ENUM_CONTEXT enumContext = {0};
@@ -218,7 +217,7 @@ void FTNoIR_Tracker::GetHeadPoseData(double *data)
for (int i = 0; i < 6; i++)
{
- auto idx = axes[i] - 1;
+ auto idx = *s.axes[i] - 1;
if (idx < 0 || idx > 7)
{
data[i] = 0;
@@ -234,19 +233,6 @@ void FTNoIR_Tracker::GetHeadPoseData(double *data)
}
}
-void FTNoIR_Tracker::loadSettings() {
-
- QMutexLocker foo(&mtx);
- QSettings settings("opentrack"); // Registry settings (in HK_USER)
- QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString();
- QSettings iniFile( currentFile, QSettings::IniFormat ); // Application settings (in INI-file)
- iniFile.beginGroup ( "tracker-joy" );
- joyid = iniFile.value("joyid", -1).toInt();
- for (int i = 0; i < 6; i++)
- axes[i] = iniFile.value(QString("axis-%1").arg(i), 0).toInt() - 1;
- iniFile.endGroup ();
-}
-
extern "C" FTNOIR_TRACKER_BASE_EXPORT ITracker* CALLING_CONVENTION GetConstructor()
{
return new FTNoIR_Tracker;
diff --git a/ftnoir_tracker_joystick/ftnoir_tracker_joystick.h b/ftnoir_tracker_joystick/ftnoir_tracker_joystick.h
index 9c856d85..162cbe48 100644
--- a/ftnoir_tracker_joystick/ftnoir_tracker_joystick.h
+++ b/ftnoir_tracker_joystick/ftnoir_tracker_joystick.h
@@ -24,10 +24,12 @@
#include <commctrl.h>
#include <basetsd.h>
#include <dinput.h>
-//#include <dinputd.h>
#include <oleauto.h>
#include <shellapi.h>
+#include "facetracknoir/options.h"
+using namespace options;
+
struct DI_ENUM_CONTEXT
{
GUID preferred_instance;
@@ -35,38 +37,53 @@ struct DI_ENUM_CONTEXT
LPDIRECTINPUT8 g_pDI;
};
+struct settings {
+ pbundle b;
+ value<int> axis_0;
+ value<int> axis_1;
+ value<int> axis_2;
+ value<int> axis_3;
+ value<int> axis_4;
+ value<int> axis_5;
+ value<int> joyid;
+ value<int>* axes[6];
+ settings() :
+ b(bundle("tracker-joystick")),
+ axis_0(b, "axis-0", 0),
+ axis_1(b, "axis-1", 0),
+ axis_2(b, "axis-2", 0),
+ axis_3(b, "axis-3", 0),
+ axis_4(b, "axis-4", 0),
+ axis_5(b, "axis-5", 0),
+ joyid(b, "joy-id", 0),
+ axes{&axis_0, &axis_1, &axis_2, &axis_3, &axis_4, &axis_5}
+ {}
+};
+
class FTNoIR_Tracker : public ITracker
{
public:
FTNoIR_Tracker();
~FTNoIR_Tracker();
-
void StartTracker(QFrame *frame);
void GetHeadPoseData(double *data);
- void loadSettings();
+ void reload();
LPDIRECTINPUT8 g_pDI;
LPDIRECTINPUTDEVICE8 g_pJoystick;
- int axes[6];
int min_[8], max_[8];
GUID preferred;
- int joyid;
QMutex mtx;
QFrame* frame;
DIDEVICEINSTANCE def;
- void reload();
int iter; // XXX bad style
+ settings s;
};
-// Widget that has controls for FTNoIR protocol client-settings.
class TrackerControls: public QWidget, public ITrackerDialog
{
Q_OBJECT
public:
- explicit TrackerControls();
- ~TrackerControls();
- void showEvent (QShowEvent *);
-
- void Initialize(QWidget *parent);
+ TrackerControls();
void registerTracker(ITracker *foo) {
tracker = dynamic_cast<FTNoIR_Tracker*>(foo);
}
@@ -75,32 +92,20 @@ public:
}
QList<GUID> guids;
Ui::UIJoystickControls ui;
- void loadSettings();
- void save();
- bool settingsDirty;
FTNoIR_Tracker* tracker;
-
+ settings s;
private slots:
void doOK();
void doCancel();
- void settingChanged() { settingsDirty = true; }
- void settingChanged(int) { settingsDirty = true; }
};
-//*******************************************************************************************************
-// FaceTrackNoIR Tracker DLL. Functions used to get general info on the Tracker
-//*******************************************************************************************************
class FTNoIR_TrackerDll : public Metadata
{
public:
- FTNoIR_TrackerDll();
- ~FTNoIR_TrackerDll();
-
void getFullName(QString *strToBeFilled);
void getShortName(QString *strToBeFilled);
void getDescription(QString *strToBeFilled);
void getIcon(QIcon *icon);
-
private:
QString trackerFullName; // Trackers' name and description
QString trackerShortName;
diff --git a/ftnoir_tracker_joystick/ftnoir_tracker_joystick_dialog.cpp b/ftnoir_tracker_joystick/ftnoir_tracker_joystick_dialog.cpp
index af3613d9..812ad454 100644
--- a/ftnoir_tracker_joystick/ftnoir_tracker_joystick_dialog.cpp
+++ b/ftnoir_tracker_joystick/ftnoir_tracker_joystick_dialog.cpp
@@ -11,22 +11,21 @@ static BOOL CALLBACK EnumJoysticksCallback( const DIDEVICEINSTANCE* pdidInstance
return DIENUM_CONTINUE;
}
-TrackerControls::TrackerControls() :
- QWidget(), tracker(nullptr), settingsDirty(false)
+TrackerControls::TrackerControls() : tracker(nullptr)
{
- ui.setupUi( this );
+ ui.setupUi( this );
- // Connect Qt signals to member-functions
+ // Connect Qt signals to member-functions
connect(ui.buttonBox, SIGNAL(accepted()), this, SLOT(doOK()));
connect(ui.buttonBox, SIGNAL(rejected()), this, SLOT(doCancel()));
- connect(ui.joylist, SIGNAL(currentIndexChanged(int)), this, SLOT(settingChanged(int)));
- connect(ui.comboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(settingChanged(int)));
- connect(ui.comboBox_2, SIGNAL(currentIndexChanged(int)), this, SLOT(settingChanged(int)));
- connect(ui.comboBox_3, SIGNAL(currentIndexChanged(int)), this, SLOT(settingChanged(int)));
- connect(ui.comboBox_4, SIGNAL(currentIndexChanged(int)), this, SLOT(settingChanged(int)));
- connect(ui.comboBox_5, SIGNAL(currentIndexChanged(int)), this, SLOT(settingChanged(int)));
- connect(ui.comboBox_6, SIGNAL(currentIndexChanged(int)), this, SLOT(settingChanged(int)));
+ tie_setting(s.joyid, ui.joylist);
+ tie_setting(s.axis_0, ui.comboBox);
+ tie_setting(s.axis_1, ui.comboBox_2);
+ tie_setting(s.axis_2, ui.comboBox_3);
+ tie_setting(s.axis_3, ui.comboBox_4);
+ tie_setting(s.axis_4, ui.comboBox_5);
+ tie_setting(s.axis_5, ui.comboBox_6);
{
auto hr = CoInitialize( nullptr );
@@ -46,125 +45,42 @@ fin:
if (g_pDI)
g_pDI->Release();
}
-
- loadSettings();
-}
-
-//
-// Destructor for server-dialog
-//
-TrackerControls::~TrackerControls() {
-}
-
-void TrackerControls::Initialize(QWidget *parent) {
- QPoint offsetpos(100, 100);
- if (parent) {
- this->move(parent->pos() + offsetpos);
- }
- show();
}
void TrackerControls::doOK() {
- save();
- this->close();
-}
-
-void TrackerControls::showEvent ( QShowEvent * ) {
- loadSettings();
+ s.b->save();
+ if (tracker)
+ tracker->reload();
+ this->close();
}
void TrackerControls::doCancel() {
- if (settingsDirty) {
- int ret = QMessageBox::question ( this, "Settings have changed", "Do you want to save the settings?", QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel, QMessageBox::Discard );
+ if (s.b->modifiedp()) {
+ int ret = QMessageBox::question ( this, "Settings have changed", "Do you want to save the settings?", QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel );
switch (ret) {
- case QMessageBox::Save:
- save();
- this->close();
- break;
- case QMessageBox::Discard:
- this->close();
- break;
- case QMessageBox::Cancel:
- // Cancel was clicked
- break;
- default:
- // should never be reached
- break;
- }
- }
- else {
- this->close();
- }
-}
-
-void TrackerControls::loadSettings() {
-
- QSettings settings("opentrack"); // Registry settings (in HK_USER)
-
- QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString();
- QSettings iniFile( currentFile, QSettings::IniFormat ); // Application settings (in INI-file)
-
- QComboBox* boxen[] = {
- ui.comboBox_4,
- ui.comboBox_5,
- ui.comboBox_6,
- ui.comboBox,
- ui.comboBox_2,
- ui.comboBox_3,
- };
-
- iniFile.beginGroup ( "tracker-joy" );
- for (int i = 0; i < 6; i++)
- {
- boxen[i]->setCurrentIndex(iniFile.value(QString("axis-%1").arg(i), 0).toInt());
- }
- ui.joylist->setCurrentIndex(iniFile.value("joyid", -1).toInt());
- iniFile.endGroup ();
-
- settingsDirty = false;
-}
-
-void TrackerControls::save() {
- QSettings settings("opentrack"); // Registry settings (in HK_USER)
-
- QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString();
- {
- QSettings iniFile( currentFile, QSettings::IniFormat ); // Application settings (in INI-file)
-
- QComboBox* boxen[] = {
- ui.comboBox_4,
- ui.comboBox_5,
- ui.comboBox_6,
- ui.comboBox,
- ui.comboBox_2,
- ui.comboBox_3,
- };
-
- iniFile.beginGroup ( "tracker-joy" );
- for (int i = 0; i < 6; i++)
- {
- iniFile.setValue(QString("axis-%1").arg(i), boxen[i]->currentIndex());
+ case QMessageBox::Save:
+ s.b->save();
+ if (tracker)
+ tracker->reload();
+ this->close();
+ break;
+ case QMessageBox::Discard:
+ s.b->reload();
+ this->close();
+ break;
+ case QMessageBox::Cancel:
+ // Cancel was clicked
+ break;
+ default:
+ // should never be reached
+ break;
}
- iniFile.setValue("joyid", ui.joylist->currentIndex());
- iniFile.endGroup ();
}
-
- if(tracker)
- {
- tracker->reload();
+ else {
+ this->close();
}
-
- settingsDirty = false;
}
-////////////////////////////////////////////////////////////////////////////////
-// Factory function that creates instances if the Tracker-settings dialog object.
-
-// Export both decorated and undecorated names.
-// GetTrackerDialog - Undecorated name, which can be easily used with GetProcAddress
-// Win32 API function.
-// _GetTrackerDialog@0 - Common name decoration for __stdcall functions in C language.
-//#pragma comment(linker, "/export:GetTrackerDialog=_GetTrackerDialog@0")
extern "C" FTNOIR_TRACKER_BASE_EXPORT ITrackerDialog* CALLING_CONVENTION GetDialog( )
{
diff --git a/ftnoir_tracker_joystick/ftnoir_tracker_joystick_dll.cpp b/ftnoir_tracker_joystick/ftnoir_tracker_joystick_dll.cpp
index c5ee4e5f..325d24a4 100644
--- a/ftnoir_tracker_joystick/ftnoir_tracker_joystick_dll.cpp
+++ b/ftnoir_tracker_joystick/ftnoir_tracker_joystick_dll.cpp
@@ -2,31 +2,19 @@
#include <QDebug>
#include "facetracknoir/global-settings.h"
-FTNoIR_TrackerDll::FTNoIR_TrackerDll() {
- //populate the description strings
- trackerFullName = "Joystick";
- trackerShortName = "Joystick";
- trackerDescription = "joystick";
-}
-
-FTNoIR_TrackerDll::~FTNoIR_TrackerDll()
-{
-
-}
-
void FTNoIR_TrackerDll::getFullName(QString *strToBeFilled)
{
- *strToBeFilled = trackerFullName;
+ *strToBeFilled = "Joystick";
}
void FTNoIR_TrackerDll::getShortName(QString *strToBeFilled)
{
- *strToBeFilled = trackerShortName;
+ *strToBeFilled = "Joystick";
}
void FTNoIR_TrackerDll::getDescription(QString *strToBeFilled)
{
- *strToBeFilled = trackerDescription;
+ *strToBeFilled = "Joystick";
}
void FTNoIR_TrackerDll::getIcon(QIcon *icon)
@@ -34,16 +22,7 @@ void FTNoIR_TrackerDll::getIcon(QIcon *icon)
*icon = QIcon(":/images/facetracknoir.png");
}
-////////////////////////////////////////////////////////////////////////////////
-// Factory function that creates instances if the Tracker object.
-
-// Export both decorated and undecorated names.
-// GetTrackerDll - Undecorated name, which can be easily used with GetProcAddress
-// Win32 API function.
-// _GetTrackerDll@0 - Common name decoration for __stdcall functions in C language.
-//#pragma comment(linker, "/export:GetTrackerDll=_GetTrackerDll@0")
-
extern "C" FTNOIR_TRACKER_BASE_EXPORT Metadata* CALLING_CONVENTION GetMetadata()
{
- return new FTNoIR_TrackerDll;
+ return new FTNoIR_TrackerDll;
}
diff --git a/ftnoir_tracker_rift/ftnoir_tracker_rift.cpp b/ftnoir_tracker_rift/ftnoir_tracker_rift.cpp
index da44ea0c..b548db71 100644
--- a/ftnoir_tracker_rift/ftnoir_tracker_rift.cpp
+++ b/ftnoir_tracker_rift/ftnoir_tracker_rift.cpp
@@ -8,14 +8,6 @@ using namespace OVR;
Rift_Tracker::Rift_Tracker()
{
- bEnableRoll = true;
- bEnablePitch = true;
- bEnableYaw = true;
-#if 0
- bEnableX = true;
- bEnableY = true;
- bEnableZ = true;
-#endif
should_quit = false;
pManager = NULL;
pSensor = NULL;
@@ -34,14 +26,8 @@ Rift_Tracker::~Rift_Tracker()
System::Destroy();
}
-
-
void Rift_Tracker::StartTracker(QFrame*)
{
- loadSettings();
- //
- // Startup the Oculus SDK device handling, use the first Rift sensor we find.
- //
System::Init(Log::ConfigureDefaultLog(LogMask_All));
pManager = DeviceManager::Create();
if (pManager != NULL)
@@ -81,80 +67,25 @@ void Rift_Tracker::GetHeadPoseData(double *data)
newHeadPose[Pitch] = pitch;
newHeadPose[Roll] = roll;
newHeadPose[Yaw] = yaw;
- if (useYawSpring)
+ if (s.useYawSpring)
{
- newHeadPose[Yaw] = old_yaw*persistence + (yaw-old_yaw);
- if(newHeadPose[Yaw]>deadzone)newHeadPose[Yaw]-= constant_drift;
- if(newHeadPose[Yaw]<-deadzone)newHeadPose[Yaw]+= constant_drift;
+ newHeadPose[Yaw] = old_yaw*s.persistence + (yaw-old_yaw);
+ if(newHeadPose[Yaw]>s.deadzone)newHeadPose[Yaw]-= s.constant_drift;
+ if(newHeadPose[Yaw]<-s.deadzone)newHeadPose[Yaw]+= s.constant_drift;
old_yaw=yaw;
}
-#if 0
- newHeadPose[TX] = acd.controllers[0].pos[0]/50.0f;
- newHeadPose[TY] = acd.controllers[0].pos[1]/50.0f;
- newHeadPose[TZ] = acd.controllers[0].pos[2]/50.0f;
-
- if (bEnableX) {
- data[TX] = newHeadPose[TX];
- }
- if (bEnableY) {
- data[TY] = newHeadPose[TY];
- }
- if (bEnableY) {
- data[TZ] = newHeadPose[TZ];
- }
-#endif
- if (bEnableYaw) {
+ if (s.bEnableYaw) {
data[Yaw] = newHeadPose[Yaw] * 57.295781f;
}
- if (bEnablePitch) {
+ if (s.bEnablePitch) {
data[Pitch] = newHeadPose[Pitch] * 57.295781f;
}
- if (bEnableRoll) {
+ if (s.bEnableRoll) {
data[Roll] = newHeadPose[Roll] * 57.295781f;
}
}
}
-
-//
-// Load the current Settings from the currently 'active' INI-file.
-//
-void Rift_Tracker::loadSettings() {
-
- qDebug() << "FTNoIR_Tracker::loadSettings says: Starting ";
- QSettings settings("opentrack"); // Registry settings (in HK_USER)
-
- QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString();
- QSettings iniFile( currentFile, QSettings::IniFormat ); // Application settings (in INI-file)
-
- qDebug() << "FTNoIR_Tracker::loadSettings says: iniFile = " << currentFile;
-
- iniFile.beginGroup ( "Rift" );
- bEnableRoll = iniFile.value ( "EnableRoll", 1 ).toBool();
- bEnablePitch = iniFile.value ( "EnablePitch", 1 ).toBool();
- bEnableYaw = iniFile.value ( "EnableYaw", 1 ).toBool();
-#if 0
- bEnableX = iniFile.value ( "EnableX", 1 ).toBool();
- bEnableY = iniFile.value ( "EnableY", 1 ).toBool();
- bEnableZ = iniFile.value ( "EnableZ", 1 ).toBool();
-#endif
- useYawSpring = iniFile.value("yaw-spring", false).toBool();
- constant_drift = iniFile.value("constant-drift", 0.000005).toDouble();
- persistence = iniFile.value("persistence", 0.99999).toDouble();
- deadzone = iniFile.value("deadzone", 0.02).toDouble();
- iniFile.endGroup ();
-}
-
-
-////////////////////////////////////////////////////////////////////////////////
-// Factory function that creates instances if the Tracker object.
-
-// Export both decorated and undecorated names.
-// GetTracker - Undecorated name, which can be easily used with GetProcAddress
-// Win32 API function.
-// _GetTracker@0 - Common name decoration for __stdcall functions in C language.
-//#pragma comment(linker, "/export:GetTracker=_GetTracker@0")
-
extern "C" FTNOIR_TRACKER_BASE_EXPORT ITracker* CALLING_CONVENTION GetConstructor()
{
return new Rift_Tracker;
diff --git a/ftnoir_tracker_rift/ftnoir_tracker_rift.h b/ftnoir_tracker_rift/ftnoir_tracker_rift.h
index 3920c6ad..7162b7ca 100644
--- a/ftnoir_tracker_rift/ftnoir_tracker_rift.h
+++ b/ftnoir_tracker_rift/ftnoir_tracker_rift.h
@@ -2,12 +2,30 @@
#include "ftnoir_tracker_base/ftnoir_tracker_base.h"
#include "ui_ftnoir_rift_clientcontrols.h"
#include <QMessageBox>
-#include <QSettings>
#include <QWaitCondition>
#include <cmath>
#include "facetracknoir/global-settings.h"
#include "OVR.h"
#include <memory>
+#include "facetracknoir/options.h"
+using namespace options;
+
+struct settings {
+ pbundle b;
+ value<bool> bEnableYaw, bEnablePitch, bEnableRoll, useYawSpring;
+ value<double> constant_drift, persistence, deadzone;
+ settings() :
+ b(bundle("Rift")),
+ bEnableYaw(b, "EnableYaw", true),
+ bEnablePitch(b, "EnablePitch", true),
+ bEnableRoll(b, "EnableRoll", true),
+ useYawSpring(b, "yaw-spring", false),
+ constant_drift(b, "constant-drift", 0.000005),
+ persistence(b, "persistence", 0.99999),
+ deadzone(b, "deadzone", 0.02)
+ {}
+};
+
class Rift_Tracker : public ITracker
{
public:
@@ -16,7 +34,6 @@ public:
void StartTracker(QFrame *) virt_override;
void GetHeadPoseData(double *data) virt_override;
- void loadSettings();
virtual int preferredHz() virt_override { return 250; }
volatile bool should_quit;
protected:
@@ -27,50 +44,27 @@ private:
OVR::DeviceManager* pManager;
OVR::SensorDevice* pSensor;
OVR::SensorFusion* pSFusion;
- bool bEnableRoll;
- bool bEnablePitch;
- bool bEnableYaw;
-#if 0
- bool bEnableX;
- bool bEnableY;
- bool bEnableZ;
-#endif
- bool useYawSpring;
- double old_yaw, constant_drift, persistence, deadzone;
+ settings s;
+ double old_yaw;
};
-// Widget that has controls for FTNoIR protocol client-settings.
class TrackerControls: public QWidget, public ITrackerDialog
{
Q_OBJECT
public:
-
explicit TrackerControls();
- ~TrackerControls();
- void showEvent (QShowEvent *);
- void Initialize(QWidget *parent);
void registerTracker(ITracker *) {}
void unRegisterTracker() {}
private:
Ui::UIRiftControls ui;
- void loadSettings();
- void save();
-
- /** helper **/
- bool settingsDirty;
-
+ settings s;
private slots:
void doOK();
void doCancel();
- void settingChanged() { settingsDirty = true; }
- void settingChanged(int) { settingsDirty = true; }
};
-//*******************************************************************************************************
-// FaceTrackNoIR Tracker DLL. Functions used to get general info on the Tracker
-//*******************************************************************************************************
class FTNoIR_TrackerDll : public Metadata
{
public:
diff --git a/ftnoir_tracker_rift/ftnoir_tracker_rift_dialog.cpp b/ftnoir_tracker_rift/ftnoir_tracker_rift_dialog.cpp
index 2efefbb3..763ddd11 100644
--- a/ftnoir_tracker_rift/ftnoir_tracker_rift_dialog.cpp
+++ b/ftnoir_tracker_rift/ftnoir_tracker_rift_dialog.cpp
@@ -1,13 +1,6 @@
#include "ftnoir_tracker_rift.h"
#include "facetracknoir/global-settings.h"
-//*******************************************************************************************************
-// FaceTrackNoIR Client Settings-dialog.
-//*******************************************************************************************************
-
-//
-// Constructor for server-settings-dialog
-//
TrackerControls::TrackerControls() :
QWidget()
{
@@ -17,75 +10,38 @@ QWidget()
connect(ui.buttonBox, SIGNAL(accepted()), this, SLOT(doOK()));
connect(ui.buttonBox, SIGNAL(rejected()), this, SLOT(doCancel()));
- connect(ui.chkEnableRoll, SIGNAL(stateChanged(int)), this, SLOT(settingChanged(int)));
- connect(ui.chkEnablePitch, SIGNAL(stateChanged(int)), this, SLOT(settingChanged(int)));
- connect(ui.chkEnableYaw, SIGNAL(stateChanged(int)), this, SLOT(settingChanged(int)));
-#if 0
- connect(ui.chkEnableX, SIGNAL(stateChanged(int)), this, SLOT(settingChanged(int)));
- connect(ui.chkEnableY, SIGNAL(stateChanged(int)), this, SLOT(settingChanged(int)));
- connect(ui.chkEnableZ, SIGNAL(stateChanged(int)), this, SLOT(settingChanged(int)));
-#endif
- // Load the settings from the current .INI-file
- loadSettings();
-}
+ tie_setting(s.bEnableYaw, ui.chkEnableYaw);
+ tie_setting(s.bEnablePitch, ui.chkEnablePitch);
+ tie_setting(s.bEnableRoll, ui.chkEnableRoll);
-//
-// Destructor for server-dialog
-//
-TrackerControls::~TrackerControls() {
- qDebug() << "~TrackerControls() says: started";
+ tie_setting(s.constant_drift, ui.constantDrift);
+ tie_setting(s.deadzone, ui.deadzone);
+ tie_setting(s.persistence, ui.persistence);
+ tie_setting(s.useYawSpring, ui.yawSpring);
}
-//
-// Initialize tracker-client-dialog
-//
-void TrackerControls::Initialize(QWidget *parent) {
-
- QPoint offsetpos(100, 100);
- if (parent) {
- this->move(parent->pos() + offsetpos);
- }
- show();
-}
-
-//
-// OK clicked on server-dialog
-//
void TrackerControls::doOK() {
- save();
+ s.b->save();
this->close();
}
-// override show event
-void TrackerControls::showEvent ( QShowEvent * ) {
- loadSettings();
-}
-
-//
-// Cancel clicked on server-dialog
-//
void TrackerControls::doCancel() {
//
// Ask if changed Settings should be saved
//
- if (settingsDirty) {
- int ret = QMessageBox::question ( this, "Settings have changed", "Do you want to save the settings?", QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel, QMessageBox::Discard );
-
- qDebug() << "doCancel says: answer =" << ret;
-
+ if (s.b->modifiedp()) {
+ int ret = QMessageBox::question ( this, "Settings have changed", "Do you want to save the settings?", QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel);
switch (ret) {
case QMessageBox::Save:
- save();
+ s.b->save();
this->close();
break;
case QMessageBox::Discard:
+ s.b->revert();
this->close();
break;
case QMessageBox::Cancel:
- // Cancel was clicked
- break;
default:
- // should never be reached
break;
}
}
@@ -94,73 +50,6 @@ void TrackerControls::doCancel() {
}
}
-
-//
-// Load the current Settings from the currently 'active' INI-file.
-//
-void TrackerControls::loadSettings() {
-
-// qDebug() << "loadSettings says: Starting ";
- QSettings settings("opentrack"); // Registry settings (in HK_USER)
-
- QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString();
- QSettings iniFile( currentFile, QSettings::IniFormat ); // Application settings (in INI-file)
-
-// qDebug() << "loadSettings says: iniFile = " << currentFile;
-
- iniFile.beginGroup ( "Rift" );
- ui.chkEnableRoll->setChecked(iniFile.value ( "EnableRoll", 1 ).toBool());
- ui.chkEnablePitch->setChecked(iniFile.value ( "EnablePitch", 1 ).toBool());
- ui.chkEnableYaw->setChecked(iniFile.value ( "EnableYaw", 1 ).toBool());
-#if 0
- ui.chkEnableX->setChecked(iniFile.value ( "EnableX", 1 ).toBool());
- ui.chkEnableY->setChecked(iniFile.value ( "EnableY", 1 ).toBool());
- ui.chkEnableZ->setChecked(iniFile.value ( "EnableZ", 1 ).toBool());
-#endif
- ui.yawSpring->setChecked(iniFile.value("yaw-spring", true).toBool());
- ui.deadzone->setValue(iniFile.value("deadzone", 0.02).toDouble());
- ui.constantDrift->setValue(iniFile.value("constant-drift", 0.000005).toDouble());
- ui.persistence->setValue(iniFile.value("persistence", 0.9999).toDouble());
- iniFile.endGroup ();
-
- settingsDirty = false;
-}
-
-//
-// Save the current Settings to the currently 'active' INI-file.
-//
-void TrackerControls::save() {
- QSettings settings("opentrack"); // Registry settings (in HK_USER)
-
- QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString();
- QSettings iniFile( currentFile, QSettings::IniFormat ); // Application settings (in INI-file)
-
- iniFile.beginGroup ( "Rift" );
- iniFile.setValue ( "EnableRoll", ui.chkEnableRoll->isChecked() );
- iniFile.setValue ( "EnablePitch", ui.chkEnablePitch->isChecked() );
- iniFile.setValue ( "EnableYaw", ui.chkEnableYaw->isChecked() );
-#if 0
- iniFile.setValue ( "EnableX", ui.chkEnableX->isChecked() );
- iniFile.setValue ( "EnableY", ui.chkEnableY->isChecked() );
- iniFile.setValue ( "EnableZ", ui.chkEnableZ->isChecked() );
-#endif
- iniFile.setValue("yaw-spring", ui.yawSpring->isChecked());
- iniFile.setValue("deadzone", ui.deadzone->value());
- iniFile.setValue("constant-drift", ui.constantDrift->value());
- iniFile.setValue("persistence", ui.persistence->value());
- iniFile.endGroup ();
-
- settingsDirty = false;
-}
-////////////////////////////////////////////////////////////////////////////////
-// Factory function that creates instances if the Tracker-settings dialog object.
-
-// Export both decorated and undecorated names.
-// GetTrackerDialog - Undecorated name, which can be easily used with GetProcAddress
-// Win32 API function.
-// _GetTrackerDialog@0 - Common name decoration for __stdcall functions in C language.
-//#pragma comment(linker, "/export:GetTrackerDialog=_GetTrackerDialog@0")
-
extern "C" FTNOIR_TRACKER_BASE_EXPORT ITrackerDialog* CALLING_CONVENTION GetDialog( )
{
return new TrackerControls;
diff --git a/ftnoir_tracker_rift/ftnoir_tracker_rift_dll.cpp b/ftnoir_tracker_rift/ftnoir_tracker_rift_dll.cpp
index 3423ba05..2b24411c 100644
--- a/ftnoir_tracker_rift/ftnoir_tracker_rift_dll.cpp
+++ b/ftnoir_tracker_rift/ftnoir_tracker_rift_dll.cpp
@@ -35,15 +35,6 @@ void FTNoIR_TrackerDll::getIcon(QIcon *icon)
*icon = QIcon(":/images/rift_tiny.png");
}
-////////////////////////////////////////////////////////////////////////////////
-// Factory function that creates instances if the Tracker object.
-
-// Export both decorated and undecorated names.
-// GetTrackerDll - Undecorated name, which can be easily used with GetProcAddress
-// Win32 API function.
-// _GetTrackerDll@0 - Common name decoration for __stdcall functions in C language.
-//#pragma comment(linker, "/export:GetTrackerDll=_GetTrackerDll@0")
-
extern "C" FTNOIR_TRACKER_BASE_EXPORT Metadata* CALLING_CONVENTION GetMetadata()
{
return new FTNoIR_TrackerDll;
diff --git a/ftnoir_tracker_udp/ftnoir_tracker_udp.cpp b/ftnoir_tracker_udp/ftnoir_tracker_udp.cpp
index e70bfdc7..02ae21f0 100644
--- a/ftnoir_tracker_udp/ftnoir_tracker_udp.cpp
+++ b/ftnoir_tracker_udp/ftnoir_tracker_udp.cpp
@@ -25,18 +25,8 @@
#include "ftnoir_tracker_udp.h"
#include "facetracknoir/global-settings.h"
-FTNoIR_Tracker::FTNoIR_Tracker()
+FTNoIR_Tracker::FTNoIR_Tracker() : should_quit(false)
{
- inSocket = 0;
- outSocket = 0;
-
- bEnableRoll = true;
- bEnablePitch = true;
- bEnableYaw = true;
- bEnableX = true;
- bEnableY = true;
- bEnableZ = true;
- portAddress = 5551;
should_quit = false;
for (int i = 0; i < 6; i++)
@@ -47,127 +37,46 @@ FTNoIR_Tracker::~FTNoIR_Tracker()
{
should_quit = true;
wait();
- if (inSocket) {
- inSocket->close();
- delete inSocket;
- }
-
- if (outSocket) {
- outSocket->close();
- delete outSocket;
- }
}
/** QThread run @override **/
void FTNoIR_Tracker::run() {
-
-QHostAddress sender;
-quint16 senderPort;
-
- //
- // Read the data that was received.
- //
forever {
if (should_quit)
break;
- if (inSocket != 0) {
- while (inSocket->hasPendingDatagrams()) {
-
+ while (inSocket.hasPendingDatagrams()) {
+ QMutexLocker foo(&mutex);
QByteArray datagram;
- datagram.resize(inSocket->pendingDatagramSize());
- mutex.lock();
- inSocket->readDatagram( (char * ) &newHeadPose, sizeof(newHeadPose), &sender, &senderPort);
- mutex.unlock();
- }
- }
- else {
- break;
- }
-
+ datagram.resize(sizeof(newHeadPose));
+ inSocket.readDatagram((char * ) newHeadPose, sizeof(double[6]));
+ }
usleep(10000);
}
}
void FTNoIR_Tracker::StartTracker(QFrame*)
{
- loadSettings();
- //
- // Create UDP-sockets if they don't exist already.
- // They must be created here, because they must be in the new thread (FTNoIR_Tracker::run())
- //
- if (inSocket == 0) {
- qDebug() << "FTNoIR_Tracker::Initialize() creating insocket";
- inSocket = new QUdpSocket();
- // Connect the inSocket to the port, to receive messages
-
- if (!inSocket->bind(QHostAddress::Any, (int) portAddress, QUdpSocket::ShareAddress | QUdpSocket::ReuseAddressHint)) {
- QMessageBox::warning(0,"FaceTrackNoIR Error", "Unable to bind UDP-port",QMessageBox::Ok,QMessageBox::NoButton);
- delete inSocket;
- inSocket = 0;
- }
- }
+ (void) inSocket.bind(QHostAddress::Any, (int) s.port, QUdpSocket::ShareAddress | QUdpSocket::ReuseAddressHint);
start();
- return;
}
void FTNoIR_Tracker::GetHeadPoseData(double *data)
{
- mutex.lock();
- if (bEnableX) {
+ QMutexLocker foo(&mutex);
+ if (s.enable_x)
data[TX] = newHeadPose[TX];
- }
- if (bEnableX) {
+ if (s.enable_y)
data[TY] = newHeadPose[TY];
- }
- if (bEnableX) {
+ if (s.enable_z)
data[TZ] = newHeadPose[TZ];
- }
- if (bEnableYaw) {
+ if (s.enable_yaw)
data[Yaw] = newHeadPose[Yaw];
- }
- if (bEnablePitch) {
+ if (s.enable_pitch)
data[Pitch] = newHeadPose[Pitch];
- }
- if (bEnableRoll) {
+ if (s.enable_roll)
data[Roll] = newHeadPose[Roll];
- }
- mutex.unlock();
}
-//
-// Load the current Settings from the currently 'active' INI-file.
-//
-void FTNoIR_Tracker::loadSettings() {
-
- qDebug() << "FTNoIR_Tracker::loadSettings says: Starting ";
- QSettings settings("opentrack"); // Registry settings (in HK_USER)
-
- QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString();
- QSettings iniFile( currentFile, QSettings::IniFormat ); // Application settings (in INI-file)
-
- qDebug() << "FTNoIR_Tracker::loadSettings says: iniFile = " << currentFile;
-
- iniFile.beginGroup ( "FTNClient" );
- bEnableRoll = iniFile.value ( "EnableRoll", 1 ).toBool();
- bEnablePitch = iniFile.value ( "EnablePitch", 1 ).toBool();
- bEnableYaw = iniFile.value ( "EnableYaw", 1 ).toBool();
- bEnableX = iniFile.value ( "EnableX", 1 ).toBool();
- bEnableY = iniFile.value ( "EnableY", 1 ).toBool();
- bEnableZ = iniFile.value ( "EnableZ", 1 ).toBool();
- portAddress = (float) iniFile.value ( "PortNumber", 5550 ).toInt();
- iniFile.endGroup ();
-}
-
-
-////////////////////////////////////////////////////////////////////////////////
-// Factory function that creates instances if the Tracker object.
-
-// Export both decorated and undecorated names.
-// GetTracker - Undecorated name, which can be easily used with GetProcAddress
-// Win32 API function.
-// _GetTracker@0 - Common name decoration for __stdcall functions in C language.
-//#pragma comment(linker, "/export:GetTracker=_GetTracker@0")
-
extern "C" FTNOIR_TRACKER_BASE_EXPORT ITracker* CALLING_CONVENTION GetConstructor()
{
return new FTNoIR_Tracker;
diff --git a/ftnoir_tracker_udp/ftnoir_tracker_udp.h b/ftnoir_tracker_udp/ftnoir_tracker_udp.h
index c7e9decf..62eb67df 100644
--- a/ftnoir_tracker_udp/ftnoir_tracker_udp.h
+++ b/ftnoir_tracker_udp/ftnoir_tracker_udp.h
@@ -3,42 +3,47 @@
#include <QThread>
#include <QUdpSocket>
#include <QMessageBox>
-#include <QSettings>
#include <QMutex>
#include <QWaitCondition>
#include <math.h>
#include "facetracknoir/global-settings.h"
+#include "facetracknoir/options.h"
+using namespace options;
+
+struct settings {
+ pbundle b;
+ value<int> port;
+ value<bool> enable_roll, enable_pitch, enable_yaw,
+ enable_x, enable_y, enable_z;
+ settings() :
+ b(bundle("udp-tracker")),
+ port(b, "port", 4242),
+ enable_roll(b, "enable-roll", true),
+ enable_pitch(b, "enable-pitch", true),
+ enable_yaw(b, "enable-yaw", true),
+ enable_x(b, "enable-x", true),
+ enable_y(b, "enable-y", true),
+ enable_z(b, "enable-y", true)
+ {}
+};
class FTNoIR_Tracker : public ITracker, public QThread
{
public:
FTNoIR_Tracker();
- ~FTNoIR_Tracker();
-
+ ~FTNoIR_Tracker();
void StartTracker(QFrame *);
void GetHeadPoseData(double *data);
- void loadSettings();
volatile bool should_quit;
protected:
void run(); // qthread override run method
-
private:
- // UDP socket-variables
- QUdpSocket *inSocket; // Receive from ...
- QUdpSocket *outSocket; // Send to ...
- QHostAddress destIP; // Destination IP-address
- QHostAddress srcIP; // Source IP-address
-
- double newHeadPose[6]; // Structure with new headpose
-
- float portAddress; // Port-number
- bool bEnableRoll;
- bool bEnablePitch;
- bool bEnableYaw;
- bool bEnableX;
- bool bEnableY;
- bool bEnableZ;
+ QUdpSocket inSocket;
+ QHostAddress destIP;
+ QHostAddress srcIP;
+ double newHeadPose[6];
QMutex mutex;
+ settings s;
};
// Widget that has controls for FTNoIR protocol client-settings.
@@ -48,26 +53,14 @@ class TrackerControls: public QWidget, public ITrackerDialog
public:
explicit TrackerControls();
- ~TrackerControls();
- void showEvent (QShowEvent *);
-
- void Initialize(QWidget *parent);
void registerTracker(ITracker *) {}
void unRegisterTracker() {}
-
private:
Ui::UICFTNClientControls ui;
- void loadSettings();
- void save();
-
- /** helper **/
- bool settingsDirty;
-
+ settings s;
private slots:
void doOK();
void doCancel();
- void settingChanged() { settingsDirty = true; };
- void settingChanged(int) { settingsDirty = true; };
};
//*******************************************************************************************************
@@ -76,17 +69,9 @@ private slots:
class FTNoIR_TrackerDll : public Metadata
{
public:
- FTNoIR_TrackerDll();
- ~FTNoIR_TrackerDll();
-
void getFullName(QString *strToBeFilled);
void getShortName(QString *strToBeFilled);
void getDescription(QString *strToBeFilled);
void getIcon(QIcon *icon);
-
-private:
- QString trackerFullName; // Trackers' name and description
- QString trackerShortName;
- QString trackerDescription;
};
diff --git a/ftnoir_tracker_udp/ftnoir_tracker_udp_dialog.cpp b/ftnoir_tracker_udp/ftnoir_tracker_udp_dialog.cpp
index e17d5c32..59026288 100644
--- a/ftnoir_tracker_udp/ftnoir_tracker_udp_dialog.cpp
+++ b/ftnoir_tracker_udp/ftnoir_tracker_udp_dialog.cpp
@@ -25,84 +25,38 @@
#include "ftnoir_tracker_udp.h"
#include "facetracknoir/global-settings.h"
-//*******************************************************************************************************
-// FaceTrackNoIR Client Settings-dialog.
-//*******************************************************************************************************
-
-//
-// Constructor for server-settings-dialog
-//
TrackerControls::TrackerControls() :
QWidget()
{
ui.setupUi( this );
- // Connect Qt signals to member-functions
connect(ui.btnOK, SIGNAL(clicked()), this, SLOT(doOK()));
connect(ui.btnCancel, SIGNAL(clicked()), this, SLOT(doCancel()));
- connect(ui.spinPortNumber, SIGNAL(valueChanged(int)), this, SLOT(settingChanged()));
-
- connect(ui.chkEnableRoll, SIGNAL(stateChanged(int)), this, SLOT(settingChanged(int)));
- connect(ui.chkEnablePitch, SIGNAL(stateChanged(int)), this, SLOT(settingChanged(int)));
- connect(ui.chkEnableYaw, SIGNAL(stateChanged(int)), this, SLOT(settingChanged(int)));
- connect(ui.chkEnableX, SIGNAL(stateChanged(int)), this, SLOT(settingChanged(int)));
- connect(ui.chkEnableY, SIGNAL(stateChanged(int)), this, SLOT(settingChanged(int)));
- connect(ui.chkEnableZ, SIGNAL(stateChanged(int)), this, SLOT(settingChanged(int)));
-
- // Load the settings from the current .INI-file
- loadSettings();
-}
-
-//
-// Destructor for server-dialog
-//
-TrackerControls::~TrackerControls() {
- qDebug() << "~TrackerControls() says: started";
-}
-
-//
-// Initialize tracker-client-dialog
-//
-void TrackerControls::Initialize(QWidget *parent) {
- QPoint offsetpos(100, 100);
- if (parent) {
- this->move(parent->pos() + offsetpos);
- }
- show();
+ tie_setting(s.enable_x, ui.chkEnableX);
+ tie_setting(s.enable_y, ui.chkEnableY);
+ tie_setting(s.enable_z, ui.chkEnableZ);
+ tie_setting(s.enable_yaw, ui.chkEnableYaw);
+ tie_setting(s.enable_pitch, ui.chkEnablePitch);
+ tie_setting(s.enable_roll, ui.chkEnableRoll);
+ tie_setting(s.port, ui.spinPortNumber);
}
-//
-// OK clicked on server-dialog
-//
void TrackerControls::doOK() {
- save();
+ s.b->save();
this->close();
}
-// override show event
-void TrackerControls::showEvent ( QShowEvent * ) {
- loadSettings();
-}
-
-//
-// Cancel clicked on server-dialog
-//
void TrackerControls::doCancel() {
- //
- // Ask if changed Settings should be saved
- //
- if (settingsDirty) {
- int ret = QMessageBox::question ( this, "Settings have changed", "Do you want to save the settings?", QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel, QMessageBox::Discard );
-
- qDebug() << "doCancel says: answer =" << ret;
-
+ if (s.b->modifiedp()) {
+ int ret = QMessageBox::question ( this, "Settings have changed", "Do you want to save the settings?", QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel);
switch (ret) {
case QMessageBox::Save:
- save();
+ s.b->save();
this->close();
break;
case QMessageBox::Discard:
+ s.b->revert();
this->close();
break;
case QMessageBox::Cancel:
@@ -118,64 +72,6 @@ void TrackerControls::doCancel() {
}
}
-
-//
-// Load the current Settings from the currently 'active' INI-file.
-//
-void TrackerControls::loadSettings() {
-
-// qDebug() << "loadSettings says: Starting ";
- QSettings settings("opentrack"); // Registry settings (in HK_USER)
-
- QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString();
- QSettings iniFile( currentFile, QSettings::IniFormat ); // Application settings (in INI-file)
-
-// qDebug() << "loadSettings says: iniFile = " << currentFile;
-
- iniFile.beginGroup ( "FTNClient" );
- ui.chkEnableRoll->setChecked(iniFile.value ( "EnableRoll", 1 ).toBool());
- ui.chkEnablePitch->setChecked(iniFile.value ( "EnablePitch", 1 ).toBool());
- ui.chkEnableYaw->setChecked(iniFile.value ( "EnableYaw", 1 ).toBool());
- ui.chkEnableX->setChecked(iniFile.value ( "EnableX", 1 ).toBool());
- ui.chkEnableY->setChecked(iniFile.value ( "EnableY", 1 ).toBool());
- ui.chkEnableZ->setChecked(iniFile.value ( "EnableZ", 1 ).toBool());
-
- ui.spinPortNumber->setValue( iniFile.value ( "PortNumber", 5550 ).toInt() );
- iniFile.endGroup ();
-
- settingsDirty = false;
-}
-
-//
-// Save the current Settings to the currently 'active' INI-file.
-//
-void TrackerControls::save() {
- QSettings settings("opentrack"); // Registry settings (in HK_USER)
-
- QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString();
- QSettings iniFile( currentFile, QSettings::IniFormat ); // Application settings (in INI-file)
-
- iniFile.beginGroup ( "FTNClient" );
- iniFile.setValue ( "EnableRoll", ui.chkEnableRoll->isChecked() );
- iniFile.setValue ( "EnablePitch", ui.chkEnablePitch->isChecked() );
- iniFile.setValue ( "EnableYaw", ui.chkEnableYaw->isChecked() );
- iniFile.setValue ( "EnableX", ui.chkEnableX->isChecked() );
- iniFile.setValue ( "EnableY", ui.chkEnableY->isChecked() );
- iniFile.setValue ( "EnableZ", ui.chkEnableZ->isChecked() );
- iniFile.setValue ( "PortNumber", ui.spinPortNumber->value() );
- iniFile.endGroup ();
-
- settingsDirty = false;
-}
-////////////////////////////////////////////////////////////////////////////////
-// Factory function that creates instances if the Tracker-settings dialog object.
-
-// Export both decorated and undecorated names.
-// GetTrackerDialog - Undecorated name, which can be easily used with GetProcAddress
-// Win32 API function.
-// _GetTrackerDialog@0 - Common name decoration for __stdcall functions in C language.
-//#pragma comment(linker, "/export:GetTrackerDialog=_GetTrackerDialog@0")
-
extern "C" FTNOIR_TRACKER_BASE_EXPORT ITrackerDialog* CALLING_CONVENTION GetDialog( )
{
return new TrackerControls;
diff --git a/ftnoir_tracker_udp/ftnoir_tracker_udp_dll.cpp b/ftnoir_tracker_udp/ftnoir_tracker_udp_dll.cpp
index 7d7b7c81..22dc7daa 100644
--- a/ftnoir_tracker_udp/ftnoir_tracker_udp_dll.cpp
+++ b/ftnoir_tracker_udp/ftnoir_tracker_udp_dll.cpp
@@ -26,31 +26,19 @@
#include <QDebug>
#include "facetracknoir/global-settings.h"
-FTNoIR_TrackerDll::FTNoIR_TrackerDll() {
- //populate the description strings
- trackerFullName = "UDP";
- trackerShortName = "UDP";
- trackerDescription = "opentrack UDP client";
-}
-
-FTNoIR_TrackerDll::~FTNoIR_TrackerDll()
-{
-
-}
-
void FTNoIR_TrackerDll::getFullName(QString *strToBeFilled)
{
- *strToBeFilled = trackerFullName;
+ *strToBeFilled = "UDP";
}
void FTNoIR_TrackerDll::getShortName(QString *strToBeFilled)
{
- *strToBeFilled = trackerShortName;
+ *strToBeFilled = "UDP";
}
void FTNoIR_TrackerDll::getDescription(QString *strToBeFilled)
{
- *strToBeFilled = trackerDescription;
+ *strToBeFilled = "UDP";
}
void FTNoIR_TrackerDll::getIcon(QIcon *icon)
@@ -58,15 +46,6 @@ void FTNoIR_TrackerDll::getIcon(QIcon *icon)
*icon = QIcon(":/images/facetracknoir.png");
}
-////////////////////////////////////////////////////////////////////////////////
-// Factory function that creates instances if the Tracker object.
-
-// Export both decorated and undecorated names.
-// GetTrackerDll - Undecorated name, which can be easily used with GetProcAddress
-// Win32 API function.
-// _GetTrackerDll@0 - Common name decoration for __stdcall functions in C language.
-//#pragma comment(linker, "/export:GetTrackerDll=_GetTrackerDll@0")
-
extern "C" FTNOIR_TRACKER_BASE_EXPORT Metadata* CALLING_CONVENTION GetMetadata()
{
return new FTNoIR_TrackerDll;
diff --git a/qfunctionconfigurator/functionconfig.h b/qfunctionconfigurator/functionconfig.h
index 9654fffb..4d771dfd 100644
--- a/qfunctionconfigurator/functionconfig.h
+++ b/qfunctionconfigurator/functionconfig.h
@@ -30,7 +30,7 @@ private:
volatile bool _tracking_active;
int _max_Input;
int _max_Output;
- FunctionConfig(const FunctionConfig&) {}
+ FunctionConfig(const FunctionConfig&) = delete;
public:
int maxInput() const { return _max_Input; }
int maxOutput() const { return _max_Output; }