42 #include <visp/vpConfig.h>
43 #if ( defined(VISP_HAVE_GDI) || defined(VISP_HAVE_D3D9) )
46 #include <visp/vpDisplayWin32.h>
47 #include <visp/vpDisplayException.h>
58 void vpCreateWindow(threadParam * param)
61 (param->vpDisp)->window.initWindow(param->title.c_str(), param->x, param->y,
70 iStatus(false), window(rend)
103 "Image not initialized")) ;
106 window.renderer->setImg(I);
130 "Image not initialized")) ;
133 window.renderer->setImg(I);
153 title_ = std::string(title);
155 title_ = std::string(
" ");
163 threadParam * param =
new threadParam;
168 param->vpDisp =
this;
169 param->title = this->
title_;
189 if(!
window.isInitialized())
194 "Window not initialized")) ;
217 window.renderer->setImg(I);
246 window.renderer->setImgROI(I,iP,width,height);
269 window.renderer->setImg(I);
297 window.renderer->setImgROI(I,iP,width,height);
328 WaitForSingleObject(
window.semaClick, 0);
329 WaitForSingleObject(
window.semaClickUp, 0);
330 WaitForSingleObject(
window.semaClick, INFINITE);
334 ret = (WAIT_OBJECT_0 == WaitForSingleObject(
window.semaClick, 0));
368 WaitForSingleObject(
window.semaClick, 0);
369 WaitForSingleObject(
window.semaClickUp, 0);
370 WaitForSingleObject(
window.semaClick, INFINITE);
374 ret = (WAIT_OBJECT_0 == WaitForSingleObject(
window.semaClick, 0));
416 WaitForSingleObject(
window.semaClick, 0);
417 WaitForSingleObject(
window.semaClickUp, 0);
418 WaitForSingleObject(
window.semaClick, INFINITE);
422 ret = (WAIT_OBJECT_0 == WaitForSingleObject(
window.semaClick, 0));
428 button =
window.clickButton;
469 WaitForSingleObject(
window.semaClickUp, 0);
470 WaitForSingleObject(
window.semaClick, 0);
471 WaitForSingleObject(
window.semaClickUp, INFINITE);
475 ret = (WAIT_OBJECT_0 == WaitForSingleObject(
window.semaClickUp, 0));
481 button =
window.clickButtonUp;
509 WaitForSingleObject(
window.semaKey, 0);
510 WaitForSingleObject(
window.semaKey, 0);
511 WaitForSingleObject(
window.semaKey, INFINITE);
515 ret = (WAIT_OBJECT_0 == WaitForSingleObject(
window.semaKey, 0));
546 WaitForSingleObject(
window.semaKey, 0);
547 WaitForSingleObject(
window.semaKey, 0);
548 WaitForSingleObject(
window.semaKey, INFINITE);
552 ret = (WAIT_OBJECT_0 == WaitForSingleObject(
window.semaKey, 0));
555 sprintf(
string,
"%s",
window.lpString);
577 ret = (WAIT_OBJECT_0 == WaitForSingleObject(
window.semaMove, 0));
635 SetWindowPos(
window.hWnd,HWND_TOP, winx, winy, 0, 0,
636 SWP_ASYNCWINDOWPOS | SWP_NOACTIVATE | SWP_NOZORDER |SWP_NOSIZE);
650 SetWindowText(
window.hWnd, windowtitle);
676 PostMessage(
window.getHWnd(), vpWM_DISPLAY, 0,0);
695 typedef struct _half_rect_t{
696 unsigned short left_top;
697 unsigned short right_bottom;
703 hr1.left_top = (
unsigned short)iP.
get_u();
704 hr1.right_bottom = (
unsigned short)(iP.
get_u()+width-1);
706 hr2.left_top = (
unsigned short)iP.
get_v();
707 hr2.right_bottom = (
unsigned short)(iP.
get_v()+height-1);
710 # if 1 // new version FS
711 WPARAM wp = (WPARAM)(hr1.left_top <<
sizeof(
unsigned short)) + hr1.right_bottom;
712 LPARAM lp = (hr2.left_top <<
sizeof(
unsigned short)) + hr2.right_bottom;
714 WPARAM wp=*((WPARAM*)(&hr1));
715 LPARAM lp=*((WPARAM*)(&hr2));
717 PostMessage(
window.getHWnd(), vpWM_DISPLAY_ROI, wp,lp);
719 PostMessage(
window.getHWnd(), vpWM_DISPLAY, 0,0);
734 window.renderer->setPixel(ip, color);
746 unsigned int thickness )
750 window.renderer->drawLine(ip1, ip2, color, thickness);
766 unsigned int thickness )
770 window.renderer->drawLine(ip1,ip2,color,thickness,PS_DASHDOT);
787 unsigned int width,
unsigned int height,
788 const vpColor &color,
bool fill,
789 unsigned int thickness )
793 window.renderer->drawRect(topLeft,width,height,color, fill, thickness);
811 const vpColor &color,
bool fill,
812 unsigned int thickness )
816 unsigned int width =
static_cast<unsigned int>( bottomRight.
get_j() - topLeft.
get_j() );
817 unsigned int height =
static_cast<unsigned int>(bottomRight.
get_i() - topLeft.
get_i() );
818 window.renderer->drawRect(topLeft,width,height,color, fill, thickness);
833 const vpColor &color,
bool fill,
834 unsigned int thickness )
841 window.renderer->drawRect(topLeft,
842 static_cast<unsigned int>( rectangle.
getWidth() ),
843 static_cast<unsigned int>( rectangle.
getHeight() ),
844 color, fill, thickness);
861 unsigned int thickness )
865 window.renderer->drawCircle(center,radius,color,fill,thickness);
880 window.renderer->drawText(ip,text,color);
893 unsigned int thickness)
897 window.renderer->drawCross(ip, size, color, thickness);
911 unsigned int w,
unsigned int h,
912 unsigned int thickness)
917 window.renderer->drawArrow(ip1, ip2, color, w, h, thickness);
928 window.renderer->clear(color);
940 PostMessage(
window.getHWnd(), vpWM_CLOSEDISPLAY, 0,0);
945 WaitForSingleObject(
hThread, INFINITE);
949 window.initialized = false ;
961 window.renderer->getImage(I);
static const int MAX_INIT_DELAY
Maximum delay for window initialization.
DWORD threadId
Id of the window's thread.
void displayCharString(const vpImagePoint &ip, const char *text, const vpColor &color=vpColor::green)
void displayDotLine(const vpImagePoint &ip1, const vpImagePoint &ip2, const vpColor &color, unsigned int thickness=1)
void displayCircle(const vpImagePoint ¢er, unsigned int radius, const vpColor &color, bool fill=false, unsigned int thickness=1)
unsigned int getWidth() const
virtual ~vpDisplayWin32()
bool getClick(bool blocking=true)
Class to define colors available for display functionnalities.
void setFont(const char *fontname)
Set the font used to display text.
bool displayHasBeenInitialized
display has been initialized
void displayCross(const vpImagePoint &ip, unsigned int size, const vpColor &color, unsigned int thickness=1)
bool iStatus
Initialization status.
void displayLine(const vpImagePoint &ip1, const vpImagePoint &ip2, const vpColor &color, unsigned int thickness=1)
void displayImageROI(const vpImage< unsigned char > &I, const vpImagePoint &iP, const unsigned int width, const unsigned int height)
bool getKeyboardEvent(bool blocking=true)
vpDisplayWin32(vpWin32Renderer *rend=NULL)
vpWin32Window window
The window.
bool getClickUp(vpImagePoint &ip, vpMouseButton::vpMouseButtonType &button, bool blocking=true)
void set_i(const double ii)
void displayImage(const vpImage< vpRGBa > &I)
void set_u(const double u)
void set_v(const double v)
void setTitle(const char *windowtitle)
void displayRectangle(const vpImagePoint &topLeft, unsigned int width, unsigned int height, const vpColor &color, bool fill=false, unsigned int thickness=1)
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)
void init(vpImage< unsigned char > &I, int winx=-1, int winy=-1, const char *title=NULL)
void displayPoint(const vpImagePoint &ip, const vpColor &color)
friend void vpCreateWindow(threadParam *param)
Function used to launch the window in a thread.
void set_j(const double jj)
bool getPointerMotionEvent(vpImagePoint &ip)
Error that can be emited by the vpDisplay class and its derivates.
HANDLE hThread
Handle of the window's thread.
int windowXPosition
display position
unsigned int getHeight() const
Defines a rectangle in the plane.
void flushDisplayROI(const vpImagePoint &iP, const unsigned int width, const unsigned int height)
flush the Win32 buffer It's necessary to use this function to see the results of any drawing ...
Class that defines a 2D point in an image. This class is useful for image processing and stores only ...
void clearDisplay(const vpColor &color=vpColor::white)
void flushDisplay()
flush the Win32 buffer It's necessary to use this function to see the results of any drawing ...
int windowYPosition
display position
void setWindowPosition(int winx, int winy)
bool getPointerPosition(vpImagePoint &ip)
void getImage(vpImage< vpRGBa > &I)