Files
envi-code/SourceCode/Code2026/tg_shs/shs_kerncmd/BuildingArea.cpp
T
2026-09-28 15:28:50 +08:00

2069 lines
56 KiB
C++

#include "stdafx.h"
#include "resource.h"
#include "actrans.h"
#include "buildingArea.h"
// Zyu add on 100826,面积统计对话框
#include "CountAreaDlg.h"
//由标准层层号得到标准层的重复数,标准层可以包括多层(如2-5)
long GetLayerNum(CString sLayerNo)
{
DList<int> lst;
::StrToIntList(sLayerNo,lst);
return lst.Length();
}
extern CString GetAreaText(double dUseArea);
TBAHouseData::TBAHouseData(TBAHouse& house,int floorNum):m_arrayLayerNum(floorNum)
{
m_lstHouse.AddTail(&house);
m_arrayLayerNum.SetAll(0);
m_polyOutline=house.GetOutline();
m_sName=house.GetName();
m_sType=house.GetHouseType();
m_fSpaceArea=house.GetSpaceArea();
m_fBalconyArea=house.GetBalconyArea();
// Zyu modify on 100906,套内建筑面积包括阳台面积
//m_fBuildArea=house.GetBuildArea();
m_fBuildArea=house.GetBuildAreaEx();
m_fWallArea=house.GetWallArea();
m_fSharedArea=house.GetSharedArea();
m_fStatisticsArea=house.GetStatisticsBuildArea();
m_fStatisticsAreaEx=house.GetStatisticsBuildAreaEx();
m_fBalconyAreaEx=house.GetBalconyAreaEx();
//add by fxj 090622 加入跃层处理
TBAHouse* pHouseUp=house.GetHouseUp();
// sg modify 110420,支持多层跃层
while (pHouseUp != NULL)
// if (pHouseUp!=NULL)
{
m_fSpaceArea+=pHouseUp->GetSpaceArea();
m_fBalconyArea+=pHouseUp->GetBalconyArea();
// Zyu modify on 100906,套内建筑面积包括阳台面积
//m_fBuildArea+=pHouseUp->GetBuildArea();
m_fBuildArea+=pHouseUp->GetBuildAreaEx();
m_fWallArea+=pHouseUp->GetWallArea();
m_fSharedArea+=pHouseUp->GetSharedArea();
m_fStatisticsArea+=pHouseUp->GetStatisticsBuildArea();
m_fStatisticsAreaEx+=pHouseUp->GetStatisticsBuildAreaEx();
m_fBalconyAreaEx+=pHouseUp->GetBalconyAreaEx();
// sg add 110420,支持多层跃层
pHouseUp = pHouseUp->GetHouseUp();
}
m_fSharedAreaEx=m_fStatisticsAreaEx-m_fSpaceArea;
}
void TBAHouseData::AppendHouse(TBAHouse *pHouse)
{
//del by fxj 090610 套型一样是很普遍的,不算冲突
//if (!m_lstHouse[0]->IsSimilarHouse(*pHouse))
// adsout<<_T("\n套型")<<(const TCHAR*)m_sName<<_T("编号发现有冲突!");
m_lstHouse.AddTail(pHouse);
}
long TBAHouseData::GetTotalNum()const
{
long num=0;
for(long i=0;i<m_arrayLayerNum.GetLength();i++)
{
//modified by fxj
long nLayerNum=GetLayerNum(m_arrayLayerName.GetAt(i));
num+=m_arrayLayerNum.GetAt(i)*nLayerNum;
}
return num;
}
bool TBAHouseData::operator >(const TBAHouseData&a)const
{
return _tcsicmp(m_sName,a.m_sName)>0;
}
bool TBAHouseData::operator ==(const TBAHouseData&a)const
{
return _tcsicmp(m_sName,a.m_sName)>0;
}
///////////////////////////////////////////////////////////////////////////////////////////////////////
//根据户对象,构造户型列表,同时统计每层的数量
void TBAHouseDataList::Append(TBAHouse* pHouse,long floorIndex,long floorNum)
{
TBAHouseData *pHD=new TBAHouseData(*pHouse,floorNum);
if (!SortIn(pHD))//同一编号的户型已经存在
{
delete pHD;
pHD=GetCurData();
pHD->AppendHouse(pHouse);
}
pHD->m_arrayLayerNum[floorIndex]+=1;//所在层计数
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
//标准层面积统计,共用面积只进行层内分摊
void FloorArea()
{
RBList mask=ads_buildlist(RTDXF0,_T("TCH_SPACE"),8,
(const TCHAR*)XString(_T("%s,%s,%s,%s,%s,%s"),LAY_BUILDING_SPACE,LAY_HOUSE_SPACE,LAY_SHARE_SPACE,LAY_BALCONY_SPACE,LAY_SPACE,LAY_HOLE_SPACE),
NULL);
PickSet ss(SS_FREE);
if (SelectEntities(_T("\n请选择需要统计的标准层房间、面积对象:"),ss,mask)!=RTNORM)
return;
TBAFloor fl;
fl.Append(ss);
fl.Share(TBAShare::kShareAll);//只进行层内分摊
double total=0;
for(fl.m_lstHouse.MoveToFirst();!fl.m_lstHouse.IsOut();fl.m_lstHouse.MoveToNext())
{
TBAHouse *pHouse=(TBAHouse*)(fl.m_lstHouse.GetCurData());
adsout<<_T("\n套名:")<<pHouse->GetName()
<<_T(",使用面积:")<<_AS_SQMETER(pHouse->GetSpaceArea())
<<_T(",阳台面积:")<<_AS_SQMETER(pHouse->GetBalconyArea())
<<_T(",套内建筑面积:")<<_AS_SQMETER(pHouse->GetBuildArea())
<<_T(",分摊面积:")<<_AS_SQMETER(pHouse->GetSharedArea())
<<_T(",建筑面积:")<<_AS_SQMETER(pHouse->GetStatisticsBuildArea())
<<_T(",套型建筑面积:")<<_AS_SQMETER(pHouse->GetStatisticsBuildAreaEx());
total+=pHouse->GetStatisticsBuildArea();
}
adsout<<_T("\n套内阳台总面积:")<<_AS_SQMETER(fl.GetHouseBalconyArea());
adsout<<_T("\n套内总使用面积:")<<_AS_SQMETER(fl.GetHouseSpaceArea());
adsout<<_T("\n套内总面积:")<<_AS_SQMETER(fl.GetHouseArea());
adsout<<_T("\n公摊面积:")<<_AS_SQMETER(fl.GetShareArea(TBAShare::kShareAll));
adsout<<_T("\n建筑总面积:")<<_AS_SQMETER(fl.GetStatisticsBuildArea());
adsout<<_T("\n套面积总和:")<<_AS_SQMETER(total);
}
////////////////////////////////////////////////////////////////////////////////////
ProjectTreeGrid::ProjectTreeGrid():WDGrid(true)
{
}
CAreaChildDlg::CAreaChildDlg(TBABuilding *pBuilding)
{
m_pBuilding=pBuilding;
}
BOOL CAreaChildDlg::OnInitDialog()
{
CAcUiTabChildDialog::OnInitDialog();
ShowGrid();
return TRUE;
}
void CAreaChildDlg::ShowGrid()
{
m_grid.Clear();
//------add 080903------
int oldColNum=m_grid.GetColNum();
for(int i=oldColNum-1;i>-1;i--)
{
m_grid.DelCol(i);
}
//-----------------------
m_grid.SetReadOnly();
m_grid.AppendCol(_T("楼层\\户号"), 70);
m_grid.AppendCol(_T("编号"), 30);
m_grid.AppendCol(_T("套型"), 70);
m_grid.AppendCol(_T("套内使用面积"), 80);
m_grid.AppendCol(_T("套内墙体面积"), 80);
m_grid.AppendCol(_T("阳台面积"), 60);
m_grid.AppendCol(_T("套内建筑面积"), 80);
m_grid.AppendCol(_T("分摊面积"), 60);
m_grid.AppendCol(_T("建筑面积(含阳台)"), 100);
m_grid.SetColPosFix();
m_grid.SetColFixLength();
m_grid.Create(this, IDC_BUD_LIST);
m_grid.FitLastCol();
double dTotalSpace=0,dTotalWall=0,dTotalBalcony=0,dTotalBuild=0,dTotalShared=0,dTotalStatisticsBuild=0;
for(m_pBuilding->MoveToFirst();!m_pBuilding->IsOut();m_pBuilding->MoveToNext())
{
TBAFloor *pFloor=(TBAFloor*)m_pBuilding->GetCurData();
WDGridTreeRow *pRow=new WDGridTreeRow(m_grid);
TProjectFloor *pFloorDef=pFloor->m_pFloorDef;
CString strLayNo;
if (!pFloorDef)
strLayNo=_T("1");
else
{
strLayNo=pFloorDef->GetLayerNo();
}
int nFloorNum=1;
nFloorNum=GetLayerNum(strLayNo);
strLayNo+=_T("层");
(*pRow)[0].SetText(strLayNo);
double dSumSpaceArea=0,dSumWallArea=0,dSumBalconyArea=0,dSumBuildArea=0,dSumSharedArea=0,dSumStatisticsBuildArea=0;
int nUpNum=0;//当前层是跃层上层的户数
for(pFloor->m_lstHouse.MoveToFirst();!pFloor->m_lstHouse.IsOut();pFloor->m_lstHouse.MoveToNext())
{
TBAHouse *pHouse =(TBAHouse*)pFloor->m_lstHouse.GetCurData();
WDGridTreeRow *pNewRow = new WDGridTreeRow(pRow);
//modified 090622 加入跃层处理.跃层的上层不再输出,上层的数据被加入下层
double dSpaceArea=0;
double dWallArea=0;
double dBalconyArea=0;
double dBuildArea=0;
double dSharedArea=0;
double dStatisticsBuildArea=0;
if (pHouse->IsHouseUp())
{
nUpNum++;
if (pNewRow!=NULL)
delete pNewRow;
continue;
}
dSpaceArea=pHouse->GetSpaceArea();
dWallArea=pHouse->GetWallArea();
dBalconyArea=pHouse->GetBalconyArea();
// Zyu modify on 100906,套内建筑面积包括阳台面积
//dBuildArea=pHouse->GetBuildArea();
dBuildArea=pHouse->GetBuildAreaEx();
dSharedArea=pHouse->GetSharedArea();
dStatisticsBuildArea=pHouse->GetStatisticsBuildArea();
TBAHouse* pHouseUp=pHouse->GetHouseUp();
// 问题描述:只能统计跃一层的情况
// 修改描述:在统计时不受层数限制,只要套内面积的户号相同,
// 即认为是跃层,可以统计跃两层或多层的情况
// 修改人、修改时间:Zyu modify on 100909
// Begin
if (pHouseUp!=NULL)
{
CString sLayCode=strLayNo;
sLayCode+=_T("户号");
sLayCode+=pHouseUp->GetCode();
sLayCode+=_T(",");
m_lstUpHouseCode.AddTail(sLayCode);
// Zyu add on 100909,循环取上层
while (pHouseUp)
{
dSpaceArea+=pHouseUp->GetSpaceArea();
dWallArea+=pHouseUp->GetWallArea();
dBalconyArea+=pHouseUp->GetBalconyArea();
// Zyu modify on 100906,套内建筑面积包括阳台面积
//dBuildArea+=pHouseUp->GetBuildArea();
dBuildArea+=pHouseUp->GetBuildAreaEx();
dSharedArea+=pHouseUp->GetSharedArea();
dStatisticsBuildArea+=pHouseUp->GetStatisticsBuildArea();
// Zyu add on 100909,循环取上层
pHouseUp = pHouseUp->GetHouseUp();
}
}
// End
(*pNewRow)[0].SetText(pHouse->GetCode());
(*pNewRow)[1].SetText(pHouse->GetName());
(*pNewRow)[2].SetText(pHouse->GetHouseType());
(*pNewRow)[3].SetText(GetAreaText(_AS_SQMETER(dSpaceArea)));
(*pNewRow)[4].SetText(GetAreaText(_AS_SQMETER(dWallArea)));
(*pNewRow)[5].SetText(GetAreaText(_AS_SQMETER(dBalconyArea)));
(*pNewRow)[6].SetText(GetAreaText(_AS_SQMETER(dBuildArea)));
(*pNewRow)[7].SetText(GetAreaText(_AS_SQMETER(dSharedArea)));
(*pNewRow)[8].SetText(GetAreaText(_AS_SQMETER(dStatisticsBuildArea)));
dSumSpaceArea+=dSpaceArea;
dSumWallArea+=dWallArea;
dSumBalconyArea+=dBalconyArea;
dSumBuildArea+=dBuildArea;
dSumSharedArea+=dSharedArea;
dSumStatisticsBuildArea+=dStatisticsBuildArea;
pRow->AppendChild(pNewRow);
}
if (pFloor->m_lstHouse.GetLength()==nUpNum)
{
if (pRow!=NULL)
delete pRow;
continue;
}
m_grid.AppendRow(pRow);
WDGridTreeRow *pSumRow = new WDGridTreeRow(pRow);
(*pSumRow)[0].SetText(_T("合计"));
(*pSumRow)[1].SetText(_T("--"));
(*pSumRow)[2].SetText(_T("--"));
(*pSumRow)[3].SetText(GetAreaText(_AS_SQMETER(dSumSpaceArea)));
(*pSumRow)[4].SetText(GetAreaText(_AS_SQMETER(dSumWallArea)));
(*pSumRow)[5].SetText(GetAreaText(_AS_SQMETER(dSumBalconyArea)));
(*pSumRow)[6].SetText(GetAreaText(_AS_SQMETER(dSumBuildArea)));
(*pSumRow)[7].SetText(GetAreaText(_AS_SQMETER(dSumSharedArea)));
(*pSumRow)[8].SetText(GetAreaText(_AS_SQMETER(dSumStatisticsBuildArea)));
pRow->AppendChild(pSumRow);
dTotalSpace+=(dSumSpaceArea*nFloorNum);
dTotalWall+=(dSumWallArea*nFloorNum);
dTotalBalcony+=(dSumBalconyArea*nFloorNum);
dTotalBuild+=(dSumBuildArea*nFloorNum);
dTotalShared+=(dSumSharedArea*nFloorNum);
dTotalStatisticsBuild+=(dSumStatisticsBuildArea*nFloorNum);
}
WDGridTreeRow *pTotalRow=new WDGridTreeRow(m_grid);
(*pTotalRow)[0].SetText(_T("合计"));
(*pTotalRow)[1].SetText(_T("--"));
(*pTotalRow)[2].SetText(_T("--"));
(*pTotalRow)[3].SetText(GetAreaText(_AS_SQMETER(dTotalSpace)));
(*pTotalRow)[4].SetText(GetAreaText(_AS_SQMETER(dTotalWall)));
(*pTotalRow)[5].SetText(GetAreaText(_AS_SQMETER(dTotalBalcony)));
(*pTotalRow)[6].SetText(GetAreaText(_AS_SQMETER(dTotalBuild)));
(*pTotalRow)[7].SetText(GetAreaText(_AS_SQMETER(dTotalShared)));
(*pTotalRow)[8].SetText(GetAreaText(_AS_SQMETER(dTotalStatisticsBuild)));
m_grid.AppendRow(pTotalRow);
}
BOOL CAreaChildDlg::GetSheet(TDbSheet *pSheet)
{
AcDbObjectId idTextStyle = InitTextStyle(TS_SPACE);
if (!idTextStyle)
{
acutPrintf(_T("\n初始化文字样式失败!"));
return FALSE;
}
int iRow = m_grid.GetRowNum() + 2;
const int iCol = 10;
const double dColWidArray[iCol] = {20, 20,20,40,40,40,40,40,40,40};
pSheet->InitSheet(iRow, iCol, 7.0, 14.0);
TSheetColumn column;
for(int i=0; i<iCol; i++)
{
column.SetWidth(dColWidArray[i]);
pSheet->SetColumnAt(i, column);
}
TGridStyle gridStyle;
gridStyle.SetOverrideAll(TRUE);
gridStyle.SetTextWrap(TRUE);
gridStyle.SetHorMode(AcDb::kTextMid);
gridStyle.SetVerMode(AcDb::kTextVertMid);
gridStyle.SetTextHeight(3.5);
gridStyle.SetTextStyleId(idTextStyle);
pSheet->SetGridStyle(gridStyle);
pSheet->SetRowHeightStyle(TSheetRow::kAutomatic);
pSheet->SetTitleText(_T("建筑面积统计表(m^U2^U)"));
TSheetTitle &title=pSheet->GetTitle();
TDividerStyle &dStyle=title.GetDividerStyle();
TGridStyle &titleGridStyle=title.GetGridStyle();
dStyle.SetDividerFlag(TDividerStyle::kNone);
titleGridStyle.SetTextHeight(5.0);
TDbSheet &rSheet=*pSheet;
TGridCell *pCell;
rSheet.MergeCells(0,0, 1,0);
pCell=rSheet(0, 0);
pCell->SetText(_T("楼层"));
rSheet.MergeCells(0,1,0,3);
pCell=rSheet(0,1);
pCell->SetText(_T("分户"));
rSheet.MergeCells(0,4,0,9);
pCell=rSheet(0,4);
pCell->SetText(_T("面积分类(m^U2^U)"));
pCell=rSheet(1,1);
pCell->SetText(_T("户号"));
pCell=rSheet(1,2);
pCell->SetText(_T("编号"));
pCell=rSheet(1,3);
pCell->SetText(_T("套型"));
pCell=rSheet(1,4);
pCell->SetText(_T("套内使用面积"));
pCell=rSheet(1,5);
pCell->SetText(_T("套内墙体面积"));
pCell=rSheet(1,6);
pCell->SetText(_T("阳台面积"));
pCell=rSheet(1,7);
pCell->SetText(_T("套内建筑面积"));
pCell=rSheet(1,8);
pCell->SetText(_T("分摊面积"));
pCell=rSheet(1,9);
pCell->SetText(_T("建筑面积(含阳台)"));
// 添加内容
int k=2;
for(i=0;i<iRow-2;i++)
{
WDGridTreeRow &row=(WDGridTreeRow&)m_grid.GetRow(i);
if (row.IsChildRow())
continue;
if (row.IsParentRow())
{
if (!row.IsChildVisible())
{
for(int j=0;j<row.GetChildNum();j++)
rSheet.AddRowAt(rSheet.GetRowNum());
}
rSheet.MergeCells(k,0,k+row.GetChildNum()-1,0);
TGridCell *pCell=rSheet(k,0);
pCell->SetText(row[0].GetText());
for(int j=0;j<row.GetChildNum();j++)
{
WDGridTreeRow &rowChild = row.GetChild(j);
for(int h=1;h<iCol; h++)
{
CString szText;
szText = rowChild[h-1].GetText();
TGridCell *pCell = rSheet(k, h);
if (pCell != NULL)
pCell->SetText(szText);
}
k++;
}
}
else
{
TGridCell *pCell = rSheet(k, 0);
pCell->SetText(_T("合计"));
pCell = rSheet(k, 1);
pCell->SetText(_T("--"));
for(int h=2;h<iCol; h++)
{
CString szText;
szText = row[h-1].GetText();
TGridCell *pCell = rSheet(k, h);
if (pCell != NULL)
pCell->SetText(szText);
}
k++;
}
}
//删除空行
iRow=rSheet.GetRowNum();
TGridCell *pCelltemp=rSheet(iRow-1,1);
CString str=pCelltemp->GetText();
while(str==_T(""))
{
rSheet.RemoveRow(iRow-1);
iRow--;
TGridCell *pCelltemp=rSheet(iRow-1,1);
str=pCelltemp->GetText();
}
pSheet->CalculateRowHeight(0, pSheet->GetRowNum()-1);
return TRUE;
}
///////////////////////////////////////////////////
CPatternStaChildDlg::CPatternStaChildDlg(TBAHouseDataList *pListHouseData)
{
m_pLstHouseData=pListHouseData;
}
BOOL CPatternStaChildDlg::OnInitDialog()
{
CAcUiTabChildDialog::OnInitDialog();
ShowGrid();
return TRUE;
}
void CPatternStaChildDlg::ShowGrid()
{
m_grid.Clear();
//------add 080903------
int oldColNum=m_grid.GetColNum();
for(int i=oldColNum-1;i>-1;i--)
{
m_grid.DelCol(i);
}
//-----------------------
m_grid.SetReadOnly();
m_grid.AppendCol(_T("编号"), 30);
m_grid.AppendCol(_T("套型"), 70);
m_grid.AppendCol(_T("套内使用面积"), 80);
m_grid.AppendCol(_T("套内墙体面积"), 80);
m_grid.AppendCol(_T("阳台面积"), 60);
m_grid.AppendCol(_T("套内建筑面积"), 80);
m_grid.AppendCol(_T("分摊面积"), 70);
m_grid.AppendCol(_T("建筑面积(含阳台)"), 100);
if (m_pLstHouseData->GetLength()<1)//add 090213
return;
TBAHouseData *pFirstHouseData=*(m_pLstHouseData->GetFirst());
int nFloorNum=pFirstHouseData->m_arrayLayerNum.GetLength();
for(i=0;i<nFloorNum;i++)
{
CString strLayNo=pFirstHouseData->m_arrayLayerName.GetAt(i);
strLayNo+=_T("层");
// Zyu modify on 100902,调整布局
//m_grid.AppendCol(strLayNo,40);
m_grid.AppendCol(strLayNo,30);
}
m_grid.AppendCol(_T("合计"),40);
m_grid.SetColPosFix();
m_grid.SetColFixLength();
m_grid.Create(this, IDC_STYLE_LIST);
m_grid.FitLastCol();
int nColNum=m_grid.GetColNum();
for(m_pLstHouseData->MoveToFirst();!m_pLstHouseData->IsOut();m_pLstHouseData->MoveToNext())
{
TBAHouseData *pHouseData=m_pLstHouseData->GetCurData();
WDGridRow *pRow=new WDGridRow(m_grid);
(*pRow)[0].SetText(pHouseData->m_sName);
(*pRow)[1].SetText(pHouseData->m_sType);
(*pRow)[2].SetText(GetAreaText(_AS_SQMETER(pHouseData->m_fSpaceArea)));
(*pRow)[3].SetText(GetAreaText(_AS_SQMETER(pHouseData->m_fWallArea)));
(*pRow)[4].SetText(GetAreaText(_AS_SQMETER(pHouseData->m_fBalconyArea)));
(*pRow)[5].SetText(GetAreaText(_AS_SQMETER(pHouseData->m_fBuildArea)));
(*pRow)[6].SetText(GetAreaText(_AS_SQMETER(pHouseData->m_fSharedArea)));
(*pRow)[7].SetText(GetAreaText(_AS_SQMETER(pHouseData->m_fStatisticsArea)));
for(int j=0;j<nFloorNum;j++)
{
int nHouse=pHouseData->m_arrayLayerNum[j];
(*pRow)[8+j].SetText(XString(_T("%d"),nHouse));
}
(*pRow)[nColNum-1].SetText(XString(_T("%d"),pHouseData->GetTotalNum()));
m_grid.AppendRow(pRow);
}
}
BOOL CPatternStaChildDlg::GetSheet(TDbSheet *pSheet)
{
AcDbObjectId idTextStyle = InitTextStyle(TS_SPACE);
if (!idTextStyle)
{
acutPrintf(_T("\n初始化文字样式失败!"));
return FALSE;
}
int iRow = m_grid.GetRowNum() + 2;
const int iCol = m_grid.GetColNum();
const double dColWidArray[8] = {20,20,40,40,40,40,40,40};
pSheet->InitSheet(iRow, iCol, 7.0, 14.0);
TGridStyle gridStyle;
gridStyle.SetOverrideAll(TRUE);
gridStyle.SetTextWrap(TRUE);
gridStyle.SetHorMode(AcDb::kTextMid);
gridStyle.SetVerMode(AcDb::kTextVertMid);
gridStyle.SetTextHeight(3.5);
gridStyle.SetTextStyleId(idTextStyle);
pSheet->SetGridStyle(gridStyle);
pSheet->SetRowHeightStyle(TSheetRow::kAutomatic);
// Zyu modify on 100902,修改表格名称
//pSheet->SetTitleText(_T("套型统计表(m^U2^U)"));
pSheet->SetTitleText(_T("房产套型统计表(m^U2^U)"));
TSheetTitle &title=pSheet->GetTitle();
TDividerStyle &dStyle=title.GetDividerStyle();
TGridStyle &titleGridStyle=title.GetGridStyle();
dStyle.SetDividerFlag(TDividerStyle::kNone);
titleGridStyle.SetTextHeight(5.0);
TSheetColumn column;
for(int i=0; i<8; i++)
{
column.SetWidth(dColWidArray[i]);
pSheet->SetColumnAt(i, column);
}
for(i=8;i<iCol;i++)
{
column.SetWidth(20);
pSheet->SetColumnAt(i,column);
}
TDbSheet &rSheet=*pSheet;
TGridCell *pCell;
rSheet.MergeCells(0,0, 1,0);
pCell=rSheet(0, 0);
pCell->SetText(_T("编号"));
rSheet.MergeCells(0,1,1,1);
pCell=rSheet(0,1);
pCell->SetText(_T("套型"));
rSheet.MergeCells(0,2,0,7);
pCell=rSheet(0,2);
pCell->SetText(_T("面积分类(m^U2^U)"));
pCell=rSheet(1,2);
pCell->SetText(_T("套内使用面积"));
pCell=rSheet(1,3);
pCell->SetText(_T("套内墙体面积"));
pCell=rSheet(1,4);
pCell->SetText(_T("阳台面积"));
pCell=rSheet(1,5);
pCell->SetText(_T("套内建筑面积"));
pCell=rSheet(1,6);
pCell->SetText(_T("分摊面积"));
pCell=rSheet(1,7);
pCell->SetText(_T("建筑面积(含阳台)"));
rSheet.MergeCells(0,8,0,iCol-1);
pCell=rSheet(0,8);
// Zyu modify on 100827,修改名称
//pCell->SetText(_T("户数"));
pCell->SetText(_T("套数"));
for(i=8;i<iCol;i++)
{
WDGridCol &col=m_grid.GetCol(i);
CString sColName=col.GetName();
pCell=rSheet(1,i);
pCell->SetText(sColName);
}
for(int j=2;j<iRow;j++)
{
for(int h=0;h<iCol;h++)
{
pCell=rSheet(j,h);
pCell->SetText(m_grid.GetCell(j-2,h).GetText());
}
}
pSheet->CalculateRowHeight(0, pSheet->GetRowNum()-1);
return TRUE;
}
//////////////////////////////////////////////////////////////////////////
// Zyu add on 100827,住宅套型统计表
///////////////////////////////////////////////////
CHousePtnStaChildDlg::CHousePtnStaChildDlg(TBAHouseDataList *pListHouseData)
{
m_pLstHouseData=pListHouseData;
}
BOOL CHousePtnStaChildDlg::OnInitDialog()
{
CAcUiTabChildDialog::OnInitDialog();
ShowGrid();
return TRUE;
}
void CHousePtnStaChildDlg::ShowGrid()
{
m_grid.Clear();
int oldColNum=m_grid.GetColNum();
for(int i=oldColNum-1;i>-1;i--)
{
m_grid.DelCol(i);
}
m_grid.SetReadOnly();
m_grid.AppendCol(_T("编号"), 30);
m_grid.AppendCol(_T("套型"), 70);
m_grid.AppendCol(_T("套内使用面积 S1"), 100);
m_grid.AppendCol(_T("分摊面积 S2"), 90);
m_grid.AppendCol(_T("套型建筑面积 S1+S2"), 80);
m_grid.AppendCol(_T("阳台面积"), 60);
if (m_pLstHouseData->GetLength()<1)
return;
TBAHouseData *pFirstHouseData=*(m_pLstHouseData->GetFirst());
int nFloorNum=pFirstHouseData->m_arrayLayerNum.GetLength();
for(i=0;i<nFloorNum;i++)
{
CString strLayNo=pFirstHouseData->m_arrayLayerName.GetAt(i);
strLayNo+=_T("层");
m_grid.AppendCol(strLayNo,40);
}
m_grid.AppendCol(_T("合计"),40);
m_grid.SetColPosFix();
m_grid.SetColFixLength();
m_grid.Create(this, IDC_LST_STYLE);
m_grid.FitLastCol();
int nColNum=m_grid.GetColNum();
for(m_pLstHouseData->MoveToFirst();!m_pLstHouseData->IsOut();m_pLstHouseData->MoveToNext())
{
TBAHouseData *pHouseData=m_pLstHouseData->GetCurData();
WDGridRow *pRow=new WDGridRow(m_grid);
(*pRow)[0].SetText(pHouseData->m_sName);
(*pRow)[1].SetText(pHouseData->m_sType);
(*pRow)[2].SetText(GetAreaText(_AS_SQMETER(pHouseData->m_fSpaceArea)));
(*pRow)[3].SetText(GetAreaText(_AS_SQMETER(pHouseData->m_fSharedAreaEx)));
(*pRow)[4].SetText(GetAreaText(_AS_SQMETER(pHouseData->m_fSpaceArea + pHouseData->m_fSharedAreaEx)));
(*pRow)[5].SetText(GetAreaText(_AS_SQMETER(pHouseData->m_fBalconyArea)));
for(int j=0;j<nFloorNum;j++)
{
int nHouse=pHouseData->m_arrayLayerNum[j];
(*pRow)[6+j].SetText(XString(_T("%d"),nHouse));
}
(*pRow)[nColNum-1].SetText(XString(_T("%d"),pHouseData->GetTotalNum()));
m_grid.AppendRow(pRow);
}
}
BOOL CHousePtnStaChildDlg::GetSheet(TDbSheet *pSheet)
{
AcDbObjectId idTextStyle = InitTextStyle(TS_SPACE);
if (!idTextStyle)
{
acutPrintf(_T("\n初始化文字样式失败!"));
return FALSE;
}
int iRow = m_grid.GetRowNum() + 2;
const int iCol = m_grid.GetColNum();
const double dColWidArray[6] = {20,20,40,40,40,40};
pSheet->InitSheet(iRow, iCol, 7.0, 14.0);
TGridStyle gridStyle;
gridStyle.SetOverrideAll(TRUE);
gridStyle.SetTextWrap(TRUE);
gridStyle.SetHorMode(AcDb::kTextMid);
gridStyle.SetVerMode(AcDb::kTextVertMid);
gridStyle.SetTextHeight(3.5);
gridStyle.SetTextStyleId(idTextStyle);
pSheet->SetGridStyle(gridStyle);
pSheet->SetRowHeightStyle(TSheetRow::kAutomatic);
pSheet->SetTitleText(_T("住宅套型统计表(m^U2^U)"));
TSheetTitle &title=pSheet->GetTitle();
TDividerStyle &dStyle=title.GetDividerStyle();
TGridStyle &titleGridStyle=title.GetGridStyle();
dStyle.SetDividerFlag(TDividerStyle::kNone);
titleGridStyle.SetTextHeight(5.0);
TSheetColumn column;
for(int i=0; i<6; i++)
{
column.SetWidth(dColWidArray[i]);
pSheet->SetColumnAt(i, column);
}
for(i=6;i<iCol;i++)
{
column.SetWidth(20);
pSheet->SetColumnAt(i,column);
}
TDbSheet &rSheet=*pSheet;
TGridCell *pCell;
rSheet.MergeCells(0,0, 1,0);
pCell=rSheet(0, 0);
pCell->SetText(_T("编号"));
rSheet.MergeCells(0,1,1,1);
pCell=rSheet(0,1);
pCell->SetText(_T("套型"));
rSheet.MergeCells(0,2,0,5);
pCell=rSheet(0,2);
pCell->SetText(_T("面积分类(m^U2^U)"));
pCell=rSheet(1,2);
pCell->SetText(_T("套内使用面积 S1"));
pCell=rSheet(1,3);
pCell->SetText(_T("分摊面积 S2"));
pCell=rSheet(1,4);
pCell->SetText(_T("套型建筑面积 S1+S2"));
pCell=rSheet(1,5);
pCell->SetText(_T("阳台面积"));
rSheet.MergeCells(0,6,0,iCol-1);
pCell=rSheet(0,6);
pCell->SetText(_T("套数"));
for(i=6;i<iCol;i++)
{
WDGridCol &col=m_grid.GetCol(i);
CString sColName=col.GetName();
pCell=rSheet(1,i);
pCell->SetText(sColName);
}
for(int j=2;j<iRow;j++)
{
for(int h=0;h<iCol;h++)
{
pCell=rSheet(j,h);
pCell->SetText(m_grid.GetCell(j-2,h).GetText());
}
}
pSheet->CalculateRowHeight(0, pSheet->GetRowNum()-1);
return TRUE;
}
//////////////////////////////////////////////////
CPatternAnaChildDlg::CPatternAnaChildDlg(TBAHouseDataList *pListHouseData)
{
m_pLstHouseData=pListHouseData;
}
BOOL CPatternAnaChildDlg::OnInitDialog()
{
CAcUiTabChildDialog::OnInitDialog();
ShowGrid();
return TRUE;
}
void CPatternAnaChildDlg::ShowGrid()
{
m_grid.Clear();
//------add 080903------
int oldColNum=m_grid.GetColNum();
for(int i=oldColNum-1;i>-1;i--)
{
m_grid.DelCol(i);
}
//-----------------------
m_grid.SetReadOnly();
m_grid.AppendCol(_T("分类\\套型\\编号"), 110);
// Zyu modify on 100902,调整布局
//m_grid.AppendCol(_T("套内使用面积 S1"), 80);
m_grid.AppendCol(_T("套内使用面积 S1"), 100);
m_grid.AppendCol(_T("分摊面积 S2"), 80);
// Zyu modify on 100902,调整布局
//m_grid.AppendCol(_T("阳台面积"), 80);
//m_grid.AppendCol(_T("套型建筑面积 S1+S2"),100);
m_grid.AppendCol(_T("套型建筑面积 S1+S2"),120);
m_grid.AppendCol(_T("阳台面积"), 60);
// Zyu modify on 100827,修改名称
//m_grid.AppendCol(_T("户数 N"), 50);
m_grid.AppendCol(_T("套数 N"), 50);
m_grid.AppendCol(_T("套型总面积 (S1+S2)*N"), 130);
m_grid.AppendCol(_T("比例"), 50);
m_grid.SetColPosFix();
m_grid.SetColFixLength();
m_grid.Create(this, IDC_ANA_LIST);
m_grid.FitLastCol();
DualList<TBAHouseData*> lstHouseDataS;
DualList<TBAHouseData*> lstHouseDataL;
double sqmeterTotalAreaEx=0;
for(m_pLstHouseData->MoveToFirst();!m_pLstHouseData->IsOut();m_pLstHouseData->MoveToNext())
{
TBAHouseData *pHD=NULL;
pHD=m_pLstHouseData->GetCurData();
sqmeterTotalAreaEx+=_AS_SQMETER((pHD->m_fStatisticsAreaEx)*(pHD->GetTotalNum()));
if (_AS_SQMETER(pHD->m_fStatisticsAreaEx)-90>1E-6)
lstHouseDataL.AddTail(pHD);
else
lstHouseDataS.AddTail(pHD);
}
if (lstHouseDataS.GetLength()>=1)
{
WDGridTreeRow *pRow=new WDGridTreeRow(m_grid);
(*pRow)[0].SetText(_T("90平米内"));
m_grid.AppendRow(pRow);
double totalSpaceArea=0,totalSharedAreaEx=0,totalBalconyAreaEx=0,totalStatisticsAreaEx=0,totalAllAreaEx=0;
int totalNum=0;
while(lstHouseDataS.GetLength()!=0)
{
TBAHouseData *pFirstHD=*(lstHouseDataS.GetFirst());
CString sType=pFirstHD->m_sType;
WDGridTreeRow *pRowChild1=new WDGridTreeRow(pRow);
(*pRowChild1)[0].SetText(sType);
pRow->AppendChild(pRowChild1);
double sumSpaceArea=0,sumSharedAreaEx=0,sumBalconyAreaEx=0,sumStatisticsAreaEx=0,sumAllAreaEx=0;
int sumNum=0;
for(lstHouseDataS.MoveToFirst();!lstHouseDataS.IsOut();lstHouseDataS.MoveToNext())
{
TBAHouseData *pCurHD=lstHouseDataS.GetCurData();
if (pCurHD->m_sType!=sType)
continue;
WDGridTreeRow *pRowChild2=new WDGridTreeRow(pRowChild1);
(*pRowChild2)[0].SetText(pCurHD->m_sName);
(*pRowChild2)[1].SetText(GetAreaText(_AS_SQMETER(pCurHD->m_fSpaceArea)));
(*pRowChild2)[2].SetText(GetAreaText(_AS_SQMETER(pCurHD->m_fSharedAreaEx)));
// Zyu modify on 100902,调整布局
//(*pRowChild2)[3].SetText(GetAreaText(_AS_SQMETER(pCurHD->m_fBalconyAreaEx)));
//(*pRowChild2)[4].SetText(GetAreaText(_AS_SQMETER(pCurHD->m_fStatisticsAreaEx)));
(*pRowChild2)[3].SetText(GetAreaText(_AS_SQMETER(pCurHD->m_fStatisticsAreaEx)));
(*pRowChild2)[4].SetText(GetAreaText(_AS_SQMETER(pCurHD->m_fBalconyAreaEx)));
(*pRowChild2)[5].SetText(XString(_T("%d"),pCurHD->GetTotalNum()));
(*pRowChild2)[6].SetText(GetAreaText(_AS_SQMETER(pCurHD->m_fStatisticsAreaEx*pCurHD->GetTotalNum())));
double fScale=0;
if (sqmeterTotalAreaEx>1E-6)
fScale=(_AS_SQMETER(pCurHD->m_fStatisticsAreaEx*pCurHD->GetTotalNum()))/sqmeterTotalAreaEx;
(*pRowChild2)[7].SetText(XString(_T("%.1f%%"),fScale*100));
pRowChild1->AppendChild(pRowChild2);
sumSpaceArea+=pCurHD->m_fSpaceArea;
sumSharedAreaEx+=pCurHD->m_fSharedAreaEx;
sumBalconyAreaEx+=pCurHD->m_fBalconyAreaEx;
sumStatisticsAreaEx+=pCurHD->m_fStatisticsAreaEx;
sumNum+=pCurHD->GetTotalNum();
sumAllAreaEx+=pCurHD->m_fStatisticsAreaEx*pCurHD->GetTotalNum();
lstHouseDataS.DelCur();
}
WDGridTreeRow *pRowSum=new WDGridTreeRow(pRowChild1);
(*pRowSum)[0].SetText(_T("合计"));
(*pRowSum)[1].SetText(GetAreaText(_AS_SQMETER(sumSpaceArea)));
(*pRowSum)[2].SetText(GetAreaText(_AS_SQMETER(sumSharedAreaEx)));
// Zyu modify on 100902,调整布局
//(*pRowSum)[3].SetText(GetAreaText(_AS_SQMETER(sumBalconyAreaEx)));
//(*pRowSum)[4].SetText(GetAreaText(_AS_SQMETER(sumStatisticsAreaEx)));
(*pRowSum)[3].SetText(GetAreaText(_AS_SQMETER(sumStatisticsAreaEx)));
(*pRowSum)[4].SetText(GetAreaText(_AS_SQMETER(sumBalconyAreaEx)));
(*pRowSum)[5].SetText(XString(_T("%d"),sumNum));
(*pRowSum)[6].SetText(GetAreaText(_AS_SQMETER(sumAllAreaEx)));
double fScale=0;
if (sqmeterTotalAreaEx>1E-6)
fScale=(_AS_SQMETER(sumAllAreaEx))/sqmeterTotalAreaEx;
(*pRowSum)[7].SetText(XString(_T("%.1f%%"),fScale*100));
pRowChild1->AppendChild(pRowSum);
totalSpaceArea+=sumSpaceArea;
totalSharedAreaEx+=sumSharedAreaEx;
totalBalconyAreaEx+=sumBalconyAreaEx;
totalStatisticsAreaEx+=sumStatisticsAreaEx;
totalNum+=sumNum;
totalAllAreaEx+=sumAllAreaEx;
}
WDGridTreeRow *pRowTotal=new WDGridTreeRow(pRow);
(*pRowTotal)[0].SetText(_T("合计"));
(*pRowTotal)[1].SetText(GetAreaText(_AS_SQMETER(totalSpaceArea)));
(*pRowTotal)[2].SetText(GetAreaText(_AS_SQMETER(totalSharedAreaEx)));
// Zyu modify on 100902,调整布局
//(*pRowTotal)[3].SetText(GetAreaText(_AS_SQMETER(totalBalconyAreaEx)));
//(*pRowTotal)[4].SetText(GetAreaText(_AS_SQMETER(totalStatisticsAreaEx)));
(*pRowTotal)[3].SetText(GetAreaText(_AS_SQMETER(totalStatisticsAreaEx)));
(*pRowTotal)[4].SetText(GetAreaText(_AS_SQMETER(totalBalconyAreaEx)));
(*pRowTotal)[5].SetText(XString(_T("%d"),totalNum));
(*pRowTotal)[6].SetText(GetAreaText(_AS_SQMETER(totalAllAreaEx)));
double fScale=0;
if (sqmeterTotalAreaEx>1E-6)
fScale=(_AS_SQMETER(totalAllAreaEx))/sqmeterTotalAreaEx;
(*pRowTotal)[7].SetText(XString(_T("%.1f%%"),fScale*100));
pRow->AppendChild(pRowTotal);
}
if (lstHouseDataL.GetLength()>=1)
{
WDGridTreeRow *pRow1=new WDGridTreeRow(m_grid);
(*pRow1)[0].SetText(_T("90平米外"));
m_grid.AppendRow(pRow1);
double totalSpaceArea=0,totalSharedAreaEx=0,totalBalconyAreaEx=0,totalStatisticsAreaEx=0,totalAllAreaEx=0;
int totalNum=0;
while(lstHouseDataL.GetLength()!=0)
{
TBAHouseData *pFirstHD=*(lstHouseDataL.GetFirst());
CString sType=pFirstHD->m_sType;
WDGridTreeRow *pRowChild1=new WDGridTreeRow(pRow1);
(*pRowChild1)[0].SetText(sType);
pRow1->AppendChild(pRowChild1);
double sumSpaceArea=0,sumSharedAreaEx=0,sumBalconyAreaEx=0,sumStatisticsAreaEx=0,sumAllAreaEx=0;
int sumNum=0;
for(lstHouseDataL.MoveToFirst();!lstHouseDataL.IsOut();lstHouseDataL.MoveToNext())
{
TBAHouseData *pCurHD=lstHouseDataL.GetCurData();
if (pCurHD->m_sType!=sType)
continue;
WDGridTreeRow *pRowChild2=new WDGridTreeRow(pRowChild1);
(*pRowChild2)[0].SetText(pCurHD->m_sName);
(*pRowChild2)[1].SetText(GetAreaText(_AS_SQMETER(pCurHD->m_fSpaceArea)));
(*pRowChild2)[2].SetText(GetAreaText(_AS_SQMETER(pCurHD->m_fSharedAreaEx)));
// Zyu modify on 100902,调整布局
//(*pRowChild2)[3].SetText(GetAreaText(_AS_SQMETER(pCurHD->m_fBalconyAreaEx)));
//(*pRowChild2)[4].SetText(GetAreaText(_AS_SQMETER(pCurHD->m_fStatisticsAreaEx)));
(*pRowChild2)[3].SetText(GetAreaText(_AS_SQMETER(pCurHD->m_fStatisticsAreaEx)));
(*pRowChild2)[4].SetText(GetAreaText(_AS_SQMETER(pCurHD->m_fBalconyAreaEx)));
(*pRowChild2)[5].SetText(XString(_T("%d"),pCurHD->GetTotalNum()));
(*pRowChild2)[6].SetText(GetAreaText(_AS_SQMETER(pCurHD->m_fStatisticsAreaEx*pCurHD->GetTotalNum())));
double fScale=0;
if (sqmeterTotalAreaEx>1E-6)
fScale=(_AS_SQMETER(pCurHD->m_fStatisticsAreaEx*pCurHD->GetTotalNum()))/sqmeterTotalAreaEx;
(*pRowChild2)[7].SetText(XString(_T("%.1f%%"),fScale*100));
pRowChild1->AppendChild(pRowChild2);
sumSpaceArea+=pCurHD->m_fSpaceArea;
sumSharedAreaEx+=pCurHD->m_fSharedAreaEx;
sumBalconyAreaEx+=pCurHD->m_fBalconyAreaEx;
sumStatisticsAreaEx+=pCurHD->m_fStatisticsAreaEx;
sumNum+=pCurHD->GetTotalNum();
sumAllAreaEx+=pCurHD->m_fStatisticsAreaEx*pCurHD->GetTotalNum();
lstHouseDataL.DelCur();
}
WDGridTreeRow *pRowSum=new WDGridTreeRow(pRowChild1);
(*pRowSum)[0].SetText(_T("合计"));
(*pRowSum)[1].SetText(GetAreaText(_AS_SQMETER(sumSpaceArea)));
(*pRowSum)[2].SetText(GetAreaText(_AS_SQMETER(sumSharedAreaEx)));
// Zyu modify on 100902,调整布局
//(*pRowSum)[3].SetText(GetAreaText(_AS_SQMETER(sumBalconyAreaEx)));
//(*pRowSum)[4].SetText(GetAreaText(_AS_SQMETER(sumStatisticsAreaEx)));
(*pRowSum)[3].SetText(GetAreaText(_AS_SQMETER(sumStatisticsAreaEx)));
(*pRowSum)[4].SetText(GetAreaText(_AS_SQMETER(sumBalconyAreaEx)));
(*pRowSum)[5].SetText(XString(_T("%d"),sumNum));
(*pRowSum)[6].SetText(GetAreaText(_AS_SQMETER(sumAllAreaEx)));
double fScale=0;
if (sqmeterTotalAreaEx>1E-6)
fScale=(_AS_SQMETER(sumAllAreaEx))/sqmeterTotalAreaEx;
(*pRowSum)[7].SetText(XString(_T("%.1f%%"),fScale*100));
pRowChild1->AppendChild(pRowSum);
totalSpaceArea+=sumSpaceArea;
totalSharedAreaEx+=sumSharedAreaEx;
totalBalconyAreaEx+=sumBalconyAreaEx;
totalStatisticsAreaEx+=sumStatisticsAreaEx;
totalNum+=sumNum;
totalAllAreaEx+=sumAllAreaEx;
}
WDGridTreeRow *pRowTotal=new WDGridTreeRow(pRow1);
(*pRowTotal)[0].SetText(_T("合计"));
(*pRowTotal)[1].SetText(GetAreaText(_AS_SQMETER(totalSpaceArea)));
(*pRowTotal)[2].SetText(GetAreaText(_AS_SQMETER(totalSharedAreaEx)));
// Zyu modify on 100902,调整布局
//(*pRowTotal)[3].SetText(GetAreaText(_AS_SQMETER(totalBalconyAreaEx)));
//(*pRowTotal)[4].SetText(GetAreaText(_AS_SQMETER(totalStatisticsAreaEx)));
(*pRowTotal)[3].SetText(GetAreaText(_AS_SQMETER(totalStatisticsAreaEx)));
(*pRowTotal)[4].SetText(GetAreaText(_AS_SQMETER(totalBalconyAreaEx)));
(*pRowTotal)[5].SetText(XString(_T("%d"),totalNum));
(*pRowTotal)[6].SetText(GetAreaText(_AS_SQMETER(totalAllAreaEx)));
double fScale=0;
if (sqmeterTotalAreaEx>1E-6)
fScale=(_AS_SQMETER(totalAllAreaEx))/sqmeterTotalAreaEx;
(*pRowTotal)[7].SetText(XString(_T("%.1f%%"),fScale*100));
pRow1->AppendChild(pRowTotal);
}
}
BOOL CPatternAnaChildDlg::GetSheet(TDbSheet *pSheet)
{
AcDbObjectId idTextStyle = InitTextStyle(TS_SPACE);
if (!idTextStyle)
{
acutPrintf(_T("\n初始化文字样式失败!"));
return FALSE;
}
int iRow = m_grid.GetRowNum() + 1;
const int iCol = 10;
const double dColWidArray[iCol] = {30, 30,20,40,40,40,40,30,40,20};
pSheet->InitSheet(iRow, iCol, 7.0, 14.0);
TGridStyle gridStyle;
gridStyle.SetOverrideAll(TRUE);
gridStyle.SetTextWrap(TRUE);
gridStyle.SetHorMode(AcDb::kTextMid);
gridStyle.SetVerMode(AcDb::kTextVertMid);
gridStyle.SetTextHeight(3.5);
gridStyle.SetTextStyleId(idTextStyle);
pSheet->SetGridStyle(gridStyle);
pSheet->SetRowHeightStyle(TSheetRow::kAutomatic);
// Zyu modify on 100902,修改表格名称
//pSheet->SetTitleText(_T("套型分析表(m^U2^U)"));
pSheet->SetTitleText(_T("住宅套型分析表(m^U2^U)"));
TSheetTitle &title=pSheet->GetTitle();
TDividerStyle &dStyle=title.GetDividerStyle();
TGridStyle &titleGridStyle=title.GetGridStyle();
dStyle.SetDividerFlag(TDividerStyle::kNone);
titleGridStyle.SetTextHeight(5.0);
TSheetColumn column;
for(int i=0; i<10; i++)
{
column.SetWidth(dColWidArray[i]);
pSheet->SetColumnAt(i, column);
}
TDbSheet &rSheet=*pSheet;
TGridCell *pCell;
pCell=rSheet(0, 0);
pCell->SetText(_T("分类"));
pCell=rSheet(0,1);
pCell->SetText(_T("套型"));
pCell=rSheet(0,2);
pCell->SetText(_T("编号"));
pCell=rSheet(0,3);
pCell->SetText(_T("套内使用面积 S1"));
pCell=rSheet(0,4);
pCell->SetText(_T("分摊面积 S2"));
// Zyu modify on 100902,调整布局
//pCell=rSheet(0,5);
//pCell->SetText(_T("阳台面积"));
//pCell=rSheet(0,6);
//pCell->SetText(_T("套型建筑面积 S1+S2"));
pCell=rSheet(0,5);
pCell->SetText(_T("套型建筑面积 S1+S2"));
pCell=rSheet(0,6);
pCell->SetText(_T("阳台面积"));
pCell=rSheet(0,7);
// Zyu modify on 100902,修改“户数”为“套数”
//pCell->SetText(_T("户数 N"));
pCell->SetText(_T("套数 N"));
pCell=rSheet(0,8);
pCell->SetText(_T("套型总面积 (S1+S2)*N"));
pCell=rSheet(0,9);
pCell->SetText(_T("比例"));
// 添加内容
int k=1;
for(i=0;i<iRow-1;i++)
{
WDGridTreeRow &row=(WDGridTreeRow&)m_grid.GetRow(i);
if (row.IsChildRow())
continue;
if (row.IsParentRow())
{
for(int j=0;j<row.GetChildNum();j++)
{
WDGridTreeRow &rowChild1=row.GetChild(j);
if (rowChild1.IsParentRow())
{
if (!rowChild1.IsChildVisible())
{
for(int h=0;h<rowChild1.GetChildNum();h++)
rSheet.AddRowAt(rSheet.GetRowNum());
}
}
else
{
if (!row.IsChildVisible())
rSheet.AddRowAt(rSheet.GetRowNum());
}
}//增加行数
for(j=0;j<row.GetChildNum();j++)
{
WDGridTreeRow &rowChild = row.GetChild(j);
if (rowChild.IsParentRow())
{
for(int d=0;d<rowChild.GetChildNum();d++)
{
WDGridTreeRow &rowChildEx=rowChild.GetChild(d);
TGridCell *pCell=rSheet(k,1);
if (pCell != NULL)
pCell->SetText(rowChild[0].GetText());
pCell=rSheet(k,0);
pCell->SetText(row[0].GetText());
for(int h=2;h<iCol;h++)
{
CString szText;
szText=rowChildEx[h-2].GetText();
TGridCell *pCell = rSheet(k,h);
if (pCell != NULL)
pCell->SetText(szText);
}
k++;
}
}
else
{
TGridCell *pCell=rSheet(k,1);
if (pCell != NULL)
pCell->SetText(rowChild[0].GetText());
pCell=rSheet(k,0);
if (pCell != NULL)
pCell->SetText(row[0]);
pCell=rSheet(k,2);
if (pCell != NULL)
pCell->SetText(_T("--"));
for(int h=3;h<iCol; h++)
{
CString szText;
szText = rowChild[h-2].GetText();
TGridCell *pCell = rSheet(k, h);
if (pCell != NULL)
pCell->SetText(szText);
}
k++;
}
}//在表格中写入数据
}
}
//删除空行
iRow=rSheet.GetRowNum();
TGridCell *pCelltemp=rSheet(iRow-1,2);
CString str=pCelltemp->GetText();
while(str==_T(""))
{
rSheet.RemoveRow(iRow-1);
iRow--;
TGridCell *pCelltemp=rSheet(iRow-1,2);
str=pCelltemp->GetText();
}
// 合并第二列
XString sTextA0;//当前比较文本
pCell=rSheet(1,1);
sTextA0=pCell->GetText();//套型
int iFrom1=1;
for(int j=2; j<iRow; j++)
{
XString sTextA;
pCell=rSheet(j,1);
sTextA=pCell->GetText();
if (_tcsicmp(sTextA,sTextA0)!=0)
{
int iRowEnd=j-1;
// 合并
if (iRowEnd>iFrom1)
rSheet.MergeCells(iFrom1,1,iRowEnd,1);
iFrom1=j;
//建立新比较文本
sTextA0=sTextA;
}
else if (j==iRow-1) {//继续比较,直至不相等或到了末行
if (j>iFrom1)
rSheet.MergeCells(iFrom1,1,j,1);
}
}
//合并第一列
XString sTextB0;//当前比较文本
pCell=rSheet(1,0);
sTextB0=pCell->GetText();//分类
int iFrom2=1;
for(j=2; j<iRow; j++)
{
XString sTextB;
pCell=rSheet(j,0);
sTextB=pCell->GetText();
if (_tcsicmp(sTextB,sTextB0)!=0)
{
int iRowEnd=j-1;
// 合并
if (iRowEnd>iFrom2)
rSheet.MergeCells(iFrom2,0,iRowEnd,0);
iFrom2=j;
//建立新比较文本
sTextB0=sTextB;
}
else if (j==iRow-1) {//继续比较,直至不相等或到了末行
if (j>iFrom2)
rSheet.MergeCells(iFrom2,0,j,0);
}
}
pSheet->CalculateRowHeight(0, pSheet->GetRowNum()-1);
return TRUE;
}
//////////////////////////////////////////////////
// Zyu add on 100901,表格的Jig对象
TDbSheetJig::TDbSheetJig()
{
m_pEnt = NULL;
}
TDbSheetJig::TDbSheetJig(TDbSheet *pEnt)
{
m_pEnt = pEnt;
}
AcEdJig::DragStatus TDbSheetJig::sampler()
{
setUserInputControls((UserInputControls)
(AcEdJig::kAccept3dCoordinates | AcEdJig::kNullResponseAccepted));
if (!m_sKeyword.IsEmpty())
{
setKeywordList(m_sKeyword);
}
AcGePoint3d ptTemp;
DragStatus status = acquirePoint(ptTemp);
if (status == AcEdJig::kNormal)
{
if (m_ptInsert == ptTemp)
{
return AcEdJig::kNoChange;
}
m_ptInsert = ptTemp;
}
return status;
}
Adesk::Boolean TDbSheetJig::update()
{
m_pEnt->SetLocation(m_ptInsert);
return Adesk::kTrue;
}
AcDbEntity* TDbSheetJig::entity() const
{
return (AcDbEntity*)m_pEnt;
}
void TDbSheetJig::SetKeyword(LPCTSTR pszKeyword)
{
m_sKeyword = pszKeyword;
}
//////////////////////////////////////////////////////////////////////////
int CProjectAreaSheet::s_nPage = 0;
IMPLEMENT_DYNAMIC(CProjectAreaSheet, CAcUiTabMainDialog)
CProjectAreaSheet::CProjectAreaSheet(TBABuilding *pBuilding,TBAHouseDataList*pLstHouseData,CWnd* parent)
:CAcUiTabMainDialog(CProjectAreaSheet::IDD, parent)
{
m_pageBudAreaSta.m_pBuilding=pBuilding;
m_pagePatternSta.m_pLstHouseData=pLstHouseData;
m_pagePatternAna.m_pLstHouseData=pLstHouseData;
// Zyu add on 100827,添加一个“住宅套型统计表”
m_pageHousePtnSta.m_pLstHouseData = pLstHouseData;
}
void CProjectAreaSheet::DoDataExchange(CDataExchange* pDX)
{
CAcUiTabMainDialog::DoDataExchange(pDX);
DDX_Control(pDX, IDC_AREA_TAB, m_tab);
}
BEGIN_MESSAGE_MAP(CProjectAreaSheet, CAcUiTabMainDialog)
ON_BN_CLICKED(IDC_LABEL,OnLabel)
ON_WM_CLOSE()
ON_WM_DESTROY()
ON_WM_SIZING()
ON_WM_SIZE()
END_MESSAGE_MAP()
BOOL CProjectAreaSheet::OnInitDialog()
{
BOOL bResult = CAcUiTabMainDialog::OnInitDialog();
SetAcadTabPointer(&m_tab);
// Zyu modify on 100827,添加一个“住宅套型统计表”,并修改其它表格的显示名称
//AddTab(0, _T("建筑面积统计表"), CAreaChildDlg::IDD, &m_pageBudAreaSta);
//AddTab(1, _T("套型统计表"),CPatternStaChildDlg::IDD , &m_pagePatternSta);
//AddTab(2, _T("套型分析表"),CPatternAnaChildDlg::IDD , &m_pagePatternAna);
AddTab(0, _T("建筑面积统计表"), CAreaChildDlg::IDD, &m_pageBudAreaSta);
AddTab(1, _T("房产套型统计表"),CPatternStaChildDlg::IDD , &m_pagePatternSta);
AddTab(2, _T("住宅套型统计表"),CHousePtnStaChildDlg::IDD , &m_pageHousePtnSta);
AddTab(3, _T("住宅套型分析表"),CPatternAnaChildDlg::IDD , &m_pagePatternAna);
m_tab.SetActiveTab(s_nPage);
// Zyu add on 100831,布置对话框
CRect rcMain;
GetWindowRect(&rcMain);
Relayout(rcMain.Width(), rcMain.Height());
return bResult;
}
void CProjectAreaSheet::OnClose()
{
CAcUiTabMainDialog::OnClose();
}
void CProjectAreaSheet::OnDestroy()
{
s_nPage = m_tab.GetActiveTab();
CAcUiTabMainDialog::OnDestroy();
}
// Zyu modify on 100901,重写函数,增加Jig和更新表格数据的功能
/*
void CProjectAreaSheet::OnLabel()
{
TDbSheet *pSheet=new TDbSheet;
BOOL bGetSheet=FALSE;
int nTab=m_tab.GetActiveTab();
if (nTab == 0)
{
bGetSheet=m_pageBudAreaSta.GetSheet(pSheet);
}
else if (nTab==1)
{
bGetSheet=m_pagePatternSta.GetSheet(pSheet);
}
// Zyu add on 100827,增加住宅套型统计表
else if (2 == nTab)
{
bGetSheet = m_pageHousePtnSta.GetSheet(pSheet);
}
else
bGetSheet=m_pagePatternAna.GetSheet(pSheet);
if (bGetSheet)
{
BeginEditorCommand();
XPoint ptLoc;
acedGetAcadFrame()->SetFocus();
if (ads_getpoint(NULL, _T("\n左上角点<返回>:"), ptLoc)!=RTNORM)
{
delete pSheet;
CompleteEditorCommand();
return;
}
//UCS
ptLoc=Ucs2Wcs(ptLoc);
ptLoc.z=0;
pSheet->SetRotation(Ucs2Wcs(0.0));// pSheet->SetLayoutRotation(Ucs2Wcs(0));布局转角改为直接转角 modified by fxj 090222
pSheet->SetLocation(ptLoc);
if (nTab == 0)
{
if (m_pageBudAreaSta.m_lstUpHouseCode.GetLength()>0)
{
CString szTip;
for(int i=0;i<m_pageBudAreaSta.m_lstUpHouseCode.GetLength();i++)
{
szTip+=m_pageBudAreaSta.m_lstUpHouseCode[i];
}
szTip+=_T("为跃层套型,技术指标在各户套型的下层标注。");
TDbMText *pNote1=new TDbMText;
double dHeight=3.5;
pNote1->SetHeight(dHeight);
pNote1->SetStyleId(InitTextStyle(TS_SPACE));
pNote1->SetText(szTip);
pNote1->SetAlignment(XExplodeDraw::kTopLeft);
XPoint ptLow,ptUp;
pSheet->GetExtents2d(ptLow,ptUp);
pNote1->SetPageWidth(fabs(ptUp.x - ptLow.x),FALSE);
pNote1->SetLineSpace(dHeight/4);
pNote1->SetLocation(ptLow);
AddToModelSpace(pNote1,Adesk::kTrue);
}
}
pSheet->AddToCSpace(Adesk::kTrue);//modified 080820
actrTransactionManager->flushGraphics(); //acad 刷新
acedUpdateDisplay();
//add 080908
XString skWord;
INITGET_BEG(0, _T("R"));
int nCode=acedGetKword(_T(""), skWord);
CompleteEditorCommand();
INITGET_END();
}
else
{
if (pSheet!=NULL)
delete pSheet;
}
}
*/
// add by xly 0n 110414 设置实体的图层并将实体添加到图纸中
extern TARCH_IMPEXP BOOL g_bTextDefaultLayer;
AcDbObjectId AddToSpace(Adesk::Boolean bClosed, TDbEntity *pEntSymb)
{
const TCHAR *pszLayer = pEntSymb->GetDefaultLayer();
// 设置在默认图层
if(pszLayer && g_bTextDefaultLayer)
{
AcDbObjectId idLayer = InitLayer(pszLayer, TRUE);
if (idLayer.isValid())
{
pEntSymb->setLayer(pszLayer);
}
}
return AddToCurrentSpace(pEntSymb, bClosed, Adesk::kTrue);
}
void CProjectAreaSheet::OnLabel()
{
TDbSheet *pSheet=new TDbSheet;
BOOL bGetSheet=FALSE;
int nTab=m_tab.GetActiveTab();
if (nTab == 0)
{
bGetSheet=m_pageBudAreaSta.GetSheet(pSheet);
}
else if (nTab==1)
{
bGetSheet=m_pagePatternSta.GetSheet(pSheet);
}
else if (2 == nTab)
{
bGetSheet = m_pageHousePtnSta.GetSheet(pSheet);
}
else
bGetSheet=m_pagePatternAna.GetSheet(pSheet);
if (bGetSheet)
{
BeginEditorCommand();
acedGetAcadFrame()->SetFocus();
pSheet->SetRotation(Ucs2Wcs(0.0));
TDbSheetJig jig(pSheet);
bool bLoop = true;
while (bLoop)
{
jig.SetKeyword(_T("Q"));
acutPrintf(_T("\n请点取表格位置(左上角点)或[更新表格数据(Q)]<返回>:"));
AcEdJig::DragStatus dragStat;
INITGET_BEG(0, _T("Q"));
dragStat = jig.drag();
INITGET_END();
switch (dragStat)
{
case AcEdJig::kNoChange:
case AcEdJig::kNormal:
{
TDbSheet *pSheetClone = (TDbSheet*)jig.entity()->clone();
if (nTab == 0)
{
if (m_pageBudAreaSta.m_lstUpHouseCode.GetLength()>0)
{
CString szTip;
for(int i=0;i<m_pageBudAreaSta.m_lstUpHouseCode.GetLength();i++)
{
szTip+=m_pageBudAreaSta.m_lstUpHouseCode[i];
}
szTip+=_T("为跃层套型,技术指标在各户套型的下层标注。");
TDbMText *pNote1=new TDbMText;
double dHeight=3.5;
pNote1->SetHeight(dHeight);
pNote1->SetStyleId(InitTextStyle(TS_SPACE));
pNote1->SetText(szTip);
pNote1->SetAlignment(XExplodeDraw::kTopLeft);
XPoint ptLow,ptUp;
pSheetClone->GetExtents2d(ptLow,ptUp);
pNote1->SetPageWidth(fabs(ptUp.x - ptLow.x),FALSE);
pNote1->SetLineSpace(dHeight/4);
pNote1->SetLocation(ptLow);
// add by xly 0n 110414 设置实体的图层并将实体添加到图纸中
// AddToModelSpace(pNote1,Adesk::kTrue);
AddToSpace(Adesk::kTrue, pNote1);
}
}
// add by xly 0n 110414 设置实体的图层并将实体添加到图纸中
//pSheetClone->AddToCSpace(Adesk::kTrue);
AddToSpace(Adesk::kTrue,pSheetClone);
actrTransactionManager->flushGraphics(); // acad刷新
acedUpdateDisplay();
}
break;
case AcEdJig::kKW1:
{
TEntitySet ent;
TRBList rbFilter(acutBuildList(RTDXF0, _T("TCH_SHEET"), NULL));
TCHAR chRet;
int iRetCode = SelectEntity(_T("\n请选择上华表格(注意表格的行列数必须匹配)或[新建表格(Q)]<返回>:"), ent, rbFilter, _T("Q"), chRet);
switch (iRetCode)
{
case RTNORM:
{
CopySheet(pSheet, ent);
}
break;
case RTKWORD:
{
bLoop = true;
}
break;
default:
{
bLoop = false;
}
}
}
break;
default:
{
bLoop = false;
}
}
}
delete pSheet;
CompleteEditorCommand();
}
else
{
if (pSheet != NULL)
{
delete pSheet;
}
}
}
// Zyu add on 100831,对话框大小支持鼠标拖动修改
void CProjectAreaSheet::OnSize(UINT nType, int cx, int cy)
{
CAcUiTabMainDialog::OnSize(nType, cx, cy);
CRect rcMain;
GetWindowRect(&rcMain);
Relayout(rcMain.Width(), rcMain.Height());
}
// Zyu add on 100831,调整Tab中窗口的大小
void CProjectAreaSheet::ResizeChildDlg(CDialog *pDlg, UINT nID)
{
if (pDlg != NULL)
{
CRect rcChildWnd;
CRect rcMain;
pDlg->GetWindowRect(&rcChildWnd);
this->GetWindowRect(&rcMain);
// 调整子窗口的大小
rcChildWnd.right = rcMain.right - 22;
rcChildWnd.bottom = rcMain.bottom - 50;
ScreenToClient(&rcChildWnd);
pDlg->MoveWindow(&rcChildWnd);
// 调整List表单控件的大小
CWnd *pWnd = pDlg->GetDlgItem(nID);
if (pWnd != NULL)
{
CRect rcList;
rcList.left = 6;
rcList.right = rcMain.Width() - 50;
rcList.top = 20;
rcList.bottom = rcMain.Height() - 110;
pWnd->MoveWindow(rcList);
}
}
}
// Zyu add on 100831,重新布局窗口中的控件
void CProjectAreaSheet::Relayout(int iWidth, int iHeight)
{
CWnd *pWndTab = GetDlgItem(IDC_AREA_TAB);
if (pWndTab != NULL)
{
// 调整TAB控件位置
CRect rectTab;
rectTab.left = 11;
rectTab.right =iWidth - 18;
rectTab.bottom = iHeight - 70;
rectTab.top = 11;
pWndTab->MoveWindow(&rectTab);
// 调整TAB中子窗口的位置
ResizeChildDlg(&m_pageBudAreaSta, IDC_BUD_LIST);
ResizeChildDlg(&m_pagePatternSta, IDC_STYLE_LIST);
ResizeChildDlg(&m_pageHousePtnSta, IDC_LST_STYLE);
ResizeChildDlg(&m_pagePatternAna, IDC_ANA_LIST);
// 调整按钮位置
CRect rcButton;
CWnd *pWndBtn = GetDlgItem(IDC_LABEL);
if (pWndBtn != NULL)
{
pWndBtn->GetWindowRect(rcButton);
long x = iWidth - 244, y = iHeight - 63;
rcButton.right = rcButton.Width() + x;
rcButton.left = x;
rcButton.bottom = rcButton.Height() + y;
rcButton.top = y;
pWndBtn->MoveWindow(rcButton);
}
pWndBtn = NULL;
pWndBtn = GetDlgItem(IDCANCEL);
if (pWndBtn != NULL);
{
pWndBtn->GetWindowRect(rcButton);
long x = iWidth - 133, y = iHeight - 63;
rcButton.right = rcButton.Width() + x;
rcButton.left = x;
rcButton.bottom = rcButton.Height() + y;
rcButton.top = y;
pWndBtn->MoveWindow(rcButton);
}
}
}
// Zyu add on 100901,拷贝表格
void CProjectAreaSheet::CopySheet(TDbSheet *pSheetSrc, TEntitySet &entDest)
{
if (NULL != pSheetSrc)
{
OPENOBJ_BEGIN(entDest, AcDb::kForWrite, TDbSheet, pEnt);
int iRowNum = pEnt->GetRowNum(); // 行数
int iColNum = pEnt->GetColumnNum(); // 列数
// 要求所选表格对象的行数、列数与生成的表格相同
if (iRowNum != pSheetSrc->GetRowNum()
|| iColNum != pSheetSrc->GetColumnNum())
{
MessageBox(_T("表格行数或列数不匹配!请正确选择上华表格。"), 0, MB_ICONWARNING);
}
else
{
// 首先把已被合并的单元格恢复
for (int m = 0; m < iRowNum; m++)
{
for (int n = 0; n < iRowNum; n++)
{
// 当前单元格
TGridCell &tCell = *(*pEnt)(m, n);
if (tCell.IsRange())
{
pEnt->ExplodeCell(m, n);
}
}
}
for (int i = 0; i < iRowNum; i++)
{
for (int j = 0; j < iColNum; j++)
{
TGridCell *pGridCell = (*pSheetSrc)(i, j);
if (NULL != pGridCell)
{
// 是否需要合并单元格
if (pGridCell->IsRange())
{
const TGridRange *pGridRange = pGridCell->GetRange();
if (NULL != pGridRange)
{
int iRowMin = pGridRange->GetCoord(TRUE);
int iRowMax = pGridRange->GetCoordMax(TRUE);
int iColMin = pGridRange->GetCoord(FALSE);
int iColMax = pGridRange->GetCoordMax(FALSE);
// 判断是否是首次做合并单元格,避免重复操作
if (iRowMin == i && iColMin == j)
{
pEnt->MergeCells(iRowMin, iColMin, iRowMax, iColMax);
(*pEnt)(i, j)->SetText(pGridCell->GetText());
}
}
}
else
{
(*pEnt)(i, j)->SetText(pGridCell->GetText());
}
}
}
}
}
OPENOBJ_END();
}
}
//////////////////////////////////////////////////////////
// Zyu modify on 100826,修改面积统计命令,增加对话框交互
// Begin
//建筑项目面积统计
/*
void ProjectArea1()
{
//------add by fxj 090610 加是否支持复式住宅的提示
BOOL bDuplex=FALSE;
int nRet0;
TCHAR sKey[1024]=_T("");
INITGET_BEG(0,_T("Y N"))
nRet0=acedGetKword(_T("\n允许不同楼层户号相同,同一户号的面积按跃层住宅合并统计[是(Y)/否(N)]<N>:"),sKey);
INITGET_END()
if (nRet0==RTNONE || (nRet0==RTNORM&&sKey[0]==_T('N')))
bDuplex=FALSE;
else if (nRet0!=RTNORM)
return;
else
bDuplex=TRUE;
//---------------------------------------
BOOL bSta=TRUE;//标准层面积统计
TBABuilding building;
TBAHouseDataList lstHouseData;
int nRet;
TCHAR skword[1024]=_T("");
INITGET_BEG(0,_T("A B"))
nRet=acedGetKword(_T("\n请选择统计类型 [标准层面积统计(A)/工程面积统计(B)]<A>:"),skword);
INITGET_END()
if (nRet==RTNONE||(nRet==RTNORM&&skword[0]==_T('A')))//标准层面积统计
{
RBList mask=ads_buildlist(RTDXF0,_T("TCH_SPACE"),//8,
//(const TCHAR*)XString(_T("%s,%s,%s,%s,%s,%s"),LAY_BUILDING_SPACE,LAY_HOUSE_SPACE,LAY_SHARE_SPACE,LAY_BALCONY_SPACE,LAY_SPACE,LAY_HOLE_SPACE),
NULL);//moidfied by fxj 090701 不以图层为选择标准
PickSet ss(SS_FREE);
NSel: if (SelectEntities(_T("\n请选择需要统计的标准层房间/面积对象:"),ss,mask)!=RTNORM)
return;
//add by fxj 090603 判断选择集中是否有“建筑面积”,若无则重新选择;若有,则判断其面积是否大于所有套内面积之和,不大于则重选
int nTA=0;
double dTotalArea=0;
double dSumHouseArea=0;
for(long i=0;i<ss.Length();i++)
{
Entity ent=ss[i];
OPENOBJ_BEGIN(ent, AcDb::kForRead, TDbSpace, pSpace)
if (pSpace == NULL)
continue;
if (pSpace->GetType()==TDbSpace::kHouseArea)
{
dSumHouseArea+=pSpace->m_nUseArea;
}
if (pSpace->GetType()==TDbSpace::kTotalArea)
{
nTA++;
AcGeVector3d vt;
XPoly2D poly(1);
pSpace->GetPathPoly(poly,vt);
dTotalArea=poly.Area();
}
OPENOBJ_END();
}
if (nTA<1)
{
//moidfied by fxj 090701 不以图层为选择标准,以类型为过滤标准
Entity ent1;
//RBList mask1=ads_buildlist(RTDXF0,_T("TCH_SPACE"),8,LAY_BUILDING_SPACE,NULL);
RBList mask1=ads_buildlist(RTDXF0,_T("TCH_SPACE"),NULL);
int nRet=SelectEntity(_T("\n没有发现建筑面积对象,请选择要统计标准层的建筑面积对象<退出>: "),ent1,mask1);
if (nRet!=RTNORM)
return;
else
{
OPENOBJ_BEGIN(ent1, AcDb::kForRead, TDbSpace, pSpace)
if (pSpace==NULL)
return;
if (pSpace->GetType()!=TDbSpace::kTotalArea)
return;
OPENOBJ_END();
}
ss+=ent1;
}
else
{
if (dTotalArea-dSumHouseArea<-1E-6)
{
adsout<<_T("\n重新选择建筑面积!");
goto NSel;
}
}
//将标准层统计看成只有一层的建筑工程统计
TBAFloor *pFloor=new TBAFloor;
pFloor->Append(ss);
building.AddTail(pFloor);
}
else if (nRet!=RTNORM)
return;
else//工程内统计
{
if (g_project.IsEmpty())
{
AfxMessageBox(_T("请打开或新建一个工程项目,并在工程数据库中建立楼层表!"));
CString sCmd=GetFullCmdName(_T("TProjectBar"));
acedPostCommand(sCmd+_T("\n"));
return;
}
TProjectGroupItem* pTable=GetFloorTable();
if (pTable==NULL)
{
AfxMessageBox(_T("请在工程数据库中建立楼层表!"));
CString sCmd=GetFullCmdName(_T("TProjectBar"));
acedPostCommand(sCmd+_T("\n"));
return;
}
acedSetStatusBarProgressMeter(_T("面积统计..."), 0, pTable->GetLength());
for(pTable->MoveToFirst();!pTable->IsOut();pTable->MoveToNext())
{
acedSetStatusBarProgressMeterPos(pTable->GetCur());
if (acedUsrBrk())
{
adsout<<_T("\n用户中止统计!");
return;
}
TProjectFloor* pFloor=(TProjectFloor*)pTable->GetCurData();
adsout << _T("\n统计标准层") << (const TCHAR*)pFloor->GetName() << _T("的面积...");
building.AddTail(new TBAFloor(pFloor));
}
acedRestoreStatusBar();
bSta=FALSE;//非标准层面积统计
}
building.Share();//分摊计算
//add by fxj 090612 处理跃层
if ((!bSta)&&bDuplex)
building.FindHouseUp();//处理跃层
//套型统计
Array<CString> arrayLayerName;
for(building.MoveToFirst();!building.IsOut();building.MoveToNext())
{
TBAFloor *pFloor=(TBAFloor*)building.GetCurData();
//----------add by fxj --------
TProjectFloor *pFloorDef=pFloor->m_pFloorDef;
CString strLayNo;
if (!pFloorDef)
strLayNo=_T("1");
else
{
strLayNo=pFloorDef->GetLayerNo();
}
arrayLayerName.AddTail(strLayNo);
//----------------add by fxj ----------------
for(pFloor->m_lstHouse.MoveToFirst();!pFloor->m_lstHouse.IsOut();pFloor->m_lstHouse.MoveToNext())
{
TBAHouse *pHouse =(TBAHouse*)pFloor->m_lstHouse.GetCurData();
//add by fxj 090716 考虑跃层
if (pHouse->IsHouseUp())
continue;
lstHouseData.Append(pHouse,building.GetCur(),building.GetLength());
}
}
//---------add by fxj 090213 ----------
if (lstHouseData.GetLength()<1)
{
adsout<<_T("\n未找到已分户房间!");
return;
}
//-----------------------
for(lstHouseData.MoveToFirst();!lstHouseData.IsOut();lstHouseData.MoveToNext())
{
TBAHouseData *pHD=lstHouseData.GetCurData();
pHD->m_arrayLayerName=arrayLayerName;
}
//弹出命令对话框,将building数据转化为电子表格内容(电子表格暂时是不可修改的),参考前面FloorArea函数...
//将电子表格内容转化为所需面积统计表(TDbSheet),并标注到图上...
CAcModuleResourceOverride vTmp;
CProjectAreaSheet sheet(&building,&lstHouseData,acedGetAcadFrame());
sheet.DoModal();
//adsout<<_T("\n建筑套内总使用面积:")<<_AS_SQMETER(building.GetHouseSpaceArea());
//adsout<<_T("\n建筑阳台总面积:")<<_AS_SQMETER(building.GetHouseBalconyArea());
//adsout<<_T("\n建筑套内总面积:")<<_AS_SQMETER(building.GetHouseArea());
//adsout<<_T("\n建筑公摊总面积:")<<_AS_SQMETER(building.GetShareArea());
//adsout<<_T("\n建筑总面积:")<<_AS_SQMETER(building.GetStatisticsBuildArea());
}
*/
void ProjectArea()
{
CCountAreaDlg dlg(acedGetAcadFrame());
INT_PTR iRet = 0;
{
CAcModuleResourceOverride rscTemp;
iRet = dlg.DoModal();
}
if (IDOK == iRet)
{
CProjectAreaSheet sheet(&dlg.m_baBuilding, &dlg.m_lstHouseData, acedGetAcadFrame());
CAcModuleResourceOverride rscTemp;
sheet.DoModal();
}
}
// End