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>
49 void vpCreateWindow(threadParam *param)
52 (param->vpDisp)->window.initWindow(param->title.c_str(), param->x, param->y, param->w, param->h);
62 : iStatus(false), window(nullptr)
64 init(I, winx, winy, title);
68 : iStatus(false), window(nullptr)
70 init(I, winx, winy, title);
100 window.renderer->setImg(I);
123 window.renderer->setImg(I);
150 threadParam *param =
new threadParam;
155 param->vpDisp =
this;
174 if (!
window.isInitialized()) {
199 window.renderer->setImg(I);
228 window.renderer->setImgROI(I, iP, width, height);
250 window.renderer->setImg(I);
279 window.renderer->setImgROI(I, iP, width, height);
309 WaitForSingleObject(
window.semaClick, 0);
310 WaitForSingleObject(
window.semaClickUp, 0);
311 WaitForSingleObject(
window.semaClick, INFINITE);
315 ret = (WAIT_OBJECT_0 == WaitForSingleObject(
window.semaClick, 0));
348 WaitForSingleObject(
window.semaClick, 0);
349 WaitForSingleObject(
window.semaClickUp, 0);
350 WaitForSingleObject(
window.semaClick, INFINITE);
354 ret = (WAIT_OBJECT_0 == WaitForSingleObject(
window.semaClick, 0));
393 WaitForSingleObject(
window.semaClick, 0);
394 WaitForSingleObject(
window.semaClickUp, 0);
395 WaitForSingleObject(
window.semaClick, INFINITE);
399 ret = (WAIT_OBJECT_0 == WaitForSingleObject(
window.semaClick, 0));
405 button =
window.clickButton;
443 WaitForSingleObject(
window.semaClickUp, 0);
444 WaitForSingleObject(
window.semaClick, 0);
445 WaitForSingleObject(
window.semaClickUp, INFINITE);
449 ret = (WAIT_OBJECT_0 == WaitForSingleObject(
window.semaClickUp, 0));
455 button =
window.clickButtonUp;
483 WaitForSingleObject(
window.semaKey, 0);
484 WaitForSingleObject(
window.semaKey, 0);
485 WaitForSingleObject(
window.semaKey, INFINITE);
489 ret = (WAIT_OBJECT_0 == WaitForSingleObject(
window.semaKey, 0));
520 WaitForSingleObject(
window.semaKey, 0);
521 WaitForSingleObject(
window.semaKey, 0);
522 WaitForSingleObject(
window.semaKey, INFINITE);
526 ret = (WAIT_OBJECT_0 == WaitForSingleObject(
window.semaKey, 0));
529 std::stringstream ss;
550 bool ret = (WAIT_OBJECT_0 == WaitForSingleObject(
window.semaMove, 0));
606 SetWindowPos(
window.hWnd, HWND_TOP, winx, winy, 0, 0,
607 SWP_ASYNCWINDOWPOS | SWP_NOACTIVATE | SWP_NOZORDER | SWP_NOSIZE);
619 SetWindowText(
window.hWnd, windowtitle.c_str());
643 PostMessage(
window.getHWnd(), vpWM_DISPLAY, 0, 0);
660 WORD left = (WORD)iP.
get_u();
661 WORD right = (WORD)(iP.
get_u() + width - 1);
663 WORD top = (WORD)iP.
get_v();
664 WORD bottom = (WORD)(iP.
get_v() + height - 1);
667 WPARAM wp = MAKEWPARAM(left, right);
668 LPARAM lp = MAKELPARAM(top, bottom);
670 PostMessage(
window.getHWnd(), vpWM_DISPLAY_ROI, wp, lp);
683 if (thickness == 1) {
684 window.renderer->setPixel(ip, color);
698 unsigned int thickness)
702 window.renderer->drawLine(ip1, ip2, color, thickness);
715 unsigned int thickness)
719 window.renderer->drawLine(ip1, ip2, color, thickness, PS_DASHDOT);
736 const vpColor &color,
bool fill,
unsigned int thickness)
740 window.renderer->drawRect(topLeft, width, height, color, fill, thickness);
756 const vpColor &color,
bool fill,
unsigned int thickness)
760 unsigned int width =
static_cast<unsigned int>(bottomRight.
get_j() - topLeft.
get_j());
761 unsigned int height =
static_cast<unsigned int>(bottomRight.
get_i() - topLeft.
get_i());
762 window.renderer->drawRect(topLeft, width, height, color, fill, thickness);
783 window.renderer->drawRect(topLeft,
static_cast<unsigned int>(rectangle.
getWidth()),
784 static_cast<unsigned int>(rectangle.
getHeight()), color, fill, thickness);
797 unsigned int thickness)
801 window.renderer->drawCircle(center, radius, color, fill, thickness);
814 window.renderer->drawText(ip, text.c_str(), color);
825 unsigned int thickness)
829 window.renderer->drawCross(ip, size, color, thickness);
840 unsigned int w,
unsigned int h,
unsigned int thickness)
845 window.renderer->drawArrow(ip1, ip2, color, w, h, thickness);
856 window.renderer->clear(color);
867 PostMessage(
window.getHWnd(), vpWM_CLOSEDISPLAY, 0, 0);
872 WaitForSingleObject(
hThread, INFINITE);
876 window.initialized =
false;
888 window.renderer->getImage(I);
897 w = GetSystemMetrics(SM_CXSCREEN);
898 h = GetSystemMetrics(SM_CYSCREEN);
906 unsigned int width, height;
916 unsigned int width, height;
923 #elif !defined(VISP_BUILD_SHARED_LIBS)
925 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.
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 It's necessary to use this function to see the results of any drawing
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 It's necessary to use this function to see the results of any drawing
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
static const int MAX_INIT_DELAY
Maximum delay for window initialization.
bool getKeyboardEvent(bool blocking=true) 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.