绘制箭线的工具CArrowTool在OnLButtonDown中实际生成箭线对象,并记录箭线所连的开始节点,箭线的终节点确定在后面说明。
2. 2图元联动操作
2.2.1删除节点及箭线
void CDrawView::OnEditClear()
{
CDrawDoc* pDoc=(CDrawDoc*)GetDocument();
POSITION pos = m_selection.GetHeadPosition();
while (pos != NULL)
{
CDrawObj* pObj = m_selection.GetNext(pos);
GetDocument()->Remove(pObj); //删除节点
CDrawNode* pDrawCircle=(CDrawNode*)pObj;
nIndex=pDrawCircle->GetObjIndex();//获取节点编号,若不是节点对象,返回0
if(nIndex)
{
pDoc->m_nIndex=nIndex;
pos=GetDocument()->m_objects.GetHeadPosition();
int i=0;
int num=pDoc->m_objects.GetCount();
m_num=pDoc->m_nIndex;
while(i<num)
{//序号位于被删除节点之后的所有节点序号减1
CDrawNode* pDrawCircle=(CDrawNode*)pDoc->m_objects.GetNext(pos);
if(pDrawCircle->GetObjIndex()>m_num)
{
pDrawCircle->SetCircleIndex(m_num);
m_num++;
}
|