⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 zuantool.cpp

📁 参数化车间设备资源绘制程序
💻 CPP
字号:
#include "StdAfx.h"
#include ".\zuantool.h"
#using <mscorlib.dll>
#include "zuanobj.h"
#include "visdrawdoc.h"
#include "visdrawview.h"

CZuanTool::CZuanTool(void)
{
}

CZuanTool::~CZuanTool(void)
{
}
CZuanTool::CZuanTool(DrawShape drawShape)
	: CDrawTool(drawShape)
{
	pObj = NULL;
}



void CZuanTool::OnLButtonDown(CVisDrawView* pView, UINT nFlags, const CPoint& point)
{	
	// TODO: 在此添加消息处理程序代码和/或调用默认值

	double ptx, pty;
	CPoint local = point;
	CPoint lastpoint;

	/*根据当前的状态决定做的事情*/
	//CClientDC dc(this);


	//把设备坐标转化为逻辑坐标
	pView->ClientToDoc(local);

	//把逻辑坐标转化为实际坐标

	pView->ClientToWorld(local, ptx,pty);

	  //申请与视图窗口相关的设备描述表
	CDC* dc=pView->GetDC();

	 int pic;

	 pic=pView->m_picIDzuan;
	 CBitmap bitmap;
		bitmap.LoadBitmap(pic);
		CDC dcComp;
		dcComp.CreateCompatibleDC(dc);
		dcComp.SelectObject(&bitmap);

		BITMAP bmInfo;
		bitmap.GetObject(sizeof(bmInfo),&bmInfo);
	 

	// pObj->Draw(pView,idBitmap,pDC);
		dc->BitBlt(point.x,point.y,bmInfo.bmWidth,bmInfo.bmHeight, &dcComp, 0,0,SRCCOPY);
	
		 pObj = new CZuanObj(CRect(local, CSize(0, 0)));

//把第一次按下的鼠标点设置为矩形左上角
		pObj->SetPoint(1,ptx,pty);
		
		pObj->CalcBounds(pView);

		pView->ClientToDoc(lastpoint);

		lastpoint.x=local.x+bmInfo.bmWidth;
		lastpoint.y=local.y+bmInfo.bmHeight;


		//把逻辑坐标转化为实际坐标
		pView->ClientToWorld(lastpoint, ptx,pty);
        pObj->SetPoint(2,ptx,pty);

		pView->Invalidate();
       
		pObj->CalcBounds(pView);

		pView->GetDocument()->Add(pObj);

		
		/*
		pObj->m_RectTracker.m_rect;
		pObj->m_RectTracker.m_nStyle=CRectTracker::resizeInside;
		if(pObj->m_RectTracker.Track(this,point,FALSE,NULL))
		{
			pObj->m_RectLP=pObj->m_RectTracker.m_rect;
			dc.DPtoLP(pObj->m_RectLP);
			pObj->rect=pObj->m_RectLP;

		}
		*/
		lastPoint=point;
		prePoint=point;

		pView->ReleaseDC(dc);
		
	
}


void CZuanTool::OnLButtonUp(CVisDrawView* pView, UINT nFlags, const CPoint& point)
{
}

void CZuanTool::OnMouseMove(CVisDrawView* pView, UINT nFlags, const CPoint& point)
{
/*double ptx, pty;
	CPoint local = point;

	//把设备坐标转化为逻辑坐标
	pView->ClientToDoc(local);

	pView->ClientToWorld(local, ptx,pty);

	CDC* dc=pView->GetDC();

	dc->SetROP2(R2_NOT);
		dc->SelectStockObject(NULL_BRUSH);

	CBitmap bitmap;
		bitmap.LoadBitmap(m_picID);

		

		CDC dcComp;
		dcComp.CreateCompatibleDC(dc);
		dcComp.SelectObject(&bitmap);
		
		BITMAP bmInfo;
		bitmap.GetObject(sizeof(bmInfo),&bmInfo);
		//将图片显示到视图中间

		dc->BitBlt(local.x,local.y,bmInfo.bmWidth,bmInfo.bmHeight, &dcComp, 0,0,SRCCOPY);

		 prePoint=point;
		pView->ReleaseDC(dc);
		*/



}
void CZuanTool::OnLButtonDblClk(CVisDrawView* pView, UINT nFlags, const CPoint& point)
{
	CDrawTool::OnLButtonDblClk(pView, nFlags, point);
}
//void CCheTool::OnInitialUpdate(void)
//{
	/*CDC* pDC=GetDC();
	m_pMemDC->CreateCompatibleDC(pDC);
	m_pBmp->LoadBitmap(IDB_CHE);
	m_pMemDC->SelectObject(m_pBmp);
	ReleaseDC(pDC);
	*/


//}
void CZuanTool::CreateObj(CVisDrawView* pView, const CPoint& point)
{
	
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -