#include "stdafx.h" #include "TransformMotiveGraphDrawer.h" TransformMotiveGraphDrawer::TransformMotiveGraphDrawer() :m_pSIMGDrawer(NULL), m_trackerTransform(NULL) { memset(&m_boundPoints, 0, sizeof(m_boundPoints)); m_boundColor = RGB(0, 153, 255); } void TransformMotiveGraphDrawer::SetSIMGDrawer(SelectedItemMotionGraphDrawer * drawer) { m_pSIMGDrawer = drawer; } void TransformMotiveGraphDrawer::SetBoundRect(CRect & rect) { m_boundRect = rect; } void TransformMotiveGraphDrawer::CopyMatrix(Gdiplus::Matrix * matrix) { delete m_matrix; if (matrix) m_matrix = matrix->Clone(); else m_matrix = NULL; } void TransformMotiveGraphDrawer::FirstDraw(CDC * pDC, Gdiplus::Matrix * matrix, int mouseX, int mouseY) { } void TransformMotiveGraphDrawer::Draw(CDC * pDC, Gdiplus::Matrix * matrix, int mouseX, int mouseY) { } void TransformMotiveGraphDrawer::LButtonDown(int mouseX, int mouseY) { } void TransformMotiveGraphDrawer::Erease(CDC * pDC) { } void TransformMotiveGraphDrawer::DrawBoundShape(CDC * pDC) { TranslateBoundRect(); int nOldRop = pDC->SetROP2(R2_NOTXORPEN); CPen pen(PS_SOLID, 0, m_boundColor); CGdiObject * pOldPen = pDC->SelectObject(&pen); pDC->Polygon(m_boundPoints, 4); pDC->SelectObject(pOldPen); pDC->SetROP2(nOldRop); } void TransformMotiveGraphDrawer::TranslateBoundRect() { //角点与索引的对应关系 // 0----------1 // | | // | | // 3----------2 Gdiplus::Point cornerPts[4]; cornerPts[0].X = cornerPts[3].X = m_boundRect.left; cornerPts[0].Y = cornerPts[1].Y = m_boundRect.top; cornerPts[1].X = cornerPts[2].X = m_boundRect.right; cornerPts[2].Y = cornerPts[3].Y = m_boundRect.bottom; m_matrix->TransformPoints(cornerPts, 4); m_boundPoints[0].x = cornerPts[0].X; m_boundPoints[0].y = cornerPts[0].Y; m_boundPoints[1].x = cornerPts[1].X; m_boundPoints[1].y = cornerPts[1].Y; m_boundPoints[2].x = cornerPts[2].X; m_boundPoints[2].y = cornerPts[2].Y; m_boundPoints[3].x = cornerPts[3].X; m_boundPoints[3].y = cornerPts[3].Y; }