39#include <visp3/core/vpConfig.h>
40#if (defined(VISP_HAVE_GDI) || defined(VISP_HAVE_D3D9))
43#include <visp3/core/vpDisplayException.h>
44#include <visp3/gui/vpDisplayWin32.h>
52void vpCreateWindow(threadParam *param)
55 (param->vpDisp)->window.initWindow(param->title.c_str(), param->x, param->y, param->w, param->h);
90 window.renderer->setImg(I);
114 window.renderer->setImg(I);
141 threadParam *param =
new threadParam;
146 param->vpDisp =
this;
165 if (!
window.isInitialized()) {
190 window.renderer->setImg(I);
219 window.renderer->setImgROI(I, iP, width, height);
241 window.renderer->setImg(I);
270 window.renderer->setImgROI(I, iP, width, height);
300 WaitForSingleObject(
window.semaClick, 0);
301 WaitForSingleObject(
window.semaClickUp, 0);
302 WaitForSingleObject(
window.semaClick, INFINITE);
305 ret = (WAIT_OBJECT_0 == WaitForSingleObject(
window.semaClick, 0));
338 WaitForSingleObject(
window.semaClick, 0);
339 WaitForSingleObject(
window.semaClickUp, 0);
340 WaitForSingleObject(
window.semaClick, INFINITE);
343 ret = (WAIT_OBJECT_0 == WaitForSingleObject(
window.semaClick, 0));
382 WaitForSingleObject(
window.semaClick, 0);
383 WaitForSingleObject(
window.semaClickUp, 0);
384 WaitForSingleObject(
window.semaClick, INFINITE);
387 ret = (WAIT_OBJECT_0 == WaitForSingleObject(
window.semaClick, 0));
393 button =
window.clickButton;
431 WaitForSingleObject(
window.semaClickUp, 0);
432 WaitForSingleObject(
window.semaClick, 0);
433 WaitForSingleObject(
window.semaClickUp, INFINITE);
436 ret = (WAIT_OBJECT_0 == WaitForSingleObject(
window.semaClickUp, 0));
442 button =
window.clickButtonUp;
470 WaitForSingleObject(
window.semaKey, 0);
471 WaitForSingleObject(
window.semaKey, 0);
472 WaitForSingleObject(
window.semaKey, INFINITE);
475 ret = (WAIT_OBJECT_0 == WaitForSingleObject(
window.semaKey, 0));
506 WaitForSingleObject(
window.semaKey, 0);
507 WaitForSingleObject(
window.semaKey, 0);
508 WaitForSingleObject(
window.semaKey, INFINITE);
511 ret = (WAIT_OBJECT_0 == WaitForSingleObject(
window.semaKey, 0));
514 std::stringstream ss;
535 bool ret = (WAIT_OBJECT_0 == WaitForSingleObject(
window.semaMove, 0));
591 SetWindowPos(
window.hWnd, HWND_TOP, winx, winy, 0, 0,
592 SWP_ASYNCWINDOWPOS | SWP_NOACTIVATE | SWP_NOZORDER | SWP_NOSIZE);
604 SetWindowText(
window.hWnd, windowtitle.c_str());
625 PostMessage(
window.getHWnd(), vpWM_DISPLAY, 0, 0);
642 WORD left = (WORD)iP.
get_u();
643 WORD right = (WORD)(iP.
get_u() + width - 1);
645 WORD top = (WORD)iP.
get_v();
646 WORD bottom = (WORD)(iP.
get_v() + height - 1);
649 WPARAM wp = MAKEWPARAM(left, right);
650 LPARAM lp = MAKELPARAM(top, bottom);
652 PostMessage(
window.getHWnd(), vpWM_DISPLAY_ROI, wp, lp);
665 if (thickness == 1) {
666 window.renderer->setPixel(ip, color);
679 unsigned int thickness)
683 window.renderer->drawLine(ip1, ip2, color, thickness);
696 unsigned int thickness)
700 window.renderer->drawLine(ip1, ip2, color, thickness, PS_DASHDOT);
717 const vpColor &color,
bool fill,
unsigned int thickness)
721 window.renderer->drawRect(topLeft, width, height, color, fill, thickness);
737 const vpColor &color,
bool fill,
unsigned int thickness)
741 unsigned int width =
static_cast<unsigned int>(bottomRight.
get_j() - topLeft.
get_j());
742 unsigned int height =
static_cast<unsigned int>(bottomRight.
get_i() - topLeft.
get_i());
743 window.renderer->drawRect(topLeft, width, height, color, fill, thickness);
764 window.renderer->drawRect(topLeft,
static_cast<unsigned int>(rectangle.
getWidth()),
765 static_cast<unsigned int>(rectangle.
getHeight()), color, fill, thickness);
778 unsigned int thickness)
782 window.renderer->drawCircle(center, radius, color, fill, thickness);
795 window.renderer->drawText(ip, text, color);
806 unsigned int thickness)
810 window.renderer->drawCross(ip, size, color, thickness);
821 unsigned int w,
unsigned int h,
unsigned int thickness)
826 window.renderer->drawArrow(ip1, ip2, color, w, h, thickness);
837 window.renderer->clear(color);
848 PostMessage(
window.getHWnd(), vpWM_CLOSEDISPLAY, 0, 0);
853 WaitForSingleObject(
hThread, INFINITE);
857 window.initialized =
false;
869 window.renderer->getImage(I);
878 w = GetSystemMetrics(SM_CXSCREEN);
879 h = GetSystemMetrics(SM_CYSCREEN);
887 unsigned int width, height;
897 unsigned int width, height;
901#elif !defined(VISP_BUILD_SHARED_LIBS)
904void dummy_vpDisplayWin32(){};
Class to define RGB colors available for display functionalities.
Error that can be emitted by the vpDisplay class and its derivatives.
@ notInitializedError
Display not initialized.
void displayRectangle(const vpImagePoint &topLeft, unsigned int width, unsigned int height, const vpColor &color, bool fill=false, unsigned int thickness=1)
void displayCircle(const vpImagePoint ¢er, unsigned int radius, const vpColor &color, bool fill=false, unsigned int thickness=1)
void init(vpImage< unsigned char > &I, int winx=-1, int winy=-1, const std::string &title="")
DWORD threadId
Id of the window's thread.
vpWin32Window window
The window.
void setFont(const std::string &fontname)
Set the font used to display text.
void getImage(vpImage< vpRGBa > &I)
vpDisplayWin32(vpWin32Renderer *rend=NULL)
unsigned int getScreenWidth()
bool getKeyboardEvent(bool blocking=true)
void clearDisplay(const vpColor &color=vpColor::white)
bool getClickUp(vpImagePoint &ip, vpMouseButton::vpMouseButtonType &button, bool blocking=true)
void displayDotLine(const vpImagePoint &ip1, const vpImagePoint &ip2, const vpColor &color, unsigned int thickness=1)
void setWindowPosition(int winx, int winy)
unsigned int getScreenHeight()
HANDLE hThread
Handle of the window's thread.
void displayCharString(const vpImagePoint &ip, const char *text, const vpColor &color=vpColor::green)
friend void vpCreateWindow(threadParam *param)
Function used to launch the window in a thread.
bool getPointerPosition(vpImagePoint &ip)
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)
bool iStatus
Initialization status.
void flushDisplayROI(const vpImagePoint &iP, unsigned int width, unsigned int height)
flush the Win32 buffer It's necessary to use this function to see the results of any drawing
void displayPoint(const vpImagePoint &ip, const vpColor &color, unsigned int thickness=1)
static const int MAX_INIT_DELAY
Maximum delay for window initialization.
bool getPointerMotionEvent(vpImagePoint &ip)
void displayImageROI(const vpImage< unsigned char > &I, const vpImagePoint &iP, unsigned int width, unsigned int height)
void displayLine(const vpImagePoint &ip1, const vpImagePoint &ip2, const vpColor &color, unsigned int thickness=1)
virtual ~vpDisplayWin32()
void getScreenSize(unsigned int &width, unsigned int &height)
void displayCross(const vpImagePoint &ip, unsigned int size, const vpColor &color, unsigned int thickness=1)
bool getClick(bool blocking=true)
void flushDisplay()
flush the Win32 buffer It's necessary to use this function to see the results of any drawing
void displayImage(const vpImage< vpRGBa > &I)
void setTitle(const std::string &windowtitle)
int m_windowXPosition
display position
int m_windowYPosition
display position
bool m_displayHasBeenInitialized
display has been initialized
void setScale(vpScaleType scaleType, unsigned int width, unsigned int height)
Class that defines a 2D point in an image. This class is useful for image processing and stores only ...
Definition of the vpImage class member functions.
unsigned int getWidth() const
unsigned int getHeight() const
Defines a rectangle in the plane.