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

📄 drawtool.cpp

📁 连接oracle
💻 CPP
📖 第 1 页 / 共 2 页
字号:
			position += delta;
			pObj->MoveTo(position, pView);
		}
		else if (nDragHandle != 0)
		{
			pObj->MoveHandleTo(nDragHandle, local, pView);
		}
	}
	
	lastPoint = local;

	if (selectMode == size && c_drawShape == selection)
	{
		c_last = point;
		SetCursor(pView->m_selection.GetHead()->GetHandleCursor(nDragHandle));
		return; // bypass CDrawTool
	}

	c_last = point;

	if (c_drawShape == selection)
		CDrawTool::OnMouseMove(pView, nFlags, point);
}
//复制一个圆
void CSelectTool::CloneEllipse(CDrawView *pView)
{
	ASSERT_VALID(pView);
	ASSERT(pView->m_cfDraw != NULL);
	
	// Create a shared file and associate a CArchive with it
	CSharedFile file;
	CArchive ar(&file, CArchive::store);
	CString strWellNO = "";
	BOOL bLinkPic = FALSE;

	// Serialize selected objects to the archive
	pView->m_selection.Serialize(ar);
	ar.Close();

	COleDataSource* pDataSource = NULL;
	TRY
	{
		pDataSource = new COleDataSource;
		// put on local format instead of or in addation to
		pDataSource->CacheGlobalData(pView->m_cfDraw, file.Detach());

		// if only one item and it is a COleClientItem then also
		// paste in that format
		CDrawObj* pDrawObj = pView->m_selection.GetHead();
		strWellNO = pDrawObj->m_sWellNO; 
		bLinkPic = pDrawObj->m_bLinkPic;
		if (pView->m_selection.GetCount() == 1 &&
			pDrawObj->IsKindOf(RUNTIME_CLASS(CDrawOleObj)))
		{
			//CDrawOleObj* pDrawOle = (CDrawOleObj*)pDrawObj;
			//pDrawOle->m_pClientItem->GetClipboardData(pDataSource, FALSE);
		}
		pDataSource->SetClipboard();

		//paste
		COleDataObject dataObject;
		dataObject.AttachClipboard();
		pView->OnUpdate(NULL, HINT_UPDATE_SELECTION, NULL);
		pView->m_selection.RemoveAll();
		if (dataObject.IsDataAvailable(pView->m_cfDraw))
		{
			pView->PasteNative(dataObject);

			// now add all items in m_selection to document
			POSITION pos = pView->m_selection.GetHeadPosition();
			while (pos != NULL)
			{
				CDrawObj* pDrawObj = pView->m_selection.GetNext(pos);
				pDrawObj->m_DShape = ellipsecopy;
				pView->GetDocument()->Add(pDrawObj);
				pDrawObj->m_sWellNO = strWellNO;
				pDrawObj->m_bLinkPic = bLinkPic;
				COLORREF color = m_ColorGreen;
				pDrawObj->SetLineColor(color);
				
			}
		}
		else
			pView->PasteEmbedded(dataObject, pView->GetInitialPosition().TopLeft() );

		pView->GetDocument()->SetModifiedFlag();

		// invalidate new pasted stuff
		pView->GetDocument()->UpdateAllViews(NULL, HINT_UPDATE_SELECTION, &(pView->m_selection));

	}
	CATCH_ALL(e)
	{
		delete pDataSource;
		THROW_LAST();
	}
	END_CATCH_ALL
		
}

////////////////////////////////////////////////////////////////////////////
// CRectTool (does rectangles, round-rectangles, and ellipses)

CRectTool::CRectTool(DrawShape drawShape)
	: CDrawTool(drawShape)
{
}

void CRectTool::OnLButtonDown(CDrawView* pView, UINT nFlags, const CPoint& point)
{
	CDrawTool::OnLButtonDown(pView, nFlags, point);

	CPoint local = point;
	pView->ClientToDoc(local);

	CDrawRect* pObj = new CDrawRect(CRect(local, CSize(0, 0)));
	switch (m_drawShape)
	{
	default:
		ASSERT(FALSE); // unsuported shape!

	case rect:
		pObj->m_nShape = CDrawRect::rectangle;
		break;

	case roundRect:
		pObj->m_nShape = CDrawRect::roundRectangle;
		break;

	case ellipse:
		pObj->m_nShape = CDrawRect::ellipse;
		break;

	case line:
		pObj->m_nShape = CDrawRect::line;
		break;
	case fault_line:
		pObj->m_nShape = CDrawRect::fault_line;
		break;
	case text:			//hjq 新加文档 2006-11
		pObj->m_nShape = CDrawRect::text;
		break;
	case recttext:
		pObj->m_nShape = CDrawRect::recttext;
		break;
	}
	pView->GetDocument()->Add(pObj);
	pView->Select(pObj);

	selectMode = size;
	nDragHandle = 1;
	lastPoint = local;
}

void CRectTool::OnLButtonDblClk(CDrawView* pView, UINT nFlags, const CPoint& point)
{
	CDrawTool::OnLButtonDblClk(pView, nFlags, point);
}

void CRectTool::OnLButtonUp(CDrawView* pView, UINT nFlags, const CPoint& point)
{
	if (point == c_down)
	{
		// Don't create empty objects...
		CDrawObj *pObj = pView->m_selection.GetTail();
		pView->GetDocument()->Remove(pObj);
		pObj->Remove();
		selectTool.OnLButtonDown(pView, nFlags, point); // try a select!
	}

	selectTool.OnLButtonUp(pView, nFlags, point);
}

