2604 lines
66 KiB
C++
2604 lines
66 KiB
C++
#include "stdafx.h"
|
||
#include "resource.h"
|
||
#include "TextStyleDlg.h"
|
||
#include "GridSheetDlg.h"
|
||
#include "SelectSheetDlg.h"
|
||
#include "OpeningLabelData.h"
|
||
#include "Project.h"
|
||
|
||
Adesk::Boolean acedPostCommand(const TCHAR * );
|
||
|
||
// add by xlc on 110307 记录门窗标默认设置
|
||
static BOOL s_bTextAsOp = FALSE;
|
||
static BOOL s_bBlock = TRUE;
|
||
|
||
//从指定构件库中加载构件,外部释放
|
||
AcDbEntity* LoadGJKEntity(XString sBlockName)
|
||
{
|
||
AcDbEntity *pEntRes=NULL;
|
||
|
||
XString sBlockName1;
|
||
if(LoadDwbBlock(sBlockName,sBlockName1) == RTNORM)
|
||
{
|
||
AcDbDatabase *pDatabase = acdbHostApplicationServices()->workingDatabase();
|
||
AcDbBlockTable *pBlkTable = NULL;
|
||
pDatabase->getBlockTable(pBlkTable,AcDb::kForRead);
|
||
if(pBlkTable!=NULL)
|
||
{
|
||
AcDbBlockTableRecord *pBlkTableRec = NULL;
|
||
pBlkTable->getAt(sBlockName1,pBlkTableRec,AcDb::kForRead);
|
||
pBlkTable->close();
|
||
|
||
if(pBlkTableRec!=NULL)
|
||
{
|
||
AcDbBlockTableRecordIterator *pBlkTableRecIte = NULL;
|
||
pBlkTableRec->newIterator(pBlkTableRecIte);
|
||
if(pBlkTableRecIte!=NULL)
|
||
{
|
||
for (pBlkTableRecIte->start();!pBlkTableRecIte->done();pBlkTableRecIte->step())
|
||
{
|
||
AcDbEntity *pEnt = NULL;
|
||
pBlkTableRecIte->getEntity(pEnt,AcDb::kForRead);
|
||
if(pEnt != NULL)
|
||
{
|
||
pEntRes=(AcDbEntity*)pEnt->clone();
|
||
pEnt->close();
|
||
break;
|
||
}
|
||
}
|
||
delete pBlkTableRecIte;
|
||
}
|
||
|
||
if (pBlkTableRec->upgradeOpen() == Acad::eOk)
|
||
pBlkTableRec->erase();
|
||
|
||
pBlkTableRec->close();
|
||
}
|
||
}
|
||
}
|
||
|
||
TEntityBase *pTEnt=TEntityBase::Cast(pEntRes);
|
||
if(pTEnt!=NULL)
|
||
pTEnt->SetPScale(DocGetPScale());//设为当前比例,071024
|
||
return pEntRes;
|
||
}
|
||
|
||
//extern TARCH_IMPEXP int DragMovePickSet(PickSet &ss, const TCHAR *pszPrompt, const XPoint &ptBase, XPoint &ptFinal);
|
||
|
||
//extern BOOL TARCH_IMPEXP StrToIntList(const TCHAR * pszDesc, DList<int> &lstResult);
|
||
|
||
|
||
|
||
/////////////////////////////////////////////////////////////////////////
|
||
// 统计门窗表 <dwg>.op
|
||
class TOpeningTableItem {
|
||
// int operator == (const TOpeningTableItem *p1, const XOpenignData *p2);
|
||
public:
|
||
XString m_sTypeCode, m_sOpKind, m_sSize;
|
||
int m_nCount;
|
||
DList<int> m_lstCount; //keep the number of the openings in every story
|
||
DList<int> m_lstLayCnt;
|
||
public:
|
||
TOpeningTableItem():m_nCount(1) {}
|
||
TOpeningTableItem(const TDbOpening &src);
|
||
TOpeningTableItem(const TDbCornerWin &src);
|
||
TOpeningTableItem(const TDbDormer &src);
|
||
TOpeningTableItem(const TOpeningTableItem &src);
|
||
TOpeningTableItem & operator = (const TOpeningTableItem &src);
|
||
static int CompareForFindByCode(const TOpeningTableItem *, const void *);
|
||
static int CompareForSortByCode(const TOpeningTableItem *, const TOpeningTableItem *);
|
||
static int CompareForFindByData(const TOpeningTableItem *p1, const void *pv2);
|
||
const TCHAR *GetLength();
|
||
const TCHAR* GetWidth();
|
||
};
|
||
const TCHAR* TOpeningTableItem::GetLength()
|
||
{
|
||
CString sSize(m_sSize);
|
||
int i=sSize.Find(_T('X'));
|
||
return sSize.Left(i);
|
||
}
|
||
const TCHAR* TOpeningTableItem::GetWidth()
|
||
{
|
||
CString sSize(m_sSize);
|
||
int i=sSize.Find(_T('X'));
|
||
return sSize.Right(sSize.GetLength()-1-i);
|
||
}
|
||
int operator== (const TOpeningTableItem &p1, const TOpeningTableItem &p2)
|
||
{
|
||
return (_tcsicmp(p1.m_sTypeCode, p2.m_sTypeCode)==0 &&
|
||
_tcscmp(p1.m_sOpKind, p2.m_sOpKind)==0 &&
|
||
_tcscmp(p1.m_sSize, p2.m_sSize)==0);
|
||
}
|
||
|
||
TOpeningTableItem::TOpeningTableItem(const TOpeningTableItem &src)
|
||
{
|
||
*this = src;
|
||
}
|
||
|
||
TOpeningTableItem::TOpeningTableItem(const TDbOpening &src)
|
||
:m_nCount(1)
|
||
{
|
||
m_sTypeCode = src.m_sLabel;
|
||
|
||
// modify by xlc on 110307 设置门窗子类型
|
||
//m_sOpKind = src.GetKindString();
|
||
m_sOpKind = src.GetSubKind();
|
||
if (_tcsicmp(m_sOpKind, _T("墙洞")) == 0)
|
||
{
|
||
m_sOpKind = _T("洞口");
|
||
}
|
||
else if (_tcsicmp(m_sOpKind, _T("组合门")) == 0)
|
||
{
|
||
m_sOpKind = _T("组合门窗");
|
||
}
|
||
else if (_tcsicmp(m_sOpKind, _T("组合窗")) == 0)
|
||
{
|
||
m_sOpKind = _T("组合门窗");
|
||
}
|
||
//wlw add 131114 如果是洞口,部院专版有问题。GetSubKind()在fd.GFD(_T("门窗用途"), csSubKind);函数会把洞口返回成普通门
|
||
if (src.GetKind() == TOpeningData::OP_HOLE)
|
||
{
|
||
m_sOpKind = _T("洞口");
|
||
}
|
||
|
||
m_sSize = XString(_T("%dX%d"), AS_INT(src.GetWidth()), AS_INT(src.GetHeight()));
|
||
}
|
||
|
||
|
||
TOpeningTableItem::TOpeningTableItem(const TDbCornerWin &src)
|
||
:m_nCount(1)
|
||
{
|
||
m_sTypeCode = src.GetLabel();
|
||
m_sOpKind = src.GetKindString();
|
||
if(src.isKindOf(TDbBandWin::desc()))//带形窗
|
||
{
|
||
TDbBandWin& banWin=(TDbBandWin&)src;
|
||
// sg modify 120514,根据9.0需求,带形窗宽度的测量改用中心线
|
||
//m_sSize = XString(_T("%dX%d"), AS_INT(banWin.GetWidth()), AS_INT(src.GetHeight()));
|
||
m_sSize = XString(_T("%dX%d"), AS_INT(banWin.GetGeomCenterWidth()), AS_INT(src.GetHeight()));
|
||
}
|
||
else
|
||
{
|
||
// sg modify 120514,根据9.0需求,转角窗宽度的测量要根据编号设置,分别按阴角、中线、阳角分别读取
|
||
// m_sSize = XString(_T("(%d+%d)X%d"), AS_INT(src.GetWidth1()), AS_INT(src.GetWidth2()), AS_INT(src.GetHeight()));
|
||
TOpeningLabelData labelData;
|
||
TOpeningLabelData::ECalWidthRule nRule = labelData.GetCalWidthRule();
|
||
|
||
double dWidth1 = src.GetWidth1(),
|
||
dWidth2 = src.GetWidth2();
|
||
if (nRule == TOpeningLabelData::kMiddle)
|
||
{
|
||
dWidth1 = dWidth1 + fabs(src.GetWallThick2())*0.5;
|
||
dWidth2 = dWidth2 + fabs(src.GetWallThick1())*0.5;
|
||
}
|
||
else if (nRule == TOpeningLabelData::kOutboard)
|
||
{
|
||
dWidth1 = dWidth1 + fabs(src.GetWallThick2());
|
||
dWidth2 = dWidth2 + fabs(src.GetWallThick1());
|
||
}
|
||
m_sSize = XString(_T("(%d+%d)X%d"), AS_INT(dWidth1), AS_INT(dWidth2), AS_INT(src.GetHeight()));
|
||
}
|
||
}
|
||
|
||
TOpeningTableItem::TOpeningTableItem(const TDbDormer &src)
|
||
:m_nCount(1)
|
||
{
|
||
m_sTypeCode = src.GetLabel();
|
||
m_sOpKind = _T("老虎窗");
|
||
m_sSize = XString(_T("%dX%d"), AS_INT(src.GetDormerPar().GetWindowWidth()),
|
||
AS_INT(src.GetDormerPar().GetWindowHeight()));
|
||
}
|
||
|
||
TOpeningTableItem & TOpeningTableItem:: operator = (const TOpeningTableItem &src)
|
||
{
|
||
m_sTypeCode = src.m_sTypeCode;
|
||
m_sOpKind = src.m_sOpKind;
|
||
m_sSize = src.m_sSize;
|
||
m_nCount = src.m_nCount;
|
||
return *this;
|
||
}
|
||
|
||
int TOpeningTableItem::CompareForFindByCode(const TOpeningTableItem *p1, const void *pv2)
|
||
{
|
||
const TCHAR *p2=(const TCHAR *)pv2;
|
||
return _tcsicmp(p1->m_sTypeCode, p2);
|
||
}
|
||
|
||
int TOpeningTableItem::CompareForFindByData(const TOpeningTableItem *p1, const void *pv2)
|
||
{
|
||
const TOpeningTableItem *p2=(const TOpeningTableItem *)pv2;
|
||
if(*p1 == *p2) return 0;
|
||
return 1;
|
||
}
|
||
|
||
// 逆序输出
|
||
static const TCHAR *g_szOpKind[]={_T("墙洞"),_T("组合门"),_T("子母门"),_T("门连窗"),_T("门"),_T("老虎窗"),_T("带形窗"),_T("转角窗"),_T("组合窗"),_T("弧窗"),_T("凸窗"),_T("窗")};
|
||
int GetSeqCode(const TCHAR *szKind)
|
||
{
|
||
int nSeqCode=-1;
|
||
for(int i=0;i<ELEMENTS(g_szOpKind);i++) {
|
||
if(_tcscmp(szKind, g_szOpKind[i])==0) {
|
||
nSeqCode=i;
|
||
break;
|
||
}
|
||
}
|
||
return nSeqCode;
|
||
}
|
||
// 正序输出,add by whl
|
||
static const TCHAR *g_szOpKind2[]={_T("墙洞"),_T("老虎窗"),_T("带形窗"),_T("转角窗"),_T("组合窗"),_T("弧窗"),_T("凸窗"),_T("窗"),_T("组合门"),_T("子母门"),_T("门连窗"),_T("门")};
|
||
int GetSeqCode2(const TCHAR *szKind)
|
||
{
|
||
int nSeqCode=-1;
|
||
//modify by xlc on 110307 调整输出顺序
|
||
//for(int i=0;i<ELEMENTS(g_szOpKind2);i++) {
|
||
// if(_tcscmp(szKind, g_szOpKind2[i])==0) {
|
||
// nSeqCode=i;
|
||
// break;
|
||
// }
|
||
//}
|
||
|
||
TOpeningLabelData labelData;
|
||
CStringArray arrAllSubType;
|
||
if(labelData.GetAllOpeningType(arrAllSubType))
|
||
{
|
||
for (int i = 0; i < arrAllSubType.GetSize(); i++)
|
||
{
|
||
if (_tcscmp(szKind, arrAllSubType[i]) == 0)
|
||
{
|
||
nSeqCode = arrAllSubType.GetSize() - 1 - i;
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
|
||
return nSeqCode;
|
||
}
|
||
bool g_bWinFirst=FALSE;
|
||
int TOpeningTableItem::CompareForSortByCode(const TOpeningTableItem *p1, const TOpeningTableItem *p2)
|
||
{
|
||
if(g_bWinFirst)
|
||
{
|
||
int nSeqCode1=GetSeqCode(p1->m_sOpKind);
|
||
int nSeqCode2=GetSeqCode(p2->m_sOpKind);
|
||
if(nSeqCode1>nSeqCode2)
|
||
return -1;
|
||
else if(nSeqCode1<nSeqCode2)
|
||
return 1;
|
||
return CmpLabel(p1->m_sTypeCode, p2->m_sTypeCode);
|
||
}
|
||
else
|
||
{
|
||
int nSeqCode1=GetSeqCode2(p1->m_sOpKind);
|
||
int nSeqCode2=GetSeqCode2(p2->m_sOpKind);
|
||
if(nSeqCode1>nSeqCode2)
|
||
return -1;
|
||
else if(nSeqCode1<nSeqCode2)
|
||
return 1;
|
||
return CmpLabel(p1->m_sTypeCode, p2->m_sTypeCode);
|
||
}
|
||
}
|
||
|
||
BOOL IsTextAsOpening(AcDbObjectId id, // [in] 对象句柄
|
||
CString &strOpKind, // [out]门窗类型
|
||
CString &strTypeCode, // [out]门窗标号
|
||
CString &strSize) // [out]洞口尺寸
|
||
{
|
||
strTypeCode = _T("");
|
||
strOpKind = _T("");
|
||
strSize = _T("");
|
||
|
||
CString csLayer; // 获取图层
|
||
{
|
||
XDbObject obj(id, AcDb::kForRead);
|
||
if (!obj)
|
||
{
|
||
return FALSE; // 无法打开实体
|
||
}
|
||
|
||
TDbText *pTgText = TDbText::cast(obj.m_pObject);
|
||
if (pTgText != NULL)
|
||
{
|
||
csLayer = pTgText->layer();
|
||
strTypeCode = pTgText->GetText();
|
||
}
|
||
else
|
||
{
|
||
AcDbText *pCadText = AcDbText::cast(obj.m_pObject);
|
||
if (pCadText != NULL)
|
||
{
|
||
csLayer = pCadText->layer();
|
||
strTypeCode = pCadText->textString();
|
||
}
|
||
else
|
||
{
|
||
return FALSE; // 实体类型错误
|
||
}
|
||
}
|
||
}
|
||
|
||
XString strRefDim1(_T("|%s"), LAY_OPENING_DIM);
|
||
XString strRefDim2(_T("$%s"), LAY_OPENING_DIM);
|
||
XString strRefDim3(_T("|%s"), LAY_FILEOPENING_DIM);
|
||
XString strRefDim4(_T("$%s"), LAY_FILEOPENING_DIM);
|
||
|
||
if ((_tcsicmp(csLayer, LAY_OPENING_DIM)!=0 && _tcsicmp(csLayer, LAY_FILEOPENING_DIM)!=0
|
||
&& csLayer.Find(strRefDim1) == -1
|
||
&& csLayer.Find(strRefDim2) == -1
|
||
&& csLayer.Find(strRefDim3) == -1
|
||
&& csLayer.Find(strRefDim4) == -1) ||
|
||
strTypeCode.IsEmpty())
|
||
{
|
||
return FALSE; // 验证是否在指定图层上,验证编号是否为空
|
||
}
|
||
|
||
|
||
// 拆分字符串
|
||
CString csTmp, csLabel, csSize;
|
||
int nLength = strTypeCode.GetLength(),
|
||
nFind(-1),nFindEnd(-1);
|
||
for (int i=0; i<nLength; i++)
|
||
{
|
||
csTmp = strTypeCode.Mid(i, 1);
|
||
if (!csTmp.CompareNoCase(_T("甲")))
|
||
{//IsDigital函数对甲有bug,过滤甲字
|
||
continue;
|
||
}
|
||
if (IsDigital(csTmp))
|
||
{
|
||
if (nFind < 0)
|
||
{
|
||
nFind = i; // 找到第1个数字后结束
|
||
}
|
||
nFindEnd = i; //找到最后一个数字wlw
|
||
continue;
|
||
}
|
||
}
|
||
|
||
// 全部数字或者全部字母,得不到类型或尺寸,只统计个数
|
||
if (nFind==0 || nFind==-1)
|
||
{
|
||
return TRUE;
|
||
}
|
||
|
||
csSize = strTypeCode.Mid(nFind, nFindEnd - nFind + 1);// 尺寸wlw 13.11.11
|
||
//csSize = strTypeCode.Right(nLength - nFind); // 尺寸
|
||
csLabel = strTypeCode.Left(nFind); // 标号
|
||
csTmp = csLabel.Right(1);
|
||
if (_tcsicmp(csTmp, _T("-")) == 0) // 判断是否包含连字符
|
||
{
|
||
csLabel = csLabel.Left(i - 1);
|
||
}
|
||
|
||
|
||
// 解析类型和标号
|
||
TOpeningLabelData data;
|
||
CStringArray arCsLabel, arCsSubType;
|
||
data.GetTypeByLabel(csLabel, arCsLabel, arCsSubType);
|
||
|
||
nLength = arCsSubType.GetSize();
|
||
if (nLength > 0)
|
||
{
|
||
strOpKind = arCsSubType[0];
|
||
//return TRUE; // 类型不在当前标准中,只统计个数 wlw 13.11.11
|
||
}
|
||
|
||
|
||
// 解析洞口尺寸
|
||
nLength = csSize.GetLength();
|
||
if (nLength > 3) // 按顺序标注
|
||
{
|
||
csTmp = csSize.Left(nLength - 2); // 宽度
|
||
csLabel = csSize.Right(2); // 高度
|
||
|
||
int nWidth = _ttoi(csTmp),
|
||
nHeight = _ttoi(csLabel);
|
||
nWidth *= 100;
|
||
nHeight *= 100;
|
||
strSize.Format(_T("%dX%d"), AS_INT(nWidth), AS_INT(nHeight));
|
||
}
|
||
return TRUE;
|
||
}
|
||
|
||
//////////////////////////////////////////////////////
|
||
// 统计门窗表(DList<AcDbObjectId>)
|
||
int StaticOpeningsFromDatabase(DList<AcDbObjectId>& ssOpenings, DList<TOpeningTableItem> &lstOpenings)
|
||
{
|
||
long lCount=ssOpenings.Length();
|
||
for(long i=0L; i<lCount; i++)
|
||
{
|
||
AcDbObjectId &ent = *ssOpenings[i];
|
||
XDbObject obj(ent, AcDb::kForRead);
|
||
if(!obj) continue;
|
||
TDbOpening *pOpening=TDbOpening::cast(obj.m_pObject);
|
||
TDbCornerWin *pWin=TDbCornerWin::cast(obj.m_pObject);
|
||
TDbDormer *pDormer=TDbDormer::cast(obj.m_pObject);
|
||
|
||
TOpeningTableItem *pData1=NULL;
|
||
XString sCode;
|
||
|
||
bool bOpeningText = FALSE;
|
||
CString strOpKind,strTypeCode,strSize;
|
||
if(!pWin && !pOpening && !pDormer)
|
||
{
|
||
// add by xlc on 110307 增加作为门窗的文字
|
||
if (IsTextAsOpening(ent, strOpKind, strTypeCode,strSize))
|
||
{
|
||
bOpeningText = TRUE;
|
||
pData1 = new TOpeningTableItem();
|
||
pData1->m_sOpKind = strOpKind;
|
||
pData1->m_sTypeCode= strTypeCode;
|
||
pData1->m_sSize = strSize;
|
||
}
|
||
else
|
||
|
||
continue;
|
||
}
|
||
|
||
if (!bOpeningText)
|
||
{
|
||
if(pWin) {
|
||
if(!pWin->Has3D())
|
||
continue;
|
||
sCode=pWin->GetLabel();
|
||
if(!sCode) {
|
||
adsout << _T("\n发现没有编号的转角窗!");
|
||
}
|
||
pData1 = new TOpeningTableItem(*pWin);
|
||
} else if(pDormer) {
|
||
sCode=pDormer->GetLabel();
|
||
if(!sCode) {
|
||
adsout << _T("\n发现没有编号的老虎窗!");
|
||
}
|
||
pData1 = new TOpeningTableItem(*pDormer);
|
||
} else {
|
||
if(!pOpening->Has3D())
|
||
continue;
|
||
if(/*pOpening->GetKind()==TOpeningData::OP_CORNWIN || pOpening->GetKind()==TOpeningData::OP_HOLE ||*/
|
||
(pOpening->m_nOpStyle&OPS_LVTRY) || (pOpening->m_nOpStyle&OPS_LIFTDOOR))
|
||
continue; //电梯门,卫生隔断门不参加统计, Modified by whl on 040720,带形窗参加统计
|
||
if (_tcsicmp(pOpening->GetSubKind(), _T("隔断门"))==0 || _tcsicmp(pOpening->GetSubKind(), _T("电梯门"))==0)
|
||
continue;
|
||
//modified by whl on 050809,墙洞参加统计
|
||
sCode=pOpening->GetLabel();
|
||
if(!sCode) {
|
||
adsout << _T("\n发现没有编号的门窗!");
|
||
//continue;
|
||
}
|
||
pData1 = new TOpeningTableItem(*pOpening);
|
||
}
|
||
}
|
||
|
||
TOpeningTableItem *pData=lstOpenings.FindNode(pData1, TOpeningTableItem::CompareForFindByData);
|
||
if(!pData) { //没有发现相同数据的门窗
|
||
if(lstOpenings.FindNode((const TCHAR *)pData1->m_sTypeCode, TOpeningTableItem::CompareForFindByCode)) {
|
||
//但是发现编号相同的门窗
|
||
adsout << _T("\n编号为'") << sCode << _T("'的门窗参数不一致!");
|
||
}
|
||
lstOpenings.Append(pData1);
|
||
} else {
|
||
pData->m_nCount++;
|
||
delete pData1; //ZJQ add here on 2003/6/26
|
||
}
|
||
}
|
||
return RTNORM;
|
||
}
|
||
|
||
CString PathOfExternalRecord(const AcDbBlockTableRecord &blk)
|
||
{
|
||
if (blk.isFromExternalReference()) // 外部参照内
|
||
{
|
||
TCHAR *ss = NULL;
|
||
if (blk.pathName(ss) == Acad::eOk)
|
||
{
|
||
CString sPath(ss);
|
||
delete [] ss;
|
||
return sPath;
|
||
}
|
||
else return _T("");
|
||
}
|
||
|
||
return _T("");
|
||
}
|
||
|
||
namespace OPENINGTABLE
|
||
{
|
||
|
||
// 判断该地址是否为绝对路径。
|
||
// 判断方法:是否存在":"盘符
|
||
bool IsWholePath(const CString &strpath)
|
||
{
|
||
return strpath.Find(_T(":")) != -1;
|
||
}
|
||
|
||
// 相对路径处理成绝对路径
|
||
// strRelativePath:相对路径,strCurrDir:当前目录
|
||
CString DealToWholePath(const CString &strRelativePath, const CString &strCurrDir)
|
||
{
|
||
// strBackSlash是反过来的情形,对应于:"\.."
|
||
CString strSingleSlash = _T("\\"), strDoubleSlash = _T("\\\\"), strBackSlash = _T("..\\");
|
||
CString strWholePath = strCurrDir + strSingleSlash + strRelativePath;
|
||
|
||
// 处理掉“\\”情况
|
||
int nPos = strWholePath.Find(strDoubleSlash);
|
||
while (nPos != -1)
|
||
{
|
||
strWholePath.Replace(strDoubleSlash, strSingleSlash); //
|
||
nPos = strWholePath.Find(strDoubleSlash);
|
||
}
|
||
|
||
// 处理"..",这个需要退一级目录
|
||
strWholePath.MakeReverse();
|
||
nPos = strWholePath.Find(strBackSlash);
|
||
while (nPos != -1)
|
||
{
|
||
int nPosTemp = strWholePath.Find(strSingleSlash, nPos + 3);
|
||
if (nPosTemp != -1)
|
||
{
|
||
strWholePath.Delete(nPos, nPosTemp - nPos + 1);
|
||
}
|
||
|
||
nPos = strWholePath.Find(strBackSlash);
|
||
}
|
||
|
||
strWholePath.MakeReverse();
|
||
return strWholePath;
|
||
}
|
||
|
||
CString FilePathToDir(const CString &strFileFullPath)
|
||
{
|
||
int nPos = strFileFullPath.ReverseFind(_T('\\'));
|
||
if (nPos > 0)
|
||
{
|
||
return strFileFullPath.Mid(0, nPos);
|
||
}
|
||
else
|
||
return _T("");
|
||
}
|
||
|
||
// 从绝对路径中取得文件名称
|
||
CString GetFileName(const CString &strWholePath)
|
||
{
|
||
int nPos = strWholePath.ReverseFind(_T('\\'));
|
||
if (nPos != -1 && nPos != strWholePath.GetLength() - 1)
|
||
{
|
||
return strWholePath.Mid(nPos + 1, strWholePath.GetLength() - nPos);
|
||
}
|
||
else
|
||
{
|
||
return strWholePath;
|
||
}
|
||
}
|
||
}
|
||
|
||
//////////////////////////////////////////////////////
|
||
// 统计某个DWG中的门窗表
|
||
int StaticOpeningsFromDatabase(AcDbDatabase *db, DList<TOpeningTableItem> &lstOpenings,TProjectFloor* pFloor=NULL)
|
||
{
|
||
DList<AcDbObjectId> ssOpenings, ss;
|
||
Acad::ErrorStatus es1;
|
||
|
||
CString strRbList = _T("ATS_OPENING,ATS_CORNER_WINDOW,ATS_DORMER");
|
||
if (s_bTextAsOp)
|
||
strRbList += (_T(",ATS_TEXT,TEXT"));
|
||
if (s_bBlock)
|
||
strRbList += (_T(",TCH_INSERT,INSERT"));
|
||
|
||
|
||
if(pFloor==NULL||!pFloor->IsFloorInFrame())
|
||
{
|
||
//add by xlc on 110307 增加文字处理
|
||
// if (s_bTextAsOp)
|
||
// {
|
||
// es1=GetEntityFromDatabase(ssOpenings, *db, _T("ATS_OPENING,ATS_CORNER_WINDOW,ATS_DORMER,ATS_TEXT,TEXT"), 1, ACDB_MODEL_SPACE);
|
||
// }
|
||
// else
|
||
//
|
||
// {
|
||
// es1=GetEntityFromDatabase(ssOpenings, *db, _T("ATS_OPENING,ATS_CORNER_WINDOW,ATS_DORMER"), 1, ACDB_MODEL_SPACE);
|
||
// }
|
||
es1 = GetEntityFromDatabase(ss, *db, strRbList, 1, ACDB_MODEL_SPACE);
|
||
}
|
||
else
|
||
{
|
||
XPoint ptMin,ptMax;
|
||
pFloor->GetRange(ptMin,ptMax);
|
||
|
||
//add by xlc on 110307 增加文字处理
|
||
// if (s_bTextAsOp)
|
||
// {
|
||
// es1=GetEntityFromDatabase(ssOpenings, *db, _T("ATS_OPENING,ATS_CORNER_WINDOW,ATS_DORMER,ATS_TEXT,TEXT"), 1, ACDB_MODEL_SPACE,ptMin,ptMax);
|
||
// }
|
||
// else
|
||
//
|
||
// {
|
||
// es1=GetEntityFromDatabase(ssOpenings, *db, _T("ATS_OPENING,ATS_CORNER_WINDOW,ATS_DORMER"), 1, ACDB_MODEL_SPACE,ptMin,ptMax);
|
||
// }
|
||
es1=GetEntityFromDatabase(ss, *db, strRbList, 1, ACDB_MODEL_SPACE,ptMin,ptMax);
|
||
}
|
||
|
||
if(es1 != Acad::eOk) {
|
||
return RTERROR;
|
||
}
|
||
|
||
int lCount = ss.Length();
|
||
//wlw mod 2013.10.31 修改崩溃,删除const TCHAR *szFileName时有野指针.
|
||
CString szFName;
|
||
for(int i=0; i<lCount; i++)
|
||
{
|
||
const TCHAR *szFileName;
|
||
OPENOBJ_BEGIN(*ss[i], AcDb::kForRead, AcDbBlockReference, pRecRef)
|
||
if (pRecRef != NULL)
|
||
{
|
||
OPENOBJ_BEGIN(pRecRef->blockTableRecord(), AcDb::kForRead, AcDbBlockTableRecord, pRec)
|
||
// OPENOBJ_BEGIN(pRecRef->ownerId(), AcDb::kForRead, AcDbBlockTableRecord, pRec)
|
||
if (pRec != NULL)
|
||
{
|
||
szFName = PathOfExternalRecord(*pRec);
|
||
if (szFName != _T("") && !OPENINGTABLE::IsWholePath(szFName))
|
||
{
|
||
db->getFilename(szFileName);
|
||
szFName = OPENINGTABLE::DealToWholePath(szFName, OPENINGTABLE::FilePathToDir(CString(szFileName)));
|
||
}
|
||
|
||
if (szFName != _T(""))
|
||
{
|
||
AcDbDatabase dwgDb(false, true);
|
||
#if ADS < 21
|
||
if(dwgDb.readDwgFile(szFName, _SH_DENYNO, false)==Acad::eOk)
|
||
#else
|
||
if(dwgDb.readDwgFile(szFName, AcDbDatabase::kForReadAndAllShare, false)==Acad::eOk)
|
||
#endif
|
||
{
|
||
StaticOpeningsFromDatabase(&dwgDb, lstOpenings);
|
||
}
|
||
else
|
||
{
|
||
szFName = OPENINGTABLE::GetFileName(szFName);
|
||
const TCHAR *szFileName = NULL;
|
||
db->getFilename(szFileName);
|
||
szFName = OPENINGTABLE::DealToWholePath(szFName, OPENINGTABLE::FilePathToDir(CString(szFileName)));
|
||
#if ADS < 21
|
||
if(dwgDb.readDwgFile(szFName, _SH_DENYNO, false)==Acad::eOk)
|
||
#else
|
||
if(dwgDb.readDwgFile(szFName, AcDbDatabase::kForReadAndAllShare, false)==Acad::eOk)
|
||
#endif
|
||
{
|
||
StaticOpeningsFromDatabase(&dwgDb, lstOpenings);
|
||
}
|
||
}
|
||
}
|
||
else
|
||
{
|
||
AcDbBlockTableRecordIterator *pIter = NULL;
|
||
pRec->newIterator(pIter);
|
||
for (pIter->start(); !pIter->done(); pIter->step())
|
||
{
|
||
AcDbEntity *pEnt = NULL;
|
||
pIter->getEntity(pEnt, AcDb::kForRead);
|
||
if (pEnt->isKindOf(TDbOpening::desc())
|
||
|| pEnt->isKindOf(TDbCornerWin::desc())
|
||
|| pEnt->isKindOf(TDbDormer::desc())
|
||
|| (s_bTextAsOp && (pEnt->isKindOf(AcDbText::desc()) || pEnt->isKindOf(TDbText::desc()))))
|
||
{
|
||
ssOpenings.Append(new AcDbObjectId((AcDbStub*)(pEnt->id())));
|
||
}
|
||
|
||
pEnt->close();
|
||
}
|
||
}
|
||
}
|
||
OPENOBJ_END()
|
||
}
|
||
else
|
||
{
|
||
ssOpenings.Append(new AcDbObjectId(*ss[i]));
|
||
}
|
||
OPENOBJ_END()
|
||
}
|
||
|
||
StaticOpeningsFromDatabase(ssOpenings, lstOpenings);
|
||
|
||
return RTNORM;
|
||
}
|
||
|
||
|
||
//////////////////////////////////////////////////////////
|
||
//合并门窗表中相同单元格
|
||
void MergeOpSheet(TDbSheet*pSheet,long firstRow)
|
||
{
|
||
if(pSheet->GetColumnNum()<1)
|
||
return;
|
||
if(firstRow>=pSheet->GetRowNum())
|
||
return;
|
||
|
||
long iStart=firstRow;
|
||
TGridCell*pCell=(*pSheet)(iStart,0);
|
||
XString lastText=pCell->GetText();
|
||
for(long i=iStart+1;i<pSheet->GetRowNum();i++)
|
||
{
|
||
TGridCell *pCell=(*pSheet)(i,0);
|
||
if(lastText!=pCell->GetText())
|
||
{
|
||
if(i-iStart>1)//超过一行
|
||
pSheet->MergeCells(iStart,0,i-1,0);
|
||
|
||
lastText=pCell->GetText();
|
||
iStart=i;
|
||
}
|
||
}
|
||
if(i-iStart>1)//最后一次合并
|
||
pSheet->MergeCells(iStart,0,i-1,0);
|
||
}
|
||
//合并门窗表中nCol列的相同单元格
|
||
void MergeOpSheet(TDbSheet*pSheet,long firstRow,int nCol)
|
||
{
|
||
if(pSheet->GetColumnNum()<1)
|
||
return;
|
||
if(firstRow>=pSheet->GetRowNum())
|
||
return;
|
||
|
||
if(nCol<0||nCol>=pSheet->GetColumnNum())
|
||
return;
|
||
|
||
long iStart=firstRow;
|
||
TGridCell*pCell=(*pSheet)(iStart,nCol);
|
||
XString lastText=pCell->GetText();
|
||
for(long i=iStart+1;i<pSheet->GetRowNum();i++)
|
||
{
|
||
TGridCell *pCell=(*pSheet)(i,nCol);
|
||
if(lastText!=pCell->GetText())
|
||
{
|
||
if(i-iStart>1)//超过一行
|
||
pSheet->MergeCells(iStart,nCol,i-1,nCol);
|
||
|
||
lastText=pCell->GetText();
|
||
iStart=i;
|
||
}
|
||
}
|
||
if(i-iStart>1)//最后一次合并
|
||
pSheet->MergeCells(iStart,nCol,i-1,nCol);
|
||
}
|
||
|
||
// 统计门窗表, 对当前DWG
|
||
/*void StaticOpenings()
|
||
{
|
||
DList<TOpeningTableItem> lstOpenings;
|
||
PickSet ss(SS_FREE);
|
||
RBList mask(RTDXF0, _T("ATS_OPENING,ATS_CORNER_WINDOW,ATS_DORMER"), NULL);
|
||
g_ssPickFirst.Free();
|
||
if(SelectEntities(_T("\n请选择当前层门窗:"), ss, mask)!=RTNORM)
|
||
return;
|
||
{
|
||
long lCount = ss.Length();
|
||
DList<AcDbObjectId> ssOpenings;
|
||
for(long i=0L; i<lCount; i++) {
|
||
AcDbObjectId* pId = new AcDbObjectId;
|
||
acdbGetObjectId(*pId, ss[i]);
|
||
ssOpenings.Append(pId);
|
||
}
|
||
StaticOpeningsFromDatabase(ssOpenings, lstOpenings);
|
||
lstOpenings.QuickSort(TOpeningTableItem::CompareForSortByCode);
|
||
}
|
||
|
||
AcDbObjectId idTextStyle=InitTextStyle(TS_WDTABLE);
|
||
if(!idTextStyle)
|
||
return;
|
||
|
||
XPoint ptLoc;
|
||
TDbSheet *pSheet=new TDbSheet,*pNewSheet=new TDbSheet;
|
||
pSheet->SetRotation(Ucs2Wcs(0.0));
|
||
pNewSheet->SetRotation(Ucs2Wcs(0.0));
|
||
int nRowNum=lstOpenings.Length()+1;
|
||
pSheet->InitSheet(nRowNum, 8, 7.0, 14.0);
|
||
pNewSheet->InitSheet(nRowNum+1,8,7.0,14.0);
|
||
TSheetColumn column;
|
||
double nColWidthArray[8]={14.0, 22.0, 30.0, 10.0, 40.0, 12, 22.0, 50.0};
|
||
for(int m=0; m<8; m++) {
|
||
column.SetWidth(nColWidthArray[m]);
|
||
pSheet->SetColumnAt(m, column);
|
||
}
|
||
TSheetColumn column1;
|
||
double nColWidthArray1[8]={14.0, 22.0, 20.0, 20.0, 20.0, 40.0, 20.0, 50.0};
|
||
for(m=0; m<8; m++) {
|
||
column1.SetWidth(nColWidthArray1[m]);
|
||
pNewSheet->SetColumnAt(m, column1);
|
||
}
|
||
|
||
pSheet->SetTitleText(_T("门窗表"));
|
||
pNewSheet->SetTitleText(_T("门窗表"));
|
||
TGridStyle gridStyle;
|
||
gridStyle.SetOverrideAll(TRUE);
|
||
gridStyle.SetTextWrap(FALSE);
|
||
gridStyle.SetTextHeight(3.5);
|
||
gridStyle.SetHorMode(AcDb::kTextCenter);
|
||
gridStyle.SetVerMode(AcDb::kTextVertMid);
|
||
gridStyle.SetTextStyleId(idTextStyle);
|
||
pSheet->SetGridStyle(gridStyle);
|
||
pNewSheet->SetGridStyle(gridStyle);
|
||
|
||
TSheetTitle &title=pSheet->GetTitle();
|
||
title.SetHeight(16.0);
|
||
TSheetTitle &title1=pNewSheet->GetTitle();
|
||
title1.SetHeight(16.0);
|
||
TGridStyle &gStyle=title.GetGridStyle();
|
||
gStyle.SetFlagBit(OF_TEXTHEIGHT);
|
||
gStyle.SetTextHeight(8.0);
|
||
TGridStyle &gStyle1=title1.GetGridStyle();
|
||
gStyle1.SetFlagBit(OF_TEXTHEIGHT);
|
||
gStyle1.SetTextHeight(8.0);
|
||
|
||
TDividerStyle &dStyle=title.GetDividerStyle();
|
||
dStyle.SetDividerFlag(TDividerStyle::kNone);
|
||
TDividerStyle &dStyle1=title1.GetDividerStyle();
|
||
dStyle1.SetDividerFlag(TDividerStyle::kNone);
|
||
|
||
{
|
||
const TCHAR *szHeadText[8]={_T("类型"),_T("设计编号"), _T("洞口尺寸(mm)"), _T("数量"),_T("图集名称"),_T("页次"), _T("选用型号"), _T("备注")};
|
||
for(int k=0;k<8;k++) {
|
||
TGridCell *pCell=(*pSheet)(0, k);
|
||
TGridStyle &grStyle=pCell->GetGridStyle();
|
||
grStyle.SetFlagBit(OF_TEXTHEIGHT);
|
||
grStyle.SetTextHeight(4.0);
|
||
pCell->SetText(szHeadText[k]);
|
||
}
|
||
}
|
||
{
|
||
pNewSheet->MergeCells(0,0,1,0);
|
||
pNewSheet->MergeCells(0,1,1,1);
|
||
pNewSheet->MergeCells(0,2,0,3);
|
||
pNewSheet->MergeCells(0,4,1,4);
|
||
pNewSheet->MergeCells(0,5,0,6);
|
||
pNewSheet->MergeCells(0,7,1,7);
|
||
const TCHAR *szHeadText[8]={_T("类别"),_T("设计编号"), _T(""), _T("洞口尺寸(mm)"),_T("樘 数"),_T("图集代号"),_T("编号"),_T("备注")};
|
||
for(int k=0;k<8;k++) {
|
||
TGridCell *pCell=(*pNewSheet)(0, k);
|
||
TGridStyle &grStyle=pCell->GetGridStyle();
|
||
grStyle.SetFlagBit(OF_TEXTHEIGHT);
|
||
grStyle.SetTextHeight(4.0);
|
||
pCell->SetText(szHeadText[k]);
|
||
}
|
||
TGridCell*pCell=(*pNewSheet)(1,2);
|
||
pCell->SetText(_T("宽"));
|
||
pCell=(*pNewSheet)(1,3);
|
||
pCell->SetText(_T("高"));
|
||
pCell=(*pNewSheet)(0,5);
|
||
pCell->SetText(_T("采用标准图集及编号"));
|
||
pCell=(*pNewSheet)(1,5);
|
||
pCell->SetText(_T("图集代号"));
|
||
pCell=(*pNewSheet)(1,6);
|
||
pCell->SetText(_T("编号"));
|
||
}
|
||
|
||
BOOL bAutoUpr=FALSE;
|
||
TDbConfig *pConfig=GetDwgGlobal(AcDb::kForRead, acdbCurDwg());
|
||
if(pConfig && pConfig->IsCapLabel())
|
||
bAutoUpr=TRUE;
|
||
if(pConfig) pConfig->close();
|
||
|
||
for(int n=1; n<nRowNum; n++) {
|
||
TOpeningTableItem *pData=lstOpenings[n-1];
|
||
TGridCell *pCell=(*pSheet)(n, 0);
|
||
pCell->SetText(pData->m_sOpKind);
|
||
pCell=(*pSheet)(n, 1);
|
||
if(bAutoUpr)
|
||
pCell->SetText(_tcsupr(pData->m_sTypeCode));
|
||
else pCell->SetText(pData->m_sTypeCode);
|
||
pCell=(*pSheet)(n, 2);
|
||
pCell->SetText(pData->m_sSize);
|
||
pCell=(*pSheet)(n, 3);
|
||
pCell->SetText(XString(_T("%d"), pData->m_nCount));
|
||
}
|
||
|
||
int nRowNum1=nRowNum+1;
|
||
for(n=2; n<nRowNum1; n++) {
|
||
TOpeningTableItem *pData=lstOpenings[n-2];
|
||
TGridCell *pCell=(*pNewSheet)(n, 0);
|
||
pCell->SetText(pData->m_sOpKind);
|
||
pCell=(*pNewSheet)(n, 1);
|
||
if(bAutoUpr)
|
||
pCell->SetText(_tcsupr(pData->m_sTypeCode));
|
||
else
|
||
pCell->SetText(pData->m_sTypeCode);
|
||
pCell=(*pNewSheet)(n, 2);
|
||
pCell->SetText(pData->GetLength());
|
||
pCell=(*pNewSheet)(n, 3);
|
||
pCell->SetText(pData->GetWidth());
|
||
pCell=(*pNewSheet)(n, 4);
|
||
pCell->SetText(XString(_T("%d"), pData->m_nCount));
|
||
}
|
||
|
||
|
||
if(pSheet->IsValid()&&pNewSheet->IsValid()) {
|
||
CTemporaryResourceOverride vTemp;
|
||
COpGridSheetDlg dlg(pSheet,pNewSheet, acedGetAcadFrame());
|
||
if(dlg.DoModal()==IDOK) {
|
||
if(XGetPoint(NULL, _T("\n门窗表位置(左上角点)"), ptLoc)==RTNORM) {
|
||
if(COpGridSheetDlg::s_bNewSheet)
|
||
{
|
||
MergeOpSheet(pNewSheet,2);
|
||
pNewSheet->SetLocation(Ucs2Wcs(ptLoc));
|
||
pNewSheet->AddToCSpace(Adesk::kTrue);
|
||
delete pSheet;
|
||
}
|
||
else
|
||
{
|
||
MergeOpSheet(pSheet,1);
|
||
pSheet->SetLocation(Ucs2Wcs(ptLoc));
|
||
pSheet->AddToCSpace(Adesk::kTrue);
|
||
delete pNewSheet;
|
||
}
|
||
} else{
|
||
delete pSheet;
|
||
delete pNewSheet;
|
||
}
|
||
} else {
|
||
delete pSheet;
|
||
delete pNewSheet;
|
||
}
|
||
} else{
|
||
delete pSheet;
|
||
delete pNewSheet;
|
||
}
|
||
}*/
|
||
|
||
|
||
class _QuitHighShow
|
||
{
|
||
public:
|
||
_QuitHighShow(PickSet &ss) : m_ss(ss) {}
|
||
~_QuitHighShow() {m_ss.Redraw(4);}
|
||
PickSet &m_ss;
|
||
};
|
||
int SelectEntitiesOnce(CString csPrompt,PickSet &ssResult, const TRBList &rbBaseMask,const TCHAR* szKeyword, TCHAR &chRet);
|
||
|
||
// add by xly 0n 110412 设置实体的图层并将实体添加到图纸中
|
||
extern TARCH_IMPEXP BOOL g_bTextDefaultLayer;
|
||
void StaticOpenings()
|
||
{
|
||
|
||
DList<TOpeningTableItem> lstOpenings;
|
||
PickSet ss(SS_FREE);
|
||
_QuitHighShow high(ss);
|
||
|
||
CTemporaryResourceOverride vTemp;
|
||
CSelectSheetDlg dlg;
|
||
dlg.m_bSingle=TRUE;
|
||
|
||
bool bModReg = false;
|
||
CString strBlockName(_T(""));
|
||
dlg.ReadParamFromRegistry();
|
||
strBlockName = dlg.m_strBlockName;
|
||
|
||
// modify by xlc on 110307 调整流程,增加文字作为门窗设置
|
||
//RBList mask(RTDXF0, _T("ATS_OPENING,ATS_CORNER_WINDOW,ATS_DORMER"), NULL);
|
||
//g_ssPickFirst.Free();
|
||
//if(SelectEntities(_T("\n请选择当前层门窗:"), ss, mask)!=RTNORM)
|
||
// return;
|
||
int nRet = 0;
|
||
TCHAR szRet;
|
||
|
||
// PickSet ssEnts;
|
||
// s_bTextAsOp = dlg.m_bTextAsOp;
|
||
// s_bBlock = dlg.m_bBlock;
|
||
|
||
while (1)
|
||
{
|
||
g_ssPickFirst.Free();
|
||
// if (s_bTextAsOp)
|
||
// {
|
||
// RBList mask(RTDXF0, _T("ATS_OPENING,ATS_CORNER_WINDOW,ATS_DORMER,ATS_TEXT,TEXT"), NULL);
|
||
// nRet = SelectEntities(_T("\n请选择门窗或[设置(S)]<退出>:"), ss, mask, _T("S"), szRet);
|
||
// }
|
||
// else
|
||
// {
|
||
// RBList mask(RTDXF0, _T("ATS_OPENING,ATS_CORNER_WINDOW,ATS_DORMER"), NULL);
|
||
// nRet = SelectEntities(_T("\n请选择门窗或[设置(S)]<退出>:"), ss, mask, _T("S"), szRet);
|
||
// }
|
||
|
||
CString strRbList = _T("ATS_OPENING,ATS_CORNER_WINDOW,ATS_DORMER");
|
||
if (s_bTextAsOp)
|
||
strRbList += (_T(",ATS_TEXT,TEXT"));
|
||
if (s_bBlock)
|
||
strRbList += (_T(",TCH_INSERT,INSERT"));
|
||
|
||
PickSet ssTemp(SS_FREE);
|
||
if (ss.Length() == 0)
|
||
{
|
||
nRet = SelectEntitiesOnce(_T("\n请选择门窗或[设置(S)]<退出>:"), ssTemp, RBList(RTDXF0, strRbList, NULL),
|
||
_T("S"), szRet);
|
||
}
|
||
else
|
||
{
|
||
nRet = SelectEntitiesOnce(_T("\n请选择门窗:"), ssTemp, RBList(RTDXF0, strRbList, NULL),
|
||
_T(""), szRet);
|
||
}
|
||
|
||
if (nRet == RTKWORD)
|
||
{
|
||
dlg.m_bTextAsOp = s_bTextAsOp;
|
||
dlg.m_bBlock = s_bBlock;
|
||
if(dlg.DoModal()==IDOK)
|
||
{
|
||
if (_tcsicmp(strBlockName, dlg.m_strBlockName) != 0)
|
||
{
|
||
bModReg = true;
|
||
strBlockName = dlg.m_strBlockName;
|
||
}
|
||
s_bTextAsOp = dlg.m_bTextAsOp;
|
||
s_bBlock = dlg.m_bBlock;
|
||
}
|
||
}
|
||
else if (nRet == RTNORM)
|
||
{
|
||
ssTemp.Redraw(3);
|
||
ss += ssTemp;
|
||
// break;
|
||
}
|
||
else if (nRet == RTNONE)
|
||
{
|
||
if (ss.Length() == 0)
|
||
return; // 退出
|
||
else
|
||
break; // 确定
|
||
}
|
||
else
|
||
{
|
||
return;
|
||
}
|
||
}
|
||
|
||
{
|
||
long lCount = ss.Length();
|
||
DList<AcDbObjectId> ssOpenings;
|
||
for(long i=0L; i<lCount; i++)
|
||
{
|
||
if (ss[i].Is(_T("INSERT")) || ss[i].Is(_T("TCH_INSERT")))
|
||
{ // 如果是块,则打开这个块, 读取里边的所有实体
|
||
OPENOBJ_BEGIN(ss[i], AcDb::kForRead, AcDbBlockReference, pRecRef)
|
||
if (pRecRef != NULL)
|
||
{
|
||
OPENOBJ_BEGIN(pRecRef->blockTableRecord(), AcDb::kForRead, AcDbBlockTableRecord, pRec)
|
||
if (pRec != NULL)
|
||
{
|
||
AcDbBlockTableRecordIterator *pIter = NULL;
|
||
pRec->newIterator(pIter);
|
||
for (pIter->start(); !pIter->done(); pIter->step())
|
||
{
|
||
AcDbEntity *pEnt = NULL;
|
||
pIter->getEntity(pEnt, AcDb::kForRead);
|
||
if (pEnt->isKindOf(TDbOpening::desc())
|
||
|| pEnt->isKindOf(TDbCornerWin::desc())
|
||
|| pEnt->isKindOf(TDbDormer::desc())
|
||
|| (s_bTextAsOp && (pEnt->isKindOf(AcDbText::desc()) || pEnt->isKindOf(TDbText::desc()))))
|
||
{
|
||
ssOpenings.Append(new AcDbObjectId((AcDbStub*)(pEnt->id())));
|
||
}
|
||
|
||
pEnt->close();
|
||
}
|
||
}
|
||
OPENOBJ_END()
|
||
}
|
||
OPENOBJ_END()
|
||
}
|
||
else
|
||
{
|
||
AcDbObjectId* pId = new AcDbObjectId;
|
||
acdbGetObjectId(*pId, ss[i]);
|
||
ssOpenings.Append(pId);
|
||
}
|
||
}
|
||
StaticOpeningsFromDatabase(ssOpenings, lstOpenings);
|
||
lstOpenings.QuickSort(TOpeningTableItem::CompareForSortByCode);
|
||
}
|
||
|
||
|
||
//if(dlg.DoModal()!=IDOK)
|
||
//{
|
||
// return;
|
||
//}
|
||
//strBlockName=dlg.m_strBlockName;
|
||
|
||
AcDbEntity *pEnt=NULL;
|
||
XString sLibFile;
|
||
sLibFile << g_sDwbPath << _T("Sheet.TKW");
|
||
pEnt=LoadGJKEntity(strBlockName);
|
||
|
||
TDbSheet *pSheet=NULL;
|
||
if(pEnt!=NULL)
|
||
{
|
||
if(pEnt->isKindOf(TDbSheet::desc()))
|
||
{
|
||
pSheet=TDbSheet::cast(pEnt);
|
||
}
|
||
else
|
||
{
|
||
AfxMessageBox(_T("表格块错误,先设置表格!"));
|
||
delete pEnt;
|
||
return;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
AfxMessageBox(_T("表格块错误,先设置表格!"));
|
||
return;
|
||
}
|
||
int nRowNum=lstOpenings.Length();
|
||
//long lCount = m_grid.GetRowNum(); //原始表格行数
|
||
long colCount=pSheet->GetColumnNum(); //表格列数
|
||
long rowCount=pSheet->GetRowNum(); //原始表格行数
|
||
long lRow = rowCount-1;
|
||
//--------确定添加项---------------------------
|
||
if(rowCount<2)//表格没有台头或没有单元项
|
||
{
|
||
AfxMessageBox(_T("表格错误,先设置表格!"));
|
||
delete pSheet;
|
||
return;
|
||
}
|
||
|
||
int nCount=0; //表格匹配字段数
|
||
int nKind(-1),nCode(-1),nSize(-1),nWidth(-1),nHeight(-1),nNum(-1);//类别,设计编号,洞口尺寸,宽,高,总计的列位置,-1表示不存在该列
|
||
for(int j=0;j<colCount;j++)
|
||
{
|
||
TGridCell *pCell=(*pSheet)(lRow-1, j);
|
||
CString ss=pCell->GetText();
|
||
if(ss.Find(_T("(类别)"))!=-1||ss.Find(_T("(类别)"))!=-1)
|
||
{
|
||
if(nKind==-1)
|
||
{
|
||
nKind=j;
|
||
nCount++;
|
||
}
|
||
}
|
||
else if((ss.Find(_T("(设计编号)"))!=-1)||(ss.Find(_T("(设计编号)"))!=-1))
|
||
{
|
||
if(nCode==-1)
|
||
{
|
||
nCode=j;
|
||
nCount++;
|
||
}
|
||
}
|
||
else if((ss.Find(_T("(洞口尺寸)"))!=-1)||(ss.Find(_T("(洞口尺寸)"))!=-1))
|
||
{
|
||
if(nSize==-1)
|
||
{
|
||
nSize=j;
|
||
nCount++;
|
||
}
|
||
}
|
||
else if((ss.Find(_T("(宽)"))!=-1)||(ss.Find(_T("(宽)"))!=-1))
|
||
{
|
||
if(nWidth==-1)
|
||
{
|
||
nWidth=j;
|
||
nCount++;
|
||
}
|
||
}
|
||
else if((ss.Find(_T("(高)"))!=-1)||(ss.Find(_T("(高)"))!=-1))
|
||
{
|
||
if(nHeight==-1)
|
||
{
|
||
nHeight=j;
|
||
nCount++;
|
||
}
|
||
}
|
||
else if((ss.Find(_T("(总计)"))!=-1)||(ss.Find(_T("(总计)"))!=-1))
|
||
{
|
||
if(nNum==-1)
|
||
{
|
||
nNum=j;
|
||
nCount++;
|
||
}
|
||
}
|
||
else if((ss.Find(_T("类"))!=-1)&&(ss.Find(_T("别"))!=-1))
|
||
{
|
||
if(nKind==-1)
|
||
{
|
||
nKind=j;
|
||
nCount++;
|
||
}
|
||
}
|
||
else if((ss.Find(_T("设"))!=-1)&&(ss.Find(_T("计"))!=-1)&&(ss.Find(_T("编"))!=-1)&&(ss.Find(_T("号"))!=-1))
|
||
{
|
||
if(nCode==-1)
|
||
{
|
||
nCode=j;
|
||
nCount++;
|
||
}
|
||
}
|
||
else if((ss.Find(_T("洞"))!=-1)&&(ss.Find(_T("口"))!=-1)&&(ss.Find(_T("尺"))!=-1)&&(ss.Find(_T("寸"))!=-1))
|
||
{
|
||
if(nSize==-1)
|
||
{
|
||
nSize=j;
|
||
nCount++;
|
||
}
|
||
}
|
||
else if((ss.Find(_T("宽"))!=-1))
|
||
{
|
||
if(nWidth==-1)
|
||
{
|
||
nWidth=j;
|
||
nCount++;
|
||
}
|
||
}
|
||
else if((ss.Find(_T("高"))!=-1))
|
||
{
|
||
if(nHeight==-1)
|
||
{
|
||
nHeight=j;
|
||
nCount++;
|
||
}
|
||
}
|
||
else if((ss.Find(_T("总"))!=-1)&&(ss.Find(_T("计"))!=-1))
|
||
{
|
||
if(nNum==-1)
|
||
{
|
||
nNum=j;
|
||
nCount++;
|
||
}
|
||
}
|
||
}
|
||
if (nCount<2)
|
||
{
|
||
AfxMessageBox(_T("表格错误,至少匹配两个字段!"));
|
||
delete pSheet;
|
||
return;
|
||
}
|
||
if(bModReg)
|
||
{
|
||
dlg.WriteParamToRegistry();
|
||
}
|
||
|
||
for(j=0;j<rowCount;j++)
|
||
{
|
||
for(int k=0;k<colCount;k++)
|
||
{
|
||
TGridCell *pCell=(*pSheet)(j, k);
|
||
CString ss=pCell->GetText();
|
||
CString str(_T(""));
|
||
|
||
//modify by xlc on 090206插入表格有问号
|
||
// if(ss.Find(_T("(类别)"))!=-1||ss.Find(_T("(类别)"))!=-1)
|
||
// {
|
||
// str=ss.Left(ss.GetLength()-4);
|
||
// pCell->SetText(str);
|
||
// }
|
||
// else if((ss.Find(_T("(设计编号)"))!=-1)||ss.Find(_T("(设计编号)"))!=-1)
|
||
// {
|
||
// str=ss.Left(ss.GetLength()-6);
|
||
// pCell->SetText(str);
|
||
// }
|
||
// else if((ss.Find(_T("(洞口尺寸)"))!=-1)||(ss.Find(_T("(洞口尺寸)"))!=-1))
|
||
// {
|
||
// str=ss.Left(ss.GetLength()-6);
|
||
// pCell->SetText(str);
|
||
// }
|
||
// else if((ss.Find(_T("(宽)"))!=-1)||(ss.Find(_T("(宽)"))!=-1))
|
||
// {
|
||
// str=ss.Left(ss.GetLength()-3);
|
||
// pCell->SetText(str);
|
||
// }
|
||
// else if((ss.Find(_T("(高)"))!=-1)||(ss.Find(_T("(高)"))!=-1))
|
||
// {
|
||
// str=ss.Left(ss.GetLength()-3);
|
||
// pCell->SetText(str);
|
||
// }
|
||
// else if((ss.Find(_T("(总计)"))!=-1)||(ss.Find(_T("(总计)"))!=-1))
|
||
// {
|
||
// str=ss.Left(ss.GetLength()-4);
|
||
// pCell->SetText(str);
|
||
// }
|
||
if(ss.Find(_T("(类别)"))!=-1)
|
||
{
|
||
CString s1=_T("(类别)");
|
||
str=ss.Left(ss.GetLength()-s1.GetLength());
|
||
pCell->SetText(str);
|
||
}
|
||
else if(ss.Find(_T("(类别)"))!=-1)
|
||
{
|
||
CString s1=_T("(类别)");
|
||
str=ss.Left(ss.GetLength()-s1.GetLength());
|
||
pCell->SetText(str);
|
||
}
|
||
else if((ss.Find(_T("(设计编号)"))!=-1))
|
||
{
|
||
CString s1=_T("(设计编号)");
|
||
str=ss.Left(ss.GetLength()-s1.GetLength());
|
||
pCell->SetText(str);
|
||
}
|
||
else if(ss.Find(_T("(设计编号)"))!=-1)
|
||
{
|
||
CString s1=_T("(设计编号)");
|
||
str=ss.Left(ss.GetLength()-s1.GetLength());
|
||
pCell->SetText(str);
|
||
}
|
||
else if(ss.Find(_T("(洞口尺寸)"))!=-1)
|
||
{
|
||
CString s1=_T("(洞口尺寸)");
|
||
str=ss.Left(ss.GetLength()-s1.GetLength());
|
||
pCell->SetText(str);
|
||
}
|
||
else if(ss.Find(_T("(洞口尺寸)"))!=-1)
|
||
{
|
||
CString s1=_T("(洞口尺寸)");
|
||
str=ss.Left(ss.GetLength()-s1.GetLength());
|
||
pCell->SetText(str);
|
||
}
|
||
else if((ss.Find(_T("(宽)"))!=-1))
|
||
{
|
||
CString s1=_T("(宽)");
|
||
str=ss.Left(ss.GetLength()-s1.GetLength());
|
||
pCell->SetText(str);
|
||
}
|
||
else if(ss.Find(_T("(宽)"))!=-1)
|
||
{
|
||
CString s1=_T("(宽)");
|
||
str=ss.Left(ss.GetLength()-s1.GetLength());
|
||
pCell->SetText(str);
|
||
}
|
||
else if((ss.Find(_T("(高)"))!=-1))
|
||
{
|
||
CString s1=_T("(高)");
|
||
str=ss.Left(ss.GetLength()-s1.GetLength());
|
||
pCell->SetText(str);
|
||
}
|
||
else if(ss.Find(_T("(高)"))!=-1)
|
||
{
|
||
CString s1=_T("(高)");
|
||
str=ss.Left(ss.GetLength()-s1.GetLength());
|
||
pCell->SetText(str);
|
||
}
|
||
else if(ss.Find(_T("(总计)"))!=-1)
|
||
{
|
||
CString s1=_T("(总计)");
|
||
str=ss.Left(ss.GetLength()-s1.GetLength());
|
||
pCell->SetText(str);
|
||
}
|
||
else if(ss.Find(_T("(总计)"))!=-1)
|
||
{
|
||
CString s1=_T("(总计)");
|
||
str=ss.Left(ss.GetLength()-s1.GetLength());
|
||
pCell->SetText(str);
|
||
}
|
||
}
|
||
}
|
||
|
||
BOOL bAutoUpr=FALSE;
|
||
TDbConfig *pConfig=GetDwgGlobal(AcDb::kForRead, acdbCurDwg());
|
||
if(pConfig && pConfig->IsCapLabel())
|
||
bAutoUpr=TRUE;
|
||
if(pConfig) pConfig->close();
|
||
|
||
//填表格数据
|
||
for(long i=0; i<nRowNum; i++)
|
||
{
|
||
TOpeningTableItem *pData=lstOpenings[i];
|
||
if(pData==NULL)
|
||
continue;
|
||
|
||
(*pSheet).AddRowAt(lRow+1);
|
||
(*pSheet).CopyRow(lRow,lRow+1);
|
||
TGridCell *pCell=NULL;
|
||
|
||
if(nKind!=-1)
|
||
{
|
||
pCell=(*pSheet)(lRow, nKind);
|
||
pCell->SetText(pData->m_sOpKind);
|
||
}
|
||
if(nCode!=-1)
|
||
{
|
||
pCell=(*pSheet)(lRow, nCode);
|
||
if(bAutoUpr)
|
||
pCell->SetText(_tcsupr(pData->m_sTypeCode));
|
||
else
|
||
pCell->SetText(pData->m_sTypeCode);
|
||
}
|
||
if(nSize!=-1)
|
||
{
|
||
pCell=(*pSheet)(lRow, nSize);
|
||
pCell->SetText(pData->m_sSize);
|
||
}
|
||
if(nWidth!=-1)
|
||
{
|
||
pCell=(*pSheet)(lRow,nWidth);
|
||
pCell->SetText(pData->GetLength());
|
||
}
|
||
if(nHeight!=-1)
|
||
{
|
||
pCell=(*pSheet)(lRow,nHeight);
|
||
pCell->SetText(pData->GetWidth());
|
||
}
|
||
if(nNum!=-1)
|
||
{
|
||
pCell=(*pSheet)(lRow, nNum);
|
||
pCell->SetText(XString(_T("%d"), pData->m_nCount));
|
||
}
|
||
|
||
lRow++;
|
||
}
|
||
pSheet->RemoveRow(lRow);
|
||
MergeOpSheet(pSheet,rowCount-1,nKind);//合并类别列相同单元格
|
||
|
||
//绘图
|
||
if(pSheet->IsValid())
|
||
{
|
||
//CTemporaryResourceOverride vTemp;
|
||
//CGridSheetDlg dlg(pSheet,acedGetAcadFrame());
|
||
//dlg.m_nRowNum=rowCount-1;//表头行数
|
||
//if(dlg.DoModal()==IDOK)
|
||
{
|
||
XPoint ptLoc;
|
||
PickSet ss(SS_FREE);
|
||
ss.IncludeBegin();
|
||
|
||
//modify by xlc on 090108解决用户坐标的问题
|
||
//pSheet->SetLocation(ptLoc);
|
||
pSheet->SetLocation(Ucs2Wcs(ptLoc));
|
||
pSheet->SetRotation(Ucs2Wcs(0.0));
|
||
|
||
pSheet->AddToCSpace(Adesk::kTrue);
|
||
pSheet = NULL;
|
||
ss.IncludeEnd();
|
||
|
||
XPoint xp;
|
||
int nRet = DragMovePickSet(ss, _T("\n请点取门窗表位置(左上角点)<退出>: "), xp, xp);
|
||
if(nRet != RTNORM)
|
||
{
|
||
ss.Delete();
|
||
}
|
||
// modify by xly on 110412 设置门窗的图层的切换
|
||
if (ss.Length()>0)
|
||
{
|
||
Entity ent = ss[0L];
|
||
TDbEntity *pEnt= NULL;
|
||
OPENOBJ_BEGIN(ent,AcDb::kForWrite,TDbEntity,pEnt);
|
||
if (pEnt)
|
||
{
|
||
// 设置在默认图层
|
||
if(!g_bTextDefaultLayer)
|
||
{
|
||
AcApDocument *pDoc = acDocManager->curDocument();
|
||
AcDbObjectId id = pDoc->database()->clayer();
|
||
if (id.isValid())
|
||
{
|
||
pEnt->setLayer(id);
|
||
}
|
||
}
|
||
}
|
||
OPENOBJ_END();
|
||
}
|
||
|
||
return;
|
||
}
|
||
}
|
||
|
||
delete pSheet;
|
||
}
|
||
|
||
|
||
//////////////////////////////////////////////////////
|
||
// Command: 统计项目门窗表
|
||
/*void StaticProjectOpeningTable()
|
||
{
|
||
if(g_project.IsEmpty())
|
||
{
|
||
AfxMessageBox(_T("请打开或新建一个工程项目,并在工程数据库中建立楼层表!"));
|
||
CString sCmd=GetFullCmdName(_T("TProjectBar"));
|
||
acedPostCommand(sCmd+_T("\n"));
|
||
return;
|
||
}
|
||
|
||
|
||
TProjectGroupItem* pTable=GetFloorTable();
|
||
if(pTable==NULL)
|
||
return;
|
||
|
||
static int nAns=Q_YES;
|
||
DList<TOpeningTableItem> lstAllOpenings;
|
||
|
||
CString sCurDwg=curDoc()->fileName();
|
||
int nCurFloorIndex = 0;
|
||
XStringList szDescList;
|
||
int nStdLayerNum = pTable->GetLength();
|
||
for(pTable->MoveToFirst();!pTable->IsOut();pTable->MoveToNext()) {
|
||
TProjectFloor* pFloor=(TProjectFloor*)pTable->GetCurData();
|
||
XString sDwgFile=g_project.GetDwgFullName(pFloor->GetName());
|
||
XString sFloor=pFloor->GetLayerNo();
|
||
if(nAns==Q_YES) {
|
||
XString sFlrDesc(sFloor);
|
||
sFlrDesc << _T("层");
|
||
szDescList.Append(tstrnew(sFlrDesc));
|
||
}
|
||
DList<int> lstIndexes;
|
||
if(!StrToIntList(sFloor, lstIndexes)) {
|
||
adsout << /*UMSG* /_T("\n楼层的描述有错!");
|
||
return ;
|
||
}
|
||
|
||
int nLayerCount=lstIndexes.Length(); //自然层个数
|
||
ASSERT(nLayerCount>0);
|
||
|
||
|
||
adsout << _T("\n统计标准层") << (const TCHAR*)pFloor->GetName() << _T("的门窗表...");
|
||
DList<TOpeningTableItem> lstOpenings;
|
||
|
||
if(_tcsicmp(sCurDwg, sDwgFile)==0)
|
||
{//Current DWG
|
||
if(StaticOpeningsFromDatabase(acdbCurDwg(), lstOpenings,pFloor)!=RTNORM)
|
||
{
|
||
adsout << _T("\n图中有错, 中断统计!");
|
||
return ;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
AcDbDatabase dwgDb(false, true);
|
||
if(dwgDb.readDwgFile(sDwgFile, _SH_DENYNO, false)!=Acad::eOk) {
|
||
adsout << _T("\n不能访问") << sDwgFile << _T(", 中断统计!");
|
||
return ;
|
||
}
|
||
if(StaticOpeningsFromDatabase(&dwgDb, lstOpenings,pFloor)!=RTNORM) {
|
||
adsout << _T("\n图中有错, 中断统计!");
|
||
return ;
|
||
}
|
||
}
|
||
|
||
// 累计所有楼层
|
||
int nCountOfOpening=lstOpenings.Length();
|
||
for(int idx=0; idx<nCountOfOpening; idx++) {
|
||
TOpeningTableItem *pData = lstOpenings[idx];
|
||
TOpeningTableItem *pData1=lstAllOpenings.FindNode(pData, TOpeningTableItem::CompareForFindByData);
|
||
if(!pData1) { //未发现相同数据的门窗
|
||
TOpeningTableItem *pNewData = new TOpeningTableItem(*pData);
|
||
|
||
if(nAns==Q_YES) {
|
||
for (int i = 0 ; i < nStdLayerNum ; i++) {
|
||
pNewData->m_lstCount.Append(new int(0));
|
||
pNewData->m_lstLayCnt.Append(new int(0));
|
||
}
|
||
*pNewData->m_lstCount[nCurFloorIndex] = pData->m_nCount;
|
||
*pNewData->m_lstLayCnt[nCurFloorIndex] = nLayerCount;
|
||
}
|
||
|
||
pNewData->m_nCount *= nLayerCount;
|
||
if(lstAllOpenings.FindNode((const TCHAR *)pData->m_sTypeCode, TOpeningTableItem::CompareForFindByCode)) {
|
||
//但是发现相同编号的门窗
|
||
adsout << _T("\n标准层") << sDwgFile << _T("编号为'") << pData->m_sTypeCode << _T("'的门窗参数与其他楼层不一致!");
|
||
}
|
||
lstAllOpenings.Append(pNewData);
|
||
} else {
|
||
pData1->m_nCount += nLayerCount*pData->m_nCount;
|
||
|
||
if(nAns==Q_YES) {
|
||
*pData1->m_lstCount[nCurFloorIndex] = pData->m_nCount;
|
||
*pData1->m_lstLayCnt[nCurFloorIndex] = nLayerCount;
|
||
}
|
||
}
|
||
}
|
||
if(nAns==Q_YES) nCurFloorIndex++;
|
||
}
|
||
lstAllOpenings.QuickSort(TOpeningTableItem::CompareForSortByCode);
|
||
|
||
AcDbObjectId idTextStyle=InitTextStyle(TS_WDTABLE);
|
||
if(!idTextStyle)
|
||
return;
|
||
|
||
BOOL bAutoUpr=FALSE;
|
||
TDbConfig *pConfig=GetDwgGlobal(AcDb::kForRead, acdbCurDwg());
|
||
if(pConfig && pConfig->IsCapLabel())
|
||
bAutoUpr=TRUE;
|
||
if(pConfig) pConfig->close();
|
||
|
||
TDbSheet *pSheet=new TDbSheet;
|
||
pSheet->SetRotation(Ucs2Wcs(0.0));//add by whl
|
||
int nRowNum=lstAllOpenings.Length()+2;
|
||
pSheet->InitSheet(nRowNum, 8+szDescList.Length(), 7.0, 14.0);
|
||
|
||
TSheetColumn column;
|
||
double nColWidthArray[8]={14.0, 22.0, 30.0, 15.0, 40.0, 12, 22.0, 50.0};
|
||
const TCHAR *szHeadArray[8]={_T("类型"), _T("设计编号"), _T("洞口尺寸(mm)"), _T("合计"), _T("图集名称"), _T("页次"), _T("选用型号"), _T("备注")};
|
||
for(int m=0; m<3; m++) {
|
||
column.SetWidth(nColWidthArray[m]);
|
||
pSheet->SetColumnAt(m, column);
|
||
pSheet->MergeCells(0,m,1,m);
|
||
TGridCell *pCell=(*pSheet)(0, m);
|
||
pCell->SetText(szHeadArray[m]);
|
||
TGridStyle &grStyle=pCell->GetGridStyle();
|
||
grStyle.SetFlagBit(OF_TEXTHEIGHT);
|
||
grStyle.SetTextHeight(4.0);
|
||
}
|
||
int nStdFloorNum=szDescList.Length();
|
||
if(nStdFloorNum>1)
|
||
pSheet->MergeCells(0,3,0,3+nStdFloorNum);
|
||
{
|
||
TGridCell *pCell=(*pSheet)(0, 3);
|
||
pCell->SetText(_T("数量"));
|
||
TGridStyle &grStyle=pCell->GetGridStyle();
|
||
grStyle.SetFlagBit(OF_TEXTHEIGHT);
|
||
grStyle.SetTextHeight(4.0);
|
||
}
|
||
for(m=3; m<=nStdFloorNum+3; m++) {
|
||
column.SetWidth(nColWidthArray[3]);
|
||
pSheet->SetColumnAt(m, column);
|
||
TGridCell *pCell=(*pSheet)(1, m);
|
||
if(m==nStdFloorNum+3)
|
||
pCell->SetText(_T("合计"));
|
||
else
|
||
pCell->SetText(szDescList[m-3]);
|
||
TGridStyle &grStyle=pCell->GetGridStyle();
|
||
grStyle.SetFlagBit(OF_TEXTHEIGHT);
|
||
grStyle.SetTextHeight(4.0);
|
||
}
|
||
pSheet->MergeCells(0, nStdFloorNum+4, 0, nStdFloorNum+6);
|
||
TGridCell *pCell=(*pSheet)(0, 4+nStdFloorNum);
|
||
pCell->SetText(_T("图集选用"));
|
||
for(m=4; m<8; m++) {
|
||
column.SetWidth(nColWidthArray[m]);
|
||
pSheet->SetColumnAt(nStdFloorNum+m, column);
|
||
TGridCell *pCell=(*pSheet)(m==7? 0 : 1, m+nStdFloorNum);
|
||
pCell->SetText(szHeadArray[m]);
|
||
TGridStyle &grStyle=pCell->GetGridStyle();
|
||
grStyle.SetFlagBit(OF_TEXTHEIGHT);
|
||
grStyle.SetTextHeight(4.0);
|
||
}
|
||
pSheet->MergeCells(0,7+nStdFloorNum,1,7+nStdFloorNum);
|
||
|
||
|
||
TGridStyle gridStyle;
|
||
gridStyle.SetOverrideAll(TRUE);
|
||
gridStyle.SetTextWrap(FALSE);
|
||
gridStyle.SetHorMode(AcDb::kTextCenter);
|
||
gridStyle.SetVerMode(AcDb::kTextVertMid);
|
||
gridStyle.SetTextHeight(3.5);
|
||
gridStyle.SetTextStyleId(idTextStyle);
|
||
pSheet->SetGridStyle(gridStyle);
|
||
|
||
// 设置标题
|
||
TSheetTitle &title=pSheet->GetTitle();
|
||
title.SetHeight(16.0);
|
||
TGridStyle &gStyle=title.GetGridStyle();
|
||
gStyle.SetFlagBit(OF_TEXTHEIGHT);
|
||
gStyle.SetTextHeight(8.0);
|
||
TDividerStyle &dStyle=title.GetDividerStyle();
|
||
dStyle.SetDividerFlag(TDividerStyle::kNone);
|
||
pSheet->SetTitleText(_T("门窗表"));
|
||
|
||
for(int n=2; n<nRowNum; n++) {
|
||
TOpeningTableItem *pData=lstAllOpenings[n-2];
|
||
|
||
TGridCell *pCell=(*pSheet)(n, 0);
|
||
pCell->SetText(pData->m_sOpKind);
|
||
pCell=(*pSheet)(n, 1);
|
||
if(bAutoUpr)
|
||
pCell->SetText(_tcsupr(pData->m_sTypeCode));
|
||
else
|
||
pCell->SetText(pData->m_sTypeCode);
|
||
pCell=(*pSheet)(n, 2);
|
||
pCell->SetText(pData->m_sSize);
|
||
|
||
int nNum = pData->m_lstCount.Length();
|
||
ASSERT(nNum==szDescList.Length());
|
||
for (int i = 0 ; i < nNum ; i++) {
|
||
int nLayCnt = *pData->m_lstLayCnt[i];
|
||
CString pStrDesc;
|
||
pStrDesc.Format(_T("%d"), *pData->m_lstCount[i]);
|
||
if (nLayCnt > 1) {
|
||
CString pStrTemp;
|
||
pStrTemp.Format(_T("X%d=%d"), nLayCnt,(int)(*pData->m_lstCount[i]*nLayCnt));
|
||
pStrDesc+=pStrTemp;
|
||
}
|
||
pCell=(*pSheet)(n, i+3);
|
||
if(*pData->m_lstCount[i]*nLayCnt>0)
|
||
pCell->SetText(pStrDesc);
|
||
}
|
||
|
||
pCell=(*pSheet)(n, nNum+3);
|
||
pCell->SetText(XString(_T("%d"), pData->m_nCount));
|
||
}
|
||
|
||
TDbSheet *pNewSheet=new TDbSheet;
|
||
pNewSheet->SetRotation(Ucs2Wcs(0.0));//add by whl
|
||
{
|
||
int nRowNum=lstAllOpenings.Length()+2;
|
||
pNewSheet->InitSheet(nRowNum, 8+szDescList.Length(), 7.0, 14.0);
|
||
|
||
TSheetColumn column;
|
||
double nColWidthArray[8]={14.0, 22.0, 20.0, 20.0, 15.0, 40, 22.0, 50.0};
|
||
const TCHAR *szHeadArray[8]={_T("类型"), _T("设计编号"), _T("洞口尺寸(mm)"),_T("洞口尺寸(mm)"),_T("各层樘数"), _T("图集代号"), _T("编号"),_T("备注")};
|
||
for(int m=0; m<4; m++) {
|
||
column.SetWidth(nColWidthArray[m]);
|
||
pNewSheet->SetColumnAt(m, column);
|
||
TGridCell *pCell=(*pNewSheet)(0, m);
|
||
pCell->SetText(szHeadArray[m]);
|
||
TGridStyle &grStyle=pCell->GetGridStyle();
|
||
grStyle.SetFlagBit(OF_TEXTHEIGHT);
|
||
grStyle.SetTextHeight(4.0);
|
||
}
|
||
pNewSheet->MergeCells(0,0,1,0);
|
||
pNewSheet->MergeCells(0,1,1,1);
|
||
pNewSheet->MergeCells(0,2,0,3);
|
||
pCell=(*pNewSheet)(1,2);
|
||
pCell->SetText(_T("宽"));
|
||
pCell=(*pNewSheet)(1,3);
|
||
pCell->SetText(_T("高"));
|
||
|
||
int nStdFloorNum=szDescList.Length();
|
||
if(nStdFloorNum>1)
|
||
pNewSheet->MergeCells(0,4,0,3+nStdFloorNum);
|
||
{
|
||
TGridCell *pCell=(*pNewSheet)(0, 4);
|
||
pCell->SetText(_T("各层樘数"));
|
||
TGridStyle &grStyle=pCell->GetGridStyle();
|
||
grStyle.SetFlagBit(OF_TEXTHEIGHT);
|
||
grStyle.SetTextHeight(4.0);
|
||
}
|
||
pNewSheet->MergeCells(0,4+nStdFloorNum,1,4+nStdFloorNum);
|
||
for(m=4; m<=nStdFloorNum+4; m++) {
|
||
column.SetWidth(nColWidthArray[4]);
|
||
pNewSheet->SetColumnAt(m, column);
|
||
TGridCell *pCell=(*pNewSheet)(1, m);
|
||
if(m==nStdFloorNum+4)
|
||
pCell->SetText(_T("总樘数"));
|
||
else
|
||
pCell->SetText(szDescList[m-4]);
|
||
TGridStyle &grStyle=pCell->GetGridStyle();
|
||
grStyle.SetFlagBit(OF_TEXTHEIGHT);
|
||
grStyle.SetTextHeight(4.0);
|
||
}
|
||
pNewSheet->MergeCells(0,5+nStdFloorNum,0,6+nStdFloorNum);
|
||
TGridCell *pCell=(*pNewSheet)(0, 5+nStdFloorNum);
|
||
pCell->SetText(_T("采用标准图集及编号"));
|
||
for(m=5; m<7; m++) {
|
||
column.SetWidth(nColWidthArray[m]);
|
||
pNewSheet->SetColumnAt(nStdFloorNum+m, column);
|
||
TGridCell *pCell=(*pNewSheet)(1, m+nStdFloorNum);
|
||
pCell->SetText(szHeadArray[m]);
|
||
TGridStyle &grStyle=pCell->GetGridStyle();
|
||
grStyle.SetFlagBit(OF_TEXTHEIGHT);
|
||
grStyle.SetTextHeight(4.0);
|
||
}
|
||
{
|
||
column.SetWidth(nColWidthArray[m]);
|
||
pNewSheet->MergeCells(0,m+nStdFloorNum,1,m+nStdFloorNum);
|
||
pNewSheet->SetColumnAt(nStdFloorNum+m, column);
|
||
TGridCell *pCell=(*pNewSheet)(0, m+nStdFloorNum);
|
||
pCell->SetText(szHeadArray[m]);
|
||
TGridStyle &grStyle=pCell->GetGridStyle();
|
||
grStyle.SetFlagBit(OF_TEXTHEIGHT);
|
||
grStyle.SetTextHeight(4.0);
|
||
}
|
||
|
||
TGridStyle gridStyle;
|
||
gridStyle.SetOverrideAll(TRUE);
|
||
gridStyle.SetTextWrap(FALSE);
|
||
gridStyle.SetHorMode(AcDb::kTextCenter);
|
||
gridStyle.SetVerMode(AcDb::kTextVertMid);
|
||
gridStyle.SetTextHeight(3.5);
|
||
gridStyle.SetTextStyleId(idTextStyle);
|
||
pNewSheet->SetGridStyle(gridStyle);
|
||
|
||
// 设置标题
|
||
TSheetTitle &title=pNewSheet->GetTitle();
|
||
title.SetHeight(16.0);
|
||
TGridStyle &gStyle=title.GetGridStyle();
|
||
gStyle.SetFlagBit(OF_TEXTHEIGHT);
|
||
gStyle.SetTextHeight(8.0);
|
||
TDividerStyle &dStyle=title.GetDividerStyle();
|
||
dStyle.SetDividerFlag(TDividerStyle::kNone);
|
||
pNewSheet->SetTitleText(_T("门窗表"));
|
||
|
||
for(int n=2; n<nRowNum; n++) {
|
||
TOpeningTableItem *pData=lstAllOpenings[n-2];
|
||
TGridCell *pCell=(*pNewSheet)(n, 0);
|
||
pCell->SetText(pData->m_sOpKind);
|
||
pCell=(*pNewSheet)(n, 1);
|
||
if(bAutoUpr)
|
||
pCell->SetText(_tcsupr(pData->m_sTypeCode));
|
||
else
|
||
pCell->SetText(pData->m_sTypeCode);
|
||
pCell=(*pNewSheet)(n, 2);
|
||
pCell->SetText(pData->GetLength());
|
||
pCell=(*pNewSheet)(n,3);
|
||
pCell->SetText(pData->GetWidth());
|
||
|
||
int nNum = pData->m_lstCount.Length();
|
||
ASSERT(nNum==szDescList.Length());
|
||
for (int i = 0 ; i < nNum ; i++) {
|
||
int nLayCnt = *pData->m_lstLayCnt[i];
|
||
CString pStrDesc;
|
||
pStrDesc.Format(_T("%d"), *pData->m_lstCount[i]);
|
||
if (nLayCnt > 1) {
|
||
CString pStrTemp;
|
||
pStrTemp.Format(_T("X%d=%d"), nLayCnt,(int)(*pData->m_lstCount[i]*nLayCnt));
|
||
pStrDesc+=pStrTemp;
|
||
}
|
||
pCell=(*pNewSheet)(n, i+4);
|
||
if(*pData->m_lstCount[i]*nLayCnt>0)
|
||
pCell->SetText(pStrDesc);
|
||
}
|
||
|
||
pCell=(*pNewSheet)(n, nNum+4);
|
||
pCell->SetText(XString(_T("%d"), pData->m_nCount));
|
||
}
|
||
}
|
||
|
||
GEOAPI BOOL g_szArxContext;
|
||
if(!g_szArxContext)
|
||
return;
|
||
|
||
if(pSheet->IsValid()&&pNewSheet->IsValid()) {
|
||
CTemporaryResourceOverride vTemp;
|
||
COpGridSheetDlg dlg(pSheet,pNewSheet,acedGetAcadFrame());
|
||
if(dlg.DoModal()==IDOK) {
|
||
XPoint ptLoc;
|
||
if(XGetPoint(NULL, _T("\n门窗表位置(左上角点)"), ptLoc)==RTNORM) {
|
||
if(COpGridSheetDlg::s_bNewSheet)
|
||
{
|
||
MergeOpSheet(pNewSheet,2);
|
||
pNewSheet->SetLocation(Ucs2Wcs(ptLoc));
|
||
pNewSheet->AddToCSpace(Adesk::kTrue);
|
||
delete pSheet;
|
||
}else{
|
||
MergeOpSheet(pSheet,2);
|
||
pSheet->SetLocation(Ucs2Wcs(ptLoc));
|
||
pSheet->AddToCSpace(Adesk::kTrue);
|
||
delete pNewSheet;
|
||
}
|
||
} else{
|
||
delete pSheet;
|
||
delete pNewSheet;
|
||
}
|
||
} else{
|
||
delete pSheet;
|
||
delete pNewSheet;
|
||
}
|
||
} else{
|
||
delete pSheet;
|
||
delete pNewSheet;
|
||
}
|
||
}*/
|
||
|
||
void StaticProjectOpeningTable()
|
||
{
|
||
if(g_project.IsEmpty())
|
||
{
|
||
AfxMessageBox(_T("请打开或新建一个工程项目,并在工程数据库中建立楼层表!"));
|
||
CString sCmd=GetFullCmdName(_T("TProjectBar")).cs();
|
||
acedPostCommand(sCmd+_T("\n"));
|
||
return;
|
||
}
|
||
|
||
TProjectGroupItem* pTable=GetFloorTable();
|
||
if(pTable==NULL)
|
||
return;
|
||
|
||
static int nAns=Q_YES;
|
||
DList<TOpeningTableItem> lstAllOpenings;
|
||
|
||
CTemporaryResourceOverride vTemp;
|
||
CSelectSheetDlg dlg;
|
||
dlg.m_bSingle=FALSE;
|
||
dlg.ReadParamFromRegistry();
|
||
|
||
CString strBlockName(_T(""));
|
||
//if(dlg.DoModal()!=IDOK)
|
||
{
|
||
// return;
|
||
}
|
||
strBlockName=dlg.m_strBlockName;
|
||
|
||
bool bModReg = false;
|
||
|
||
while(1){
|
||
CString sCurDwg=curDoc()->fileName();
|
||
int nCurFloorIndex = 0;
|
||
XStringList szDescList;
|
||
int nStdLayerNum = pTable->GetLength();
|
||
int nLayerCount(0);
|
||
for(pTable->MoveToFirst();!pTable->IsOut();pTable->MoveToNext())
|
||
{
|
||
TProjectFloor* pFloor=(TProjectFloor*)pTable->GetCurData();
|
||
XString sDwgFile=g_project.GetDwgFullName(pFloor->GetName());
|
||
XString sFloor=pFloor->GetLayerNo();
|
||
if(nAns==Q_YES) {
|
||
XString sFlrDesc(sFloor);
|
||
//sFlrDesc << _T("层");
|
||
szDescList.Append(tstrnew(sFlrDesc));
|
||
}
|
||
DList<int> lstIndexes;
|
||
if(!StrToIntList(sFloor, lstIndexes)) {
|
||
adsout << /*UMSG*/_T("\n楼层的描述有错!");
|
||
return ;
|
||
}
|
||
|
||
nLayerCount=lstIndexes.Length(); //自然层个数
|
||
ASSERT(nLayerCount>0);
|
||
|
||
|
||
adsout << _T("\n统计标准层") << (const TCHAR*)pFloor->GetName() << _T("的门窗表...");
|
||
DList<TOpeningTableItem> lstOpenings;
|
||
|
||
if(_tcsicmp(sCurDwg, sDwgFile)==0)
|
||
{//Current DWG
|
||
if(StaticOpeningsFromDatabase(acdbCurDwg(), lstOpenings,pFloor)!=RTNORM)
|
||
{
|
||
adsout << _T("\n图中有错, 中断统计!");
|
||
return ;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
AcDbDatabase dwgDb(false, true);
|
||
#if ADS < 21
|
||
if(dwgDb.readDwgFile(sDwgFile, _SH_DENYNO, false)!=Acad::eOk) {
|
||
#else
|
||
if(dwgDb.readDwgFile(sDwgFile, AcDbDatabase::kForReadAndAllShare, false)!=Acad::eOk) {
|
||
#endif
|
||
adsout << _T("\n不能访问") << sDwgFile << _T(", 中断统计!");
|
||
return ;
|
||
}
|
||
if(StaticOpeningsFromDatabase(&dwgDb, lstOpenings,pFloor)!=RTNORM) {
|
||
adsout << _T("\n图中有错, 中断统计!");
|
||
return ;
|
||
}
|
||
}
|
||
|
||
// 累计所有楼层
|
||
int nCountOfOpening=lstOpenings.Length();
|
||
for(int idx=0; idx<nCountOfOpening; idx++) {
|
||
TOpeningTableItem *pData = lstOpenings[idx];
|
||
TOpeningTableItem *pData1=lstAllOpenings.FindNode(pData, TOpeningTableItem::CompareForFindByData);
|
||
if(!pData1) { //未发现相同数据的门窗
|
||
TOpeningTableItem *pNewData = new TOpeningTableItem(*pData);
|
||
|
||
if(nAns==Q_YES) {
|
||
for (int i = 0 ; i < nStdLayerNum ; i++) {
|
||
pNewData->m_lstCount.Append(new int(0));
|
||
pNewData->m_lstLayCnt.Append(new int(0));
|
||
}
|
||
*pNewData->m_lstCount[nCurFloorIndex] = pData->m_nCount;
|
||
*pNewData->m_lstLayCnt[nCurFloorIndex] = nLayerCount;
|
||
}
|
||
|
||
pNewData->m_nCount *= nLayerCount;
|
||
if(lstAllOpenings.FindNode((const TCHAR *)pData->m_sTypeCode, TOpeningTableItem::CompareForFindByCode)) {
|
||
//但是发现相同编号的门窗
|
||
adsout << _T("\n标准层") << sDwgFile << _T("编号为'") << pData->m_sTypeCode << _T("'的门窗参数与其他楼层不一致!");
|
||
}
|
||
lstAllOpenings.Append(pNewData);
|
||
} else {
|
||
pData1->m_nCount += nLayerCount*pData->m_nCount;
|
||
|
||
if(nAns==Q_YES) {
|
||
*pData1->m_lstCount[nCurFloorIndex] = pData->m_nCount;
|
||
*pData1->m_lstLayCnt[nCurFloorIndex] = nLayerCount;
|
||
}
|
||
}
|
||
}
|
||
if(nAns==Q_YES) nCurFloorIndex++;
|
||
}
|
||
lstAllOpenings.QuickSort(TOpeningTableItem::CompareForSortByCode);
|
||
|
||
/*
|
||
CTemporaryResourceOverride vTemp;
|
||
CSelectSheetDlg dlg;
|
||
dlg.m_bSingle=FALSE;
|
||
|
||
CString strBlockName(_T(""));
|
||
if(dlg.DoModal()!=IDOK)
|
||
{
|
||
return;
|
||
}
|
||
strBlockName=dlg.m_strBlockName;
|
||
*/
|
||
AcDbEntity *pEnt=NULL;
|
||
XString sLibFile;
|
||
sLibFile << g_sDwbPath << _T("Sheet.TKW");
|
||
pEnt=LoadGJKEntity(strBlockName);
|
||
|
||
TDbSheet *pSheet=NULL;
|
||
if(pEnt!=NULL)
|
||
{
|
||
if(pEnt->isKindOf(TDbSheet::desc()))
|
||
{
|
||
pSheet=TDbSheet::cast(pEnt);
|
||
}
|
||
else
|
||
{
|
||
AfxMessageBox(_T("表格块错误!"));
|
||
delete pEnt;
|
||
return;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
AfxMessageBox(_T("表格块错误!"));
|
||
return;
|
||
}
|
||
int nRowNum=lstAllOpenings.Length(); //添加表格行数
|
||
long colCount=pSheet->GetColumnNum(); //表格列数
|
||
long rowCount=pSheet->GetRowNum(); //原始表格行数
|
||
long lRow = rowCount-1;
|
||
|
||
if(rowCount<2)//表格没有台头或没有单元项
|
||
{
|
||
AfxMessageBox(_T("表格错误!"));
|
||
delete pSheet;
|
||
return;
|
||
}
|
||
|
||
int nCount=0; //匹配字段数
|
||
int nFloorName(-1),nTotalNum(-1); //楼层名列位置,总计列位置
|
||
int nKind(-1),nCode(-1),nSize(-1),nWidth(-1),nHeight(-1);//类别,设计编号,洞口尺寸,宽,高的列位置,-1表示不存在该列
|
||
for(int j=0;j<colCount;j++)
|
||
{
|
||
TGridCell *pCell=(*pSheet)(lRow-1, j);
|
||
CString ss=pCell->GetText();
|
||
if(ss.Find(_T("(类别)"))!=-1||ss.Find(_T("(类别)"))!=-1)
|
||
{
|
||
if(nKind==-1)
|
||
{
|
||
nKind=j;
|
||
nCount++;
|
||
}
|
||
}
|
||
else if((ss.Find(_T("(设计编号)"))!=-1)||(ss.Find(_T("(设计编号)"))!=-1))
|
||
{
|
||
if(nCode==-1)
|
||
{
|
||
nCode=j;
|
||
nCount++;
|
||
}
|
||
}
|
||
else if((ss.Find(_T("(洞口尺寸)"))!=-1)||(ss.Find(_T("(洞口尺寸)"))!=-1))
|
||
{
|
||
if(nSize==-1)
|
||
{
|
||
nSize=j;
|
||
nCount++;
|
||
}
|
||
}
|
||
else if((ss.Find(_T("(宽)"))!=-1)||(ss.Find(_T("(宽)"))!=-1))
|
||
{
|
||
if(nWidth==-1)
|
||
{
|
||
nWidth=j;
|
||
nCount++;
|
||
}
|
||
}
|
||
else if((ss.Find(_T("(高)"))!=-1)||(ss.Find(_T("(高)"))!=-1))
|
||
{
|
||
if(nHeight==-1)
|
||
{
|
||
nHeight=j;
|
||
nCount++;
|
||
}
|
||
}
|
||
else if(ss.Find(_T("(楼层名)"))!=-1||ss.Find(_T("(楼层名)"))!=-1)
|
||
{
|
||
if(nFloorName==-1)
|
||
{
|
||
nFloorName=j;
|
||
nCount++;
|
||
}
|
||
}
|
||
else if((ss.Find(_T("(总计)"))!=-1)||(ss.Find(_T("(总计)"))!=-1))
|
||
{
|
||
if(nTotalNum==-1)
|
||
{
|
||
nTotalNum=j;
|
||
nCount++;
|
||
}
|
||
}
|
||
else if((ss.Find(_T("类"))!=-1)&&(ss.Find(_T("别"))!=-1))
|
||
{
|
||
if(nKind==-1)
|
||
{
|
||
nKind=j;
|
||
nCount++;
|
||
}
|
||
}
|
||
else if((ss.Find(_T("设"))!=-1)&&(ss.Find(_T("计"))!=-1)&&(ss.Find(_T("编"))!=-1)&&(ss.Find(_T("号"))!=-1))
|
||
{
|
||
if(nCode==-1)
|
||
{
|
||
nCode=j;
|
||
nCount++;
|
||
}
|
||
}
|
||
else if((ss.Find(_T("洞"))!=-1)&&(ss.Find(_T("口"))!=-1)&&(ss.Find(_T("尺"))!=-1)&&(ss.Find(_T("寸"))!=-1))
|
||
{
|
||
if(nSize==-1)
|
||
{
|
||
nSize=j;
|
||
nCount++;
|
||
}
|
||
}
|
||
else if((ss.Find(_T("宽"))!=-1))
|
||
{
|
||
if(nWidth==-1)
|
||
{
|
||
nWidth=j;
|
||
nCount++;
|
||
}
|
||
}
|
||
else if((ss.Find(_T("高"))!=-1))
|
||
{
|
||
if(nHeight==-1)
|
||
{
|
||
nHeight=j;
|
||
nCount++;
|
||
}
|
||
}
|
||
else if((ss.Find(_T("(总)"))!=-1)&&(ss.Find(_T("(计)"))!=-1))
|
||
{
|
||
if(nTotalNum==-1)
|
||
{
|
||
nTotalNum=j;
|
||
nCount++;
|
||
}
|
||
}
|
||
}
|
||
|
||
if (nCount<2)
|
||
{
|
||
AfxMessageBox(_T("表格错误,至少匹配两个字段!"));
|
||
delete pSheet;
|
||
return;
|
||
}
|
||
dlg.WriteParamToRegistry();
|
||
|
||
for(j=0;j<rowCount;j++)
|
||
{
|
||
for(int k=0;k<colCount;k++)
|
||
{
|
||
TGridCell *pCell=(*pSheet)(j, k);
|
||
CString ss=pCell->GetText();
|
||
CString str(_T(""));
|
||
|
||
//modify by xlc on 090206插入表格有问号
|
||
// if(ss.Find(_T("(类别)"))!=-1||ss.Find(_T("(类别)"))!=-1)
|
||
// {
|
||
// str=ss.Left(ss.GetLength()-4);
|
||
// pCell->SetText(str);
|
||
// }
|
||
// else if((ss.Find(_T("(设计编号)"))!=-1)||ss.Find(_T("(设计编号)"))!=-1)
|
||
// {
|
||
// str=ss.Left(ss.GetLength()-6);
|
||
// pCell->SetText(str);
|
||
// }
|
||
// else if((ss.Find(_T("(洞口尺寸)"))!=-1)||(ss.Find(_T("(洞口尺寸)"))!=-1))
|
||
// {
|
||
// str=ss.Left(ss.GetLength()-6);
|
||
// pCell->SetText(str);
|
||
// }
|
||
// else if((ss.Find(_T("(宽)"))!=-1)||(ss.Find(_T("(宽)"))!=-1))
|
||
// {
|
||
// str=ss.Left(ss.GetLength()-3);
|
||
// pCell->SetText(str);
|
||
// }
|
||
// else if((ss.Find(_T("(高)"))!=-1)||(ss.Find(_T("(高)"))!=-1))
|
||
// {
|
||
// str=ss.Left(ss.GetLength()-3);
|
||
// pCell->SetText(str);
|
||
// }
|
||
// else if((ss.Find(_T("(总计)"))!=-1)||(ss.Find(_T("(总计)"))!=-1))
|
||
// {
|
||
// str=ss.Left(ss.GetLength()-4);
|
||
// pCell->SetText(str);
|
||
// }
|
||
if(ss.Find(_T("(类别)"))!=-1)
|
||
{
|
||
CString s1=_T("(类别)");
|
||
str=ss.Left(ss.GetLength()-s1.GetLength());
|
||
pCell->SetText(str);
|
||
}
|
||
else if(ss.Find(_T("(类别)"))!=-1)
|
||
{
|
||
CString s1=_T("(类别)");
|
||
str=ss.Left(ss.GetLength()-s1.GetLength());
|
||
pCell->SetText(str);
|
||
}
|
||
else if((ss.Find(_T("(设计编号)"))!=-1))
|
||
{
|
||
CString s1=_T("(设计编号)");
|
||
str=ss.Left(ss.GetLength()-s1.GetLength());
|
||
pCell->SetText(str);
|
||
}
|
||
else if(ss.Find(_T("(设计编号)"))!=-1)
|
||
{
|
||
CString s1=_T("(设计编号)");
|
||
str=ss.Left(ss.GetLength()-s1.GetLength());
|
||
pCell->SetText(str);
|
||
}
|
||
else if(ss.Find(_T("(洞口尺寸)"))!=-1)
|
||
{
|
||
CString s1=_T("(洞口尺寸)");
|
||
str=ss.Left(ss.GetLength()-s1.GetLength());
|
||
pCell->SetText(str);
|
||
}
|
||
else if(ss.Find(_T("(洞口尺寸)"))!=-1)
|
||
{
|
||
CString s1=_T("(洞口尺寸)");
|
||
str=ss.Left(ss.GetLength()-s1.GetLength());
|
||
pCell->SetText(str);
|
||
}
|
||
else if((ss.Find(_T("(宽)"))!=-1))
|
||
{
|
||
CString s1=_T("(宽)");
|
||
str=ss.Left(ss.GetLength()-s1.GetLength());
|
||
pCell->SetText(str);
|
||
}
|
||
else if(ss.Find(_T("(宽)"))!=-1)
|
||
{
|
||
CString s1=_T("(宽)");
|
||
str=ss.Left(ss.GetLength()-s1.GetLength());
|
||
pCell->SetText(str);
|
||
}
|
||
else if((ss.Find(_T("(高)"))!=-1))
|
||
{
|
||
CString s1=_T("(高)");
|
||
str=ss.Left(ss.GetLength()-s1.GetLength());
|
||
pCell->SetText(str);
|
||
}
|
||
else if(ss.Find(_T("(高)"))!=-1)
|
||
{
|
||
CString s1=_T("(高)");
|
||
str=ss.Left(ss.GetLength()-s1.GetLength());
|
||
pCell->SetText(str);
|
||
}
|
||
else if(ss.Find(_T("(总计)"))!=-1)
|
||
{
|
||
CString s1=_T("(总计)");
|
||
str=ss.Left(ss.GetLength()-s1.GetLength());
|
||
pCell->SetText(str);
|
||
}
|
||
else if(ss.Find(_T("(总计)"))!=-1)
|
||
{
|
||
CString s1=_T("(总计)");
|
||
str=ss.Left(ss.GetLength()-s1.GetLength());
|
||
pCell->SetText(str);
|
||
}
|
||
}
|
||
}
|
||
|
||
int nAddCol(0);
|
||
if(nFloorName!=-1&&nTotalNum-nFloorName>=1)//表格中有自然层
|
||
{
|
||
if(nTotalNum-nFloorName<szDescList.Length())
|
||
{
|
||
nAddCol=szDescList.Length()-(nTotalNum-nFloorName);//需要增加的自然层的列数
|
||
}
|
||
}
|
||
|
||
//增加列数
|
||
for(j=0;j<nAddCol;j++)
|
||
{
|
||
pSheet->AddColumnAt(nFloorName+1);
|
||
}
|
||
if(nAddCol>0) //增加列数后调整其他项的列序号
|
||
{
|
||
int nInitCol=nTotalNum;
|
||
nTotalNum += nAddCol;
|
||
if(nKind > nInitCol)
|
||
{
|
||
nKind += nAddCol;
|
||
}
|
||
if(nCode > nInitCol)
|
||
{
|
||
nCode += nAddCol;
|
||
}
|
||
if(nSize > nInitCol)
|
||
{
|
||
nSize += nAddCol;
|
||
}
|
||
if(nWidth > nInitCol)
|
||
{
|
||
nWidth += nAddCol;
|
||
}
|
||
if(nHeight > nInitCol)
|
||
{
|
||
nHeight += nAddCol;
|
||
}
|
||
}
|
||
|
||
//添加自然层的表头
|
||
if(nFloorName!=-1)
|
||
{
|
||
for(j=0;j<szDescList.Length();j++)
|
||
{
|
||
TGridCell *pCell=(*pSheet)(lRow-1, nFloorName+j);
|
||
CString ss=pCell->GetText();
|
||
pCell->SetText(szDescList[j]);
|
||
}
|
||
}
|
||
|
||
BOOL bAutoUpr=FALSE;
|
||
TDbConfig *pConfig=GetDwgGlobal(AcDb::kForRead, acdbCurDwg());
|
||
if(pConfig && pConfig->IsCapLabel())
|
||
bAutoUpr=TRUE;
|
||
if(pConfig) pConfig->close();
|
||
|
||
//填表格数据
|
||
for(long i=0; i<nRowNum; i++)
|
||
{
|
||
TOpeningTableItem *pData=lstAllOpenings[i];
|
||
if(pData==NULL)
|
||
continue;
|
||
|
||
(*pSheet).AddRowAt(lRow+1);
|
||
(*pSheet).CopyRow(lRow,lRow+1);
|
||
TGridCell *pCell=NULL;
|
||
|
||
if(nKind!=-1)
|
||
{
|
||
pCell=(*pSheet)(lRow, nKind);
|
||
pCell->SetText(pData->m_sOpKind);
|
||
}
|
||
if(nCode!=-1)
|
||
{
|
||
pCell=(*pSheet)(lRow, nCode);
|
||
if(bAutoUpr)
|
||
pCell->SetText(_tcsupr(pData->m_sTypeCode));
|
||
else
|
||
pCell->SetText(pData->m_sTypeCode);
|
||
}
|
||
if(nSize!=-1)
|
||
{
|
||
pCell=(*pSheet)(lRow, nSize);
|
||
pCell->SetText(pData->m_sSize);
|
||
}
|
||
if(nWidth!=-1)
|
||
{
|
||
pCell=(*pSheet)(lRow,nWidth);
|
||
pCell->SetText(pData->GetLength());
|
||
}
|
||
if(nHeight!=-1)
|
||
{
|
||
pCell=(*pSheet)(lRow,nHeight);
|
||
pCell->SetText(pData->GetWidth());
|
||
}
|
||
|
||
if(nFloorName!=-1)
|
||
{
|
||
int nNum = pData->m_lstCount.Length();
|
||
ASSERT(nNum==szDescList.Length());
|
||
for (int i = 0 ; i < nNum ; i++)
|
||
{
|
||
int nLayCnt = *pData->m_lstLayCnt[i];
|
||
CString pStrDesc;
|
||
pStrDesc.Format(_T("%d"), *pData->m_lstCount[i]);
|
||
if (nLayCnt > 1)
|
||
{
|
||
CString pStrTemp;
|
||
pStrTemp.Format(_T("X%d=%d"), nLayCnt,(int)(*pData->m_lstCount[i]*nLayCnt));
|
||
pStrDesc+=pStrTemp;
|
||
}
|
||
pCell=(*pSheet)(lRow, i+nFloorName);
|
||
if(*pData->m_lstCount[i]*nLayCnt>0)
|
||
pCell->SetText(pStrDesc);
|
||
}
|
||
}
|
||
if(nTotalNum!=-1)
|
||
{
|
||
pCell=(*pSheet)(lRow, nTotalNum);
|
||
pCell->SetText(XString(_T("%d"), pData->m_nCount));
|
||
}
|
||
|
||
lRow++;
|
||
}
|
||
pSheet->RemoveRow(lRow);
|
||
MergeOpSheet(pSheet,rowCount-1,nKind);//合并类别列相同单元格
|
||
|
||
//绘图
|
||
if(pSheet->IsValid())
|
||
{
|
||
//CTemporaryResourceOverride vTemp;
|
||
//CGridSheetDlg dlg(pSheet,acedGetAcadFrame());
|
||
//dlg.m_nRowNum=rowCount-1;//表头行数
|
||
//if(dlg.DoModal()==IDOK)
|
||
{
|
||
XPoint ptLoc;
|
||
PickSet ss(SS_FREE);
|
||
ss.IncludeBegin();
|
||
|
||
//modify by xlc on 090108解决用户坐标的问题
|
||
//pSheet->SetLocation(ptLoc);
|
||
pSheet->SetLocation(Ucs2Wcs(ptLoc));
|
||
pSheet->SetRotation(Ucs2Wcs(0.0));
|
||
|
||
pSheet->AddToCSpace(Adesk::kTrue);
|
||
pSheet = NULL;
|
||
ss.IncludeEnd();
|
||
|
||
//modify by xlc on 110307 调整流程,增加设置门窗文字功能
|
||
//int nRet = DragMovePickSet(ss, _T("\n门窗表位置(左上角点): "), XPoint(), XPoint());
|
||
//if(nRet != RTNORM)
|
||
//{
|
||
// ss.Delete();
|
||
//}
|
||
XPoint xp;
|
||
int nRet = DragMovePickSet(ss, _T("\n请点取门窗表位置(左上角点)或[设置(S)]<退出>: "), xp, xp,_T("S"));
|
||
if (nRet == RTNORM )
|
||
{
|
||
if(bModReg)
|
||
{
|
||
dlg.WriteParamToRegistry();
|
||
}
|
||
|
||
// modify by xly on 110412 设置门窗的图层的切换
|
||
if (ss.Length()>0)
|
||
{
|
||
Entity ent = ss[0L];
|
||
TDbEntity *pEnt= NULL;
|
||
OPENOBJ_BEGIN(ent,AcDb::kForWrite,TDbEntity,pEnt);
|
||
if (pEnt)
|
||
{
|
||
// 设置在默认图层
|
||
if(!g_bTextDefaultLayer)
|
||
{
|
||
AcApDocument *pDoc = acDocManager->curDocument();
|
||
AcDbObjectId id = pDoc->database()->clayer();
|
||
if (id.isValid())
|
||
{
|
||
pEnt->setLayer(id);
|
||
}
|
||
}
|
||
}
|
||
OPENOBJ_END();
|
||
}
|
||
|
||
return;
|
||
}
|
||
else if (nRet == RTKWORD)
|
||
{
|
||
dlg.m_bTextAsOp = s_bTextAsOp;
|
||
dlg.m_bBlock = s_bBlock;
|
||
if(dlg.DoModal()==IDOK)
|
||
{
|
||
if (_tcsicmp(strBlockName, dlg.m_strBlockName) != 0)
|
||
{
|
||
bModReg = true;
|
||
strBlockName = dlg.m_strBlockName;
|
||
}
|
||
s_bTextAsOp = dlg.m_bTextAsOp;
|
||
s_bBlock = dlg.m_bBlock;
|
||
}
|
||
ss.Delete();
|
||
}
|
||
else
|
||
{
|
||
ss.Delete();
|
||
delete pSheet;
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
delete pSheet;
|
||
}
|
||
}
|
||
|
||
//////////////////////////////////////////////////////
|
||
// Command: 门窗表文字样式
|
||
void OpTableTextStyle()
|
||
{
|
||
AcDbObjectId id=InitTextStyle(TS_WDTABLE);
|
||
if(!!id) {
|
||
XPushVarStr vTemp1(_T("TEXTSTYLE"), GetSymbolName(id));
|
||
CTemporaryResourceOverride vTemp;
|
||
CTextStyleDlg dlg(acedGetAcadFrame());
|
||
dlg.DoModal(); // DLG only has IDOK;
|
||
}
|
||
}
|
||
|
||
|
||
|
||
|
||
|
||
//////////////////////////////////////////////////////////////////////////
|
||
// 选择函数
|
||
class CSelectStruct
|
||
{
|
||
public:
|
||
#if ADS > 22
|
||
static bool KeyFilter(MSG* msg);
|
||
#else
|
||
static BOOL KeyFilter(MSG* msg);
|
||
#endif
|
||
static int SelectEnts(CString csPrompt,PickSet &ssResult, const TRBList &rbBaseMask,const TCHAR* szKeyword, TCHAR &chRet);
|
||
|
||
|
||
private:
|
||
static CString m_sKeyWordList;
|
||
static int m_rtRet;
|
||
static TCHAR m_chRet;
|
||
};
|
||
|
||
CString CSelectStruct::m_sKeyWordList;
|
||
int CSelectStruct::m_rtRet;
|
||
TCHAR CSelectStruct::m_chRet;
|
||
////////////////////////////////////////////////////////////////////////////
|
||
#if ADS > 22
|
||
bool CSelectStruct::KeyFilter(MSG* msg)
|
||
#else
|
||
BOOL CSelectStruct::KeyFilter(MSG* msg)
|
||
#endif
|
||
{
|
||
if(!acdbCurDwg())
|
||
return FALSE;
|
||
|
||
BOOL bRet = FALSE;
|
||
m_sKeyWordList.MakeUpper();
|
||
switch(msg->message)
|
||
{
|
||
case WM_KEYDOWN: //键盘输入关键字
|
||
{
|
||
if (msg->wParam == VK_RETURN||
|
||
msg->wParam == VK_SPACE)// 键盘输入空格或回车 add by lxb on 2011/11/28
|
||
{
|
||
m_rtRet = RTNONE;
|
||
msg->wParam = VK_SPACE;
|
||
}
|
||
else
|
||
{
|
||
CString sKey(TCHAR(msg->wParam));
|
||
sKey.MakeUpper();
|
||
if (m_sKeyWordList.Find(sKey) != -1)
|
||
{
|
||
//ads_printf(sKey);
|
||
m_chRet = sKey[0];
|
||
m_rtRet = RTKWORD;
|
||
msg->wParam = VK_SPACE;
|
||
}
|
||
}
|
||
}
|
||
break;
|
||
case WM_RBUTTONDOWN: // 鼠标右键
|
||
{
|
||
m_rtRet = RTNONE;
|
||
msg->wParam = VK_SPACE;
|
||
}
|
||
break;
|
||
default:
|
||
break;
|
||
}
|
||
|
||
return bRet;
|
||
}
|
||
|
||
int CSelectStruct::SelectEnts(CString csPrompt,PickSet &ssResult, const TRBList &rbBaseMask,const TCHAR* szKeyword, TCHAR &chRet)
|
||
{
|
||
if (szKeyword == NULL)
|
||
m_sKeyWordList = _T("");
|
||
else
|
||
m_sKeyWordList = szKeyword;
|
||
m_rtRet = RTERROR;
|
||
// 钩子函数监视键盘中输入关键字
|
||
acedRegisterFilterWinMsg(KeyFilter);
|
||
|
||
// 保存返回结果
|
||
int nRet = 0;
|
||
const TCHAR *szTempPrompts[2]={csPrompt, _T("") };
|
||
int iRet = ssResult.Get(_T(":S:$"), szTempPrompts, NULL, rbBaseMask);
|
||
if (m_rtRet == RTKWORD)
|
||
{
|
||
chRet = m_chRet;
|
||
nRet = RTKWORD;
|
||
}
|
||
else if (m_rtRet == RTNONE)
|
||
{
|
||
nRet = RTNONE;
|
||
}
|
||
else
|
||
nRet = iRet;
|
||
|
||
// 释放函数
|
||
acedRemoveFilterWinMsg(KeyFilter);
|
||
return nRet;
|
||
}
|
||
|
||
int SelectEntitiesOnce(CString csPrompt,PickSet &ssResult, const TRBList &rbBaseMask,const TCHAR* szKeyword, TCHAR &chRet)
|
||
{
|
||
return CSelectStruct::SelectEnts(csPrompt, ssResult, rbBaseMask, szKeyword, chRet);
|
||
} |