Visual Servoing Platform  version 3.0.0
vpDisplayGTK.h
1 /****************************************************************************
2  *
3  * This file is part of the ViSP software.
4  * Copyright (C) 2005 - 2015 by Inria. All rights reserved.
5  *
6  * This software is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * ("GPL") version 2 as published by the Free Software Foundation.
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 http://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  * Authors:
34  * Christophe Collewet
35  * Eric Marchand
36  *
37  *****************************************************************************/
38 
39 #ifndef vpDisplayGTK_h
40 #define vpDisplayGTK_h
41 
42 #include <visp3/core/vpConfig.h>
43 #if ( defined(VISP_HAVE_GTK) )
44 
45 #include <visp3/core/vpImage.h>
46 #include <visp3/core/vpDisplay.h>
47 
48 #include <gtk/gtk.h>
49 #include <gdk/gdkrgb.h>
50 
51 
141 class VISP_EXPORT vpDisplayGTK: public vpDisplay
142 {
143 private:
145  GtkWidget *widget;
146  GdkPixmap *background;
147  GdkGC *gc;
148  GdkColor blue,red,yellow,green,cyan,orange,white, black, gdkcolor,
149  lightBlue, darkBlue, lightRed, darkRed,lightGreen, darkGreen,
150  purple, lightGray, gray, darkGray;
151  GdkColormap *colormap;
152 
153  GdkFont *font;
154  guchar *vectgtk;
155  GdkColor **col ;
156  int ncol, nrow ;
157 
158  typedef enum {
159  id_black=0,
160  id_white,
161  id_lightGray,
162  id_gray,
163  id_darkGray,
164  id_lightRed,
165  id_red,
166  id_darkRed,
167  id_lightGreen,
168  id_green,
169  id_darkGreen,
170  id_lightBlue,
171  id_blue,
172  id_darkBlue,
173  id_yellow,
174  id_cyan,
175  id_orange,
176  id_purple,
177  id_npredefined // Number of predefined colors
178  } vpColorIdentifier;
179 
180 public:
181  vpDisplayGTK() ;
182  vpDisplayGTK(int winx, int winy, const char *title=NULL) ;
183  vpDisplayGTK(vpImage<unsigned char> &I, int winx=-1, int winy=-1,
184  const char *title=NULL) ;
185  vpDisplayGTK(vpImage<vpRGBa> &I, int winx=-1, int winy=-1,
186  const char *title=NULL) ;
187 
188  virtual ~vpDisplayGTK() ;
189 
191  int winx=-1, int winy=-1,
192  const char *title=NULL) ;
193  void init(vpImage<vpRGBa> &I,
194  int winx=-1, int winy=-1,
195  const char *title=NULL) ;
196 
197  void init(unsigned int width, unsigned int height,
198  int winx=-1, int winy=-1 ,
199  const char *title=NULL) ;
200 
201  unsigned int getScreenDepth();
202  void getScreenSize(unsigned int &width, unsigned int &height);
203  void getImage(vpImage<vpRGBa> &I) ;
204 
205 protected:
206 
207  void setFont( const char *fontname );
208  void setTitle(const char *title) ;
209  void setWindowPosition(int winx, int winy);
210 
211  void clearDisplay(const vpColor &color=vpColor::white) ;
212 
213  void closeDisplay() ;
214 
215  void displayArrow(const vpImagePoint &ip1,
216  const vpImagePoint &ip2,
217  const vpColor &color=vpColor::white,
218  unsigned int w=4,unsigned int h=2,
219  unsigned int thickness=1) ;
220  void displayCharString(const vpImagePoint &ip, const char *text,
221  const vpColor &color=vpColor::green) ;
222 
223  void displayCircle(const vpImagePoint &center, unsigned int radius,
224  const vpColor &color,
225  bool fill = false,
226  unsigned int thickness=1);
227  void displayCross(const vpImagePoint &ip, unsigned int size,
228  const vpColor &color, unsigned int thickness=1) ;
229  void displayDotLine(const vpImagePoint &ip1,
230  const vpImagePoint &ip2,
231  const vpColor &color, unsigned int thickness=1) ;
232 
233  void displayImage(const vpImage<vpRGBa> &I) ;
234  void displayImage(const vpImage<unsigned char> &I) ;
235  void displayImage(const unsigned char *I) ;
236 
237  void displayImageROI(const vpImage<unsigned char> &I,const vpImagePoint &iP, const unsigned int width, const unsigned int height);
238  void displayImageROI(const vpImage<vpRGBa> &I,const vpImagePoint &iP, const unsigned int width, const unsigned int height);
239 
240  void displayLine(const vpImagePoint &ip1,
241  const vpImagePoint &ip2,
242  const vpColor &color, unsigned int thickness=1) ;
243 
244  void displayPoint(const vpImagePoint &ip, const vpColor &color) ;
245  void displayRectangle(const vpImagePoint &topLeft,
246  unsigned int width, unsigned int height,
247  const vpColor &color, bool fill = false,
248  unsigned int thickness=1) ;
249  void displayRectangle(const vpImagePoint &topLeft,
250  const vpImagePoint &bottomRight,
251  const vpColor &color, bool fill = false,
252  unsigned int thickness=1) ;
253  void displayRectangle(const vpRect &rectangle,
254  const vpColor &color, bool fill = false,
255  unsigned int thickness=1) ;
256 
257  void flushDisplay() ;
258  void flushDisplayROI(const vpImagePoint &iP, const unsigned int width, const unsigned int height) ;
259 
260  bool getClick(bool blocking=true) ;
261  bool getClick(vpImagePoint &ip, bool blocking=true) ;
262  bool getClick(vpImagePoint &ip,
264  bool blocking=true) ;
265  bool getClickUp(vpImagePoint &ip,
267  bool blocking=true) ;
268  bool getKeyboardEvent(bool blocking=true);
269  bool getKeyboardEvent(char *string, bool blocking=true);
271  bool getPointerPosition (vpImagePoint &ip);
272 
273  inline unsigned int getWidth() const { return width ; }
274  inline unsigned int getHeight() const { return height ; }
275 } ;
276 
277 #endif
278 #endif
279 
280 /*
281  * Local variables:
282  * c-basic-offset: 2
283  * End:
284  */
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:170
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:273
Class to define colors available for display functionnalities.
Definition: vpColor.h:121
unsigned int getHeight() const
Definition: vpDisplayGTK.h:274
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:166
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:141
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:81
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:88
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:158
virtual void displayPoint(const vpImagePoint &ip, const vpColor &color)=0