Files
envi-code/SourceCode/Code2026/inc/KTAdsEntity.h
T

228 lines
5.0 KiB
C++
Raw Normal View History

2026-10-04 00:04:20 +08:00
#if !defined(__KTADSENTITY_H__)
2026-09-28 15:28:50 +08:00
#define __KTADSENTITY_H__
// Description:
2026-10-04 00:04:20 +08:00
// 类CKTAdsEntity用于管理由ads_name表示的实体对象, 用于代替ads_name的使用,
// 它支持AcDbObjectId.
// 用法同ads_name做实体对象使用时相同
2026-09-28 15:28:50 +08:00
// Company: Kingtouch Software Corporation. Copyright 2002-2005
// Author: WangYongguang
// Date: 2002.05.01
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#if ARX > 20
#ifndef _WIN64
typedef int32_t* ADS_NAME;
#else
typedef int64_t* ADS_NAME;
#endif
#else
#ifndef _WIN64
typedef long* ADS_NAME;
#else
typedef __int64* ADS_NAME;
#endif
#endif
#ifdef EARTHWORM_EXPORT
#define DLLIMPEXP __declspec(dllexport)
#else
#define DLLIMPEXP __declspec(dllimport)
#endif
class DLLIMPEXP CKTAdsEntity
{
public:
2026-10-04 00:04:20 +08:00
// 默认构造函数
2026-09-28 15:28:50 +08:00
CKTAdsEntity();
2026-10-04 00:04:20 +08:00
// 构造函数,拷贝构造
2026-09-28 15:28:50 +08:00
CKTAdsEntity(const CKTAdsEntity& cEnt);
2026-10-04 00:04:20 +08:00
// 构造函数,传入ID
2026-09-28 15:28:50 +08:00
CKTAdsEntity(const AcDbObjectId& idEnt);
2026-10-04 00:04:20 +08:00
// 构造函数,传入handle
2026-09-28 15:28:50 +08:00
CKTAdsEntity(const AcDbHandle& handle);
2026-10-04 00:04:20 +08:00
// 构造函数,传入ads_name
2026-09-28 15:28:50 +08:00
CKTAdsEntity(const ads_name adsName);
2026-10-04 00:04:20 +08:00
// 析构函数
2026-09-28 15:28:50 +08:00
virtual ~CKTAdsEntity();
2026-10-04 00:04:20 +08:00
// 从旧的ID方式获得ads_name
2026-09-28 15:28:50 +08:00
#ifdef _WIN64
CKTAdsEntity& SetFromOldId(__int64 lOldId);
#else
CKTAdsEntity& SetFromOldId(long lOldId);
#endif
2026-10-04 00:04:20 +08:00
// 从Handle字符串方式获得ads_name
2026-09-28 15:28:50 +08:00
CKTAdsEntity& SetFromHandle(LPCTSTR pszHandle);
2026-10-04 00:04:20 +08:00
// 获取旧的ID值
2026-09-28 15:28:50 +08:00
Adesk::IntDbId AsOldId() const;
2026-10-04 00:04:20 +08:00
// 获取ads_name
2026-09-28 15:28:50 +08:00
ADS_NAME AsAdsName();
ADS_NAME AsAdsName() const;
2026-10-04 00:04:20 +08:00
// 取得ads_name
2026-09-28 15:28:50 +08:00
void GetAdsName(ads_name adsName) const;
2026-10-04 00:04:20 +08:00
// 取得AcDbObjectId
2026-09-28 15:28:50 +08:00
void GetObjectId(AcDbObjectId& idEnt) const;
2026-10-04 00:04:20 +08:00
// 获得与之关联的Handle
2026-09-28 15:28:50 +08:00
AcDbHandle Handle() const;
2026-10-04 00:04:20 +08:00
// 判断是否有效
2026-09-28 15:28:50 +08:00
bool IsValid() const;
2026-10-04 00:04:20 +08:00
// 判断是否被删除
2026-09-28 15:28:50 +08:00
bool IsErased() const;
2026-10-04 00:04:20 +08:00
// 设置高亮显示
2026-09-28 15:28:50 +08:00
void Highlight(BOOL bHighlight = TRUE, BOOL bUpdate = TRUE);
2026-10-04 00:04:20 +08:00
// 设置夹点显示
2026-09-28 15:28:50 +08:00
void Griplight(BOOL bGriplight = TRUE, BOOL bUpdate = TRUE);
2026-10-04 00:04:20 +08:00
// 重载运算符号=
2026-09-28 15:28:50 +08:00
CKTAdsEntity& operator=(const CKTAdsEntity& adsEnt);
CKTAdsEntity& operator=(const AcDbObjectId& idEnt);
CKTAdsEntity& operator=(const AcDbHandle& handle);
CKTAdsEntity& operator=(const ads_name adsName);
CKTAdsEntity& operator=(int iNull);
2026-10-04 00:04:20 +08:00
// 重载运算符号
2026-09-28 15:28:50 +08:00
operator AcDbObjectId();
operator AcDbHandle();
operator ADS_NAME();
2026-10-04 00:04:20 +08:00
// 重载运算符号&
2026-09-28 15:28:50 +08:00
ADS_NAME operator&();
ADS_NAME operator&() const;
2026-10-04 00:04:20 +08:00
// 重载运算符号bool
2026-09-28 15:28:50 +08:00
operator bool() const;
2026-10-04 00:04:20 +08:00
// 重载运算符号==
2026-09-28 15:28:50 +08:00
bool operator==(const CKTAdsEntity& adsEnt) const;
bool operator==(const AcDbObjectId& idEnt) const;
bool operator==(const AcDbHandle& handle) const;
bool operator==(const ads_name adsName) const;
bool operator==(int iNull) const;
2026-10-04 00:04:20 +08:00
// 重载运算符号!=
2026-09-28 15:28:50 +08:00
bool operator!=(const CKTAdsEntity& adsEnt) const;
bool operator!=(const AcDbObjectId& idEnt) const;
bool operator!=(const AcDbHandle& handle) const;
bool operator!=(const ads_name adsName) const;
bool operator!=(int iNull) const;
protected:
ads_name m_adsName;
2026-10-04 00:04:20 +08:00
// 放在m_adsName之后,符合CopyMemory内存顺序
2026-09-28 15:28:50 +08:00
BOOL m_bHighlight;
BOOL m_bGriplight;
};
2026-10-04 00:04:20 +08:00
// 重载运算符号==
2026-09-28 15:28:50 +08:00
inline bool operator==(const AcDbObjectId& idEnt, const CKTAdsEntity& adsEnt)
{
return (adsEnt == idEnt);
}
inline bool operator==(const AcDbHandle& handle, const CKTAdsEntity& adsEnt)
{
return (adsEnt == handle);
}
inline bool operator==(const ads_name adsName, const CKTAdsEntity& adsEnt)
{
return (adsEnt == adsName);
}
inline bool operator==(int iNull, const CKTAdsEntity& adsEnt)
{
return (adsEnt == iNull);
}
2026-10-04 00:04:20 +08:00
// 重载运算符号!=
2026-09-28 15:28:50 +08:00
inline bool operator!=(const AcDbObjectId& idEnt, const CKTAdsEntity& adsEnt)
{
return (adsEnt != idEnt);
}
inline bool operator!=(const AcDbHandle& handle, const CKTAdsEntity& adsEnt)
{
return (adsEnt != handle);
}
inline bool operator!=(const ads_name adsName, const CKTAdsEntity& adsEnt)
{
return (adsEnt != adsName);
}
inline bool operator!=(int iNull, const CKTAdsEntity& adsEnt)
{
return (adsEnt != iNull);
}
/////////////////////////////////////////////////////////
2026-10-04 00:04:20 +08:00
// 获取ads_name
2026-09-28 15:28:50 +08:00
inline ADS_NAME CKTAdsEntity::AsAdsName()
{
return m_adsName;
}
inline ADS_NAME CKTAdsEntity::AsAdsName() const
{
return (ADS_NAME)m_adsName;
}
inline CKTAdsEntity::operator ADS_NAME()
{
return m_adsName;
}
2026-10-04 00:04:20 +08:00
// 重载运算符号&
2026-09-28 15:28:50 +08:00
inline ADS_NAME CKTAdsEntity::operator&()
{
return m_adsName;
}
inline ADS_NAME CKTAdsEntity::operator&() const
{
return (ADS_NAME)m_adsName;
}
2026-10-04 00:04:20 +08:00
// 重载运算符号bool
2026-09-28 15:28:50 +08:00
inline CKTAdsEntity::operator bool() const
{
return IsValid();
}
2026-10-04 00:04:20 +08:00
// 重载运算符号!=
2026-09-28 15:28:50 +08:00
inline bool CKTAdsEntity::operator!=(const CKTAdsEntity& adsEnt) const
{
return !(operator==(adsEnt));
}
inline bool CKTAdsEntity::operator!=(const AcDbObjectId& idEnt) const
{
return !(operator==(idEnt));
}
inline bool CKTAdsEntity::operator!=(const AcDbHandle& handle) const
{
return !(operator==(handle));
}
inline bool CKTAdsEntity::operator!=(const ads_name adsName) const
{
return !(operator==(adsName));
}
inline bool CKTAdsEntity::operator!=(int iNull) const
{
return !(operator==(iNull));
}
#endif // __KTADSENTITY_H__