From 518a327bb9dcaa1f4b1000fd15decdea3d8154bc Mon Sep 17 00:00:00 2001
From: Souriya Trinh <souriya.trinh+github@gmail.com>
Date: Mon, 29 Jul 2024 22:36:59 +0200
Subject: [PATCH 1/2] Update tutorial-mb-generic-tracker-read to use
 vpDisplayFactory class.

---
 .../tutorial-mb-generic-tracker-read.cpp      | 30 ++++---------------
 1 file changed, 5 insertions(+), 25 deletions(-)

diff --git a/tutorial/tracking/model-based/generic/tutorial-mb-generic-tracker-read.cpp b/tutorial/tracking/model-based/generic/tutorial-mb-generic-tracker-read.cpp
index 1704418f10..a982e2be6e 100644
--- a/tutorial/tracking/model-based/generic/tutorial-mb-generic-tracker-read.cpp
+++ b/tutorial/tracking/model-based/generic/tutorial-mb-generic-tracker-read.cpp
@@ -1,14 +1,11 @@
 #include <memory>
 #include <visp3/core/vpConfig.h>
 #include <visp3/core/vpIoTools.h>
-#include <visp3/gui/vpDisplayX.h>
-#include <visp3/gui/vpDisplayGDI.h>
-#include <visp3/gui/vpDisplayOpenCV.h>
+#include <visp3/gui/vpDisplayFactory.h>
 #include <visp3/io/vpImageIo.h>
 #include <visp3/core/vpImageDraw.h>
 
-#if (defined(VISP_HAVE_X11) || defined(VISP_HAVE_GDI) || defined(HAVE_OPENCV_HIGHGUI)) \
-  && (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11)
+#if defined(VISP_HAVE_DISPLAY) && (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11)
 namespace
 {
 // https://en.cppreference.com/w/cpp/io/c/fprintf
@@ -22,23 +19,12 @@ std::string toString(const std::string &name, int val)
 
   return str;
 }
-
-template<typename T, typename... Args>
-std::unique_ptr<T> make_unique_compat(Args&&... args)
-{
-#if ((__cplusplus >= 201402L) || (defined(_MSVC_LANG) && (_MSVC_LANG >= 201402L)))
-  return std::make_unique<T>(args...);
-#else
-  return std::unique_ptr<T>(new T(std::forward<Args>(args)...));
-#endif
-}
 }
 #endif
 
 int main(int argc, char *argv[])
 {
-#if (defined(VISP_HAVE_X11) || defined(VISP_HAVE_GDI) || defined(HAVE_OPENCV_HIGHGUI)) \
-  && (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11) && defined(VISP_HAVE_MINIZ)
+#if defined(VISP_HAVE_DISPLAY) && (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11) && defined(VISP_HAVE_MINIZ)
 #ifdef ENABLE_VISP_NAMESPACE
   using namespace VISP_NAMESPACE_NAME;
 #endif
@@ -114,14 +100,8 @@ int main(int argc, char *argv[])
   vpImage<unsigned char> I(height, width);
   vpImage<vpRGBa> I_display(height, width);
 
-  std::unique_ptr<vpDisplay> display;
-#if defined(VISP_HAVE_X11)
-  display = make_unique_compat<vpDisplayX>(I_display, 100, 100, "Model-based tracker");
-#elif defined(VISP_HAVE_GDI)
-  display = make_unique_compat<vpDisplayGDI>(I_display, 100, 100, "Model-based tracker");
-#elif defined(HAVE_OPENCV_HIGHGUI)
-  display = make_unique_compat<vpDisplayOpenCV>(I_display, 100, 100, "Model-based tracker");
-#endif
+  std::shared_ptr<vpDisplay> display = vpDisplayFactory::createDisplay();
+  display->init(I_display, 100, 100, "Model-based tracker");
 
   visp::cnpy::NpyArray arr_nb_data = npz_data["nb_data"];
   int nb_data = *arr_nb_data.data<int>();

From 8eb86a057966533f9e2bbcaf4b3d84bd6db4927e Mon Sep 17 00:00:00 2001
From: Souriya Trinh <souriya.trinh+github@gmail.com>
Date: Tue, 30 Jul 2024 00:30:36 +0200
Subject: [PATCH 2/2] Remove template for std::shared_ptr<vpDisplay>
 createDisplay() function.

---
 modules/gui/include/visp3/gui/vpDisplayFactory.h | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/modules/gui/include/visp3/gui/vpDisplayFactory.h b/modules/gui/include/visp3/gui/vpDisplayFactory.h
index 16c68f3e10..713dea9678 100644
--- a/modules/gui/include/visp3/gui/vpDisplayFactory.h
+++ b/modules/gui/include/visp3/gui/vpDisplayFactory.h
@@ -128,15 +128,12 @@ vpDisplay *allocateDisplay(vpImage<T> &I, const int winx = -1, const int winy =
 
 #if (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11)
 /**
- * \brief Return a smart pointer vpDisplay specialization initialized with \b I
+ * \brief Return a smart pointer vpDisplay specialization
  * if a GUI library is available or nullptr otherwise.
  *
- * \tparam T : Any type that an image can handle and that can be displayed.
- *
- * \return A smart pointer pointing to a vpDisplay specialization initialized with \b I
+ * \return A smart pointer pointing to a vpDisplay specialization
  * if a GUI library is available or nullptr otherwise.
  */
-template<typename T>
 std::shared_ptr<vpDisplay> createDisplay()
 {
 #if defined(VISP_HAVE_DISPLAY)