Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make gtk-2, X11, libjpeg and libpng private #1259

Merged
merged 2 commits into from
Oct 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions doc/tutorial/unix/tutorial-install-fedora.dox
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,15 @@ $ sudo dnf install libdmtx-devel
\verbatim
$ sudo dnf install gsl-devel
\endverbatim
- Gtk-2 for gui capabilities instead of X11
\verbatim
$ sudo dnf install gtk2-devel glib2-devel pango-devel atk-devel cairo-devel
\endverbatim
After installing the gtk packages, you need to explicitly enable gtk usage during ViSP cmake configuration step by:
\verbatim
$ cd $VISP_WS/visp-build
$ cmake ../visp -DUSE_GTK=ON
\endverbatim

\subsection install_fedora_get_source Get ViSP source code

Expand Down
15 changes: 15 additions & 0 deletions doc/tutorial/unix/tutorial-install-osx-homebrew.dox
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,21 @@ dyld[33644]: Library not loaded: /System/Library/Frameworks/Python.framework/Ver
To overcome this error, download and install the latest Python 2
for macOS from [offical site](https://www.python.org/downloads/macos/).

\subsubsection install_brew_3rdparty_other Other optional 3rd parties

We give also the way to install other 3rd party libraries to enable specific capabilities.

- Gtk-2 for gui capabilities instead of X11
\verbatim
$ brew install gtk
\endverbatim
After installing the gtk packages, you need to explicitly enable gtk usage during ViSP cmake configuration step by:
\verbatim
$ cd $VISP_WS/visp-build
$ cmake ../visp -DUSE_GTK=ON
\endverbatim


\subsection install_brew_get_source Get ViSP source code

There are different ways to get ViSP source code:
Expand Down
12 changes: 11 additions & 1 deletion doc/tutorial/unix/tutorial-install-ubuntu.dox
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ $ mkdir -p $VISP_WS

\section install_ubuntu_quick Quick ViSP installation

In this section, we give minimal instructions to build ViSP from source just to try ViSP without entering in \ref install_ubuntu_advanced.
In this section, we give minimal instructions to build ViSP from source just to try ViSP without entering in
\ref install_ubuntu_advanced.

- Install a small number of recommended 3rd parties

Expand Down Expand Up @@ -448,6 +449,15 @@ $ sudo apt-get install libgsl-dev
\verbatim
$ sudo apt-get install nlohmann-json3-dev
\endverbatim
- Gtk-2 for gui capabilities instead of X11
\verbatim
$ sudo apt-get install libgtk2.0-dev libglib2.0-dev libpango1.0-dev libatk1.0-dev libcairo2-dev
\endverbatim
After installing the gtk packages, you need to explicitly enable gtk usage during ViSP cmake configuration step by:
\verbatim
$ cd $VISP_WS/visp-build
$ cmake ../visp -DUSE_GTK=ON
\endverbatim

\subsection install_ubuntu_visp_get_source Get ViSP source code

Expand Down
22 changes: 12 additions & 10 deletions modules/gui/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,31 +36,33 @@
# Add optional 3rd parties
set(opt_incs "")
set(opt_libs "")
set(opt_libs_private "")

# Display X11, GTK, GDI, D3D9. OpenCV already handled by core module
if(USE_X11)
list(APPEND opt_incs ${X11_INCLUDE_DIR})
list(APPEND opt_libs ${X11_LIBRARIES})
# X11 is private
include_directories(${X11_INCLUDE_DIR})
list(APPEND opt_libs_private ${X11_LIBRARIES})
mark_as_advanced(X11_xcb_icccm_INCLUDE_PATH)
mark_as_advanced(X11_xcb_icccm_LIB)
mark_as_advanced(X11_xcb_xkb_INCLUDE_PATH)
endif()

if(USE_GTK2)
list(APPEND opt_incs ${GTK2_INCLUDE_DIRS})
list(APPEND opt_libs ${GTK2_LIBRARIES})
# FS next lines removed until they proved to be useful
# if(UNIX)
# ## ignore gtk pedantic warnings by gcc specific -isystem :
# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -isystem ${GTK2_gtk_INCLUDE_PATH}")
# endif()
# gtk2 is private
include_directories(${GTK2_INCLUDE_DIRS})
list(APPEND opt_libs_private ${GTK2_LIBRARIES})
endif()

if(USE_GDI)
list(APPEND opt_libs ${GDI_LIBRARIES})
endif()

if(USE_DIRECT3D)
list(APPEND opt_incs ${DIRECT3D_INCLUDE_DIRS})
list(APPEND opt_libs ${DIRECT3D_LIBRARIES})
endif()

if(USE_PCL)
list(APPEND opt_incs ${PCL_INCLUDE_DIRS})

Expand All @@ -83,7 +85,7 @@ if(USE_PCL)
list(APPEND opt_libs ${PCL_DEPS_LIBRARIES})
endif()

vp_add_module(gui visp_core)
vp_add_module(gui visp_core PRIVATE_OPTIONAL ${opt_libs_private})
vp_glob_module_sources()
vp_module_include_directories(${opt_incs})
vp_create_module(${opt_libs})
Expand Down
172 changes: 83 additions & 89 deletions modules/gui/include/visp3/gui/vpDisplayGTK.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/****************************************************************************
*
/*
* ViSP, open source Visual Servoing Platform software.
* Copyright (C) 2005 - 2023 by Inria. All rights reserved.
*
Expand Down Expand Up @@ -30,11 +29,7 @@
*
* Description:
* Image display.
*
* Authors:
* Christophe Collewet
*
*****************************************************************************/
*/

#ifndef vpDisplayGTK_h
#define vpDisplayGTK_h
Expand All @@ -46,90 +41,89 @@
#include <visp3/core/vpImage.h>

/*!
\file vpDisplayGTK.h
\brief Define the GTK console to display images.
*/
* \file vpDisplayGTK.h
* \brief Define the GTK console to display images.
*/

/*!

\class vpDisplayGTK

\ingroup group_gui_display

\brief The vpDisplayGTK allows to display image using the GTK 3rd party
library. Thus to enable this class GTK should be installed. Installation
instructions are provided here https://visp.inria.fr/3rd_gtk.

The example below shows how to display an image with this video device.
\code
#include <visp3/core/vpImagePoint.h>
#include <visp3/gui/vpDisplayGTK.h>
#include <visp3/io/vpImageIo.h>

int main()
{
#if defined(VISP_HAVE_GTK)
vpImage<unsigned char> I; // Grey level image

// Read an image in PGM P5 format
#ifdef _WIN32
vpImageIo::read(I, "C:/Temp/visp-images/Klimt/Klimt.pgm");
#else
vpImageIo::read(I, "/local/soft/ViSP/ViSP-images/Klimt/Klimt.pgm");
#endif

vpDisplayGTK d;

// Initialize the display with the image I. Display and image are
// now link together.
d.init(I);

// Specify the window location
vpDisplay::setWindowPosition(I, 400, 100);

// Set the display window title
vpDisplay::setTitle(I, "My GTK display");

// Set the display background with image I content
vpDisplay::display(I);

// Draw a red rectangle in the display overlay (foreground)
vpDisplay::displayRectangle(I, 10, 10, 100, 20, vpColor::red, true);

// Draw a red rectangle in the display overlay (foreground)
vpImagePoint topLeftCorner;
topLeftCorner.set_i(50);
topLeftCorner.set_j(10);
vpDisplay::displayRectangle(I, topLeftCorner, 100, 20, vpColor::green, true);

// Flush the foreground and background display
vpDisplay::flush(I);

// Get non blocking keyboard events
std::cout << "Check keyboard events..." << std::endl;
char key[10];
bool ret;
for (int i=0; i< 200; i++) {
bool ret = vpDisplay::getKeyboardEvent(I, key, false);
if (ret)
std::cout << "keyboard event: key: " << "\"" << key << "\"" << std::endl;
vpTime::wait(40);
}

// Get a blocking keyboard event
std::cout << "Wait for a keyboard event..." << std::endl;
ret = vpDisplay::getKeyboardEvent(I, key, true);
std::cout << "keyboard event: " << ret << std::endl;
if (ret)
std::cout << "key: " << "\"" << key << "\"" << std::endl;

// Wait for a click in the display window
std::cout << "Wait for a button click..." << std::endl;
vpDisplay::getClick(I);
#endif
}
\endcode
*/
* \class vpDisplayGTK
*
* \ingroup group_gui_display
*
* \brief The vpDisplayGTK allows to display image using the GTK 3rd party
* library. Thus to enable this class GTK should be installed. Installation
* instructions are provided here https://visp.inria.fr/3rd_gtk.
*
* The example below shows how to display an image with this video device.
* \code
* #include <visp3/core/vpImagePoint.h>
* #include <visp3/gui/vpDisplayGTK.h>
* #include <visp3/io/vpImageIo.h>
*
* int main()
* {
* #if defined(VISP_HAVE_GTK)
* vpImage<unsigned char> I; // Grey level image
*
* // Read an image in PGM P5 format
* #ifdef _WIN32
* vpImageIo::read(I, "C:/Temp/visp-images/Klimt/Klimt.pgm");
* #else
* vpImageIo::read(I, "/local/soft/ViSP/ViSP-images/Klimt/Klimt.pgm");
* #endif
*
* vpDisplayGTK d;
*
* // Initialize the display with the image I. Display and image are
* // now link together.
* d.init(I);
*
* // Specify the window location
* vpDisplay::setWindowPosition(I, 400, 100);
*
* // Set the display window title
* vpDisplay::setTitle(I, "My GTK display");
*
* // Set the display background with image I content
* vpDisplay::display(I);
*
* // Draw a red rectangle in the display overlay (foreground)
* vpDisplay::displayRectangle(I, 10, 10, 100, 20, vpColor::red, true);
*
* // Draw a red rectangle in the display overlay (foreground)
* vpImagePoint topLeftCorner;
* topLeftCorner.set_i(50);
* topLeftCorner.set_j(10);
* vpDisplay::displayRectangle(I, topLeftCorner, 100, 20, vpColor::green, true);
*
* // Flush the foreground and background display
* vpDisplay::flush(I);
*
* // Get non blocking keyboard events
* std::cout << "Check keyboard events..." << std::endl;
* char key[10];
* bool ret;
* for (int i=0; i< 200; i++) {
* bool ret = vpDisplay::getKeyboardEvent(I, key, false);
* if (ret)
* std::cout << "keyboard event: key: " << "\"" << key << "\"" << std::endl;
* vpTime::wait(40);
* }
*
* // Get a blocking keyboard event
* std::cout << "Wait for a keyboard event..." << std::endl;
* ret = vpDisplay::getKeyboardEvent(I, key, true);
* std::cout << "keyboard event: " << ret << std::endl;
* if (ret)
* std::cout << "key: " << "\"" << key << "\"" << std::endl;
*
* // Wait for a click in the display window
* std::cout << "Wait for a button click..." << std::endl;
* vpDisplay::getClick(I);
* #endif
* }
* \endcode
*/
class VISP_EXPORT vpDisplayGTK : public vpDisplay
{
private:
Expand Down
Loading
Loading