ViSP  2.9.0
vpDisplayGTK.h
1 /****************************************************************************
2  *
3  * $Id: vpDisplayGTK.h 4604 2014-01-21 14:15:23Z 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  * Christophe Collewet
39  * Eric Marchand
40  *
41  *****************************************************************************/
42 
43 #ifndef vpDisplayGTK_h
44 #define vpDisplayGTK_h
45 
46 #include <visp/vpConfig.h>
47 #if ( defined(VISP_HAVE_GTK) )
48 
49 #include <visp/vpImage.h>
50 #include <visp/vpDisplay.h>
51 
52 #include <gtk/gtk.h>
53 #include <gdk/gdkrgb.h>
54 
55 
145 class VISP_EXPORT vpDisplayGTK: public vpDisplay
146 {
147 private:
149  GtkWidget *widget;
150  GdkPixmap *background;
151  GdkGC *gc;
152  GdkColor blue,red,yellow,green,cyan,orange,white, black, gdkcolor,
153  lightBlue, darkBlue, lightRed, darkRed,lightGreen, darkGreen,
154  purple, lightGray, gray, darkGray;
155  GdkColormap *colormap;
156 
157  GdkFont *font;
158  guchar *vectgtk;
159  GdkColor **col ;
160  int ncol, nrow ;
161 
162  typedef enum {
163  id_black=0,
164  id_white,
165  id_lightGray,
166  id_gray,
167  id_darkGray,
168  id_lightRed,
169  id_red,
170  id_darkRed,
171  id_lightGreen,
172  id_green,
173  id_darkGreen,
174  id_lightBlue,
175  id_blue,
176  id_darkBlue,
177  id_yellow,
178  id_cyan,
179  id_orange,
180  id_purple,
181  id_npredefined // Number of predefined colors
182  } vpColorIdentifier;
183 
184 public:
185  vpDisplayGTK() ;
186  vpDisplayGTK(int winx, int winy, const char *title=NULL) ;
187  vpDisplayGTK(vpImage<unsigned char> &I, int winx=-1, int winy=-1,
188  const char *title=NULL) ;
189  vpDisplayGTK(vpImage<vpRGBa> &I, int winx=-1, int winy=-1,
190  const char *title=NULL) ;
191 
192  virtual ~vpDisplayGTK() ;
193 
195  int winx=-1, int winy=-1,
196  const char *title=NULL) ;
197  void init(vpImage<vpRGBa> &I,
198  int winx=-1, int winy=-1,
199  const char *title=NULL) ;
200 
201  void init(unsigned int width, unsigned int height,
202  int winx=-1, int winy=-1 ,
203  const char *title=NULL) ;
204 
205  unsigned int getScreenDepth();
206  void getScreenSize(unsigned int &width, unsigned int &height);
207  void getImage(vpImage<vpRGBa> &I) ;
208 
209 protected:
210 
211  void setFont( const char *fontname );
212  void setTitle(const char *title) ;
213  void setWindowPosition(int winx, int winy);
214 
215  void clearDisplay(const vpColor &color=vpColor::white) ;
216 
217  void closeDisplay() ;
218 
219  void displayArrow(const vpImagePoint &ip1,
220  const vpImagePoint &ip2,
221  const vpColor &color=vpColor::white,
222  unsigned int w=4,unsigned int h=2,
223  unsigned int thickness=1) ;
224  void displayCharString(const vpImagePoint &ip, const char *text,
225  const vpColor &color=vpColor::green) ;
226 
227  void displayCircle(const vpImagePoint &center, unsigned int radius,
228  const vpColor &color,
229  bool fill = false,
230  unsigned int thickness=1);
231  void displayCross(const vpImagePoint &ip, unsigned int size,
232  const vpColor &color, unsigned int thickness=1) ;
233  void displayDotLine(const vpImagePoint &ip1,
234  const vpImagePoint &ip2,
235  const vpColor &color, unsigned int thickness=1) ;
236 
237  void displayImage(const vpImage<vpRGBa> &I) ;
238  void displayImage(const vpImage<unsigned char> &I) ;
239  void displayImage(const unsigned char *I) ;
240 
241  void displayImageROI(const vpImage<unsigned char> &I,const vpImagePoint &iP, const unsigned int width, const unsigned int height);
242  void displayImageROI(const vpImage<vpRGBa> &I,const vpImagePoint &iP, const unsigned int width, const unsigned int height);
243 
244  void displayLine(const vpImagePoint &ip1,
245  const vpImagePoint &ip2,
246  const vpColor &color, unsigned int thickness=1) ;
247 
248  void displayPoint(const vpImagePoint &ip, const vpColor &color) ;
249  void displayRectangle(const vpImagePoint &topLeft,
250  unsigned int width, unsigned int height,
251  const vpColor &color, bool fill = false,
252  unsigned int thickness=1) ;
253  void displayRectangle(const vpImagePoint &topLeft,
254  const vpImagePoint &bottomRight,
255  const vpColor &color, bool fill = false,
256  unsigned int thickness=1) ;
257  void displayRectangle(const vpRect &rectangle,
258  const vpColor &color, bool fill = false,
259  unsigned int thickness=1) ;
260 
261  void flushDisplay() ;
262  void flushDisplayROI(const vpImagePoint &iP, const unsigned int width, const unsigned int height) ;
263 
264  bool getClick(bool blocking=true) ;
265  bool getClick(vpImagePoint &ip, bool blocking=true) ;
266  bool getClick(vpImagePoint &ip,
268  bool blocking=true) ;
269  bool getClickUp(vpImagePoint &ip,
271  bool blocking=true) ;
272  bool getKeyboardEvent(bool blocking=true);
273  bool getKeyboardEvent(char *string, bool blocking=true);
275  bool getPointerPosition (vpImagePoint &ip);
276 
277  inline unsigned int getWidth() const { return width ; }
278  inline unsigned int getHeight() const { return height ; }
279 } ;
280 
281 #endif
282 #endif
283 
284 /*
285  * Local variables:
286  * c-basic-offset: 2
287  * End:
288  */
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
unsigned int getWidth() const
Definition: vpDisplayGTK.h:277
Class to define colors available for display functionnalities.
Definition: vpColor.h:125
unsigned int getHeight() const
Definition: vpDisplayGTK.h:278
virtual void clearDisplay(const vpColor &color=vpColor::white)=0
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
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
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
The vpDisplayGTK allows to display image using the GTK+ library version 1.2.
Definition: vpDisplayGTK.h:145
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
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