diff --git a/CMakeLists.txt b/CMakeLists.txt index aea4d2c..14bdff9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,13 +1,13 @@ cmake_minimum_required(VERSION 3.5) -project(soccerwindow2 VERSION 2020.08) +project(soccerwindow2 VERSION 2023) if(CMAKE_VERSION VERSION_LESS "3.7.0") set(CMAKE_INCLUDE_CURRENT_DIR ON) endif() # compliler optionsqc -set(CMAKE_CXX_STANDARD 14) +set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED True) if(NOT CMAKE_BUILD_TYPE) diff --git a/configure.ac b/configure.ac index a5b874c..f7b1bb4 100644 --- a/configure.ac +++ b/configure.ac @@ -2,7 +2,7 @@ # Process this file with autoconf to produce a configure script. AC_PREREQ(2.61) -AC_INIT([soccerwindow2], [2020.08], [akky@users.sourceforge.jp]) +AC_INIT([soccerwindow2], [2023], [akky@users.sourceforge.jp]) AC_CONFIG_SRCDIR([config.h.in]) AC_CONFIG_HEADERS([config.h]) @@ -37,54 +37,19 @@ AC_PROG_INSTALL # ---------------------------------------------------------- # check Qt -AC_ARG_ENABLE(qt4, - AC_HELP_STRING([--enable-qt4], - [use Qt4 tool kit instead of Qt5 (default no)])) -AC_ARG_ENABLE(gl, - AC_HELP_STRING([--enable-gl], - [enable GLWidget for Qt (default yes)])) - -if test "x$enable_qt4" == "xyes"; then - AC_MSG_NOTICE(enabled Qt4) - - QTMODULES="QtCore QtGui QtNetwork" - - if test "x$enable_gl" == "xyes"; then - AC_MSG_NOTICE(enabled GLWidget) - CFLAGS="-DUSE_GLWIDGET $CFLAGS" - CXXFLAGS="-DUSE_GLWIDGET $CXXFLAGS" - QTMODULES="$QTMODULES QtOpenGL" - fi - - AX_QT([4.3.0],[$QTMODULES]) -else - AC_MSG_NOTICE(enabled Qt5) - - QTMODULES="Qt5Core Qt5Gui Qt5Widgets Qt5Network" - - if test "x$enable_gl" == "xyes"; then - AC_MSG_NOTICE(enabled GL5Widget) - CFLAGS="-DUSE_GLWIDGET $CFLAGS" - CXXFLAGS="-DUSE_GLWIDGET $CXXFLAGS" - QTMODULES="$QTMODULES Qt5OpenGL" - fi - - AX_QT([5.0.0],[$QTMODULES]) -fi -if test x$have_qt != xyes ; then - AC_MSG_ERROR([$QTMODULES could not be found.]) +AX_HAVE_QT +if test "x$have_qt" != "xyes"; then + AC_MSG_ERROR([Qt not found.]) AM_CONDITIONAL(BUILD_QT, [test "1" = "0"]) else - CFLAGS="-fPIC $CFLAGS" - CXXFLAGS="-fPIC $CXXFLAGS" AM_CONDITIONAL(BUILD_QT, [test "1" = "1"]) fi # ---------------------------------------------------------- # check C++ -AX_CXX_COMPILE_STDCXX_14(noext) +AX_CXX_COMPILE_STDCXX_17(noext) # ---------------------------------------------------------- # check boost diff --git a/m4/ax_boost_base.m4 b/m4/ax_boost_base.m4 index d540395..b1fed7a 100644 --- a/m4/ax_boost_base.m4 +++ b/m4/ax_boost_base.m4 @@ -11,9 +11,9 @@ # Test for the Boost C++ libraries of a particular version (or newer) # # If no path to the installed boost library is given the macro searchs -# under /usr, /usr/local, /opt and /opt/local and evaluates the -# $BOOST_ROOT environment variable. Further documentation is available at -# . +# under /usr, /usr/local, /opt, /opt/local and /opt/homebrew and evaluates +# the $BOOST_ROOT environment variable. Further documentation is available +# at . # # This macro calls: # @@ -33,7 +33,7 @@ # and this notice are preserved. This file is offered as-is, without any # warranty. -#serial 45 +#serial 52 # example boost program (need to pass version) m4_define([_AX_BOOST_BASE_PROGRAM], @@ -113,7 +113,8 @@ AC_DEFUN([_AX_BOOST_BASE_RUNDETECT],[ dnl are found, e.g. when only header-only libraries are installed! AS_CASE([${host_cpu}], [x86_64],[libsubdirs="lib64 libx32 lib lib64"], - [ppc64|powerpc64|s390x|sparc64|aarch64|ppc64le|powerpc64le|riscv64],[libsubdirs="lib64 lib lib64"], + [mips*64*],[libsubdirs="lib64 lib32 lib lib64"], + [ppc64|powerpc64|s390x|sparc64|aarch64|ppc64le|powerpc64le|riscv64|e2k|loongarch64],[libsubdirs="lib64 lib lib64"], [libsubdirs="lib"] ) @@ -122,11 +123,12 @@ AC_DEFUN([_AX_BOOST_BASE_RUNDETECT],[ dnl are almost assuredly the ones desired. AS_CASE([${host_cpu}], [i?86],[multiarch_libsubdir="lib/i386-${host_os}"], + [armv7l],[multiarch_libsubdir="lib/arm-${host_os}"], [multiarch_libsubdir="lib/${host_cpu}-${host_os}"] ) dnl first we check the system location for boost libraries - dnl this location ist chosen if boost libraries are installed with the --layout=system option + dnl this location is chosen if boost libraries are installed with the --layout=system option dnl or if you install boost with RPM AS_IF([test "x$_AX_BOOST_BASE_boost_path" != "x"],[ AC_MSG_CHECKING([for boostlib >= $1 ($WANT_BOOST_VERSION) includes in "$_AX_BOOST_BASE_boost_path/include"]) @@ -149,7 +151,7 @@ AC_DEFUN([_AX_BOOST_BASE_RUNDETECT],[ else search_libsubdirs="$multiarch_libsubdir $libsubdirs" fi - for _AX_BOOST_BASE_boost_path_tmp in /usr /usr/local /opt /opt/local ; do + for _AX_BOOST_BASE_boost_path_tmp in /usr /usr/local /opt /opt/local /opt/homebrew ; do if test -d "$_AX_BOOST_BASE_boost_path_tmp/include/boost" && test -r "$_AX_BOOST_BASE_boost_path_tmp/include/boost" ; then for libsubdir in $search_libsubdirs ; do if ls "$_AX_BOOST_BASE_boost_path_tmp/$libsubdir/libboost_"* >/dev/null 2>&1 ; then break; fi @@ -225,7 +227,7 @@ AC_DEFUN([_AX_BOOST_BASE_RUNDETECT],[ fi else if test "x$cross_compiling" != "xyes" ; then - for _AX_BOOST_BASE_boost_path in /usr /usr/local /opt /opt/local ; do + for _AX_BOOST_BASE_boost_path in /usr /usr/local /opt /opt/local /opt/homebrew ; do if test -d "$_AX_BOOST_BASE_boost_path" && test -r "$_AX_BOOST_BASE_boost_path" ; then for i in `ls -d $_AX_BOOST_BASE_boost_path/include/boost-* 2>/dev/null`; do _version_tmp=`echo $i | sed "s#$_AX_BOOST_BASE_boost_path##" | sed 's/\/include\/boost-//' | sed 's/_/./'` diff --git a/m4/ax_boost_system.m4 b/m4/ax_boost_system.m4 index 207d7be..323e2a6 100644 --- a/m4/ax_boost_system.m4 +++ b/m4/ax_boost_system.m4 @@ -31,7 +31,7 @@ # and this notice are preserved. This file is offered as-is, without any # warranty. -#serial 19 +#serial 20 AC_DEFUN([AX_BOOST_SYSTEM], [ @@ -108,7 +108,7 @@ AC_DEFUN([AX_BOOST_SYSTEM], fi if test "x$ax_lib" = "x"; then - AC_MSG_ERROR(Could not find a version of the library!) + AC_MSG_ERROR(Could not find a version of the Boost::System library!) fi if test "x$link_system" = "xno"; then AC_MSG_ERROR(Could not link against $ax_lib !) diff --git a/m4/ax_cxx_compile_stdcxx.m4 b/m4/ax_cxx_compile_stdcxx.m4 index 9e9eaed..8edf515 100644 --- a/m4/ax_cxx_compile_stdcxx.m4 +++ b/m4/ax_cxx_compile_stdcxx.m4 @@ -10,13 +10,13 @@ # # Check for baseline language coverage in the compiler for the specified # version of the C++ standard. If necessary, add switches to CXX and -# CXXCPP to enable support. VERSION may be '11' (for the C++11 standard) -# or '14' (for the C++14 standard). +# CXXCPP to enable support. VERSION may be '11', '14', '17', or '20' for +# the respective C++ standard version. # # The second argument, if specified, indicates whether you insist on an # extended mode (e.g. -std=gnu++11) or a strict conformance mode (e.g. # -std=c++11). If neither is specified, you get whatever works, with -# preference for an extended mode. +# preference for no added switch, and then for an extended mode. # # The third argument, if specified 'mandatory' or if left unspecified, # indicates that baseline support for the specified C++ standard is @@ -34,13 +34,16 @@ # Copyright (c) 2015 Paul Norman # Copyright (c) 2015 Moritz Klammler # Copyright (c) 2016, 2018 Krzesimir Nowak +# Copyright (c) 2019 Enji Cooper +# Copyright (c) 2020 Jason Merrill +# Copyright (c) 2021 Jörn Heusipp # # Copying and distribution of this file, with or without modification, are # permitted in any medium without royalty provided the copyright notice # and this notice are preserved. This file is offered as-is, without any # warranty. -#serial 10 +#serial 18 dnl This macro is based on the code from the AX_CXX_COMPILE_STDCXX_11 macro dnl (serial version number 13). @@ -49,6 +52,7 @@ AC_DEFUN([AX_CXX_COMPILE_STDCXX], [dnl m4_if([$1], [11], [ax_cxx_compile_alternatives="11 0x"], [$1], [14], [ax_cxx_compile_alternatives="14 1y"], [$1], [17], [ax_cxx_compile_alternatives="17 1z"], + [$1], [20], [ax_cxx_compile_alternatives="20"], [m4_fatal([invalid first argument `$1' to AX_CXX_COMPILE_STDCXX])])dnl m4_if([$2], [], [], [$2], [ext], [], @@ -61,6 +65,16 @@ AC_DEFUN([AX_CXX_COMPILE_STDCXX], [dnl AC_LANG_PUSH([C++])dnl ac_success=no + m4_if([$2], [], [dnl + AC_CACHE_CHECK(whether $CXX supports C++$1 features by default, + ax_cv_cxx_compile_cxx$1, + [AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_testbody_$1])], + [ax_cv_cxx_compile_cxx$1=yes], + [ax_cv_cxx_compile_cxx$1=no])]) + if test x$ax_cv_cxx_compile_cxx$1 = xyes; then + ac_success=yes + fi]) + m4_if([$2], [noext], [], [dnl if test x$ac_success = xno; then for alternative in ${ax_cxx_compile_alternatives}; do @@ -90,9 +104,18 @@ AC_DEFUN([AX_CXX_COMPILE_STDCXX], [dnl dnl HP's aCC needs +std=c++11 according to: dnl http://h21007.www2.hp.com/portal/download/files/unprot/aCxx/PDF_Release_Notes/769149-001.pdf dnl Cray's crayCC needs "-h std=c++11" + dnl MSVC needs -std:c++NN for C++17 and later (default is C++14) for alternative in ${ax_cxx_compile_alternatives}; do - for switch in -std=c++${alternative} +std=c++${alternative} "-h std=c++${alternative}"; do - cachevar=AS_TR_SH([ax_cv_cxx_compile_cxx$1_$switch]) + for switch in -std=c++${alternative} +std=c++${alternative} "-h std=c++${alternative}" MSVC; do + if test x"$switch" = xMSVC; then + dnl AS_TR_SH maps both `:` and `=` to `_` so -std:c++17 would collide + dnl with -std=c++17. We suffix the cache variable name with _MSVC to + dnl avoid this. + switch=-std:c++${alternative} + cachevar=AS_TR_SH([ax_cv_cxx_compile_cxx$1_${switch}_MSVC]) + else + cachevar=AS_TR_SH([ax_cv_cxx_compile_cxx$1_$switch]) + fi AC_CACHE_CHECK(whether $CXX supports C++$1 features with $switch, $cachevar, [ac_save_CXX="$CXX" @@ -139,7 +162,6 @@ m4_define([_AX_CXX_COMPILE_STDCXX_testbody_11], _AX_CXX_COMPILE_STDCXX_testbody_new_in_11 ) - dnl Test body for checking C++14 support m4_define([_AX_CXX_COMPILE_STDCXX_testbody_14], @@ -147,12 +169,24 @@ m4_define([_AX_CXX_COMPILE_STDCXX_testbody_14], _AX_CXX_COMPILE_STDCXX_testbody_new_in_14 ) +dnl Test body for checking C++17 support + m4_define([_AX_CXX_COMPILE_STDCXX_testbody_17], _AX_CXX_COMPILE_STDCXX_testbody_new_in_11 _AX_CXX_COMPILE_STDCXX_testbody_new_in_14 _AX_CXX_COMPILE_STDCXX_testbody_new_in_17 ) +dnl Test body for checking C++20 support + +m4_define([_AX_CXX_COMPILE_STDCXX_testbody_20], + _AX_CXX_COMPILE_STDCXX_testbody_new_in_11 + _AX_CXX_COMPILE_STDCXX_testbody_new_in_14 + _AX_CXX_COMPILE_STDCXX_testbody_new_in_17 + _AX_CXX_COMPILE_STDCXX_testbody_new_in_20 +) + + dnl Tests for new features in C++11 m4_define([_AX_CXX_COMPILE_STDCXX_testbody_new_in_11], [[ @@ -164,7 +198,11 @@ m4_define([_AX_CXX_COMPILE_STDCXX_testbody_new_in_11], [[ #error "This is not a C++ compiler" -#elif __cplusplus < 201103L +// MSVC always sets __cplusplus to 199711L in older versions; newer versions +// only set it correctly if /Zc:__cplusplus is specified as well as a +// /std:c++NN switch: +// https://devblogs.microsoft.com/cppblog/msvc-now-correctly-reports-__cplusplus/ +#elif __cplusplus < 201103L && !defined _MSC_VER #error "This is not a C++11 compiler" @@ -189,11 +227,13 @@ namespace cxx11 struct Base { + virtual ~Base() {} virtual void f() {} }; struct Derived : public Base { + virtual ~Derived() override {} virtual void f() override {} }; @@ -453,7 +493,7 @@ m4_define([_AX_CXX_COMPILE_STDCXX_testbody_new_in_14], [[ #error "This is not a C++ compiler" -#elif __cplusplus < 201402L +#elif __cplusplus < 201402L && !defined _MSC_VER #error "This is not a C++14 compiler" @@ -577,7 +617,7 @@ m4_define([_AX_CXX_COMPILE_STDCXX_testbody_new_in_17], [[ #error "This is not a C++ compiler" -#elif __cplusplus < 201703L +#elif __cplusplus < 201703L && !defined _MSC_VER #error "This is not a C++17 compiler" @@ -943,6 +983,36 @@ namespace cxx17 } // namespace cxx17 -#endif // __cplusplus < 201703L +#endif // __cplusplus < 201703L && !defined _MSC_VER + +]]) + + +dnl Tests for new features in C++20 + +m4_define([_AX_CXX_COMPILE_STDCXX_testbody_new_in_20], [[ + +#ifndef __cplusplus + +#error "This is not a C++ compiler" + +#elif __cplusplus < 202002L && !defined _MSC_VER + +#error "This is not a C++20 compiler" + +#else + +#include + +namespace cxx20 +{ + +// As C++20 supports feature test macros in the standard, there is no +// immediate need to actually test for feature availability on the +// Autoconf side. + +} // namespace cxx20 + +#endif // __cplusplus < 202002L && !defined _MSC_VER ]]) diff --git a/m4/ax_cxx_compile_stdcxx_17.m4 b/m4/ax_cxx_compile_stdcxx_17.m4 new file mode 100644 index 0000000..a683417 --- /dev/null +++ b/m4/ax_cxx_compile_stdcxx_17.m4 @@ -0,0 +1,35 @@ +# ============================================================================= +# https://www.gnu.org/software/autoconf-archive/ax_cxx_compile_stdcxx_17.html +# ============================================================================= +# +# SYNOPSIS +# +# AX_CXX_COMPILE_STDCXX_17([ext|noext], [mandatory|optional]) +# +# DESCRIPTION +# +# Check for baseline language coverage in the compiler for the C++17 +# standard; if necessary, add switches to CXX and CXXCPP to enable +# support. +# +# This macro is a convenience alias for calling the AX_CXX_COMPILE_STDCXX +# macro with the version set to C++17. The two optional arguments are +# forwarded literally as the second and third argument respectively. +# Please see the documentation for the AX_CXX_COMPILE_STDCXX macro for +# more information. If you want to use this macro, you also need to +# download the ax_cxx_compile_stdcxx.m4 file. +# +# LICENSE +# +# Copyright (c) 2015 Moritz Klammler +# Copyright (c) 2016 Krzesimir Nowak +# +# Copying and distribution of this file, with or without modification, are +# permitted in any medium without royalty provided the copyright notice +# and this notice are preserved. This file is offered as-is, without any +# warranty. + +#serial 2 + +AX_REQUIRE_DEFINED([AX_CXX_COMPILE_STDCXX]) +AC_DEFUN([AX_CXX_COMPILE_STDCXX_17], [AX_CXX_COMPILE_STDCXX([17], [$1], [$2])]) diff --git a/m4/ax_have_qt.m4 b/m4/ax_have_qt.m4 new file mode 100644 index 0000000..95d4940 --- /dev/null +++ b/m4/ax_have_qt.m4 @@ -0,0 +1,246 @@ +# =========================================================================== +# https://www.gnu.org/software/autoconf-archive/ax_have_qt.html +# =========================================================================== +# +# SYNOPSIS +# +# AX_HAVE_QT +# +# DESCRIPTION +# +# Searches $PATH and queries qmake for Qt include files, libraries and Qt +# binary utilities. The macro only supports Qt5 or later. +# +# The following shell variable is set to either "yes" or "no": +# +# have_qt +# +# Additionally, the following variables are exported: +# +# QT_CXXFLAGS +# QT_LIBS +# QT_MOC +# QT_UIC +# QT_RCC +# QT_LRELEASE +# QT_LUPDATE +# QT_DIR +# QMAKE +# +# which respectively contain an "-I" flag pointing to the Qt include +# directory, link flags necessary to link with Qt and X, the full path to +# the meta object compiler and the user interface compiler both, and +# finally the variable QTDIR as Qt likes to see it defined. +# +# Example lines for Makefile.in: +# +# CXXFLAGS = @QT_CXXFLAGS@ +# MOC = @QT_MOC@ +# +# After the variables have been set, a trial compile and link is performed +# to check the correct functioning of the meta object compiler. This test +# may fail when the different detected elements stem from different +# releases of the Qt framework. In that case, an error message is emitted +# and configure stops. +# +# No common variables such as $LIBS or $CFLAGS are polluted. +# +# LICENSE +# +# Copyright (c) 2008 Bastiaan Veelo +# Copyright (c) 2014 Alex Henrie +# +# Copying and distribution of this file, with or without modification, are +# permitted in any medium without royalty provided the copyright notice +# and this notice are preserved. This file is offered as-is, without any +# warranty. + +#serial 25 + +AU_ALIAS([BNV_HAVE_QT], [AX_HAVE_QT]) +AC_DEFUN([AX_HAVE_QT], +[ + AC_REQUIRE([AC_PROG_CXX]) + AC_REQUIRE([AC_PATH_X]) + AC_REQUIRE([AC_PATH_XTRA]) + # openSUSE leap 15.3 installs qmake-qt5, not qmake, for example. + # Store the full name (like qmake-qt5) into QMAKE + # and the specifier (like -qt5 or empty) into am_have_qt_qmexe_suff. + AC_ARG_VAR([QMAKE],"Qt make tool") + AC_CHECK_TOOLS([QMAKE],[qmake qmake-qt6 qmake-qt5],[false]) + + AC_MSG_CHECKING(for Qt) + am_have_qt_qmexe_suff=`echo $QMAKE | sed 's,^.*qmake,,'` + # If we have Qt5 or later in the path, we're golden + ver=`$QMAKE --version | grep -o "Qt version ."` + + if test "$ver" ">" "Qt version 4"; then + have_qt=yes + # This pro file dumps qmake's variables, but it only works on Qt 5 or later + am_have_qt_dir=`mktemp -d` + am_have_qt_pro="$am_have_qt_dir/test.pro" + am_have_qt_stash="$am_have_qt_dir/.qmake.stash" + am_have_qt_makefile="$am_have_qt_dir/Makefile" + # http://qt-project.org/doc/qt-5/qmake-variable-reference.html#qt + cat > $am_have_qt_pro << EOF +win32 { + CONFIG -= debug_and_release + CONFIG += release +} +qtHaveModule(axcontainer): QT += axcontainer +qtHaveModule(axserver): QT += axserver +qtHaveModule(concurrent): QT += concurrent +qtHaveModule(core): QT += core +qtHaveModule(dbus): QT += dbus +qtHaveModule(declarative): QT += declarative +qtHaveModule(designer): QT += designer +qtHaveModule(gui): QT += gui +qtHaveModule(help): QT += help +qtHaveModule(multimedia): QT += multimedia +qtHaveModule(multimediawidgets): QT += multimediawidgets +qtHaveModule(network): QT += network +qtHaveModule(opengl): QT += opengl +qtHaveModule(printsupport): QT += printsupport +qtHaveModule(qml): QT += qml +qtHaveModule(qmltest): QT += qmltest +qtHaveModule(x11extras): QT += x11extras +qtHaveModule(script): QT += script +qtHaveModule(scripttools): QT += scripttools +qtHaveModule(sensors): QT += sensors +qtHaveModule(serialport): QT += serialport +qtHaveModule(sql): QT += sql +qtHaveModule(svg): QT += svg +qtHaveModule(testlib): QT += testlib +qtHaveModule(uitools): QT += uitools +qtHaveModule(webkit): QT += webkit +qtHaveModule(webkitwidgets): QT += webkitwidgets +qtHaveModule(xml): QT += xml +qtHaveModule(xmlpatterns): QT += xmlpatterns +percent.target = % +percent.commands = @echo -n "\$(\$(@))\ " +QMAKE_EXTRA_TARGETS += percent +EOF + $QMAKE $am_have_qt_pro -o $am_have_qt_makefile + QT_CXXFLAGS=`cd $am_have_qt_dir; make -s -f $am_have_qt_makefile CXXFLAGS INCPATH` + QT_LIBS=`cd $am_have_qt_dir; make -s -f $am_have_qt_makefile LIBS` + rm $am_have_qt_pro $am_have_qt_stash $am_have_qt_makefile + rmdir $am_have_qt_dir + + # Look for specific tools in $PATH + QT_MOC=`which moc$am_have_qt_qmexe_suff` + QT_UIC=`which uic$am_have_qt_qmexe_suff` + QT_RCC=`which rcc$am_have_qt_qmexe_suff` + QT_LRELEASE=`which lrelease$am_have_qt_qmexe_suff` + QT_LUPDATE=`which lupdate$am_have_qt_qmexe_suff` + + # Get Qt version from qmake + QT_DIR=`$QMAKE --version | grep -o -E /.+` + + # All variables are defined, report the result + AC_MSG_RESULT([$have_qt: + QT_CXXFLAGS=$QT_CXXFLAGS + QT_DIR=$QT_DIR + QT_LIBS=$QT_LIBS + QT_UIC=$QT_UIC + QT_MOC=$QT_MOC + QT_RCC=$QT_RCC + QT_LRELEASE=$QT_LRELEASE + QT_LUPDATE=$QT_LUPDATE]) + else + # Qt was not found + have_qt=no + QT_CXXFLAGS= + QT_DIR= + QT_LIBS= + QT_UIC= + QT_MOC= + QT_RCC= + QT_LRELEASE= + QT_LUPDATE= + AC_MSG_RESULT($have_qt) + fi + AC_SUBST(QT_CXXFLAGS) + AC_SUBST(QT_DIR) + AC_SUBST(QT_LIBS) + AC_SUBST(QT_UIC) + AC_SUBST(QT_MOC) + AC_SUBST(QT_RCC) + AC_SUBST(QT_LRELEASE) + AC_SUBST(QT_LUPDATE) + AC_SUBST(QMAKE) + + #### Being paranoid: + if test x"$have_qt" = xyes; then + AC_MSG_CHECKING(correct functioning of Qt installation) + AC_CACHE_VAL(ax_cv_qt_test_result, + [ + cat > ax_qt_test.h << EOF +#include +class Test : public QObject +{ +Q_OBJECT +public: + Test() {} + ~Test() {} +public slots: + void receive() {} +signals: + void send(); +}; +EOF + + cat > ax_qt_main.$ac_ext << EOF +#include "ax_qt_test.h" +#include +int main( int argc, char **argv ) +{ + QApplication app( argc, argv ); + Test t; + QObject::connect( &t, SIGNAL(send()), &t, SLOT(receive()) ); +} +EOF + + ax_cv_qt_test_result="failure" + ax_try_1="$QT_MOC ax_qt_test.h -o moc_ax_qt_test.$ac_ext >/dev/null 2>/dev/null" + AC_TRY_EVAL(ax_try_1) + if test x"$ac_status" != x0; then + echo "$ax_err_1" >&AS_MESSAGE_LOG_FD + echo "configure: could not run $QT_MOC on:" >&AS_MESSAGE_LOG_FD + cat ax_qt_test.h >&AS_MESSAGE_LOG_FD + else + ax_try_2="$CXX $QT_CXXFLAGS -c $CXXFLAGS -o moc_ax_qt_test.o moc_ax_qt_test.$ac_ext >/dev/null 2>/dev/null" + AC_TRY_EVAL(ax_try_2) + if test x"$ac_status" != x0; then + echo "$ax_err_2" >&AS_MESSAGE_LOG_FD + echo "configure: could not compile:" >&AS_MESSAGE_LOG_FD + cat moc_ax_qt_test.$ac_ext >&AS_MESSAGE_LOG_FD + else + ax_try_3="$CXX $QT_CXXFLAGS -c $CXXFLAGS -o ax_qt_main.o ax_qt_main.$ac_ext >/dev/null 2>/dev/null" + AC_TRY_EVAL(ax_try_3) + if test x"$ac_status" != x0; then + echo "$ax_err_3" >&AS_MESSAGE_LOG_FD + echo "configure: could not compile:" >&AS_MESSAGE_LOG_FD + cat ax_qt_main.$ac_ext >&AS_MESSAGE_LOG_FD + else + ax_try_4="$CXX -o ax_qt_main ax_qt_main.o moc_ax_qt_test.o $QT_LIBS $LIBS >/dev/null 2>/dev/null" + AC_TRY_EVAL(ax_try_4) + if test x"$ac_status" != x0; then + echo "$ax_err_4" >&AS_MESSAGE_LOG_FD + else + ax_cv_qt_test_result="success" + fi + fi + fi + fi + ])dnl AC_CACHE_VAL ax_cv_qt_test_result + AC_MSG_RESULT([$ax_cv_qt_test_result]) + if test x"$ax_cv_qt_test_result" = "xfailure"; then + AC_MSG_ERROR([Failed to find matching components of a complete + Qt installation. Try using more options, + see ./configure --help.]) + fi + + rm -f ax_qt_test.h moc_ax_qt_test.$ac_ext moc_ax_qt_test.o \ + ax_qt_main.$ac_ext ax_qt_main.o ax_qt_main + fi +]) diff --git a/src/model/main_data.cpp b/src/model/main_data.cpp index 8d592dc..43ebebd 100644 --- a/src/model/main_data.cpp +++ b/src/model/main_data.cpp @@ -41,7 +41,7 @@ #include "options.h" #include "view_holder.h" -#include +//#include #include #ifndef NO_TIMER @@ -206,13 +206,13 @@ bool MainData::receiveMonitorPacket( const char * message, const int client_version ) { - if ( client_version == 4 ) - { - rcsc::rcg::ParserV5 p; - return p.parseLine( 0, message, M_view_holder ); - } + // if ( client_version == 4 ) + // { + // rcsc::rcg::ParserV5 p; + // return p.parseLine( 0, message, M_view_holder ); + // } - if ( client_version == 3 ) + if ( client_version >= 3 ) { rcsc::rcg::ParserV4 p; return p.parseLine( 0, message, M_view_holder ); diff --git a/src/model/options.cpp b/src/model/options.cpp index 46721f8..6f91591 100644 --- a/src/model/options.cpp +++ b/src/model/options.cpp @@ -85,7 +85,7 @@ Options::Options() : M_connect( false ), M_host( "127.0.0.1" ), M_port( 6000 ), - M_client_version( 4 ), + M_client_version( 5 ), M_wait_seconds( 5 ), M_auto_quit_mode( false ), M_kill_server( false ), @@ -142,6 +142,7 @@ Options::Options() M_show_player_number( true ), M_show_player_type( false ), M_show_view_area( true ), + M_show_focus_point( false ), M_show_illegal_defense_state( true ), M_show_pointto( true ), M_show_attentionto( false ), @@ -156,6 +157,7 @@ Options::Options() M_enlarge_mode( true ), M_ball_size( 0.35 ), M_player_size( 0.0 ), + M_focus_point_size( 2.0 ), M_show_voronoi_diagram( false ), M_show_delaunay_triangulation( false ), M_voronoi_target( rcsc::NEUTRAL ), @@ -400,12 +402,18 @@ Options::parseCmdLine( int argc, ( "show-view-area", "", rcsc::BoolSwitch( &M_show_view_area ), "show player\'s view area." ) - ( "show-illegal-defense-state", "", - rcsc::BoolSwitch( &M_show_illegal_defense_state ), - "show player\'s illegal defense state." ) ( "hide-view-area", "", rcsc::NegateSwitch( &M_show_view_area ), "show player\'s view area." ) + ( "show-focus-point", "", + rcsc::BoolSwitch( &M_show_focus_point ), + "show player\'s view area." ) + ( "hide-focus-point", "", + rcsc::NegateSwitch( &M_show_focus_point ), + "hide player\'s focus point." ) + ( "show-illegal-defense-state", "", + rcsc::BoolSwitch( &M_show_illegal_defense_state ), + "show player\'s illegal defense state." ) ( "show-pointto", "", rcsc::BoolSwitch( &M_show_pointto ), "show player\'s pointto information." ) @@ -445,6 +453,9 @@ Options::parseCmdLine( int argc, ( "player-size", "", &M_player_size, "set a fixed player radius in enlarge mode." ) + ( "focus-point-size", "", + &M_focus_point_size, + "set the radius of the focus point." ) ; debug_server_options.add() @@ -765,6 +776,8 @@ Options::parseCmdLine( int argc, if ( M_player_size < 0.0 ) M_player_size = 0.0; + if ( M_focus_point_size < 0.1 ) M_focus_point_size = 0.1; + return true; } @@ -895,6 +908,17 @@ Options::setPlayerSize( const double & size ) M_player_size = size; } +/*-------------------------------------------------------------------*/ +/*! + + */ +void +Options::setFocusPointSize( const double size ) +{ + if ( size < 0.1 ) return; + M_focus_point_size = size; +} + /*-------------------------------------------------------------------*/ /*! diff --git a/src/model/options.h b/src/model/options.h index 3458886..b71bd50 100644 --- a/src/model/options.h +++ b/src/model/options.h @@ -182,6 +182,7 @@ class Options { bool M_show_player_number; bool M_show_player_type; bool M_show_view_area; + bool M_show_focus_point; bool M_show_illegal_defense_state; bool M_show_pointto; bool M_show_attentionto; @@ -199,6 +200,7 @@ class Options { bool M_enlarge_mode; double M_ball_size; double M_player_size; + double M_focus_point_size; // computational geometry @@ -510,6 +512,9 @@ class Options { void toggleShowViewArea() { M_show_view_area = ! M_show_view_area; } bool showViewArea() const { return M_show_view_area; } + void toggleShowFocusPoint() { M_show_focus_point = ! M_show_focus_point; } + bool showFocusPoint() const { return M_show_focus_point; } + void toggleShowIllegalDefenseState() { M_show_illegal_defense_state = ! M_show_illegal_defense_state; } bool showIllegalDefenseState() const { return M_show_illegal_defense_state; } @@ -557,6 +562,9 @@ class Options { void setPlayerSize( const double & size ); const double & playerSize() const { return M_player_size; } + void setFocusPointSize( const double size ); + double focusPointSize() const { return M_focus_point_size; } + void setFocusType( const FocusType type ) { M_focus_type = type; } FocusType focusType() const { return M_focus_type; } diff --git a/src/model/trainer_data.cpp b/src/model/trainer_data.cpp index 49983b1..18455c0 100644 --- a/src/model/trainer_data.cpp +++ b/src/model/trainer_data.cpp @@ -43,7 +43,7 @@ TrainerData::TrainerData() : M_drag_mode( false ) , M_dragged_player_side( rcsc::NEUTRAL ) , M_dragged_player_number( 0 ) - , M_play_mode( rcsc::PM_Drop_Ball ) + , M_playmode( rcsc::PM_PlayOn ) , M_ball_move_pos( 0.0, 0.0 ) , M_ball_move_vel( 0.0, 0.0 ) { @@ -54,6 +54,25 @@ TrainerData::TrainerData() } } +/*-------------------------------------------------------------------*/ +void +TrainerData::setPlayMode( const std::string & playmode_str ) +{ + const char * playmode_strings[] = PLAYMODE_STRINGS; + + rcsc::PlayMode new_playmode = rcsc::PM_PlayOn; // default + for ( int i = 0; i < rcsc::PM_MAX; ++i ) + { + if ( playmode_str == playmode_strings[i] ) + { + new_playmode = static_cast< rcsc::PlayMode >( i ); + break; + } + } + + M_playmode = new_playmode; +} + /*-------------------------------------------------------------------*/ /*! diff --git a/src/model/trainer_data.h b/src/model/trainer_data.h index ab39c32..e58aa83 100644 --- a/src/model/trainer_data.h +++ b/src/model/trainer_data.h @@ -43,7 +43,7 @@ class TrainerData { rcsc::SideID M_dragged_player_side; int M_dragged_player_number; - rcsc::PlayMode M_play_mode; + rcsc::PlayMode M_playmode; rcsc::Vector2D M_ball_move_pos; rcsc::Vector2D M_ball_move_vel; @@ -68,14 +68,16 @@ class TrainerData { M_drag_mode = ! M_drag_mode; } - rcsc::PlayMode playMode() const + rcsc::PlayMode playmode() const { - return M_play_mode; + return M_playmode; } void setPlayMode( const rcsc::PlayMode mode ) { - M_play_mode = mode; + M_playmode = mode; } + void setPlayMode( const std::string & playmode_str ); + const rcsc::Vector2D & ballPos() const diff --git a/src/qt/CMakeLists.txt b/src/qt/CMakeLists.txt index 1f6a806..4025e38 100644 --- a/src/qt/CMakeLists.txt +++ b/src/qt/CMakeLists.txt @@ -29,7 +29,6 @@ add_executable(soccerwindow2 main.cpp main_window.cpp monitor_client.cpp - monitor_move_dialog.cpp offside_line_painter.cpp player_control_painter.cpp player_painter.cpp @@ -39,6 +38,7 @@ add_executable(soccerwindow2 score_board_painter.cpp score_board_painter_rcss.cpp team_graphic_painter.cpp + trainer_dialog.cpp view_config_dialog.cpp voronoi_diagram_painter.cpp ) diff --git a/src/qt/Makefile.am b/src/qt/Makefile.am index 0aa8a4a..85708c4 100644 --- a/src/qt/Makefile.am +++ b/src/qt/Makefile.am @@ -34,7 +34,6 @@ soccerwindow2_SOURCES = \ main.cpp \ main_window.cpp \ monitor_client.cpp \ - monitor_move_dialog.cpp \ offside_line_painter.cpp \ player_control_painter.cpp \ player_painter.cpp \ @@ -44,6 +43,7 @@ soccerwindow2_SOURCES = \ score_board_painter.cpp \ score_board_painter_rcss.cpp \ team_graphic_painter.cpp \ + trainer_dialog.cpp \ view_config_dialog.cpp \ voronoi_diagram_painter.cpp @@ -65,8 +65,8 @@ nodist_soccerwindow2_SOURCES = \ moc_log_player_tool_bar.cpp \ moc_main_window.cpp \ moc_monitor_client.cpp \ - moc_monitor_move_dialog.cpp \ moc_player_type_dialog.cpp \ + moc_trainer_dialog.cpp \ moc_view_config_dialog.cpp noinst_HEADERS = \ @@ -96,7 +96,6 @@ noinst_HEADERS = \ log_player_tool_bar.h \ main_window.h \ monitor_client.h \ - monitor_move_dialog.h \ mouse_state.h \ offside_line_painter.h \ painter_interface.h \ @@ -108,6 +107,7 @@ noinst_HEADERS = \ score_board_painter.h \ score_board_painter_rcss.h \ team_graphic_painter.h \ + trainer_dialog.h \ view_config_dialog.h \ voronoi_diagram_painter.h @@ -115,7 +115,7 @@ noinst_HEADERS = \ soccerwindow2_CPPFLAGS = -I$(top_srcdir)/src/model $(QT_CPPFLAGS) soccerwindow2_CXXFLAGS = $(QT_CXXFLAGS) -Wall -W -Wno-deprecated-copy soccerwindow2_LDFLAGS = $(QT_LDFLAGS) -soccerwindow2_LDADD = $(top_builddir)/src/model/libsoccerwindow2_model.a $(QT_LDADD) +soccerwindow2_LDADD = $(top_builddir)/src/model/libsoccerwindow2_model.a $(QT_LIBS) #soccerwindow2_LIBADD = ../model/libsoccerwindow2_model.a # source files from headers generated by Meta Object Compiler diff --git a/src/qt/debug_message_window.cpp b/src/qt/debug_message_window.cpp index 60329b9..78c70b5 100644 --- a/src/qt/debug_message_window.cpp +++ b/src/qt/debug_message_window.cpp @@ -759,6 +759,18 @@ DebugMessageWindow::createControlToolBar() QToolBar * tbar = new QToolBar( tr( "Control" ), this ); tbar->setIconSize( QSize( 16, 16 ) ); + { + M_debug_start_time_box = new QLineEdit( tr( "-1" ) ); + M_debug_start_time_box->setMaximumSize( 48, 48 ); + //M_debug_start_time_box->setMinimumSize( 48, 16 ); + M_debug_start_time_box->setValidator( new QIntValidator( -1, 99999999 ) ); + + M_debug_end_time_box = new QLineEdit( tr( "99999" ) ); + M_debug_end_time_box->setMaximumSize( 48, 48 ); + //M_debug_end_time_box->setMinimumSize( 48, 16 ); + M_debug_end_time_box->setValidator( new QIntValidator( 1, 99999999 ) ); + } + M_find_box = new QLineEdit(); M_find_box->setMaximumSize( 100, 48 ); connect( M_find_box, SIGNAL( returnPressed() ), @@ -804,6 +816,9 @@ DebugMessageWindow::createControlToolBar() tbar->addAction( M_clear_data_act ); tbar->addAction( run_offline_client_act ); + tbar->addWidget( M_debug_start_time_box ); + tbar->addWidget( new QLabel( tr( "-" ) ) ); + tbar->addWidget( M_debug_end_time_box ); tbar->addSeparator(); @@ -1822,7 +1837,9 @@ DebugMessageWindow::runOfflineClientImpl() << "--log-dir" << QString::fromStdString( Options::instance().debugLogDir() ) << "--debug" << "--debug-server-logging" << "--unum" << QString::number( s.unum() ) - << "--teamname" << QString::fromStdString( team.name() ); + << "--teamname" << QString::fromStdString( team.name() ) + << "--debug-start-time" << M_debug_start_time_box->text() + << "--debug-end-time" << M_debug_end_time_box->text(); std::cerr << __FILE__ << ": (runOfflineClient)\n" << " invoking command [" << command.toStdString() << " " diff --git a/src/qt/debug_message_window.h b/src/qt/debug_message_window.h index 36a5beb..c26aa12 100644 --- a/src/qt/debug_message_window.h +++ b/src/qt/debug_message_window.h @@ -63,6 +63,10 @@ class DebugMessageWindow MainData & M_main_data; QToolBar * M_tool_bar; + + QLineEdit * M_debug_start_time_box; + QLineEdit * M_debug_end_time_box; + QLineEdit * M_find_box; QRadioButton * M_find_forward_rb; QRadioButton * M_find_backward_rb; diff --git a/src/qt/detail_dialog.cpp b/src/qt/detail_dialog.cpp index 1db0932..6a4bc34 100644 --- a/src/qt/detail_dialog.cpp +++ b/src/qt/detail_dialog.cpp @@ -88,13 +88,13 @@ DetailDialog::~DetailDialog() void DetailDialog::createWidgets() { - QVBoxLayout * layout = new QVBoxLayout(); + QHBoxLayout * layout = new QHBoxLayout(); layout->setContentsMargins( 2, 2, 2, 2 ); layout->setSpacing( 2 ); layout->setSizeConstraint( QLayout::SetFixedSize ); layout->addWidget( createBallLabels(), - 1, Qt::AlignHCenter ); + 0, Qt::AlignTop ); //1, Qt::AlignHCenter ); layout->addWidget( createPlayerLabels(), 1, Qt::AlignHCenter ); @@ -116,25 +116,49 @@ DetailDialog::createBallLabels() layout->setContentsMargins( 1, 1, 1, 1 ); layout->setSpacing( 0 ); layout->setColumnMinimumWidth( 0, this->fontMetrics().width( tr( "AttentionTo " ) ) ); - layout->setColumnMinimumWidth( 1, this->fontMetrics().width( tr( "-12.345, -12.345" ) ) ); - layout->setColumnMinimumWidth( 2, this->fontMetrics().width( tr( "--(123.456, -123.4)" ) ) ); + layout->setColumnMinimumWidth( 1, this->fontMetrics().width( tr( " -12.345, -12.345" ) ) ); + layout->setColumnMinimumWidth( 2, this->fontMetrics().width( tr( " --(123.456, -123.4)" ) ) ); int row = 0; layout->addWidget( new QLabel( tr( "Pos " ) ), row, 0, Qt::AlignRight ); - M_ball_pos = new QLabel( tr( " 0.00, 0.00" ) ); + M_ball_pos = new QLabel( tr( " 0.000, 0.000" ) ); layout->addWidget( M_ball_pos, row, 1, Qt::AlignRight ); ++row; + layout->addWidget( new QLabel( tr( "DebugPos " ) ), row, 0, Qt::AlignRight ); + M_debug_ball_pos = new QLabel( tr( " 0.000, 0.000" ) ); + layout->addWidget( M_debug_ball_pos, row, 1, Qt::AlignRight ); + ++row; + + layout->addWidget( new QLabel( tr( "PosError " ) ), row, 0, Qt::AlignRight ); + M_ball_pos_error = new QLabel( tr( " 0.000, 0.000" ) ); + layout->addWidget( M_ball_pos_error, row, 1, Qt::AlignRight ); + ++row; + layout->addWidget( new QLabel( tr( "Vel " ) ), row, 0, Qt::AlignRight ); - M_ball_vel = new QLabel( tr( " 0.00, 0.00" ) ); + M_ball_vel = new QLabel( tr( " 0.000, 0.000" ) ); layout->addWidget( M_ball_vel, row, 1, Qt::AlignRight ); M_ball_polar_vel = new QLabel( tr( " ( 0.000, 0.0)" ) ); layout->addWidget( M_ball_polar_vel, row, 2, Qt::AlignRight ); ++row; + layout->addWidget( new QLabel( tr( "DebugVel " ) ), row, 0, Qt::AlignRight ); + M_debug_ball_vel = new QLabel( tr( " 0.000, 0.000" ) ); + layout->addWidget( M_debug_ball_vel, row, 1, Qt::AlignRight ); + M_debug_ball_polar_vel = new QLabel( tr( " ( 0.000, 0.0)" ) ); + layout->addWidget( M_debug_ball_polar_vel, row, 2, Qt::AlignRight ); + ++row; + + layout->addWidget( new QLabel( tr( "VelError " ) ), row, 0, Qt::AlignRight ); + M_ball_vel_error = new QLabel( tr( " 0.000, 0.000" ) ); + layout->addWidget( M_ball_vel_error, row, 1, Qt::AlignRight ); + M_ball_polar_vel_error = new QLabel( tr( " ( 0.000, 0.0)" ) ); + layout->addWidget( M_ball_polar_vel_error, row, 2, Qt::AlignRight ); + ++row; + layout->addWidget( new QLabel( tr( "LastMove " ) ), row, 0, Qt::AlignRight ); - M_ball_last_move = new QLabel( tr( " 0.00, 0.00" ) ); + M_ball_last_move = new QLabel( tr( " 0.000, 0.000" ) ); layout->addWidget( M_ball_last_move, row, 1, Qt::AlignRight ); M_ball_last_polar_move = new QLabel( tr( " ( 0.000, 0.0)" ) ); layout->addWidget( M_ball_last_polar_move, row, 2, Qt::AlignRight ); @@ -399,21 +423,24 @@ DetailDialog::updateLabels() const rcsc::rcg::BallT & ball = view->ball(); - snprintf( buf, 64, " %6.2f, %6.2f", - ball.x() * reverse, - ball.y() * reverse ); + const rcsc::Vector2D ball_pos( ball.x() * reverse, + ball.y() * reverse ); + rcsc::Vector2D ball_vel; + + snprintf( buf, 64, " %7.3f, %7.3f", + ball_pos.x, ball_pos.y ); M_ball_pos->setText( QString::fromLatin1( buf ) ); if ( ball.hasVelocity() ) { - rcsc::Vector2D vel( ball.deltaX() * reverse, - ball.deltaY() * reverse ); - snprintf( buf, 64, " %6.2f, %6.2f", - vel.x, vel.y ); + ball_vel.assign( ball.deltaX() * reverse, + ball.deltaY() * reverse ); + snprintf( buf, 64, " %7.3f, %7.3f", + ball_vel.x, ball_vel.y ); M_ball_vel->setText( QString::fromLatin1( buf ) ); snprintf( buf, 64, " (%7.3f, %6.1f)", - vel.r(), vel.th().degree() ); + ball_vel.r(), ball_vel.th().degree() ); M_ball_polar_vel->setText( QString::fromLatin1( buf ) ); } else @@ -424,8 +451,8 @@ DetailDialog::updateLabels() if ( ! last_view ) { - M_ball_last_move->setText( tr( " 0.00, 0.00" ) ); - M_ball_last_polar_move->setText( tr( " ( 0.000, 0.0)" ) ); + M_ball_last_move->setText( tr( " -.---, -.---" ) ); + M_ball_last_polar_move->setText( tr( " ( -.---, -.-)" ) ); } else { @@ -433,7 +460,7 @@ DetailDialog::updateLabels() ball.y() - last_view->ball().y() ); move *= reverse; - snprintf( buf, 64, " %6.2f, %6.2f", + snprintf( buf, 64, " %7.3f, %7.3f", move.x, move.y ); M_ball_last_move->setText( QString::fromLatin1( buf ) ); @@ -442,6 +469,53 @@ DetailDialog::updateLabels() M_ball_last_polar_move->setText( QString::fromLatin1( buf ) ); } + // debug ball data + { + const AgentID id = opt.selectedAgent(); + if ( id.isNull() ) + { + M_debug_ball_pos->setText( tr( " -.--, -.--" ) ); + M_debug_ball_vel->setText( tr( " -.--, -.--" ) ); + M_debug_ball_polar_vel->setText( tr( " ( -.---, -.-)" ) ); + } + else + { + const DebugViewData::ConstPtr debug_view = M_main_data.viewHolder().getDebugView( view->time(), id ); + if ( ! debug_view + || ! debug_view->ball() ) + { + M_debug_ball_pos->setText( tr( " -.--, -.--" ) ); + M_debug_ball_vel->setText( tr( " -.--, -.--" ) ); + M_debug_ball_polar_vel->setText( tr( " ( -.---, -.-)" ) ); + } + else + { + const rcsc::Vector2D debug_ball_pos( debug_view->ball()->x() * reverse, + debug_view->ball()->y() * reverse ); + const rcsc::Vector2D debug_ball_vel( debug_view->ball()->vx() * reverse, + debug_view->ball()->vy() * reverse ); + + snprintf( buf, 64, " %7.3f, %7.3f", debug_ball_pos.x, debug_ball_pos.y ); + M_debug_ball_pos->setText( QString::fromLatin1( buf ) ); + + snprintf( buf, 64, " %7.3f, %7.3f", debug_ball_pos.x - ball_pos.x, debug_ball_pos.y - ball_pos.y ); + M_ball_pos_error->setText( QString::fromLatin1( buf ) ); + + snprintf( buf, 64, " %7.3f, %7.3f", debug_ball_vel.x, debug_ball_vel.y ); + M_debug_ball_vel->setText( QString::fromLatin1( buf ) ); + + snprintf( buf, 64, " %7.3f, %7.3f", debug_ball_vel.x - ball_vel.x, debug_ball_vel.y - ball_vel.y ); + M_ball_vel_error->setText( QString::fromLatin1( buf ) ); + + snprintf( buf, 64, " (%7.3f, %6.1f)", debug_ball_vel.r(), debug_ball_vel.th().degree() ); + M_debug_ball_polar_vel->setText( QString::fromLatin1( buf ) ); + + snprintf( buf, 64, " (%7.3f, %6.1f)", debug_ball_vel.r() - ball_vel.r(), ( debug_ball_vel.th() - ball_vel.th() ).degree() ); + M_ball_polar_vel_error->setText( QString::fromLatin1( buf ) ); + } + } + } + // update player int number = opt.selectedNumber(); @@ -450,6 +524,8 @@ DetailDialog::updateLabels() return; } + // player data + const int player_index = std::abs( number ) - 1 + ( number > 0 ? 0 : 11 ); const rcsc::ServerParam & SP = rcsc::ServerParam::i(); const rcsc::rcg::PlayerT & player = view->players()[player_index]; diff --git a/src/qt/detail_dialog.h b/src/qt/detail_dialog.h index abde8d6..76d1e6f 100644 --- a/src/qt/detail_dialog.h +++ b/src/qt/detail_dialog.h @@ -53,8 +53,17 @@ class DetailDialog // ball info labels QLabel * M_ball_pos; + QLabel * M_debug_ball_pos; + QLabel * M_ball_pos_error; + QLabel * M_ball_vel; + QLabel * M_debug_ball_vel; + QLabel * M_ball_vel_error; + QLabel * M_ball_polar_vel; + QLabel * M_debug_ball_polar_vel; + QLabel * M_ball_polar_vel_error; + QLabel * M_ball_last_move; QLabel * M_ball_last_polar_move; diff --git a/src/qt/draw_config.cpp b/src/qt/draw_config.cpp index 5e48434..67a3c60 100644 --- a/src/qt/draw_config.cpp +++ b/src/qt/draw_config.cpp @@ -70,6 +70,7 @@ const QColor DrawConfig::EFFORT_DECAYED_PEN_COLOR = QColor( 255, 0, 0 ); const QColor DrawConfig::RECOVERY_DECAYED_PEN_COLOR = QColor( 252, 231, 31 ); const QColor DrawConfig::VIEW_CONE_PEN_COLOR = QColor( 55, 255, 255 ); const QColor DrawConfig::VIEW_AREA_PEN_COLOR = QColor( 255, 255, 255 ); +const QColor DrawConfig::FOCUS_POINT_COLOR = QColor( 255, 255, 255 ); const QColor DrawConfig::KICK_PEN_COLOR = QColor( 255, 255, 255 ); const QColor DrawConfig::KICK_FAULT_COLOR = QColor( 0, 255, 0 ); const QColor DrawConfig::CATCH_COLOR = QColor( 10, 80, 10 ); @@ -138,6 +139,7 @@ DrawConfig::DrawConfig() M_recovery_decayed_pen( RECOVERY_DECAYED_PEN_COLOR, 0, Qt::SolidLine ), M_view_cone_pen( VIEW_CONE_PEN_COLOR, 0, Qt::SolidLine ), M_view_area_pen( VIEW_AREA_PEN_COLOR, 0, Qt::SolidLine ), + M_focus_point_pen( FOCUS_POINT_COLOR, 0, Qt::SolidLine ), M_kick_pen( KICK_PEN_COLOR, 2, Qt::SolidLine ), M_kick_fault_pen( KICK_FAULT_COLOR, 2, Qt::SolidLine ), M_kick_fault_brush( KICK_FAULT_COLOR, Qt::SolidPattern ), @@ -234,6 +236,7 @@ DrawConfig::setDefaultColors() M_recovery_decayed_pen.setColor( RECOVERY_DECAYED_PEN_COLOR ); M_view_cone_pen.setColor( VIEW_CONE_PEN_COLOR ); M_view_area_pen.setColor( VIEW_AREA_PEN_COLOR ); + M_focus_point_pen.setColor( FOCUS_POINT_COLOR ); M_kick_pen.setColor( KICK_PEN_COLOR ); M_kick_fault_pen.setColor( KICK_FAULT_COLOR ); M_kick_fault_brush.setColor( KICK_FAULT_COLOR ); @@ -511,6 +514,12 @@ DrawConfig::readSettings() M_view_area_pen.setColor( toColor( val.toString() ) ); } + val = settings.value( "focus_point_color" ); + if ( val.isValid() ) + { + M_focus_point_pen.setColor( toColor( val.toString() ) ); + } + // player status val = settings.value( "kick_pen_color" ); if ( val.isValid() ) @@ -781,6 +790,8 @@ DrawConfig::saveSettings() toString( viewConePen().color() ) ); settings.setValue( "view_area_pen_color", toString( viewAreaPen().color() ) ); + settings.setValue( "focus_point_color", + toString( focusPointPen().color() ) ); // player status settings.setValue( "kick_pen_color", toString( kickPen().color() ) ); diff --git a/src/qt/draw_config.h b/src/qt/draw_config.h index b3ad9be..c538d7f 100644 --- a/src/qt/draw_config.h +++ b/src/qt/draw_config.h @@ -67,6 +67,7 @@ class DrawConfig { static const QColor RECOVERY_DECAYED_PEN_COLOR; static const QColor VIEW_CONE_PEN_COLOR; static const QColor VIEW_AREA_PEN_COLOR; + static const QColor FOCUS_POINT_COLOR; static const QColor KICK_PEN_COLOR; static const QColor KICK_FAULT_COLOR; static const QColor CATCH_COLOR; @@ -184,6 +185,8 @@ class DrawConfig { //! the pen of players' view area QPen M_view_area_pen; + //! player's focus point circle + QPen M_focus_point_pen; //-------------------------------------------------- // player status @@ -342,6 +345,7 @@ class DrawConfig { const QPen & recoveryDecayedPen() const { return M_recovery_decayed_pen; } const QPen & viewConePen() const { return M_view_cone_pen; } const QPen & viewAreaPen() const { return M_view_area_pen; } + const QPen & focusPointPen() const { return M_focus_point_pen; } const QPen & kickPen() const { return M_kick_pen; } const QPen & kickFaultPen() const { return M_kick_fault_pen; } @@ -429,6 +433,7 @@ class DrawConfig { void setRecoveryDecayedColor( const QColor & col ) { M_recovery_decayed_pen.setColor( col ); } void setViewConeColor( const QColor & col ) { M_view_cone_pen.setColor( col ); } void setViewAreaColor( const QColor & col ) { M_view_area_pen.setColor( col ); } + void setFocusPointColor( const QColor & col ) { M_focus_point_pen.setColor( col ); } void setKickColor( const QColor & col ) { M_kick_pen.setColor( col ); } void setKickFaultColor( const QColor & col ) diff --git a/src/qt/main_window.cpp b/src/qt/main_window.cpp index a21680a..8cd8790 100644 --- a/src/qt/main_window.cpp +++ b/src/qt/main_window.cpp @@ -47,7 +47,7 @@ #include "image_save_dialog.h" #include "detail_dialog.h" #include "font_setting_dialog.h" -#include "monitor_move_dialog.h" +#include "trainer_dialog.h" #include "player_type_dialog.h" #include "view_config_dialog.h" #include "debug_message_window.h" @@ -106,12 +106,12 @@ /*-------------------------------------------------------------------*/ /*! -*/ + */ MainWindow::MainWindow() : M_log_player( new LogPlayer( M_main_data, this ) ), M_detail_dialog( static_cast< DetailDialog * >( 0 ) ), M_player_type_dialog( static_cast< PlayerTypeDialog * >( 0 ) ), - M_monitor_move_dialog( static_cast< MonitorMoveDialog * >( 0 ) ), + M_trainer_dialog( static_cast< TrainerDialog * >( 0 ) ), M_view_config_dialog( static_cast< ViewConfigDialog * >( 0 ) ), M_launcher_dialog( static_cast< LauncherDialog * >( 0 ) ), M_debug_message_window( static_cast< DebugMessageWindow * >( 0 ) ), @@ -175,7 +175,7 @@ MainWindow::MainWindow() /*-------------------------------------------------------------------*/ /*! -*/ + */ MainWindow::~MainWindow() { //std::cerr << "delete MainWindow" << std::endl; @@ -190,7 +190,7 @@ MainWindow::~MainWindow() /*-------------------------------------------------------------------*/ /*! -*/ + */ void MainWindow::init() { @@ -268,7 +268,7 @@ MainWindow::init() /*-------------------------------------------------------------------*/ /*! -*/ + */ void MainWindow::readSettings() { @@ -375,7 +375,7 @@ MainWindow::readSettings() /*-------------------------------------------------------------------*/ /*! -*/ + */ void MainWindow::saveSettings() { @@ -422,7 +422,7 @@ MainWindow::saveSettings() /*-------------------------------------------------------------------*/ /*! -*/ + */ void MainWindow::createActions() { @@ -439,7 +439,7 @@ MainWindow::createActions() /*-------------------------------------------------------------------*/ /*! -*/ + */ void MainWindow::createActionsFile() { @@ -480,7 +480,7 @@ MainWindow::createActionsFile() this->addAction( M_save_debug_view_act ); // M_open_draw_data_act = new QAction( QIcon( QPixmap( open_rcg_xpm ) ), - tr( "Open draw data" ), this ); + tr( "Open draw data" ), this ); M_open_draw_data_act->setStatusTip( tr( "Open draw data file" ) ); connect( M_open_draw_data_act, SIGNAL( triggered() ), this, SLOT( openDrawData() ) ); this->addAction( M_open_draw_data_act ); @@ -505,7 +505,7 @@ MainWindow::createActionsFile() /*-------------------------------------------------------------------*/ /*! -*/ + */ void MainWindow::createActionsMonitor() { @@ -585,11 +585,11 @@ MainWindow::createActionsMonitor() this, SLOT( toggleDragMoveMode( bool ) ) ); this->addAction( M_toggle_drag_move_mode_act ); // - M_show_monitor_move_dialog_act = new QAction( tr( "Move Dialog" ), this ); - M_show_monitor_move_dialog_act->setStatusTip( tr( "Show player move dialog" ) ); + M_show_monitor_move_dialog_act = new QAction( tr( "Trainer Panel" ), this ); + M_show_monitor_move_dialog_act->setStatusTip( tr( "Show Trainer Panel " ) ); //M_show_monitor_move_dialog_act->setEnabled( false ); connect( M_show_monitor_move_dialog_act, SIGNAL( triggered() ), - this, SLOT( showMonitorMoveDialog() ) ); + this, SLOT( showTrainerDialog() ) ); this->addAction( M_show_monitor_move_dialog_act ); // #ifndef Q_WS_WIN @@ -612,7 +612,7 @@ MainWindow::createActionsMonitor() /*-------------------------------------------------------------------*/ /*! -*/ + */ void MainWindow::createActionsView() { @@ -645,10 +645,10 @@ MainWindow::createActionsView() connect( M_full_screen_act, SIGNAL( triggered() ), this, SLOT( toggleFullScreen() ) ); this->addAction( M_full_screen_act ); -// (void) new QShortcut( Qt::ALT + Qt::Key_Return, -// this, SLOT( toggleFullScreen() ) ); -// (void) new QShortcut( Qt::ALT + Qt::Key_Enter, -// this, SLOT( toggleFullScreen() ) ); + // (void) new QShortcut( Qt::ALT + Qt::Key_Return, + // this, SLOT( toggleFullScreen() ) ); + // (void) new QShortcut( Qt::ALT + Qt::Key_Enter, + // this, SLOT( toggleFullScreen() ) ); { QAction * act = new QAction( tr( "Toggle Full Screen" ), this ); act->setShortcut( Qt::ALT + Qt::Key_Return ); @@ -733,7 +733,7 @@ MainWindow::createActionsView() /*-------------------------------------------------------------------*/ /*! -*/ + */ void MainWindow::createActionsViewConfig() { @@ -804,6 +804,12 @@ MainWindow::createActionsViewConfig() M_toggle_show_view_area_act->setStatusTip( tr( "Show/Hide players' view area" ) ); this->addAction( M_toggle_show_view_area_act ); + // j + M_toggle_show_focus_point_act = new QAction( tr( "Show Focus Point" ), this ); + M_toggle_show_focus_point_act->setShortcut( Qt::Key_J ); + M_toggle_show_focus_point_act->setStatusTip( tr( "Show/Hide selected players' focus point" ) ); + this->addAction( M_toggle_show_focus_point_act ); + // d M_toggle_show_body_shadow_act = new QAction( tr( "Show Body Shadow" ), this ); M_toggle_show_body_shadow_act->setShortcut( Qt::Key_D ); @@ -976,7 +982,7 @@ MainWindow::createActionsViewConfig() // a M_toggle_select_auto_all_act = new QAction( tr( "Select auto all" ), this ); M_toggle_select_auto_all_act->setShortcut( Qt::Key_A ); - M_toggle_select_auto_all_act->setStatusTip( tr( "Select the player narest to the ball in all players" ) ); + M_toggle_select_auto_all_act->setStatusTip( tr( "Select the player nearest to the ball in all players" ) ); this->addAction( M_toggle_select_auto_all_act ); // l @@ -1001,7 +1007,7 @@ MainWindow::createActionsViewConfig() /*-------------------------------------------------------------------*/ /*! -*/ + */ void MainWindow::createActionsLogPlayer() { @@ -1165,7 +1171,7 @@ MainWindow::createActionsLogPlayer() /*-------------------------------------------------------------------*/ /*! -*/ + */ void MainWindow::createActionsDebug() { @@ -1200,7 +1206,7 @@ MainWindow::createActionsDebug() /*-------------------------------------------------------------------*/ /*! -*/ + */ void MainWindow::createActionsHelp() { @@ -1222,7 +1228,7 @@ MainWindow::createActionsHelp() /*-------------------------------------------------------------------*/ /*! -*/ + */ void MainWindow::createMenus() { @@ -1237,7 +1243,7 @@ MainWindow::createMenus() /*-------------------------------------------------------------------*/ /*! -*/ + */ void MainWindow::createMenuFile() { @@ -1263,7 +1269,7 @@ MainWindow::createMenuFile() /*-------------------------------------------------------------------*/ /*! -*/ + */ void MainWindow::createMenuMonitor() { @@ -1295,7 +1301,7 @@ MainWindow::createMenuMonitor() /*-------------------------------------------------------------------*/ /*! -*/ + */ void MainWindow::createMenuLogPlayer() { @@ -1321,7 +1327,7 @@ MainWindow::createMenuLogPlayer() /*-------------------------------------------------------------------*/ /*! -*/ + */ void MainWindow::createMenuView() { @@ -1341,9 +1347,9 @@ MainWindow::createMenuView() { QMenu * submenu = menu->addMenu( tr( "Qt &Style" ) ); Q_FOREACH ( QAction * action, M_style_act_group->actions() ) - { - submenu->addAction( action ); - } + { + submenu->addAction( action ); + } } menu->addAction( M_show_color_setting_dialog_act ); menu->addAction( M_show_font_setting_dialog_act ); @@ -1365,6 +1371,7 @@ MainWindow::createMenuView() submenu->addAction( M_toggle_show_player_type_act ); submenu->addAction( M_toggle_show_stamina_act ); submenu->addAction( M_toggle_show_view_area_act ); + submenu->addAction( M_toggle_show_focus_point_act ); submenu->addAction( M_toggle_show_body_shadow_act ); submenu->addAction( M_toggle_show_catchable_area_act ); submenu->addAction( M_toggle_show_tackle_area_act ); @@ -1401,7 +1408,7 @@ MainWindow::createMenuView() /*-------------------------------------------------------------------*/ /*! -*/ + */ void MainWindow::createMenuDebug() { @@ -1412,7 +1419,7 @@ MainWindow::createMenuDebug() /*-------------------------------------------------------------------*/ /*! -*/ + */ void MainWindow::createMenuHelp() { @@ -1420,27 +1427,27 @@ MainWindow::createMenuHelp() menu->addAction( M_about_act ); menu->addAction( M_shortcut_keys_act ); -// QAction * act = new QAction( tr( "About Qt" ), this ); -// act->setStatusTip( tr( "Show about Qt." ) ); -// connect( act, SIGNAL( triggered() ), qApp, SLOT( aboutQt() ) ); -// menu->addAction( act ); + // QAction * act = new QAction( tr( "About Qt" ), this ); + // act->setStatusTip( tr( "Show about Qt." ) ); + // connect( act, SIGNAL( triggered() ), qApp, SLOT( aboutQt() ) ); + // menu->addAction( act ); menu->addAction( tr( "About Qt" ), qApp, SLOT( aboutQt() ) ); } /*-------------------------------------------------------------------*/ /*! -*/ + */ void MainWindow::createToolBars() { -// M_monitor_tool_bar = new QToolBar( tr( "Monitor" ), this ); -// M_monitor_tool_bar->setIconSize( QSize( 16, 16 ) ); -// M_monitor_tool_bar->addAction( M_set_live_mode_act ); -// M_monitor_tool_bar->addAction( M_toggle_drag_move_mode_act ); -// M_monitor_tool_bar->addAction( M_toggle_debug_server_act ); + // M_monitor_tool_bar = new QToolBar( tr( "Monitor" ), this ); + // M_monitor_tool_bar->setIconSize( QSize( 16, 16 ) ); + // M_monitor_tool_bar->addAction( M_set_live_mode_act ); + // M_monitor_tool_bar->addAction( M_toggle_drag_move_mode_act ); + // M_monitor_tool_bar->addAction( M_toggle_debug_server_act ); -// this->addToolBar( M_monitor_tool_bar ); + // this->addToolBar( M_monitor_tool_bar ); // @@ -1527,7 +1534,7 @@ MainWindow::createToolBars() /*-------------------------------------------------------------------*/ /*! -*/ + */ void MainWindow::createStatusBar() { @@ -1554,7 +1561,7 @@ MainWindow::createStatusBar() /*-------------------------------------------------------------------*/ /*! -*/ + */ void MainWindow::createFieldCanvas() { @@ -1566,7 +1573,7 @@ MainWindow::createFieldCanvas() connect( this, SIGNAL( viewUpdated() ), M_field_canvas, SLOT( update() ) ); - //M_field_canvas, SLOT( repaint() ) ); + //M_field_canvas, SLOT( repaint() ) ); connect( M_field_canvas, SIGNAL( mouseMoved( const QPoint & ) ), this, SLOT( updatePositionLabel( const QPoint & ) ) ); @@ -1592,16 +1599,16 @@ MainWindow::createFieldCanvas() /*-------------------------------------------------------------------*/ /*! -*/ + */ QMenu * MainWindow::createNormalPopupMenu() { QMenu * menu = new QMenu( M_field_canvas ); menu->addAction( M_open_rcg_act ); menu->addAction( M_connect_monitor_act ); -// #ifndef Q_WS_WIN -// menu->addAction( M_restart_server_act ); -// #endif + // #ifndef Q_WS_WIN + // menu->addAction( M_restart_server_act ); + // #endif return menu; } @@ -1609,7 +1616,7 @@ MainWindow::createNormalPopupMenu() /*-------------------------------------------------------------------*/ /*! -*/ + */ QMenu * MainWindow::createSystemPopupMenu() { @@ -1628,7 +1635,7 @@ MainWindow::createSystemPopupMenu() /*-------------------------------------------------------------------*/ /*! -*/ + */ QMenu * MainWindow::createMonitorPopupMenu() { @@ -1716,7 +1723,7 @@ MainWindow::createMonitorPopupMenu() /*-------------------------------------------------------------------*/ /*! -*/ + */ QMenu * MainWindow::createOfflinePopupMenu() { @@ -1731,7 +1738,7 @@ MainWindow::createOfflinePopupMenu() /*-------------------------------------------------------------------*/ /*! -*/ + */ void MainWindow::createViewConfigDialog() { @@ -1787,13 +1794,15 @@ MainWindow::createViewConfigDialog() connect( M_toggle_player_reverse_draw_act, SIGNAL( triggered() ), M_view_config_dialog, SLOT( togglePlayerReverseDraw() ) ); connect( M_toggle_show_player_number_act, SIGNAL( triggered() ), - M_view_config_dialog, SLOT( toggleShowPlayerNumber() ) ); + M_view_config_dialog, SLOT( toggleShowPlayerNumber() ) ); connect( M_toggle_show_player_type_act, SIGNAL( triggered() ), M_view_config_dialog, SLOT( toggleShowPlayerType() ) ); connect( M_toggle_show_stamina_act, SIGNAL( triggered() ), M_view_config_dialog, SLOT( toggleShowStamina() ) ); connect( M_toggle_show_view_area_act, SIGNAL( triggered() ), M_view_config_dialog, SLOT( toggleShowViewArea() ) ); + connect( M_toggle_show_focus_point_act, SIGNAL( triggered() ), + M_view_config_dialog, SLOT( toggleShowFocusPoint() ) ); connect( M_toggle_show_body_shadow_act, SIGNAL( triggered() ), M_view_config_dialog, SLOT( toggleShowBodyShadow() ) ); connect( M_toggle_show_catchable_area_act, SIGNAL( triggered() ), @@ -1837,7 +1846,7 @@ MainWindow::createViewConfigDialog() #else Qt::CTRL + Qt::Key_AsciiCircum, #endif - M_view_config_dialog, SLOT( selectRightCoach() ) ); + M_view_config_dialog, SLOT( selectRightCoach() ) ); s->setParent( this ); } @@ -1859,7 +1868,7 @@ MainWindow::createViewConfigDialog() /*-------------------------------------------------------------------*/ /*! -*/ + */ void MainWindow::closeEvent( QCloseEvent * event ) { @@ -1872,7 +1881,7 @@ MainWindow::closeEvent( QCloseEvent * event ) /*-------------------------------------------------------------------*/ /*! -*/ + */ void MainWindow::resizeEvent( QResizeEvent * event ) { @@ -1888,7 +1897,7 @@ MainWindow::resizeEvent( QResizeEvent * event ) /*-------------------------------------------------------------------*/ /*! -*/ + */ void MainWindow::wheelEvent( QWheelEvent * event ) { @@ -1907,7 +1916,7 @@ MainWindow::wheelEvent( QWheelEvent * event ) /*-------------------------------------------------------------------*/ /*! -*/ + */ void MainWindow::dragEnterEvent( QDragEnterEvent * event ) { @@ -1920,7 +1929,7 @@ MainWindow::dragEnterEvent( QDragEnterEvent * event ) /*-------------------------------------------------------------------*/ /*! -*/ + */ void MainWindow::dropEvent( QDropEvent * event ) { @@ -1928,14 +1937,14 @@ MainWindow::dropEvent( QDropEvent * event ) QList< QUrl > urls = mimedata->urls(); -// std::cerr << "urls size = " << urls.size() << std::endl; + // std::cerr << "urls size = " << urls.size() << std::endl; -// for ( int i = 0; i < urls.size() && i < 32; ++i ) -// { -// std::cerr << "url " << i << ": " -// << urls.at(i).path().toStdString() -// << std::endl; -// } + // for ( int i = 0; i < urls.size() && i < 32; ++i ) + // { + // std::cerr << "url " << i << ": " + // << urls.at(i).path().toStdString() + // << std::endl; + // } while ( ! urls.empty() && urls.back().isEmpty() ) @@ -1968,7 +1977,7 @@ MainWindow::dropEvent( QDropEvent * event ) /*-------------------------------------------------------------------*/ /*! -*/ + */ void MainWindow::openRCG() { @@ -2002,7 +2011,7 @@ MainWindow::openRCG() /*-------------------------------------------------------------------*/ /*! -*/ + */ void MainWindow::openRCG( const QString & file_path ) { @@ -2085,7 +2094,7 @@ MainWindow::openRCG( const QString & file_path ) /*-------------------------------------------------------------------*/ /*! -*/ + */ void MainWindow::saveRCG() { @@ -2195,7 +2204,7 @@ MainWindow::saveRCG() /*-------------------------------------------------------------------*/ /*! -*/ + */ void MainWindow::openDebugView() { @@ -2235,7 +2244,7 @@ MainWindow::openDebugView() /*-------------------------------------------------------------------*/ /*! -*/ + */ void MainWindow::saveDebugView() { @@ -2273,7 +2282,7 @@ MainWindow::saveDebugView() /*-------------------------------------------------------------------*/ /*! -*/ + */ void MainWindow::openDrawData() { @@ -2297,7 +2306,7 @@ MainWindow::openDrawData() /*-------------------------------------------------------------------*/ /*! -*/ + */ void MainWindow::openDrawData( const QString & file_path ) { @@ -2332,7 +2341,7 @@ MainWindow::openDrawData( const QString & file_path ) /*-------------------------------------------------------------------*/ /*! -*/ + */ void MainWindow::kickOff() { @@ -2346,7 +2355,7 @@ MainWindow::kickOff() /*-------------------------------------------------------------------*/ /*! -*/ + */ void MainWindow::setLiveMode() { @@ -2360,7 +2369,7 @@ MainWindow::setLiveMode() /*-------------------------------------------------------------------*/ /*! -*/ + */ void MainWindow::connectMonitor() { @@ -2370,7 +2379,7 @@ MainWindow::connectMonitor() /*-------------------------------------------------------------------*/ /*! -*/ + */ void MainWindow::connectMonitorTo() { @@ -2396,7 +2405,7 @@ MainWindow::connectMonitorTo() /*-------------------------------------------------------------------*/ /*! -*/ + */ void MainWindow::connectMonitorTo( const char * hostname ) { @@ -2489,7 +2498,7 @@ MainWindow::connectMonitorTo( const char * hostname ) /*-------------------------------------------------------------------*/ /*! -*/ + */ void MainWindow::disconnectMonitor() { @@ -2535,7 +2544,7 @@ MainWindow::disconnectMonitor() /*-------------------------------------------------------------------*/ /*! -*/ + */ void MainWindow::killServer() { @@ -2561,7 +2570,7 @@ MainWindow::killServer() /*-------------------------------------------------------------------*/ /*! -*/ + */ void MainWindow::startServer() { @@ -2599,7 +2608,7 @@ MainWindow::startServer() /*-------------------------------------------------------------------*/ /*! -*/ + */ void MainWindow::restartServer() { @@ -2609,7 +2618,7 @@ MainWindow::restartServer() /*-------------------------------------------------------------------*/ /*! -*/ + */ void MainWindow::restartServer( const QString & command ) { @@ -2648,7 +2657,7 @@ MainWindow::restartServer( const QString & command ) /*-------------------------------------------------------------------*/ /*! -*/ + */ void MainWindow::toggleDragMoveMode( bool on ) { @@ -2661,7 +2670,7 @@ MainWindow::toggleDragMoveMode( bool on ) /*-------------------------------------------------------------------*/ /*! -*/ + */ void MainWindow::showLauncherDialog() { @@ -2686,7 +2695,7 @@ MainWindow::showLauncherDialog() /*-------------------------------------------------------------------*/ /*! -*/ + */ void MainWindow::toggleMenuBar() { @@ -2696,7 +2705,7 @@ MainWindow::toggleMenuBar() /*-------------------------------------------------------------------*/ /*! -*/ + */ void MainWindow::toggleToolBar() { @@ -2707,7 +2716,7 @@ MainWindow::toggleToolBar() /*-------------------------------------------------------------------*/ /*! -*/ + */ void MainWindow::toggleStatusBar() { @@ -2717,7 +2726,7 @@ MainWindow::toggleStatusBar() /*-------------------------------------------------------------------*/ /*! -*/ + */ void MainWindow::toggleFullScreen() { @@ -2734,7 +2743,7 @@ MainWindow::toggleFullScreen() /*-------------------------------------------------------------------*/ /*! -*/ + */ void MainWindow::showPlayerTypeDialog() { @@ -2752,31 +2761,31 @@ MainWindow::showPlayerTypeDialog() /*-------------------------------------------------------------------*/ /*! -*/ + */ void -MainWindow::showMonitorMoveDialog() +MainWindow::showTrainerDialog() { - if ( M_monitor_move_dialog ) + if ( M_trainer_dialog ) { - M_monitor_move_dialog->setVisible( ! M_monitor_move_dialog->isVisible() ); + M_trainer_dialog->setVisible( ! M_trainer_dialog->isVisible() ); } else { - M_monitor_move_dialog - = new MonitorMoveDialog( this, - M_main_data, - M_main_data.getTrainerData() ); - connect( M_monitor_move_dialog, SIGNAL( executed() ), + M_trainer_dialog + = new TrainerDialog( this, + M_main_data, + M_main_data.getTrainerData() ); + connect( M_trainer_dialog, SIGNAL( executed() ), this, SLOT( moveObjects() ) ); - M_monitor_move_dialog->show(); + M_trainer_dialog->show(); } } /*-------------------------------------------------------------------*/ /*! -*/ + */ void MainWindow::showDetailDialog() { @@ -2797,7 +2806,7 @@ MainWindow::showDetailDialog() /*-------------------------------------------------------------------*/ /*! -*/ + */ void MainWindow::changeStyle( bool checked ) { @@ -2816,7 +2825,7 @@ MainWindow::changeStyle( bool checked ) /*-------------------------------------------------------------------*/ /*! -*/ + */ void MainWindow::showColorSettingDialog() { @@ -2831,7 +2840,7 @@ MainWindow::showColorSettingDialog() /*-------------------------------------------------------------------*/ /*! -*/ + */ void MainWindow::showFontSettingDialog() { @@ -2846,7 +2855,7 @@ MainWindow::showFontSettingDialog() /*-------------------------------------------------------------------*/ /*! -*/ + */ void MainWindow::showViewConfigDialog() { @@ -2856,7 +2865,7 @@ MainWindow::showViewConfigDialog() /*-------------------------------------------------------------------*/ /*! -*/ + */ void MainWindow::showDebugMessageWindow() { @@ -2865,21 +2874,21 @@ MainWindow::showDebugMessageWindow() M_debug_message_window ->setVisible( ! M_debug_message_window->isVisible() ); } -// else -// { -// M_debug_message_window = new DebugMessageWindow( this, -// M_main_data ); -// connect( M_debug_message_window, SIGNAL( configured() ), -// this, SIGNAL( viewUpdated() ) ); + // else + // { + // M_debug_message_window = new DebugMessageWindow( this, + // M_main_data ); + // connect( M_debug_message_window, SIGNAL( configured() ), + // this, SIGNAL( viewUpdated() ) ); -// M_debug_message_window->show(); -// } + // M_debug_message_window->show(); + // } } /*-------------------------------------------------------------------*/ /*! -*/ + */ void MainWindow::toggleDebugServer( bool on ) { @@ -2896,7 +2905,7 @@ MainWindow::toggleDebugServer( bool on ) /*-------------------------------------------------------------------*/ /*! -*/ + */ void MainWindow::startDebugServer() { @@ -2927,7 +2936,7 @@ MainWindow::startDebugServer() /*-------------------------------------------------------------------*/ /*! -*/ + */ void MainWindow::stopDebugServer() { @@ -2942,7 +2951,7 @@ MainWindow::stopDebugServer() /*-------------------------------------------------------------------*/ /*! -*/ + */ void MainWindow::showImageSaveDialog() { @@ -2958,7 +2967,7 @@ MainWindow::showImageSaveDialog() /*-------------------------------------------------------------------*/ /*! -*/ + */ void MainWindow::about() { @@ -3037,9 +3046,9 @@ MainWindow::printShortcutKeys() } table_widget->setSortingEnabled( true ); -// std::cerr << "table row_count = " << table_widget->rowCount() -// << "table col_count = " << table_widget->columnCount() -// << std::endl; + // std::cerr << "table row_count = " << table_widget->rowCount() + // << "table col_count = " << table_widget->columnCount() + // << std::endl; layout->addWidget( table_widget ); dialog.setLayout( layout ); @@ -3053,7 +3062,7 @@ MainWindow::printShortcutKeys() /*-------------------------------------------------------------------*/ /*! -*/ + */ void MainWindow::resizeCanvas( const QSize & size ) { @@ -3118,7 +3127,7 @@ MainWindow::saveImageAndQuit() /*-------------------------------------------------------------------*/ /*! -*/ + */ void MainWindow::receiveMonitorPacket() { @@ -3162,7 +3171,7 @@ MainWindow::receiveMonitorPacket() /*-------------------------------------------------------------------*/ /*! -*/ + */ void MainWindow::updatePositionLabel( const QPoint & point ) { @@ -3201,7 +3210,7 @@ MainWindow::updatePositionLabel( const QPoint & point ) /*-------------------------------------------------------------------*/ /*! -*/ + */ void MainWindow::dropBallThere() { @@ -3222,7 +3231,7 @@ MainWindow::dropBallThere() /*-------------------------------------------------------------------*/ /*! -*/ + */ void MainWindow::dropBall( const QPoint & point ) { @@ -3247,7 +3256,7 @@ MainWindow::dropBall( const QPoint & point ) /*-------------------------------------------------------------------*/ /*! -*/ + */ void MainWindow::freeKickLeft( const QPoint & point ) { @@ -3276,7 +3285,7 @@ MainWindow::freeKickLeft( const QPoint & point ) /*-------------------------------------------------------------------*/ /*! -*/ + */ void MainWindow::freeKickRight( const QPoint & point ) { @@ -3305,7 +3314,7 @@ MainWindow::freeKickRight( const QPoint & point ) /*-------------------------------------------------------------------*/ /*! -*/ + */ void MainWindow::movePlayer( const QPoint & point ) { @@ -3336,7 +3345,7 @@ MainWindow::movePlayer( const QPoint & point ) /*-------------------------------------------------------------------*/ /*! -*/ + */ void MainWindow::moveObjects() { @@ -3346,7 +3355,7 @@ MainWindow::moveObjects() return; } - TrainerData & data = M_main_data.getTrainerData(); + const TrainerData & data = M_main_data.getTrainerData(); // ball if ( data.ballPos().isValid() ) @@ -3366,15 +3375,17 @@ MainWindow::moveObjects() M_monitor_client->sendTrainerMoveBall( data.ballPos().x, data.ballPos().y ); } + + M_monitor_client->sendChangeMode( data.playmode() ); } else { - if ( data.playMode() == rcsc::PM_FreeKick_Left ) + if ( data.playmode() == rcsc::PM_FreeKick_Left ) { M_monitor_client->sendFreeKickLeft( data.ballPos().x, data.ballPos().y ); } - else if ( data.playMode() == rcsc::PM_FreeKick_Right ) + else if ( data.playmode() == rcsc::PM_FreeKick_Right ) { M_monitor_client->sendFreeKickRight( data.ballPos().x, data.ballPos().y ); @@ -3418,7 +3429,7 @@ MainWindow::moveObjects() /*-------------------------------------------------------------------*/ /*! -*/ + */ void MainWindow::yellowCard() { @@ -3447,7 +3458,7 @@ MainWindow::yellowCard() /*-------------------------------------------------------------------*/ /*! -*/ + */ void MainWindow::redCard() { diff --git a/src/qt/main_window.h b/src/qt/main_window.h index 91180bb..47849f3 100644 --- a/src/qt/main_window.h +++ b/src/qt/main_window.h @@ -55,7 +55,7 @@ class LauncherDialog; class LogPlayer; class LogPlayerToolBar; class MonitorClient; -class MonitorMoveDialog; +class TrainerDialog; class PlayerTypeDialog; class ViewConfigDialog; @@ -79,7 +79,7 @@ class MainWindow DetailDialog * M_detail_dialog; PlayerTypeDialog * M_player_type_dialog; - MonitorMoveDialog * M_monitor_move_dialog; + TrainerDialog * M_trainer_dialog; ViewConfigDialog * M_view_config_dialog; LauncherDialog * M_launcher_dialog; @@ -140,6 +140,7 @@ class MainWindow QAction * M_toggle_show_player_type_act; QAction * M_toggle_show_stamina_act; QAction * M_toggle_show_view_area_act; + QAction * M_toggle_show_focus_point_act; QAction * M_toggle_show_body_shadow_act; QAction * M_toggle_show_catchable_area_act; QAction * M_toggle_show_tackle_area_act; @@ -281,7 +282,7 @@ private slots: void changeStyle( bool checked ); void showColorSettingDialog(); void showFontSettingDialog(); - void showMonitorMoveDialog(); + void showTrainerDialog(); void showViewConfigDialog(); // tool menu actions slots diff --git a/src/qt/monitor_client.cpp b/src/qt/monitor_client.cpp index 9c8318e..2dfd38a 100644 --- a/src/qt/monitor_client.cpp +++ b/src/qt/monitor_client.cpp @@ -42,8 +42,6 @@ #include #include -#include -#include #include #include @@ -82,15 +80,12 @@ MonitorClient::MonitorClient( QObject * parent, M_waited_msec( 0 ) { - // check protocl versin range - if ( version < 1 ) + // check protocol versin range + if ( version < 1 + || 5 < version ) { - M_version = 1; - } - - if ( 4 < version ) - { - M_version = 4; + std::cerr << "(MonitorClient) Unsupported protocol version " << version << std::endl; + return; } QHostInfo host = QHostInfo::fromName( QString::fromLatin1( hostname ) ); diff --git a/src/qt/player_painter.cpp b/src/qt/player_painter.cpp index bb5415d..8788f16 100644 --- a/src/qt/player_painter.cpp +++ b/src/qt/player_painter.cpp @@ -211,6 +211,13 @@ PlayerPainter::drawAll( QPainter & painter, { drawViewDir( painter, param ); } + + if ( selected + && player.focusDist() > 1.0e-5 + && opt.showFocusPoint() ) + { + drawFocusPoint( painter, param ); + } } if ( player.isGoalie() @@ -806,7 +813,14 @@ PlayerPainter::drawViewArea( QPainter & painter, const double TEAM_FAR = opt.scale( 40.0 ); const double TEAM_TOOFAR = opt.scale( 60.0 ); - painter.setPen( dconf.linePen() ); + const rcsc::SideID side = ( Options::instance().reverseSide() + ? static_cast< rcsc::SideID >( -1 * param.player_.side() ) + : param.player_.side() ); + + //painter.setPen( dconf.linePen() ); + painter.setPen( side == rcsc::LEFT ? dconf.leftTeamPen() + : side == rcsc::RIGHT ? dconf.rightTeamPen() + : dconf.linePen() ); //painter.setBrush( dconf.transparentBrush() ); int view_start_angle_int @@ -903,6 +917,30 @@ PlayerPainter::drawViewDir( QPainter & painter, painter.drawLine( QLineF( param.x_, param.y_, end_x, end_y ) ); } +/*-------------------------------------------------------------------*/ +/*! + + */ +void +PlayerPainter::drawFocusPoint( QPainter & painter, + const PlayerPainter::Param & param ) const +{ + const Options & opt = Options::instance(); + const DrawConfig & dconf = DrawConfig::instance(); + + const rcsc::AngleDeg focus_angle = param.head_ + param.player_.focus_dir_; + const rcsc::Vector2D focus_point = rcsc::Vector2D::from_polar( param.player_.focusDist(), focus_angle ); + const double radius = opt.scale( opt.focusPointSize() ); + + const QPointF point( opt.screenX( param.player_.x() + focus_point.x ), + opt.screenY( param.player_.y() + focus_point.y ) ); + + painter.setPen( dconf.focusPointPen() ); + painter.setBrush( Qt::NoBrush ); + painter.drawLine( QPointF( param.x_, param.y_ ), point ); + painter.drawEllipse( point, radius, radius ); +} + /*-------------------------------------------------------------------*/ /*! diff --git a/src/qt/player_painter.h b/src/qt/player_painter.h index 28e7cf8..1e471e2 100644 --- a/src/qt/player_painter.h +++ b/src/qt/player_painter.h @@ -145,6 +145,9 @@ class PlayerPainter void drawViewDir( QPainter & painter, const PlayerPainter::Param & param ) const; + void drawFocusPoint( QPainter & painter, + const PlayerPainter::Param & param ) const; + void drawCatchableArea( QPainter & painter, const PlayerPainter::Param & param ) const; void drawTackleArea( QPainter & painter, diff --git a/src/qt/player_painter_rcss.cpp b/src/qt/player_painter_rcss.cpp index b421853..6a66e48 100644 --- a/src/qt/player_painter_rcss.cpp +++ b/src/qt/player_painter_rcss.cpp @@ -216,6 +216,7 @@ PlayerPainterRCSS::drawAll( QPainter & painter, { const Options & opt = Options::instance(); + const bool selected = opt.isSelectedAgent( player.side(), player.unum() ); const Param param( player, ball, M_main_data.viewHolder().playerType( player.type() ) ); @@ -224,17 +225,26 @@ PlayerPainterRCSS::drawAll( QPainter & painter, //drawShadow( painter, param ); drawEdge( painter, param ); - if ( opt.isSelectedAgent( player.side(), player.unum() ) + if ( selected && opt.playerFutureCycle() > 0 && player.hasVelocity() ) { drawFuture( painter, param ); } - if ( player.hasView() - && opt.showViewArea() ) + if ( player.hasView() ) { - drawViewArea( painter, param ); + if ( opt.showViewArea() ) + { + drawViewArea( painter, param ); + } + + if ( selected + && player.focusDist() > 1.0e-5 + && opt.showFocusPoint() ) + { + drawFocusPoint( painter, param ); + } } if ( player.isGoalie() @@ -602,6 +612,31 @@ PlayerPainterRCSS::drawViewArea( QPainter & painter, painter.drawLine( QLineF( param.x_, param.y_, end_x, end_y ) ); } +/*-------------------------------------------------------------------*/ +/*! + + */ +void +PlayerPainterRCSS::drawFocusPoint( QPainter & painter, + const PlayerPainterRCSS::Param & param ) const +{ + const Options & opt = Options::instance(); + const DrawConfig & dconf = DrawConfig::instance(); + + const rcsc::AngleDeg focus_angle = param.head_ + param.player_.focus_dir_; + const rcsc::Vector2D focus_point = rcsc::Vector2D::from_polar( param.player_.focusDist(), focus_angle ); + const double radius = opt.scale( opt.focusPointSize() ); + + const QPointF point( opt.screenX( param.player_.x() + focus_point.x ), + opt.screenY( param.player_.y() + focus_point.y ) ); + + painter.setPen( dconf.focusPointPen() ); + painter.setBrush( Qt::NoBrush ); + painter.drawLine( QPointF( param.x_, param.y_ ), point ); + painter.drawEllipse( point, radius, radius ); + +} + /*-------------------------------------------------------------------*/ /*! diff --git a/src/qt/player_painter_rcss.h b/src/qt/player_painter_rcss.h index 1621ee6..7b95560 100644 --- a/src/qt/player_painter_rcss.h +++ b/src/qt/player_painter_rcss.h @@ -170,6 +170,9 @@ class PlayerPainterRCSS void drawViewAreaBackground( QPainter & painter, const rcsc::rcg::PlayerT & player ) const; + void drawFocusPoint( QPainter & painter, + const PlayerPainterRCSS::Param & param ) const; + void drawCatchableArea( QPainter & painter, const PlayerPainterRCSS::Param & param ) const; void drawTackleArea( QPainter & painter, diff --git a/src/qt/monitor_move_dialog.cpp b/src/qt/trainer_dialog.cpp similarity index 83% rename from src/qt/monitor_move_dialog.cpp rename to src/qt/trainer_dialog.cpp index 4c5e6b7..bfe2910 100644 --- a/src/qt/monitor_move_dialog.cpp +++ b/src/qt/trainer_dialog.cpp @@ -1,8 +1,8 @@ // -*-c++-*- /*! - \file monitor_move_dialog.cpp - \brief monitor client move control dialog class Source File. + \file trainer_dialog.cpp + \brief trainer dialog class Source File. */ /* @@ -41,7 +41,7 @@ #include #endif -#include "monitor_move_dialog.h" +#include "trainer_dialog.h" #include "options.h" #include "main_data.h" @@ -59,27 +59,43 @@ /*! */ -MonitorMoveDialog::MonitorMoveDialog( QWidget * parent, - const MainData & main_data, - TrainerData & trainer_data ) +TrainerDialog::TrainerDialog( QWidget * parent, + const MainData & main_data, + TrainerData & trainer_data ) : QDialog( parent ) , M_main_data( main_data ) , M_trainer_data( trainer_data ) + , M_auto_repeat_timer( new QTimer( this ) ) { - this->setWindowTitle( tr( "Player Move Control" ) ); + this->setWindowTitle( tr( "Trainer Panel" ) ); createWidgets(); + + connect( M_auto_repeat_timer, SIGNAL( timeout() ), + this, SLOT( sendCommand() ) ); + + M_ball_cb->setChecked( true ); + M_left_all_cb->setChecked( true ); + M_right_all_cb->setChecked( true ); } /*-------------------------------------------------------------------*/ /*! */ -MonitorMoveDialog::~MonitorMoveDialog() +TrainerDialog::~TrainerDialog() +{ + //std::cerr << "delete TrainerDialog" << std::endl; +} + +/*-------------------------------------------------------------------*/ +void +TrainerDialog::closeEvent( QCloseEvent * ) { - //std::cerr << "delete MonitorMoveDialog" << std::endl; + std::cerr << "TrainerDialog::closeEvent" << std::endl; + M_auto_repeat_timer->stop(); } /*-------------------------------------------------------------------*/ @@ -87,7 +103,7 @@ MonitorMoveDialog::~MonitorMoveDialog() */ void -MonitorMoveDialog::createWidgets() +TrainerDialog::createWidgets() { QVBoxLayout * top_layout = new QVBoxLayout(); top_layout->setSizeConstraint( QLayout::SetFixedSize ); @@ -139,6 +155,14 @@ MonitorMoveDialog::createWidgets() top_layout->addLayout( layout ); } + // other options + { + QHBoxLayout * layout = new QHBoxLayout(); + layout->addWidget( createAutoRepeatBox() ); + + top_layout->addLayout( layout ); + } + // buttons { QHBoxLayout * layout = new QHBoxLayout(); @@ -152,7 +176,7 @@ MonitorMoveDialog::createWidgets() QPushButton * cancel = new QPushButton( tr( "Close" ) ); cancel->setAutoDefault( false ); connect( cancel, SIGNAL( clicked() ), - this, SLOT( reject() ) ); + this, SLOT( close() ) ); layout->addWidget( cancel, 2, Qt::AlignVCenter ); top_layout->addLayout( layout ); @@ -166,7 +190,7 @@ MonitorMoveDialog::createWidgets() */ QWidget * -MonitorMoveDialog::createBallBox() +TrainerDialog::createBallBox() { QVBoxLayout * top_layout = new QVBoxLayout(); top_layout->setSizeConstraint( QLayout::SetFixedSize ); @@ -182,7 +206,7 @@ MonitorMoveDialog::createBallBox() int col = 0; M_ball_cb = new QCheckBox(); - M_ball_cb->setChecked( false ); + //M_ball_cb->setChecked( false ); connect( M_ball_cb, SIGNAL( toggled( bool ) ), this, SLOT( toggleBallCheck( bool ) ) ); layout->addWidget( M_ball_cb, row, col++ ); @@ -228,7 +252,7 @@ MonitorMoveDialog::createBallBox() M_ball_vy = new QLineEdit( tr( "0.0" ) ); M_ball_vy->setEnabled( false ); M_ball_vy->setValidator( new QDoubleValidator( -3.0, 3.0, 3, - M_ball_vy ) ); + M_ball_vy ) ); M_ball_vy->setMaximumSize( 64, 24 ); layout->addWidget( M_ball_vy, row, col++ ); @@ -244,30 +268,64 @@ MonitorMoveDialog::createBallBox() */ QWidget * -MonitorMoveDialog::createPlayModeBox() +TrainerDialog::createAutoRepeatBox() { QHBoxLayout * top_layout = new QHBoxLayout(); top_layout->setSizeConstraint( QLayout::SetFixedSize ); top_layout->setContentsMargins( 1, 1, 1, 1 ); top_layout->setSpacing( 1 ); - M_drop_ball_rb = new QRadioButton( tr( "Drop" ) ); - //connect( drop, SIGNAL( clicked() ), - //this, SLOT( clickDropBall() ) ); - top_layout->addWidget( M_drop_ball_rb ); - // - M_free_kick_left_rb = new QRadioButton( tr( "Left" ) ); - //connect( left, SIGNAL( clicked() ), - //this, SLOT( clickFreeKickLeft() ) ); - top_layout->addWidget( M_free_kick_left_rb ); - // - M_free_kick_right_rb = new QRadioButton( tr( "Right" ) ); - //connect( right, SIGNAL( clicked() ), - //this, SLOT( clickFreeKickRight() ) ); - top_layout->addWidget( M_free_kick_right_rb ); + top_layout->addWidget( new QLabel( tr( "Auto repeat:" ) ) ); + + top_layout->addSpacing( 2 ); + M_auto_repeat_text = new QLineEdit( tr( "0" ) ); + connect( M_auto_repeat_text, SIGNAL( textEdited( const QString & ) ), + this, SLOT( changeAutoRepeatTimer( const QString & ) ) ); + + top_layout->addWidget( M_auto_repeat_text ); + M_auto_repeat_text->setValidator( new QIntValidator( 0, 300, M_auto_repeat_text ) ); + M_auto_repeat_text->setMaximumSize( 64, 24 ); + top_layout->addSpacing( 2 ); + top_layout->addWidget( new QLabel( tr( "sec." ) ) ); + + top_layout->addStretch(); + + QGroupBox * group_box( new QGroupBox( tr( "Options" ) ) ); + group_box->setLayout( top_layout ); + + return group_box; +} + +/*-------------------------------------------------------------------*/ +/*! + + */ +QWidget * +TrainerDialog::createPlayModeBox() +{ + QHBoxLayout * top_layout = new QHBoxLayout(); + top_layout->setSizeConstraint( QLayout::SetFixedSize ); + top_layout->setContentsMargins( 1, 1, 1, 1 ); + top_layout->setSpacing( 1 ); + + + M_playmode_cb = new QComboBox(); + + M_playmode_cb->addItem( tr( "play_on" ) ); + M_playmode_cb->addItem( tr( "free_kick_l" ) ); + M_playmode_cb->addItem( tr( "free_kick_r" ) ); + M_playmode_cb->addItem( tr( "kick_in_l" ) ); + M_playmode_cb->addItem( tr( "kick_in_r" ) ); + M_playmode_cb->addItem( tr( "corner_kick_l" ) ); + M_playmode_cb->addItem( tr( "corner_kick_r" ) ); + M_playmode_cb->addItem( tr( "goal_kick_l" ) ); + M_playmode_cb->addItem( tr( "goal_kick_r" ) ); + M_playmode_cb->addItem( tr( "indirect_free_kick_l" ) ); + M_playmode_cb->addItem( tr( "indirect_free_kick_r" ) ); + + top_layout->addWidget( M_playmode_cb ); - M_drop_ball_rb->setChecked( true ); QGroupBox * group_box = new QGroupBox( tr( "PlayMode" ) ); group_box->setLayout( top_layout ); @@ -279,7 +337,7 @@ MonitorMoveDialog::createPlayModeBox() */ QWidget * -MonitorMoveDialog::createLeftTeamBox() +TrainerDialog::createLeftTeamBox() { QVBoxLayout * top_layout = new QVBoxLayout(); top_layout->setSizeConstraint( QLayout::SetFixedSize ); @@ -298,9 +356,9 @@ MonitorMoveDialog::createLeftTeamBox() int col = 0; layout->addWidget( new QLabel( tr( " " ) ), 0, col++, Qt::AlignHCenter ); M_left_all_cb = new QCheckBox(); - M_left_all_cb->setChecked( false ); connect( M_left_all_cb, SIGNAL( toggled( bool ) ), this, SLOT( toggleLeftAll( bool ) ) ); + //M_left_all_cb->setChecked( false ); layout->addWidget( M_left_all_cb, 0, col++, Qt::AlignHCenter ); layout->addWidget( new QLabel( tr( "X" ) ), 0, col++, Qt::AlignHCenter ); layout->addWidget( new QLabel( tr( "Y" ) ), 0, col++, Qt::AlignHCenter ); @@ -357,7 +415,7 @@ MonitorMoveDialog::createLeftTeamBox() */ QWidget * -MonitorMoveDialog::createRightTeamBox() +TrainerDialog::createRightTeamBox() { QVBoxLayout * top_layout = new QVBoxLayout(); top_layout->setSizeConstraint( QLayout::SetFixedSize ); @@ -376,7 +434,7 @@ MonitorMoveDialog::createRightTeamBox() int col = 0; layout->addWidget( new QLabel( tr( " " ) ), 0, col++, Qt::AlignHCenter ); M_right_all_cb = new QCheckBox(); - M_right_all_cb->setChecked( false ); + //M_right_all_cb->setChecked( false ); connect( M_right_all_cb, SIGNAL( toggled( bool ) ), this, SLOT( toggleRightAll( bool ) ) ); layout->addWidget( M_right_all_cb, 0, col++, Qt::AlignHCenter ); @@ -435,7 +493,7 @@ MonitorMoveDialog::createRightTeamBox() */ void -MonitorMoveDialog::toggleBallCheck( bool on ) +TrainerDialog::toggleBallCheck( bool on ) { M_ball_x->setEnabled( on ); M_ball_y->setEnabled( on ); @@ -449,7 +507,7 @@ MonitorMoveDialog::toggleBallCheck( bool on ) */ void -MonitorMoveDialog::toggleBallVelCheck( bool on ) +TrainerDialog::toggleBallVelCheck( bool on ) { M_ball_vx->setEnabled( on ); M_ball_vy->setEnabled( on ); @@ -460,7 +518,7 @@ MonitorMoveDialog::toggleBallVelCheck( bool on ) */ void -MonitorMoveDialog::toggleLeftAll( bool on ) +TrainerDialog::toggleLeftAll( bool on ) { for ( int i = 0; i < 11; ++i ) { @@ -476,7 +534,7 @@ MonitorMoveDialog::toggleLeftAll( bool on ) */ void -MonitorMoveDialog::toggleRightAll( bool on ) +TrainerDialog::toggleRightAll( bool on ) { for ( int i = 0; i < 11; ++i ) { @@ -492,7 +550,7 @@ MonitorMoveDialog::toggleRightAll( bool on ) */ void -MonitorMoveDialog::toggleLeftCheck( int index ) +TrainerDialog::toggleLeftCheck( int index ) { if ( index < 0 || 11 < index ) { @@ -511,7 +569,7 @@ MonitorMoveDialog::toggleLeftCheck( int index ) */ void -MonitorMoveDialog::toggleRightCheck( int index ) +TrainerDialog::toggleRightCheck( int index ) { if ( index < 0 || 11 < index ) { @@ -530,7 +588,7 @@ MonitorMoveDialog::toggleRightCheck( int index ) */ void -MonitorMoveDialog::readFieldStatus() +TrainerDialog::readFieldStatus() { MonitorViewData::ConstPtr view = M_main_data.getCurrentViewData(); @@ -542,52 +600,46 @@ MonitorMoveDialog::readFieldStatus() const bool reverse = Options::instance().reverseSide(); const double rval = Options::instance().reverseValue(); - // playmode - if ( view->isLeftSetPlay() ) - { - if ( reverse ) - { - M_free_kick_right_rb->setChecked( true ); - } - else - { - M_free_kick_left_rb->setChecked( true ); - } - } - else if ( view->isRightSetPlay() ) { - if ( reverse ) + const char * playmode_strings[] = PLAYMODE_STRINGS; + const rcsc::PlayMode pmode = view->playmode(); + const QString pmode_string( playmode_strings[pmode] ); + + bool found = false; + for ( int i = 0; i < M_playmode_cb->count(); ++i ) { - M_free_kick_left_rb->setChecked( true ); + if ( M_playmode_cb->itemText( i ) == pmode_string ) + { + found = true; + M_playmode_cb->setCurrentIndex( i ); + break; + } } - else + + if ( ! found ) { - M_free_kick_right_rb->setChecked( true ); + M_playmode_cb->setCurrentIndex( 0 ); // play_on if not found } } - else - { - M_drop_ball_rb->setChecked( true ); - } char buf[64]; // ball if ( M_ball_cb->isChecked() ) { - snprintf( buf, 64, "%.3f", view->ball().x() * rval ); + snprintf( buf, 63, "%.3f", view->ball().x() * rval ); M_ball_x->setText( QString::fromLatin1( buf ) ); - snprintf( buf, 64, "%.3f", view->ball().y() * rval ); + snprintf( buf, 63, "%.3f", view->ball().y() * rval ); M_ball_y->setText( QString::fromLatin1( buf ) ); if ( M_ball_vel_cb->isChecked() && view->ball().hasVelocity() ) { - snprintf( buf, 64, "%.3f", view->ball().deltaX() * rval ); + snprintf( buf, 63, "%.3f", view->ball().deltaX() * rval ); M_ball_vx->setText( QString::fromLatin1( buf ) ); - snprintf( buf, 64, "%.3f", view->ball().deltaY() * rval ); + snprintf( buf, 63, "%.3f", view->ball().deltaY() * rval ); M_ball_vy->setText( QString::fromLatin1( buf ) ); } } @@ -603,10 +655,10 @@ MonitorMoveDialog::readFieldStatus() { if ( ! M_left_cb[idx]->isChecked() ) continue; - snprintf( buf, 64, "%.3f", players[i].x() * rval ); + snprintf( buf, 63, "%.3f", players[i].x() * rval ); M_left_x[idx]->setText( QString::fromLatin1( buf ) ); - snprintf( buf, 64, "%.3f", players[i].y() * rval ); + snprintf( buf, 63, "%.3f", players[i].y() * rval ); M_left_y[idx]->setText( QString::fromLatin1( buf ) ); double body = players[i].body(); @@ -615,7 +667,7 @@ MonitorMoveDialog::readFieldStatus() body += 180.0; if ( body > 180.0 ) body -= 360.0; } - snprintf( buf, 64, "%.3f", body ); + snprintf( buf, 63, "%.3f", body ); M_left_body[idx]->setText( QString::fromLatin1( buf ) ); } } @@ -628,10 +680,10 @@ MonitorMoveDialog::readFieldStatus() { if ( ! M_right_cb[idx]->isChecked() ) continue; - snprintf( buf, 64, "%.3f", players[i].x() * rval ); + snprintf( buf, 63, "%.3f", players[i].x() * rval ); M_right_x[idx]->setText( QString::fromLatin1( buf ) ); - snprintf( buf, 64, "%.3f", players[i].y() * rval ); + snprintf( buf, 63, "%.3f", players[i].y() * rval ); M_right_y[idx]->setText( QString::fromLatin1( buf ) ); double body = players[i].body(); @@ -640,7 +692,7 @@ MonitorMoveDialog::readFieldStatus() body += 180.0; if ( body > 180.0 ) body -= 360.0; } - snprintf( buf, 64, "%.3f", body ); + snprintf( buf, 63, "%.3f", body ); M_right_body[idx]->setText( QString::fromLatin1( buf ) ); } } @@ -652,7 +704,7 @@ MonitorMoveDialog::readFieldStatus() */ void -MonitorMoveDialog::open() +TrainerDialog::open() { QString file_path = QFileDialog::getOpenFileName( this, @@ -677,7 +729,6 @@ MonitorMoveDialog::open() M_ball_cb->setChecked( false ); M_ball_x->setEnabled( false ); M_ball_y->setEnabled( false ); - M_drop_ball_rb->setChecked( true ); for ( int i = 0; i < 11; ++i ) { @@ -710,17 +761,13 @@ MonitorMoveDialog::open() " playmode %s ", str_id ) == 1 ) { - if ( ! std::strcmp( str_id, "free_kick_l" ) ) - { - M_free_kick_left_rb->setChecked( true ); - } - else if ( ! std::strcmp( str_id, "free_kick_r" ) ) - { - M_free_kick_right_rb->setChecked( true ); - } - else + for ( int i = 0; i < M_playmode_cb->count(); ++i ) { - M_drop_ball_rb->setChecked( true ); + if ( M_playmode_cb->itemText( i ) == str_id ) + { + M_playmode_cb->setCurrentIndex( i ); + break; + } } } else if ( std::sscanf( line_buf.c_str(), @@ -867,7 +914,7 @@ MonitorMoveDialog::open() */ void -MonitorMoveDialog::save() +TrainerDialog::save() { QString file_path = QFileDialog::getSaveFileName( this, @@ -890,18 +937,7 @@ MonitorMoveDialog::save() } // playmode - if ( M_free_kick_left_rb->isChecked() ) - { - fout << "playmode free_kick_l\n"; - } - else if ( M_free_kick_right_rb->isChecked() ) - { - fout << "playmode free_kick_r\n"; - } - else - { - fout << "playmode drop_ball\n"; - } + fout << "playmode " << M_playmode_cb->currentText().toStdString() << '\n'; // ball if ( M_ball_cb->isChecked() ) @@ -960,33 +996,32 @@ MonitorMoveDialog::save() fout.close(); } +/*-------------------------------------------------------------------*/ +void +TrainerDialog::changeAutoRepeatTimer( const QString & val ) +{ + const int new_interval = val.toInt() * 1000; + + if ( new_interval > 0 ) + { + M_auto_repeat_timer->start( new_interval ); + } + else + { + M_auto_repeat_timer->stop(); + } +} + /*-------------------------------------------------------------------*/ /*! */ void -MonitorMoveDialog::sendCommand() +TrainerDialog::sendCommand() { const bool reverse = Options::instance().reverseSide(); - { - if ( M_free_kick_left_rb->isChecked() ) - { - M_trainer_data.setPlayMode( reverse - ? rcsc::PM_FreeKick_Right - : rcsc::PM_FreeKick_Left ); - } - else if ( M_free_kick_right_rb->isChecked() ) - { - M_trainer_data.setPlayMode( reverse - ? rcsc::PM_FreeKick_Left - : rcsc::PM_FreeKick_Right ); - } - else - { - M_trainer_data.setPlayMode( rcsc::PM_Drop_Ball ); - } - } + M_trainer_data.setPlayMode( M_playmode_cb->currentText().toStdString() ); // ball { @@ -1090,5 +1125,15 @@ MonitorMoveDialog::sendCommand() } } + const int timer_sec = M_auto_repeat_text->text().toInt(); + if ( timer_sec > 0 ) + { + M_auto_repeat_timer->start( timer_sec * 1000 ); + } + else + { + M_auto_repeat_timer->stop(); + } + emit executed(); } diff --git a/src/qt/monitor_move_dialog.h b/src/qt/trainer_dialog.h similarity index 75% rename from src/qt/monitor_move_dialog.h rename to src/qt/trainer_dialog.h index 4d6eadc..7b01e2b 100644 --- a/src/qt/monitor_move_dialog.h +++ b/src/qt/trainer_dialog.h @@ -1,8 +1,8 @@ // -*-c++-*- /*! - \file monitor_move_dialog.h - \brief monitor client move control dialog class Header File. + \file trainer_dialog.h + \brief trainer dialog class Header File. */ /* @@ -29,21 +29,22 @@ ///////////////////////////////////////////////////////////////////// -#ifndef SOCCERWINDOW2_QT4_PLAYER_MOVE_DIALOG_H -#define SOCCERWINDOW2_QT4_PLAYER_MOVE_DIALOG_H +#ifndef SOCCERWINDOW2_QT_TRAINER_DIALOG_H +#define SOCCERWINDOW2_QT_TRAINER_DIALOG_H #include +class QComboBox; class QCheckBox; class QLineEdit; -class QRadioButton; +class QTimer; class MainData; class TrainerData; //! field canvas configuration dialog -class MonitorMoveDialog +class TrainerDialog : public QDialog { Q_OBJECT @@ -60,9 +61,11 @@ class MonitorMoveDialog QLineEdit * M_ball_vx; QLineEdit * M_ball_vy; - QRadioButton * M_drop_ball_rb; - QRadioButton * M_free_kick_left_rb; - QRadioButton * M_free_kick_right_rb; + //QCheckBox * M_auto_repeat_cb; + QLineEdit * M_auto_repeat_text; + QTimer * M_auto_repeat_timer; + + QComboBox * M_playmode_cb; QCheckBox * M_left_all_cb; QCheckBox * M_left_cb[11]; @@ -76,19 +79,26 @@ class MonitorMoveDialog QLineEdit * M_right_y[11]; QLineEdit * M_right_body[11]; + public: - MonitorMoveDialog( QWidget * parent, - const MainData & main_data, - TrainerData & trainer_data ); - ~MonitorMoveDialog(); + TrainerDialog( QWidget * parent, + const MainData & main_data, + TrainerData & trainer_data ); + ~TrainerDialog(); + +protected: + + void closeEvent( QCloseEvent * e ); private: void createWidgets(); QWidget * createBallBox(); + QWidget * createAutoRepeatBox(); QWidget * createPlayModeBox(); + QWidget * createRecoverBox(); QWidget * createLeftTeamBox(); QWidget * createRightTeamBox(); @@ -101,13 +111,14 @@ private slots: void toggleBallCheck( bool on ); void toggleBallVelCheck( bool on ); - void toggleLeftAll( bool on ); void toggleRightAll( bool on ); void toggleLeftCheck( int index ); void toggleRightCheck( int index ); + void changeAutoRepeatTimer( const QString & val ); + void sendCommand(); signals: diff --git a/src/qt/view_config_dialog.cpp b/src/qt/view_config_dialog.cpp index 237b3a4..1f87399 100644 --- a/src/qt/view_config_dialog.cpp +++ b/src/qt/view_config_dialog.cpp @@ -263,28 +263,45 @@ ViewConfigDialog::createObjectSizeControls() this, SLOT( clickEnlarge( bool ) ) ); top_layout->addWidget( M_enlarge_cb ); - - QHBoxLayout * box = new QHBoxLayout(); - // - box->addWidget( new QLabel( tr( "Ball Size:" ) ) ); - // - M_ball_size_text = new QLineEdit( tr( "0.35" ) ); - M_ball_size_text->setValidator( new QDoubleValidator( 0.01, 100.0, 3, M_ball_size_text ) ); - M_ball_size_text->setMaximumSize( 48, 24 ); - connect( M_ball_size_text, SIGNAL( textChanged( const QString & ) ), - this, SLOT( editBallSize( const QString & ) ) ); - box->addWidget( M_ball_size_text ); - // - box->addWidget( new QLabel( tr( " Player Size:" ) ) ); - // - M_player_size_text = new QLineEdit( tr( "0.0" ) ); - M_player_size_text->setValidator( new QDoubleValidator( 0.0, 100.0, 3, M_ball_size_text ) ); - M_player_size_text->setMaximumSize( 48, 24 ); - connect( M_player_size_text, SIGNAL( textChanged( const QString & ) ), - this, SLOT( editPlayerSize( const QString & ) ) ); - box->addWidget( M_player_size_text ); - // - top_layout->addLayout( box ); + { + QHBoxLayout * box = new QHBoxLayout(); + // + box->addWidget( new QLabel( tr( "Ball Size:" ) ) ); + // + M_ball_size_text = new QLineEdit( tr( "0.35" ) ); + M_ball_size_text->setValidator( new QDoubleValidator( 0.01, 100.0, 3, M_ball_size_text ) ); + M_ball_size_text->setMaximumSize( 48, 24 ); + connect( M_ball_size_text, SIGNAL( textChanged( const QString & ) ), + this, SLOT( editBallSize( const QString & ) ) ); + box->addWidget( M_ball_size_text ); + // + box->addWidget( new QLabel( tr( " Player Size:" ) ) ); + // + M_player_size_text = new QLineEdit( tr( "0.0" ) ); + M_player_size_text->setValidator( new QDoubleValidator( 0.0, 100.0, 3, M_ball_size_text ) ); + M_player_size_text->setMaximumSize( 48, 24 ); + connect( M_player_size_text, SIGNAL( textChanged( const QString & ) ), + this, SLOT( editPlayerSize( const QString & ) ) ); + box->addWidget( M_player_size_text ); + // + top_layout->addLayout( box ); + } + { + QHBoxLayout * box = new QHBoxLayout(); + // + box->addWidget( new QLabel( tr( "Focus Point Size:" ) ) ); + // + M_focus_point_size_text = new QLineEdit( tr( "2.0" ) ); + M_focus_point_size_text->setValidator( new QDoubleValidator( 0.1, 100.0, 3, M_focus_point_size_text ) ); + M_focus_point_size_text->setMaximumSize( 48, 24 ); + connect( M_focus_point_size_text, SIGNAL( textChanged( const QString & ) ), + this, SLOT( editFocusPointSize( const QString & ) ) ); + box->addWidget( M_focus_point_size_text ); + // + box->addStretch(); + // + top_layout->addLayout( box ); + } group_box->setLayout( top_layout ); return group_box; @@ -444,18 +461,18 @@ ViewConfigDialog::createPlayersDetailControls() this, SLOT( clickShowViewArea( bool ) ) ); layout->addWidget( M_view_area_cb ); // + M_focus_point_cb = new QCheckBox( tr( "Focus Point" ) ); + M_focus_point_cb->setChecked( opt.showFocusPoint() ); + connect( M_focus_point_cb, SIGNAL( clicked( bool ) ), + this, SLOT( clickShowFocusPoint( bool ) ) ); + layout->addWidget( M_focus_point_cb ); + // M_body_shadow_cb = new QCheckBox( tr( "Body Shadow" ) ); M_body_shadow_cb->setChecked( opt.showBodyShadow() ); connect( M_body_shadow_cb, SIGNAL( clicked( bool ) ), this, SLOT( clickShowBodyShadow( bool ) ) ); layout->addWidget( M_body_shadow_cb ); // - M_catchable_area_cb = new QCheckBox( tr( "Catch Area" ) ); - M_catchable_area_cb->setChecked( opt.showCatchableArea() ); - connect( M_catchable_area_cb, SIGNAL( clicked( bool ) ), - this, SLOT( clickShowCatchableArea( bool ) ) ); - layout->addWidget( M_catchable_area_cb ); - top_layout->addLayout( layout ); } { @@ -463,6 +480,13 @@ ViewConfigDialog::createPlayersDetailControls() layout->setContentsMargins( 0, 0, 0, 0 ); layout->setSpacing( 0 ); + // + M_catchable_area_cb = new QCheckBox( tr( "Catch Area" ) ); + M_catchable_area_cb->setChecked( opt.showCatchableArea() ); + connect( M_catchable_area_cb, SIGNAL( clicked( bool ) ), + this, SLOT( clickShowCatchableArea( bool ) ) ); + layout->addWidget( M_catchable_area_cb ); + // M_tackle_area_cb = new QCheckBox( tr( "Tackle Area" ) ); M_tackle_area_cb->setChecked( opt.showTackleArea() ); @@ -1260,6 +1284,7 @@ ViewConfigDialog::updateAll() M_enlarge_cb->setChecked( opt.enlargeMode() ); M_ball_size_text->setText( QString::number( opt.ballSize() ) ); M_player_size_text->setText( QString::number( opt.playerSize() ) ); + M_focus_point_size_text->setText( QString::number( opt.focusPointSize() ) ); updateFieldScale(); @@ -1273,6 +1298,7 @@ ViewConfigDialog::updateAll() M_stamina_cb->setChecked( opt.showStamina() ); M_stamina_capacity_cb->setChecked( opt.showStaminaCapacity() ); M_view_area_cb->setChecked( opt.showViewArea() ); + M_focus_point_cb->setChecked( opt.showFocusPoint() ); M_body_shadow_cb->setChecked( opt.showBodyShadow() ); M_catchable_area_cb->setChecked( opt.showCatchableArea() ); M_tackle_area_cb->setChecked( opt.showTackleArea() ); @@ -1506,6 +1532,24 @@ ViewConfigDialog::editPlayerSize( const QString & text ) } } +/*-------------------------------------------------------------------*/ +/*! + + */ +void +ViewConfigDialog::editFocusPointSize( const QString & text ) +{ + bool ok = true; + double value = text.toDouble( &ok ); + + if ( ok ) + { + Options::instance().setFocusPointSize( value ); + + emit configured(); + } +} + /*-------------------------------------------------------------------*/ /*! @@ -1797,6 +1841,34 @@ ViewConfigDialog::toggleShowViewArea() emit configured(); } + +/*-------------------------------------------------------------------*/ +/*! + + */ +void +ViewConfigDialog::clickShowFocusPoint( bool checked ) +{ + if ( Options::instance().showFocusPoint() != checked ) + { + Options::instance().toggleShowFocusPoint(); + emit configured(); + } +} + +/*-------------------------------------------------------------------*/ +/*! + + */ +void +ViewConfigDialog::toggleShowFocusPoint() +{ + Options::instance().toggleShowFocusPoint(); + M_focus_point_cb->setChecked( Options::instance().showFocusPoint() ); + + emit configured(); +} + /*-------------------------------------------------------------------*/ /*! diff --git a/src/qt/view_config_dialog.h b/src/qt/view_config_dialog.h index 4ea2926..46896cc 100644 --- a/src/qt/view_config_dialog.h +++ b/src/qt/view_config_dialog.h @@ -69,6 +69,7 @@ class ViewConfigDialog QCheckBox * M_enlarge_cb; QLineEdit * M_ball_size_text; QLineEdit * M_player_size_text; + QLineEdit * M_focus_point_size_text; // canvas size control QLineEdit * M_canvas_width_text; @@ -88,6 +89,7 @@ class ViewConfigDialog QCheckBox * M_stamina_cb; QCheckBox * M_stamina_capacity_cb; QCheckBox * M_view_area_cb; + QCheckBox * M_focus_point_cb; QCheckBox * M_body_shadow_cb; QCheckBox * M_catchable_area_cb; QCheckBox * M_tackle_area_cb; @@ -218,6 +220,7 @@ private slots: void clickShowStamina( bool checked ); void clickShowStaminaCapacity( bool checked ); void clickShowViewArea( bool checked ); + void clickShowFocusPoint( bool checked ); void clickShowBodyShadow( bool checked ); void clickShowCatchableArea( bool checked ); void clickShowTackleArea( bool checked ); @@ -303,6 +306,7 @@ public slots: void toggleEnlarge(); void editBallSize( const QString & text ); void editPlayerSize( const QString & text ); + void editFocusPointSize( const QString & text ); void applyCanvasSize(); @@ -316,6 +320,7 @@ public slots: void toggleShowStamina(); void toggleShowStaminaCapacity(); void toggleShowViewArea(); + void toggleShowFocusPoint(); void toggleShowBodyShadow(); void toggleShowCatchableArea(); void toggleShowTackleArea();