void CRectTool::OnMouseMove(CDrawView* pView, UINT nFlags, const CPoint& point)
{
	SetCursor(AfxGetApp()->LoadStandardCursor(IDC_CROSS));
	selectTool.OnMouseMove(pView, nFlags, point);
}


////////////////////////////////////////////////////////////////////////////
// CPolyTool
CPolyTool::CPolyTool(DrawShape drawShape): CDrawTool(drawShape)
{
	m_pDrawObj = NULL;
}
CPolyTool::CPolyTool()
	: CDrawTool(poly)
{
	m_pDrawObj = NULL;
}

void CPolyTool::OnLButtonDown(CDrawView* pView, UINT nFlags, const CPoint& point)
{
	CDrawTool::OnLButtonDown(pView, nFlags, point);

	CPoint local = point;
	pView->ClientToDoc(local);
	
	if (m_pDrawObj == NULL)
	{
		pView->SetCapture();

		m_pDrawObj = new CDrawPoly(CRect(local, CSize(0, 0)));
		pView->GetDocument()->Add(m_pDrawObj);
		pView->Select(m_pDrawObj);
		m_pDrawObj->AddPoint(local, pView);
	}
	else if (local == m_pDrawObj->m_points[0])
	{
		// Stop when the first point is repeated...
		ReleaseCapture();
		m_pDrawObj->m_nPoints -= 1;
		if (m_pDrawObj->m_nPoints < 2)
		{
			m_pDrawObj->Remove();
		}
		else
		{
			pView->InvalObj(m_pDrawObj);
		}
		m_pDrawObj = NULL;
		c_drawShape = selection;
		return;
	}
	switch (m_drawShape)
		{
		default:
			ASSERT(FALSE); // unsuported shape!

		case poly:
			m_pDrawObj->m_nShape = CDrawPoly::poly;
			break;

		case poly_line:
			m_pDrawObj->m_nShape = CDrawPoly::poly_line;
			break;		
		case polyFault:
			m_pDrawObj->m_nShape = CDrawPoly::polyFault;
			break;	
		case polylink:
			m_pDrawObj->m_nShape = CDrawPoly::polylink;
			break;
			
	}
	local.x += 1; // adjacent points can't be the same!
	m_pDrawObj->AddPoint(local, pView);

	selectMode = size;
	nDragHandle = m_pDrawObj->GetHandleCount();
	lastPoint = local;
}

void CPolyTool::OnLButtonUp(CDrawView* /*pView*/, UINT /*nFlags*/, const CPoint& /*point*/)
{
	// Don't release capture yet!
}

void CPolyTool::OnMouseMove(CDrawView* pView, UINT nFlags, const CPoint& point)
{
	if (m_pDrawObj != NULL && (nFlags & MK_LBUTTON) != 0)
	{
		CPoint local = point;
		pView->ClientToDoc(local);
		m_pDrawObj->AddPoint(local);
		nDragHandle = m_pDrawObj->GetHandleCount();
		lastPoint = local;
		c_last = point;
		SetCursor(AfxGetApp()->LoadCursor(IDC_PENCIL));
	}
	else
	{
		SetCursor(AfxGetApp()->LoadStandardCursor(IDC_CROSS));
		selectTool.OnMouseMove(pView, nFlags, point);
	}
}

void CPolyTool::OnLButtonDblClk(CDrawView* pView, UINT , const CPoint& )
{
	ReleaseCapture();

	int nPoints = m_pDrawObj->m_nPoints;
	if (nPoints > 2 &&
		(m_pDrawObj->m_points[nPoints - 1] == m_pDrawObj->m_points[nPoints - 2] ||
		m_pDrawObj->m_points[nPoints - 1].x - 1 == m_pDrawObj->m_points[nPoints - 2].x &&
		m_pDrawObj->m_points[nPoints - 1].y == m_pDrawObj->m_points[nPoints - 2].y))

	{
		// Nuke the last point if it's the same as the next to last...
		m_pDrawObj->m_nPoints -= 1;
		pView->InvalObj(m_pDrawObj);
	}

	m_pDrawObj = NULL;
	c_drawShape = selection;
}

void CPolyTool::OnCancel()
{
	CDrawTool::OnCancel();

	m_pDrawObj = NULL;
}

/////////////////////////////////////////////////////////////////////////////

BOOL CRectTool::SetTest(CDrawRect* pObj, DrawShape drawShape)
{
	//CDrawRect* pObj = new CDrawRect(position);
	switch (drawShape)
	{
	case rect:
		pObj->m_nShape = CDrawRect::rectangle;
		break;

	case roundRect:
		pObj->m_nShape = CDrawRect::roundRectangle;
		break;

	case ellipse:
		pObj->m_nShape = CDrawRect::ellipse;
		break;
	case line:
		pObj->m_nShape = CDrawRect::line;
		break;
	case fault_line:
		pObj->m_nShape = CDrawRect::fault_line;
		break;
	case text:			//hjq 新加文档 2006-11
		pObj->m_nShape = CDrawRect::text;
		break;
	case recttext:
		pObj->m_nShape = CDrawRect::recttext;
		break;
	default:
		ASSERT(FALSE); // unsuported shape!

	}
	return TRUE;
}



⌨️ 快捷键说明

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