ViSP  2.8.0
vpDisplayWin32.h
1 /****************************************************************************
2  *
3  * $Id: vpDisplayWin32.h 4056 2013-01-05 13:04:42Z fspindle $
4  *
5  * This file is part of the ViSP software.
6  * Copyright (C) 2005 - 2013 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 <visp/vpImage.h>
50 #include <visp/vpDisplay.h>
51 #include <windows.h>
52 #include <visp/vpWin32Window.h>
53 #include <visp/vpWin32Renderer.h>
54 #include <visp/vpRect.h>
55 #include <visp/vpImagePoint.h>
56 
57 #ifndef DOXYGEN_SHOULD_SKIP_THIS
58 
61 struct threadParam
62 {
64  vpDisplayWin32 * vpDisp;
65 
67  int x;
68 
70  int y;
71 
73  unsigned int w;
74 
76  unsigned int h;
77 
79  char * title;
80 };
81 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
82 
95 class VISP_EXPORT vpDisplayWin32 : public vpDisplay
96 {
97  protected:
99  static const int MAX_INIT_DELAY;
100 
102  HANDLE hThread;
103 
105  DWORD threadId;
106 
108  bool iStatus;
109 
111  vpWin32Window window;
112 
114  RECT roi;
115 
117  friend void vpCreateWindow(threadParam * param);
118 
119  public:
120 
121  vpDisplayWin32(vpWin32Renderer * rend = NULL);
122 
124  int winx=-1, int winy=-1,
125  const char *title=NULL);
126 
128  int winx=-1, int winy=-1,
129  const char *title=NULL);
130 
131  virtual ~vpDisplayWin32();
132 
133  void setTitle(const char *windowtitle);
134  void setFont( const char *fontname );
135  void setWindowPosition(int winx, int winy);
136  void clearDisplay(const vpColor &color=vpColor::white);
137  void closeDisplay();
138  void displayImage(const vpImage<vpRGBa> &I);
139  void displayImage(const vpImage<unsigned char> &I);
140 
141  void displayImageROI(const vpImage<unsigned char> &I,const vpImagePoint &iP, const unsigned int width, const unsigned int height);
142  void displayImageROI(const vpImage<vpRGBa> &I,const vpImagePoint &iP, const unsigned int width, const unsigned int height);
143 
144  void flushDisplay();
145  void flushDisplayROI(const vpImagePoint &iP, const unsigned int width, const unsigned int height);
146 
148  int winx=-1, int winy=-1,
149  const char *title=NULL) ;
150 
151  void init(vpImage<vpRGBa> &I,
152  int winx=-1, int winy=-1,
153  const char *title=NULL) ;
154 
155  void init(unsigned int width, unsigned int height,
156  int winx=-1, int winy=-1 ,
157  const char *title=NULL) ;
158 
159  void getImage(vpImage<vpRGBa> &I);
160 
161  protected:
162 
163  void displayArrow(const vpImagePoint &ip1,
164  const vpImagePoint &ip2,
165  const vpColor &color=vpColor::white,
166  unsigned int w=4,unsigned int h=2,
167  unsigned int thickness=1) ;
168 
169  void displayCharString(const vpImagePoint &ip, const char *text,
170  const vpColor &color=vpColor::green) ;
171 
172  void displayCircle(const vpImagePoint &center, unsigned int radius,
173  const vpColor &color,
174  bool fill = false,
175  unsigned int thickness=1);
176 
177  void displayCross(const vpImagePoint &ip, unsigned int size,
178  const vpColor &color, unsigned int thickness=1) ;
179 
180  void displayDotLine(const vpImagePoint &ip1,
181  const vpImagePoint &ip2,
182  const vpColor &color, unsigned int thickness=1) ;
183 
184  void displayLine(const vpImagePoint &ip1,
185  const vpImagePoint &ip2,
186  const vpColor &color, unsigned int thickness=1);
187 
188 
189  void displayPoint(const vpImagePoint &ip, const vpColor &color);
190 
191  void displayRectangle(const vpImagePoint &topLeft,
192  unsigned int width, unsigned int height,
193  const vpColor &color, bool fill = false,
194  unsigned int thickness=1);
195  void displayRectangle(const vpImagePoint &topLeft,
196  const vpImagePoint &bottomRight,
197  const vpColor &color, bool fill = false,
198  unsigned int thickness=1) ;
199  void displayRectangle(const vpRect &rectangle,
200  const vpColor &color, bool fill = false,
201  unsigned int thickness=1) ;
202 
203  bool getClick( bool blocking=true);
204 
205  bool getClick(vpImagePoint &ip, bool blocking=true);
206 
207  bool getClick(vpImagePoint &ip,
208  vpMouseButton::vpMouseButtonType& button, bool blocking=true);
209 
210  bool getClickUp(vpImagePoint &ip,
212  bool blocking=true);
213  bool getKeyboardEvent( bool blocking=true);
214  bool getKeyboardEvent(char *string, bool blocking);
216  bool getPointerPosition (vpImagePoint &ip);
217 
218  void waitForInit();
219 
220 };
221 #endif
222 #endif
223 
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:175
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:321
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: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
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