//-------------------------------------------------------------------------------------------------------+ // Copyright (C), 1998-2007, SH Software Co. Ltd. // = FileName : Entity 类 // = Version : ver2.0 // = Author : zjq // = CreateDate : 2002-09-09 // = Description: Entity 声明 // = Maintainers: // //-------------------------------------------------------------------------------------------------------+ #ifndef _ENTITY_H_ #define _ENTITY_H_ #ifndef _RBLIST_H_ #include "RBList.h" #endif #ifndef _XPOINT_H_ #include "XPoint.h" #endif #ifndef _GROUPS_H_ #include "Groups.h" #endif class XPoint; class PickSet; class GEOAPI Entity : public RBList { public: Entity(); Entity(const ads_name n); Entity(const Entity &ent); Entity(LPCTSTR handle); ~Entity(); void operator = (const ads_name n); void operator = (const Entity &n); int operator !() const; void operator > (ads_name entother) const; int operator == (const ads_name ent) const; int operator == (const Entity &ent) const; operator LONG_PTR *(); operator void *(); // 下列函数没有采用ADS命名规则,不建议使用 int In(const PickSet *pSelectionSet); int Redraw(int mode = 1) const; int RedrawAll(int mode = 1) const; int Delete() const; int Update() const; int Erase() const; // member functions about groups int Make(); int Modify() const; int _GetGroups(); // member functions that can get a Entity Name; int UserSelect(LPCTSTR prompt,ads_point pt); int UserSelect(LPCTSTR prompt = NULL); int UserSelect(LPCTSTR prompt,XPoint &pt); int FilterSelect(LPCTSTR prompt, const RBList &mask, ads_point res); int FilterSelect(LPCTSTR prompt, const RBList &mask); int FilterSelect1(ads_real distPrec, LPCTSTR prmpt, const RBList &mask, ads_point res = NULL); int GetLast(); int GetNext(const Entity &et); int CreateByHandle(LPCTSTR handle); int Handent(LPCTSTR handle); int handent(LPCTSTR handle); int GetData(int cd,void *buf); int SetData(int cd,...); int Make(int,...); int MakeEx(int, ...); int GetNext(); // member functions to implement Extended Data Access; static const TCHAR *ApplicationName; static int AssignAppName(const TCHAR *s); // 不建议使用 int GetGroups(int getEx = 1); int GetGroups(const TCHAR *appName); void FreeGroups(); // 采用ADS命名规则, 建议使用 int entgetx(); int entgetx(const TCHAR *appName); int Match(const RBList &exlist); int MatchEx(const Groups *tag, const Groups *data); int MatchEx(int tag, const TCHAR *data); int MatchEx(int tag, int data) ; int MatchEx(int tag, ads_real data); int MatchEx(int tag, const Groups * data); int MatchBase(const Groups &rb); int MatchBase(const RBList &baseList); int GetExtend(ads_point lowPt, ads_point upPt, ads_matrix mat = NULL); int GetExtend(ads_point cen, ads_real *x, ads_real *y, ads_real *z = NULL); int Is(const TCHAR *entType); int XTransform(ads_matrix mat); int Move(const XPoint & basept, XPoint & res) const; //动态拖动 int Rotate(const XPoint &src, ads_real *res = NULL) const; int Scale(const XPoint &src, ads_real *res = NULL) const; Groups * SearchByTagCode(int tag_code); Groups * SearchDataByTag(int tag); // 扩充实体的操作 int GetInt (int tag_code, int &buf); int GetReal(int tag_code, ads_real &buf); int GetRString(int tag_cdoe,TCHAR *&buf); int GetString (int tag_code,TCHAR *buf); int GetPoint(int tag_code, XPoint &buf); int GetRBinary(int tag_code, short &nBufLen, const char * &buf); int SetInt (int tag_code,int buf); int SetReal(int tag_code,ads_real buf); int SetString (int tag_code, const TCHAR *buf, int isHandle = 0); int SetPoint(int tag_code, const XPoint &buf); int SetBinary(int tag_code, short nBufLen, const char * buf); // API 2.0 // support simple type string & int & real int SetExData(int tag_code,...); int GetExData(int tag_code,void *buf); // 删除指定的扩充实体数据 int DeleteTag(int tag_code); int RemoveXData(); int SetStruct(void *buf,int len, int tag_code = EX_STRUCT); int GetStruct(void *buf,int len, int tag_code = EX_STRUCT); public: ads_name name; PGroups groupsEx; private: int CreateTag(void *buf,int tag_code,int type); void _MakeExGroups(); }; typedef Entity EntityEx; inline void Entity::operator = (const ads_name n) { FreeGroups(); name[0] = n[0]; name[1] = n[1]; } inline void Entity::operator = (const Entity &n) { FreeGroups(); *this = n.name; } inline void Entity::operator > (ads_name entother) const { *entother = *name; entother[1] = name[1]; } inline int Entity::operator == (const ads_name ent) const { return *name == *ent && name[1] == ent[1]; } inline int Entity::operator == (const Entity &ent) const { return *this == ent.name; } inline int Entity::operator !() const { return !*name && !name[1]; // return ADSName::operator !(); } inline Entity::operator LONG_PTR *() { return name; } inline Entity::operator void *() { return name; } inline Entity::Entity() : groupsEx(0) { *name = name[1] = 0; } inline Entity::Entity(const ads_name n): groupsEx(0) { name[0] = n[0]; name[1] = n[1]; } inline Entity::Entity(const Entity &ent): groupsEx(0) { name[0] = ent.name[0]; name[1] = ent.name[1]; } inline Entity::Entity(LPCTSTR handle): groupsEx(0) { name[0] = name[1] = 0; ads_handent((LPCTSTR)handle,name); } inline int Entity::Delete() const { return ads_entdel(name); } inline int Entity::UserSelect(LPCTSTR prompt,XPoint &pt) { return UserSelect(prompt,(double*)&pt); } inline int Entity::GetLast() { FreeGroups(); return (ads_entlast(name)); } inline int Entity::Modify() const { return (ads_entmod((struct resbuf *)groups)); } inline int Entity::Update() const { return (ads_entupd(name)); } inline int Entity::GetNext(const Entity &et) { FreeGroups(); return (ads_entnext(et.name,name)); } inline int Entity::CreateByHandle(LPCTSTR handle) { return (ads_handent(handle,name)); } inline int Entity::UserSelect(LPCTSTR prompt,ads_point pt) { FreeGroups(); return (ads_entsel(prompt,name,pt)); } inline int Entity::UserSelect(LPCTSTR prompt) { FreeGroups(); ads_point pt; return (ads_entsel(prompt,name,pt)); } inline int Entity::Redraw(int mode) const { return (ads_redraw(name,mode)); } inline int Entity::Handent(LPCTSTR handle) { FreeGroups(); return ads_handent((LPCTSTR)handle,name); } inline int Entity::handent(LPCTSTR handle) { FreeGroups(); return ads_handent((LPTSTR)handle,name); } inline int Entity::GetData(int cd,void *buf) { if (!groups) { _GetGroups(); } return RBList::GetData(cd,buf); } inline Groups * Entity::SearchDataByTag(int tag) { Groups *rbTag = SearchByTagCode(tag); if(!rbTag) { return NULL; } return rbTag->next; } inline int Entity::GetNext() { Entity e = *this; return GetNext(e); } inline void Entity::FreeGroups() { groupsEx = NULL; RBList::FreeGroups(); } inline int Entity::entgetx() { return GetGroups(); } inline int Entity::entgetx(const TCHAR *appName) { return GetGroups((TCHAR *)appName); } inline int Entity::Is(const TCHAR *entType) { TCHAR eType[40]; if(GetData(0, eType) == RTNORM && _tcsicmp(eType, entType) == 0) { return 1; } return 0; } #endif