예제 #1
0
void CPointTool::OnLButtonDown(_CVIEW * pView, UINT nFlags, CPoint& point)
{
	CMiniCADDoc* pDoc = pView->GetDocument();
	if (pDoc==NULL)return;
	CADGraphics	*pGraphics = &pDoc->m_Graphics;
	CDisplay *pDisplay = pGraphics->m_pDisplay;
	if (pDisplay == NULL) return;
	CADPoint* pPoint;
	pPoint=new CADPoint();
	ADPOINT adPoint=pDoc->m_Graphics.ClientToDoc(point);
	pPoint->pt=adPoint;
	pPoint->m_nLayer=pDoc->m_LayerGroup.indexOf(pDoc->m_curLayer);
	pDoc->m_Graphics.m_Entities.Add((CObject*)pPoint);
	pDoc->m_Graphics.DrawGraphics(pDisplay->GetDC(),pPoint);
	pView->ReBitBlt();
	CDrawTool::OnLButtonDown(pView, nFlags, point);
}
예제 #2
0
파일: PanTool.cpp 프로젝트: yaoyushun/sdcad
void CPanTool::OnLButtonUp(_CVIEW* pView, UINT nFlags, CPoint& point)
{
	CMiniCADDoc* pDoc = pView->GetDocument();
	if (pDoc==NULL)return;
	CADGraphics	*pGraphics = &pDoc->m_Graphics;
	CDisplay *pDisplay = pGraphics->m_pDisplay;
	if (pDisplay == NULL) return;
	double ddx,ddy;
	int dx,dy;
	dx = point.x - c_PtDown.x;
	dy = point.y - c_PtDown.y;
	if (pView->m_curWorkSpace==MODELSPACE)
	{
		ddx = dx/pDoc->m_Graphics.m_ZoomRate;
		ddy = dy/pDoc->m_Graphics.m_ZoomRate;
		pDoc->m_Graphics.m_Bound.Offset(-ddx,-ddy);
		pView->ReDraw();
	}
	else
	{
		CDC* pPaperDC=pDisplay->GetPaperDC();
		ddx = dx/pDoc->m_Graphics.m_ZoomRate;
		ddy = dy/pDoc->m_Graphics.m_ZoomRate;
		pDoc->m_Graphics.m_Bound.Offset(-ddx,-ddy);

		CPoint point1;
		point1 = pDoc->m_Graphics.DocToClient(pView->m_RotatePt);
		pDoc->m_Graphics.RotateAll(pDisplay->GetDC(),point1,-(int)pDoc->m_Graphics.m_RotateAngle);

		//pDoc->m_Graphics.DrawGraphics(m_pDisplay->GetDC());
		pPaperDC->BitBlt(pView->m_ModelRect.left,pView->m_ModelRect.top,pView->m_ModelRect.Width(),pView->m_ModelRect.Height(),pDisplay->GetDC(),0,0,SRCCOPY);	
		pView->Invalidate(false);			
	}
	
	CDrawTool::OnLButtonUp(pView, nFlags, point);
}
예제 #3
0
void CRectTool::OnLButtonDown(_CVIEW * pView, UINT nFlags, CPoint& point)
{
    CDC* pDC = NULL;
    pDC = pView->GetDC();
    if (pDC == NULL) return;
    CMiniCADDoc* pDoc = pView->GetDocument();
    if (pDoc==NULL)return;
    CADGraphics	*pGraphics = &pDoc->m_Graphics;
    CDisplay *pDisplay = pGraphics->m_pDisplay;
    if (pDisplay == NULL) return;

    if (c_nDown==0)
    {
///		c_PtDown=point;
        CPen Pen;
        if (!Pen.CreatePen(PS_SOLID, 1, RGB(255,255,255)))
            return;
        CPen* pOldPen = pDC->SelectObject(&Pen);
        LOGBRUSH logBrush;
        logBrush.lbColor = 0;
        logBrush.lbHatch = 0;
        logBrush.lbStyle = BS_NULL;
        CBrush NullBrush;
        NullBrush.CreateBrushIndirect(&logBrush);
        CBrush* pOldBrush = pDC->SelectObject(&NullBrush);

        int oldDrawMode = pDC->SetROP2(R2_XORPEN);

        pView->m_pTempEntity=new CADPolyline();
        CADPolyline* pPolyline=(CADPolyline*)pView->m_pTempEntity;
        pView->SetProjectLineWidth(pPolyline);
        pPolyline->m_nLayer=pDoc->m_LayerGroup.indexOf(pDoc->m_curLayer);
        pPolyline->m_Closed=true;
        if(c_bSnap && pDoc->m_Graphics.m_bHaveSnap)
        {
            ADPOINT* pPoint=new ADPOINT();
            *pPoint = pDoc->m_Graphics.m_curSnapP;
            pPolyline->m_Point.Add((CObject*)pPoint);
            c_PtDown = pDoc->m_Graphics.DocToClient(pDoc->m_Graphics.m_curSnapP);
            c_PtOld = point;
        } else
        {
            ADPOINT* pPoint=new ADPOINT();
            *pPoint = pDoc->m_Graphics.ClientToDoc(point);
            pPolyline->m_Point.Add((CObject*)pPoint);
            c_PtDown = point;
            c_PtOld = point;
        }
        pDC->Rectangle(point.x,point.y,point.x,point.y);
        pDC->SetROP2(oldDrawMode);
        pDC->SelectObject(pOldPen);
        pDC->SelectObject(pOldBrush);
        Pen.DeleteObject();
    }
    if (c_nDown<2)
        c_nDown++;
    if (c_nDown==2)
    {
        c_nDown=0;
        ADPOINT adPoint;
        if (c_bSnap && pDoc->m_Graphics.m_bHaveSnap)
        {
            adPoint=pDoc->m_Graphics.m_curSnapP;
        } else
        {

            adPoint=pDoc->m_Graphics.ClientToDoc(point);
        }
        CADPolyline* pPolyline=(CADPolyline*)pView->m_pTempEntity;
        ADPOINT* pPoint1=(ADPOINT*)pPolyline->m_Point.GetAt(0);
        ADPOINT* pPoint=new ADPOINT();
        pPoint->x = adPoint.x;
        pPoint->y = pPoint1->y;
        pPolyline->m_Point.Add((CObject*)pPoint);
        pPoint=new ADPOINT();
        *pPoint = adPoint;
        pPolyline->m_Point.Add((CObject*)pPoint);
        pPoint=new ADPOINT();
        pPoint->x = pPoint1->x;
        pPoint->y = adPoint.y;
        pPolyline->m_Point.Add((CObject*)pPoint);
        pDoc->m_Graphics.m_Entities.Add((CObject*)pPolyline);
        pDoc->m_Graphics.DrawGraphics(pDisplay->GetDC(),pView->m_pTempEntity);
        pView->m_pTempEntity=NULL;
        pView->ReBitBlt();
    }
    DeleteDC(pDC->m_hDC);
    //CDrawTool::OnLButtonDown(pView, nFlags, point);
}
예제 #4
0
파일: PanTool.cpp 프로젝트: yaoyushun/sdcad
void CPanTool::OnMouseMove(_CVIEW* pView, UINT nFlags, CPoint& point)
{
	::SetCursor(AfxGetApp()->LoadCursor(IDC_PAN));
	CDC* pDC = NULL;
	pDC = pView->GetDC();
	if (pDC == NULL) return;
	CMiniCADDoc* pDoc = pView->GetDocument();
	if (pDoc==NULL)return;
	CADGraphics	*pGraphics = &pDoc->m_Graphics;
	CDisplay *pDisplay = pGraphics->m_pDisplay;
	if (pDisplay == NULL) return;
	if (!c_bDown)
	{
		DeleteDC(pDC->m_hDC);
		return;
	}
	::SetCursor(AfxGetApp()->LoadCursor(IDC_PANDOWN));

	double ddx,ddy;
	int dx,dy;
	dx=point.x-c_PtOld.x;
	dy=point.y-c_PtOld.y;
	ddx=dx/pDoc->m_Graphics.m_ZoomRate;
	ddy=dy/pDoc->m_Graphics.m_ZoomRate;

	int cx = point.x - c_PtDown.x;
	int cy = point.y - c_PtDown.y;

	CBrush brush;
	brush.CreateSolidBrush(pDoc->m_Graphics.m_BKColor);
	CRect rect;
	CRect rect2;
	pView->GetClientRect(rect);
	if(pView->m_curWorkSpace==MODELSPACE)
	{
		if (cx>0)
			rect2.SetRect(0,0,cx,rect.Height());
		else
			rect2.SetRect(rect.Width()+cx,0,rect.Width(),rect.Height());
		pDC->FillRect(&rect2, &brush);
		if (cy>0)
			rect2.SetRect(0,0,rect.Width(),cy-1);
		else
			rect2.SetRect(0,rect.Height()+cy,rect.Width(),rect.Height());
		pDC->FillRect(&rect2, &brush);
		pDC->BitBlt(cx,cy,rect.Width(),rect.Height(),pDisplay->GetDC(),0,0,SRCCOPY);
	}
	else
	{
		CRect moveRect=pView->m_ModelRect;
		CDC* pPaperDC=pDisplay->GetPaperDC();
		int xOffset=0;
		int yOffset=0;
		if (cx>0)
		{
			if(cx>pView->m_ModelRect.Width())cx=pView->m_ModelRect.Width();
			rect2.SetRect(pView->m_ModelRect.left,pView->m_ModelRect.top,pView->m_ModelRect.left+cx,pView->m_ModelRect.top+pView->m_ModelRect.Height());
			moveRect.left+=cx;
		}
		else
		{
			if(cx<-pView->m_ModelRect.Width())cx=-pView->m_ModelRect.Width();
			rect2.SetRect(pView->m_ModelRect.left+pView->m_ModelRect.Width()+cx,pView->m_ModelRect.top,pView->m_ModelRect.left+pView->m_ModelRect.Width(),pView->m_ModelRect.top+pView->m_ModelRect.Height());
			moveRect.right+=cx;
			xOffset-=cx;
			
		}
		pPaperDC->FillRect(&rect2, &brush);
		if (cy>0)
		{
			if(cy>pView->m_ModelRect.Height())cy=pView->m_ModelRect.Height();
			rect2.SetRect(pView->m_ModelRect.left,pView->m_ModelRect.top,pView->m_ModelRect.left+pView->m_ModelRect.Width(),pView->m_ModelRect.top+cy);
			moveRect.top+=cy;
		}
		else
		{
			if(cy<-pView->m_ModelRect.Height())cy=-pView->m_ModelRect.Height();
			rect2.SetRect(pView->m_ModelRect.left,pView->m_ModelRect.top+pView->m_ModelRect.Height()+cy,pView->m_ModelRect.left+pView->m_ModelRect.Width(),pView->m_ModelRect.top+pView->m_ModelRect.Height());
			moveRect.bottom+=cy;
			yOffset-=cy;						
		}
		pPaperDC->FillRect(&rect2, &brush);

		pPaperDC->BitBlt(moveRect.left,moveRect.top,moveRect.Width(),moveRect.Height(),pDisplay->GetDC(),xOffset,yOffset,SRCCOPY);
		pView->Invalidate(false);
	}
	brush.DeleteObject();
	DeleteDC(pDC->m_hDC);
	CDrawTool::OnMouseMove(pView, nFlags, point);
}