void FillPolygon( const Polygon& poly, const cv::Scalar& color, Mat& img ){ //get the number of paths and the number of contours std::vector< std::vector<cv::Point> > pts; float width = img.cols; float height = img.rows; const Polygon::Paths& paths = poly.GetPaths(); for( const Polygon::Path& path : paths ){ std::vector<cv::Point> _pts; for( const Point& pt : path ){ cv::Point _pt(pt.x*width,pt.y*height); _pts.push_back(_pt); } pts.push_back( _pts ); } cv::fillPoly( img, pts, color ); }
void CExtMiniDockFrameWnd::_ResizingUpdateState( const CPoint & point ) { CPoint _pt(point); ASSERT( m_nResizingMode != HTNOWHERE ); CExtControlBar * pExtBar = GetControlBarExt(); ASSERT_VALID( pExtBar ); // BringWindowToTop(); CRect rcClient, rcWnd, rcWndOrg; GetClientRect(rcClient); GetWindowRect(rcWnd); rcWndOrg = rcWnd; CSize sizeDiff = rcWnd.Size() - rcClient.Size(); ASSERT( sizeDiff.cx >= 0 && sizeDiff.cy >= 0 ); if( sizeDiff.cx < pExtBar->_CalcDesiredMinHW() ) sizeDiff.cx = pExtBar->_CalcDesiredMinHW(); if( sizeDiff.cy < pExtBar->_CalcDesiredMinVH() ) sizeDiff.cy = pExtBar->_CalcDesiredMinVH(); UINT nHit = m_nResizingMode; bool bLeft=false, bTop=false, bHorz=false, bInvTop=false, bInvLeft=false; CPoint ptOffsetWnd(0,0); if( pExtBar->m_bFixedMode ) { switch( nHit ) { case HTTOPLEFT: case HTTOPRIGHT: nHit = HTTOP; break; case HTBOTTOMLEFT: case HTBOTTOMRIGHT: nHit = HTBOTTOM; break; } // switch( nHit ) switch( nHit ) { case HTTOP: // if( _pt.y > rcWndOrg.bottom ) // _pt.y = rcWndOrg.bottom; _pt.y = rcWndOrg.bottom + rcWndOrg.top - _pt.y; nHit = HTBOTTOM; bInvLeft = true; bInvTop = true; break; case HTLEFT: // if( _pt.x > rcWndOrg.right ) // _pt.x = rcWndOrg.right; _pt.x = rcWndOrg.right + rcWndOrg.left - _pt.x; nHit = HTRIGHT; bInvLeft = true; bInvTop = true; break; } // switch( nHit ) } // if( pExtBar->m_bFixedMode ) if( bInvLeft || bInvTop || (!pExtBar->m_bFixedMode) ) { CRect rcWnd; CRect rcClient; GetWindowRect( &rcWnd ); GetClientRect( &rcClient ); ScreenToClient( & rcWnd ); if( bInvLeft || (!pExtBar->m_bFixedMode) ) ptOffsetWnd.x = abs( rcWnd.left - rcClient.left ); if( bInvTop || (!pExtBar->m_bFixedMode) ) ptOffsetWnd.y = abs( rcWnd.top - rcClient.top ); } // if( bInvLeft || bInvTop ) switch( nHit ) { case HTLEFT: bHorz = true; rcWnd.left = min(_pt.x,rcWnd.right); bLeft = true; break; case HTRIGHT: bHorz = true; rcWnd.right = max(_pt.x,rcWnd.left); break; case HTTOP: rcWnd.top = min(_pt.y,rcWnd.bottom); bTop = true; break; case HTTOPLEFT: rcWnd.left = min(_pt.x,rcWnd.right); rcWnd.top = min(_pt.y,rcWnd.bottom); bLeft = true; bTop = true; break; case HTTOPRIGHT: rcWnd.right = max(_pt.x,rcWnd.left); rcWnd.top = min(_pt.y,rcWnd.bottom); bTop = true; break; case HTBOTTOM: rcWnd.bottom = max(_pt.y,rcWnd.top); break; case HTBOTTOMLEFT: rcWnd.left = min(_pt.x,rcWnd.right); rcWnd.bottom = max(_pt.y,rcWnd.top); bLeft = true; break; case HTBOTTOMRIGHT: rcWnd.right = max(_pt.x,rcWnd.left); rcWnd.bottom = max(_pt.y,rcWnd.top); break; default: ASSERT( FALSE ); return; } // switch( nHit ) if( rcWnd.Width() < sizeDiff.cx ) rcWnd.right = rcWnd.left + sizeDiff.cx; if( rcWnd.Height() < sizeDiff.cy ) rcWnd.bottom = rcWnd.top + sizeDiff.cy; if( rcWnd.right > rcWndOrg.right && bLeft ) rcWnd.OffsetRect( rcWndOrg.right - rcWnd.right, 0 ); if( rcWnd.bottom > rcWndOrg.bottom && bTop ) rcWnd.OffsetRect( 0, rcWndOrg.bottom - rcWnd.bottom ); // rcWnd.OffsetRect( ptOffsetWnd ); // rcWndOrg.OffsetRect( ptOffsetWnd ); rcClient.SetRect( rcWnd.left - (rcClient.left-rcWndOrg.left), rcWnd.top - (rcClient.top-rcWndOrg.top), rcWnd.right - (rcClient.right-rcWndOrg.right), rcWnd.bottom - (rcClient.bottom-rcWndOrg.bottom) ); if( !pExtBar->m_bFixedMode ) { /* ASSERT( (GetStyle() & __REMOVED_NONFIXMODE_STYLES) == 0 ); pExtBar->m_sizeFloat = rcClient.Size(); MoveWindow( &rcWnd ); */ ASSERT( (GetStyle() & __REMOVED_NONFIXMODE_STYLES) == 0 ); pExtBar->m_sizeFloated = rcWnd.Size() -ptOffsetWnd // - CSize( // afxData.cxBorder2*2, // afxData.cyBorder2*2 // ) ; MoveWindow( &rcWnd ); //ASSERT( pExtBar->m_sizeFloat == rcClient.Size() ); DelayRecalcLayout(); SetTimer(3,20,NULL); return; /* CRect rcResultClient; pExtBar->GetClientRect( &rcResultClient ); ASSERT( rcResultClient.Size() == rcClient.Size() ); */ } // if( !pExtBar->m_bFixedMode ) else { DWORD dwMode = LM_HORZ|LM_COMMIT; LONG nLendth = 0; if( bHorz ) nLendth = rcClient.Width(); else { dwMode |= LM_LENGTHY; nLendth = rcClient.Height(); } CSize _size = pExtBar-> CalcDynamicLayout( nLendth, //rcClient.Width(), dwMode // LM_HORZ | LM_COMMIT ); pExtBar->m_sizeFloated = _size; if( bInvTop ) { ASSERT( rcWnd.top == rcWndOrg.top ); rcWnd.bottom = m_rcWndResizingStart.bottom; rcWnd.top = rcWnd.bottom - _size.cy // - (_size.cy + sizeDiff.cy) - ptOffsetWnd.y ; } if( bInvLeft ) { ASSERT( rcWnd.left == rcWndOrg.left ); rcWnd.right = m_rcWndResizingStart.right; rcWnd.left = rcWnd.right - _size.cx // - (_size.cx + sizeDiff.cx) - ptOffsetWnd.x ; } } // else from if( !pExtBar->m_bFixedMode ) /* CSize sizePreCalc = rcClient.Size(); if( _size != sizePreCalc ) { pExtBar->m_sizeFloat = _size; if( bHorz ) rcWnd.left += _size.cx-sizePreCalc.cx; else rcWnd.top += _size.cy-sizePreCalc.cy; } */ ASSERT( pExtBar->m_pDockSite != NULL ); ASSERT( pExtBar->m_pDockBar != NULL ); pExtBar->m_ptFloatHelper = rcWnd.TopLeft(); pExtBar->m_pDockSite-> FloatControlBar( pExtBar, pExtBar->m_ptFloatHelper, CBRS_ALIGN_TOP | (pExtBar->m_pDockBar->m_dwDockStyle & CBRS_FLOAT_MULTI) | CBRS_SIZE_DYNAMIC ); RecalcLayout(); }
void CExtMiniDockFrameWnd::_ResizingUpdateState( const CPoint & point ) { if( g_bInResizingUpdateState || m_ptLastResizing == point ) return; m_ptLastResizing = point; g_bInResizingUpdateState = true; CPoint _pt( point ); ASSERT( m_nResizingMode != HTNOWHERE ); CExtControlBar * pExtBar = GetControlBarExt(); ASSERT_VALID( pExtBar ); //BringWindowToTop(); CRect rcClient, rcClientOrg, rcWnd, rcWndOrg; GetClientRect( &rcClient ); GetWindowRect( &rcWnd ); rcClientOrg = rcClient; rcWndOrg = rcWnd; CSize sizeDiff = rcWnd.Size() - rcClient.Size(); ASSERT( sizeDiff.cx >= 0 && sizeDiff.cy >= 0 ); CSize sizeNcDiff( sizeDiff ); int nCalcMinHW = pExtBar->_CalcDesiredMinHW(); int nCalcMinVH = pExtBar->_CalcDesiredMinVH(); if( sizeDiff.cx < nCalcMinHW ) sizeDiff.cx = nCalcMinHW; if( sizeDiff.cy < nCalcMinVH ) sizeDiff.cy = nCalcMinVH; UINT nHit = m_nResizingMode; bool bLeft = false, bTop = false, bHorz = false, bInvTop = false, bInvLeft = false; CPoint ptOffsetWnd( 0, 0 ); if( pExtBar->IsFixedMode() ) { switch( nHit ) { case HTTOPLEFT: case HTTOPRIGHT: nHit = HTTOP; break; case HTBOTTOMLEFT: case HTBOTTOMRIGHT: nHit = HTBOTTOM; break; } // switch( nHit ) switch( nHit ) { case HTTOP: _pt.y = rcWndOrg.bottom + rcWndOrg.top - _pt.y; nHit = HTBOTTOM; bInvLeft = true; bInvTop = true; break; case HTLEFT: _pt.x = rcWndOrg.right + rcWndOrg.left - _pt.x; nHit = HTRIGHT; bInvLeft = true; bInvTop = true; break; } // switch( nHit ) } // if( pExtBar->IsFixedMode() ) if( bInvLeft || bInvTop || (!pExtBar->IsFixedMode()) ) { CRect rcWnd( rcWndOrg ); ScreenToClient( & rcWnd ); if( bInvLeft || (!pExtBar->IsFixedMode()) ) ptOffsetWnd.x = abs( rcWnd.left - rcClientOrg.left ); if( bInvTop || (!pExtBar->IsFixedMode()) ) ptOffsetWnd.y = abs( rcWnd.top - rcClientOrg.top ); } // if( bInvLeft || bInvTop ) switch( nHit ) { case HTLEFT: bHorz = true; rcWnd.left = min( _pt.x, rcWnd.right ); bLeft = true; break; case HTRIGHT: bHorz = true; rcWnd.right = max( _pt.x, rcWnd.left ); break; case HTTOP: rcWnd.top = min( _pt.y, rcWnd.bottom ); bTop = true; break; case HTTOPLEFT: rcWnd.left = min( _pt.x, rcWnd.right ); rcWnd.top = min( _pt.y, rcWnd.bottom ); bLeft = true; bTop = true; break; case HTTOPRIGHT: rcWnd.right = max( _pt.x, rcWnd.left ); rcWnd.top = min( _pt.y, rcWnd.bottom ); bTop = true; break; case HTBOTTOM: rcWnd.bottom = max( _pt.y, rcWnd.top ); break; case HTBOTTOMLEFT: rcWnd.left = min( _pt.x, rcWnd.right ); rcWnd.bottom = max( _pt.y, rcWnd.top ); bLeft = true; break; case HTBOTTOMRIGHT: rcWnd.right = max( _pt.x, rcWnd.left ); rcWnd.bottom = max( _pt.y, rcWnd.top ); break; default: ASSERT( FALSE ); g_bInResizingUpdateState = false; return; } // switch( nHit ) if( rcWnd.Width() < sizeDiff.cx ) rcWnd.right = rcWnd.left + sizeDiff.cx; if( rcWnd.Height() < sizeDiff.cy ) rcWnd.bottom = rcWnd.top + sizeDiff.cy; if( rcWnd.right > rcWndOrg.right && bLeft ) rcWnd.OffsetRect( rcWndOrg.right - rcWnd.right, 0 ); if( rcWnd.bottom > rcWndOrg.bottom && bTop ) rcWnd.OffsetRect( 0, rcWndOrg.bottom - rcWnd.bottom ); rcClient.SetRect( rcWnd.left - (rcClient.left-rcWndOrg.left), rcWnd.top - (rcClient.top-rcWndOrg.top), rcWnd.right - (rcClient.right-rcWndOrg.right), rcWnd.bottom - (rcClient.bottom-rcWndOrg.bottom) ); if( !pExtBar->IsFixedMode() ) { ASSERT( (GetStyle() & __REMOVED_NONFIXMODE_STYLES) == 0 ); CSize _sizeMinFloated = pExtBar->_CalcDesiredMinFloatedSize(); CSize _size = rcWnd.Size(); if( _size.cx < _sizeMinFloated.cx ) _size.cx = _sizeMinFloated.cx; if( _size.cy < _sizeMinFloated.cy ) _size.cy = _sizeMinFloated.cy; CExtPaintManager::monitor_parms_t _mp; CExtPaintManager::stat_GetMonitorParms( _mp, this ); CSize _sizeMaxFloated = _mp.m_rcWorkArea.Size(); if( _size.cx > _sizeMaxFloated.cx ) _size.cx = _sizeMaxFloated.cx; if( _size.cy > _sizeMaxFloated.cy ) _size.cy = _sizeMaxFloated.cy; CRect rcWndValidated( rcWnd.TopLeft(), _size ); pExtBar->m_sizeFloated = _size - ptOffsetWnd; MoveWindow( &rcWndValidated ); SetTimer( 3, 1, NULL ); g_bInResizingUpdateState = false; return; } // if( !pExtBar->IsFixedMode() ) int nWinResizingFrameDX = ::GetSystemMetrics( SM_CXSIZEFRAME ); int nWinResizingFrameDY = ::GetSystemMetrics( SM_CYSIZEFRAME ); DWORD dwMode = LM_HORZ|LM_COMMIT; LONG nLendth = 0; if( bHorz ) nLendth = rcClient.Width(); else { dwMode |= LM_LENGTHY; nLendth = rcClient.Height() - nWinResizingFrameDY; } // else from if( bHorz ) CSize _sizeFloatedPrev = pExtBar->m_sizeFloated; CSize _size = pExtBar->CalcDynamicLayout( nLendth, dwMode ); if( _sizeFloatedPrev == _size ) { g_bInResizingUpdateState = false; return; } // if( _size.cx < _sizeMinFloated.cx ) // _size.cx = _sizeMinFloated.cx; // if( _size.cy < _sizeMinFloated.cy ) // _size.cy = _sizeMinFloated.cy; pExtBar->m_sizeFloated = _size; if( bInvTop ) { ASSERT( rcWnd.top == rcWndOrg.top ); rcWnd.bottom = m_rcWndResizingStart.bottom; rcWnd.top = rcWnd.bottom - _size.cy - ptOffsetWnd.y; } if( bInvLeft ) { ASSERT( rcWnd.left == rcWndOrg.left ); rcWnd.right = m_rcWndResizingStart.right; rcWnd.left = rcWnd.right - _size.cx - ptOffsetWnd.x; } ASSERT( pExtBar->m_pDockSite != NULL ); ASSERT( pExtBar->m_pDockBar != NULL ); pExtBar->m_ptFloatHelper = rcWnd.TopLeft(); _size += sizeNcDiff; _size.cx -= nWinResizingFrameDX; // (+ v.2.22) _size.cy -= nWinResizingFrameDY; CRect rcToMoveMinFrame( pExtBar->m_ptFloatHelper, _size ); MoveWindow( &rcToMoveMinFrame); SendMessage( WM_NCPAINT ); RecalcLayout(); pExtBar->RedrawWindow( NULL, NULL, RDW_INVALIDATE|RDW_UPDATENOW |RDW_ERASE|RDW_ERASENOW |RDW_ALLCHILDREN ); g_bInResizingUpdateState = false; }