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>
52 void vpCreateWindow(threadParam *param)
55 (param->vpDisp)->window.initWindow(param->title.c_str(), param->x, param->y, param->w, param->h);
65 : iStatus(false), window(nullptr)
67 init(I, winx, winy, title);
71 : iStatus(false), window(nullptr)
73 init(I, winx, winy, title);
104 window.renderer->setImg(I);
128 window.renderer->setImg(I);
155 threadParam *param =
new threadParam;
160 param->vpDisp =
this;
179 if (!
window.isInitialized()) {
204 window.renderer->setImg(I);
233 window.renderer->setImgROI(I, iP, width, height);
255 window.renderer->setImg(I);
284 window.renderer->setImgROI(I, iP, width, height);
314 WaitForSingleObject(
window.semaClick, 0);
315 WaitForSingleObject(
window.semaClickUp, 0);
316 WaitForSingleObject(
window.semaClick, INFINITE);
320 ret = (WAIT_OBJECT_0 == WaitForSingleObject(
window.semaClick, 0));
353 WaitForSingleObject(
window.semaClick, 0);
354 WaitForSingleObject(
window.semaClickUp, 0);
355 WaitForSingleObject(
window.semaClick, INFINITE);
359 ret = (WAIT_OBJECT_0 == WaitForSingleObject(
window.semaClick, 0));
398 WaitForSingleObject(
window.semaClick, 0);
399 WaitForSingleObject(
window.semaClickUp, 0);
400 WaitForSingleObject(
window.semaClick, INFINITE);
404 ret = (WAIT_OBJECT_0 == WaitForSingleObject(
window.semaClick, 0));
410 button =
window.clickButton;
448 WaitForSingleObject(
window.semaClickUp, 0);
449 WaitForSingleObject(
window.semaClick, 0);
450 WaitForSingleObject(
window.semaClickUp, INFINITE);
454 ret = (WAIT_OBJECT_0 == WaitForSingleObject(
window.semaClickUp, 0));
460 button =
window.clickButtonUp;
488 WaitForSingleObject(
window.semaKey, 0);
489 WaitForSingleObject(
window.semaKey, 0);
490 WaitForSingleObject(
window.semaKey, INFINITE);
494 ret = (WAIT_OBJECT_0 == WaitForSingleObject(
window.semaKey, 0));
525 WaitForSingleObject(
window.semaKey, 0);
526 WaitForSingleObject(
window.semaKey, 0);
527 WaitForSingleObject(
window.semaKey, INFINITE);
531 ret = (WAIT_OBJECT_0 == WaitForSingleObject(
window.semaKey, 0));
534 std::stringstream ss;
555 bool ret = (WAIT_OBJECT_0 == WaitForSingleObject(
window.semaMove, 0));
611 SetWindowPos(
window.hWnd, HWND_TOP, winx, winy, 0, 0,
612 SWP_ASYNCWINDOWPOS | SWP_NOACTIVATE | SWP_NOZORDER | SWP_NOSIZE);
624 SetWindowText(
window.hWnd, windowtitle.c_str());
645 PostMessage(
window.getHWnd(), vpWM_DISPLAY, 0, 0);
662 WORD left = (WORD)iP.
get_u();
663 WORD right = (WORD)(iP.
get_u() + width - 1);
665 WORD top = (WORD)iP.
get_v();
666 WORD bottom = (WORD)(iP.
get_v() + height - 1);
669 WPARAM wp = MAKEWPARAM(left, right);
670 LPARAM lp = MAKELPARAM(top, bottom);
672 PostMessage(
window.getHWnd(), vpWM_DISPLAY_ROI, wp, lp);
685 if (thickness == 1) {
686 window.renderer->setPixel(ip, color);
700 unsigned int thickness)
704 window.renderer->drawLine(ip1, ip2, color, thickness);
717 unsigned int thickness)
721 window.renderer->drawLine(ip1, ip2, color, thickness, PS_DASHDOT);
738 const vpColor &color,
bool fill,
unsigned int thickness)
742 window.renderer->drawRect(topLeft, width, height, color, fill, thickness);
758 const vpColor &color,
bool fill,
unsigned int thickness)
762 unsigned int width =
static_cast<unsigned int>(bottomRight.
get_j() - topLeft.
get_j());
763 unsigned int height =
static_cast<unsigned int>(bottomRight.
get_i() - topLeft.
get_i());
764 window.renderer->drawRect(topLeft, width, height, color, fill, thickness);
785 window.renderer->drawRect(topLeft,
static_cast<unsigned int>(rectangle.
getWidth()),
786 static_cast<unsigned int>(rectangle.
getHeight()), color, fill, thickness);
799 unsigned int thickness)
803 window.renderer->drawCircle(center, radius, color, fill, thickness);
816 window.renderer->drawText(ip, text.c_str(), color);
827 unsigned int thickness)
831 window.renderer->drawCross(ip, size, color, thickness);
842 unsigned int w,
unsigned int h,
unsigned int thickness)
847 window.renderer->drawArrow(ip1, ip2, color, w, h, thickness);
858 window.renderer->clear(color);
869 PostMessage(
window.getHWnd(), vpWM_CLOSEDISPLAY, 0, 0);
874 WaitForSingleObject(
hThread, INFINITE);
878 window.initialized =
false;
890 window.renderer->getImage(I);
899 w = GetSystemMetrics(SM_CXSCREEN);
900 h = GetSystemMetrics(SM_CYSCREEN);
908 unsigned int width, height;
918 unsigned int width, height;
922 #elif !defined(VISP_BUILD_SHARED_LIBS)
924 void 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.
bool getClick(bool blocking=true) vp_override
void getImage(vpImage< vpRGBa > &I) vp_override
void displayRectangle(const vpImagePoint &topLeft, unsigned int width, unsigned int height, const vpColor &color, bool fill=false, unsigned int thickness=1) vp_override
bool getPointerMotionEvent(vpImagePoint &ip) vp_override
void getScreenSize(unsigned int &width, unsigned int &height) vp_override
void displayImageROI(const vpImage< unsigned char > &I, const vpImagePoint &iP, unsigned int width, unsigned int height) vp_override
virtual ~vpDisplayWin32() vp_override
void displayImage(const vpImage< vpRGBa > &I) vp_override
void clearDisplay(const vpColor &color=vpColor::white) vp_override
DWORD threadId
Id of the window's thread.
vpWin32Window window
The window.
void displayLine(const vpImagePoint &ip1, const vpImagePoint &ip2, const vpColor &color, unsigned int thickness=1) vp_override
void displayPoint(const vpImagePoint &ip, const vpColor &color, unsigned int thickness=1) vp_override
bool getClickUp(vpImagePoint &ip, vpMouseButton::vpMouseButtonType &button, bool blocking=true) vp_override
void displayDotLine(const vpImagePoint &ip1, const vpImagePoint &ip2, const vpColor &color, unsigned int thickness=1) vp_override
void setWindowPosition(int winx, int winy) vp_override
void flushDisplay() vp_override
flush the Win32 buffer It's necessary to use this function to see the results of any drawing
unsigned int getScreenHeight() vp_override
bool getKeyboardEvent(bool blocking=true) vp_override
void setFont(const std::string &fontname) vp_override
Set the font used to display text.
void setTitle(const std::string &windowtitle) vp_override
vpDisplayWin32(vpWin32Renderer *rend=nullptr)
void displayCircle(const vpImagePoint ¢er, unsigned int radius, const vpColor &color, bool fill=false, unsigned int thickness=1) vp_override
HANDLE hThread
Handle of the window's thread.
bool getPointerPosition(vpImagePoint &ip) vp_override
friend void vpCreateWindow(threadParam *param)
Function used to launch the window in a thread.
bool iStatus
Initialization status.
void closeDisplay() vp_override
unsigned int getScreenWidth() vp_override
void init(vpImage< unsigned char > &I, int winx=-1, int winy=-1, const std::string &title="") vp_override
static const int MAX_INIT_DELAY
Maximum delay for window initialization.
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) vp_override
void flushDisplayROI(const vpImagePoint &iP, unsigned int width, unsigned int height) vp_override
flush the Win32 buffer It's necessary to use this function to see the results of any drawing
void displayCross(const vpImagePoint &ip, unsigned int size, const vpColor &color, unsigned int thickness=1) vp_override
void displayText(const vpImagePoint &ip, const std::string &text, const vpColor &color=vpColor::green) vp_override
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 ...
unsigned int getWidth() const
unsigned int getHeight() const
Defines a rectangle in the plane.