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);
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);
306 ret = (WAIT_OBJECT_0 == WaitForSingleObject(
window.semaClick, 0));
339 WaitForSingleObject(
window.semaClick, 0);
340 WaitForSingleObject(
window.semaClickUp, 0);
341 WaitForSingleObject(
window.semaClick, INFINITE);
345 ret = (WAIT_OBJECT_0 == WaitForSingleObject(
window.semaClick, 0));
384 WaitForSingleObject(
window.semaClick, 0);
385 WaitForSingleObject(
window.semaClickUp, 0);
386 WaitForSingleObject(
window.semaClick, INFINITE);
390 ret = (WAIT_OBJECT_0 == WaitForSingleObject(
window.semaClick, 0));
396 button =
window.clickButton;
434 WaitForSingleObject(
window.semaClickUp, 0);
435 WaitForSingleObject(
window.semaClick, 0);
436 WaitForSingleObject(
window.semaClickUp, INFINITE);
440 ret = (WAIT_OBJECT_0 == WaitForSingleObject(
window.semaClickUp, 0));
446 button =
window.clickButtonUp;
474 WaitForSingleObject(
window.semaKey, 0);
475 WaitForSingleObject(
window.semaKey, 0);
476 WaitForSingleObject(
window.semaKey, INFINITE);
480 ret = (WAIT_OBJECT_0 == WaitForSingleObject(
window.semaKey, 0));
511 WaitForSingleObject(
window.semaKey, 0);
512 WaitForSingleObject(
window.semaKey, 0);
513 WaitForSingleObject(
window.semaKey, INFINITE);
517 ret = (WAIT_OBJECT_0 == WaitForSingleObject(
window.semaKey, 0));
520 std::stringstream ss;
541 bool ret = (WAIT_OBJECT_0 == WaitForSingleObject(
window.semaMove, 0));
597 SetWindowPos(
window.hWnd, HWND_TOP, winx, winy, 0, 0,
598 SWP_ASYNCWINDOWPOS | SWP_NOACTIVATE | SWP_NOZORDER | SWP_NOSIZE);
610 SetWindowText(
window.hWnd, windowtitle.c_str());
631 PostMessage(
window.getHWnd(), vpWM_DISPLAY, 0, 0);
648 WORD left = (WORD)iP.
get_u();
649 WORD right = (WORD)(iP.
get_u() + width - 1);
651 WORD top = (WORD)iP.
get_v();
652 WORD bottom = (WORD)(iP.
get_v() + height - 1);
655 WPARAM wp = MAKEWPARAM(left, right);
656 LPARAM lp = MAKELPARAM(top, bottom);
658 PostMessage(
window.getHWnd(), vpWM_DISPLAY_ROI, wp, lp);
671 if (thickness == 1) {
672 window.renderer->setPixel(ip, color);
686 unsigned int thickness)
690 window.renderer->drawLine(ip1, ip2, color, thickness);
703 unsigned int thickness)
707 window.renderer->drawLine(ip1, ip2, color, thickness, PS_DASHDOT);
724 const vpColor &color,
bool fill,
unsigned int thickness)
728 window.renderer->drawRect(topLeft, width, height, color, fill, thickness);
744 const vpColor &color,
bool fill,
unsigned int thickness)
748 unsigned int width =
static_cast<unsigned int>(bottomRight.
get_j() - topLeft.
get_j());
749 unsigned int height =
static_cast<unsigned int>(bottomRight.
get_i() - topLeft.
get_i());
750 window.renderer->drawRect(topLeft, width, height, color, fill, thickness);
771 window.renderer->drawRect(topLeft,
static_cast<unsigned int>(rectangle.
getWidth()),
772 static_cast<unsigned int>(rectangle.
getHeight()), color, fill, thickness);
785 unsigned int thickness)
789 window.renderer->drawCircle(center, radius, color, fill, thickness);
802 window.renderer->drawText(ip, text.c_str(), color);
813 unsigned int thickness)
817 window.renderer->drawCross(ip, size, color, thickness);
828 unsigned int w,
unsigned int h,
unsigned int thickness)
833 window.renderer->drawArrow(ip1, ip2, color, w, h, thickness);
844 window.renderer->clear(color);
855 PostMessage(
window.getHWnd(), vpWM_CLOSEDISPLAY, 0, 0);
860 WaitForSingleObject(
hThread, INFINITE);
864 window.initialized =
false;
876 window.renderer->getImage(I);
885 w = GetSystemMetrics(SM_CXSCREEN);
886 h = GetSystemMetrics(SM_CYSCREEN);
894 unsigned int width, height;
904 unsigned int width, height;
908 #elif !defined(VISP_BUILD_SHARED_LIBS)
911 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 getClickUp(vpImagePoint &ip, vpMouseButton::vpMouseButtonType &button, bool blocking=true) override
void displayText(const vpImagePoint &ip, const std::string &text, const vpColor &color=vpColor::green) override
void closeDisplay() override
void displayLine(const vpImagePoint &ip1, const vpImagePoint &ip2, const vpColor &color, unsigned int thickness=1) override
void init(vpImage< unsigned char > &I, int winx=-1, int winy=-1, const std::string &title="") override
void displayRectangle(const vpImagePoint &topLeft, unsigned int width, unsigned int height, const vpColor &color, bool fill=false, unsigned int thickness=1) override
unsigned int getScreenWidth() override
unsigned int getScreenHeight() override
void displayDotLine(const vpImagePoint &ip1, const vpImagePoint &ip2, const vpColor &color, unsigned int thickness=1) override
DWORD threadId
Id of the window's thread.
vpWin32Window window
The window.
void flushDisplay() 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) override
void clearDisplay(const vpColor &color=vpColor::white) override
void flushDisplayROI(const vpImagePoint &iP, unsigned int width, unsigned int height) override
flush the Win32 buffer It's necessary to use this function to see the results of any drawing
void displayCircle(const vpImagePoint ¢er, unsigned int radius, const vpColor &color, bool fill=false, unsigned int thickness=1) override
vpDisplayWin32(vpWin32Renderer *rend=nullptr)
bool getPointerPosition(vpImagePoint &ip) override
HANDLE hThread
Handle of the window's thread.
friend void vpCreateWindow(threadParam *param)
Function used to launch the window in a thread.
void displayPoint(const vpImagePoint &ip, const vpColor &color, unsigned int thickness=1) override
bool iStatus
Initialization status.
void displayImageROI(const vpImage< unsigned char > &I, const vpImagePoint &iP, unsigned int width, unsigned int height) override
static const int MAX_INIT_DELAY
Maximum delay for window initialization.
virtual ~vpDisplayWin32() 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) override
void setFont(const std::string &fontname) override
Set the font used to display text.
bool getKeyboardEvent(bool blocking=true) override
void displayImage(const vpImage< vpRGBa > &I) override
bool getPointerMotionEvent(vpImagePoint &ip) override
void setWindowPosition(int winx, int winy) override
void getScreenSize(unsigned int &width, unsigned int &height) override
bool getClick(bool blocking=true) override
void setTitle(const std::string &windowtitle) override
void getImage(vpImage< vpRGBa > &I) 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.