ViSP  2.10.0
vpDisplayWin32.h
1 /****************************************************************************
2  *
3  * $Id: vpDisplayWin32.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  * Windows 32 display base class
36  *
37  * Authors:
38  * Bruno Renier
39  *
40  *****************************************************************************/
41 
42 #include <visp/vpConfig.h>
43 
44 #if ( defined(VISP_HAVE_GDI) || defined(VISP_HAVE_D3D9) )
45 
46 #ifndef vpDisplayWin32_hh
47 #define vpDisplayWin32_hh
48 
49 #include <string>
50 
51 #include <visp/vpImage.h>
52 #include <visp/vpDisplay.h>
53 #include <windows.h>
54 #include <visp/vpWin32Window.h>
55 #include <visp/vpWin32Renderer.h>
56 #include <visp/vpRect.h>
57 #include <visp/vpImagePoint.h>
58 
59 #ifndef DOXYGEN_SHOULD_SKIP_THIS
60 
63 struct threadParam
64 {
66  vpDisplayWin32 * vpDisp;
67 
69  int x;
70 
72  int y;
73 
75  unsigned int w;
76 
78  unsigned int h;
79 
81  std::string title;
82 };
83 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
84 
97 class VISP_EXPORT vpDisplayWin32 : public vpDisplay
98 {
99  protected:
101  static const int MAX_INIT_DELAY;
102 
104  HANDLE hThread;
105 
107  DWORD threadId;
108 
110  bool iStatus;
111 
113  vpWin32Window window;
114 
116  RECT roi;
117 
119  friend void vpCreateWindow(threadParam * param);
120 
121  public:
122 
123  vpDisplayWin32(vpWin32Renderer * rend = NULL);
124 
126  int winx=-1, int winy=-1,
127  const char *title=NULL);
128 
130  int winx=-1, int winy=-1,
131  const char *title=NULL);
132 
133  virtual ~vpDisplayWin32();
134 
135  void setTitle(const char *windowtitle);
136  void setFont( const char *fontname );
137  void setWindowPosition(int winx, int winy);
138  void clearDisplay(const vpColor &color=vpColor::white);
139  void closeDisplay();
140  void displayImage(const vpImage<vpRGBa> &I);
141  void displayImage(const vpImage<unsigned char> &I);
142 
143  void displayImageROI(const vpImage<unsigned char> &I,const vpImagePoint &iP, const unsigned int width, const unsigned int height);
144  void displayImageROI(const vpImage<vpRGBa> &I,const vpImagePoint &iP, const unsigned int width, const unsigned int height);
145 
146  void flushDisplay();
147  void flushDisplayROI(const vpImagePoint &iP, const unsigned int width, const unsigned int height);
148 
150  int winx=-1, int winy=-1,
151  const char *title=NULL) ;
152 
153  void init(vpImage<vpRGBa> &I,
154  int winx=-1, int winy=-1,
155  const char *title=NULL) ;
156 
157  void init(unsigned int width, unsigned int height,
158  int winx=-1, int winy=-1 ,
159  const char *title=NULL) ;
160 
161  void getImage(vpImage<vpRGBa> &I);
162 
163  protected:
164 
165  void displayArrow(const vpImagePoint &ip1,
166  const vpImagePoint &ip2,
167  const vpColor &color=vpColor::white,
168  unsigned int w=4,unsigned int h=2,
169  unsigned int thickness=1) ;
170 
171  void displayCharString(const vpImagePoint &ip, const char *text,
172  const vpColor &color=vpColor::green) ;
173 
174  void displayCircle(const vpImagePoint &center, unsigned int radius,
175  const vpColor &color,
176  bool fill = false,
177  unsigned int thickness=1);
178 
179  void displayCross(const vpImagePoint &ip, unsigned int size,
180  const vpColor &color, unsigned int thickness=1) ;
181 
182  void displayDotLine(const vpImagePoint &ip1,
183  const vpImagePoint &ip2,
184  const vpColor &color, unsigned int thickness=1) ;
185 
186  void displayLine(const vpImagePoint &ip1,
187  const vpImagePoint &ip2,
188  const vpColor &color, unsigned int thickness=1);
189 
190 
191  void displayPoint(const vpImagePoint &ip, const vpColor &color);
192 
193  void displayRectangle(const vpImagePoint &topLeft,
194  unsigned int width, unsigned int height,
195  const vpColor &color, bool fill = false,
196  unsigned int thickness=1);
197  void displayRectangle(const vpImagePoint &topLeft,
198  const vpImagePoint &bottomRight,
199  const vpColor &color, bool fill = false,
200  unsigned int thickness=1) ;
201  void displayRectangle(const vpRect &rectangle,
202  const vpColor &color, bool fill = false,
203  unsigned int thickness=1) ;
204 
205  bool getClick( bool blocking=true);
206 
207  bool getClick(vpImagePoint &ip, bool blocking=true);
208 
209  bool getClick(vpImagePoint &ip,
210  vpMouseButton::vpMouseButtonType& button, bool blocking=true);
211 
212  bool getClickUp(vpImagePoint &ip,
214  bool blocking=true);
215  bool getKeyboardEvent( bool blocking=true);
216  bool getKeyboardEvent(char *string, bool blocking);
218  bool getPointerPosition (vpImagePoint &ip);
219 
220  void waitForInit();
221 
222 };
223 #endif
224 #endif
225 
virtual void displayCircle(const vpImagePoint &center, unsigned int radius, const vpColor &color, bool fill=false, unsigned int thickness=1)=0
static const int MAX_INIT_DELAY
Maximum delay for window initialization.
DWORD threadId
Id of the window's thread.
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:174
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
Class to define colors available for display functionnalities.
Definition: vpColor.h:125
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
bool iStatus
Initialization status.
static const vpColor green
Definition: vpColor.h:170
vpWin32Window window
The window.
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
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:328
virtual void displayDotLine(const vpImagePoint &ip1, const vpImagePoint &ip2, const vpColor &color, unsigned int thickness=1)=0
HANDLE hThread
Handle of the window's thread.
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:93
virtual void displayLine(const vpImagePoint &ip1, const vpImagePoint &ip2, const vpColor &color, unsigned int thickness=1)=0
Base abstract class for Windows 32 displays. Implements the window creation in a separate thread and ...
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