Visual Servoing Platform  version 3.0.1
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
vpDisplayGTK.h
1 /****************************************************************************
2  *
3  * This file is part of the ViSP software.
4  * Copyright (C) 2005 - 2017 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 
138 class VISP_EXPORT vpDisplayGTK: public vpDisplay
139 {
140 private:
142  GtkWidget *widget;
143  GdkPixmap *m_background;
144  GdkGC *m_gc;
145  GdkColor blue,red,yellow,green,cyan,orange,white, black, gdkcolor,
146  lightBlue, darkBlue, lightRed, darkRed,lightGreen, darkGreen,
147  purple, lightGray, gray, darkGray;
148  GdkColormap *colormap;
149 
150  GdkFont *font;
151  guchar *vectgtk;
152  GdkColor **col ;
153  int ncol, nrow ;
154 
155  typedef enum {
156  id_black=0,
157  id_white,
158  id_lightGray,
159  id_gray,
160  id_darkGray,
161  id_lightRed,
162  id_red,
163  id_darkRed,
164  id_lightGreen,
165  id_green,
166  id_darkGreen,
167  id_lightBlue,
168  id_blue,
169  id_darkBlue,
170  id_yellow,
171  id_cyan,
172  id_orange,
173  id_purple,
174  id_npredefined // Number of predefined colors
175  } vpColorIdentifier;
176 
177 public:
178  vpDisplayGTK() ;
179  vpDisplayGTK(int winx, int winy, const std::string &title="");
181  vpDisplayGTK(vpImage<unsigned char> &I, int winx=-1, int winy=-1, const std::string &title="", vpScaleType type=SCALE_DEFAULT) ;
183  vpDisplayGTK(vpImage<vpRGBa> &I, int winx=-1, int winy=-1, const std::string &title="", vpScaleType type=SCALE_DEFAULT) ;
184 
185  virtual ~vpDisplayGTK() ;
186 
187  void getImage(vpImage<vpRGBa> &I) ;
188  unsigned int getScreenDepth();
189  unsigned int getScreenHeight();
190  void getScreenSize(unsigned int &width, unsigned int &height);
191  unsigned int getScreenWidth();
192 
193  void init(vpImage<unsigned char> &I, int winx=-1, int winy=-1, const std::string &title="");
194  void init(vpImage<vpRGBa> &I, int winx=-1, int winy=-1, const std::string &title="");
195  void init(unsigned int width, unsigned int height, int winx=-1, int winy=-1, const std::string &title="");
196 
197 protected:
198 
199  void setFont(const std::string &fontname );
200  void setTitle(const std::string &title) ;
201  void setWindowPosition(int winx, int winy);
202 
203  void clearDisplay(const vpColor &color=vpColor::white) ;
204 
205  void closeDisplay() ;
206 
207  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) ;
208  void displayCharString(const vpImagePoint &ip, const char *text, const vpColor &color=vpColor::green) ;
209 
210  void displayCircle(const vpImagePoint &center, unsigned int radius, const vpColor &color, bool fill = false, unsigned int thickness=1);
211  void displayCross(const vpImagePoint &ip, unsigned int size, const vpColor &color, unsigned int thickness=1) ;
212  void displayDotLine(const vpImagePoint &ip1, const vpImagePoint &ip2, const vpColor &color, unsigned int thickness=1) ;
213 
214  void displayImage(const vpImage<vpRGBa> &I) ;
215  void displayImage(const vpImage<unsigned char> &I) ;
216  void displayImage(const unsigned char *I) ;
217 
218  void displayImageROI(const vpImage<unsigned char> &I,const vpImagePoint &iP, const unsigned int width, const unsigned int height);
219  void displayImageROI(const vpImage<vpRGBa> &I,const vpImagePoint &iP, const unsigned int width, const unsigned int height);
220 
221  void displayLine(const vpImagePoint &ip1, const vpImagePoint &ip2, const vpColor &color, unsigned int thickness=1) ;
222 
223  void displayPoint(const vpImagePoint &ip, const vpColor &color, unsigned int thickness=1) ;
224  void displayRectangle(const vpImagePoint &topLeft, unsigned int width, unsigned int height, const vpColor &color, bool fill = false, unsigned int thickness=1) ;
225  void displayRectangle(const vpImagePoint &topLeft, const vpImagePoint &bottomRight, const vpColor &color, bool fill = false, unsigned int thickness=1) ;
226  void displayRectangle(const vpRect &rectangle, const vpColor &color, bool fill = false, unsigned int thickness=1) ;
227 
228  void flushDisplay() ;
229  void flushDisplayROI(const vpImagePoint &iP, const unsigned int width, const unsigned int height) ;
230 
231  bool getClick(bool blocking=true) ;
232  bool getClick(vpImagePoint &ip, bool blocking=true) ;
233  bool getClick(vpImagePoint &ip, vpMouseButton::vpMouseButtonType& button, bool blocking=true) ;
234  bool getClickUp(vpImagePoint &ip, vpMouseButton::vpMouseButtonType& button, bool blocking=true) ;
235  bool getKeyboardEvent(bool blocking=true);
236  bool getKeyboardEvent(std::string &key, bool blocking=true);
238  bool getPointerPosition (vpImagePoint &ip);
239 } ;
240 
241 #endif
242 #endif
243 
244 /*
245  * Local variables:
246  * c-basic-offset: 2
247  * End:
248  */
Class that defines generic functionnalities for display.
Definition: vpDisplay.h:169
static bool getPointerPosition(const vpImage< unsigned char > &I, vpImagePoint &ip)
static bool getClick(const vpImage< unsigned char > &I, bool blocking=true)
static bool getPointerMotionEvent(const vpImage< unsigned char > &I, vpImagePoint &ip)
Class to define colors available for display functionnalities.
Definition: vpColor.h:121
static bool getClickUp(const vpImage< unsigned char > &I, vpImagePoint &ip, vpMouseButton::vpMouseButtonType &button, bool blocking=true)
static void displayPoint(const vpImage< unsigned char > &I, const vpImagePoint &ip, const vpColor &color, unsigned int thickness=1)
static const vpColor green
Definition: vpColor.h:166
static void setFont(const vpImage< unsigned char > &I, const std::string &font)
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)
The vpDisplayGTK allows to display image using the GTK 3rd party library. Thus to enable this class G...
Definition: vpDisplayGTK.h:138
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 getImage(const vpImage< unsigned char > &Is, vpImage< vpRGBa > &Id)
Definition: vpDisplay.cpp:155
static void displayCircle(const vpImage< unsigned char > &I, const vpImagePoint &center, unsigned int radius, const vpColor &color, bool fill=false, unsigned int thickness=1)
static void displayCross(const vpImage< unsigned char > &I, const vpImagePoint &ip, unsigned int size, const vpColor &color, unsigned int thickness=1)
static void setWindowPosition(const vpImage< unsigned char > &I, int winx, int winy)
vpScaleType
Values that could be applied to a display to down scale the size of the display.
Definition: vpDisplay.h:173
Defines a rectangle in the plane.
Definition: vpRect.h:82
Class that defines a 2D point in an image. This class is useful for image processing and stores only ...
Definition: vpImagePoint.h:88
static void displayLine(const vpImage< unsigned char > &I, const vpImagePoint &ip1, const vpImagePoint &ip2, const vpColor &color, unsigned int thickness=1)
static bool getKeyboardEvent(const vpImage< unsigned char > &I, bool blocking=true)
static void displayCharString(const vpImage< unsigned char > &I, const vpImagePoint &ip, const char *string, const vpColor &color)
static void setTitle(const vpImage< unsigned char > &I, const std::string &windowtitle)
static const vpColor white
Definition: vpColor.h:158
static void displayDotLine(const vpImage< unsigned char > &I, const vpImagePoint &ip1, const vpImagePoint &ip2, const vpColor &color, unsigned int thickness=1)