Visual Servoing Platform  version 3.6.1 under development (2024-07-27)
vpDisplayX.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 
39 #ifndef VP_DISPLAY_X_H
40 #define VP_DISPLAY_X_H
41 
42 #include <visp3/core/vpConfig.h>
43 #include <visp3/core/vpDisplay.h>
44 
45 #ifdef VISP_HAVE_X11
46 #include <visp3/core/vpImage.h>
47 #include <visp3/core/vpRect.h>
48 
50 
134 class VISP_EXPORT vpDisplayX : public vpDisplay
135 {
136  // private:
137  //#ifndef DOXYGEN_SHOULD_SKIP_THIS
138  // vpDisplayX(const vpDisplayX &)
139  // : vpDisplay(), display(nullptr), window(), Ximage(nullptr), lut(),
140  // context(), screen(), event(), pixmap(),
141  // x_color(nullptr), screen_depth(8), xcolor(), values(),
142  // ximage_data_init(false), RMask(0), GMask(0), BMask(0), RShift(0),
143  // GShift(0), BShift(0)
144  // {
145  // throw vpException(vpException::functionNotImplementedError, "Not
146  // implemented!");
147  // }
148  // vpDisplayX &operator=(const vpDisplayX &){
149  // throw vpException(vpException::functionNotImplementedError, "Not
150  // implemented!"); return *this;
151  // }
152  //#endif
153 
154 public:
155  vpDisplayX();
156  vpDisplayX(int winx, int winy, const std::string &title = "");
158  vpDisplayX(vpImage<unsigned char> &I, int winx = -1, int winy = -1, const std::string &title = "",
159  vpScaleType type = SCALE_DEFAULT);
161  vpDisplayX(vpImage<vpRGBa> &I, int winx = -1, int winy = -1, const std::string &title = "",
162  vpScaleType type = SCALE_DEFAULT);
163 
164  virtual ~vpDisplayX() VP_OVERRIDE;
165 
166  void getImage(vpImage<vpRGBa> &I) VP_OVERRIDE;
167  unsigned int getScreenDepth();
168  unsigned int getScreenHeight() VP_OVERRIDE;
169  void getScreenSize(unsigned int &width, unsigned int &height) VP_OVERRIDE;
170  unsigned int getScreenWidth() VP_OVERRIDE;
171 
172  void init(vpImage<unsigned char> &I, int win_x = -1, int win_y = -1, const std::string &win_title = "") VP_OVERRIDE;
173  void init(vpImage<vpRGBa> &I, int win_x = -1, int win_y = -1, const std::string &win_title = "") VP_OVERRIDE;
174  void init(unsigned int win_width, unsigned int win_height, int win_x = -1, int win_y = -1,
175  const std::string &win_title = "") VP_OVERRIDE;
176 
177 protected:
178  void clearDisplay(const vpColor &color = vpColor::white) VP_OVERRIDE;
179 
180  void closeDisplay() VP_OVERRIDE;
181 
182  void displayArrow(const vpImagePoint &ip1, const vpImagePoint &ip2, const vpColor &color = vpColor::white,
183  unsigned int w = 4, unsigned int h = 2, unsigned int thickness = 1) VP_OVERRIDE;
184 
185  void displayCircle(const vpImagePoint &center, unsigned int radius, const vpColor &color, bool fill = false,
186  unsigned int thickness = 1) VP_OVERRIDE;
187  void displayCross(const vpImagePoint &ip, unsigned int size, const vpColor &color, unsigned int thickness = 1) VP_OVERRIDE;
188  void displayDotLine(const vpImagePoint &ip1, const vpImagePoint &ip2, const vpColor &color,
189  unsigned int thickness = 1) VP_OVERRIDE;
190 
191  void displayImage(const vpImage<unsigned char> &I) VP_OVERRIDE;
192  void displayImage(const vpImage<vpRGBa> &I) VP_OVERRIDE;
193  void displayImage(const unsigned char *I);
194 
195  void displayImageROI(const vpImage<unsigned char> &I, const vpImagePoint &iP, unsigned int width,
196  unsigned int height) VP_OVERRIDE;
197  void displayImageROI(const vpImage<vpRGBa> &I, const vpImagePoint &iP, unsigned int width, unsigned int height) VP_OVERRIDE;
198 
199  void displayLine(const vpImagePoint &ip1, const vpImagePoint &ip2, const vpColor &color, unsigned int thickness = 1) VP_OVERRIDE;
200  void displayPoint(const vpImagePoint &ip, const vpColor &color, unsigned int thickness = 1) VP_OVERRIDE;
201 
202  void displayRectangle(const vpImagePoint &topLeft, unsigned int width, unsigned int height, const vpColor &color,
203  bool fill = false, unsigned int thickness = 1) VP_OVERRIDE;
204  void displayRectangle(const vpImagePoint &topLeft, const vpImagePoint &bottomRight, const vpColor &color,
205  bool fill = false, unsigned int thickness = 1) VP_OVERRIDE;
206  void displayRectangle(const vpRect &rectangle, const vpColor &color, bool fill = false, unsigned int thickness = 1) VP_OVERRIDE;
207 
208  void displayText(const vpImagePoint &ip, const std::string &text, const vpColor &color = vpColor::green) VP_OVERRIDE;
209 
210  void flushDisplay() VP_OVERRIDE;
211  void flushDisplayROI(const vpImagePoint &iP, unsigned int width, unsigned int height) VP_OVERRIDE;
212 
213  bool getClick(bool blocking = true) VP_OVERRIDE;
214  bool getClick(vpImagePoint &ip, bool blocking = true) VP_OVERRIDE;
215  bool getClick(vpImagePoint &ip, vpMouseButton::vpMouseButtonType &button, bool blocking = true) VP_OVERRIDE;
216  bool getClickUp(vpImagePoint &ip, vpMouseButton::vpMouseButtonType &button, bool blocking = true) VP_OVERRIDE;
217 
218  bool getKeyboardEvent(bool blocking = true) VP_OVERRIDE;
219  bool getKeyboardEvent(std::string &key, bool blocking = true) VP_OVERRIDE;
220 
221  bool getPointerMotionEvent(vpImagePoint &ip) VP_OVERRIDE;
222  bool getPointerPosition(vpImagePoint &ip) VP_OVERRIDE;
223 
224  void setFont(const std::string &font) VP_OVERRIDE;
225  void setTitle(const std::string &title) VP_OVERRIDE;
226  void setWindowPosition(int win_x, int win_y) VP_OVERRIDE;
227 
228 private:
229  // Implementation
230  class Impl;
231  Impl *m_impl;
232 };
233 
234 END_VISP_NAMESPACE
235 #endif
236 #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
Use the X11 console to display images on unix-like OS. Thus to enable this class X11 should be instal...
Definition: vpDisplayX.h:135
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