www.pudn.com > my2cadtest07261930.rar > CopyTool.cpp, change:2006-07-26,size:2546b


 
#include "stdafx.h" 
#include "CopyTool.h" 
 
extern CList<CShape *> m_list;  
 
CCopyTool::CCopyTool(HWND hWnd):CTool(hWnd) 
{ 
 
} 
 
CCopyTool::~CCopyTool() 
{ 
 
} 
 
void CCopyTool::OnLButtonDown(WPARAM wParam,LPARAM lParam) 
{ 
  POINT curPT; 
 curPT.x=LOWORD(lParam); 
 curPT.y=HIWORD(lParam); 
  
 switch (m_status) 
 { 
 case NoClick: 
	 { 
		 for(int nI=0;nI<m_list.GetCount();nI++)  //单个图形操作 
			 { 
				 if(m_list[nI].node->IsLock())       
				 { 
					   for(int nJ=0;nJ<m_list[nI].node->GetPointCount();nJ++) 
						   { 
							   int distance=m_list[nI].node->GetPointArr()[nJ].DistanceTo(curPT); 
							   if(distance<6) 
								   { 
									 m_catchShape=m_list[nI].node->GetShapeCopy(); 
 
									 m_catchShapeList.AddTail(m_catchShape); 
 
									 m_begPT=curPT; 
									 m_status=FirstClick; 
									 return; 
								   } 
							    
						   }                  					    
				 } 
			 } 
 
          for( nI=0;nI<m_list.GetCount();nI++)  //多图一起操作 
			 { 
				 if(m_list[nI].node->IsLock())       
				 { 
					m_catchShape=m_list[nI].node->GetShapeCopy(); 
					m_catchShapeList.AddTail(m_catchShape); 
                    m_begPT=curPT; 
					m_status=FirstClick; 
				 } 
			 } 
 
	 } 
 break; 
 case FirstClick: 
	 if( m_catchShapeList.GetCount()!=0 ) 
		{        
		  for(int i=0;i<m_catchShapeList.GetCount();i++) 
		  { 
		    m_catchShapeList[i].node->EnterOper(m_hdc); 
			m_list.AddTail(m_catchShapeList[i].node); 
		  }	 
          m_catchShapeList.DeleteAll(); 
          m_catchShape=NULL; 
          ReleaseDC(m_hWnd,m_hdc); 
		} 
		m_status = NoClick; 
 
		m_list.SetEditStatus(true); 
 
		break; 
 } 
 return; 
} 
 
void CCopyTool::OnMouseMove(WPARAM wParam,LPARAM lParam) 
{ 
    POINT curPT; 
    curPT.x=LOWORD(lParam); 
    curPT.y=HIWORD(lParam); 
	 
	if(m_status==FirstClick) 
	 { 
       this->m_endPT=curPT;  
       int dx=m_endPT.GetPoint().x-m_begPT.GetPoint().x; 
       int dy=m_endPT.GetPoint().y-m_begPT.GetPoint().y;     		    
	   m_hdc=GetDC(m_hWnd); 
 
	   for(int i=0;i<m_catchShapeList.GetCount();i++) 
	   { 
		   m_catchShapeList[i].node->MoveSelf(m_hdc,dx,dy);	 
	   }	    
	   return; 
	 } 
    else 
	{ 
		return; 
	} 
	 
} 
 
void CCopyTool::OnRButtonDown(WPARAM wParam,LPARAM lParam)  
{ 
   HDC m_hdc = GetDC(m_hWnd); 
	for(int i=0;i<m_catchShapeList.GetCount();i++) 
	{ 
		m_catchShapeList[i].node->RollBackOper(m_hdc); 
	} 
          m_catchShapeList.DeleteAll(); 
          m_catchShape=NULL; 
	m_status = NoClick; 
    ReleaseDC(m_hWnd,m_hdc); 
	 
}