Visual Servoing Platform  version 3.6.1 under development (2024-12-07)
vpDisplayGTK.h
1 /*
2  * ViSP, open source Visual Servoing Platform software.
3  * Copyright (C) 2005 - 2024 by Inria. All rights reserved.
4  *
5  * This software is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  * See the file LICENSE.txt at the root directory of this source
10  * distribution for additional information about the GNU GPL.
11  *
12  * For using ViSP with software that can not be combined with the GNU
13  * GPL, please contact Inria about acquiring a ViSP Professional
14  * Edition License.
15  *
16  * See https://visp.inria.fr for more information.
17  *
18  * This software was developed at:
19  * Inria Rennes - Bretagne Atlantique
20  * Campus Universitaire de Beaulieu
21  * 35042 Rennes Cedex
22  * France
23  *
24  * If you have questions regarding the use of this file, please contact
25  * Inria at visp@inria.fr
26  *
27  * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
28  * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
29  *
30  * Description:
31  * Image display.
32  */
33 
34 #ifndef VP_DISPLAY_GTK_H
35 #define VP_DISPLAY_GTK_H
36 
37 #include <visp3/core/vpConfig.h>
38 #include <visp3/core/vpDisplay.h>
39 #if (defined(VISP_HAVE_GTK))
40 #include <visp3/core/vpImage.h>
41 
42 BEGIN_VISP_NAMESPACE
43 
132 class VISP_EXPORT vpDisplayGTK : public vpDisplay
133 {
134 private:
135  typedef enum
136  {
137  id_black = 0,
138  id_white,
139  id_lightGray,
140  id_gray,
141  id_darkGray,
142  id_lightRed,
143  id_red,
144  id_darkRed,
145  id_lightGreen,
146  id_green,
147  id_darkGreen,
148  id_lightBlue,
149  id_blue,
150  id_darkBlue,
151  id_yellow,
152  id_cyan,
153  id_orange,
154  id_purple,
155  id_npredefined // Number of predefined colors
156  } vpColorIdentifier;
157 
158 public:
159  vpDisplayGTK();
160  vpDisplayGTK(int win_x, int win_y, const std::string &win_title = "");
162  vpDisplayGTK(vpImage<unsigned char> &I, int win_x = -1, int win_y = -1, const std::string &win_title = "",
163  vpScaleType type = SCALE_DEFAULT);
165  vpDisplayGTK(vpImage<vpRGBa> &I, int win_x = -1, int win_y = -1, const std::string &win_title = "",
166  vpScaleType type = SCALE_DEFAULT);
167 
168  virtual ~vpDisplayGTK() VP_OVERRIDE;
169 
170  void getImage(vpImage<vpRGBa> &I) VP_OVERRIDE;
171  unsigned int getScreenDepth();
172  unsigned int getScreenHeight() VP_OVERRIDE;
173  void getScreenSize(unsigned int &screen_width, unsigned int &screen_height) VP_OVERRIDE;
174  unsigned int getScreenWidth() VP_OVERRIDE;
175 
176  void init(vpImage<unsigned char> &I, int win_x = -1, int win_y = -1, const std::string &win_title = "") VP_OVERRIDE;
177  void init(vpImage<vpRGBa> &I, int win_x = -1, int win_y = -1, const std::string &win_title = "") VP_OVERRIDE;
178  void init(unsigned int win_width, unsigned int win_height, int win_x = -1, int win_y = -1,
179  const std::string &win_title = "") VP_OVERRIDE;
180 
181 protected:
182  void setFont(const std::string &fontname) VP_OVERRIDE;
183  void setTitle(const std::string &win_title) VP_OVERRIDE;
184  void setWindowPosition(int win_x, int win_y) VP_OVERRIDE;
185 
186  void clearDisplay(const vpColor &color = vpColor::white) VP_OVERRIDE;
187 
188  void closeDisplay() VP_OVERRIDE;
189 
190  void displayArrow(const vpImagePoint &ip1, const vpImagePoint &ip2, const vpColor &color = vpColor::white,
191  unsigned int w = 4, unsigned int h = 2, unsigned int thickness = 1) VP_OVERRIDE;
192 
193  void displayCircle(const vpImagePoint &center, unsigned int radius, const vpColor &color, bool fill = false,
194  unsigned int thickness = 1) VP_OVERRIDE;
195  void displayCross(const vpImagePoint &ip, unsigned int size, const vpColor &color, unsigned int thickness = 1) VP_OVERRIDE;
196  void displayDotLine(const vpImagePoint &ip1, const vpImagePoint &ip2, const vpColor &color,
197  unsigned int thickness = 1) VP_OVERRIDE;
198 
199  void displayImage(const vpImage<vpRGBa> &I) VP_OVERRIDE;
200  void displayImage(const vpImage<unsigned char> &I) VP_OVERRIDE;
201  void displayImage(const unsigned char *I);
202 
203  void displayImageROI(const vpImage<unsigned char> &I, const vpImagePoint &iP, unsigned int width,
204  unsigned int height) VP_OVERRIDE;
205  void displayImageROI(const vpImage<vpRGBa> &I, const vpImagePoint &iP, unsigned int width, unsigned int height) VP_OVERRIDE;
206 
207  void displayLine(const vpImagePoint &ip1, const vpImagePoint &ip2, const vpColor &color, unsigned int thickness = 1) VP_OVERRIDE;
208 
209  void displayPoint(const vpImagePoint &ip, const vpColor &color, unsigned int thickness = 1) VP_OVERRIDE;
210  void displayRectangle(const vpImagePoint &topLeft, unsigned int width, unsigned int height, const vpColor &color,
211  bool fill = false, unsigned int thickness = 1) VP_OVERRIDE;
212  void displayRectangle(const vpImagePoint &topLeft, const vpImagePoint &bottomRight, const vpColor &color,
213  bool fill = false, unsigned int thickness = 1) VP_OVERRIDE;
214  void displayRectangle(const vpRect &rectangle, const vpColor &color, bool fill = false, unsigned int thickness = 1) VP_OVERRIDE;
215 
216  void displayText(const vpImagePoint &ip, const std::string &text, const vpColor &color = vpColor::green) VP_OVERRIDE;
217 
218  void flushDisplay() VP_OVERRIDE;
219  void flushDisplayROI(const vpImagePoint &iP, unsigned int width, unsigned int height) VP_OVERRIDE;
220 
221  bool getClick(bool blocking = true) VP_OVERRIDE;
222  bool getClick(vpImagePoint &ip, bool blocking = true) VP_OVERRIDE;
223  bool getClick(vpImagePoint &ip, vpMouseButton::vpMouseButtonType &button, bool blocking = true) VP_OVERRIDE;
224  bool getClickUp(vpImagePoint &ip, vpMouseButton::vpMouseButtonType &button, bool blocking = true) VP_OVERRIDE;
225  bool getKeyboardEvent(bool blocking = true) VP_OVERRIDE;
226  bool getKeyboardEvent(std::string &key, bool blocking = true) VP_OVERRIDE;
227  bool getPointerMotionEvent(vpImagePoint &ip) VP_OVERRIDE;
228  bool getPointerPosition(vpImagePoint &ip) VP_OVERRIDE;
229 
230 private:
231  // Implementation
232  class Impl;
233  Impl *m_impl;
234 };
235 
236 END_VISP_NAMESPACE
237 #endif
238 #endif
Class to define RGB colors available for display functionalities.
Definition: vpColor.h:157
static const vpColor white
Definition: vpColor.h:212
static const vpColor green
Definition: vpColor.h:220
The vpDisplayGTK allows to display image using the GTK 3rd party library. Thus to enable this class G...
Definition: vpDisplayGTK.h:133
Class that defines generic functionalities for display.
Definition: vpDisplay.h:178
static bool getClick(const vpImage< unsigned char > &I, bool blocking=true)
static void displayCircle(const vpImage< unsigned char > &I, const vpImageCircle &circle, const vpColor &color, bool fill=false, unsigned int thickness=1)
static bool getKeyboardEvent(const vpImage< unsigned char > &I, bool blocking=true)
static void displayLine(const vpImage< unsigned char > &I, const vpImagePoint &ip1, const vpImagePoint &ip2, const vpColor &color, unsigned int thickness=1, bool segment=true)
static void getImage(const vpImage< unsigned char > &Is, vpImage< vpRGBa > &Id)
Definition: vpDisplay.cpp:140
static bool getClickUp(const vpImage< unsigned char > &I, vpImagePoint &ip, vpMouseButton::vpMouseButtonType &button, bool blocking=true)
static void displayCross(const vpImage< unsigned char > &I, const vpImagePoint &ip, unsigned int size, const vpColor &color, unsigned int thickness=1)
static void setTitle(const vpImage< unsigned char > &I, const std::string &windowtitle)
static void displayArrow(const vpImage< unsigned char > &I, const vpImagePoint &ip1, const vpImagePoint &ip2, const vpColor &color=vpColor::white, unsigned int w=4, unsigned int h=2, unsigned int thickness=1)
static void displayPoint(const vpImage< unsigned char > &I, const vpImagePoint &ip, const vpColor &color, unsigned int thickness=1)
static void setFont(const vpImage< unsigned char > &I, const std::string &font)
static void displayDotLine(const vpImage< unsigned char > &I, const vpImagePoint &ip1, const vpImagePoint &ip2, const vpColor &color, unsigned int thickness=1)
static bool getPointerPosition(const vpImage< unsigned char > &I, vpImagePoint &ip)
static bool getPointerMotionEvent(const vpImage< unsigned char > &I, vpImagePoint &ip)
static void displayRectangle(const vpImage< unsigned char > &I, const vpImagePoint &topLeft, unsigned int width, unsigned int height, const vpColor &color, bool fill=false, unsigned int thickness=1)
static void setWindowPosition(const vpImage< unsigned char > &I, int winx, int winy)
static void displayText(const vpImage< unsigned char > &I, const vpImagePoint &ip, const std::string &s, const vpColor &color)
Class that defines a 2D point in an image. This class is useful for image processing and stores only ...
Definition: vpImagePoint.h:82
Defines a rectangle in the plane.
Definition: vpRect.h:79