控件中的选择集管理器
class MrxDbgSelSet;
MrxDbgSelSet.h
|
参数 |
说明 |
|
x |
x |
x
MrxDbgSelSet 类封装了选择集及其处理函数,当对象被析够的时候,将自动释放选择集。 例如:与用户交互选择实体
MrxDbgSelSet ss;
ss.userSelect(_T("选择实体:"),NULL,NULL);
McDbObjectIdArray objIds;
ss.asArray(objIds);
if(objIds.length() > 0 )
{
AfxMessageBox(_T("选择了实体"));
}例如:返回当前选择集中的实体
MrxDbgSelSet ss;
ss.impliedSelect(NULL);
McDbObjectIdArray objIds;
ss.asArray(objIds);
if(objIds.length() > 0 )
{
AfxMessageBox(_T("选择了实体"));
}例如: 构造选择时,并带关键字输入
CString sKey;
struct resbuf* KeywordCallback(const TCHAR* pszKeyWord)
{
sKey = pszKeyWord;
return NULL;
}
void CTestCommands::TestSS()
{
sKey.Empty();
ArxDbgSelSet ss;
ss.setKeywordCallback(_T("S _S D _D"), KeywordCallback);
ArxDbgSelSet::SelSetStatus ret = ss.userSelect(_T("选择对象或 [沿线搜索(S)/两点指定(_D)]"), NULL, NULL);
if (ret == ArxDbgSelSet::kKeyword)
{
acutPrintf(_T("n In Key:%s"),sKey);
}
else if(ret == ArxDbgSelSet::kSelected)
{
McDbObjectIdArray objIds;
ss.asArray(objIds);
acutPrintf(_T("ss ok:%d"),objIds.length());
}
}例如: 根据块名过滤
McDbObjectId getBlkRefId(CString sName) { MrxDbgRbList spFilter = acutBuildList(RTDXF0, _T("INSERT"),2,sName,0); MrxDbgSelSet ss; ss.allSelect(spFilter.data()); McDbObjectIdArray aryId; ss.asArray(aryId); if(aryId.isEmpty()) return McDbObjectId::kNull; else return aryId[0]; } void Rotation(CString sName,double dAng) { McDbObjectId id = getBlkRefId(sName); if(id.isNull()) return; McDbObjectPointer<McDbBlockReference> spBlkRef(id,McDb::kForWrite); if(spBlkRef.openStatus() != Mcad::eOk) return; spBlkRef->setRotation(dAng); }