bs2833172 发表于 2007-3-29 13:33:00

一个画图问题

请问各位高手如何能实现让图形跟着鼠标走,鼠标点击时获取鼠标点击的坐标然后把图型移动到那个坐标?

bs2833172 发表于 2007-3-29 16:45:00

<p>问题已解决!使用acedGrRead()就可以循环跟踪鼠标动作啦</p><p>实现代码片断如下:</p><p>&nbsp;AcDbBlockReference *pBlkRef = new AcDbBlockReference() ;<br/>&nbsp;pBlkRef-&gt;setBlockTableRecord(idNewBlock) ;<br/>&nbsp;AcGePoint3d pntRefPos(0.0,0.0,0.0) ;<br/>&nbsp;<br/>&nbsp;AcDbBlockTable *pCurBlkTab ;<br/>&nbsp;AcDbBlockTableRecord *pCurBlkTabRcd ;<br/>&nbsp;pCurDatabase-&gt;getBlockTable(pCurBlkTab,AcDb::kForRead) ;<br/>&nbsp;pCurBlkTab-&gt;getAt(ACDB_MODEL_SPACE,pCurBlkTabRcd,AcDb::kForWrite) ;<br/>&nbsp;pCurBlkTab-&gt;close() ;</p><p>&nbsp;AcDbObjectId idBlkRef ;<br/>&nbsp;pCurBlkTabRcd-&gt;appendAcDbEntity(idBlkRef,pBlkRef) ;<br/>&nbsp;pBlkRef-&gt;close() ;</p><p>&nbsp;resbuf res ;<br/>&nbsp;int type ;<br/>&nbsp;do<br/>&nbsp;{<br/>&nbsp;&nbsp;acedGrRead(1,&amp;type,&amp;res) ;<br/>&nbsp;&nbsp;pntRefPos = res.resval.rpoint ;<br/>&nbsp;&nbsp;pntRefPos = res.resval.rpoint ;</p><p>&nbsp;&nbsp;acdbOpenObject(pBlkRef,idBlkRef,AcDb::kForWrite) ;<br/>&nbsp;&nbsp;pBlkRef-&gt;setPosition(pntRefPos) ;<br/>&nbsp;&nbsp;pBlkRef-&gt;close() ;<br/>&nbsp;}<br/>&nbsp;while (type != 3) ;</p>

lsy83021 发表于 2007-6-20 09:47:00

<p>这个问题能给完整的答案和解释吗?</p><p>谢谢!</p>
页: [1]
查看完整版本: 一个画图问题