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

1171 lines
34 KiB
C++

// OpeningValidateDlg.cpp : implementation file
//
#include "stdafx.h"
#include "resource.h"
#include "OpeningValidateDlg.h"
#include "OpeningValidation.h"
#include "aectip.h"
#include "rxregsvc.h"// [12/26/2007 nsh]
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
static CObjectTipWnd * g_pOpeningTipWnd=NULL;
static Entity g_entCurOpening;
// 观察对象
extern void EditObject(Entity ent);// [12/26/2007 nsh]
extern void GetOpeningIdList(DList<AcDbDatabase> &dbList, DList<AcDbObjectId> &idList) ;// [3/14/2008 nsh]
int GetObjectNumInCurDwg(const AcDbObjectIdArray &idArray)
{
int nCount=0;
int nLen=idArray.length();
for(int i=0; i<nLen; i++) {
AcDbObjectId id=idArray[i];
if (id.isValid()&&id.database()==acdbCurDwg())
nCount++;
}
return nCount;
}
int GetObjectIdInCurDwg(const AcDbObjectIdArray &idArray, AcDbObjectIdArray &idArrayCurDwg)
{
int nCount=0;
int nLen=idArray.length();
for(int i=0; i<nLen; i++) {
AcDbObjectId id=idArray[i];
if (id.isValid()&& //add by xlc on 090519
id.database()==acdbCurDwg())
{
nCount++;
idArrayCurDwg.append(id);
}
}
return nCount;
}
// 不知何原因,鼠标不能移到门窗范围内
BOOL ViewOpeningMsg(MSG* msg)
{
/*
if (g_pOpeningTipWnd) {
if (g_pOpeningTipWnd->m_hWnd!=msg->hwnd && !IsAcadDwgView(msg->hwnd))
return FALSE;
} else {
if (!IsAcadDwgView(msg->hwnd))
return FALSE;
}*/
BOOL nRet=FALSE;
static CPoint ptLast;
switch(msg->message) {
case WM_MOUSEMOVE: {
CPoint ptDwgView = msg->pt;
CPoint ptScr=ptDwgView;
//if (ptScr.x-ptLast.x<=2 && ptScr.y-ptLast.y<=2)
// return FALSE;
ptLast=ptScr;
acedGetAcadDwgView()->ScreenToClient(&ptDwgView);
//int nVpNum=acedGetWinNum(ptDwgView.x, ptDwgView.y);
int cvport=0;
VERIFY(xg_getvar(_T("CVPORT"), &cvport)==RTNORM);
//if (nVpNum==cvport) {
XPoint ptWcs;
acedCoordFromPixelToWorld(cvport, ptDwgView, ptWcs);
Entity ent=g_entCurOpening;
XPoint ptLow, ptUp;
VERIFY(ent.GetExtend(ptLow, ptUp)==RTNORM);
XRectAngle rec(ptLow, ptUp);
XPoly2D poly2d, polyOffset;
rec.AsPoly2D(poly2d);
poly2d.Offset((ptUp.x-ptLow.x)/10.0, polyOffset);
ptWcs.z=0;
polyOffset.SetElevation(0.0);
if ((ptWcs&polyOffset)==PR_INSIDE) {
nRet=TRUE;
/*
if (g_pOpeningTipWnd) {
CRect rect;
g_pOpeningTipWnd->GetWindowRect(rect);
if ((ptLast.x-ptScr.x)>4 || (ptLast.y-ptScr.y)>4) {
int nx=rect.left + ptScr.x - ptLast.x;
int ny=rect.top + ptScr.y - ptLast.y;
g_pOpeningTipWnd->MoveWindow(nx,
ny, rect.Width(), rect.Height(), TRUE);
ptLast=ptScr;
}
} else {*/
//if ((ptLast.x-ptScr.x)>4 || (ptLast.y-ptScr.y)>4 ||) {
//显示门窗信息
DList<TObjInfoUnit> lstInfo;
OPENOBJ_BEGIN(ent, AcDb::kForRead, TDbOpening, pEnt);
ASSERT(pEnt);
pEnt->GetTips(lstInfo);
lstInfo.Append(new TObjInfoUnit(_T("比例"), XString(_T("%.f"), pEnt->GetPScale())));
AcRxClass *pRxClass=pEnt->isA();
lstInfo.Append(new TObjInfoUnit(_T("DXF类型"), pRxClass->dxfName()));
TCHAR *pszLayer=pEnt->layer();
if (pszLayer) {
lstInfo.Append(new TObjInfoUnit(_T("图层"), pszLayer));
delete [] pszLayer;
}
OPENOBJ_END();
//if (!nRet) {
if (g_pOpeningTipWnd) {
g_pOpeningTipWnd->DestroyWindow();
delete g_pOpeningTipWnd;
g_pOpeningTipWnd=NULL;
}
//}
ptLast=ptScr;
g_pOpeningTipWnd = new CObjectTipWnd();
g_pOpeningTipWnd->Create(lstInfo, ptDwgView.x,ptDwgView.y);
//}
}
//}
}
break;
default:
break;
}
if (!nRet) {
if (g_pOpeningTipWnd) {
g_pOpeningTipWnd->DestroyWindow();
delete g_pOpeningTipWnd;
g_pOpeningTipWnd=NULL;
}
}
return FALSE;
}
// modify by xlc on 090902 消除tg5lib影响
// #if ADS<18
#if 0
/////////////////////////////////////////////////////////////////////////////
// COpeningValidateDlg dialog
COpeningValidateDlg::COpeningValidateDlg(TOpeningValidateTable *pSheet, CWnd* pParent /*=NULL*/)
: CAcUiDialog(COpeningValidateDlg::IDD, pParent)
{
m_pSheet=pSheet;
m_bReadEnable=FALSE;
m_nWorkMode=0;
m_bInit=FALSE;
m_nOldSizeY=260;
m_nOldSizeX=558;
//{{AFX_DATA_INIT(COpeningValidateDlg)
//}}AFX_DATA_INIT
}
void COpeningValidateDlg::ShowSlide(UINT id, CImageDC& imgdc, const TCHAR* sldName)
{
CWnd *pWnd=GetDlgItem(id);
if (pWnd) {
CRect cR;
CDC* pDC = pWnd->GetDC();
pWnd->GetClientRect(&cR);
imgdc.InitDC(pDC,cR, GetAcadBackColor());
if (!sldName || !sldName[0]) {
imgdc.PaintSlide(_T(""));
} else {
XString sFullPath(256);
sFullPath << g_sDwbPath << sldName;
imgdc.PaintSlide(sFullPath);
}
pWnd->ReleaseDC(pDC);
}
}
void COpeningValidateDlg::ShowSlide()
{
COleVariant curRow=m_grid.GetBookmark();
if (V_VT(&curRow)!=VT_I4)
return;
int nCurRow=V_I4(&curRow);
TOpeningValidation *pRow=(*m_pSheet)[nCurRow];
if (!(pRow->m_nFlag&OVF_STYLE2D))
ShowSlide(IDC_STYLE2D, m_slide2d, pRow->m_sStyle2d);
else
ShowSlide(IDC_STYLE2D, m_slide2d, _T(""));
if (!(pRow->m_nFlag&OVF_STYLE3D))
ShowSlide(IDC_STYLE3D, m_slide3d, pRow->m_sStyle3d);
else
ShowSlide(IDC_STYLE3D, m_slide3d, _T(""));
}
BOOL COpeningValidateDlg::IsBOF() const
{
return m_nCurIndex<=-1;
}
BOOL COpeningValidateDlg::IsEOF() const
{
ASSERT(m_pSheet);
return m_nCurIndex>=m_pSheet->Length();
}
//////////////////////////////////////
// 移到指定的行
BOOL COpeningValidateDlg::MoveTo(long bookmark)
{
ASSERT(m_pSheet);
m_nCurIndex=bookmark;
if (IsEOF()) m_nCurIndex=m_pSheet->Length();
else if (IsBOF()) m_nCurIndex=-1;
return TRUE;
}
////////////////////////////////////////
// 相对移动
void COpeningValidateDlg::Move(long offset)
{
m_nCurIndex += offset;
if (IsEOF()) m_nCurIndex=m_pSheet->Length();
else if (IsBOF()) m_nCurIndex=-1;
}
void COpeningValidateDlg::DoDataExchange(CDataExchange* pDX)
{
CAcUiDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(COpeningValidateDlg)
DDX_Control(pDX, IDC_GRID, m_grid);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(COpeningValidateDlg, CAcUiDialog)
//{{AFX_MSG_MAP(COpeningValidateDlg)
ON_WM_PAINT()
ON_BN_CLICKED(IDC_VIEWOBJ, OnViewobj)
ON_WM_SIZE()
ON_WM_CREATE()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// COpeningValidateDlg message handlers
BOOL COpeningValidateDlg::OnInitDialog()
{
CAcUiDialog::OnInitDialog();
CRect rectDlg;
GetClientRect(rectDlg);
sizeDlg.cx = rectDlg.Width();
sizeDlg.cy = rectDlg.Height();
long nIncY = sizeDlg.cy - m_nOldSizeY; // 对话框绝对尺寸
long nIncX = sizeDlg.cx - m_nOldSizeX;
m_bInit = TRUE;
ResetSize(nIncX, nIncY);
if (m_pSheet)
ConfigGrid();
if (m_nWorkMode)
GetDlgItem(IDC_VIEWOBJ)->ShowWindow(SW_HIDE);
else
GetDlgItem(IDCANCEL)->ShowWindow(SW_HIDE);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void COpeningValidateDlg::OnPaint()
{
CDC* pDC;
CRect cR,cR1;
CPaintDC dc(this); // device context for painting
// TODO: Add your message handler code here
CWnd *pWnd2d=GetDlgItem(IDC_STYLE2D);
CWnd *pWnd3d=GetDlgItem(IDC_STYLE3D);
pDC = pWnd3d->GetDC();
pWnd3d->GetClientRect(&cR);
m_slide3d.InitDC(pDC, cR,GetAcadBackColor());
m_slide3d.Redraw();
pWnd3d->ReleaseDC(pDC);
pDC = pWnd2d->GetDC();
pWnd2d->GetClientRect(&cR1);
m_slide2d.InitDC(pDC,cR1,GetAcadBackColor());
m_slide2d.Redraw();
pWnd2d->ReleaseDC(pDC);
}
//布置Grid的界面
void COpeningValidateDlg::ConfigGrid()
{
if (!m_pSheet) return;
m_bReadEnable = FALSE; //禁止Grid从数据源读取数据, 锁定
m_grid.SuppressTransforms(TRUE);
m_grid.SetApproxCount(m_pSheet->Length());
if (!m_pSheet->Length()) {
COleVariant var;
V_VT(&var) = VT_NULL;
m_grid.SetBookmark(var);
} else {
m_grid.SetBookmark(COleVariant(0L));
}
m_bReadEnable = TRUE; //解开Grid从数据源读取数据的锁定
m_grid.ReBind();
ShowSlide();
}
BEGIN_EVENTSINK_MAP(COpeningValidateDlg, CAcUiDialog)
//{{AFX_EVENTSINK_MAP(COpeningValidateDlg)
ON_EVENT(COpeningValidateDlg, IDC_GRID, 41 /* UnboundReadDataEx */, OnUnboundReadDataExGrid, VTS_DISPATCH VTS_PVARIANT VTS_I4 VTS_PI4)
ON_EVENT(COpeningValidateDlg, IDC_GRID, -603 /* KeyPress */, OnKeyPressgrid, VTS_PI2)
ON_EVENT(COpeningValidateDlg, IDC_GRID, 11 /* RowColChange */, OnRowColChangeGrid, VTS_PVARIANT VTS_I2)
//}}AFX_EVENTSINK_MAP
END_EVENTSINK_MAP()
// 读取数据, 为了便于在读数时加锁
void COpeningValidateDlg::ReadData(CTrueDBGrid50_RowBuffer &RowBuffer, VARIANT FAR* StartLocation, long offset, long FAR* ApproximatePosition)
{
if (!m_pSheet || !m_pSheet->Length() || !m_bReadEnable) {
RowBuffer.SetRowCount(0);
return;
}
long RowsFetched = 0;
// If StartLocation is a Null VARIANT, it means we are positioning
// relative to BOF (if offset > 0) or EOF (if offset < 0)
if (V_VT(StartLocation) == VT_NULL) {
if (offset > 0) {
m_nCurIndex=-1L;
} else { // Position to EOF
m_nCurIndex=m_pSheet->Length();
}
} else {
// StartLocation refers to a valid bookmark, so just go there.
ASSERT(V_VT(StartLocation)==VT_I4);
long nPos=V_I4(StartLocation);
if (!MoveTo(nPos)) {
V_VT(StartLocation)=VT_NULL;
}
}
Move(offset);
if (!IsBOF() && !IsEOF()) {
*ApproximatePosition = m_nCurIndex;
}
long lRowCount = RowBuffer.GetRowCount();
short sColCount = RowBuffer.GetColumnCount();
for(long row = 0; row < lRowCount; row++) {
if (IsBOF() || IsEOF()) {
RowBuffer.SetRowCount(RowsFetched);
return;
}
TOpeningValidation *pRow= (*m_pSheet)[m_nCurIndex];
for(short col = 0; col < sColCount; col++) {
short sColIndex = RowBuffer.GetColumnIndex(row, col);
//TGridCell *pCell=(*m_pSheet)(int(m_nCurIndex), int(sColIndex));
CString csText;
switch(sColIndex) {
case 0: //编号
csText=(const TCHAR *)pRow->m_sLabel;
break;
case 1:
csText.Format(_T("%d"), (int)pRow->m_idArray.length());
break;
case 2:
csText.Format(_T("%d"), (int)GetObjectNumInCurDwg(pRow->m_idArray));
break;
case 3:
if (pRow->m_nFlag&OVF_KIND)
csText=_T("<冲突>");
else
csText=(const TCHAR *)pRow->m_sKind;
break;
case 4:
if (pRow->m_nFlag&OVF_WIDTH)
csText=_T("<冲突>");
else
csText.Format(_T("%d"), AS_INT(pRow->m_nWidth));
break;
case 5:
if (pRow->m_nFlag&OVF_HEIGHT)
csText=_T("<冲突>");
else
csText.Format(_T("%d"), AS_INT(pRow->m_nHeight));
break;
case 6:
if (pRow->m_nFlag&OVF_STYLE2D)
csText=_T("<冲突>");
else
csText=(const TCHAR *)pRow->m_sStyle2d;
break;
case 7:
if (pRow->m_nFlag&OVF_STYLE3D)
csText=_T("<冲突>");
else
csText=(const TCHAR *)pRow->m_sStyle3d;
break;
}
COleVariant vValue=csText;
RowBuffer.SetValue(row, col, vValue);
}
long nPos=m_nCurIndex;
RowBuffer.SetBookmark(row, COleVariant(nPos));
RowsFetched++;
MoveNext();
}
RowBuffer.SetRowCount(RowsFetched);
}
void COpeningValidateDlg::OnUnboundReadDataExGrid(LPDISPATCH RowBuf, VARIANT FAR* StartLocation, long offset, long FAR* ApproximatePosition)
{
CTrueDBGrid50_RowBuffer RowBuffer(RowBuf);
static BOOL bLocked = FALSE; //进行锁定,即下一次的读数消息必须在本次消息结束之后方可以处理
if (bLocked) {
#if !defined(NDEBUG)
adsout << _T("\nGrid违背了锁定规则!");
#endif
return;
}
bLocked=TRUE;
ReadData(RowBuffer, StartLocation, offset, ApproximatePosition);
bLocked=FALSE;
}
void COpeningValidateDlg::OnKeyPressgrid(short FAR* KeyAscii)
{
if (*KeyAscii == VK_RETURN) {
//m_grid.Update();
}
}
BOOL COpeningValidateDlg::PreTranslateMessage(MSG* pMsg)
{
if (m_grid.IsSpecialKey(pMsg))
return TRUE;
return CAcUiDialog::PreTranslateMessage(pMsg);
}
///////////////////////////////////////////////////////////////////////////
// 当前行发生改变时,显示当前幻灯
void COpeningValidateDlg::OnRowColChangeGrid(VARIANT FAR* LastRow, short LastCol)
{
COleVariant curRow=m_grid.GetBookmark();
if (V_VT(&curRow)!=VT_I4)
return;
int nCurRow=V_I4(&curRow);
int nLastRow=V_I4(LastRow);
if (nCurRow!=nLastRow) {
ShowSlide();
}
}
void COpeningValidateDlg::OnViewobj()
{
COleVariant curRow=m_grid.GetBookmark();
if (V_VT(&curRow)!=VT_I4)
return;
int nCurRow=V_I4(&curRow);
TOpeningValidation *pRow=(*m_pSheet)[nCurRow];
AcDbObjectIdArray idArrayCurDwg;
int nObjNum=GetObjectIdInCurDwg(pRow->m_idArray, idArrayCurDwg);
if (nObjNum<=0)
return;
int nCurIndex=0;
BeginEditorCommand();
while(1) {
AcDbObjectId idObj=idArrayCurDwg[nCurIndex];
if (idObj.database()!=acdbCurDwg()) {
nCurIndex++;
continue;
}
adsout << _T("\n观察第") << (nCurIndex+1) << _T("/") << nObjNum << _T("个编号为'") << pRow->m_sLabel << _T("'的门窗 [编辑属性(E)/列表查询(L)/返回(X)]<下一个>:");
Entity ent;
VERIFY(acdbGetAdsName(ent.name, idObj)==Acad::eOk);
XPoint ptLow, ptUp;
VERIFY(ent.GetExtend(ptLow, ptUp)==RTNORM);
AssureInCurrentView(ptLow, ptUp);
XScreenDc dc(1, 1);
XRectAngle rec(ptLow, ptUp);
XPoly2D poly2d, polyOffset;
rec.AsPoly2D(poly2d);
poly2d.Offset((ptUp.x-ptLow.x)/10.0, polyOffset);
polyOffset.TransUCS(Groups(0), Groups(1));
dc << polyOffset;
g_entCurOpening=ent;
//BOOL bMsgHook=acedRegisterFilterWinMsg(ViewOpeningMsg);
int nRet=RTNORM;
XString sKeyword;
INITGET_BEG(0, _T("E X L"));// [12/26/2007 nsh]
nRet=ads_getkword(_T(""), sKeyword);
INITGET_END();
//if (bMsgHook)
// acedRemoveFilterWinMsg(ViewOpeningMsg);
ads_redraw(NULL, 1);
if (nRet==RTCAN)
break;
if (nRet==RTNONE) {
nCurIndex++;
if (nCurIndex==nObjNum)
nCurIndex=0;
} else if (nRet==RTNORM) {
if (sKeyword[0]==_T('X'))
{
// [3/14/2008 nsh]
//-------------------------------begin------------------------------
m_pSheet->Reset();
DList<AcDbDatabase> dbList;
DList<AcDbObjectId> ss;
GetOpeningIdList(dbList, ss);
if (!ss)
return;
int lCount=ss.Length();
for(int i=0; i<lCount; i++) {
AcDbObjectId &ent=*ss[i];
OPENOBJ_BEGIN(ent, AcDb::kForRead, TDbOpening, pOpening);
if (pOpening && pOpening->GetKind()!=TOpeningData::OP_CORNWIN &&
//pOpening->GetKind()!=TOpeningData::OP_HOLE &&
!(pOpening->m_nOpStyle&OPS_LIFTDOOR) && !(pOpening->m_nOpStyle&OPS_LVTRY))
m_pSheet->Validate(pOpening);
OPENOBJ_END();
}
m_pSheet->QuickSort(TOpeningValidation::CompareForSort);
//重新初始话对话窗
SendMessage(WM_INITDIALOG,NULL,NULL);
//--------------------------------end-------------------------------
break;
}
if (sKeyword[0]==_T('L'))
{
OPENOBJ_BEGIN(ent, AcDb::kForRead, TDbOpening, pWin);
if (pWin)
pWin->list();
OPENOBJ_END();
}
// [12/26/2007 nsh]
//--------------------begin----------------------------
if (sKeyword[0]==_T('E'))
{
RBList maskDimSym(RTDXF0, _T("TCH_*"), 68, 1, NULL);
if (ent.MatchBase(maskDimSym)) {
if (!AT_loaded(_T("tch_annotate")))
acrxLoadModule(_T("tch_annotate.arx"), 0, Adesk::kTrue);
}
EditObject(ent);
}
//---------------------end-----------------------------
}
}
CompleteEditorCommand();
}
void COpeningValidateDlg::OnOK()
{
if (m_nWorkMode==1) {
COleVariant curRow=m_grid.GetBookmark();
if (V_VT(&curRow)!=VT_I4)
return;
int nCurRow=V_I4(&curRow);
TOpeningValidation *pRow=(*m_pSheet)[nCurRow];
if (pRow->m_opKind!=m_opKind || pRow->m_nFlag) {
// 问题描述:提示不合适
// 解决方法:改为"类别不匹配,请选择同类门窗编号!"
// 修改人,修改时间:Zyu modify on 100322
//AfxMessageBox(_T("请选择有效的门窗编号!"));
AfxMessageBox(_T("类别不匹配,请选择同类门窗编号!"));
return;
} else {
m_nCurIndex=nCurRow;
}
}
CAcUiDialog::OnOK();
}
AcDbObjectId COpeningValidateDlg::GetFinalSelect()
{
if (m_nCurIndex>=0) {
TOpeningValidation *pRow=(*m_pSheet)[m_nCurIndex];
if (!pRow->m_idArray.isEmpty() && !pRow->m_nFlag && m_opKind==pRow->m_opKind)
return pRow->m_idArray[0];
}
return AcDbObjectId::kNull;
}
void COpeningValidateDlg::OnSize(UINT nType, int cx, int cy)
{
if (m_bInit && (!nType || nType==SIZE_MAXIMIZED)) {
CSize sizeOld = sizeDlg;
sizeDlg.cx = cx;
sizeDlg.cy = cy;
long nIncY = sizeDlg.cy - sizeOld.cy;
long nIncX = sizeDlg.cx - sizeOld.cx;
ResetSize(nIncX, nIncY);
}
}
void COpeningValidateDlg::ResetSize(long nIncX, long nIncY)
{
CRect rectGrid;
m_grid.GetWindowRect(rectGrid);
ScreenToClient(rectGrid);
CRect rectCancel, rectOk, rectView, rectStatic2d, rectStatic3d, rectStyle2d,rectStyle3d;
CWnd *pCancel = GetDlgItem(IDCANCEL);
CWnd *pOk = GetDlgItem(IDOK);
CWnd *pView = GetDlgItem(IDC_VIEWOBJ);
CWnd *pStatic2d = GetDlgItem(IDC_STATIC_2D);
CWnd *pStatic3d = GetDlgItem(IDC_STATIC_3D);
CWnd *pStyle2d = GetDlgItem(IDC_STYLE2D);
CWnd *pStyle3d = GetDlgItem(IDC_STYLE3D);
pCancel->GetWindowRect(rectCancel);
ScreenToClient(rectCancel);
pOk->GetWindowRect(rectOk);
ScreenToClient(rectOk);
pView->GetWindowRect(rectView);
ScreenToClient(rectView);
pStatic2d->GetWindowRect(rectStatic2d);
ScreenToClient(rectStatic2d);
pStatic3d->GetWindowRect(rectStatic3d);
ScreenToClient(rectStatic3d);
pStyle2d->GetWindowRect(rectStyle2d);
ScreenToClient(rectStyle2d);
pStyle3d->GetWindowRect(rectStyle3d);
ScreenToClient(rectStyle3d);
m_grid.MoveWindow(rectGrid.left, rectGrid.top,
rectGrid.Width()+nIncX, rectGrid.Height()+nIncY);
pCancel->MoveWindow(rectCancel.left, rectCancel.top + nIncY,
rectCancel.Width(), rectCancel.Height());
pOk->MoveWindow(rectOk.left, rectOk.top + nIncY,
rectOk.Width(), rectOk.Height());
pView->MoveWindow(rectView.left, rectView.top + nIncY,
rectView.Width(), rectView.Height());
pStatic2d->MoveWindow(rectStatic2d.left + nIncX, rectStatic2d.top,
rectStatic2d.Width(), rectStatic2d.Height());
pStatic3d->MoveWindow(rectStatic3d.left+ nIncX, rectStatic3d.top,
rectStatic3d.Width(), rectStatic3d.Height());
pStyle2d->MoveWindow(rectStyle2d.left+ nIncX, rectStyle2d.top,
rectStyle2d.Width(), rectStyle2d.Height());
pStyle3d->MoveWindow(rectStyle3d.left+ nIncX, rectStyle3d.top,
rectStyle3d.Width(), rectStyle3d.Height());
}
int COpeningValidateDlg::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CAcUiDialog::OnCreate(lpCreateStruct) == -1)
return -1;
CRect rect;
GetClientRect(rect);
m_nOldSizeX=rect.Width();
m_nOldSizeY=rect.Height();
return 0;
}
#endif
BOOL COpeningValidateNewDlg::m_bShowOnlyCurDwg = TRUE;
COpeningValidateNewDlg::COpeningValidateNewDlg(TOpeningValidateTable *pSheet, CWnd* pParent /*=NULL*/)
: CAcUiDialog(COpeningValidateNewDlg::IDD, pParent)
{
m_pSheet=pSheet;
m_nWorkMode=0;
m_bInit=FALSE;
m_nOldSizeY=260;
m_nOldSizeX=558;
m_bCreate=TRUE;
//{{AFX_DATA_INIT(COpeningValidateNewDlg)
//}}AFX_DATA_INIT
}
void COpeningValidateNewDlg::ShowSlide(UINT id, CImageDC& imgdc, const TCHAR* sldName)
{
CWnd *pWnd=GetDlgItem(id);
if (pWnd) {
CRect cR;
CDC* pDC = pWnd->GetDC();
pWnd->GetClientRect(&cR);
imgdc.InitDC(pDC,cR, GetAcadBackColor());
if (!sldName || !sldName[0])
{
imgdc.PaintSlide(_T(""));
}
else
{
XString sFullPath(256);
sFullPath << g_sDwbPath << sldName;
imgdc.PaintSlide(sFullPath);
}
pWnd->ReleaseDC(pDC);
}
}
void COpeningValidateNewDlg::ShowSlide()
{
int nCurIndex=m_grid.m_nCurIndex;
if (nCurIndex<0||nCurIndex>=m_pSheet->Length())
return;
TOpeningValidation *pRow=(*m_pSheet)[nCurIndex];
if (!(pRow->m_nFlag&OVF_STYLE2D))
ShowSlide(IDC_STYLE2D, m_slide2d, pRow->m_sStyle2d);
else
ShowSlide(IDC_STYLE2D, m_slide2d, _T(""));
if (!(pRow->m_nFlag&OVF_STYLE3D))
ShowSlide(IDC_STYLE3D, m_slide3d, pRow->m_sStyle3d);
else
ShowSlide(IDC_STYLE3D, m_slide3d, _T(""));
}
////////////////////////////////////////
void COpeningValidateNewDlg::DoDataExchange(CDataExchange* pDX)
{
CAcUiDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(COpeningValidateNewDlg)
DDX_Control(pDX, IDC_GRID, m_grid);
DDX_Check(pDX, IDC_CHECK_CURDWG, m_bShowOnlyCurDwg);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(COpeningValidateNewDlg, CAcUiDialog)
//{{AFX_MSG_MAP(COpeningValidateNewDlg)
ON_WM_PAINT()
ON_BN_CLICKED(IDC_VIEWOBJ, OnViewobj)
ON_WM_SIZE()
ON_WM_CREATE()
ON_WM_LBUTTONDOWN()
ON_BN_CLICKED(IDC_CHECK_CURDWG, OnCheckCurDwg)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// COpeningValidateNewDlg message handlers
BOOL COpeningValidateNewDlg::OnInitDialog()
{
CAcUiDialog::OnInitDialog();
CRect rectDlg;
GetClientRect(rectDlg);
sizeDlg.cx = rectDlg.Width();
sizeDlg.cy = rectDlg.Height();
long nIncY = sizeDlg.cy - m_nOldSizeY; // 对话框绝对尺寸
long nIncX = sizeDlg.cx - m_nOldSizeX;
m_bInit = TRUE;
ResetSize(nIncX, nIncY);
if (m_pSheet)
InitGrid();
if (m_nWorkMode)
GetDlgItem(IDC_VIEWOBJ)->ShowWindow(SW_HIDE);
else
GetDlgItem(IDCANCEL)->ShowWindow(SW_HIDE);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void COpeningValidateNewDlg::OnPaint()
{
CDC* pDC;
CRect cR,cR1;
CPaintDC dc(this); // device context for painting
// TODO: Add your message handler code here
CWnd *pWnd2d=GetDlgItem(IDC_STYLE2D);
CWnd *pWnd3d=GetDlgItem(IDC_STYLE3D);
pDC = pWnd3d->GetDC();
pWnd3d->GetClientRect(&cR);
m_slide3d.InitDC(pDC, cR,GetAcadBackColor());
m_slide3d.Redraw();
pWnd3d->ReleaseDC(pDC);
pDC = pWnd2d->GetDC();
pWnd2d->GetClientRect(&cR1);
m_slide2d.InitDC(pDC,cR1,GetAcadBackColor());
m_slide2d.Redraw();
pWnd2d->ReleaseDC(pDC);
}
///////////////////////////////////////////////////////////////////////////
// 观察对象
void COpeningValidateNewDlg::OnViewobj()
{
//modify by xlc on 090313
//int nCurRow=m_grid.m_nCurIndex ;
int nCurRow=m_grid.GetCurRowIndex();
if (nCurRow<0||nCurRow>=m_pSheet->Length())
{
return;
}
TOpeningValidation *pRow=(*m_pSheet)[nCurRow];
AcDbObjectIdArray idArrayCurDwg;
int nObjNum=GetObjectIdInCurDwg(pRow->m_idArray, idArrayCurDwg);
if (nObjNum<=0)
return;
int nCurIndex=0;
BeginEditorCommand();
while(1)
{
AcDbObjectId idObj=idArrayCurDwg[nCurIndex];
if (idObj.database()!=acdbCurDwg()) {
nCurIndex++;
continue;
}
adsout << _T("\n观察第") << (nCurIndex+1) << _T("/") << nObjNum << _T("个编号为'") << pRow->m_sLabel << _T("'的门窗 [编辑属性(E)/列表查询(L)/返回(X)]<下一个>:");
Entity ent;
VERIFY(acdbGetAdsName(ent.name, idObj)==Acad::eOk);
XPoint ptLow, ptUp;
VERIFY(ent.GetExtend(ptLow, ptUp)==RTNORM);
AssureInCurrentView(ptLow, ptUp);
XScreenDc dc(1, 1);
XRectAngle rec(ptLow, ptUp);
XPoly2D poly2d, polyOffset;
rec.AsPoly2D(poly2d);
poly2d.Offset((ptUp.x-ptLow.x)/10.0, polyOffset);
polyOffset.TransUCS(Groups(0), Groups(1));
dc << polyOffset;
g_entCurOpening=ent;
int nRet=RTNORM;
XString sKeyword;
INITGET_BEG(0, _T("E X L"));
nRet=ads_getkword(_T(""), sKeyword);
INITGET_END();
ads_redraw(NULL, 1);
if (nRet==RTCAN)
break;
if (nRet==RTNONE)
{
nCurIndex++;
if (nCurIndex==nObjNum)
nCurIndex=0;
}
else if (nRet==RTNORM)
{
if (sKeyword[0]==_T('X'))
{
m_pSheet->Reset();
DList<AcDbDatabase> dbList;
DList<AcDbObjectId> ss;
GetOpeningIdList(dbList, ss);
if (!ss)
return;
int lCount=ss.Length();
for(int i=0; i<lCount; i++)
{
AcDbObjectId &ent=*ss[i];
OPENOBJ_BEGIN(ent, AcDb::kForRead, TDbOpening, pOpening);
if (pOpening &&
pOpening->GetKind()!=TOpeningData::OP_CORNWIN &&
!(pOpening->m_nOpStyle&OPS_LIFTDOOR) &&
!(pOpening->m_nOpStyle&OPS_LVTRY) &&
_tcsicmp(pOpening->GetSubKind(), _T("隔断门"))!=0 && // sg add 110309,增加对新增子类型的判断
_tcsicmp(pOpening->GetSubKind(), _T("电梯门"))!=0)
{
m_pSheet->Validate(pOpening);
}
OPENOBJ_END();
}
m_pSheet->QuickSort(TOpeningValidation::CompareForSort);
//重新初始话对话窗
//SendMessage(WM_INITDIALOG,NULL,NULL);
m_bCreate=FALSE;
if (m_pSheet)
InitGrid();
break;
}
else if (sKeyword[0]==_T('L'))
{
OPENOBJ_BEGIN(ent, AcDb::kForRead, TDbOpening, pWin);
if (pWin)
pWin->list();
OPENOBJ_END();
}
else if (sKeyword[0]==_T('E'))
{
RBList maskDimSym(RTDXF0, _T("TCH_*"), 68, 1, NULL);
if (ent.MatchBase(maskDimSym))
{
if (!AT_loaded(_T("tch_annotate")))
acrxLoadModule(_T("tch_annotate.arx"), 0, Adesk::kTrue);
}
EditObject(ent);
}
}
}
CompleteEditorCommand();
}
void COpeningValidateNewDlg::OnOK()
{
if (m_nWorkMode==1)
{
//modify by xlc on 090921 解决门窗界面查表时选中行时无法点确定返回的问题
m_grid.m_nCurIndex = m_grid.GetCurRowIndex();
if (!m_grid.IsRowValid())
{
return;
}
int nCurRow=m_grid.m_nCurIndex;
TOpeningValidation *pRow=(*m_pSheet)[nCurRow];
if (pRow->m_opKind!=m_opKind || pRow->m_nFlag)
{
// 问题描述:提示不合适
// 解决方法:改为"类别不匹配,请选择同类门窗编号!"
// 修改人,修改时间:Zyu modify on 100322
//AfxMessageBox(_T("请选择有效的门窗编号!"));
AfxMessageBox(_T("类别不匹配,请选择同类门窗编号!"));
return;
}
}
CAcUiDialog::OnOK();
}
AcDbObjectId COpeningValidateNewDlg::GetFinalSelect()
{
if (m_grid.m_nCurIndex>=0) {
TOpeningValidation *pRow=(*m_pSheet)[m_grid.m_nCurIndex];
if (!pRow->m_idArray.isEmpty() && !pRow->m_nFlag && m_opKind==pRow->m_opKind)
return pRow->m_idArray[0];
}
return AcDbObjectId::kNull;
}
void COpeningValidateNewDlg::OnSize(UINT nType, int cx, int cy)
{
if (m_bInit && (!nType || nType==SIZE_MAXIMIZED))
{
CSize sizeOld = sizeDlg;
sizeDlg.cx = cx;
sizeDlg.cy = cy;
long nIncY = sizeDlg.cy - sizeOld.cy;
long nIncX = sizeDlg.cx - sizeOld.cx;
ResetSize(nIncX, nIncY);
}
}
void COpeningValidateNewDlg::ResetSize(long nIncX, long nIncY)
{
CRect rectGrid;
m_grid.GetWindowRect(rectGrid);
ScreenToClient(rectGrid);
CRect rectCancel, rectOk, rectView, rectStatic2d, rectStatic3d, rectStyle2d,rectStyle3d, rectDWGOnly;
CWnd *pCancel = GetDlgItem(IDCANCEL);
CWnd *pOk = GetDlgItem(IDOK);
CWnd *pView = GetDlgItem(IDC_VIEWOBJ);
CWnd *pStatic2d = GetDlgItem(IDC_STATIC_2D);
CWnd *pStatic3d = GetDlgItem(IDC_STATIC_3D);
CWnd *pStyle2d = GetDlgItem(IDC_STYLE2D);
CWnd *pStyle3d = GetDlgItem(IDC_STYLE3D);
CWnd *pWndDWGOnly = GetDlgItem(IDC_CHECK_CURDWG);
pCancel->GetWindowRect(rectCancel);
ScreenToClient(rectCancel);
pOk->GetWindowRect(rectOk);
ScreenToClient(rectOk);
pView->GetWindowRect(rectView);
ScreenToClient(rectView);
pStatic2d->GetWindowRect(rectStatic2d);
ScreenToClient(rectStatic2d);
pStatic3d->GetWindowRect(rectStatic3d);
ScreenToClient(rectStatic3d);
pStyle2d->GetWindowRect(rectStyle2d);
ScreenToClient(rectStyle2d);
pStyle3d->GetWindowRect(rectStyle3d);
ScreenToClient(rectStyle3d);
pWndDWGOnly->GetWindowRect(rectDWGOnly);
ScreenToClient(rectDWGOnly);
m_grid.MoveWindow(rectGrid.left, rectGrid.top,
rectGrid.Width()+nIncX, rectGrid.Height()+nIncY);
pCancel->MoveWindow(rectCancel.left, rectCancel.top + nIncY,
rectCancel.Width(), rectCancel.Height());
pOk->MoveWindow(rectOk.left, rectOk.top + nIncY,
rectOk.Width(), rectOk.Height());
pView->MoveWindow(rectView.left, rectView.top + nIncY,
rectView.Width(), rectView.Height());
pStatic2d->MoveWindow(rectStatic2d.left + nIncX, rectStatic2d.top,
rectStatic2d.Width(), rectStatic2d.Height());
pStatic3d->MoveWindow(rectStatic3d.left+ nIncX, rectStatic3d.top,
rectStatic3d.Width(), rectStatic3d.Height());
pStyle2d->MoveWindow(rectStyle2d.left+ nIncX, rectStyle2d.top,
rectStyle2d.Width(), rectStyle2d.Height());
pStyle3d->MoveWindow(rectStyle3d.left+ nIncX, rectStyle3d.top,
rectStyle3d.Width(), rectStyle3d.Height());
pWndDWGOnly->MoveWindow(rectDWGOnly.left, rectCancel.top + nIncY,
rectDWGOnly.Width(), rectDWGOnly.Height());
}
int COpeningValidateNewDlg::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CAcUiDialog::OnCreate(lpCreateStruct) == -1)
return -1;
// TODO: Add your specialized creation code here
CRect rect;
GetClientRect(rect);
m_nOldSizeX=rect.Width();
m_nOldSizeY=rect.Height();
return 0;
}
//布置Grid的界面
void COpeningValidateNewDlg::InitGrid()
{
if (!m_pSheet)
return;
int nCurRow=m_grid.m_nCurIndex=0;
m_grid.Clear();
if (m_bCreate)
{
m_grid.AppendCol(_T("编号"), 50);
m_grid.AppendCol(_T("总数"), 40);
m_grid.AppendCol(_T("数量"), 40);
m_grid.AppendCol(_T("类型"), 40);
m_grid.AppendCol(_T("宽度"), 50);
m_grid.AppendCol(_T("高度"), 50);
m_grid.AppendCol(_T("2D样式"), 100);
m_grid.AppendCol(_T("3D样式"), 100);
m_grid.SetColPosFix();
m_grid.SetRowPosFix();
m_grid.SetColFixLength();
m_grid.FitLastCol();
m_grid.Create(this, IDC_GRID);
}
CString csText;
for (int i=0;i<m_pSheet->Length();i++)
{
m_grid.AppendRow();
TOpeningValidation *pRow= (*m_pSheet)[i];
m_grid.GetCell(i, 0).SetText((const TCHAR *)pRow->m_sLabel);
csText.Format(_T("%d"), (int)pRow->m_idArray.length());
m_grid.GetCell(i, 1).SetText(csText);
csText.Empty();
csText.Format(_T("%d"), (int)GetObjectNumInCurDwg(pRow->m_idArray));
m_grid.GetCell(i, 2).SetText(csText);
csText.Empty();
if (pRow->m_nFlag&OVF_KIND)
csText=_T("<冲突>");
else
csText=(const TCHAR *)pRow->m_sKind;
m_grid.GetCell(i, 3).SetText(csText);
csText.Empty();
if (pRow->m_nFlag&OVF_WIDTH)
csText=_T("<冲突>");
else
csText.Format(_T("%d"), AS_INT(pRow->m_nWidth));
m_grid.GetCell(i, 4).SetText(csText);
csText.Empty();
if (pRow->m_nFlag&OVF_HEIGHT)
csText=_T("<冲突>");
else
csText.Format(_T("%d"), AS_INT(pRow->m_nHeight));
m_grid.GetCell(i, 5).SetText(csText);
csText.Empty();
if (pRow->m_nFlag&OVF_STYLE2D)
csText=_T("<冲突>");
else
csText=(const TCHAR *)pRow->m_sStyle2d;
m_grid.GetCell(i, 6).SetText(csText);
csText.Empty();
if (pRow->m_nFlag&OVF_STYLE3D)
csText=_T("<冲突>");
else
csText=(const TCHAR *)pRow->m_sStyle3d;
m_grid.GetCell(i, 7).SetText(csText);
}
m_grid.SetCurRowIndex(nCurRow);
ShowSlide();
}
void COpeningValidateNewDlg::OnLButtonDown(UINT nFlags, CPoint point)
{
if (nFlags == IDC_GRID)
{
ShowSlide();
}
}
//add by xlc on 110308
void COpeningValidateNewDlg::OnCheckCurDwg()
{
UpdateData(TRUE);
DList<AcDbDatabase> dbList;
DList<AcDbObjectId> ss;
if (m_bShowOnlyCurDwg) // 本图
{
GetEntFromBlockByDxf(ss, _T("TCH_OPENING"));
}
else // 本工程
{
GetOpeningIdList(dbList, ss);
}
if (!ss)
return;
m_pSheet->Reset();
int lCount=ss.Length();
for(int i=0; i<lCount; i++)
{
AcDbObjectId &ent=*ss[i];
OPENOBJ_BEGIN(ent, AcDb::kForRead, TDbOpening, pOpening);
if (pOpening &&
pOpening->GetKind()!=TOpeningData::OP_CORNWIN &&
!(pOpening->m_nOpStyle&OPS_LIFTDOOR) &&
!(pOpening->m_nOpStyle&OPS_LVTRY) &&
_tcsicmp(pOpening->GetSubKind(), _T("隔断门"))!=0 && // sg add 110309,增加对新增子类型的判断
_tcsicmp(pOpening->GetSubKind(), _T("电梯门"))!=0)
{
m_pSheet->Validate(pOpening);
}
OPENOBJ_END();
}
m_pSheet->QuickSort(TOpeningValidation::CompareForSort);
m_bCreate=FALSE;
if (m_pSheet)
{
InitGrid();
}
UpdateData(FALSE);
}