Visual Servoing Platform  version 3.6.1 under development (2024-05-28)
vpDisplayGTK.h
1 /*
2  * ViSP, open source Visual Servoing Platform software.
3  * Copyright (C) 2005 - 2023 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 vpDisplayGTK_h
35 #define vpDisplayGTK_h
36 
37 #include <visp3/core/vpConfig.h>
38 #if (defined(VISP_HAVE_GTK))
39 
40 #include <visp3/core/vpDisplay.h>
41 #include <visp3/core/vpImage.h>
42 
127 class VISP_EXPORT vpDisplayGTK : public vpDisplay
128 {
129 private:
130  typedef enum
131  {
132  id_black = 0,
133  id_white,
134  id_lightGray,
135  id_gray,
136  id_darkGray,
137  id_lightRed,
138  id_red,
139  id_darkRed,
140  id_lightGreen,
141  id_green,
142  id_darkGreen,
143  id_lightBlue,
144  id_blue,
145  id_darkBlue,
146  id_yellow,
147  id_cyan,
148  id_orange,
149  id_purple,
150  id_npredefined // Number of predefined colors
151  } vpColorIdentifier;
152 
153 public:
154  vpDisplayGTK();
155  vpDisplayGTK(int win_x, int win_y, const std::string &win_title = "");
157  vpDisplayGTK(vpImage<unsigned char> &I, int win_x = -1, int win_y = -1, const std::string &win_title = "",
158  vpScaleType type = SCALE_DEFAULT);
160  vpDisplayGTK(vpImage<vpRGBa> &I, int win_x = -1, int win_y = -1, const std::string &win_title = "",
161  vpScaleType type = SCALE_DEFAULT);
162 
163  virtual ~vpDisplayGTK() vp_override;
164 
165  void getImage(vpImage<vpRGBa> &I) vp_override;
166  unsigned int getScreenDepth();
167  unsigned int getScreenHeight() vp_override;
168  void getScreenSize(unsigned int &screen_width, unsigned int &screen_height) vp_override;
169  unsigned int getScreenWidth() vp_override;
170 
171  void init(vpImage<unsigned char> &I, int win_x = -1, int win_y = -1, const std::string &win_title = "") vp_override;
172  void init(vpImage<vpRGBa> &I, int win_x = -1, int win_y = -1, const std::string &win_title = "") vp_override;
173  void init(unsigned int win_width, unsigned int win_height, int win_x = -1, int win_y = -1,
174  const std::string &win_title = "") vp_override;
175 
176 protected:
177  void setFont(const std::string &fontname) vp_override;
178  void setTitle(const std::string &win_title) vp_override;
179  void setWindowPosition(int win_x, int win_y) vp_override;
180 
181  void clearDisplay(const vpColor &color = vpColor::white) vp_override;
182 
183  void closeDisplay() vp_override;
184 
185  void displayArrow(const vpImagePoint &ip1, const vpImagePoint &ip2, const vpColor &color = vpColor::white,
186  unsigned int w = 4, unsigned int h = 2, unsigned int thickness = 1) vp_override;
187 
188  void displayCircle(const vpImagePoint &center, unsigned int radius, const vpColor &color, bool fill = false,
189  unsigned int thickness = 1) vp_override;
190  void displayCross(const vpImagePoint &ip, unsigned int size, const vpColor &color, unsigned int thickness = 1) vp_override;
191  void displayDotLine(const vpImagePoint &ip1, const vpImagePoint &ip2, const vpColor &color,
192  unsigned int thickness = 1) vp_override;
193 
194  void displayImage(const vpImage<vpRGBa> &I) vp_override;
195  void displayImage(const vpImage<unsigned char> &I) vp_override;
196  void displayImage(const unsigned char *I);
197 
198  void displayImageROI(const vpImage<unsigned char> &I, const vpImagePoint &iP, unsigned int width,
199  unsigned int height) vp_override;
200  void displayImageROI(const vpImage<vpRGBa> &I, const vpImagePoint &iP, unsigned int width, unsigned int height) vp_override;
201 
202  void displayLine(const vpImagePoint &ip1, const vpImagePoint &ip2, const vpColor &color, unsigned int thickness = 1) vp_override;
203 
204  void displayPoint(const vpImagePoint &ip, const vpColor &color, unsigned int thickness = 1) vp_override;
205  void displayRectangle(const vpImagePoint &topLeft, unsigned int width, unsigned int height, const vpColor &color,
206  bool fill = false, unsigned int thickness = 1) vp_override;
207  void displayRectangle(const vpImagePoint &topLeft, const vpImagePoint &bottomRight, const vpColor &color,
208  bool fill = false, unsigned int thickness = 1) vp_override;
209  void displayRectangle(const vpRect &rectangle, const vpColor &color, bool fill = false, unsigned int thickness = 1) vp_override;
210 
211  void displayText(const vpImagePoint &ip, const std::string &text, const vpColor &color = vpColor::green) vp_override;
212 
213  void flushDisplay() vp_override;
214  void flushDisplayROI(const vpImagePoint &iP, unsigned int width, unsigned int height) vp_override;
215 
216  bool getClick(bool blocking = true) vp_override;
217  bool getClick(vpImagePoint &ip, bool blocking = true) vp_override;
218  bool getClick(vpImagePoint &ip, vpMouseButton::vpMouseButtonType &button, bool blocking = true) vp_override;
219  bool getClickUp(vpImagePoint &ip, vpMouseButton::vpMouseButtonType &button, bool blocking = true) vp_override;
220  bool getKeyboardEvent(bool blocking = true) vp_override;
221  bool getKeyboardEvent(std::string &key, bool blocking = true) vp_override;
222  bool getPointerMotionEvent(vpImagePoint &ip) vp_override;
223  bool getPointerPosition(vpImagePoint &ip) vp_override;
224 
225 private:
226  // Implementation
227  class Impl;
228  Impl *m_impl;
229 };
230 
231 #endif
232 #endif
Class to define RGB colors available for display functionalities.
Definition: vpColor.h:152
static const vpColor white
Definition: vpColor.h:206
static const vpColor green
Definition: vpColor.h:214
The vpDisplayGTK allows to display image using the GTK 3rd party library. Thus to enable this class G...
Definition: vpDisplayGTK.h:128
Class that defines generic functionalities for display.
Definition: vpDisplay.h:173
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:138
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:76