Mercurial > octave
changeset 32005:8f9de7cb4e02
Use appropriate type for arguments of Color::getRgbF and QColor::getHslF.
* m4/acinclude.m4 (OCTAVE_CHECK_FUNC_QCOLOR_FLOAT_TYPE): Add check if
Color::getRgbF and QColor::getHslF use arguments of type `float`. These
arguments are of type `qreal` with Qt5 (which is `double` on some platforms).
They are `float` with Qt6.
* libgui/graphics/QtHandlesUtils.cc (octave::Utils::toRgb),
libgui/src/gui-settings.cc (octave::gui_settings::get_color_value),
libgui/src/gui-utils.cc (octave::interpolate_color): Use arguments of
appropriate for Color::getRgbF and QColor::getHslF.
author | Markus Mützel <markus.muetzel@gmx.de> |
---|---|
date | Thu, 13 Apr 2023 11:09:04 +0200 |
parents | c5b57a82a17c |
children | 5724d89e9244 |
files | libgui/graphics/QtHandlesUtils.cc libgui/src/gui-settings.cc libgui/src/gui-utils.cc m4/acinclude.m4 |
diffstat | 4 files changed, 47 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/libgui/graphics/QtHandlesUtils.cc Thu Apr 13 09:11:48 2023 +0200 +++ b/libgui/graphics/QtHandlesUtils.cc Thu Apr 13 11:09:04 2023 +0200 @@ -161,9 +161,13 @@ Matrix rgb (1, 3); double *rgbData = rgb.fortran_vec (); +#if HAVE_QCOLOR_FLOAT_TYPE + float tmp[3]; +#else // qreal is a typedef for double except for ARM CPU architectures // where it is a typedef for float (Bug #44970). qreal tmp[3]; +#endif c.getRgbF (tmp, tmp+1, tmp+2); rgbData[0] = tmp[0]; rgbData[1] = tmp[1]; rgbData[2] = tmp[2];
--- a/libgui/src/gui-settings.cc Thu Apr 13 09:11:48 2023 +0200 +++ b/libgui/src/gui-settings.cc Thu Apr 13 11:09:04 2023 +0200 @@ -139,7 +139,11 @@ if ((mode == 1) && (default_color != settings_color_no_change)) { // In second mode, determine the default color from the first mode +#if HAVE_QCOLOR_FLOAT_TYPE + float h, s, l, a; +#else qreal h, s, l, a; +#endif default_color.getHslF (&h, &s, &l, &a); qreal l_new = 1.0-l*0.85; if (l < 0.3)
--- a/libgui/src/gui-utils.cc Thu Apr 13 09:11:48 2023 +0200 +++ b/libgui/src/gui-utils.cc Thu Apr 13 11:09:04 2023 +0200 @@ -39,7 +39,11 @@ interpolate_color (const QColor& col1, const QColor& col2, double fs, double fv) { +#if HAVE_QCOLOR_FLOAT_TYPE + float h1, s1, v1, h2, s2, v2; +#else qreal h1, s1, v1, h2, s2, v2; +#endif col1.getHsvF (&h1, &s1, &v1); col2.getHsvF (&h2, &s2, &v2);
--- a/m4/acinclude.m4 Thu Apr 13 09:11:48 2023 +0200 +++ b/m4/acinclude.m4 Thu Apr 13 11:09:04 2023 +0200 @@ -627,6 +627,40 @@ fi ]) dnl +dnl Check whether the Qt methods QColor::getRgbF and QColor::getHslF +dnl use float types as their arguments. The type of the arguments +dnl changed from qreal to float in Qt6. +dnl +dnl FIXME: Delete this check when we drop support for any version of Qt5. +dnl +AC_DEFUN([OCTAVE_CHECK_FUNC_QCOLOR_FLOAT_TYPE], [ + AC_CACHE_CHECK([for QColor::getRgbF and QColor::getHslF with float arguments], + [octave_cv_func_qcolor_float_type], + [AC_LANG_PUSH(C++) + ac_octave_save_CPPFLAGS="$CPPFLAGS" + ac_octave_save_CXXFLAGS="$CXXFLAGS" + CPPFLAGS="$QT_CPPFLAGS $CXXPICFLAG $CPPFLAGS" + CXXFLAGS="$CXXPICFLAG $CXXFLAGS" + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ + #include <QColor> + ]], [[ + QColor color; + float r, g, b, h, s, l, a; + color.getRgbF (&r, &g, &b); + color.getHslF (&h, &s, &l, &a); + ]])], + octave_cv_func_qcolor_float_type=yes, + octave_cv_func_qcolor_float_type=no) + CPPFLAGS="$ac_octave_save_CPPFLAGS" + CXXFLAGS="$ac_octave_save_CXXFLAGS" + AC_LANG_POP(C++) + ]) + if test $octave_cv_func_qcolor_float_type = yes; then + AC_DEFINE(HAVE_QCOLOR_FLOAT_TYPE, 1, + [Define to 1 if QColor::getRgbF and QColor::getHslF use float type arguments.]) + fi +]) +dnl dnl Check whether HDF5 library has version 1.6 API functions. dnl AC_DEFUN([OCTAVE_CHECK_HDF5_HAS_VER_16_API], [ @@ -1960,6 +1994,7 @@ OCTAVE_CHECK_FUNC_QHELPENGINE_DOCUMENTSFORIDENTIFIER OCTAVE_CHECK_FUNC_QWHEELEVENT_POSITION OCTAVE_CHECK_FUNC_QPAINTER_SETRENDERHINT_LOSSLESS + OCTAVE_CHECK_FUNC_QCOLOR_FLOAT_TYPE OCTAVE_CHECK_QREGION_ITERATORS OCTAVE_CHECK_QT_IMCURSORRECTANGLE_ENUM_VALUE