34#include <visp3/core/vpConfig.h>
35#if (defined(VISP_HAVE_GDI) || defined(VISP_HAVE_D3D9))
38#include <visp3/core/vpDisplayException.h>
39#include <visp3/gui/vpDisplayWin32.h>
52 (param->vpDisp)->
window.initWindow(param->title.c_str(), param->x, param->y, param->w, param->h);
64 init(I, winx, winy, title);
70 init(I, winx, winy, title);
110 if ((I.getHeight() == 0) || (I.getWidth() == 0)) {
115 init(I.getWidth(), I.getHeight(), x, y, title);
118 window.renderer->setImg(I);
134 if ((I.getHeight() == 0) || (I.getWidth() == 0)) {
139 init(I.getWidth(), I.getHeight(), x, y, title);
142 window.renderer->setImg(I);
170 threadParam *param =
new threadParam;
175 param->vpDisp =
this;
194 if (!
window.isInitialized()) {
219 window.renderer->setImg(I);
248 window.renderer->setImgROI(I, iP, width, height);
270 window.renderer->setImg(I);
299 window.renderer->setImgROI(I, iP, width, height);
327 WaitForSingleObject(
window.semaClick, 0);
328 WaitForSingleObject(
window.semaClickUp, 0);
329 WaitForSingleObject(
window.semaClick, INFINITE);
333 ret = (WAIT_OBJECT_0 == WaitForSingleObject(
window.semaClick, 0));
364 WaitForSingleObject(
window.semaClick, 0);
365 WaitForSingleObject(
window.semaClickUp, 0);
366 WaitForSingleObject(
window.semaClick, INFINITE);
370 ret = (WAIT_OBJECT_0 == WaitForSingleObject(
window.semaClick, 0));
408 WaitForSingleObject(
window.semaClick, 0);
409 WaitForSingleObject(
window.semaClickUp, 0);
410 WaitForSingleObject(
window.semaClick, INFINITE);
414 ret = (WAIT_OBJECT_0 == WaitForSingleObject(
window.semaClick, 0));
420 button =
window.clickButton;
456 WaitForSingleObject(
window.semaClickUp, 0);
457 WaitForSingleObject(
window.semaClick, 0);
458 WaitForSingleObject(
window.semaClickUp, INFINITE);
462 ret = (WAIT_OBJECT_0 == WaitForSingleObject(
window.semaClickUp, 0));
468 button =
window.clickButtonUp;
494 WaitForSingleObject(
window.semaKey, 0);
495 WaitForSingleObject(
window.semaKey, 0);
496 WaitForSingleObject(
window.semaKey, INFINITE);
500 ret = (WAIT_OBJECT_0 == WaitForSingleObject(
window.semaKey, 0));
529 WaitForSingleObject(
window.semaKey, 0);
530 WaitForSingleObject(
window.semaKey, 0);
531 WaitForSingleObject(
window.semaKey, INFINITE);
535 ret = (WAIT_OBJECT_0 == WaitForSingleObject(
window.semaKey, 0));
538 std::stringstream ss;
558 bool ret = (WAIT_OBJECT_0 == WaitForSingleObject(
window.semaMove, 0));
612 SetWindowPos(
window.hWnd, HWND_TOP, winx, winy, 0, 0,
613 SWP_ASYNCWINDOWPOS | SWP_NOACTIVATE | SWP_NOZORDER | SWP_NOSIZE);
625 SetWindowText(
window.hWnd, windowtitle.c_str());
650 PostMessage(
window.getHWnd(), vpWM_DISPLAY, 0, 0);
667 WORD left =
static_cast<WORD
>(iP.
get_u());
668 WORD right =
static_cast<WORD
>(iP.
get_u() + width - 1);
670 WORD top =
static_cast<WORD
>(iP.
get_v());
671 WORD bottom =
static_cast<WORD
>(iP.
get_v() + height - 1);
674 WPARAM wp = MAKEWPARAM(left, right);
675 LPARAM lp = MAKELPARAM(top, bottom);
677 PostMessage(
window.getHWnd(), vpWM_DISPLAY_ROI, wp, lp);
690 if (thickness == 1) {
691 window.renderer->setPixel(ip, color);
706 unsigned int thickness)
710 window.renderer->drawLine(ip1, ip2, color, thickness);
724 unsigned int thickness)
728 window.renderer->drawLine(ip1, ip2, color, thickness, PS_DASHDOT);
745 const vpColor &color,
bool fill,
unsigned int thickness)
749 window.renderer->drawRect(topLeft, width, height, color, fill, thickness);
764 const vpColor &color,
bool fill,
unsigned int thickness)
768 unsigned int width =
static_cast<unsigned int>(bottomRight.
get_j() - topLeft.
get_j());
769 unsigned int height =
static_cast<unsigned int>(bottomRight.
get_i() - topLeft.
get_i());
770 window.renderer->drawRect(topLeft, width, height, color, fill, thickness);
790 window.renderer->drawRect(topLeft,
static_cast<unsigned int>(rectangle.
getWidth()),
791 static_cast<unsigned int>(rectangle.
getHeight()), color, fill, thickness);
803 unsigned int thickness)
807 window.renderer->drawCircle(center, radius, color, fill, thickness);
820 window.renderer->drawText(ip, text.c_str(), color);
831 unsigned int thickness)
835 window.renderer->drawCross(ip, size, color, thickness);
848 unsigned int w,
unsigned int h,
unsigned int thickness)
853 window.renderer->drawArrow(ip1, ip2, color, w, h, thickness);
864 window.renderer->clear(color);
875 PostMessage(
window.getHWnd(), vpWM_CLOSEDISPLAY, 0, 0);
880 WaitForSingleObject(
hThread, INFINITE);
884 window.initialized =
false;
896 window.renderer->getImage(I);
906 w =
static_cast<unsigned int>(GetSystemMetrics(SM_CXSCREEN));
907 h =
static_cast<unsigned int>(GetSystemMetrics(SM_CYSCREEN));
915 unsigned int width, height;
925 unsigned int width, height;
932#elif !defined(VISP_BUILD_SHARED_LIBS)
934void 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 displayText(const vpImagePoint &ip, const std::string &text, const vpColor &color=vpColor::green) VP_OVERRIDE
virtual ~vpDisplayWin32() VP_OVERRIDE
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 init(vpImage< unsigned char > &I, int winx=-1, int winy=-1, const std::string &title="") VP_OVERRIDE
void displayImageROI(const vpImage< unsigned char > &I, const vpImagePoint &iP, unsigned int width, unsigned int height) VP_OVERRIDE
bool getClickUp(vpImagePoint &ip, vpMouseButton::vpMouseButtonType &button, bool blocking=true) VP_OVERRIDE
bool getClick(bool blocking=true) VP_OVERRIDE
DWORD threadId
Id of the window's thread.
vpWin32Window window
The window.
unsigned int getScreenWidth() VP_OVERRIDE
void displayCross(const vpImagePoint &ip, unsigned int size, const vpColor &color, unsigned int thickness=1) VP_OVERRIDE
void displayImage(const vpImage< vpRGBa > &I) VP_OVERRIDE
void displayDotLine(const vpImagePoint &ip1, const vpImagePoint &ip2, const vpColor &color, unsigned int thickness=1) VP_OVERRIDE
bool getPointerPosition(vpImagePoint &ip) VP_OVERRIDE
void closeDisplay() VP_OVERRIDE
VP_EXPLICIT vpDisplayWin32(vpWin32Renderer *rend=nullptr)
void displayLine(const vpImagePoint &ip1, const vpImagePoint &ip2, const vpColor &color, unsigned int thickness=1) VP_OVERRIDE
unsigned int getScreenHeight() VP_OVERRIDE
void setTitle(const std::string &windowtitle) VP_OVERRIDE
HANDLE hThread
Handle of the window's thread.
friend void vpCreateWindow(threadParam *param)
Function used to launch the window in a thread.
void flushDisplayROI(const vpImagePoint &iP, unsigned int width, unsigned int height) VP_OVERRIDE
Flush the Win32 buffer.
bool iStatus
Initialization status.
void setWindowPosition(int winx, int winy) VP_OVERRIDE
void displayPoint(const vpImagePoint &ip, const vpColor &color, unsigned int thickness=1) VP_OVERRIDE
bool getPointerMotionEvent(vpImagePoint &ip) VP_OVERRIDE
void getScreenSize(unsigned int &width, unsigned int &height) VP_OVERRIDE
void getImage(vpImage< vpRGBa > &I) VP_OVERRIDE
void flushDisplay() VP_OVERRIDE
Flush the Win32 buffer.
void displayRectangle(const vpImagePoint &topLeft, unsigned int width, unsigned int height, const vpColor &color, bool fill=false, unsigned int thickness=1) VP_OVERRIDE
void setFont(const std::string &fontname) VP_OVERRIDE
Set the font used to display text.
void displayCircle(const vpImagePoint ¢er, unsigned int radius, const vpColor &color, bool fill=false, unsigned int thickness=1) VP_OVERRIDE
void clearDisplay(const vpColor &color=vpColor::white) VP_OVERRIDE
vpDisplayWin32 & operator=(const vpDisplayWin32 &display)
static const int MAX_INIT_DELAY
Maximum delay for window initialization.
bool getKeyboardEvent(bool blocking=true) VP_OVERRIDE
static void display(const vpImage< unsigned char > &I)
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.
Defines a rectangle in the plane.