Files
gjm 164968b62e chore
把非utf8-bom编码的cpp/h文件改为 utf8 bom 编码, msvc识别utf8编码时,如果不是bom格式的,会使用当前cp_oem来解码.
2026-10-04 00:04:20 +08:00

202 lines
5.2 KiB
C++

#include "stdafx.h"
#include "TDbInterfaceMsgWrite.h"
#include "TDbInterfaceMsgObj.h"
#include "TDbMakeObjAssocReactor.h"
#include "TInterfaceModifyMsgContext.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
extern TDbMakeObjAssocReactor* g_pObjAssocReactor;
extern TInterfaceModifyMsgContext g_iMsgContext;
extern TDbXDataMap g_mapClass2Cmd;
TDbInterfaceMsgWrite::TDbInterfaceMsgWrite()
{
if (g_pObjAssocReactor != NULL)
acdbCurDwg()->removeReactor(g_pObjAssocReactor);
}
TDbInterfaceMsgWrite::~TDbInterfaceMsgWrite()
{
if (g_pObjAssocReactor != NULL)
acdbCurDwg()->addReactor(g_pObjAssocReactor);
}
BOOL TDbInterfaceMsgWrite::WriteInterfaceMsg(const TInterfaceModifyMsg& iModifyMsg)
{
/*
在有对象更改时,写入消息到全局数据对象; 启动一个命令开始时清空数据
*/
//对大数量的试题操作处理优化标记,不需要写入消息
int nMaxSetForOp = 0;
g_mapClass2Cmd.GetAt(KEY_MAX_SET_FOROP,nMaxSetForOp);
if (nMaxSetForOp == 2) //优化批量处理interfacerecord 的 update消息
{
AcDbObjectIdArray arSet;
acedGetCurrentSelectionSet(arSet);
// mcl changed. 优化处理时,要更新遮挡
// if (arSet.length() > MAX_SET_FOROP)
if (arSet.length() > MAX_SET_FOROP && iModifyMsg.GetInterfaceOper() != TDb::eUpdateCover)
return FALSE;
else
g_mapClass2Cmd.SetAt(KEY_MAX_SET_FOROP, 0);
}
CPtrArray* pArray = NULL;
if (g_iMsgContext.m_mapDb2TIMsgs.Lookup(acdbCurDwg(),(void*&)pArray))
{
TDbInterfaceMsgObj* pMsgObj = new TDbInterfaceMsgObj;
pMsgObj->SetModifyMsg(iModifyMsg);
pArray->Add(pMsgObj);
}
else
{
pArray = new CPtrArray;
TDbInterfaceMsgObj* pMsgObj = new TDbInterfaceMsgObj;
pMsgObj->SetModifyMsg(iModifyMsg);
pArray->Add(pMsgObj);
g_iMsgContext.m_mapDb2TIMsgs.SetAt(acdbCurDwg(),pArray);
}
return TRUE;
}
BOOL TDbInterfaceMsgWrite::ReadInterfaceMsgs(TInterfaceModifyMsgs& msgs)
{
/*
命令反应器,等需要从数据库的命名字典读取消息更改集
*/
CPtrArray* pArray = NULL;
if (g_iMsgContext.m_mapDb2TIMsgs.Lookup(acdbCurDwg(),(void*&)pArray))
{
TDbInterfaceMsgObj* pMsgObj = NULL;
TInterfaceModifyMsg msg;
for (int i = 0;i < pArray->GetSize();i++)
{
pMsgObj = (TDbInterfaceMsgObj*)pArray->GetAt(i);
pMsgObj->GetModifyMsg(msg);
msgs.append(msg);
delete pMsgObj;
}
pArray->RemoveAll();
}
return msgs.length() > 0;
}
BOOL TDbInterfaceMsgWrite::WriteUpdateIntfMsg(const TInterfaceModifyMsg& iModifyMsg)
{
/*
在有对象更改时,写入消息到全局数据对象; 启动一个命令开始时清空数据
*/
//对大数量的试题操作处理优化标记,不需要写入消息
int nMaxSetForOp = 0;
g_mapClass2Cmd.GetAt(KEY_MAX_SET_FOROP,nMaxSetForOp);
if (nMaxSetForOp == 2) //优化批量处理interfacerecord 的 update消息
{
AcDbObjectIdArray arSet;
acedGetCurrentSelectionSet(arSet);
if (arSet.length() > MAX_SET_FOROP)
return FALSE;
else
g_mapClass2Cmd.SetAt(KEY_MAX_SET_FOROP, 0);
}
CPtrArray* pArray = NULL;
if (g_iMsgContext.m_mapDb2TUMsgs.Lookup(acdbCurDwg(),(void*&)pArray))
{
TDbInterfaceMsgObj* pMsgObj = new TDbInterfaceMsgObj;
pMsgObj->SetModifyMsg(iModifyMsg);
pArray->Add(pMsgObj);
}
else
{
pArray = new CPtrArray;
TDbInterfaceMsgObj* pMsgObj = new TDbInterfaceMsgObj;
pMsgObj->SetModifyMsg(iModifyMsg);
pArray->Add(pMsgObj);
g_iMsgContext.m_mapDb2TUMsgs.SetAt(acdbCurDwg(),pArray);
}
return TRUE;
}
BOOL TDbInterfaceMsgWrite::ReadUpdateIntfMsgs(TInterfaceModifyMsgs& msgs)
{
/*
命令反应器,等需要从数据库的命名字典读取消息更改集
*/
CPtrArray* pArray = NULL;
if (g_iMsgContext.m_mapDb2TUMsgs.Lookup(acdbCurDwg(),(void*&)pArray))
{
TDbInterfaceMsgObj* pMsgObj = NULL;
TInterfaceModifyMsg msg;
for (int i = 0;i < pArray->GetSize();i++)
{
pMsgObj = (TDbInterfaceMsgObj*)pArray->GetAt(i);
if (pMsgObj != NULL)
{
pMsgObj->GetModifyMsg(msg);
msgs.append(msg);
delete pMsgObj;
}
}
pArray->RemoveAll();
}
return msgs.length() > 0;
}
BOOL TDbInterfaceMsgWrite::WriteAssocMsg(const TMakeObjAssocMsg& iModifyMsg)
{
/*
在有对象更改时,写入消息到全局数据对象; 启动一个命令开始时清空数据
*/
CPtrArray* pArray = NULL;
if (g_iMsgContext.m_mapDb2TAMsgs.Lookup(acdbCurDwg(),(void*&)pArray))
{
TDbInterfaceMsgObj* pMsgObj = new TDbInterfaceMsgObj;
pMsgObj->SetAssocMsg(iModifyMsg);
pArray->Add(pMsgObj);
}
else
{
pArray = new CPtrArray;
TDbInterfaceMsgObj* pMsgObj = new TDbInterfaceMsgObj;
pMsgObj->SetAssocMsg(iModifyMsg);
pArray->Add(pMsgObj);
g_iMsgContext.m_mapDb2TAMsgs.SetAt(acdbCurDwg(),pArray);
}
return TRUE;
}
BOOL TDbInterfaceMsgWrite::ReadAssocMsgs(TMakeObjAssocMsgs& msgs)
{
/*
命令反应器,等需要从数据库的命名字典读取消息更改集
*/
CPtrArray* pArray = NULL;
if (g_iMsgContext.m_mapDb2TAMsgs.Lookup(acdbCurDwg(),(void*&)pArray))
{
TDbInterfaceMsgObj* pMsgObj = NULL;
TMakeObjAssocMsg msg;
for (int i = 0;i < pArray->GetSize();i++)
{
pMsgObj = (TDbInterfaceMsgObj*)pArray->GetAt(i);
if (pMsgObj != NULL)
{
pMsgObj->GetAssocMsg(msg);
msgs.append(msg);
delete pMsgObj;
}
}
pArray->RemoveAll();
}
return msgs.length() > 0;
}