ViSP  2.9.0
vpDisplayX.h
1 /****************************************************************************
2  *
3  * $Id: vpDisplayX.h 4632 2014-02-03 17:06:40Z fspindle $
4  *
5  * This file is part of the ViSP software.
6  * Copyright (C) 2005 - 2014 by INRIA. All rights reserved.
7  *
8  * This software is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public License
10  * ("GPL") version 2 as published by the Free Software Foundation.
11  * See the file LICENSE.txt at the root directory of this source
12  * distribution for additional information about the GNU GPL.
13  *
14  * For using ViSP with software that can not be combined with the GNU
15  * GPL, please contact INRIA about acquiring a ViSP Professional
16  * Edition License.
17  *
18  * See http://www.irisa.fr/lagadic/visp/visp.html for more information.
19  *
20  * This software was developed at:
21  * INRIA Rennes - Bretagne Atlantique
22  * Campus Universitaire de Beaulieu
23  * 35042 Rennes Cedex
24  * France
25  * http://www.irisa.fr/lagadic
26  *
27  * If you have questions regarding the use of this file, please contact
28  * INRIA at visp@inria.fr
29  *
30  * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
31  * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
32  *
33  *
34  * Description:
35  * Image display.
36  *
37  * Authors:
38  * Fabien Spindler
39  *
40  *****************************************************************************/
41 
42 #ifndef vpDisplayX_h
43 #define vpDisplayX_h
44 
45 #include <visp/vpConfig.h>
46 #include <visp/vpDisplay.h>
47 #ifdef VISP_HAVE_X11
48 
49 //namespace X11name
50 //{
51 #include <X11/Xlib.h>
52 #include <X11/Xutil.h>
53 //#include <X11/Xatom.h>
54 //#include <X11/cursorfont.h>
55 //} ;
56 
57 //using namespace X11name ;
58 
59 #include <visp/vpImage.h>
60 #include <visp/vpRect.h>
61 
62 
63 
152 class VISP_EXPORT vpDisplayX: public vpDisplay
153 {
154 private:
155  int num_Xdisplay ;
156  Display *display ;
157  Window window ;
158  XImage *Ximage ;
159  Colormap lut ;
160  GC context ;
161  int screen ;
162  int planes;
163  XEvent event;
164  Pixmap pixmap;
165  unsigned long *x_color; // Array of predefined colors
166  unsigned int screen_depth ;
167  unsigned short colortable[256];
168  XColor xcolor;
169  XGCValues values;
170  int size ;
171  bool ximage_data_init;
172 
173 public:
174  vpDisplayX() ;
175  vpDisplayX(int winx, int winy, const char *title=NULL) ;
176  vpDisplayX(vpImage<unsigned char> &I, int winx=-1, int winy=-1,
177  const char *title=NULL) ;
178  vpDisplayX(vpImage<vpRGBa> &I, int winx=-1, int winy=-1,
179  const char *title=NULL) ;
180 
181  virtual ~vpDisplayX() ;
182 
184  int winx=-1, int winy=-1,
185  const char *title=NULL) ;
186  void init(vpImage<vpRGBa> &I,
187  int winx=-1, int winy=-1,
188  const char *title=NULL) ;
189 
190  void init(unsigned int width, unsigned int height,
191  int winx=-1, int winy=-1 ,
192  const char *title=NULL) ;
193 
194  unsigned int getScreenDepth();
195  void getScreenSize(unsigned int &width, unsigned int &height);
196  void getImage(vpImage<vpRGBa> &I) ;
197 
198 protected:
199 
200  void setFont( const char *font );
201  void setTitle(const char *title) ;
202  void setWindowPosition(int winx, int winy);
203 
204  void clearDisplay(const vpColor &color=vpColor::white) ;
205 
206  void closeDisplay() ;
207 
208  void displayArrow(const vpImagePoint &ip1,
209  const vpImagePoint &ip2,
210  const vpColor &color=vpColor::white,
211  unsigned int w=4,unsigned int h=2,
212  unsigned int thickness=1) ;
213 
214  void displayCharString(const vpImagePoint &ip, const char *text,
215  const vpColor &color=vpColor::green) ;
216 
217  void displayCircle(const vpImagePoint &center, unsigned int radius,
218  const vpColor &color,
219  bool fill = false,
220  unsigned int thickness=1);
221  void displayCross(const vpImagePoint &ip, unsigned int size,
222  const vpColor &color, unsigned int thickness=1) ;
223  void displayDotLine(const vpImagePoint &ip1,
224  const vpImagePoint &ip2,
225  const vpColor &color, unsigned int thickness=1) ;
226 
227  void displayImage(const vpImage<vpRGBa> &I) ;
228  void displayImage(const vpImage<unsigned char> &I) ;
229  void displayImage(const unsigned char *I) ;
230 
231  void displayImageROI(const vpImage<unsigned char> &I,const vpImagePoint &iP, const unsigned int width, const unsigned int height);
232  void displayImageROI(const vpImage<vpRGBa> &I,const vpImagePoint &iP, const unsigned int width, const unsigned int height);
233 
234  void displayLine(const vpImagePoint &ip1,
235  const vpImagePoint &ip2,
236  const vpColor &color, unsigned int thickness=1) ;
237  void displayPoint(const vpImagePoint &ip, const vpColor &color) ;
238 
239  void displayRectangle(const vpImagePoint &topLeft,
240  unsigned int width, unsigned int height,
241  const vpColor &color, bool fill = false,
242  unsigned int thickness=1) ;
243  void displayRectangle(const vpImagePoint &topLeft,
244  const vpImagePoint &bottomRight,
245  const vpColor &color, bool fill = false,
246  unsigned int thickness=1) ;
247  void displayRectangle(const vpRect &rectangle,
248  const vpColor &color, bool fill = false,
249  unsigned int thickness=1) ;
250 
251  void flushDisplay() ;
252  void flushDisplayROI(const vpImagePoint &iP, const unsigned int width, const unsigned int height);
253 
254  bool getClick(bool blocking=true) ;
255  bool getClick(vpImagePoint &ip, bool blocking=true);
256  bool getClick(vpImagePoint &ip,
258  bool blocking=true) ;
259  bool getClickUp(vpImagePoint &ip,
261  bool blocking=true);
262 
263  bool getKeyboardEvent(bool blocking=true);
264  bool getKeyboardEvent(char *string, bool blocking=true);
266  bool getPointerPosition (vpImagePoint &ip);
267 
268  inline unsigned int getWidth() const { return width ; }
269  inline unsigned int getHeight() const { return height ; }
270 } ;
271 
272 
273 #endif
274 #endif
virtual void displayCircle(const vpImagePoint &center, unsigned int radius, const vpColor &color, bool fill=false, unsigned int thickness=1)=0
virtual void displayImage(const vpImage< unsigned char > &I)=0
virtual void init(vpImage< unsigned char > &I, int x=-1, int y=-1, const char *title=NULL)=0
Class that defines generic functionnalities for display.
Definition: vpDisplay.h:176
virtual void displayArrow(const vpImagePoint &ip1, const vpImagePoint &ip2, const vpColor &color=vpColor::white, unsigned int w=4, unsigned int h=2, unsigned int thickness=1)=0
unsigned int width
Definition: vpDisplay.h:185
Class to define colors available for display functionnalities.
Definition: vpColor.h:125
virtual void clearDisplay(const vpColor &color=vpColor::white)=0
Define the X11 console to display images.
Definition: vpDisplayX.h:152
virtual bool getClickUp(vpImagePoint &ip, vpMouseButton::vpMouseButtonType &button, bool blocking=true)=0
virtual bool getPointerMotionEvent(vpImagePoint &ip)=0
static const vpColor green
Definition: vpColor.h:170
unsigned int getHeight() const
Definition: vpDisplayX.h:269
virtual void flushDisplay()=0
virtual bool getPointerPosition(vpImagePoint &ip)=0
virtual bool getKeyboardEvent(bool blocking=true)=0
virtual void setWindowPosition(int winx, int winy)=0
static void display(const vpImage< unsigned char > &I)
Definition: vpDisplay.cpp:206
unsigned int height
Definition: vpDisplay.h:186
virtual void displayCross(const vpImagePoint &ip, unsigned int size, const vpColor &color, unsigned int thickness=1)=0
virtual void displayImageROI(const vpImage< unsigned char > &I, const vpImagePoint &iP, const unsigned int width, const unsigned int height)=0
virtual void setTitle(const char *title)=0
virtual void setFont(const char *font)=0
virtual void displayRectangle(const vpImagePoint &topLeft, unsigned int width, unsigned int height, const vpColor &color, bool fill=false, unsigned int thickness=1)=0
static void getImage(const vpImage< unsigned char > &Is, vpImage< vpRGBa > &Id)
Definition: vpDisplay.cpp:324
virtual void displayDotLine(const vpImagePoint &ip1, const vpImagePoint &ip2, const vpColor &color, unsigned int thickness=1)=0
virtual void closeDisplay()=0
virtual void displayCharString(const vpImagePoint &ip, const char *text, const vpColor &color=vpColor::green)=0
unsigned int getWidth() const
Definition: vpDisplayX.h:268
Defines a rectangle in the plane.
Definition: vpRect.h:85
virtual bool getClick(bool blocking=true)=0
Class that defines a 2D point in an image. This class is useful for image processing and stores only ...
Definition: vpImagePoint.h:92
virtual void displayLine(const vpImagePoint &ip1, const vpImagePoint &ip2, const vpColor &color, unsigned int thickness=1)=0
virtual void flushDisplayROI(const vpImagePoint &iP, const unsigned int width, const unsigned int height)=0
static const vpColor white
Definition: vpColor.h:162
virtual void displayPoint(const vpImagePoint &ip, const vpColor &color)=0