2649 lines
82 KiB
C++
2649 lines
82 KiB
C++
#include "stdafx.h"
|
||
#include "AmountSettingDlg.h"
|
||
|
||
#include <SAmountItem.h>
|
||
#include <dbPipeValve.h>
|
||
#include <DbEquipment.h>
|
||
#include <DbWaterTank.h>
|
||
#include <DbPump.h>
|
||
#include <DbWell.h>
|
||
#include <DbPool.h>
|
||
#include <dbgridsheet.h>
|
||
#include "AmountSettingHeadDlg.h"
|
||
#include "DbDoubleLinePipeReducer.h"
|
||
#include "dbxrecrd.h"
|
||
#include "DbFireExtinguisher.h"
|
||
#include "NewSanitaryDefineDlg.h "
|
||
|
||
//#include <cbclass.h>
|
||
|
||
#ifdef _DEBUG
|
||
#define new DEBUG_NEW
|
||
#undef THIS_FILE
|
||
static char THIS_FILE[] = __FILE__;
|
||
#endif
|
||
|
||
//#ifdef _WIN64
|
||
#include"TGAs.h"
|
||
//#endif
|
||
|
||
//***************************************************************************************************
|
||
// 材料统计
|
||
//***************************************************************************************************
|
||
//extern Acad::ErrorStatus AssureInCurrentView_New(const XPoint &ptLow, const XPoint &ptUp);
|
||
extern int GetSanitaryDataSourceType(Entity ent);
|
||
extern bool GetLocSanitaryData(Entity ent, CSanitaryInfo &data, AcGePoint3d &ptFeed,
|
||
AcGePoint3d &ptHeatFeed, AcGePoint3d &ptDrain, AcGePoint3d &ptDir);
|
||
extern bool GetSanitaryDwbSerial(Entity ent,CString &sDwbName);
|
||
extern BOOL GetLayerReMark(const TCHAR *szLayer, CString &sRemark);
|
||
// 获取图层名及管道名
|
||
void GetLayerPipeName(std::map<CString, CString> &mapLayerPipeName)
|
||
{
|
||
CString sTemp;
|
||
if(GetLayerReMark(LAY_PIPE_COAGULATE, sTemp) && !sTemp.IsEmpty())
|
||
{
|
||
mapLayerPipeName.insert(std::make_pair(LAY_PIPE_COAGULATE, sTemp));
|
||
}
|
||
else
|
||
{
|
||
mapLayerPipeName.insert(std::make_pair(LAY_PIPE_COAGULATE, CString(_T("凝结"))));
|
||
}
|
||
|
||
if(GetLayerReMark(LAY_PIPE_DRINK, sTemp) && !sTemp.IsEmpty())
|
||
{
|
||
mapLayerPipeName.insert(std::make_pair(LAY_PIPE_DRINK, sTemp));
|
||
}
|
||
else
|
||
{
|
||
mapLayerPipeName.insert(std::make_pair(LAY_PIPE_DRINK, CString(_T("直饮"))));
|
||
}
|
||
if(GetLayerReMark(LAY_PIPE_PRESSDIRT, sTemp) && !sTemp.IsEmpty())
|
||
{
|
||
mapLayerPipeName.insert(std::make_pair(LAY_PIPE_PRESSDIRT, sTemp));
|
||
}
|
||
else
|
||
{
|
||
mapLayerPipeName.insert(std::make_pair(LAY_PIPE_PRESSDIRT, CString(_T("压力污"))));
|
||
}
|
||
if(GetLayerReMark(LAY_PIPE_PRESSUSELESS, sTemp) && !sTemp.IsEmpty())
|
||
{
|
||
mapLayerPipeName.insert(std::make_pair(LAY_PIPE_PRESSUSELESS, sTemp));
|
||
}
|
||
else
|
||
{
|
||
mapLayerPipeName.insert(std::make_pair(LAY_PIPE_PRESSUSELESS, CString(_T("压力废"))));
|
||
}
|
||
if(GetLayerReMark(LAY_PIPE_PRESSRAIN, sTemp) && !sTemp.IsEmpty())
|
||
{
|
||
mapLayerPipeName.insert(std::make_pair(LAY_PIPE_PRESSRAIN, sTemp));
|
||
}
|
||
else
|
||
{
|
||
mapLayerPipeName.insert(std::make_pair(LAY_PIPE_PRESSRAIN, CString(_T("压力雨"))));
|
||
}
|
||
if(GetLayerReMark(LAY_PIPE_USER1, sTemp) && !sTemp.IsEmpty())
|
||
{
|
||
mapLayerPipeName.insert(std::make_pair(LAY_PIPE_USER1, sTemp));
|
||
}
|
||
else
|
||
{
|
||
mapLayerPipeName.insert(std::make_pair(LAY_PIPE_USER1, CString(_T("用户1管线"))));
|
||
}
|
||
if(GetLayerReMark(LAY_PIPE_USER2, sTemp) && !sTemp.IsEmpty())
|
||
{
|
||
mapLayerPipeName.insert(std::make_pair(LAY_PIPE_USER2, sTemp));
|
||
}
|
||
else
|
||
{
|
||
mapLayerPipeName.insert(std::make_pair(LAY_PIPE_USER2, CString(_T("用户2管线"))));
|
||
}
|
||
if(GetLayerReMark(LAY_PIPE_USER3, sTemp) && !sTemp.IsEmpty())
|
||
{
|
||
mapLayerPipeName.insert(std::make_pair(LAY_PIPE_USER3, sTemp));
|
||
}
|
||
else
|
||
{
|
||
mapLayerPipeName.insert(std::make_pair(LAY_PIPE_USER3, CString(_T("用户3管线"))));
|
||
}
|
||
if(GetLayerReMark(LAY_PIPE_USER4, sTemp) && !sTemp.IsEmpty())
|
||
{
|
||
mapLayerPipeName.insert(std::make_pair(LAY_PIPE_USER4, sTemp));
|
||
}
|
||
else
|
||
{
|
||
mapLayerPipeName.insert(std::make_pair(LAY_PIPE_USER4, CString(_T("用户4管线"))));
|
||
}
|
||
if(GetLayerReMark(LAY_PIPE_USER5, sTemp) && !sTemp.IsEmpty())
|
||
{
|
||
mapLayerPipeName.insert(std::make_pair(LAY_PIPE_USER5, sTemp));
|
||
}
|
||
else
|
||
{
|
||
mapLayerPipeName.insert(std::make_pair(LAY_PIPE_USER5, CString(_T("用户5管线"))));
|
||
}
|
||
if(GetLayerReMark(LAY_PIPE_USER6, sTemp) && !sTemp.IsEmpty())
|
||
{
|
||
mapLayerPipeName.insert(std::make_pair(LAY_PIPE_USER6, sTemp));
|
||
}
|
||
else
|
||
{
|
||
mapLayerPipeName.insert(std::make_pair(LAY_PIPE_USER6, CString(_T("用户6管线"))));
|
||
}
|
||
if(GetLayerReMark(LAY_PIPE_USER7, sTemp) && !sTemp.IsEmpty())
|
||
{
|
||
mapLayerPipeName.insert(std::make_pair(LAY_PIPE_USER7, sTemp));
|
||
}
|
||
else
|
||
{
|
||
mapLayerPipeName.insert(std::make_pair(LAY_PIPE_USER7, CString(_T("用户7管线"))));
|
||
}
|
||
if(GetLayerReMark(LAY_PIPE_USER8, sTemp) && !sTemp.IsEmpty())
|
||
{
|
||
mapLayerPipeName.insert(std::make_pair(LAY_PIPE_USER8, sTemp));
|
||
}
|
||
else
|
||
{
|
||
mapLayerPipeName.insert(std::make_pair(LAY_PIPE_USER8, CString(_T("用户8管线"))));
|
||
}
|
||
}
|
||
|
||
// "$valve$0000001"
|
||
void LoadTkBlock(const TCHAR* szBlk)
|
||
{
|
||
CString csTK, csRecord;
|
||
XString xsBlk;
|
||
SplitBlkStr(szBlk, csTK, csRecord);
|
||
LoadDwbBlock(csTK, csRecord, xsBlk);
|
||
}
|
||
|
||
//const TCHAR* GetPlanValve(const TCHAR* szSysName)
|
||
//{
|
||
// XString xsTmpSys = _T("");
|
||
// CodeBase db;
|
||
// db.read_only = 1;
|
||
// XString xsKind, xsItem, xsDrawing;
|
||
//
|
||
// CString csSysTKName = g_csDwbPath + _T("VALVE.tk");
|
||
// XDbfTable *pTable = db.Open(csSysTKName);
|
||
// if(!pTable) return xsTmpSys;
|
||
// pTable->MoveFirst();
|
||
// while(!pTable->IsEOF()) {
|
||
// GET_FIELD(pTable, _T("kind"), xsKind);
|
||
// GET_FIELD(pTable, _T("item"), xsItem);
|
||
// GET_FIELD(pTable, _T("Drawing"), xsDrawing);
|
||
// if(((xsKind == _T("平面阀门")) || (xsKind == _T("平面附件"))) && (xsDrawing != _T(""))) {
|
||
// CString csSysBlk = (const TCHAR*)xsItem;
|
||
// csSysBlk = csSysBlk.Right(8);
|
||
// CString csDwb = g_csDwbPath + _T("valve");
|
||
// if(_tcsicmp(csSysBlk, szSysName) == 0){
|
||
// if(LoadDwbBlock(csDwb, (const TCHAR*)xsDrawing, xsTmpSys) != RTNORM)
|
||
// return (TCHAR*)xsTmpSys;
|
||
//
|
||
// break;
|
||
// }
|
||
// }
|
||
// pTable->MoveNext();
|
||
// }
|
||
// if(xsTmpSys == _T("")) // sys17下不这么写, 返回乱码
|
||
// return _T("");
|
||
// return (TCHAR*)xsTmpSys;
|
||
//}
|
||
|
||
CString GetPlanValve(const TCHAR* szSysName)
|
||
{
|
||
CString csRet = _T("");
|
||
|
||
CodeBase db;
|
||
db.read_only = 1;
|
||
CString csKind, csItem, csDrawing;
|
||
|
||
CString csSysTKName = g_csDwbPath + _T("VALVE.tk");
|
||
XDbfTable *pTable = db.Open(csSysTKName);
|
||
if(!pTable) return csRet;
|
||
pTable->MoveFirst();
|
||
while(!pTable->IsEOF()) {
|
||
GET_FIELD(pTable, _T("kind"), csKind);
|
||
GET_FIELD(pTable, _T("item"), csItem);
|
||
GET_FIELD(pTable, _T("Drawing"), csDrawing);
|
||
if(((csKind == _T("平面阀门")) || (csKind == _T("平面附件"))) && (csDrawing != _T(""))) {
|
||
CString csSysBlk = (const TCHAR*)csItem;
|
||
csSysBlk = csSysBlk.Right(8);
|
||
CString csDwb = g_csDwbPath + _T("valve");
|
||
if(_tcsicmp(csSysBlk, szSysName) == 0)
|
||
{
|
||
TCHAR szBlkName[256];
|
||
if(LoadDwbBlock(csDwb, (const TCHAR*)csDrawing, szBlkName) != RTNORM)
|
||
return csRet;
|
||
csRet = (const TCHAR*)szBlkName;
|
||
break;
|
||
}
|
||
}
|
||
pTable->MoveNext();
|
||
}
|
||
|
||
// if(xsTmpSys == _T("")) // sys17下不这么写, 返回乱码
|
||
// return _T("");
|
||
return csRet;
|
||
}
|
||
|
||
BOOL GetValveNameById(AcDbObjectId id, CString &csBlkName, CString &csDesName)
|
||
{
|
||
csBlkName = _T("");
|
||
OPENOBJ_BEGIN(id, AcDb::kForRead, TDbPipeValve, pEquip);
|
||
if(pEquip){
|
||
const TCHAR *szBlkName;
|
||
AcDbObjectId eqId = pEquip->GetBlock2d();
|
||
OPENOBJ_BEGIN(eqId, AcDb::kForRead, AcDbBlockTableRecord, pRecord);
|
||
if(pRecord)
|
||
pRecord->getName(szBlkName);
|
||
OPENOBJ_END();
|
||
csBlkName = szBlkName;
|
||
CString csTKName, csRocord;
|
||
SplitBlkStr(csBlkName, csTKName, csRocord);
|
||
csTKName = g_csDwbPath + csTKName + _T(".tk");
|
||
csDesName = GetBlkDesName((const TCHAR*)csRocord, (const TCHAR*)csTKName);
|
||
int idx = csDesName.Find(_T("-"));
|
||
if(idx > -1){
|
||
csDesName = csDesName.Left(idx);
|
||
}
|
||
idx = csDesName.Find(_T("("));
|
||
if(idx > -1){
|
||
csDesName = csDesName.Left(idx);
|
||
}
|
||
CString csSysBlk = pEquip->GetSysBlock();
|
||
if(csSysBlk == _T("")){
|
||
CString csBlk = GetPlanValve(csRocord);//如果是系统阀门,就找到对应的平面阀门,统计结果算平面的
|
||
if(csBlk != _T(""))
|
||
csBlkName = csBlk;
|
||
}
|
||
if(csBlkName != _T(""))
|
||
return TRUE;
|
||
}
|
||
OPENOBJ_END();
|
||
return FALSE;
|
||
}
|
||
|
||
BOOL GetSanNameByEnt(Entity ent, CString &csBlkName, CString &csDesName, int &iItem)
|
||
{
|
||
TCHAR szBlkName[256];
|
||
ent.GetData(2, szBlkName);
|
||
iItem = 4;
|
||
csBlkName = szBlkName;
|
||
csDesName = _T("卫生器具");//HZTXT “洁” 出错
|
||
|
||
if(csBlkName != _T(""))
|
||
return TRUE;
|
||
return FALSE;
|
||
}
|
||
|
||
void IsAppandItem(DList<SAmountItem> &lstAll, SAmountItem *pItem, int iFloorNum = 1)
|
||
{
|
||
|
||
pItem->m_nNum = pItem->m_nNum * iFloorNum;
|
||
int iLength = lstAll.Length();
|
||
int Index = -1;
|
||
for(int j=0;j<iLength;j++){
|
||
SAmountItem *pItem2 = lstAll[j];
|
||
if(_tcsicmp(lstAll[j]->m_csBlkName, pItem->m_csBlkName) == 0 && _tcsicmp(lstAll[j]->m_csName, pItem->m_csName) == 0 && _tcsicmp(lstAll[j]->m_csSpec, pItem->m_csSpec) == 0 && _tcsicmp(lstAll[j]->m_csDemo, pItem->m_csDemo) == 0) {
|
||
Index = j;
|
||
break;
|
||
}
|
||
}
|
||
if(Index > -1){
|
||
lstAll[Index]->m_nNum += pItem->m_nNum;
|
||
delete pItem;
|
||
}
|
||
else
|
||
lstAll.Append(pItem);
|
||
}
|
||
|
||
BOOL IsAppandNode(DList<AcDbObjectId> &lstNode, AcDbObjectId id)
|
||
{
|
||
int len = lstNode.Length();
|
||
int Index = -1;
|
||
for(int j=0;j<len;j++){
|
||
AcDbObjectId idTmp = *lstNode[j];
|
||
if(idTmp == id) {
|
||
Index = j;
|
||
break;
|
||
}
|
||
}
|
||
if(Index < 0){
|
||
lstNode.Append(new AcDbObjectId(id));
|
||
return TRUE;
|
||
}
|
||
return FALSE;
|
||
}
|
||
|
||
void GetSheetHeadInfo(DList<CBlockStruct> &lstHead)
|
||
{
|
||
lstHead.Reset();
|
||
CodeBase db;
|
||
int Number;
|
||
CString csType, csValue, csRemark;
|
||
XString fullFile;
|
||
if(!FindFile(_T("DataStore.dbf"), fullFile)) {
|
||
Callme(_T("对不起,没有发现DataStore.dbf文件!"));
|
||
return;
|
||
}
|
||
XDbfTable *pTable = db.Open(fullFile);
|
||
if(!pTable) {
|
||
Callme(_T("DataStore.dbf文件出错!"));
|
||
return;
|
||
}
|
||
pTable->MoveFirst();
|
||
while(!pTable->IsEOF()) {
|
||
GET_FIELD(pTable, _T("TypeNumber"), Number);
|
||
GET_FIELD(pTable, _T("TypeName"), csType);
|
||
GET_FIELD(pTable, _T("TypeValue"), csValue);
|
||
GET_FIELD(pTable, _T("REMARK"), csRemark);
|
||
if(Number == 43 && csRemark == _T("1")) //csRemark == _T("1") 表示显示,0不显示
|
||
{
|
||
CBlockStruct *pData = new CBlockStruct();
|
||
pData->m_csDesName = csValue;
|
||
pData->m_csRecord = csRemark;
|
||
pData->m_csTKName = csType;
|
||
lstHead.Append(pData);
|
||
}
|
||
pTable->MoveNext();
|
||
}
|
||
}
|
||
|
||
// cet 2010.9.1 del 创建的图例不能真实反映管线的实际样式
|
||
// //创建块表记录 add by cet 2009.11.12
|
||
// BOOL CreatePipeLegendBlk(CString strBlkName, CString strChars, int nColor)
|
||
// {
|
||
// // 创建块表记录:格式:TWT-字符-BLOCK
|
||
// AcDbBlockTable *pBlkTbl = NULL;
|
||
// acdbHostApplicationServices()->workingDatabase()->getBlockTable(pBlkTbl, AcDb::kForWrite);
|
||
// if (pBlkTbl == NULL)
|
||
// {
|
||
// return FALSE;
|
||
// }
|
||
//
|
||
// // 先判断该名称的块表记录是否存在存在的话直接返回,否则创建
|
||
// if (pBlkTbl->has(strBlkName))
|
||
// {
|
||
// pBlkTbl->close();
|
||
//
|
||
// return TRUE;
|
||
// }
|
||
//
|
||
// // line线1,2
|
||
// int nNum = strChars.GetLength(); //字符数
|
||
// AcGePoint3d ptStart(-500 - 80 * (nNum - 1), 0, 0), ptEnd(-150 - 80 * (nNum - 1), 0, 0);
|
||
// AcDbLine *pLine1 = new AcDbLine(ptStart, ptEnd); // 创建一条直线
|
||
// if (pLine1 == NULL)
|
||
// {
|
||
// pBlkTbl->close();
|
||
// return FALSE;
|
||
// }
|
||
//
|
||
// ptStart.set(150 + 80 * (nNum - 1) , 0, 0);
|
||
// ptEnd.set(500 + 80 * (nNum - 1) , 0, 0);
|
||
// AcDbLine *pLine2 = new AcDbLine(ptStart, ptEnd); // 创建一条直线
|
||
// if (pLine1 == NULL)
|
||
// {
|
||
// pBlkTbl->close();
|
||
// delete pLine1;
|
||
//
|
||
// return FALSE;
|
||
// }
|
||
//
|
||
// // 文字 - 字符
|
||
// AcGePoint3d ptIns(0, 0, 0);
|
||
// AcDbText *pText = new AcDbText(); //创建文字
|
||
//
|
||
// if (pText == NULL)
|
||
// {
|
||
// pBlkTbl->close();
|
||
// delete pLine1;
|
||
// delete pLine2;
|
||
//
|
||
// return FALSE;
|
||
// }
|
||
//
|
||
// pText->setTextString(strChars);
|
||
// pText->setHeight(2.0 * DocGetPScale());
|
||
// pText->setTextStyle(InitTextStyle(_T("_TWT_SHEET")));
|
||
// pText->setHorizontalMode(AcDb::kTextMid);
|
||
// pText->setWidthFactor(0.8);
|
||
// pText->setRotation(Ucs2Wcs(0.0));
|
||
// pText->setAlignmentPoint(ptIns);
|
||
// pText->setPosition(ptIns);
|
||
//
|
||
// // 创建新的块表记录
|
||
// AcDbBlockTableRecord *pBlkTblRcd = new AcDbBlockTableRecord();
|
||
// pBlkTblRcd->setName(strBlkName);
|
||
//
|
||
// // 将块表记录添加到块表中
|
||
// AcDbObjectId blkDefId = NULL;
|
||
// pBlkTbl->add(blkDefId, pBlkTblRcd);
|
||
// pBlkTbl->close();
|
||
//
|
||
// //将创建的实体添加到块表记录中
|
||
// AcDbObjectId entId = NULL;
|
||
// pBlkTblRcd->appendAcDbEntity(entId, pLine1);
|
||
// pBlkTblRcd->appendAcDbEntity(entId, pLine2);
|
||
// pBlkTblRcd->appendAcDbEntity(entId, pText);
|
||
//
|
||
// pLine1->setColorIndex(nColor);
|
||
// pLine2->setColorIndex(nColor);
|
||
//
|
||
// // 关闭实体和块表记录
|
||
// pLine1->close();
|
||
// pLine2->close();
|
||
// pText->close();
|
||
// pBlkTblRcd->close();
|
||
//
|
||
// return TRUE;
|
||
// }
|
||
|
||
// cet 2010.9.1 add 根据管线名称获取管线图层
|
||
CString GetPipeLayerByName(CString strPipeName)
|
||
{
|
||
// cet 2011.12.9 add
|
||
std::map<CString,CString> mapLayerPipeName;
|
||
GetLayerPipeName(mapLayerPipeName);
|
||
|
||
CString strLayer;
|
||
if (strPipeName.Compare(_T("给水管线")) == 0)
|
||
{
|
||
strLayer = LAY_PIPE_FEED;
|
||
}
|
||
else if (strPipeName.Compare(_T("给水中区管线")) == 0)
|
||
{
|
||
strLayer = LAY_PIPE_FEED2;
|
||
}
|
||
else if (strPipeName.Compare(_T("给水高区管线")) == 0)
|
||
{
|
||
strLayer = LAY_PIPE_FEED3;
|
||
}
|
||
else if (strPipeName.Compare(_T("喷淋管线")) == 0)
|
||
{
|
||
strLayer = LAY_PIPE_SPRINKLE;
|
||
}
|
||
else if (strPipeName.Compare(_T("喷淋中区管线")) == 0)
|
||
{
|
||
strLayer = LAY_PIPE_SPRINKLE2;
|
||
}
|
||
else if (strPipeName.Compare(_T("喷淋高区管线")) == 0)
|
||
{
|
||
strLayer = LAY_PIPE_SPRINKLE3;
|
||
}
|
||
else if (strPipeName.Compare(_T("热回水管线")) == 0)
|
||
{
|
||
strLayer = LAY_PIPE_HEADBACK;
|
||
}
|
||
else if (strPipeName.Compare(_T("热回水中区管线")) == 0)
|
||
{
|
||
strLayer = LAY_PIPE_HEADBACK2;
|
||
}
|
||
else if (strPipeName.Compare(_T("热回水高区管线")) == 0)
|
||
{
|
||
strLayer = LAY_PIPE_HEADBACK3;
|
||
}
|
||
else if (strPipeName.Compare(_T("热给水管线")) == 0)
|
||
{
|
||
strLayer = LAY_PIPE_HEADFEED;
|
||
}
|
||
else if (strPipeName.Compare(_T("热给水中区管线")) == 0)
|
||
{
|
||
strLayer = LAY_PIPE_HEADFEED2;
|
||
}
|
||
else if (strPipeName.Compare(_T("热给水高区管线")) == 0)
|
||
{
|
||
strLayer = LAY_PIPE_HEADFEED3;
|
||
}
|
||
else if (strPipeName.Compare(_T("中水管线")) == 0)
|
||
{
|
||
strLayer = LAY_PIPE_USED;
|
||
}
|
||
else if (strPipeName.Compare(_T("中水中区管线")) == 0)
|
||
{
|
||
strLayer = LAY_PIPE_USED2;
|
||
}
|
||
else if (strPipeName.Compare(_T("中水高区管线")) == 0)
|
||
{
|
||
strLayer = LAY_PIPE_USED3;
|
||
}
|
||
else if (strPipeName.Compare(_T("消防管线")) == 0)
|
||
{
|
||
strLayer = LAY_PIPE_FIRE;
|
||
}
|
||
else if (strPipeName.Compare(_T("消防中区管线")) == 0)
|
||
{
|
||
strLayer = LAY_PIPE_FIRE2;
|
||
}
|
||
else if (strPipeName.Compare(_T("消防高区管线")) == 0)
|
||
{
|
||
strLayer = LAY_PIPE_FIRE3;
|
||
}
|
||
else if (strPipeName.Compare(_T("废水管线")) == 0)
|
||
{
|
||
strLayer = LAY_PIPE_USELESS;
|
||
}
|
||
else if (strPipeName.Compare(_T("污水管线")) == 0)
|
||
{
|
||
strLayer = LAY_PIPE_DIRT;
|
||
}
|
||
else if (strPipeName.Compare(_T("雨水管线")) == 0)
|
||
{
|
||
strLayer = LAY_PIPE_RAIN;
|
||
}
|
||
/* else if (strPipeName.Compare(g_csPipeName[1]) == 0) cet 2011.12.9 modify
|
||
{
|
||
strLayer = LAY_PIPE_DRINK;
|
||
}
|
||
else if (strPipeName.Compare(_T("其它管线")) == 0)
|
||
{
|
||
strLayer = LAY_PIPE_OTHER;
|
||
}
|
||
else if (strPipeName.Compare(g_csPipeName[2]) == 0)
|
||
{
|
||
strLayer = LAY_PIPE_PRESSDIRT;
|
||
}
|
||
else if (strPipeName.Compare(g_csPipeName[3]) == 0)
|
||
{
|
||
strLayer = LAY_PIPE_PRESSUSELESS;
|
||
}
|
||
else if (strPipeName.Compare(g_csPipeName[4]) == 0)
|
||
{
|
||
strLayer = LAY_PIPE_PRESSRAIN;
|
||
}
|
||
else if (strPipeName.Compare(g_csPipeName[0]) == 0)
|
||
{
|
||
strLayer = LAY_PIPE_COAGULATE;
|
||
}
|
||
else if (strPipeName.Compare(g_csPipeName[5]) == 0)
|
||
{
|
||
strLayer = LAY_PIPE_USER1;
|
||
}
|
||
else if (strPipeName.Compare(g_csPipeName[6]) == 0)
|
||
{
|
||
strLayer = LAY_PIPE_USER2;
|
||
}
|
||
*/
|
||
else if (strPipeName.Compare(_T("其它管线")) == 0)
|
||
{
|
||
strLayer = LAY_PIPE_OTHER;
|
||
}
|
||
else if (strPipeName.Compare(mapLayerPipeName[LAY_PIPE_COAGULATE] + _T("管线")) == 0)
|
||
{
|
||
strLayer = LAY_PIPE_COAGULATE;
|
||
}
|
||
else if (strPipeName.Compare(mapLayerPipeName[LAY_PIPE_DRINK] + _T("管线")) == 0)
|
||
{
|
||
strLayer = LAY_PIPE_DRINK;
|
||
}
|
||
else if (strPipeName.Compare(mapLayerPipeName[LAY_PIPE_PRESSDIRT] + _T("管线")) == 0)
|
||
{
|
||
strLayer = LAY_PIPE_PRESSDIRT;
|
||
}
|
||
else if (strPipeName.Compare(mapLayerPipeName[LAY_PIPE_PRESSUSELESS] + _T("管线")) == 0)
|
||
{
|
||
strLayer = LAY_PIPE_PRESSUSELESS;
|
||
}
|
||
else if (strPipeName.Compare(mapLayerPipeName[LAY_PIPE_PRESSRAIN] + _T("管线")) == 0)
|
||
{
|
||
strLayer = LAY_PIPE_PRESSRAIN;
|
||
}
|
||
else if (strPipeName.Compare(mapLayerPipeName[LAY_PIPE_USER1] + _T("管线")) == 0)
|
||
{
|
||
strLayer = LAY_PIPE_USER1;
|
||
}
|
||
else if (strPipeName.Compare(mapLayerPipeName[LAY_PIPE_USER2] + _T("管线")) == 0)
|
||
{
|
||
strLayer = LAY_PIPE_USER2;
|
||
}
|
||
else if (strPipeName.Compare(mapLayerPipeName[LAY_PIPE_USER3] + _T("管线")) == 0)
|
||
{
|
||
strLayer = LAY_PIPE_USER3;
|
||
}
|
||
else if (strPipeName.Compare(mapLayerPipeName[LAY_PIPE_USER4] + _T("管线")) == 0)
|
||
{
|
||
strLayer = LAY_PIPE_USER4;
|
||
}
|
||
else if (strPipeName.Compare(mapLayerPipeName[LAY_PIPE_USER5] + _T("管线")) == 0)
|
||
{
|
||
strLayer = LAY_PIPE_USER5;
|
||
}
|
||
else if (strPipeName.Compare(mapLayerPipeName[LAY_PIPE_USER6] + _T("管线")) == 0)
|
||
{
|
||
strLayer = LAY_PIPE_USER6;
|
||
}
|
||
else if (strPipeName.Compare(mapLayerPipeName[LAY_PIPE_USER7] + _T("管线")) == 0)
|
||
{
|
||
strLayer = LAY_PIPE_USER7;
|
||
}
|
||
else if (strPipeName.Compare(mapLayerPipeName[LAY_PIPE_USER8] + _T("管线")) == 0)
|
||
{
|
||
strLayer = LAY_PIPE_USER8;
|
||
}
|
||
|
||
return strLayer;
|
||
}
|
||
|
||
// cet 2009.9.1 add 根据管线的实际样式制作图例
|
||
int CreatePipeLegendBlk(CString strBlkName, CString strPipeName)
|
||
{
|
||
// 管线图层是否存在
|
||
CString strPipeLayer = GetPipeLayerByName(strPipeName);
|
||
AcDbLayerTable *pLayerTbl = NULL;
|
||
acdbHostApplicationServices()->workingDatabase()->getLayerTable(pLayerTbl, AcDb::kForRead);
|
||
if (pLayerTbl != NULL)
|
||
{
|
||
if (!pLayerTbl->has(strPipeLayer))
|
||
{
|
||
pLayerTbl->close();
|
||
return 0;
|
||
}
|
||
pLayerTbl->close();
|
||
}
|
||
|
||
// 创建块表记录:格式:TWT-字符-BLOCK
|
||
AcDbBlockTable *pBlkTbl = NULL;
|
||
acdbHostApplicationServices()->workingDatabase()->getBlockTable(pBlkTbl, AcDb::kForWrite);
|
||
if (pBlkTbl == NULL)
|
||
{
|
||
return 0;
|
||
}
|
||
|
||
// 先判断该名称的块表记录是否存在存在的话直接返回,否则创建
|
||
if (pBlkTbl->has(strBlkName))
|
||
{
|
||
pBlkTbl->close();
|
||
return 1;
|
||
}
|
||
|
||
// 创建新的块表记录
|
||
AcDbBlockTableRecord *pBlkTblRcd = new AcDbBlockTableRecord();
|
||
pBlkTblRcd->setName(strBlkName);
|
||
|
||
// 将块表记录添加到块表中
|
||
AcDbObjectId blkDefId = NULL;
|
||
pBlkTbl->add(blkDefId, pBlkTblRcd);
|
||
pBlkTbl->close();
|
||
|
||
// 创建实体
|
||
TDbPipe *pPipe = new TDbPipe();
|
||
AcGePoint3d ptS(0, 0, 0), ptE(1000, 0, 0);
|
||
pPipe->SetStartPoint(ptS);
|
||
pPipe->SetEndPoint(ptE);
|
||
pPipe->setLayer(strPipeLayer);
|
||
|
||
//将创建的实体添加到块表记录中
|
||
AcDbObjectId entId = NULL;
|
||
pBlkTblRcd->appendAcDbEntity(entId, pPipe);
|
||
|
||
// 关闭实体和块表记录
|
||
pPipe->close();
|
||
pBlkTblRcd->close();
|
||
|
||
return 1;
|
||
}
|
||
|
||
bool PrintOutAmount(CAmountSettingDlg &dlg, DList<SAmountItem> &lstAll)
|
||
{
|
||
DList<CBlockStruct> lstHead;
|
||
GetSheetHeadInfo(lstHead);
|
||
|
||
lstAll.QuickSort(SAmountItem::SortByItem);
|
||
double nTextSize = _tstof(dlg.m_csTextHeight); //字高
|
||
double nTableHeight = _tstof(dlg.m_csTableHeight);
|
||
int nOsMode=0;
|
||
xg_getvar(_T("OSMODE"), &nOsMode);
|
||
nOsMode &= ~0x4000;
|
||
nOsMode |= OS_INT|OS_PER|OS_NEA|OS_MID;
|
||
XPushVar<int> vOsMode(_T("OSMODE"), nOsMode);
|
||
CString csPrompt = _T("点取表格左上角位置\n");
|
||
if(dlg.m_bIsDown)
|
||
csPrompt = _T("点取表格左下角位置\n");
|
||
XPoint pt;
|
||
if(XGetPoint(NULL, csPrompt, pt) != RTNORM)
|
||
return false;
|
||
AcDbObjectId idTextStyle=GetTextStyleId(dlg.m_csTextStyle);
|
||
TDbSheet *pSheet = new TDbSheet;
|
||
pSheet->SetRotation(Ucs2Wcs(0.0));//add by sr
|
||
|
||
TGridStyle gridStyle;
|
||
gridStyle.SetOverrideAll(TRUE);
|
||
gridStyle.SetTextHeight(nTextSize);
|
||
gridStyle.SetTextStyleId(idTextStyle);
|
||
|
||
if(dlg.m_csTitle != _T(""))
|
||
{
|
||
TSheetTitle &title=pSheet->GetTitle();
|
||
title.SetHeight(7.0);
|
||
title.SetText(dlg.m_csTitle);
|
||
TGridStyle &gridStyle2=title.GetGridStyle();
|
||
gridStyle2.SetTextHeight(nTextSize);
|
||
gridStyle2.SetTextStyleId(idTextStyle);
|
||
TDividerStyle &style=title.GetDividerStyle();
|
||
style.SetDividerFlag(TDividerStyle::kNone);
|
||
}
|
||
|
||
|
||
|
||
gridStyle.SetHorMode(AcDb::kTextCenter);
|
||
gridStyle.SetVerMode(AcDb::kTextVertMid);
|
||
gridStyle.SetLineSpaceFactor(0.2);
|
||
gridStyle.SetTextWrap(FALSE);
|
||
pSheet->SetGridStyle(gridStyle);
|
||
pSheet->SetRowHeight(nTableHeight);
|
||
pSheet->InitSheet(lstAll.Length()+1, lstHead.Length(), nTableHeight, 50);
|
||
// cet 2011.8.18 add 设置外框线宽以符合新规范
|
||
TDividerStyle &styleBorder = pSheet->GetBorderStyle();
|
||
styleBorder.SetLineWidth(0.2);
|
||
TSheetRow *pRow = pSheet->GetRow(0);
|
||
if (pRow != NULL)
|
||
{
|
||
TDividerStyle &styleRow = pRow->GetDividerStyle();
|
||
styleRow.SetLineWidth(0.2);
|
||
styleRow.SetDividerFlag(TDividerStyle::kLocal);
|
||
}
|
||
|
||
int FirstRow = 0;
|
||
if(dlg.m_bIsDown)
|
||
FirstRow = lstAll.Length();
|
||
int iSerialCol = -1;
|
||
int iBlockCol = -1;
|
||
int iNameCol = -1;
|
||
int iSpecCol = -1;
|
||
int iUnitCol = -1;
|
||
int iNumCol = -1;
|
||
int iDemoCol = -1;
|
||
|
||
for(int mm=0;mm<lstHead.Length();mm++)
|
||
{
|
||
double dWidth = _tstof(lstHead[mm]->m_csDesName);
|
||
|
||
// cet 2010.9.1 扩大表格中图例的宽度以便清晰显示管线线型
|
||
if (mm == 1)
|
||
{
|
||
dWidth *= 2;
|
||
}
|
||
|
||
TSheetColumn column;
|
||
column.SetWidth(dWidth);
|
||
pSheet->SetColumnAt(mm, column);
|
||
|
||
TGridCell &cell=*(*pSheet)(FirstRow, mm);
|
||
cell.SetText(lstHead[mm]->m_csTKName);
|
||
|
||
if(lstHead[mm]->m_csTKName == _T("序号"))
|
||
iSerialCol = mm;
|
||
else if(lstHead[mm]->m_csTKName == _T("图例"))
|
||
iBlockCol = mm;
|
||
else if(lstHead[mm]->m_csTKName == _T("图例"))
|
||
iBlockCol = mm;
|
||
else if(lstHead[mm]->m_csTKName == _T("名称"))
|
||
iNameCol = mm;
|
||
else if(lstHead[mm]->m_csTKName == _T("规格"))
|
||
iSpecCol = mm;
|
||
else if(lstHead[mm]->m_csTKName == _T("单位"))
|
||
iUnitCol = mm;
|
||
else if(lstHead[mm]->m_csTKName == _T("数量"))
|
||
iNumCol = mm;
|
||
else if(lstHead[mm]->m_csTKName == _T("备注"))
|
||
iDemoCol = mm;
|
||
|
||
}
|
||
|
||
// TSheetColumn column;
|
||
// column.SetWidth(12); //序号
|
||
// pSheet->SetColumnAt(0, column);
|
||
// column.SetWidth(14); //图例
|
||
// pSheet->SetColumnAt(1, column);
|
||
// column.SetWidth(43); //名称
|
||
// pSheet->SetColumnAt(2, column);
|
||
// column.SetWidth(43); //规格
|
||
// pSheet->SetColumnAt(3, column);
|
||
// column.SetWidth(12); //单位
|
||
// pSheet->SetColumnAt(4, column);
|
||
// column.SetWidth(15); //数量
|
||
// pSheet->SetColumnAt(5, column);
|
||
// column.SetWidth(41); //备注
|
||
// pSheet->SetColumnAt(6, column);
|
||
|
||
// TGridCell &cell=*(*pSheet)(FirstRow, 0);
|
||
// cell.SetText(_T("序号"));
|
||
// TGridCell &cell2=*(*pSheet)(FirstRow, 1);
|
||
// cell2.SetText(_T("图例"));
|
||
// TGridCell &cell3=*(*pSheet)(FirstRow, 2);
|
||
// cell3.SetText(_T("名称"));
|
||
// TGridCell &cell4=*(*pSheet)(FirstRow, 3);
|
||
// cell4.SetText(_T("规格"));
|
||
// TGridCell &cell5=*(*pSheet)(FirstRow, 4);
|
||
// cell5.SetText(_T("单位"));
|
||
// TGridCell &cell6=*(*pSheet)(FirstRow, 5);
|
||
// cell6.SetText(_T("数量"));
|
||
// TGridCell &cell7=*(*pSheet)(FirstRow, 6);
|
||
// cell7.SetText(_T("备注"));
|
||
|
||
|
||
pSheet->SetLocation(Ucs2Wcs(pt));
|
||
XPoint ptex = pSheet->GetExtents(FALSE);
|
||
|
||
for(int j=0;j<=lstAll.Length()-1;j++){
|
||
int m = j, index = j + 1;
|
||
if(dlg.m_bIsDown){
|
||
index = lstAll.Length() - m;
|
||
}
|
||
else
|
||
m = j + 1;
|
||
|
||
if(iSerialCol > -1) //序号
|
||
{
|
||
TGridCell &Cell=*(*pSheet)(m, iSerialCol);
|
||
XString xsIndex(_T("%d"), index);
|
||
Cell.SetText(xsIndex);
|
||
}
|
||
|
||
if(iBlockCol > -1) //图例
|
||
{
|
||
CString sName = lstAll[j]->m_csBlkName;
|
||
if(sName != _T("") && sName != _T("*"))
|
||
{
|
||
// 分解字符:格式:-字符-数字
|
||
int nPos = 0, nPos1 = -1, nPos2 = -1;
|
||
|
||
nPos1 = sName.Find(_T('-'), nPos);
|
||
nPos2 = sName.Find(_T('-'), nPos1 + 1);
|
||
|
||
CString strColor;
|
||
CString strBlkName;
|
||
CString strTemp;
|
||
// BOOL bFlag = FALSE; //块记录是否存在 cet 2010.9.1 del
|
||
int nFlag = 2; // cet 2010.9.1 add 0:失败 1:成功 2:未进行任何操作
|
||
if (nPos1 != -1 && nPos2 != -1) //检查字符串是否是“-字符-数字”格式
|
||
{
|
||
strColor = sName.Mid(nPos2 + 1);
|
||
strBlkName = sName.Mid(nPos1 + 1, nPos2 - nPos1 -1);
|
||
strTemp = _T("TWT_") + strBlkName + strColor + _T("_BLOCK"); //cet 2009.12.22 add
|
||
int nColor = _ttoi(strColor);
|
||
|
||
//检查图例图块是否存在, 不存在时创建该图块
|
||
// bFlag = CreatePipeLegendBlk(strTemp, strBlkName, nColor); //add by cet 2009.11.12
|
||
nFlag = CreatePipeLegendBlk(strTemp, lstAll[j]->m_csName); // cet 2010.9.1 modify
|
||
}
|
||
|
||
if (!sName.IsEmpty())
|
||
{
|
||
|
||
TCellBlockInsert blk;
|
||
CString csBlkName2;
|
||
|
||
// cet 2010.9.1 modify
|
||
// if (bFlag)
|
||
if(nFlag == 1)
|
||
{
|
||
csBlkName2 = strTemp;
|
||
blk.m_sBlockName = strTemp;
|
||
blk.m_nControlFlag = CBF_AUTOSIZE | CBF_SHOW_ATTR;
|
||
blk.m_yValue = 3.0;
|
||
blk.m_xValue = blk.m_zValue = 1.0;
|
||
}
|
||
// cet 2010.9.1 modify
|
||
// else
|
||
else if (nFlag == 2)
|
||
{
|
||
csBlkName2 = sName;
|
||
blk.m_sBlockName = sName;
|
||
LoadTkBlock((const TCHAR*)blk.m_sBlockName);
|
||
blk.m_nControlFlag = CBF_AUTOSIZE | CBF_UNISCALE | CBF_SHOW_ATTR | CBF_EQUAL_SIDE;
|
||
}
|
||
|
||
// cet 2010.9.1 modify
|
||
// XString xsBlk;
|
||
// blk.OutputDesc(xsBlk);
|
||
// TGridCell &Cell1=*(*pSheet)(m, iBlockCol);
|
||
// Cell1.SetText(xsBlk);
|
||
if (nFlag != 0)
|
||
{
|
||
XString xsBlk;
|
||
blk.OutputDesc(xsBlk);
|
||
TGridCell &Cell1=*(*pSheet)(m, iBlockCol);
|
||
Cell1.SetText(xsBlk);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
if(iNameCol > -1) //名称
|
||
{
|
||
TGridCell &Cell2=*(*pSheet)(m, iNameCol);
|
||
Cell2.SetText(lstAll[j]->m_csName);
|
||
}
|
||
|
||
if(iSpecCol > -1) //规格
|
||
{
|
||
TGridCell &Cell3=*(*pSheet)(m, iSpecCol);
|
||
Cell3.SetText(lstAll[j]->m_csSpec);
|
||
}
|
||
|
||
if(iUnitCol > -1) //单位
|
||
{
|
||
TGridCell &Cell4=*(*pSheet)(m, iUnitCol);
|
||
Cell4.SetText(lstAll[j]->m_csUnit);
|
||
}
|
||
|
||
if(iNumCol > -1) //数量
|
||
{
|
||
CString csNum;
|
||
if(lstAll[j]->m_iType == 0){
|
||
int iPre = dlg.m_iPrePipeLen;
|
||
CString sHead,sFormat;
|
||
sHead.Format(_T("%d"),iPre);
|
||
sFormat = _T("%.") + sHead + _T("f");
|
||
csNum.Format(sFormat, lstAll[j]->m_nNum);
|
||
}
|
||
else
|
||
csNum.Format(_T("%.0f"), lstAll[j]->m_nNum);
|
||
TGridCell &Cell5=*(*pSheet)(m, iNumCol);
|
||
Cell5.SetText(csNum);
|
||
}
|
||
|
||
if(iDemoCol > -1) //备注
|
||
{
|
||
TGridCell &Cell6=*(*pSheet)(m, iDemoCol);
|
||
Cell6.SetText(lstAll[j]->m_csDemo);
|
||
}
|
||
|
||
|
||
}
|
||
if(dlg.m_bIsDown){
|
||
pt.y += (ptex.y*DocGetPScale());
|
||
pSheet->SetLocation(pt);
|
||
}
|
||
|
||
pSheet->AddToCSpace(TRUE);
|
||
return true;
|
||
}
|
||
|
||
void AmountAllMaterialFromDwg(CAmountSettingDlg &dlg)
|
||
{
|
||
DList<SAmountItem> lstAll;
|
||
for(int ii=0;ii<dlg.m_lstFile.Length();ii++){
|
||
DList<AcDbObjectId> lstAllId;
|
||
CString csFile = dlg.m_lstFile[ii];
|
||
int iNum = *dlg.m_lstFloor[ii];
|
||
AcDbDatabase dwgDb;
|
||
#if ADS < 21
|
||
if(dwgDb.readDwgFile((const TCHAR*)csFile, _SH_DENYNO, false)!=Acad::eOk)
|
||
#else
|
||
if(dwgDb.readDwgFile((const TCHAR*)csFile, AcDbDatabase::kForReadAndAllShare, false)!=Acad::eOk)
|
||
#endif
|
||
{
|
||
adsout << _T("\n不能访问") << (const TCHAR*)csFile << _T(", 中断统计!");
|
||
return ;
|
||
}
|
||
DList<AcDbObjectId> ssAllPipe;
|
||
if(GetEntityFromDatabase(ssAllPipe, dwgDb, _T("ATS_PIPE"), 0, ACDB_MODEL_SPACE) != Acad::eOk)
|
||
return;
|
||
if(dlg.m_bXL){
|
||
if(GetEntityFromDatabase(ssAllPipe, dwgDb, _T("ATS_EQUIPMENT"), 0, ACDB_MODEL_SPACE) != Acad::eOk)
|
||
return;
|
||
}
|
||
int len = ssAllPipe.Length();
|
||
for(int i=0;i<len;i++){
|
||
AcDbObjectId id = *ssAllPipe[i];
|
||
OPENOBJ_BEGIN(id, AcDb::kForRead, AcDbEntity, pEnt);
|
||
if(pEnt){
|
||
TCHAR *layer;
|
||
layer = pEnt->layer();
|
||
BOOL bFlag = FALSE;
|
||
if(dlg.m_bFL && _tcsicmp(layer, LAY_PIPE_USELESS) == 0){
|
||
bFlag = TRUE;
|
||
}
|
||
if(dlg.m_bHL && _tcsicmp(layer, LAY_PIPE_SPRINKLE) == 0){
|
||
bFlag = TRUE;
|
||
}
|
||
if(dlg.m_bJL && (_tcsicmp(layer, LAY_PIPE_FEED) == 0
|
||
|| _tcsicmp(layer, LAY_VPIPE_FEED) == 0
|
||
|| _tcsicmp(layer, LAY_PIPE_FEED2) == 0
|
||
|| _tcsicmp(layer, LAY_PIPE_FEED3) == 0
|
||
|| _tcsicmp(layer, LAY_VPIPE_FEED2) == 0
|
||
|| _tcsicmp(layer, LAY_VPIPE_FEED3) == 0))
|
||
{
|
||
bFlag = TRUE;
|
||
}
|
||
if(dlg.m_bRHL && _tcsicmp(layer, LAY_PIPE_HEADBACK) == 0){
|
||
bFlag = TRUE;
|
||
}
|
||
if(dlg.m_bRJL && _tcsicmp(layer, LAY_PIPE_HEADFEED) == 0){
|
||
bFlag = TRUE;
|
||
}
|
||
if(dlg.m_bWL && _tcsicmp(layer, LAY_PIPE_DIRT) == 0){
|
||
bFlag = TRUE;
|
||
}
|
||
if(dlg.m_bXL && (_tcsicmp(layer, LAY_PIPE_FIRE) == 0) || (_tcsicmp(layer, LAY_EQUIP_HYDRANT) == 0)){
|
||
bFlag = TRUE;
|
||
}
|
||
if(dlg.m_bYL && _tcsicmp(layer, LAY_PIPE_RAIN) == 0){
|
||
bFlag = TRUE;
|
||
}
|
||
if(dlg.m_bZL && _tcsicmp(layer, LAY_PIPE_USED) == 0){
|
||
bFlag = TRUE;
|
||
}
|
||
|
||
if(bFlag)
|
||
lstAllId.Append(new AcDbObjectId(id));
|
||
delete [] layer;
|
||
}
|
||
OPENOBJ_END();
|
||
|
||
}
|
||
DList<AcDbObjectId> lstNode;
|
||
len = lstAllId.Length();
|
||
for(i=0;i<len;i++){
|
||
AcDbObjectId id = *lstAllId[i];
|
||
|
||
double nPipeLength(0);
|
||
int iItem(0);
|
||
CString csBlkName, csDesName;
|
||
|
||
int iMaterial = -1;
|
||
double nPipeDn(0);
|
||
|
||
OPENOBJ_BEGIN(id, AcDb::kForRead, TDbEquipment, pEquip);
|
||
if(pEquip){
|
||
int num = pEquip->GetInterfaceNum();
|
||
if(num > 0)
|
||
continue;
|
||
AcDbObjectId idTmp = pEquip->objectId();
|
||
if(IsAppandNode(lstNode, idTmp) && GetEquipNameById(idTmp, csBlkName, csDesName, iItem)){
|
||
SAmountItem *pItem = new SAmountItem(iItem, csBlkName, csDesName, _T(""), _T("个"), iNum, _T(""));
|
||
IsAppandItem(lstAll, pItem);
|
||
}
|
||
continue;
|
||
}
|
||
OPENOBJ_END();
|
||
|
||
|
||
OPENOBJ_BEGIN(id, AcDb::kForRead, TDbPipe, pPipe);
|
||
if(pPipe){
|
||
if(!pPipe->IsModel()) //不是平面管线
|
||
continue;
|
||
DList<AcDbObjectId> lstAttachment;
|
||
nPipeLength = pPipe->Length() * iNum;
|
||
AcDbObjectId nodeId1(NULL), nodeId2(NULL);
|
||
nodeId1 = pPipe->GetNode(0);
|
||
nodeId2 = pPipe->GetNode(1);
|
||
iMaterial = pPipe->GetMaterial();
|
||
nPipeDn = pPipe->GetDnDiameter();
|
||
CString csMat = GetPipeMaterialByIdx(iMaterial);
|
||
CString csSpec;
|
||
if(nPipeDn < 0)
|
||
csMat = _T("");
|
||
else{
|
||
CString csDim = GetDnByMat(csMat);
|
||
csMat.Format(_T("%s %s%.0f"), csMat, csDim, nPipeDn);
|
||
csSpec.Format(_T("Dn%.0f"), nPipeDn);
|
||
}
|
||
if(IsAppandNode(lstNode, nodeId1) && GetEquipNameById(nodeId1, csBlkName, csDesName, iItem)){
|
||
if((!dlg.m_bSan && csDesName != _T("堵头") && csDesName != _T("弯头") && csDesName != _T("变径") && csDesName != _T("三通") && csDesName != _T("四通")) || dlg.m_bSan){
|
||
if(!(csDesName == _T("水龙头") || csDesName == _T("通气帽") || csDesName == _T("清扫口") || csDesName == _T("方地漏") || csDesName == _T("排水漏斗") || csDesName == _T("雨水斗") || csDesName == _T("毛发聚集器") || csDesName == _T("圆地漏") || csDesName == _T("检查口")))
|
||
csSpec = _T("");
|
||
if(csDesName == _T("检查井")){
|
||
if(pPipe->GetSysType() == TPipeSys::kRainWater)
|
||
csDesName = _T("雨水检查井");
|
||
else if(pPipe->GetSysType() == TPipeSys::kDirtWater)
|
||
csDesName = _T("污水检查井");
|
||
OPENOBJ_BEGIN(nodeId2, AcDb::kForRead, TDbEquipment, pEquip2);
|
||
if(pEquip2)
|
||
nPipeLength -= pEquip2->GetScale()/1000;
|
||
OPENOBJ_END();
|
||
}
|
||
|
||
SAmountItem *pItem = new SAmountItem(iItem, csBlkName, csDesName, csSpec, _T("个"), iNum, _T(""));
|
||
IsAppandItem(lstAll, pItem);
|
||
}
|
||
}
|
||
if(IsAppandNode(lstNode, nodeId2) && GetEquipNameById(nodeId2, csBlkName, csDesName, iItem)){
|
||
if((!dlg.m_bSan && csDesName != _T("堵头") && csDesName != _T("弯头") && csDesName != _T("变径") && csDesName != _T("三通") && csDesName != _T("四通")) || dlg.m_bSan){
|
||
if(!(csDesName == _T("水龙头") || csDesName == _T("通气帽") || csDesName == _T("清扫口") || csDesName == _T("方地漏") || csDesName == _T("排水漏斗") || csDesName == _T("雨水斗") || csDesName == _T("毛发聚集器") || csDesName == _T("圆地漏") || csDesName == _T("检查口")))
|
||
csSpec = _T("");
|
||
if(csDesName == _T("检查井")){
|
||
if(pPipe->GetSysType() == TPipeSys::kRainWater)
|
||
csDesName = _T("雨水检查井");
|
||
else if(pPipe->GetSysType() == TPipeSys::kDirtWater)
|
||
csDesName = _T("污水检查井");
|
||
OPENOBJ_BEGIN(nodeId2, AcDb::kForRead, TDbEquipment, pEquip2);
|
||
if(pEquip2)
|
||
nPipeLength -= pEquip2->GetScale()/1000;
|
||
OPENOBJ_END();
|
||
}
|
||
|
||
SAmountItem *pItem = new SAmountItem(iItem, csBlkName, csDesName, csSpec, _T("个"), iNum, _T(""));
|
||
IsAppandItem(lstAll, pItem);
|
||
}
|
||
}
|
||
pPipe->GetAttachments(lstAttachment);
|
||
int leng = lstAttachment.Length();
|
||
for(int m=0;m<leng;m++){
|
||
AcDbObjectId idTmp = *lstAttachment[m];
|
||
if(IsAppandNode(lstNode, idTmp) && GetValveNameById(idTmp, csBlkName, csDesName)){
|
||
SAmountItem *pItem = new SAmountItem(1, csBlkName, csDesName, csSpec, _T("个"), iNum, _T(""));
|
||
IsAppandItem(lstAll, pItem);
|
||
}
|
||
}
|
||
SAmountItem *pItem = new SAmountItem(0, _T("*"), _T("管线"), csMat, _T("米"), nPipeLength, _T(""));
|
||
IsAppandItem(lstAll, pItem);
|
||
}
|
||
OPENOBJ_END();
|
||
}
|
||
}
|
||
PrintOutAmount(dlg, lstAll);
|
||
}
|
||
|
||
//得到节点附件的规格(所接管线的管径)
|
||
CString GetNodeSpec(AcDbObjectId nodeId)
|
||
{
|
||
DList<double> lstDn;
|
||
CString csDnHead;
|
||
CString csRet, csSpec1, csSpec2, csSpec3, csSpec4;
|
||
double dDnTmp(-1);
|
||
BOOL bAllDn = TRUE;
|
||
OPENOBJ_BEGIN(nodeId, AcDb::kForRead, TDbEquipment, pEquip);
|
||
if(pEquip){ //喷淋
|
||
lstDn.Append(new double(25.0));
|
||
dDnTmp = 25;
|
||
}
|
||
OPENOBJ_END();
|
||
OPENOBJ_BEGIN(nodeId, AcDb::kForRead, TDbPipeNode, pNode);
|
||
if(pNode){
|
||
int num = pNode->GetInterfaceNum();
|
||
for(int i=0;i<num;i++){
|
||
TPipeInterface face;
|
||
pNode->GetInterface(i, face);
|
||
|
||
AcDbObjectId nextPipeId = face.m_idPipe;
|
||
OPENOBJ_BEGIN(nextPipeId, AcDb::kForRead, TDbPipe, pPipe);
|
||
if(pPipe){
|
||
csDnHead = pPipe->GetLabel();
|
||
double nPipeDn = pPipe->GetDnDiameter();
|
||
CString csSpec;
|
||
if(csDnHead == _T(""))
|
||
csDnHead = _T("DN");
|
||
|
||
lstDn.Append(new double(nPipeDn));
|
||
if(dDnTmp < 0)
|
||
dDnTmp = nPipeDn;
|
||
else if(fabs(dDnTmp - nPipeDn) > 0.001)
|
||
bAllDn = FALSE;
|
||
}
|
||
OPENOBJ_END();
|
||
}
|
||
}
|
||
OPENOBJ_END();
|
||
|
||
|
||
|
||
|
||
csRet = csDnHead;
|
||
if(bAllDn) //所有管径都一致
|
||
csRet.Format(_T("%s%.0f"), csRet, dDnTmp);
|
||
else{
|
||
|
||
// 首先进行一下排序,保证不会出现DN32*25*25 & DN25*32*25 被分开列出的情况
|
||
int nCount = lstDn.Length();
|
||
for(int m=0; m<nCount-1; m++) {
|
||
for(int n=0; n<nCount-1-m; n++) {
|
||
if (*lstDn[n]>*lstDn[n+1]) { //Swap
|
||
lstDn.Swap(n,n+1);
|
||
}
|
||
}
|
||
}
|
||
|
||
for(int j=0;j<lstDn.Length();j++){
|
||
double dDn = *lstDn[j];
|
||
if(j == 0)
|
||
csRet.Format(_T("%s%.0f"), csRet, dDn);
|
||
else
|
||
csRet.Format(_T("%sx%.0f"), csRet, dDn);
|
||
}
|
||
}
|
||
return csRet;
|
||
}
|
||
|
||
//将节点或设备加入统计表中
|
||
BOOL AppandNode2List(DList<AcDbObjectId> &lstNode, AcDbObjectId nodeId1, DList<SAmountItem> &lstAll, TDbPipe *pPipe, BOOL bNeedFitting, int iNum = 1)
|
||
{
|
||
// cet 2010.5.20 del 将大小接头所有的操作放入此函数中
|
||
// // cet 2010.4.8 add 排除大小接头
|
||
// ads_name sName;
|
||
// acdbGetAdsName(sName, nodeId1);
|
||
// Entity ent(sName);
|
||
// if (ent.Is( _T("ATS_DOUBLELINEPIPEREDUCER")))
|
||
// {
|
||
// return FALSE;
|
||
// }
|
||
|
||
// cet 2010.5.20 add
|
||
ads_name sName;
|
||
acdbGetAdsName(sName, nodeId1);
|
||
Entity ent(sName);
|
||
if (ent.Is( _T("ATS_DOUBLELINEPIPEREDUCER")) && bNeedFitting)
|
||
{
|
||
AcDbObjectId idEnt;
|
||
acdbGetObjectId(idEnt, ent);
|
||
TDbDoubleLinePipeReducer *pReducer = NULL;
|
||
if (Acad::eOk == acdbOpenObject(pReducer, idEnt, AcDb::kForRead))
|
||
{
|
||
double dSPipeDia = pReducer->GetSPipeDiameter();
|
||
double dEPipeDia = pReducer->GetEPipeDiameter();
|
||
int nPipeType = pReducer->GetType();
|
||
int nLinkType = pReducer->GetLinkType();
|
||
pReducer->close();
|
||
|
||
CString strBlkName, strDesName, strNodeSpeccsDemo, strDemo, strNodeSpec;
|
||
strBlkName = _T("");
|
||
if (nLinkType == TDbDoubleLinePipeReducer::eFlangeLink)
|
||
{
|
||
if (nPipeType == TDbDoubleLinePipeReducer::eCenter)
|
||
{
|
||
strDesName = _T("同心异径管");
|
||
}
|
||
else if (nPipeType == TDbDoubleLinePipeReducer::eUp || nPipeType == TDbDoubleLinePipeReducer::eDown)
|
||
{
|
||
strDesName = _T("偏心异径管");
|
||
}
|
||
}
|
||
else if (nLinkType == TDbDoubleLinePipeReducer::eJointing)
|
||
{
|
||
if (nPipeType == TDbDoubleLinePipeReducer::eCenter)
|
||
{
|
||
strDesName = _T("同心异径管");
|
||
}
|
||
else if (nPipeType == TDbDoubleLinePipeReducer::eUp || nPipeType == TDbDoubleLinePipeReducer::eDown)
|
||
{
|
||
strDesName = _T("偏心异径管");
|
||
}
|
||
}
|
||
|
||
if (dSPipeDia > dEPipeDia)
|
||
{
|
||
strNodeSpec.Format(_T("DN%.0fX%.0f"), dSPipeDia, dEPipeDia);
|
||
}
|
||
else
|
||
{
|
||
strNodeSpec.Format(_T("DN%.0fX%.0f"), dEPipeDia, dSPipeDia);
|
||
}
|
||
|
||
int nItem(0);
|
||
SAmountItem *pItem = new SAmountItem(nItem, strBlkName, strDesName, strNodeSpec, _T("个"), 1, strDemo);
|
||
IsAppandItem(lstAll, pItem, iNum);
|
||
|
||
return TRUE;
|
||
}
|
||
|
||
return FALSE;
|
||
}
|
||
else if (ent.Is( _T("ATS_DOUBLELINEPIPEREDUCER")))
|
||
{
|
||
return TRUE;
|
||
}
|
||
|
||
if(!IsAppandNode(lstNode, nodeId1))
|
||
return FALSE;
|
||
|
||
int iItem(0);
|
||
CString csBlkName, csDesName, csNodeSpec;
|
||
|
||
if(!GetEquipNameById(nodeId1, csBlkName, csDesName, iItem))
|
||
return FALSE;
|
||
if(!bNeedFitting && (csDesName == _T("堵头") || csDesName == _T("弯头") || csDesName == _T("变径") || csDesName == _T("三通") || csDesName == _T("四通")))
|
||
return FALSE;
|
||
|
||
if(csDesName == _T("检查井")){
|
||
double nPipeLength = pPipe->Length();
|
||
// if(!DocGetMeterUnitDraw())
|
||
// nPipeLength = nPipeLength/1000;
|
||
ads_name entTmp;
|
||
acdbGetAdsName(entTmp, nodeId1);
|
||
CString csWellRadius = ReadXdata(entTmp, _T("TG-WELL-RADIUS"));
|
||
double dWellRadius = _tstof(csWellRadius);
|
||
csNodeSpec.Format(_T("Φ %.0f"), dWellRadius);
|
||
nPipeLength -= dWellRadius/1000/2;
|
||
|
||
if(pPipe->GetSysType() == TPipeSys::kRainWater)
|
||
csDesName = _T("雨水检查井");
|
||
else if(pPipe->GetSysType() == TPipeSys::kDirtWater)
|
||
csDesName = _T("污水检查井");
|
||
}
|
||
else if(csDesName.Find(_T("消火栓")) > -1){
|
||
OPENOBJ_BEGIN(nodeId1, AcDb::kForRead, TDbEquipment, pEquip);
|
||
if(pEquip){
|
||
double dX = pEquip->GetScale();
|
||
double dY = pEquip->GetYScale();
|
||
if(dX > 10 && dY > 10)
|
||
csNodeSpec.Format(_T("%.0f*%.0f"), dX, dY);
|
||
}
|
||
OPENOBJ_END();
|
||
}
|
||
else if(csDesName == _T("三通") || csDesName == _T("弯头") || csDesName == _T("四通") || csDesName == _T("变径") || csDesName == _T("堵头"))
|
||
csNodeSpec = GetNodeSpec(nodeId1);
|
||
else if (csDesName.Find(_T("存水弯")) > -1 || csDesName.Find(_T("地漏")) > -1 || csDesName.Find(_T("排水")) > -1
|
||
|| csDesName == _T("毛发聚集器") || csDesName == _T("清扫口") || csDesName == _T("雨水斗"))
|
||
{
|
||
// zxl 2012.08.14 add 支持排水附件显示规格
|
||
CString csDnHead = pPipe->GetLabel();
|
||
int nEQDn = 0;
|
||
nEQDn = pPipe->GetDnDiameter();
|
||
CString csSpec;
|
||
csSpec.Format(_T("%s%d"), csDnHead, nEQDn);
|
||
csNodeSpec = csSpec;
|
||
// 排水点不显示规格
|
||
CString csDwb = g_csDwbPath + _T("TwtSys");
|
||
XString xsTmp;
|
||
if(LoadDwbBlock(csDwb, _T("00000147"), xsTmp) != RTNORM)//排水点
|
||
return FALSE;
|
||
AcDbObjectId idDrainPt = GetBlockIdFromString(xsTmp);
|
||
OPENOBJ_BEGIN(nodeId1, AcDb::kForRead, TDbEquipment, pEquip);
|
||
if(pEquip)
|
||
{
|
||
if (pEquip->GetBlock2d() == idDrainPt)
|
||
{
|
||
csNodeSpec = _T("");
|
||
}
|
||
}
|
||
OPENOBJ_END();
|
||
}
|
||
else if (csDesName.Compare(_T("方检查井")) == 0) // cet 2013.1.23 add 方检查井按规格区分
|
||
{
|
||
ads_name entTmp;
|
||
acdbGetAdsName(entTmp, nodeId1);
|
||
CString csWellRadius = ReadXdata(entTmp, _T("TG-WELL-RADIUS"));
|
||
double dWellRadius = _tstof(csWellRadius);
|
||
csNodeSpec.Format(_T("%.0fX%.0f"), dWellRadius, dWellRadius);
|
||
}
|
||
else if (csDesName.Compare(_T("检查口")) == 0)// 检查口规格
|
||
{
|
||
CString csDnHead = pPipe->GetLabel();
|
||
csNodeSpec.Format(_T("%s%.0f"), csDnHead, pPipe->GetDnDiameter());
|
||
}
|
||
|
||
CString csDemo;
|
||
if(csDesName == _T("上下喷头"))
|
||
csDemo = _T("下垂型喷头+直立型喷头");
|
||
|
||
SAmountItem *pItem = new SAmountItem(iItem, csBlkName, csDesName, csNodeSpec, _T("个"), 1, csDemo);
|
||
IsAppandItem(lstAll, pItem, iNum);
|
||
|
||
if(csDesName.Find(_T("喷头")) > -1 && bNeedFitting){ //注意要考虑喷淋系统的节点
|
||
OPENOBJ_BEGIN(nodeId1, AcDb::kForRead, TDbEquipment, pEquip);
|
||
if(pEquip){
|
||
int num = pEquip->GetInterfaceNum();
|
||
if(num == 1)
|
||
csDesName = _T("弯头");
|
||
else if(num == 2)
|
||
csDesName = _T("三通");
|
||
else
|
||
return TRUE;
|
||
}
|
||
OPENOBJ_END();
|
||
csNodeSpec = GetNodeSpec(nodeId1);
|
||
SAmountItem *pItem = new SAmountItem(3, _T(""), csDesName, csNodeSpec, _T("个"), 1, csDemo);
|
||
IsAppandItem(lstAll, pItem, iNum);
|
||
}
|
||
|
||
return TRUE;
|
||
}
|
||
|
||
CString GetPipeSysNameBysLay(const TCHAR *layer, CString &csBlkName)
|
||
{
|
||
// cet 2011.12.9 add
|
||
std::map<CString,CString> mapLayerPipeName;
|
||
GetLayerPipeName(mapLayerPipeName);
|
||
|
||
CString csRet;
|
||
if(_tcsicmp(layer, LAY_PIPE_FEED) == 0 || _tcsicmp(layer, LAY_VPIPE_FEED) == 0)
|
||
csRet = _T("给水管线");
|
||
else if(_tcsicmp(layer, LAY_PIPE_FEED2) == 0 || _tcsicmp(layer, LAY_VPIPE_FEED2) == 0)
|
||
csRet = _T("给水中区管线");
|
||
else if(_tcsicmp(layer, LAY_PIPE_FEED3) == 0 || _tcsicmp(layer, LAY_VPIPE_FEED3) == 0)
|
||
csRet = _T("给水高区管线");
|
||
else if(_tcsicmp(layer, LAY_PIPE_SPRINKLE) == 0 || _tcsicmp(layer, LAY_VPIPE_SPRINKLE) == 0)
|
||
csRet = _T("喷淋管线");
|
||
else if(_tcsicmp(layer, LAY_PIPE_SPRINKLE2) == 0 || _tcsicmp(layer, LAY_VPIPE_SPRINKLE2) == 0)
|
||
csRet = _T("喷淋中区管线");
|
||
else if(_tcsicmp(layer, LAY_PIPE_SPRINKLE3) == 0 || _tcsicmp(layer, LAY_PIPE_SPRINKLE3) == 0)
|
||
csRet = _T("喷淋高区管线");
|
||
else if(_tcsicmp(layer, LAY_PIPE_HEADBACK) == 0 || _tcsicmp(layer, LAY_VPIPE_HEADBACK) == 0)
|
||
csRet = _T("热回水管线");
|
||
else if(_tcsicmp(layer, LAY_PIPE_HEADBACK2) == 0 || _tcsicmp(layer, LAY_VPIPE_HEADBACK2) == 0)
|
||
csRet = _T("热回水中区管线");
|
||
else if(_tcsicmp(layer, LAY_PIPE_HEADBACK3) == 0 || _tcsicmp(layer, LAY_VPIPE_HEADBACK3) == 0)
|
||
csRet = _T("热回水高区管线");
|
||
else if(_tcsicmp(layer, LAY_PIPE_HEADFEED) == 0 || _tcsicmp(layer, LAY_VPIPE_HEADFEED) == 0)
|
||
csRet = _T("热给水管线");
|
||
else if(_tcsicmp(layer, LAY_PIPE_HEADFEED2) == 0 || _tcsicmp(layer, LAY_VPIPE_HEADFEED2) == 0)
|
||
csRet = _T("热给水中区管线");
|
||
else if(_tcsicmp(layer, LAY_PIPE_HEADFEED3) == 0 || _tcsicmp(layer, LAY_VPIPE_HEADFEED3) == 0)
|
||
csRet = _T("热给水高区管线");
|
||
else if(_tcsicmp(layer, LAY_PIPE_USED) == 0 || _tcsicmp(layer, LAY_VPIPE_USED) == 0)
|
||
csRet = _T("中水管线");
|
||
else if(_tcsicmp(layer, LAY_PIPE_USED2) == 0 || _tcsicmp(layer, LAY_VPIPE_USED2) == 0)
|
||
csRet = _T("中水中区管线");
|
||
else if(_tcsicmp(layer, LAY_PIPE_USED3) == 0 || _tcsicmp(layer, LAY_VPIPE_USED3) == 0)
|
||
csRet = _T("中水高区管线");
|
||
else if(_tcsicmp(layer, LAY_PIPE_FIRE) == 0 || _tcsicmp(layer, LAY_VPIPE_FIRE) == 0)
|
||
csRet = _T("消防管线");
|
||
else if(_tcsicmp(layer, LAY_PIPE_FIRE2) == 0 || _tcsicmp(layer, LAY_VPIPE_FIRE2) == 0)
|
||
csRet = _T("消防中区管线");
|
||
else if(_tcsicmp(layer, LAY_PIPE_FIRE3) == 0 || _tcsicmp(layer, LAY_VPIPE_FIRE3) == 0)
|
||
csRet = _T("消防高区管线");
|
||
else if(_tcsicmp(layer, LAY_PIPE_USELESS) == 0 || _tcsicmp(layer, LAY_VPIPE_USELESS) == 0)
|
||
csRet = _T("废水管线");
|
||
else if(_tcsicmp(layer, LAY_PIPE_DIRT) == 0 || _tcsicmp(layer, LAY_VPIPE_DIRT) == 0)
|
||
csRet = _T("污水管线");
|
||
else if(_tcsicmp(layer, LAY_VPIPE_RAIN) == 0 ||_tcsicmp(layer, LAY_PIPE_RAIN) == 0 )
|
||
csRet = _T("雨水管线");
|
||
|
||
|
||
else if(_tcsicmp(layer, LAY_PIPE_OTHER) == 0 || _tcsicmp(layer, LAY_VPIPE_OTHER) == 0)
|
||
csRet = _T("其它管线");
|
||
else if(_tcsicmp(layer, LAY_PIPE_COAGULATE) == 0 || _tcsicmp(layer, LAY_VPIPE_COAGULATE) == 0)
|
||
csRet = mapLayerPipeName[LAY_PIPE_COAGULATE] + _T("管线");
|
||
else if(_tcsicmp(layer, LAY_PIPE_DRINK) == 0 || _tcsicmp(layer, LAY_VPIPE_DRINK) == 0)
|
||
csRet = mapLayerPipeName[LAY_PIPE_DRINK] + _T("管线");
|
||
else if(_tcsicmp(layer, LAY_PIPE_PRESSDIRT) == 0 || _tcsicmp(layer, LAY_VPIPE_PRESSDIRT) == 0)
|
||
csRet = mapLayerPipeName[LAY_PIPE_PRESSDIRT] + _T("管线");
|
||
else if(_tcsicmp(layer, LAY_PIPE_PRESSUSELESS) == 0 || _tcsicmp(layer, LAY_VPIPE_PRESSUSELESS) == 0)
|
||
csRet = mapLayerPipeName[LAY_PIPE_PRESSUSELESS] + _T("管线");
|
||
else if(_tcsicmp(layer, LAY_PIPE_PRESSRAIN) == 0 || _tcsicmp(layer, LAY_VPIPE_PRESSRAIN) == 0)
|
||
csRet = mapLayerPipeName[LAY_PIPE_PRESSRAIN] + _T("管线");
|
||
else if (_tcsicmp(layer, LAY_PIPE_USER1) == 0 || _tcsicmp(layer, LAY_VPIPE_USER1) == 0)
|
||
csRet = mapLayerPipeName[LAY_PIPE_USER1] + _T("管线");
|
||
else if (_tcsicmp(layer, LAY_PIPE_USER2) == 0 || _tcsicmp(layer, LAY_VPIPE_USER2) == 0)
|
||
csRet = mapLayerPipeName[LAY_PIPE_USER2] + _T("管线");
|
||
else if (_tcsicmp(layer, LAY_PIPE_USER3) == 0 || _tcsicmp(layer, LAY_VPIPE_USER3) == 0)
|
||
csRet = mapLayerPipeName[LAY_PIPE_USER3] + _T("管线");
|
||
else if (_tcsicmp(layer, LAY_PIPE_USER4) == 0 || _tcsicmp(layer, LAY_VPIPE_USER4) == 0)
|
||
csRet = mapLayerPipeName[LAY_PIPE_USER4] + _T("管线");
|
||
else if (_tcsicmp(layer, LAY_PIPE_USER5) == 0 || _tcsicmp(layer, LAY_VPIPE_USER5) == 0)
|
||
csRet = mapLayerPipeName[LAY_PIPE_USER5] + _T("管线");
|
||
else if (_tcsicmp(layer, LAY_PIPE_USER6) == 0 || _tcsicmp(layer, LAY_VPIPE_USER6) == 0)
|
||
csRet = mapLayerPipeName[LAY_PIPE_USER6] + _T("管线");
|
||
else if (_tcsicmp(layer, LAY_PIPE_USER7) == 0 || _tcsicmp(layer, LAY_VPIPE_USER7) == 0)
|
||
csRet = mapLayerPipeName[LAY_PIPE_USER7] + _T("管线");
|
||
else if (_tcsicmp(layer, LAY_PIPE_USER8) == 0 || _tcsicmp(layer, LAY_VPIPE_USER8) == 0)
|
||
csRet = mapLayerPipeName[LAY_PIPE_USER8] + _T("管线");
|
||
|
||
// cet 2010.9.1 modify 防止管线块名重复
|
||
// csBlkName = g_csPipeDim[GetPipeLayerIdxByName(layer)];
|
||
csBlkName = csRet;
|
||
int iColorIdx = GetLayerColorIdx(layer);
|
||
csBlkName.Format(_T("-%s-%d"), csBlkName, iColorIdx);
|
||
return csRet;
|
||
}
|
||
|
||
// zxl 20123.08.14 add
|
||
void GetPoolNameById(const AcDbObjectId &idRef, CString &csBlkName, CString &csDesName)
|
||
{
|
||
CString csDwb = g_csDwbPath + _T("TwtSys");
|
||
XString xsTmp1, xsTmp2, xsTmp3, xsTmp4, xsTmp5, xsTmp6;
|
||
if(LoadDwbBlock(csDwb, _T("00000353"), xsTmp1) != RTNORM) //化粪池
|
||
return;
|
||
if(LoadDwbBlock(csDwb, _T("00000354"), xsTmp2) != RTNORM) //隔油池
|
||
return;
|
||
if(LoadDwbBlock(csDwb, _T("00000355"), xsTmp3) != RTNORM) //沉淀池
|
||
return;
|
||
if(LoadDwbBlock(csDwb, _T("00000356"), xsTmp4) != RTNORM) //降温池
|
||
return;
|
||
if(LoadDwbBlock(csDwb, _T("00000357"), xsTmp5) != RTNORM) //中和池
|
||
return;
|
||
if(LoadDwbBlock(csDwb, _T("00000399"), xsTmp6) != RTNORM) //化粪池
|
||
return;
|
||
|
||
AcDbObjectId idBlock;
|
||
idBlock = InitBlock((const TCHAR*)xsTmp1);
|
||
if (idBlock && idBlock == idRef)
|
||
{
|
||
csBlkName = xsTmp1;
|
||
csDesName = _T("化粪池");
|
||
}
|
||
idBlock = InitBlock((const TCHAR*)xsTmp2);
|
||
if (idBlock && idBlock == idRef)
|
||
{
|
||
csBlkName = xsTmp2;
|
||
csDesName = _T("隔油池");
|
||
}
|
||
idBlock = InitBlock((const TCHAR*)xsTmp3);
|
||
if (idBlock && idBlock == idRef)
|
||
{
|
||
csBlkName = xsTmp3;
|
||
csDesName = _T("沉淀池");
|
||
}
|
||
idBlock = InitBlock((const TCHAR*)xsTmp4);
|
||
if (idBlock && idBlock == idRef)
|
||
{
|
||
csBlkName = xsTmp4;
|
||
csDesName = _T("降温池");
|
||
}
|
||
idBlock = InitBlock((const TCHAR*)xsTmp5);
|
||
if (idBlock && idBlock == idRef)
|
||
{
|
||
csBlkName = xsTmp5;
|
||
csDesName = _T("中和池");
|
||
}
|
||
idBlock = InitBlock((const TCHAR*)xsTmp6);
|
||
if (idBlock && idBlock == idRef)
|
||
{
|
||
csBlkName = xsTmp6;
|
||
csDesName = _T("化粪池");
|
||
}
|
||
}
|
||
|
||
// 添加扩展字典,保存实体id cet 2012.9.17 add
|
||
void WriteXDataToEntity(const AcDbObjectId &idEnt, PickSet &ss, const CString &sXRecordName = _T("XdPickset"))
|
||
{
|
||
AcDbEntity *pEnt = NULL;
|
||
acdbOpenObject(pEnt, idEnt, AcDb::kForWrite);
|
||
if (pEnt == NULL)
|
||
{
|
||
return;
|
||
}
|
||
// 获取扩展字典
|
||
pEnt->createExtensionDictionary();
|
||
AcDbObjectId idDict = pEnt->extensionDictionary();
|
||
pEnt->close();
|
||
// 打开扩展字典,获得扩展记录
|
||
AcDbDictionary *pDict = NULL;
|
||
acdbOpenObject(pDict, idDict, AcDb::kForWrite);
|
||
if (pDict == NULL)
|
||
{
|
||
return;
|
||
}
|
||
|
||
AcDbObjectId idXd;
|
||
pDict->getAt(sXRecordName, idXd);
|
||
if (idXd.isValid())
|
||
{
|
||
pDict->close();
|
||
acutPrintf(_T("\n扩展记录已存在,请重新命名!"));
|
||
return;
|
||
}
|
||
|
||
AcDbXrecord *pXd = new AcDbXrecord;
|
||
pDict->setAt(sXRecordName, pXd, idXd);
|
||
pDict->close();
|
||
|
||
struct resbuf *pBuf = NULL, *pTemp = NULL, *pNext = NULL;
|
||
for (long i = 0; i < ss.Length(); i++)
|
||
{
|
||
if ( i != 0)
|
||
{
|
||
pTemp = acutBuildList(AcDb::kDxfSoftPointerId, ss[i].name, 0);
|
||
pNext->rbnext = pTemp;
|
||
pNext = pTemp;
|
||
}
|
||
else
|
||
{
|
||
pBuf = acutBuildList(AcDb::kDxfSoftPointerId, ss[i].name, 0);
|
||
pNext = pBuf;
|
||
}
|
||
}
|
||
|
||
pXd->setFromRbChain(*pBuf);
|
||
acutRelRb(pBuf);
|
||
pXd->close();
|
||
}
|
||
|
||
void ReadXDataFromEntity(const AcDbObjectId &idEnt, PickSet &ss, const CString &sXRecordName = _T("XdPickset"))
|
||
{
|
||
AcDbEntity *pEnt = NULL;
|
||
acdbOpenObject(pEnt, idEnt, AcDb::kForRead);
|
||
if (pEnt == NULL)
|
||
{
|
||
return;
|
||
}
|
||
// 获取扩展字典
|
||
AcDbObjectId idDict = pEnt->extensionDictionary();
|
||
pEnt->close();
|
||
// 打开扩展字典,获得扩展记录
|
||
AcDbDictionary *pDict = NULL;
|
||
acdbOpenObject(pDict, idDict, AcDb::kForRead);
|
||
if (pDict == NULL)
|
||
{
|
||
return;
|
||
}
|
||
|
||
AcDbXrecord *pXd = NULL;
|
||
pDict->getAt(sXRecordName, (AcDbObject *&)pXd, AcDb::kForRead);
|
||
pDict->close();
|
||
if (pXd == NULL)
|
||
{
|
||
return;
|
||
}
|
||
struct resbuf *pBuf = NULL;
|
||
pXd->rbChain(&pBuf);
|
||
pXd->close();
|
||
|
||
if (pBuf != NULL)
|
||
{
|
||
AcDbObjectId id;
|
||
struct resbuf *pTemp = pBuf;
|
||
while(pTemp != NULL)
|
||
{
|
||
if (pTemp->restype == AcDb::kDxfSoftPointerId)
|
||
{
|
||
// 排斥已删除实体
|
||
acdbGetObjectId(id, pTemp->resval.rlname);
|
||
if (!id.isValid())
|
||
{
|
||
pTemp = pTemp->rbnext;
|
||
continue;
|
||
}
|
||
Entity ent(pTemp->resval.rlname);
|
||
ss += ent;
|
||
pTemp = pTemp->rbnext;
|
||
continue;
|
||
}
|
||
break;
|
||
}
|
||
acutRelRb(pBuf);
|
||
}
|
||
}
|
||
|
||
// zxl 2013.07.15 add
|
||
BOOL GetHoleNameByDim(Entity entHole, CString &csName)
|
||
{
|
||
XPoint pt;
|
||
AcDbObjectId Id;
|
||
double dDist = 0.0;
|
||
acdbGetObjectId(Id, entHole);
|
||
AcDbBlockReference *pBlkRef = NULL;
|
||
acdbOpenObject(pBlkRef, Id, AcDb::kForRead);
|
||
if(pBlkRef != NULL)
|
||
{
|
||
pt = pBlkRef->position();
|
||
AcGeScale3d sc = pBlkRef->scaleFactors();
|
||
dDist = sqrt(pow(sc.sx / 2, 2) + pow(sc.sy / 2, 2));
|
||
pBlkRef->close();
|
||
}
|
||
|
||
OPENOBJ_BEGIN(entHole, AcDb::kForRead, TDbOpening, pOpening);
|
||
if(pOpening != NULL)
|
||
{
|
||
pt = pOpening->GetLocation();
|
||
double dX = 0.0, dY = 0.0;
|
||
AcGeScale3d sc = pOpening->GetInsert2DScale(&dX, &dY);
|
||
dDist = sqrt(pow(dX / 2, 2) + pow(dY / 2, 2));
|
||
}
|
||
OPENOBJ_END();
|
||
|
||
PickSet ssSel(SS_FREE);
|
||
RBList rbFilter(RTDXF0, _T("ATS_MULTILEADER"), NULL);
|
||
acedSSGet(_T("A"),NULL,NULL,rbFilter,ssSel);
|
||
|
||
Entity ent;
|
||
for (long l = 0; l < ssSel.Length(); l++)
|
||
{
|
||
ent = ssSel[l];
|
||
AcDbObjectId IdDim;
|
||
acdbGetObjectId(IdDim, ent);
|
||
OPENOBJ_BEGIN(IdDim, AcDb::kForRead, TDbSymbMultiLeader, pLeader);
|
||
XPointList lstPts;
|
||
pLeader->GetLeaderVertexes(lstPts);
|
||
if(lstPts.Length() > 0)
|
||
{
|
||
if ((*lstPts[0]).Distance2d(pt) < dDist)
|
||
{
|
||
csName = pLeader->GetText1();
|
||
return TRUE;
|
||
}
|
||
}
|
||
OPENOBJ_END();
|
||
}
|
||
return FALSE;
|
||
}
|
||
|
||
void AmountAllMaterial()
|
||
{
|
||
CTemporaryResourceOverride vTemp;
|
||
CAmountSettingDlg dlg;
|
||
if(dlg.DoModal() != IDOK)
|
||
return;
|
||
if(dlg.m_iRange == 1){
|
||
AmountAllMaterialFromDwg(dlg);
|
||
return;
|
||
}
|
||
|
||
DList<SAmountItem> lstAll;
|
||
PickSet ssAll(SS_FREE), ss(SS_FREE);
|
||
RBList rbMask = ads_buildlist( -4, _T("<or"),
|
||
-4, _T("<and"), RTDXF0, _T("ATS_PUMP"), 8, _T("*"), -4, _T("and>"),
|
||
-4, _T("<and"), RTDXF0, _T("ATS_WATERTANK"), 8, _T("*"), -4, _T("and>"),
|
||
-4, _T("<and"), RTDXF0, _T("ATS_PIPEVALVE"), 8, _T("*"), -4, _T("and>"),
|
||
-4, _T("<and"), RTDXF0, _T("ATS_PIPE"), 8, _T("*"), -4, _T("and>"),
|
||
-4, _T("<and"), RTDXF0, _T("ATS_DOUBLELINEPIPE"), 8, _T("*"), -4, _T("and>"),
|
||
-4, _T("<and"), RTDXF0, _T("ATS_DOUBLELINEPIPEREDUCER"), 8, _T("*"), -4, _T("and>"), // cet 2010.4.8 add
|
||
-4, _T("<and"), RTDXF0, _T("ATS_EQUIPMENT"), 8, _T("*"), -4, _T("and>"),
|
||
-4, _T("<and"), RTDXF0, _T("INSERT"), 8, _T("LVTRY"), -4, _T("and>"),
|
||
-4, _T("<and"), RTDXF0, _T("AEC_BLOCK_INSERT"), 8, _T("LVTRY"), -4, _T("and>"),
|
||
-4, _T("<and"), RTDXF0, _T("ATS_POOL"), 8, _T("*"), -4, _T("and>"), // zxl 2012.08.14 add
|
||
-4, _T("<and"), RTDXF0, _T("INSERT"), 8, LAY_EQ_FIRE, -4, _T("and>"), // cet 2013.2.6 add 统计灭火器
|
||
-4, _T("<and"), RTDXF0, _T("INSERT"), 8, LAY_TWT_HOLE, -4, _T("and>"), // zxl 2013.07.10 add 统计楼板洞
|
||
-4, _T("<and"), RTDXF0, _T("ATS_OPENING"), 8, LAY_TWT_HOLE, -4, _T("and>"), // zxl 2013.07.10 add 统计基础洞
|
||
-4, _T("or>"), NULL);
|
||
RBList rbMask2(RTDXF0, _T("ATS_PIPE"), 8, GetLayerNames(_T("管")), NULL);
|
||
|
||
XPoly2D poly;
|
||
TCHAR szKey[32]=_T("P");
|
||
TCHAR cRet;
|
||
int ret = SelectEntities(_T("\n请选择统计范围{选取闭合PLINE(P)}<整张图>"), ssAll, rbMask, szKey, cRet);
|
||
if(ret == RTKWORD){
|
||
Entity entPoly;
|
||
RBList rbMask2(RTDXF0, _T("LWPOLYLINE"), 8, _T("*"), NULL);
|
||
if(SelectEntity(_T("\n请选择表示范围的闭合PLINE:<退出>"), entPoly, rbMask2) != RTNORM)
|
||
return;
|
||
XPoly2D poly2(entPoly);
|
||
XPoint ptLow3, ptUp3;
|
||
poly2.GetExtend(ptLow3, ptUp3);
|
||
poly2.TransUCS(Groups(0), Groups(1));//Groups(0) wcs, Groups(1) ucs
|
||
RBList rbFence = poly2.Fence();
|
||
//AssureInCurrentView(ptLow3, ptUp3); cet 2011.12.31 add
|
||
AssureInCurrentView_New(ptLow3, ptUp3);
|
||
ssAll.Get(_T("CP"), rbFence, NULL, rbMask);
|
||
poly = poly2;
|
||
poly.TransUCS(Groups(1), Groups(0)); // cet 2011.12.30 add
|
||
}
|
||
else if(ret != RTNORM){
|
||
ssAll.Get(_T("X"), NULL, NULL, rbMask);
|
||
}
|
||
|
||
long len = ssAll.Length();
|
||
if(len < 1)
|
||
return;
|
||
for(long i=0;i<len;i++){
|
||
Entity ent = ssAll[i];
|
||
TCHAR layer[256];
|
||
ent.GetData(8, layer);
|
||
|
||
if(dlg.m_bJL && (_tcsicmp(layer, LAY_PIPE_FEED) == 0
|
||
|| _tcsicmp(layer, LAY_VPIPE_FEED) == 0
|
||
|| _tcsicmp(layer, LAY_PIPE_FEED2) == 0
|
||
|| _tcsicmp(layer, LAY_PIPE_FEED3) == 0
|
||
|| _tcsicmp(layer, LAY_VPIPE_FEED2) == 0
|
||
|| _tcsicmp(layer, LAY_VPIPE_FEED3) == 0))
|
||
{
|
||
ss += ent;
|
||
}
|
||
if(dlg.m_bHL && (_tcsicmp(layer, LAY_PIPE_SPRINKLE) == 0
|
||
|| _tcsicmp(layer, LAY_VPIPE_SPRINKLE) == 0
|
||
|| _tcsicmp(layer, LAY_EQUIP_SPRINKLE) == 0
|
||
|| _tcsicmp(layer, LAY_PIPE_SPRINKLE2) == 0
|
||
|| _tcsicmp(layer, LAY_PIPE_SPRINKLE3) == 0
|
||
|| _tcsicmp(layer, LAY_VPIPE_SPRINKLE2) == 0
|
||
|| _tcsicmp(layer, LAY_VPIPE_SPRINKLE3) == 0))
|
||
{
|
||
ss += ent;
|
||
}
|
||
if(dlg.m_bRHL && (_tcsicmp(layer, LAY_PIPE_HEADBACK) == 0
|
||
|| _tcsicmp(layer, LAY_VPIPE_HEADBACK) == 0
|
||
|| _tcsicmp(layer, LAY_PIPE_HEADBACK2) == 0
|
||
|| _tcsicmp(layer, LAY_PIPE_HEADBACK3) == 0
|
||
|| _tcsicmp(layer, LAY_VPIPE_HEADBACK2) == 0
|
||
|| _tcsicmp(layer, LAY_VPIPE_HEADBACK3) == 0))
|
||
{
|
||
ss += ent;
|
||
}
|
||
if(dlg.m_bRJL && (_tcsicmp(layer, LAY_PIPE_HEADFEED) == 0
|
||
|| _tcsicmp(layer, LAY_PIPE_HEADFEED2) == 0
|
||
|| _tcsicmp(layer, LAY_PIPE_HEADFEED3) == 0
|
||
|| _tcsicmp(layer, LAY_VPIPE_HEADFEED) == 0
|
||
|| _tcsicmp(layer, LAY_VPIPE_HEADFEED2) == 0
|
||
|| _tcsicmp(layer, LAY_VPIPE_HEADFEED3) == 0))
|
||
{
|
||
ss += ent;
|
||
}
|
||
if(dlg.m_bZL && (_tcsicmp(layer, LAY_PIPE_USED) == 0
|
||
|| _tcsicmp(layer, LAY_PIPE_USED2) == 0
|
||
|| _tcsicmp(layer, LAY_PIPE_USED3) == 0
|
||
|| _tcsicmp(layer, LAY_VPIPE_USED) == 0
|
||
|| _tcsicmp(layer, LAY_VPIPE_USED2) == 0
|
||
|| _tcsicmp(layer, LAY_VPIPE_USED3) == 0))
|
||
{
|
||
ss += ent;
|
||
}
|
||
CString str = LAY_EQUIP_HYDRANT;
|
||
if(dlg.m_bXL && (_tcsicmp(layer, LAY_VPIPE_FIRE) == 0
|
||
|| _tcsicmp(layer, LAY_VPIPE_FIRE2) == 0
|
||
|| _tcsicmp(layer, LAY_VPIPE_FIRE3) == 0
|
||
|| _tcsicmp(layer, LAY_EQUIP_HYDRANT) == 0
|
||
|| _tcsicmp(layer, LAY_EQ_FIRE) == 0 // cet 2011.2.15 add
|
||
|| _tcsicmp(layer, LAY_TWT_OUT) == 0
|
||
|| _tcsicmp(layer, LAY_PIPE_FIRE) == 0
|
||
|| _tcsicmp(layer, LAY_PIPE_FIRE2) == 0
|
||
|| _tcsicmp(layer, LAY_PIPE_FIRE3) == 0))
|
||
{
|
||
ss += ent;
|
||
}
|
||
|
||
|
||
if(dlg.m_bFL && (_tcsicmp(layer, LAY_PIPE_USELESS) == 0 || _tcsicmp(layer, LAY_VPIPE_USELESS) == 0)){
|
||
ss += ent;
|
||
}
|
||
|
||
if(dlg.m_bWL && (_tcsicmp(layer, LAY_PIPE_DIRT) == 0 || _tcsicmp(layer, LAY_VPIPE_DIRT) == 0)){
|
||
ss += ent;
|
||
}
|
||
|
||
if(dlg.m_bYL && (_tcsicmp(layer, LAY_VPIPE_RAIN) == 0 ||_tcsicmp(layer, LAY_PIPE_RAIN) == 0 || _tcsicmp(layer, LAY_TWT_GULLY) == 0)){
|
||
ss += ent;
|
||
}
|
||
|
||
if(dlg.m_bDrink && (_tcsicmp(layer, LAY_PIPE_DRINK) == 0 || _tcsicmp(layer, LAY_VPIPE_DRINK) == 0)){
|
||
ss += ent;
|
||
}
|
||
if(dlg.m_bOther && (_tcsicmp(layer, LAY_PIPE_OTHER) == 0 || _tcsicmp(layer, LAY_VPIPE_OTHER) == 0)){
|
||
ss += ent;
|
||
}
|
||
if(dlg.m_bPressDirt && (_tcsicmp(layer, LAY_PIPE_PRESSDIRT) == 0 || _tcsicmp(layer, LAY_VPIPE_PRESSDIRT) == 0)){
|
||
ss += ent;
|
||
}
|
||
if(dlg.m_bPressUseless && (_tcsicmp(layer, LAY_PIPE_PRESSUSELESS) == 0 || _tcsicmp(layer, LAY_VPIPE_PRESSUSELESS) == 0)){
|
||
ss += ent;
|
||
}
|
||
if(dlg.m_bPressRain && (_tcsicmp(layer, LAY_PIPE_PRESSRAIN) == 0 || _tcsicmp(layer, LAY_VPIPE_PRESSRAIN) == 0)){
|
||
ss += ent;
|
||
}
|
||
if(dlg.m_bCoagulate && (_tcsicmp(layer, LAY_PIPE_COAGULATE) == 0 || _tcsicmp(layer, LAY_VPIPE_COAGULATE) == 0)){
|
||
ss += ent;
|
||
}
|
||
// cet 2009.12.23 add
|
||
if(dlg.m_bCivismWater && (_tcsicmp(layer, LAY_PIPE_USER1) == 0 || _tcsicmp(layer, LAY_VPIPE_USER1) == 0))
|
||
{
|
||
ss += ent;
|
||
}
|
||
// cet 2009.12.23 add
|
||
if(dlg.m_bCycleWater && (_tcsicmp(layer, LAY_PIPE_USER2) == 0 || _tcsicmp(layer, LAY_VPIPE_USER2) == 0))
|
||
{
|
||
ss += ent;
|
||
}
|
||
|
||
// cet 2011.12.8 add
|
||
if(dlg.IsSelectedMenuItem(0) && (_tcsicmp(layer, LAY_PIPE_USER3) == 0 || _tcsicmp(layer, LAY_VPIPE_USER3) == 0))
|
||
ss += ent;
|
||
if(dlg.IsSelectedMenuItem(1) && (_tcsicmp(layer, LAY_PIPE_USER4) == 0 || _tcsicmp(layer, LAY_VPIPE_USER4) == 0))
|
||
ss += ent;
|
||
if(dlg.IsSelectedMenuItem(2) && (_tcsicmp(layer, LAY_PIPE_USER5) == 0 || _tcsicmp(layer, LAY_VPIPE_USER5) == 0))
|
||
ss += ent;
|
||
if(dlg.IsSelectedMenuItem(3) && (_tcsicmp(layer, LAY_PIPE_USER6) == 0 || _tcsicmp(layer, LAY_VPIPE_USER6) == 0))
|
||
ss += ent;
|
||
if(dlg.IsSelectedMenuItem(4) && (_tcsicmp(layer, LAY_PIPE_USER7) == 0 || _tcsicmp(layer, LAY_VPIPE_USER7) == 0))
|
||
ss += ent;
|
||
if(dlg.IsSelectedMenuItem(5) && (_tcsicmp(layer, LAY_PIPE_USER8) == 0 || _tcsicmp(layer, LAY_VPIPE_USER8) == 0))
|
||
ss += ent;
|
||
|
||
if(_tcsicmp(layer, LAY_PIPE_DOUBLE) == 0)
|
||
ss += ent;
|
||
if(dlg.m_bLvtry && _tcsicmp(layer, LAY_SANIWARE) == 0)
|
||
ss += ent;
|
||
if(_tcsicmp(layer, LAY_TWT_PUMP) == 0 || _tcsicmp(layer, LAY_TWT_WATERTANK) == 0 || (_tcsicmp(layer, LAY_TWT_EXTINGUISHER) == 0 && dlg.m_bXL) || _tcsicmp(layer, LAY_TWT_HOLE) == 0)
|
||
ss += ent;
|
||
if (ent.Is(_T("ATS_POOL")))//zxl 2012.08.20 add 材料统计支持池子
|
||
ss += ent;
|
||
if (dlg.m_bHole && _tcsicmp(layer, LAY_TWT_HOLE) == 0)// 统计基础洞和楼板洞 zxl 2013.07.10 add
|
||
ss += ent;
|
||
|
||
}
|
||
len = ss.Length();
|
||
if(len < 1)
|
||
return;
|
||
acedSetStatusBarProgressMeter(_T("统计中..."), 0, len);
|
||
|
||
PickSet ssCalc(SS_FREE); // cet 2012.9.18 add 所有被统计的实体
|
||
DList<AcDbObjectId> lstNode;
|
||
for(i=0;i<len;i++){
|
||
acedSetStatusBarProgressMeterPos(i);
|
||
Entity ent = ss[i];
|
||
TCHAR layer[256];
|
||
ent.GetData(8, layer);
|
||
ssCalc += ent; // cet 2012.9.18 add
|
||
|
||
int iItem(0);
|
||
CString csBlkName, csDesName;
|
||
if(ent.Is(_T("AEC_BLOCK_INSERT")) || ent.Is(_T("INSERT"))){
|
||
// cet 2013.2.6 add 统计灭火器
|
||
if (ent.Is(_T("INSERT")) && _tcsicmp(layer, LAY_EQ_FIRE) == 0)
|
||
{
|
||
CString sSpecType, sNum, sSpecification, sGrade;
|
||
sSpecType = ReadXdata(ent, _T("SpecType"));
|
||
sNum = ReadXdata(ent, _T("Num"));
|
||
sSpecification = ReadXdata(ent, _T("Specification"));
|
||
sGrade = ReadXdata(ent, _T("Grade"));
|
||
|
||
int nIndex = sSpecification.Find(_T("("));
|
||
if (nIndex != -1)
|
||
{
|
||
csDesName = sSpecification.Right(sSpecification.GetLength() - nIndex);
|
||
sSpecification = sSpecification.Left(nIndex);
|
||
csDesName = sSpecType + _T("灭火器") + csDesName;
|
||
}
|
||
|
||
int nNum = _tstof(sNum);
|
||
sGrade.Insert(0, _T("灭火器级别"));
|
||
sGrade += _T("/具");
|
||
|
||
TCHAR szBlkName[256];
|
||
ent.GetData(2, szBlkName);
|
||
csBlkName = szBlkName;
|
||
|
||
SAmountItem *pItem = new SAmountItem(iItem, csBlkName, csDesName, sSpecification, _T("具"), nNum, sGrade);
|
||
IsAppandItem(lstAll, pItem, dlg.m_iNum);
|
||
continue;
|
||
}
|
||
else if (ent.Is(_T("INSERT")) && _tcsicmp(layer, LAY_TWT_HOLE) == 0)// 支持楼板洞 zxl 2013.07.10 add
|
||
{
|
||
TCHAR szBlkName[256];
|
||
ent.GetData(2, szBlkName);
|
||
csBlkName = szBlkName;
|
||
|
||
CString sSpecType = ReadXdata(ent, _T("SpecType"));
|
||
GetHoleNameByDim(ent, csDesName);
|
||
|
||
SAmountItem *pItem = new SAmountItem(iItem, csBlkName, csDesName, sSpecType, _T("个"), 1, _T(""));
|
||
IsAppandItem(lstAll, pItem, dlg.m_iNum);
|
||
continue;
|
||
}
|
||
|
||
GetSanNameByEnt(ent, csBlkName, csDesName, iItem);
|
||
int nDataSourceType = GetSanitaryDataSourceType(ent);
|
||
XPoint ptHeatFeed, ptFeed, ptDrain, ptDir;
|
||
CSanitaryInfo sanInfo;
|
||
CString sDwbName;
|
||
if (nDataSourceType == 1 || nDataSourceType == 0)
|
||
{
|
||
GetSanitaryDwbSerial(ent, sDwbName);
|
||
}
|
||
else
|
||
{
|
||
GetLocSanitaryData(ent, sanInfo, ptFeed, ptHeatFeed, ptDrain, ptDir);
|
||
sDwbName = sanInfo.sDwbName;
|
||
}
|
||
SAmountItem *pItem = new SAmountItem(iItem, csBlkName, csDesName, _T(""), _T("个"), 1, sDwbName);
|
||
IsAppandItem(lstAll, pItem, dlg.m_iNum);
|
||
continue;
|
||
}
|
||
|
||
if (ent.Is(_T("ATS_EQUIPMENT")) && _tcsicmp(layer, LAY_TWT_EXTINGUISHER) == 0)// zxl 2014.01.21 add 灭火器
|
||
{
|
||
CString sSpecType, sNum, sSpecification, sGrade;
|
||
OPENOBJ_BEGIN(ent, AcDb::kForRead, TDbFireExtinguisher, pFire);
|
||
if(pFire != NULL)
|
||
{
|
||
csBlkName = GetBlkNameById(pFire->GetBlock2d());
|
||
CString sTKName, sRocord;
|
||
SplitBlkStr(csBlkName, sTKName, sRocord);
|
||
if (pFire->GetSpecificationType() == 1)
|
||
{
|
||
sSpecType = _T("推车式");
|
||
}
|
||
else if (pFire->GetSpecificationType() == 0)
|
||
{
|
||
sSpecType = _T("手提式");
|
||
}
|
||
else if (pFire->GetSpecificationType() == 2)
|
||
{
|
||
sSpecType = _T("手提贮压式");
|
||
}
|
||
else
|
||
{
|
||
sSpecType = _T("推车贮压式");
|
||
}
|
||
int nNum = pFire->GetNum();
|
||
sSpecification = pFire->GetSpec();
|
||
sGrade = pFire->GetGrade();
|
||
|
||
int nIndex = sSpecification.Find(_T("("));
|
||
if (nIndex != -1)
|
||
{
|
||
csDesName = sSpecification.Right(sSpecification.GetLength() - nIndex);
|
||
sSpecification = sSpecification.Left(nIndex);
|
||
csDesName = sSpecType + _T("灭火器") + csDesName;
|
||
}
|
||
else
|
||
{
|
||
csDesName = sSpecType + _T("灭火器");
|
||
}
|
||
|
||
sGrade.Insert(0, _T("灭火器级别"));
|
||
sGrade += _T("/具");
|
||
SAmountItem *pItem = new SAmountItem(iItem, csBlkName, csDesName, sSpecification, _T("具"), nNum, sGrade);
|
||
IsAppandItem(lstAll, pItem, dlg.m_iNum);
|
||
}
|
||
OPENOBJ_END();
|
||
continue;
|
||
}
|
||
|
||
double nPipeLength(0);
|
||
int iMaterial = -1;
|
||
double nPipeDn(0);
|
||
if(ent.Is(_T("ATS_EQUIPMENT"))){ //游离的设备 如:灭火器
|
||
OPENOBJ_BEGIN(ent, AcDb::kForRead, TDbEquipment, pEquip);
|
||
if(pEquip){
|
||
int num = pEquip->GetInterfaceNum();
|
||
if(num > 0)
|
||
continue;
|
||
AcDbObjectId idTmp = pEquip->objectId();
|
||
AppandNode2List(lstNode, idTmp, lstAll, NULL, dlg.m_bSan, dlg.m_iNum);
|
||
}
|
||
OPENOBJ_END();
|
||
continue;
|
||
}
|
||
else if (ent.Is(_T("ATS_OPENING")))//基础洞 zxl 2013.07.10 add
|
||
{
|
||
CString sSpecType;
|
||
OPENOBJ_BEGIN(ent, AcDb::kForRead, TDbOpening, pOpening);
|
||
|
||
if(pOpening != NULL)
|
||
{
|
||
GetBlkNameById(pOpening->m_nIdStyle2d, csBlkName, csDesName);
|
||
double dW = 0.0, dH = 0.0, dT = 0.0;
|
||
dW = pOpening->GetWidth();
|
||
dH = pOpening->GetHeight();
|
||
dT = pOpening->GetWallThickness(TRUE);
|
||
sSpecType.Format(_T("%.0f×%.0f×%.0f"), dW, dH, dT);
|
||
}
|
||
OPENOBJ_END();
|
||
csDesName = _T("");
|
||
GetHoleNameByDim(ent, csDesName);
|
||
SAmountItem *pItem = new SAmountItem(iItem, csBlkName, csDesName, sSpecType, _T("个"), 1, _T(""));
|
||
IsAppandItem(lstAll, pItem, dlg.m_iNum);
|
||
continue;
|
||
}
|
||
else if(ent.Is(_T("ATS_PIPEVALVE"))){ //游离的阀门 如:套管 2011-11-25 沈睿 add
|
||
AcDbObjectId idTmp;
|
||
OPENOBJ_BEGIN(ent, AcDb::kForRead, TDbPipeValve, pValve);
|
||
if(pValve){
|
||
AcDbObjectId idPipe = pValve->GetPipeId();
|
||
if(idPipe != NULL)
|
||
continue;
|
||
idTmp = pValve->objectId();
|
||
}
|
||
OPENOBJ_END();
|
||
GetValveNameById(idTmp, csBlkName, csDesName);
|
||
SAmountItem *pItem = new SAmountItem(1, csBlkName, csDesName, _T(""), _T("个"), 1, _T(""));
|
||
IsAppandItem(lstAll, pItem, dlg.m_iNum);
|
||
continue;
|
||
}
|
||
else if(ent.Is(_T("ATS_WATERTANK"))){
|
||
OPENOBJ_BEGIN(ent, AcDb::kForRead, TDbWaterTank, pEquip);
|
||
if(pEquip){
|
||
int iItem(0);
|
||
double dVol(0);
|
||
CString csNodeSpec, csDesName;
|
||
if(pEquip->GetShape() == 0){
|
||
dVol = PI * (pEquip->GetLength() / 2.0) * (pEquip->GetLength() / 2.0) * pEquip->GetHeight();
|
||
csDesName = _T("圆形立式水箱");
|
||
csNodeSpec.Format(_T("%.1fm^U3^U (Φ=%.1f H=%.1f)"), dVol, pEquip->GetLength(), pEquip->GetHeight());
|
||
}
|
||
else if(pEquip->GetShape() == 1){
|
||
csDesName = _T("方形水箱");
|
||
dVol = pEquip->GetLength()*pEquip->GetWidth()*pEquip->GetHeight();
|
||
csNodeSpec.Format(_T("%.0fm^U3^U (L=%.1fB=%.1fH=%.1f)"), dVol, pEquip->GetLength(), pEquip->GetWidth(), pEquip->GetHeight());
|
||
}
|
||
else if(pEquip->GetShape() == 2){
|
||
dVol = PI * (pEquip->GetLength() / 2.0) * (pEquip->GetLength() / 2.0) * pEquip->GetHeight();
|
||
csDesName = _T("圆形卧式水箱");
|
||
csNodeSpec.Format(_T("%.1fm^U3^U (Φ=%.1f H=%.1f)"), dVol, pEquip->GetLength(), pEquip->GetHeight());
|
||
}
|
||
|
||
SAmountItem *pItem = new SAmountItem(iItem, _T(""), csDesName, csNodeSpec, _T("台"), 1, _T(""));
|
||
IsAppandItem(lstAll, pItem, dlg.m_iNum);
|
||
}
|
||
OPENOBJ_END();
|
||
continue;
|
||
}
|
||
else if(ent.Is(_T("ATS_PUMP"))){
|
||
OPENOBJ_BEGIN(ent, AcDb::kForRead, TDbPump, pEquip);
|
||
if(pEquip){
|
||
int iItem(0);
|
||
CString csBlkName, csDesName, csNodeSpeccsDemo, csDemo, csNodeSpec;
|
||
if(!GetEquipNameById(pEquip->objectId(), csBlkName, csDesName, iItem))
|
||
continue;
|
||
csNodeSpec = pEquip->GetSpare();
|
||
SAmountItem *pItem = new SAmountItem(iItem, csBlkName, csDesName, csNodeSpec, _T("台"), 1, csDemo);
|
||
IsAppandItem(lstAll, pItem, dlg.m_iNum);
|
||
}
|
||
OPENOBJ_END();
|
||
continue;
|
||
}
|
||
else if (ent.Is(_T("ATS_POOL")))// 材料统计支持化粪池 zxl 2012.08.14 add
|
||
{
|
||
OPENOBJ_BEGIN(ent, AcDb::kForRead, TDbPool, pEquip);
|
||
if(pEquip)
|
||
{
|
||
int iItem(0);
|
||
CString csBlkName, csDesName, csNodeSpeccsDemo, csDemo, csNodeSpec;
|
||
|
||
const int nScale = DocGetMeterUnitDraw() ? 1000 : 1;
|
||
int dWidth = pEquip->GetPoolWidth() * nScale;
|
||
int dLength = pEquip->GetPoolLength() * nScale;
|
||
csNodeSpec.Format(_T("%d*%d"), dLength, dWidth);
|
||
AcDbObjectId idRef = pEquip->GetBlock2d();
|
||
GetPoolNameById(idRef, csBlkName, csDesName);
|
||
|
||
SAmountItem *pItem = new SAmountItem(iItem, csBlkName, csDesName, csNodeSpec, _T("个"), 1, csDemo);
|
||
IsAppandItem(lstAll, pItem, dlg.m_iNum);
|
||
}
|
||
OPENOBJ_END();
|
||
continue;
|
||
}
|
||
|
||
OPENOBJ_BEGIN(ent, AcDb::kForRead, TDbPipe, pPipe);
|
||
if(pPipe){
|
||
DList<AcDbObjectId> lstAttachment;
|
||
nPipeLength = pPipe->Length();
|
||
// if(!DocGetMeterUnitDraw())
|
||
// nPipeLength = nPipeLength/1000;
|
||
|
||
AcDbObjectId nodeId1(NULL), nodeId2(NULL);
|
||
if(poly.Length() > 0){//按范围统计
|
||
// cet 2012.6.5 modify 比较前各参数z值设置为同一值
|
||
// if((pPipe->StartPoint()&poly) != PR_OUTSIDE)
|
||
// nodeId1 = pPipe->GetNode(0);
|
||
// if((pPipe->EndPoint()&poly) != PR_OUTSIDE)
|
||
// nodeId2 = pPipe->GetNode(1);
|
||
XPoint ptS = pPipe->StartPoint();
|
||
XPoint ptE = pPipe->EndPoint();
|
||
ptS.z = poly[0]->z;
|
||
ptE.z = poly[0]->z;
|
||
if((ptS & poly) != PR_OUTSIDE)
|
||
nodeId1 = pPipe->GetNode(0);
|
||
if((ptE & poly) != PR_OUTSIDE)
|
||
nodeId2 = pPipe->GetNode(1);
|
||
}
|
||
else{
|
||
nodeId1 = pPipe->GetNode(0);
|
||
nodeId2 = pPipe->GetNode(1);
|
||
}
|
||
CString csDnHead = pPipe->GetLabel();
|
||
iMaterial = pPipe->GetMaterial();
|
||
nPipeDn = pPipe->GetDnDiameter();
|
||
CString csMat = GetPipeMaterialByIdx(iMaterial);
|
||
CString csSpec;
|
||
// if(csDnHead == _T(""))
|
||
// csDnHead = GetDnByMat(csMat);;
|
||
if(nPipeDn < 0)
|
||
csSpec = _T("");
|
||
else
|
||
csSpec.Format(_T("%s%.0f"), csDnHead, nPipeDn);
|
||
|
||
AppandNode2List(lstNode, nodeId1, lstAll, pPipe, dlg.m_bSan, dlg.m_iNum);
|
||
AppandNode2List(lstNode, nodeId2, lstAll, pPipe, dlg.m_bSan, dlg.m_iNum);
|
||
|
||
// cet 2012.9.18 add
|
||
if (nodeId1.isValid())
|
||
{
|
||
ssCalc += nodeId1;
|
||
}
|
||
|
||
if (nodeId2.isValid())
|
||
{
|
||
ssCalc += nodeId2;
|
||
}
|
||
|
||
pPipe->GetAttachments(lstAttachment);
|
||
int leng = lstAttachment.Length();
|
||
for(int m=0;m<leng;m++){
|
||
AcDbObjectId idTmp = *lstAttachment[m];
|
||
if(IsAppandNode(lstNode, idTmp) && GetValveNameById(idTmp, csBlkName, csDesName)){
|
||
if(poly.Length() > 0){//按范围统计
|
||
OPENOBJ_BEGIN(idTmp, AcDb::kForRead, TDbPipeValve, pEquip);
|
||
if(pEquip){
|
||
XPoint ptEquipLoc = pEquip->GetLocation();
|
||
if((ptEquipLoc&poly) == PR_OUTSIDE)
|
||
continue;
|
||
}
|
||
OPENOBJ_END();
|
||
}
|
||
|
||
ssCalc += idTmp; // cet 2012.9.18 add
|
||
SAmountItem *pItem = new SAmountItem(1, csBlkName, csDesName, csSpec, _T("个"), 1, _T(""));
|
||
IsAppandItem(lstAll, pItem, dlg.m_iNum);
|
||
}
|
||
}
|
||
CString csPipeName = GetPipeSysNameBysLay(layer, csBlkName);
|
||
CString csSpec2;
|
||
csSpec2.Format(_T("%s %s"), csMat, csSpec);
|
||
// if(dlg.m_bPipeBySys) cet 2010.4.9 moidfy
|
||
if(dlg.m_bPipeBySys && !ent.Is(_T("ATS_DOUBLELINEPIPE")))
|
||
{
|
||
SAmountItem *pItem = new SAmountItem(0, csBlkName, csPipeName, csSpec2, _T("米"), nPipeLength, _T(""));
|
||
IsAppandItem(lstAll, pItem, dlg.m_iNum);
|
||
}
|
||
else
|
||
{
|
||
SAmountItem *pItem = new SAmountItem(0, _T("*"), csMat, csSpec, _T("米"), nPipeLength, _T(""));
|
||
IsAppandItem(lstAll, pItem, dlg.m_iNum);
|
||
}
|
||
}
|
||
OPENOBJ_END();
|
||
|
||
}
|
||
acedRestoreStatusBar();
|
||
if (!PrintOutAmount(dlg, lstAll))
|
||
{
|
||
return;
|
||
}
|
||
// cet 2012.9.18 add 将选择集保存到表的扩展字典中
|
||
Entity entSheet;
|
||
entSheet.GetLast();
|
||
AcDbObjectId idSheet;
|
||
acdbGetObjectId(idSheet, entSheet);
|
||
WriteXDataToEntity(idSheet, ssCalc);
|
||
}
|
||
|
||
|
||
/////////////////////////////////////////////////////////////////////////////
|
||
// CAmountSettingDlg dialog
|
||
const UINT nMenuId = 100; // cet 2011.12.9 add
|
||
int CAmountSettingDlg::m_iPrePipeLen = 0;
|
||
CString CAmountSettingDlg::m_csTitle = _T("材料表");
|
||
|
||
CAmountSettingDlg::CAmountSettingDlg(CWnd* pParent /*=NULL*/)
|
||
: CDialog(CAmountSettingDlg::IDD, pParent), m_spinText(0.1), m_spinTable(0.1)
|
||
{
|
||
//{{AFX_DATA_INIT(CAmountSettingDlg)
|
||
m_bFL = TRUE;
|
||
m_bHL = TRUE;
|
||
m_bJL = TRUE;
|
||
m_bRHL = TRUE;
|
||
m_bRJL = TRUE;
|
||
m_bWL = TRUE;
|
||
m_bXL = TRUE;
|
||
m_bYL = TRUE;
|
||
m_bZL = TRUE;
|
||
m_csTableHeight = _T("7.0");
|
||
m_csTextHeight = _T("5.0");
|
||
m_iStyle = 0;
|
||
m_bIsDown = FALSE;
|
||
m_bSan = FALSE;
|
||
m_iRange = 0;
|
||
m_iNum = 1;
|
||
m_bLvtry = TRUE;
|
||
m_bDrink = TRUE;
|
||
m_bOther = TRUE;
|
||
m_bPressDirt = TRUE;
|
||
m_bPressRain = TRUE;
|
||
m_bPressUseless = TRUE;
|
||
m_bCoagulate = TRUE;
|
||
m_bPipeBySys = FALSE;
|
||
m_bCivismWater = TRUE;
|
||
m_bCycleWater = TRUE;
|
||
m_bHole = TRUE;
|
||
//}}AFX_DATA_INIT
|
||
m_pMenu = NULL; // cet 2011.12.9 add
|
||
}
|
||
|
||
|
||
void CAmountSettingDlg::DoDataExchange(CDataExchange* pDX)
|
||
{
|
||
CDialog::DoDataExchange(pDX);
|
||
//{{AFX_DATA_MAP(CAmountSettingDlg)
|
||
DDX_Control(pDX, IDC_LIST_RANGE, m_listCtrl);
|
||
DDX_Control(pDX, IDC_COMBO_TEXTSTYLE, m_comboStyle);
|
||
DDX_Control(pDX, IDC_SPIN_TABLE, m_spinTable);
|
||
DDX_Control(pDX, IDC_SPIN_TEXT, m_spinText);
|
||
DDX_Check(pDX, IDC_CHECK_FL, m_bFL);
|
||
DDX_Check(pDX, IDC_CHECK_HL, m_bHL);
|
||
DDX_Check(pDX, IDC_CHECK_JL, m_bJL);
|
||
DDX_Check(pDX, IDC_CHECK_RHL, m_bRHL);
|
||
DDX_Check(pDX, IDC_CHECK_RJL, m_bRJL);
|
||
DDX_Check(pDX, IDC_CHECK_WL, m_bWL);
|
||
DDX_Check(pDX, IDC_CHECK_XL, m_bXL);
|
||
DDX_Check(pDX, IDC_CHECK_YL, m_bYL);
|
||
DDX_Check(pDX, IDC_CHECK_ZL, m_bZL);
|
||
DDX_Text(pDX, IDC_EDIT_TABLE_HEIGHT, m_csTableHeight);
|
||
DDX_Text(pDX, IDC_EDIT_TEXT_HEIGHT, m_csTextHeight);
|
||
DDX_CBIndex(pDX, IDC_COMBO_TEXTSTYLE, m_iStyle);
|
||
DDX_Check(pDX, IDC_CHECK_DOWN, m_bIsDown);
|
||
DDX_Check(pDX, IDC_CHECK_SANITARY, m_bSan);
|
||
DDX_Radio(pDX, IDC_RADIO_RANGE1, m_iRange);
|
||
DDX_Text(pDX, IDC_EDIT_NUM, m_iNum);
|
||
DDX_Check(pDX, IDC_CHECK_LVTRY, m_bLvtry);
|
||
DDX_Check(pDX, IDC_CHECK_DRINK, m_bDrink);
|
||
DDX_Check(pDX, IDC_CHECK_OTHER, m_bOther);
|
||
DDX_Check(pDX, IDC_CHECK_PRESSDIRT, m_bPressDirt);
|
||
DDX_Check(pDX, IDC_CHECK_PRESSRAIN, m_bPressRain);
|
||
DDX_Check(pDX, IDC_CHECK_PRESSUSELESS, m_bPressUseless);
|
||
DDX_Check(pDX, IDC_CHECK_COAGULATE, m_bCoagulate);
|
||
DDX_Check(pDX, IDC_CHECK_PIPE, m_bPipeBySys);
|
||
DDX_Check(pDX, IDC_CHK_CIVICISMWATER, m_bCivismWater);
|
||
DDX_Check(pDX, IDC_CHK_CYCLEWATER, m_bCycleWater);
|
||
DDX_CBIndex(pDX, IDC_COMBO_PIPELEN_PRE, m_iPrePipeLen);
|
||
DDX_Text(pDX, IDC_EDIT_TITLE, m_csTitle);
|
||
DDX_Check(pDX, IDC_CHECK_HOLE, m_bHole);
|
||
//}}AFX_DATA_MAP
|
||
}
|
||
|
||
|
||
BEGIN_MESSAGE_MAP(CAmountSettingDlg, CDialog)
|
||
//{{AFX_MSG_MAP(CAmountSettingDlg)
|
||
ON_BN_CLICKED(IDC_RADIO_RANGE1, OnRadioRange1)
|
||
ON_BN_CLICKED(IDC_RADIO_RANGE2, OnRadioRange2)
|
||
ON_BN_CLICKED(IDC_BUTTON_ADD, OnButtonAdd)
|
||
ON_BN_CLICKED(IDC_BUTTON_DEL, OnButtonDel)
|
||
ON_BN_CLICKED(IDC_BUTTON_SELALL, OnButtonSelall)
|
||
ON_BN_CLICKED(IDC_BUTTON_SELNULL, OnButtonSelnull)
|
||
ON_BN_CLICKED(IDC_BUTTON_SET, OnButtonSet)
|
||
ON_BN_CLICKED(IDC_BUTTON_OTHER, OnButtonOther)
|
||
//}}AFX_MSG_MAP
|
||
END_MESSAGE_MAP()
|
||
|
||
/////////////////////////////////////////////////////////////////////////////
|
||
// CAmountSettingDlg message handlers
|
||
|
||
BOOL CAmountSettingDlg::OnInitDialog()
|
||
{
|
||
CDialog::OnInitDialog();
|
||
m_spinText.SetRange(1, 20);
|
||
m_spinTable.SetRange(1, 20);
|
||
InitTwtTextStyle(g_csSheetStyle);
|
||
XSymbolList lstStyle(_T("STYLE"));
|
||
for (int m =0; m < lstStyle.Length(); m++) {
|
||
m_comboStyle.AddString(lstStyle[m]);
|
||
if(_tcsicmp(g_csSheetStyle, lstStyle[m]) == 0){
|
||
m_iStyle = m;
|
||
}
|
||
}
|
||
m_listCtrl.SetExtendedStyle(LVS_EX_GRIDLINES | LVS_EX_FULLROWSELECT);
|
||
m_listCtrl.InsertColumn ( 0, _T("楼层数"), LVCFMT_LEFT, 50 );
|
||
m_listCtrl.InsertColumn ( 1, _T("文件名"), LVCFMT_LEFT, 160 );
|
||
UpdateData(FALSE);
|
||
Reset();
|
||
InitLayerPipeName();//cet 2011.12.9 add
|
||
InitCheckBoxName(); //cet 2009.12.23 add
|
||
InitMenuData(); //cet 2011.12.9 add
|
||
return TRUE; // return TRUE unless you set the focus to a control
|
||
// EXCEPTION: OCX Property Pages should return FALSE
|
||
}
|
||
|
||
void CAmountSettingDlg::OnOK()
|
||
{
|
||
if(m_iStyle>-1)
|
||
m_comboStyle.GetLBText(m_iStyle, m_csTextStyle);
|
||
for(int i=0;i<m_listCtrl.GetItemCount();i++){
|
||
CString csFile = m_listCtrl.GetItemText(i, 1);
|
||
m_lstFile.Append(tstrnew(csFile));
|
||
CString csNum = m_listCtrl.GetItemText(i, 0);
|
||
m_lstFloor.Append(new int(_ttoi(csNum)));
|
||
}
|
||
CDialog::OnOK();
|
||
}
|
||
|
||
void CAmountSettingDlg::Reset()
|
||
{
|
||
UpdateData(TRUE);
|
||
CWnd *pWnd1 = GetDlgItem(IDC_LIST_RANGE);
|
||
CWnd *pWnd2 = GetDlgItem(IDC_BUTTON_ADD);
|
||
CWnd *pWnd3 = GetDlgItem(IDC_BUTTON_DEL);
|
||
// CWnd *pWnd4 = GetDlgItem(IDC_EDIT_NUM);
|
||
if(m_iRange == 0){
|
||
pWnd1->EnableWindow(FALSE);
|
||
pWnd2->EnableWindow(FALSE);
|
||
pWnd3->EnableWindow(FALSE);
|
||
// pWnd4->EnableWindow(FALSE);
|
||
}
|
||
else{
|
||
pWnd1->EnableWindow(TRUE);
|
||
pWnd2->EnableWindow(TRUE);
|
||
pWnd3->EnableWindow(TRUE);
|
||
// pWnd4->EnableWindow(TRUE);
|
||
}
|
||
}
|
||
|
||
void CAmountSettingDlg::OnRadioRange1()
|
||
{
|
||
Reset();
|
||
}
|
||
|
||
void CAmountSettingDlg::OnRadioRange2()
|
||
{
|
||
Reset();
|
||
}
|
||
|
||
void CAmountSettingDlg::OnButtonAdd()
|
||
{
|
||
CString csFileName;
|
||
CTemporaryResourceOverride vTemp;
|
||
CFileDialog dlg(TRUE,_T("*.dwg"),csFileName,OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,
|
||
_T("Drawing(*.dwg) |*.dwg||"), this);
|
||
TCHAR strDlgTitle[] = _T("选择要统计的DWG文件");
|
||
dlg.m_ofn.lpstrTitle = strDlgTitle;
|
||
if(dlg.DoModal()!=IDOK)
|
||
return;
|
||
UpdateData(TRUE);
|
||
int n = m_listCtrl.GetItemCount();
|
||
CString csNum;
|
||
csNum.Format(_T("%d"), m_iNum);
|
||
m_listCtrl.InsertItem ( n, csNum, 0 );
|
||
m_listCtrl.SetItemText ( n, 1, dlg.GetPathName());
|
||
|
||
}
|
||
|
||
void CAmountSettingDlg::OnButtonDel()
|
||
{
|
||
UpdateData(TRUE);
|
||
POSITION pos = m_listCtrl.GetFirstSelectedItemPosition();
|
||
if(!pos)
|
||
return;
|
||
int nItem = m_listCtrl.GetNextSelectedItem(pos);
|
||
m_listCtrl.DeleteItem(nItem);
|
||
|
||
}
|
||
|
||
void CAmountSettingDlg::OnButtonSelall()
|
||
{
|
||
UpdateData(TRUE);
|
||
m_bFL = TRUE;
|
||
m_bHL = TRUE;
|
||
m_bJL = TRUE;
|
||
m_bRHL = TRUE;
|
||
m_bRJL = TRUE;
|
||
m_bWL = TRUE;
|
||
m_bXL = TRUE;
|
||
m_bYL = TRUE;
|
||
m_bZL = TRUE;
|
||
m_bLvtry = TRUE;
|
||
m_bDrink = TRUE;
|
||
m_bOther = TRUE;
|
||
m_bPressDirt = TRUE;
|
||
m_bPressRain = TRUE;
|
||
m_bPressUseless = TRUE;
|
||
m_bCoagulate = TRUE;
|
||
m_bSan = TRUE;
|
||
m_bCivismWater = TRUE; //cet 2009.12.29 add
|
||
m_bCycleWater = TRUE; //cet 2009.12.29 add
|
||
m_bHole = TRUE; //zxl 2013.07.11 add
|
||
// cet 2011.12.9 add
|
||
std::map<UINT,bool>::iterator it;
|
||
for (it = m_mapCheck.begin(); it != m_mapCheck.end(); it++)
|
||
{
|
||
it->second = true;
|
||
}
|
||
UpdateData(FALSE);
|
||
}
|
||
|
||
void CAmountSettingDlg::OnButtonSelnull()
|
||
{
|
||
UpdateData(TRUE);
|
||
m_bFL = FALSE;
|
||
m_bHL = FALSE;
|
||
m_bJL = FALSE;
|
||
m_bRHL = FALSE;
|
||
m_bRJL = FALSE;
|
||
m_bWL = FALSE;
|
||
m_bXL = FALSE;
|
||
m_bYL = FALSE;
|
||
m_bZL = FALSE;
|
||
m_bLvtry = FALSE;
|
||
m_bDrink = FALSE;
|
||
m_bOther = FALSE;
|
||
m_bPressDirt = FALSE;
|
||
m_bPressRain = FALSE;
|
||
m_bPressUseless = FALSE;
|
||
m_bCoagulate = FALSE;
|
||
m_bSan = FALSE;
|
||
m_bCivismWater = FALSE; //cet 2009.12.29 add
|
||
m_bCycleWater = FALSE; //cet 2009.12.29 add
|
||
m_bHole = FALSE; // zxl 2013.07.11 add
|
||
// cet 2011.12.9 add
|
||
std::map<UINT,bool>::iterator it;
|
||
for (it = m_mapCheck.begin(); it != m_mapCheck.end(); it++)
|
||
{
|
||
it->second = false;
|
||
}
|
||
UpdateData(FALSE);
|
||
|
||
}
|
||
|
||
void CAmountSettingDlg::OnButtonSet()
|
||
{
|
||
CTemporaryResourceOverride vTemp;
|
||
CAmountSettingHeadDlg dlg;
|
||
if(dlg.DoModal() != IDOK)
|
||
return;
|
||
}
|
||
|
||
//cet 2009.12.23 add
|
||
//初始化复选框
|
||
void CAmountSettingDlg::InitCheckBoxName()
|
||
{
|
||
CWnd *pWnd = GetDlgItem(IDC_CHECK_COAGULATE);
|
||
if (pWnd != NULL)
|
||
{
|
||
//cet 2011.12.9 modify
|
||
//pWnd->SetWindowText(g_csPipeName[0]);
|
||
pWnd->SetWindowText(m_mapLayerPipeName[LAY_PIPE_COAGULATE]);
|
||
CString sTemp;\
|
||
sTemp = m_mapLayerPipeName[LAY_PIPE_COAGULATE];
|
||
}
|
||
|
||
pWnd = GetDlgItem(IDC_CHECK_DRINK);
|
||
if (pWnd != NULL)
|
||
{
|
||
//cet 2011.12.9 modify
|
||
//pWnd->SetWindowText(g_csPipeName[1]);
|
||
pWnd->SetWindowText(m_mapLayerPipeName[LAY_PIPE_DRINK]);
|
||
}
|
||
pWnd = GetDlgItem(IDC_CHECK_PRESSDIRT);
|
||
if (pWnd != NULL)
|
||
{
|
||
//cet 2011.12.9 modify
|
||
//pWnd->SetWindowText(g_csPipeName[2]);
|
||
pWnd->SetWindowText(m_mapLayerPipeName[LAY_PIPE_PRESSDIRT]);
|
||
}
|
||
pWnd = GetDlgItem(IDC_CHECK_PRESSUSELESS);
|
||
if (pWnd != NULL)
|
||
{
|
||
//cet 2011.12.9 modify
|
||
//pWnd->SetWindowText(g_csPipeName[3]);
|
||
pWnd->SetWindowText(m_mapLayerPipeName[LAY_PIPE_PRESSUSELESS]);
|
||
}
|
||
pWnd = GetDlgItem(IDC_CHECK_PRESSRAIN);
|
||
if (pWnd != NULL)
|
||
{
|
||
//cet 2011.12.9 modify
|
||
//pWnd->SetWindowText(g_csPipeName[4]);
|
||
pWnd->SetWindowText(m_mapLayerPipeName[LAY_PIPE_PRESSRAIN]);
|
||
}
|
||
pWnd = GetDlgItem(IDC_CHK_CIVICISMWATER);
|
||
if (pWnd != NULL)
|
||
{
|
||
//cet 2011.12.9 modify
|
||
//pWnd->SetWindowText(g_csPipeName[5]);
|
||
pWnd->SetWindowText(m_mapLayerPipeName[LAY_PIPE_USER1]);
|
||
}
|
||
pWnd = GetDlgItem(IDC_CHK_CYCLEWATER);
|
||
if (pWnd != NULL)
|
||
{
|
||
//cet 2011.12.9 modify
|
||
//pWnd->SetWindowText(g_csPipeName[6]);
|
||
pWnd->SetWindowText(m_mapLayerPipeName[LAY_PIPE_USER2]);
|
||
}
|
||
}
|
||
|
||
void CAmountSettingDlg::OnButtonOther()
|
||
{
|
||
CWnd *pWnd = GetDlgItem(IDC_BUTTON_OTHER);
|
||
if (pWnd == NULL)
|
||
{
|
||
return;
|
||
}
|
||
|
||
CRect rc;
|
||
pWnd->GetWindowRect(rc);
|
||
if(m_pMenu == NULL)
|
||
{
|
||
m_pMenu = new CMenu;
|
||
m_pMenu->CreatePopupMenu();
|
||
}
|
||
else
|
||
{
|
||
m_pMenu->DestroyMenu();
|
||
m_pMenu->CreatePopupMenu();
|
||
}
|
||
|
||
std::map<UINT,CString>::iterator it;
|
||
for (it = m_mapName.begin(); it != m_mapName.end(); it++)
|
||
{
|
||
m_pMenu->AppendMenu(m_mapCheck[it->first] ? MF_CHECKED : MF_UNCHECKED, it->first, it->second);
|
||
}
|
||
m_pMenu->TrackPopupMenu( TPM_LEFTALIGN | TPM_LEFTBUTTON | TPM_VERTICAL,
|
||
rc.left, rc.bottom, this, &rc);
|
||
}
|
||
|
||
BOOL CAmountSettingDlg::OnCommand(WPARAM wParam, LPARAM lParam)
|
||
{
|
||
if (m_mapCheck.empty())
|
||
{
|
||
return CDialog::OnCommand(wParam, lParam);
|
||
}
|
||
|
||
UINT nID = LOWORD(wParam);
|
||
UINT nMinID = m_mapCheck.begin()->first;
|
||
UINT nMaxID = m_mapCheck.rbegin()->first;
|
||
if (nMenuId > nID || nMaxID < nID)
|
||
{
|
||
return CDialog::OnCommand(wParam, lParam);
|
||
}
|
||
|
||
m_mapCheck[nID] = !m_mapCheck[nID];
|
||
return CDialog::OnCommand(wParam, lParam);
|
||
}
|
||
|
||
void CAmountSettingDlg::InitMenuData()
|
||
{
|
||
CString sTemp;
|
||
m_mapName.insert(std::make_pair(nMenuId + 1, m_mapLayerPipeName[LAY_PIPE_USER3]));
|
||
m_mapCheck.insert(std::make_pair(nMenuId + 1, true));
|
||
m_mapName.insert(std::make_pair(nMenuId + 2, m_mapLayerPipeName[LAY_PIPE_USER4]));
|
||
m_mapCheck.insert(std::make_pair(nMenuId + 2, true));
|
||
m_mapName.insert(std::make_pair(nMenuId + 3, m_mapLayerPipeName[LAY_PIPE_USER5]));
|
||
m_mapCheck.insert(std::make_pair(nMenuId + 3, true));
|
||
m_mapName.insert(std::make_pair(nMenuId + 4, m_mapLayerPipeName[LAY_PIPE_USER6]));
|
||
m_mapCheck.insert(std::make_pair(nMenuId + 4, true));
|
||
m_mapName.insert(std::make_pair(nMenuId + 5, m_mapLayerPipeName[LAY_PIPE_USER7]));
|
||
m_mapCheck.insert(std::make_pair(nMenuId + 5, true));
|
||
m_mapName.insert(std::make_pair(nMenuId + 6, m_mapLayerPipeName[LAY_PIPE_USER8]));
|
||
m_mapCheck.insert(std::make_pair(nMenuId + 6, true));
|
||
}
|
||
|
||
bool CAmountSettingDlg::IsSelectedMenuItem(int nIndex)
|
||
{
|
||
if (nIndex < 0 || nIndex >= m_mapCheck.size())
|
||
{
|
||
return false;
|
||
}
|
||
return m_mapCheck[nMenuId + nIndex + 1];
|
||
}
|
||
|
||
void CAmountSettingDlg::InitLayerPipeName()
|
||
{
|
||
GetLayerPipeName(m_mapLayerPipeName);
|
||
}
|