ViSP  2.6.2
vpDisplayGTK.h
1 /****************************************************************************
2  *
3  * $Id: vpDisplayGTK.h 3590 2012-03-05 09:48:31Z ayol $
4  *
5  * This file is part of the ViSP software.
6  * Copyright (C) 2005 - 2012 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 *Police1,*Police2;
158  guchar *vectgtk;
159  int windowXPosition ; int windowYPosition ;
160  GdkColor **col ;
161  int ncol, nrow ;
162 
163  typedef enum {
164  id_black=0,
165  id_white,
166  id_lightGray,
167  id_gray,
168  id_darkGray,
169  id_lightRed,
170  id_red,
171  id_darkRed,
172  id_lightGreen,
173  id_green,
174  id_darkGreen,
175  id_lightBlue,
176  id_blue,
177  id_darkBlue,
178  id_yellow,
179  id_cyan,
180  id_orange,
181  id_purple,
182  id_npredefined // Number of predefined colors
183  } vpColorIdentifier;
184 
185 public:
186  vpDisplayGTK() ;
187  vpDisplayGTK(int winx, int winy, const char *title=NULL) ;
188  vpDisplayGTK(vpImage<unsigned char> &I, int winx=-1, int winy=-1,
189  const char *title=NULL) ;
190  vpDisplayGTK(vpImage<vpRGBa> &I, int winx=-1, int winy=-1,
191  const char *title=NULL) ;
192 
193  virtual ~vpDisplayGTK() ;
194 
196  int winx=-1, int winy=-1,
197  const char *title=NULL) ;
198  void init(vpImage<vpRGBa> &I,
199  int winx=-1, int winy=-1,
200  const char *title=NULL) ;
201 
202  void init(unsigned int width, unsigned int height,
203  int winx=-1, int winy=-1 ,
204  const char *title=NULL) ;
205 
206  unsigned int getScreenDepth();
207  void getScreenSize(unsigned int &width, unsigned int &height);
208  void getImage(vpImage<vpRGBa> &I) ;
209 
210 protected:
211 
212  void setFont( const char *font );
213  void setTitle(const char *title) ;
214  void setWindowPosition(int winx, int winy);
215 
216  void clearDisplay(const vpColor &color=vpColor::white) ;
217 
218  void closeDisplay() ;
219 
220  void displayArrow(const vpImagePoint &ip1,
221  const vpImagePoint &ip2,
222  const vpColor &color=vpColor::white,
223  unsigned int w=4,unsigned int h=2,
224  unsigned int thickness=1) ;
225  void displayCharString(const vpImagePoint &ip, const char *text,
226  const vpColor &color=vpColor::green) ;
227 
228  void displayCircle(const vpImagePoint &center, unsigned int radius,
229  const vpColor &color,
230  bool fill = false,
231  unsigned int thickness=1);
232  void displayCross(const vpImagePoint &ip, unsigned int size,
233  const vpColor &color, unsigned int thickness=1) ;
234  void displayDotLine(const vpImagePoint &ip1,
235  const vpImagePoint &ip2,
236  const vpColor &color, unsigned int thickness=1) ;
237 
238  void displayImage(const vpImage<vpRGBa> &I) ;
239  void displayImage(const vpImage<unsigned char> &I) ;
240  void displayImage(const unsigned char *I) ;
241 
242  void displayImageROI(const vpImage<unsigned char> &I,const vpImagePoint &iP, const unsigned int width, const unsigned int height);
243  void displayImageROI(const vpImage<vpRGBa> &I,const vpImagePoint &iP, const unsigned int width, const unsigned int height);
244 
245  void displayLine(const vpImagePoint &ip1,
246  const vpImagePoint &ip2,
247  const vpColor &color, unsigned int thickness=1) ;
248 
249  void displayPoint(const vpImagePoint &ip, const vpColor &color) ;
250  void displayRectangle(const vpImagePoint &topLeft,
251  unsigned int width, unsigned int height,
252  const vpColor &color, bool fill = false,
253  unsigned int thickness=1) ;
254  void displayRectangle(const vpImagePoint &topLeft,
255  const vpImagePoint &bottomRight,
256  const vpColor &color, bool fill = false,
257  unsigned int thickness=1) ;
258  void displayRectangle(const vpRect &rectangle,
259  const vpColor &color, bool fill = false,
260  unsigned int thickness=1) ;
261 
262  void flushDisplay() ;
263  void flushDisplayROI(const vpImagePoint &iP, const unsigned int width, const unsigned int height) ;
264 
265  bool getClick(bool blocking=true) ;
266  bool getClick(vpImagePoint &ip, bool blocking=true) ;
267  bool getClick(vpImagePoint &ip,
269  bool blocking=true) ;
270  bool getClickUp(vpImagePoint &ip,
272  bool blocking=true) ;
273  bool getKeyboardEvent(bool blocking=true);
274  bool getKeyboardEvent(char *string, bool blocking=true);
276  bool getPointerPosition (vpImagePoint &ip);
277 
278  inline unsigned int getWidth() const { return width ; }
279  inline unsigned int getHeight() const { return height ; }
280 } ;
281 
282 #endif
283 #endif
284 
285 /*
286  * Local variables:
287  * c-basic-offset: 2
288  * End:
289  */
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:167
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:179
unsigned int getWidth() const
Definition: vpDisplayGTK.h:278
Class to define colors available for display functionnalities.
Definition: vpColor.h:123
unsigned int getHeight() const
Definition: vpDisplayGTK.h:279
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:168
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:180
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:300
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
int windowXPosition
display position
Definition: vpDisplay.h:173
Defines a rectangle in the plane.
Definition: vpRect.h:82
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
int windowYPosition
display position
Definition: vpDisplay.h:175
static const vpColor white
Definition: vpColor.h:160
virtual void displayPoint(const vpImagePoint &ip, const vpColor &color)=0