75 lines
2.4 KiB
C++
75 lines
2.4 KiB
C++
#ifndef __EXTERNREFCLONE_H__
|
|
#define __EXTERNREFCLONE_H__
|
|
|
|
// 选择实体时获得的数据
|
|
struct EntData
|
|
{
|
|
XPoint ptPick;
|
|
AcGeMatrix3d mat;
|
|
};
|
|
|
|
// 被克隆实体需要满足的条件
|
|
struct CloneCondition
|
|
{
|
|
CString sLayer; // 图层
|
|
bool operator== (const CloneCondition &data) const
|
|
{
|
|
if (sLayer.CompareNoCase(data.sLayer) == 0)
|
|
{
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
};
|
|
|
|
class ExternRefClone
|
|
{
|
|
public:
|
|
// 选择实体
|
|
int SelectEnt(const CString &sTip, Entity &ent, EntData &data, const CString &sKeyWord, TCHAR &chKey);
|
|
int SelectEnt(const CString &sTip, Entity &ent, EntData &data);
|
|
// 设置克隆的外部参照
|
|
void SetExternRef(Entity &ent);
|
|
// 克隆满足条件的所有实体
|
|
void CloneByCondition(std::vector<std::pair<Entity,EntData> > &vecEnt);
|
|
// 仅克隆选择实体
|
|
void CloneBySel(std::vector<std::pair<Entity,EntData> > &vecEnt);
|
|
|
|
private:
|
|
// 创建拷贝实体图层
|
|
AcDbObjectId CreateCloneLayer(const CString &sLayer);
|
|
// 绘制块参照中同层同类型的实体
|
|
void DrawEntity(Entity &entBlkRef, const std::vector<CloneCondition> &vecCdn, int &nDrawNum);
|
|
void DrawEntity(AcDbBlockReference *pRef,const std::vector<CloneCondition> &vecCdn, int &nDrawNum);
|
|
// 克隆实体
|
|
void CloneEntity(const AcDbEntity *pEnt,const std::vector<CloneCondition> &vecCdn, int &nDrawNum, AcDbEntity *&pCloneEnt);
|
|
// 是否为外部参照
|
|
bool IsExternRef(const AcDbObjectId &idRec);
|
|
// 是否普通图块
|
|
bool IsOrdinaryRef(const AcDbObjectId &idRec);
|
|
// 获得实体所属图块的id
|
|
bool GetBlkId(const AcDbObjectId &idRec, const EntData &data, AcDbObjectId &idBlk);
|
|
// 更新选择集,将其中选择的实体属于图块的,改为选择图块
|
|
void UpdateSelectionSet(std::vector<std::pair<Entity,EntData> > &vecSelEnt);
|
|
// 根据选择实体获得被克隆实体需满足的克隆条件
|
|
void GetCloneCondition(std::vector<std::pair<Entity,EntData> > &vecSelEnt, std::vector<CloneCondition> &vecCdn);
|
|
void GetCloneCondition(AcDbEntity *pEnt, CloneCondition &data);
|
|
// 是否克隆条件已经存在
|
|
bool FindCloneCondition(const std::vector<CloneCondition> &vecCdn, const CloneCondition &data);
|
|
// 创建图块
|
|
AcDbObjectId CreateCloneBlkRecord(const CString &sBlkName);
|
|
// 更新字符串,如果sText中包含sTok,则返回后一部分实体,否则不修改sText
|
|
void UpdateCString(CString &sText, const CString &sTok = _T("|"));
|
|
// 获得线型名
|
|
CString GetLinetypeName(const AcDbObjectId &idLinetype);
|
|
// 非图块实体中是否包含图块
|
|
bool IsIncludeBlk(const AcDbEntity *pEnt);
|
|
// 创建克隆线型
|
|
AcDbObjectId CreateCloneLinetype(const AcDbObjectId &idLinetype);
|
|
|
|
private:
|
|
// 外部参照
|
|
Entity m_entExternRef;
|
|
};
|
|
|
|
#endif |