4214 lines
115 KiB
C++
4214 lines
115 KiB
C++
#include "StdAfx.h"
|
||
#include <actrans.h>
|
||
#include "OpeningCheck.h"
|
||
#include "rxregsvc.h"
|
||
#include "LabelSetDlg.h"
|
||
#include "frame.h"
|
||
//add by lgy 20120312 门窗检查设置参数需要保存每次关闭应用程序时设置的参数
|
||
#include "TgAs.h"
|
||
#define DOORCKECKSET 13 //门窗检查设置
|
||
|
||
int SelectEnts(CString csPrompt1, AcDbObjectIdArray &idAryAll, AcDbObjectIdArray &idAryBlock, BOOL bEntInBlock, BOOL bSelText);
|
||
|
||
namespace NDoorWinCheck
|
||
{
|
||
CDoorWinFrame *pFrame = NULL;
|
||
static CFrameData *g_pData = NULL;
|
||
|
||
static COLORREF clHuise = RGB(205, 201, 201);
|
||
static COLORREF clShenhui = RGB(139, 137, 137);
|
||
static COLORREF clLvse = RGB(0, 255, 0);
|
||
static COLORREF clPinHong = RGB(255, 0, 255);
|
||
static COLORREF clzonghuang = 0xFFC125;
|
||
static COLORREF clRed = 0xFF0000;
|
||
static COLORREF clBlue = RGB(0x66,0xcc,0x66);
|
||
|
||
static COLORREF s_colorGrid[eColorItemNum] =
|
||
{
|
||
clHuise, // 主编号 (灰色)
|
||
clShenhui, // 门窗类型编号 (灰色)
|
||
clShenhui, // 楼层编号 (灰色)
|
||
clPinHong, // 被修改的数据--品红
|
||
RGB(232,232,224), // 被删除数据的背景色
|
||
RGB(128,128,128), // 被删除的数据的文字色
|
||
clHuise, // 其他DWG图纸中的数据 (灰色)
|
||
clBlue, // 临时编号的数据 (绿色)
|
||
clHuise, // 不是自己的属性
|
||
clHuise, // 只读的属性
|
||
RGB(255, 0, 0), // 主编号的冲突项,红色显示。
|
||
};
|
||
|
||
COLORREF GetGridColor(EGridColorIndex eIndex)
|
||
{
|
||
return s_colorGrid[eIndex];
|
||
}
|
||
|
||
// 用矩阵变换一个快中的一个点
|
||
// ptSrc:块中的点
|
||
// matrix:变换矩阵
|
||
// ptOrigin:块表基点
|
||
// ptPos:快引用的插入位置
|
||
// ret:变换之后的点
|
||
AcGePoint3d LGHTransform(const AcGePoint3d &ptSrc, const AcGeMatrix3d &matrix, const AcGePoint3d &ptOrigin, const AcGePoint3d &ptPos)
|
||
{
|
||
AcGeVector3d vec = ptSrc - ptOrigin;
|
||
return vec.transformBy(matrix) + ptPos;
|
||
}
|
||
|
||
double LGHTransform(double dDisSrc, const AcGeMatrix3d &matrix)
|
||
{
|
||
return 0.0;
|
||
}
|
||
|
||
AcDbExtents& LGHTransform(AcDbExtents &extens, const AcGeMatrix3d &matrix, const AcGePoint3d &ptOrigin, const AcGePoint3d &ptPos)
|
||
{
|
||
AcGePoint3d pt1 = extens.minPoint();
|
||
AcGePoint3d pt3 = extens.maxPoint();
|
||
AcGePoint3d pt2(pt3.x, pt1.y, 0), pt4(pt1.x, pt3.y, 0.0);
|
||
extens.set(LGHTransform(pt1, matrix, ptOrigin, ptPos), LGHTransform(pt2, matrix, ptOrigin, ptPos));
|
||
extens.addPoint(LGHTransform(pt3, matrix, ptOrigin, ptPos));
|
||
extens.addPoint(LGHTransform(pt4, matrix, ptOrigin, ptPos));
|
||
|
||
return extens;
|
||
}
|
||
|
||
// 临时红色亮显,无擦除
|
||
void RedDrawPoly(XPoly2D &poly)
|
||
{
|
||
int len = poly.Length();
|
||
for(int i=0;i<len;i++)
|
||
{
|
||
XCurveSegment seg;
|
||
poly.Nth(i, seg);
|
||
XPoint ptS, ptE;
|
||
ads_grdraw(seg.StartPoint(), seg.EndPoint(), 1, 1); // 高亮虚线
|
||
}
|
||
|
||
acedGetAcadDwgView()->Invalidate();
|
||
acedGetAcadDwgView()->UpdateData();
|
||
}
|
||
|
||
// 把该点移动到当前窗口的中心。
|
||
void MoveView(const AcGePoint3d &ptCenter)
|
||
{
|
||
CView *pView = acedGetAcadDwgView();
|
||
int nWid, nHei;
|
||
if (pView != NULL)
|
||
{
|
||
CRect rect;
|
||
pView->GetClientRect(&rect);
|
||
|
||
nWid = rect.Width();
|
||
nHei = rect.Height();
|
||
|
||
double dWid = PixelToWcs(nWid);
|
||
double dHei = PixelToWcs(nHei);
|
||
|
||
ArxZoomTo(ptCenter, dWid, dHei);
|
||
}
|
||
}
|
||
|
||
// 检测数据是否发生改变,因为没有使用反应器,就使用这个比较文件名字的方式。
|
||
bool ValidData()
|
||
{
|
||
if (g_pData == NULL)
|
||
return false;
|
||
if (curDoc() == NULL)
|
||
return false;
|
||
if (curDoc()->database() == NULL)
|
||
return false;
|
||
|
||
if (g_pData->m_pDataTable != NULL)
|
||
{
|
||
// 文档发生了切换
|
||
if (g_pData->m_pDataTable->IsDocChange() ||
|
||
g_pData->m_pDataTable->IsProjChange())
|
||
{
|
||
return false;
|
||
}
|
||
}
|
||
|
||
return true;
|
||
}
|
||
|
||
// 清楚无效数据。
|
||
void ClearUnValidData()
|
||
{
|
||
if (!ValidData())
|
||
{
|
||
if (g_pData == NULL)
|
||
return;
|
||
if (g_pData->m_pGridView != NULL)
|
||
g_pData->m_pGridView->Clear();
|
||
if (g_pData->m_pTreeView != NULL)
|
||
{
|
||
g_pData->m_pTreeView->Clear();
|
||
}
|
||
g_pData->m_pDataTable->Clear();
|
||
if (pFrame != NULL)
|
||
{
|
||
pFrame->ClearData();
|
||
}
|
||
}
|
||
}
|
||
|
||
//////////////////////////////////////////////////////////////////////////
|
||
// CSplitFrame;
|
||
IMPLEMENT_DYNCREATE(CSplitFrame, CFrameWnd);
|
||
|
||
BEGIN_MESSAGE_MAP(CSplitFrame, CFrameWnd)
|
||
END_MESSAGE_MAP()
|
||
|
||
BOOL CSplitFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext)
|
||
{
|
||
CDoorWinFrame *pFrame = (CDoorWinFrame *)GetParentFrame();
|
||
ASSERT(pFrame != NULL);
|
||
|
||
CRect rectClient;
|
||
GetClientRect(&rectClient);
|
||
|
||
m_wndSplit.CreateStatic(this, 1, 2);
|
||
|
||
m_wndSplit.CreateView(0, 0, RUNTIME_CLASS(CDoorWinTreeView),
|
||
CSize(rectClient.Width()/4, rectClient.Height()), pContext);
|
||
m_wndSplit.SetColumnInfo(0, (int)(rectClient.Width()*0.35), 10);
|
||
|
||
m_wndSplit.CreateView(0, 1, RUNTIME_CLASS(CGridView),
|
||
CSize(0, 0), pContext);
|
||
m_wndSplit.SetColumnInfo(1, (int)(rectClient.Width()*0.65), 10);
|
||
|
||
CDoorWinTreeView *pTree = (CDoorWinTreeView*)m_wndSplit.GetPane(0, 0);
|
||
CGridView *pGrid = (CGridView*)m_wndSplit.GetPane(0, 1);
|
||
pFrame->SetTreeView(pTree);
|
||
pFrame->SetGridView(pGrid);
|
||
|
||
return TRUE;
|
||
}
|
||
|
||
//////////////////////////////////////////////////////////////////////////
|
||
// CDoorAndWinCheckFrame
|
||
IMPLEMENT_DYNCREATE(CDoorWinFrame, CFrameWnd);
|
||
|
||
BEGIN_MESSAGE_MAP(CDoorWinFrame, CFrameWnd)
|
||
ON_WM_CREATE()
|
||
ON_WM_CLOSE()
|
||
ON_WM_DESTROY()
|
||
ON_WM_SIZE()
|
||
ON_WM_ERASEBKGND()
|
||
ON_WM_CLOSE()
|
||
ON_WM_SHOWWINDOW()
|
||
ON_WM_PAINT()
|
||
ON_COMMAND(IDC_BTN_SET, OnBtnSetClick)
|
||
ON_COMMAND(IDC_BTN_UPDATE, OnBtnUpdate)
|
||
ON_COMMAND(IDC_BTN_FROMDWG, OnBtnFromDWG)
|
||
ON_COMMAND(IDC_BTN_EXTENT, OnBtnChoseExtent)
|
||
ON_COMMAND(IDC_IMAGE_2D, OnPic2dClick)
|
||
ON_COMMAND(IDC_IMAGE_3D, OnPic3dClick)
|
||
ON_MESSAGE(WM_ACAD_KEEPFOCUS, onAcadKeepFocus)
|
||
ON_WM_SETFOCUS()
|
||
ON_WM_CTLCOLOR()
|
||
END_MESSAGE_MAP()
|
||
|
||
void SetSize(CSize &size, int cx, int cy)
|
||
{
|
||
size.cx = cx;
|
||
size.cy = cy;
|
||
}
|
||
CDoorWinFrame::CDoorWinFrame() : CFrameWnd(), m_pSplitFrame(NULL), m_pItemToSlide(NULL)
|
||
{
|
||
int nUnit = 22; // 以按钮的高度设置为单位高度
|
||
SetSize(m_sizeSet, nUnit * 5, nUnit); //
|
||
SetSize(m_sizeBtnBottom, nUnit * 3, nUnit);
|
||
SetSize(m_sizeSlide, nUnit*6, (int)(nUnit*4));
|
||
m_nLabelHei = (int)(nUnit * 2.5);
|
||
|
||
m_nLeftBlank = m_nTopBlank = m_nBottomBlank = m_nRightBlank = (int)(nUnit*.5); // 左侧,右侧留空的大小
|
||
|
||
m_nRowBlank1 = m_nRowBlank2 = m_nRowBlank3 = (int)(nUnit * 0.4);
|
||
|
||
m_nColBlank1 = nUnit * 2;
|
||
m_nColBlank2 = nUnit;
|
||
m_nColBlank3 = nUnit;
|
||
|
||
g_pData = &m_dataCenter;
|
||
|
||
m_cs2DStyle = _T("");
|
||
m_cs3DStyle = _T("");
|
||
|
||
for (int i = 0; i < eTipNum; i++)
|
||
{
|
||
SetTip(ETips(i), false);
|
||
}
|
||
}
|
||
|
||
CDoorWinFrame::~CDoorWinFrame()
|
||
{
|
||
// frame 会在内部被删除。
|
||
// delete m_pSplitFrame;
|
||
m_pSplitFrame = NULL;
|
||
}
|
||
|
||
void CDoorWinFrame::SetGridView(CGridView *pGrid)
|
||
{
|
||
m_dataCenter.m_pGridView = pGrid;
|
||
}
|
||
|
||
void CDoorWinFrame::SetTreeView(CDoorWinTreeView *pTree)
|
||
{
|
||
m_dataCenter.m_pTreeView = pTree;
|
||
}
|
||
|
||
CFrameData* CDoorWinFrame::GetData()
|
||
{
|
||
return &m_dataCenter;
|
||
}
|
||
|
||
void CDoorWinFrame::ShowSlide(CStatic& st, CImageDC& imgdc, const TCHAR* sldName)
|
||
{
|
||
XString sFullSld(256);
|
||
if (sldName && sldName[0])
|
||
sFullSld << g_sDwbPath << sldName;
|
||
CRect cR;
|
||
CDC* pDC = st.GetDC();
|
||
st.GetClientRect(&cR);
|
||
imgdc.InitDC(pDC,cR, GetAcadBackColor());
|
||
imgdc.PaintSlide(sFullSld);
|
||
st.ReleaseDC(pDC);
|
||
}
|
||
|
||
void CDoorWinFrame::SetSlideItem(TreeItemData *pItemData)
|
||
{
|
||
m_pItemToSlide = pItemData;
|
||
}
|
||
void CDoorWinFrame::ClearSlideItem()
|
||
{
|
||
SetSlideItem(NULL);
|
||
ShowSlide2d(CString(_T("")));
|
||
ShowSlide3d(CString(_T("")));
|
||
}
|
||
void CDoorWinFrame::ShowSlide2d(CString &strStyle2d)
|
||
{
|
||
if (!IsWindow(m_pic2d.m_hWnd))
|
||
return;
|
||
|
||
m_cs2DStyle = strStyle2d;
|
||
XString sSlidePath(256);
|
||
sSlidePath << m_cs2DStyle;
|
||
ShowSlide(m_pic2d, m_picSlide2d,sSlidePath);
|
||
|
||
InvalidateRect(Slide2dRect());
|
||
UpdateWindow();
|
||
}
|
||
|
||
void CDoorWinFrame::ShowSlide3d(CString &strStyle3d)
|
||
{
|
||
if (!IsWindow(m_pic3d.m_hWnd))
|
||
return;
|
||
|
||
m_cs3DStyle = strStyle3d;
|
||
|
||
XString sSlidePath(256);
|
||
sSlidePath << m_cs3DStyle;
|
||
ShowSlide(m_pic3d, m_picSlide3d,sSlidePath);
|
||
|
||
InvalidateRect(Slide3dRect());
|
||
UpdateWindow();
|
||
}
|
||
|
||
void CDoorWinFrame::UpdateDWG(TreeItemData *pItemData)
|
||
{
|
||
CGridView *pGrid = m_dataCenter.m_pGridView;
|
||
if (pGrid == NULL)
|
||
return;
|
||
|
||
pGrid->UpdateDWG();
|
||
|
||
// 调用CAD窗口立即更新
|
||
acedGetAcadFrame()->Invalidate();
|
||
acedGetAcadFrame()->UpdateWindow();
|
||
}
|
||
|
||
void CDoorWinFrame::ReDrawWnd()
|
||
{
|
||
if (!CSetDlg::IsShowImag())
|
||
{
|
||
// m_pic2d.EnableWindow(FALSE);
|
||
// m_pic3d.EnableWindow(FALSE);
|
||
if (IsWindow(m_pic2d.m_hWnd))
|
||
{
|
||
m_pic2d.ShowWindow(SW_HIDE);
|
||
m_pic2d.DestroyWindow();
|
||
}
|
||
if (IsWindow(m_pic3d.m_hWnd))
|
||
{
|
||
m_pic3d.ShowWindow(SW_HIDE);
|
||
m_pic3d.DestroyWindow();
|
||
}
|
||
}
|
||
else
|
||
{
|
||
// m_pic2d.EnableWindow(TRUE);
|
||
// m_pic3d.EnableWindow(TRUE);
|
||
if (!IsWindow(m_pic2d.m_hWnd))
|
||
{
|
||
m_pic2d.CreateEx(WS_EX_DLGMODALFRAME, _T("STATIC"), _T(""),
|
||
WS_CHILD|WS_VISIBLE|SS_BLACKFRAME | SS_NOTIFY,
|
||
Slide2dRect(), this, IDC_IMAGE_2D);
|
||
}
|
||
if (!IsWindow(m_pic3d.m_hWnd))
|
||
{
|
||
m_pic3d.CreateEx(WS_EX_DLGMODALFRAME, _T("STATIC"), _T(""),
|
||
WS_CHILD|WS_VISIBLE|SS_BLACKFRAME | SS_NOTIFY,
|
||
Slide3dRect(), this, IDC_IMAGE_3D);
|
||
}
|
||
m_pic2d.ShowWindow(SW_SHOW);
|
||
m_pic3d.ShowWindow(SW_SHOW);
|
||
}
|
||
CRect rect;
|
||
GetClientRect(&rect);
|
||
// 调整各个空间的位置。
|
||
OnSize(SIZE_RESTORED, rect.Width(), rect.Height());
|
||
GetDataTip(m_dataCenter.m_pDataTable);
|
||
pFrame->SetTip(eCorrespondingTip, false);
|
||
ShowMessage();
|
||
|
||
}
|
||
|
||
void CDoorWinFrame::SetTip (ETips eTip, bool bSet)
|
||
{
|
||
m_bTip[eTip] = bSet;
|
||
}
|
||
CString CDoorWinFrame::GetTip(ETips eTip) const
|
||
{
|
||
if (!m_bTip[eTip])
|
||
return _T("");
|
||
|
||
CString strTip;
|
||
switch (eTip)
|
||
{
|
||
case eConflictTip:
|
||
strTip.Format(_T("共发现%d个冲突门窗!详细参数请点击上方参数表查看"), m_nConflictDataNum);
|
||
break;
|
||
case eNoFloorTip:
|
||
strTip = _T("尚未定义楼层表,请通过【工程管理】命令创建!当前检查对象为本DWG中所有门窗");
|
||
break;
|
||
case eNoDataTip:
|
||
strTip = _T("未发现门窗");
|
||
break;
|
||
case eDataInOtherDWGTip:
|
||
strTip = _T("所选门窗不在当前图纸中");
|
||
break;
|
||
case eNoLabelTip:
|
||
strTip.Format(_T("有%d个门窗未编号"), m_nNoLabelDataNum);
|
||
break;
|
||
case eCorrespondingTip:
|
||
strTip = _T("表中参数与图中门窗的实际参数不符,请按表中参数更新原图门窗,或重新提取图中门窗参数至表中!");
|
||
break;
|
||
case eBlockData:
|
||
// strTip = _T("所选门窗在块中");
|
||
strTip = _T("所选门窗在块中,该块对应了多个引用");
|
||
break;
|
||
case eDocNotInProj:
|
||
strTip.Format(_T("当前DWG中的门窗不在%s工程中,请重新设置或选择正确的工程文件。"), ProjectName());
|
||
break;
|
||
default:
|
||
return _T("");
|
||
}
|
||
|
||
return strTip;
|
||
}
|
||
|
||
CString CDoorWinFrame::GetTip() const
|
||
{
|
||
CString strTipAll;
|
||
for (int i =0; i < eTipNum; i++)
|
||
{
|
||
CString strTemp = GetTip(ETips(i));
|
||
if (!strTemp.IsEmpty())
|
||
{
|
||
if (!strTipAll.IsEmpty())
|
||
strTipAll += (_T("\r\n"));
|
||
strTipAll += strTemp;
|
||
}
|
||
}
|
||
|
||
return strTipAll;
|
||
}
|
||
|
||
void CDoorWinFrame::ShowMessage()
|
||
{
|
||
m_editTip.SetWindowText(GetTip());
|
||
}
|
||
|
||
void CDoorWinFrame::GetDataTip(CDataTable *pTable)
|
||
{
|
||
if (pTable != NULL)
|
||
{
|
||
int iNoNameLabel = pTable->GetNoNameLabeNum(IsCheckDWG(), IsCheckProj(), IsCheckText(), IsCheckBlock());
|
||
SetTip(eNoLabelTip, iNoNameLabel != 0);
|
||
SetNoLabelDataNum(iNoNameLabel);
|
||
SetTip(eNoDataTip, !pTable->TestHasData(IsCheckDWG(), IsCheckProj(), IsCheckText(), IsCheckBlock()));
|
||
if (IsCheckProj() && !IsCheckDWG())
|
||
SetTip(eNoFloorTip, IsEmptyProject() ? true : false);
|
||
SetTip(eDocNotInProj, pTable->IsCurrDocNotInProj() && IsCheckDWG() && IsCheckProj());
|
||
}
|
||
}
|
||
|
||
void CDoorWinFrame::ClearData()
|
||
{
|
||
ClearSlideItem();
|
||
ShowSlide2d(CString(_T("")));
|
||
ShowSlide3d(CString(_T("")));
|
||
|
||
for (int i = 0; i < eTipNum; i++)
|
||
{
|
||
SetTip(ETips(i), false);
|
||
}
|
||
ShowMessage();
|
||
}
|
||
|
||
|
||
BOOL CDoorWinFrame::Create(LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle,
|
||
const RECT& rect, CWnd* pParentWnd/*, UINT nID, CCreateContext* pContext*/)
|
||
{
|
||
// TODO: Add your specialized code here and/or call the base class
|
||
if(!CreateEx(0,lpszClassName, lpszWindowName, dwStyle, rect, pParentWnd, NULL, NULL))
|
||
{
|
||
AfxMessageBox(_T("窗口创建失败"));
|
||
return FALSE;
|
||
}
|
||
|
||
return TRUE;//CWnd::Create(lpszClassName, lpszWindowName, dwStyle, rect, pParentWnd, nID, pContext);
|
||
}
|
||
|
||
BOOL CDoorWinFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext)
|
||
{
|
||
font.CreatePointFont(90, _T("宋体"));
|
||
SetFont(&font);
|
||
|
||
CRect rectClient;
|
||
GetClientRect(&rectClient);
|
||
|
||
m_btnSet.Create(_T("设置..."), WS_GROUP|WS_CHILD|WS_VISIBLE|BS_PUSHBUTTON,
|
||
BtnSetRect(), this, IDC_BTN_SET);
|
||
m_btnSet.SetFont(&font);
|
||
|
||
if (CSetDlg::IsShowImag())
|
||
{
|
||
m_pic2d.CreateEx(WS_EX_DLGMODALFRAME, _T("STATIC"), _T(""),
|
||
WS_CHILD|WS_VISIBLE|SS_BLACKFRAME | SS_NOTIFY,
|
||
Slide2dRect(), this, IDC_IMAGE_2D);
|
||
m_pic3d.CreateEx(WS_EX_DLGMODALFRAME, _T("STATIC"), _T(""),
|
||
WS_CHILD|WS_VISIBLE|SS_BLACKFRAME | SS_NOTIFY,
|
||
Slide3dRect(), this, IDC_IMAGE_3D);
|
||
}
|
||
|
||
m_btnUpdate.Create(_T("更新原图"),WS_GROUP|WS_CHILD|WS_VISIBLE|BS_PUSHBUTTON,
|
||
BtnUpdateRect(rectClient), this, IDC_BTN_UPDATE);
|
||
m_btnUpdate.SetFont(&font);
|
||
|
||
m_btnFromDwg.Create(_T("提取图纸"),WS_GROUP|WS_CHILD|WS_VISIBLE|BS_PUSHBUTTON,
|
||
BtnFromDWGRect(rectClient), this, IDC_BTN_FROMDWG);
|
||
m_btnFromDwg.SetFont(&font);
|
||
|
||
m_btnChoseExtent.Create(_T("选取范围"),WS_GROUP|WS_CHILD|WS_VISIBLE|BS_PUSHBUTTON,
|
||
BtnChoseRect(rectClient), this, IDC_BTN_EXTENT);
|
||
m_btnChoseExtent.SetFont(&font);
|
||
|
||
// ES_AUTOHSCROLL | ES_WANTRETURN | NOT WS_BORDER | NOT WS_TABSTOP
|
||
m_editTip.Create(WS_CHILD|WS_VISIBLE|ES_AUTOVSCROLL|ES_WANTRETURN|ES_MULTILINE | SS_NOTIFY | ES_READONLY ,
|
||
TipRect(rectClient), this, IDC_LABEL_MESSAGE);
|
||
m_editTip.SetFont(&font);
|
||
|
||
m_pSplitFrame = new CSplitFrame;
|
||
m_pSplitFrame->Create(NULL, NULL, WS_CHILD | WS_VISIBLE,
|
||
SplitWndRect(rectClient), this);
|
||
m_pSplitFrame->SetFont(&font);
|
||
|
||
m_pSplitFrame->ShowWindow(SW_SHOWNORMAL);
|
||
|
||
m_wndToolTip.Create(this);
|
||
m_wndToolTip.Activate(true);
|
||
m_wndToolTip.SetMaxTipWidth(250);
|
||
m_wndToolTip.SetDelayTime(TTDT_AUTOPOP, 4*m_wndToolTip.GetDelayTime(TTDT_AUTOPOP));
|
||
|
||
AddTip(IDC_BTN_UPDATE, _T("按当前参数框中的门窗信息更新原图门窗对象"));
|
||
AddTip(IDC_BTN_FROMDWG, _T("提取当前打开的工程或图形中的全部门窗信息"));
|
||
AddTip(IDC_BTN_EXTENT, _T("由设计师自行框选需提取门窗信息的图形范围"));
|
||
return TRUE;
|
||
}
|
||
|
||
int CDoorWinFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
|
||
{
|
||
if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
|
||
return -1;
|
||
|
||
SendMessage(WM_SETICON, TRUE, (LPARAM)(acedGetAcadFrame()->GetIcon(TRUE)));
|
||
ShowWindow(SW_SHOW);
|
||
|
||
return 0;
|
||
}
|
||
|
||
void CDoorWinFrame::OnClose()
|
||
{
|
||
// CFrameWnd::OnClose();
|
||
UnLockDocumentChange();
|
||
this->ShowWindow(SW_HIDE);// 隐藏这个对话框
|
||
acedGetAcadFrame()->SetFocus();
|
||
acedGetAcadFrame()->ActivateFrame();
|
||
}
|
||
void CDoorWinFrame::OnDestroy()
|
||
{
|
||
m_wndToolTip.DestroyWindow();
|
||
CFrameWnd::OnDestroy();
|
||
UnLockDocumentChange();
|
||
}
|
||
|
||
void CDoorWinFrame::OnShowWindow(BOOL bShow, UINT nStatus)
|
||
{
|
||
if(bShow)
|
||
{ // 显示本窗口
|
||
// 锁定文档。
|
||
LockDocumentChange();
|
||
// SetXXCap();
|
||
}
|
||
else
|
||
{
|
||
// ReleasXXCap();
|
||
}
|
||
|
||
CFrameWnd::OnShowWindow(bShow, nStatus);
|
||
}
|
||
|
||
void CDoorWinFrame::PostNcDestroy()
|
||
{
|
||
// 注意:pFrame在基类中被删除。
|
||
CFrameWnd::PostNcDestroy();
|
||
pFrame = NULL;
|
||
}
|
||
|
||
BOOL CDoorWinFrame::OnEraseBkgnd(CDC* pDC)
|
||
{
|
||
CRect rc;
|
||
GetClientRect(&rc);
|
||
|
||
// 修改frame的背景成为对话框的背景
|
||
pDC->FillSolidRect(rc, GetSysColor(COLOR_3DFACE));
|
||
return true;
|
||
}
|
||
|
||
void CDoorWinFrame::OnSize(UINT nType, int cx, int cy)
|
||
{
|
||
CFrameWnd::OnSize(nType, cx, cy);
|
||
ASSERT(m_pSplitFrame != NULL);
|
||
|
||
CRect rectFrame, rect;
|
||
GetClientRect(rectFrame);
|
||
rect = SplitWndRect(rectFrame);
|
||
::SetWindowPos(m_pSplitFrame->m_hWnd, HWND_BOTTOM,
|
||
rect.left, rect.top, rect.Width(), rect.Height(), 0);
|
||
|
||
rect = TipRect(rectFrame);
|
||
::SetWindowPos(m_editTip.m_hWnd, HWND_TOP,
|
||
rect.left, rect.top, rect.Width(), rect.Height(), 0);
|
||
|
||
rect = BtnUpdateRect(rectFrame);
|
||
::SetWindowPos(m_btnUpdate.m_hWnd, HWND_TOP,
|
||
rect.left, rect.top, rect.Width(), rect.Height(), 0);
|
||
|
||
rect = BtnFromDWGRect(rectFrame);
|
||
::SetWindowPos(m_btnFromDwg.m_hWnd, HWND_TOP,
|
||
rect.left, rect.top, rect.Width(), rect.Height(), 0);
|
||
|
||
rect = BtnChoseRect(rectFrame);
|
||
::SetWindowPos(m_btnChoseExtent.m_hWnd, HWND_TOP,
|
||
rect.left, rect.top, rect.Width(), rect.Height(), 0);
|
||
}
|
||
|
||
// 设置按钮响应函数
|
||
void CDoorWinFrame::OnBtnSetClick()
|
||
{
|
||
CAcModuleResourceOverride vTemp;
|
||
CSetDlg dlg;
|
||
dlg.DoModal();
|
||
}
|
||
|
||
// 更新到原图按钮响应函数
|
||
void CDoorWinFrame::OnBtnUpdate()
|
||
{
|
||
CTreeCtrl &tree = m_dataCenter.m_pTreeView->GetTreeCtrl();
|
||
|
||
HTREEITEM hItemSel = tree.GetSelectedItem();
|
||
if (hItemSel == NULL)
|
||
return;
|
||
|
||
TreeItemData *pItemData = (TreeItemData*)tree.GetItemData(hItemSel);
|
||
if (pItemData == NULL)
|
||
return;
|
||
|
||
UpdateDWG(pItemData);
|
||
|
||
GetDataTip(m_dataCenter.m_pDataTable);
|
||
pFrame->SetTip(eCorrespondingTip, false);
|
||
ShowMessage();
|
||
}
|
||
|
||
// 提取图纸按钮响应函数
|
||
void CDoorWinFrame::OnBtnFromDWG()
|
||
{
|
||
// sg delete 120703,如果图面确实发生了改变,其实不需要记忆当前选择的是哪一行
|
||
//add by lgy 20120306 点取提取图纸前保存当前grid中保存的数据以备更新时再次显示出来
|
||
//WDGridTreeRow *pCurRow = m_dataCenter.m_pGridView->m_grid.CurTreeRow();
|
||
//if (pCurRow != NULL)
|
||
//{
|
||
// if (pCurRow->IsChildRow())
|
||
// {
|
||
// WDGridTreeRow &curRow = pCurRow->GetParent();
|
||
// pCurRow = &curRow;
|
||
// }
|
||
//}
|
||
|
||
// 重新读取一下当前的数据,然后绘制。
|
||
CDataTable *pDataTable = new CDataTable;
|
||
GetOpeningDataTable(*pDataTable); // 新读取dataTable, 并且比较是否有更新
|
||
|
||
DWORD dwChange = 0;
|
||
if (!m_dataCenter.m_pDataTable->IsSelData() && !m_dataCenter.m_pDataTable->IsOldData())
|
||
dwChange = m_dataCenter.m_pDataTable->Compare(*pDataTable);
|
||
if (m_dataCenter.m_pDataTable->IsSelData() ||
|
||
m_dataCenter.m_pDataTable->IsOldData() ||
|
||
CDataTable::TestDataChange(dwChange, CDataTable::eProjChange) ||
|
||
CDataTable::TestDataChange(dwChange, CDataTable::eDocChange) ||
|
||
CDataTable::TestDataChange(dwChange, CDataTable::eLabelChange) ||
|
||
CDataTable::TestDataChange(dwChange, CDataTable::eIdDel) ||
|
||
CDataTable::TestDataChange(dwChange, CDataTable::eIdAdd) ||
|
||
CDataTable::TestDataChange(dwChange, CDataTable::ePropChange))
|
||
{
|
||
// 需要重新生成树和grid
|
||
CDataTable *pOldDataTable = m_dataCenter.m_pDataTable;
|
||
m_dataCenter.m_pDataTable = pDataTable;
|
||
|
||
CDoorWinTreeView *pTree = m_dataCenter.m_pTreeView;
|
||
pTree->Clear();
|
||
pTree->FillTreeView();
|
||
pTree->ShowRootView();
|
||
delete pOldDataTable;
|
||
|
||
//add by lgy 20120306 如果图纸中门窗数据有变化,则需要将原来保存的门窗对应的GRID页面恢复显示
|
||
//if (pCurRow != NULL)
|
||
//{
|
||
// TreeItemData *pItemData = (TreeItemData*)pCurRow->GetExtendData();
|
||
// if (pItemData != NULL)
|
||
// g_pData->m_pGridView->ReCreate(pItemData);
|
||
//}
|
||
}
|
||
else
|
||
{
|
||
// 如果表格没有发生变化,不刷新表格
|
||
//m_dataCenter.m_pGridView->RefreshGrid();
|
||
delete pDataTable;
|
||
pDataTable = NULL;
|
||
}
|
||
|
||
GetDataTip(m_dataCenter.m_pDataTable);
|
||
pFrame->SetTip(eCorrespondingTip, false);
|
||
ShowMessage();
|
||
}
|
||
|
||
void CDoorWinFrame::OnBtnChoseExtent()
|
||
{
|
||
this->ShowWindow(SW_HIDE);
|
||
acedGetAcadFrame()->SetFocus();
|
||
acedGetAcadFrame()->ActivateFrame();
|
||
|
||
AcDbObjectIdArray aryIdAll, aryIdBlock;
|
||
|
||
int ret = ::SelectEnts(_T("\n请选择待检查的门窗:"), aryIdAll, aryIdBlock, IsCheckBlock(), IsCheckText());
|
||
if (ret != RTCAN)
|
||
{
|
||
CDoorWinTreeView *pTree = m_dataCenter.m_pTreeView;
|
||
pTree->Clear();
|
||
m_dataCenter.m_pGridView->Clear();
|
||
// delete g_pData->m_pDataTable;
|
||
// ....需要读取这些数据,然后分类
|
||
g_pData->m_pDataTable->Clear();
|
||
g_pData->m_pDataTable->AddIdNoProject(aryIdAll, &aryIdBlock);
|
||
|
||
g_pData->m_pDataTable->SetFileInfo();
|
||
g_pData->m_pDataTable->SetSelFlag(true); // 设置框选标记
|
||
pTree->FillTreeView();
|
||
pTree->ShowRootView();
|
||
}
|
||
|
||
this->ShowWindow(SW_SHOW);
|
||
this->SetFocus();
|
||
this->SetActiveWindow();
|
||
GetDataTip(m_dataCenter.m_pDataTable);
|
||
pFrame->SetTip(eCorrespondingTip, false);
|
||
ShowMessage();
|
||
}
|
||
|
||
BOOL InvokeTkwMan(const TCHAR *pszLib, BOOL bSelOnly, XString &sBlockName)
|
||
{
|
||
if (!AT_loaded(_T("tch_blklib"))) {
|
||
int nRet=acrxLoadModule(_T("tch_blklib.arx"), Adesk::kTrue, true);
|
||
if (!nRet)
|
||
return FALSE;
|
||
}
|
||
int nCode=bSelOnly? RTT : RTNIL;
|
||
RBList rbCmd=ads_buildlist(RTSTR, _T("ITkw"), RTSTR, pszLib, nCode,
|
||
RTSTR, (const TCHAR *)sBlockName, NULL);
|
||
resbuf *rbRes=NULL;
|
||
if (ads_invoke(rbCmd, &rbRes)==RTNORM && rbRes) {
|
||
if (rbRes && rbRes->restype==RTSTR)
|
||
sBlockName=rbRes->resval.rstring;
|
||
ads_relrb(rbRes);
|
||
return TRUE;
|
||
}
|
||
return FALSE;
|
||
}
|
||
|
||
void CDoorWinFrame::OnPic2dClick()
|
||
{
|
||
if (m_pItemToSlide == NULL)
|
||
return; //
|
||
|
||
XString sLibFile, sBlockName;
|
||
EEntType eEntType = m_pItemToSlide->GetEntType();
|
||
|
||
if (eEntType == eM)
|
||
{ // 门类型
|
||
sLibFile << g_sDwbPath << _T("DorLib2D.TKW");
|
||
}
|
||
else if (eEntType == eC)
|
||
{
|
||
// 窗
|
||
sLibFile << g_sDwbPath << _T("WinLib2D.TKW");
|
||
}
|
||
else if (eEntType == eMLC)
|
||
{
|
||
// 门帘窗
|
||
sLibFile << g_sDwbPath << _T("WDLib3D.TKW");
|
||
}
|
||
else if (eEntType == eZMM)
|
||
{
|
||
// 子母门
|
||
sLibFile << g_sDwbPath << _T("WDLib3D.TKW");
|
||
}
|
||
else
|
||
return;
|
||
|
||
if (m_pItemToSlide->GetType() == eOneItem)
|
||
{
|
||
GridItemOneItem *pGridItem = (GridItemOneItem*)m_pItemToSlide;
|
||
sBlockName = pGridItem->pItem->aryProp[pGridItem->nIndex].str2DShowStyle;
|
||
}
|
||
else if (m_pItemToSlide->GetType() == eSameName)
|
||
{
|
||
TreeItemSameName *pSameName = (TreeItemSameName*)m_pItemToSlide;
|
||
CWidItem &widItem = pSameName->widItem;
|
||
for (int i = 0; i < widItem.aryItem.GetSize(); i++)
|
||
{
|
||
CItem *pItem = widItem.aryItem[i];
|
||
int j;
|
||
for (j = 0; j < (int)pItem->aryProp.GetSize(); j++)
|
||
{
|
||
if (i == 0 && j == 0)
|
||
{
|
||
sBlockName = pItem->aryProp[0].str2DShowStyle;
|
||
}
|
||
else
|
||
{
|
||
if (sBlockName != pItem->aryProp[0].str2DShowStyle)
|
||
{
|
||
sBlockName = _T("");
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
if (j != (int)pItem->aryProp.GetSize())
|
||
break;
|
||
}
|
||
}
|
||
|
||
// XPushAutoHide noAutoHide(this);
|
||
|
||
if (InvokeTkwMan(sLibFile, TRUE, sBlockName)) {
|
||
ShowSlide(m_pic2d, m_picSlide2d, sBlockName);
|
||
CString strStyle = (const TCHAR *)(XPathParser(sBlockName).m_sFileName);
|
||
|
||
m_pItemToSlide->SetSlideType2d(strStyle);
|
||
m_dataCenter.m_pDataTable->MakeDataOld();// 老数据
|
||
}
|
||
}
|
||
|
||
void CDoorWinFrame::OnPic3dClick()
|
||
{
|
||
if (m_pItemToSlide == NULL)
|
||
return; //
|
||
|
||
XString sLibFile, sBlockName;
|
||
EEntType eEntType = m_pItemToSlide->GetEntType();
|
||
|
||
if (IsSlideType(eEntType))
|
||
{
|
||
// 子母门
|
||
sLibFile << g_sDwbPath << _T("WDLib3D.TKW");
|
||
}
|
||
else
|
||
return;
|
||
|
||
|
||
|
||
if (m_pItemToSlide->GetType() == eOneItem)
|
||
{
|
||
GridItemOneItem *pGridItem = (GridItemOneItem*)m_pItemToSlide;
|
||
sBlockName = pGridItem->pItem->aryProp[pGridItem->nIndex].str3DShowStyle;
|
||
}
|
||
else if (m_pItemToSlide->GetType() == eSameName)
|
||
{
|
||
TreeItemSameName *pSameName = (TreeItemSameName*)m_pItemToSlide;
|
||
CWidItem &widItem = pSameName->widItem;
|
||
for (int i = 0; i < widItem.aryItem.GetSize(); i++)
|
||
{
|
||
CItem *pItem = widItem.aryItem[i];
|
||
int j;
|
||
for (j = 0; j < (int)pItem->aryProp.GetSize(); j++)
|
||
{
|
||
if (i == 0 && j == 0)
|
||
{
|
||
sBlockName = pItem->aryProp[0].str3DShowStyle;
|
||
}
|
||
else
|
||
{
|
||
if (sBlockName != pItem->aryProp[0].str3DShowStyle)
|
||
{
|
||
sBlockName = _T("");
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
if (j != (int)pItem->aryProp.GetSize())
|
||
break;
|
||
}
|
||
}
|
||
|
||
|
||
if (InvokeTkwMan(sLibFile, TRUE, sBlockName)) {
|
||
ShowSlide(m_pic3d, m_picSlide3d, sBlockName);
|
||
CString strStyle = (const TCHAR *)(XPathParser(sBlockName).m_sFileName);
|
||
|
||
m_pItemToSlide->SetSlideType3d(strStyle);
|
||
m_dataCenter.m_pDataTable->MakeDataOld();// 老数据
|
||
}
|
||
}
|
||
|
||
LONG_PTR CDoorWinFrame::onAcadKeepFocus(UINT_PTR, LONG_PTR)
|
||
{
|
||
return FALSE;
|
||
}
|
||
|
||
void CDoorWinFrame::OnSetFocus(CWnd* pOldWnd)
|
||
{
|
||
CFrameWnd::OnSetFocus(pOldWnd);
|
||
// SetXXCap();
|
||
if (!ValidData())
|
||
{
|
||
ClearUnValidData();
|
||
if (!IsCADClosed())
|
||
{
|
||
ReadDWG();
|
||
}
|
||
}
|
||
if (m_dataCenter.m_pGridView != NULL)
|
||
{
|
||
m_dataCenter.m_pGridView->RefreshGrid();
|
||
}
|
||
}
|
||
|
||
void CDoorWinFrame::OnPaint()
|
||
{
|
||
CDC* pDC;
|
||
CRect cR,cR1;
|
||
CPaintDC dc(this); // device context for painting
|
||
|
||
// TODO: Add your message handler code here
|
||
if (!m_cs3DStyle.IsEmpty() && CSetDlg::IsShowImag() && IsWindow(m_pic3d.m_hWnd))
|
||
{
|
||
pDC = m_pic3d.GetDC();
|
||
m_pic3d.GetClientRect(&cR);
|
||
m_picSlide3d.InitDC(pDC, cR, GetAcadBackColor());
|
||
m_picSlide3d.Redraw();
|
||
m_pic3d.ReleaseDC(pDC);
|
||
}
|
||
|
||
if (!m_cs2DStyle.IsEmpty() && CSetDlg::IsShowImag() && IsWindow(m_pic2d.m_hWnd))
|
||
{
|
||
pDC = m_pic2d.GetDC();
|
||
m_pic2d.GetClientRect(&cR1);
|
||
m_picSlide2d.InitDC(pDC,cR1,GetAcadBackColor());
|
||
m_picSlide2d.Redraw();
|
||
m_pic2d.ReleaseDC(pDC);
|
||
}
|
||
}
|
||
|
||
CRect CDoorWinFrame::BtnSetRect() const
|
||
{
|
||
CRect rect;
|
||
rect.top = m_nTopBlank;
|
||
rect.bottom = m_nTopBlank+m_sizeSet.cy;
|
||
rect.left = m_nLeftBlank;
|
||
rect.right = m_nLeftBlank+m_sizeSet.cx;
|
||
|
||
return rect;
|
||
}
|
||
CRect CDoorWinFrame::Slide2dRect() const
|
||
{
|
||
CRect rect;
|
||
rect.top = m_nTopBlank;
|
||
rect.bottom = m_nTopBlank+m_sizeSlide.cy;
|
||
rect.left = BtnSetRect().right + m_nColBlank1;
|
||
rect.right = rect.left+m_sizeSlide.cx;
|
||
|
||
return rect;
|
||
}
|
||
CRect CDoorWinFrame::Slide3dRect() const
|
||
{
|
||
CRect rect;
|
||
rect.top = m_nTopBlank;
|
||
rect.bottom = m_nTopBlank+m_sizeSlide.cy;
|
||
rect.left = Slide2dRect().right + m_nColBlank2;
|
||
rect.right = rect.left+m_sizeSlide.cx;
|
||
|
||
return rect;
|
||
}
|
||
CRect CDoorWinFrame::SplitWndRect(const CRect &rectFrame) const
|
||
{
|
||
CRect rect;
|
||
|
||
if (CSetDlg::IsShowImag())
|
||
{
|
||
rect.top = Slide2dRect().bottom + m_nRowBlank1;
|
||
}
|
||
else
|
||
{
|
||
rect.top = BtnSetRect().bottom + m_nRowBlank1;
|
||
}
|
||
rect.bottom = TipRect(rectFrame).top - m_nRowBlank2;
|
||
rect.left = m_nLeftBlank;
|
||
rect.right = rectFrame.right - m_nRightBlank;
|
||
|
||
return rect;
|
||
}
|
||
CRect CDoorWinFrame::TipRect(const CRect &rectFrame) const
|
||
{
|
||
CRect rect;
|
||
|
||
rect.top = BtnUpdateRect(rectFrame).top - m_nRowBlank3 - m_nLabelHei;
|
||
rect.bottom = rect.top + m_nLabelHei;
|
||
rect.left = m_nLeftBlank;
|
||
rect.right = rectFrame.right - m_nRightBlank;
|
||
|
||
return rect;
|
||
}
|
||
|
||
CRect CDoorWinFrame::BtnUpdateRect(const CRect &rectFrame) const
|
||
{
|
||
CRect rect;
|
||
rect.bottom = rectFrame.bottom - m_nBottomBlank;
|
||
rect.top = rect.bottom - m_sizeBtnBottom.cy;
|
||
rect.right = BtnFromDWGRect(rectFrame).left - m_nColBlank3;
|
||
rect.left = rect.right - m_sizeBtnBottom.cx;
|
||
return rect;
|
||
}
|
||
CRect CDoorWinFrame::BtnFromDWGRect(const CRect &rectFrame) const
|
||
{
|
||
CRect rect;
|
||
rect.bottom = rectFrame.bottom - m_nBottomBlank;
|
||
rect.top = rect.bottom - m_sizeBtnBottom.cy;
|
||
rect.right = BtnChoseRect(rectFrame).left - m_nColBlank3;
|
||
rect.left = rect.right - m_sizeBtnBottom.cx;
|
||
return rect;
|
||
}
|
||
CRect CDoorWinFrame::BtnChoseRect(const CRect &rectFrame) const
|
||
{
|
||
CRect rect;
|
||
rect.bottom = rectFrame.bottom - m_nBottomBlank;
|
||
rect.top = rect.bottom - m_sizeBtnBottom.cy;
|
||
rect.right = rectFrame.right - m_nRightBlank;
|
||
rect.left = rect.right - m_sizeBtnBottom.cx;
|
||
return rect;
|
||
}
|
||
|
||
|
||
BOOL CDoorWinFrame::PreTranslateMessage(MSG* pMsg)
|
||
{
|
||
CToolInfo toolInfo;
|
||
if (pMsg->message >= WM_MOUSEFIRST &&
|
||
pMsg->message <= WM_MOUSELAST&&m_wndToolTip.GetToolInfo(toolInfo,FromHandle(pMsg->hwnd)))
|
||
{
|
||
MSG msg;
|
||
memcpy(&msg, pMsg, sizeof(MSG));
|
||
m_wndToolTip.RelayEvent(&msg);
|
||
}
|
||
return CFrameWnd::PreTranslateMessage(pMsg);
|
||
}
|
||
BOOL CDoorWinFrame::AddTip(UINT idControl,const TCHAR *str)
|
||
{
|
||
CWnd *pWnd = GetDlgItem(idControl);
|
||
if (!pWnd)
|
||
return FALSE;
|
||
if (str==NULL)
|
||
{
|
||
HINSTANCE hInstance=AfxGetInstanceHandle();
|
||
int nRet;
|
||
CString strTip;
|
||
if (!hInstance)
|
||
nRet=strTip.LoadString(idControl);
|
||
else
|
||
{
|
||
TCHAR szTemp[1024]=_T("");
|
||
nRet=::LoadString(hInstance, idControl, szTemp, 1024);
|
||
if (nRet)
|
||
strTip=szTemp;
|
||
}
|
||
if (nRet)
|
||
return m_wndToolTip.AddTool(pWnd,strTip)!=0;
|
||
}
|
||
return m_wndToolTip.AddTool(pWnd,str)!=0;
|
||
}
|
||
HBRUSH CDoorWinFrame::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
|
||
{
|
||
HBRUSH hbr = CFrameWnd::OnCtlColor(pDC, pWnd, nCtlColor);
|
||
if (pWnd->IsWindowEnabled())
|
||
{
|
||
CToolInfo toolInfo;
|
||
if (m_wndToolTip.GetToolInfo(toolInfo, pWnd))
|
||
pDC->SetTextColor(RGB(0,0,255));
|
||
}
|
||
return hbr;
|
||
}
|
||
|
||
//////////////////////////////////////////////////////////////////////////
|
||
// TreeItemData:
|
||
|
||
void TreeItemData::SetEntSlide(AcDbObjectId &id, SOpeningProp &sProp, CString strStyle, bool b2dOr3d)
|
||
{
|
||
EEntType eEntType = sProp.pItem->eDoorWinType;
|
||
|
||
if (id.isValid() && !id.isErased())
|
||
{ // 有效的,并且当前图的
|
||
// 注意:在对一个某个Id写打开之前,需要确保锁定该文档,操作之后解锁
|
||
// 否则会产生eLockViolation打开错误
|
||
acDocManager->lockDocument(curDoc(),AcAp::kWrite,NULL,NULL,true);
|
||
OPENOBJ_BEGIN(id, AcDb::kForWrite, TDbEntity, pEnt)
|
||
if (pEnt == NULL)
|
||
return;
|
||
|
||
//modify by lgy 20120229 注释下面这一行主要是为了用户在选取选择门窗样式的时候
|
||
//不能随时选中就更新,而是点取更新图纸之后才更新
|
||
//UpdateEntStyle(pEnt, eEntType, strStyle, b2dOr3d);
|
||
if (b2dOr3d)
|
||
sProp.str2DShowStyle = strStyle;
|
||
else
|
||
sProp.str3DShowStyle = strStyle;
|
||
|
||
OPENOBJ_END()
|
||
|
||
acDocManager->unlockDocument(curDoc());
|
||
}
|
||
}
|
||
|
||
void TreeItemData::SetWidItemSlide(CWidItem *pWidItem, CString strStyle, bool b2dor3d)
|
||
{
|
||
for (int iAryItem = 0; iAryItem < (int)pWidItem->aryItem.GetSize(); iAryItem++)
|
||
{
|
||
CItem *pItem = pWidItem->aryItem[iAryItem];
|
||
for (int iId = 0; iId < (int)pItem->aryId.length(); iId++)
|
||
{
|
||
AcDbObjectId &id = pItem->aryId[iId];
|
||
SOpeningProp &sProp = pItem->aryProp[iId];
|
||
SetEntSlide(id, sProp, strStyle, b2dor3d);
|
||
}
|
||
}
|
||
}
|
||
|
||
void TreeItemData::SetAryWidItemSlide(AryWidItemPtr &aryWidItem, CString strStyle, bool b2dOr3d)
|
||
{
|
||
TDPtrList<AcDbObjectId> idLst;
|
||
for (int iAryWid = 0; iAryWid < (int)aryWidItem.GetSize(); iAryWid++)
|
||
{
|
||
CWidItem *pWidItem = aryWidItem[iAryWid];
|
||
|
||
SetWidItemSlide(pWidItem, strStyle, b2dOr3d);
|
||
if (pWidItem != NULL)
|
||
pWidItem->GetIdAry(idLst);
|
||
}
|
||
|
||
UpdateGraphicAny(idLst);
|
||
actrTransactionManager->flushGraphics();
|
||
acedUpdateDisplay();
|
||
}
|
||
|
||
EEntType TreeItemSameStyle::GetEntType() const
|
||
{
|
||
if (IsEmpty(aryWidItemPtr) || IsEmpty(aryWidItemPtr[0]->aryItem))
|
||
return eDoorTypeNum;
|
||
|
||
return aryWidItemPtr[0]->aryItem[0]->eDoorWinType;
|
||
}
|
||
void TreeItemSameStyle::SetSlideType2d(CString style)
|
||
{
|
||
// 一堆widItem,每个widItem包含一堆CItem, 每个CItem包含一堆实体
|
||
SetAryWidItemSlide(aryWidItemPtr, style, true);
|
||
}
|
||
void TreeItemSameStyle::SetSlideType3d(CString style)
|
||
{
|
||
SetAryWidItemSlide(aryWidItemPtr, style, false);
|
||
}
|
||
|
||
EEntType TreeItemSameName::GetEntType() const
|
||
{
|
||
if (IsEmpty(widItem.aryItem))
|
||
return eDoorTypeNum;
|
||
|
||
return widItem.aryItem[0]->eDoorWinType;
|
||
}
|
||
void TreeItemSameName::SetSlideType2d(CString style)
|
||
{
|
||
TDPtrList<AcDbObjectId> idLst;
|
||
|
||
SetWidItemSlide(&widItem, style, true);
|
||
widItem.GetIdAry(idLst);
|
||
|
||
UpdateGraphicAny(idLst);
|
||
actrTransactionManager->flushGraphics();
|
||
acedUpdateDisplay();
|
||
}
|
||
void TreeItemSameName::SetSlideType3d(CString style)
|
||
{
|
||
TDPtrList<AcDbObjectId> idLst;
|
||
|
||
SetWidItemSlide(&widItem, style, false);
|
||
widItem.GetIdAry(idLst);
|
||
|
||
UpdateGraphicAny(idLst);
|
||
actrTransactionManager->flushGraphics();
|
||
acedUpdateDisplay();
|
||
}
|
||
|
||
EEntType GridItemOneItem::GetEntType() const
|
||
{
|
||
return eEntType;
|
||
}
|
||
void GridItemOneItem::SetSlideType2d(CString style)
|
||
{
|
||
SetEntSlide(pItem->aryId[nIndex], pItem->aryProp[nIndex], style, true);
|
||
|
||
TDPtrList<AcDbObjectId> idLst;
|
||
idLst.Append(new AcDbObjectId(pItem->aryId[nIndex]));
|
||
|
||
UpdateGraphicAny(idLst);
|
||
actrTransactionManager->flushGraphics();
|
||
acedUpdateDisplay();
|
||
}
|
||
void GridItemOneItem::SetSlideType3d(CString style)
|
||
{
|
||
SetEntSlide(pItem->aryId[nIndex], pItem->aryProp[nIndex], style, false);
|
||
TDPtrList<AcDbObjectId> idLst;
|
||
idLst.Append(new AcDbObjectId(pItem->aryId[nIndex]));
|
||
|
||
UpdateGraphicAny(idLst);
|
||
actrTransactionManager->flushGraphics();
|
||
acedUpdateDisplay();
|
||
}
|
||
//////////////////////////////////////////////////////////////////////////
|
||
|
||
|
||
//////////////////////////////////////////////////////////////////////////
|
||
// CDoorWinGrid;
|
||
IMPLEMENT_DYNCREATE(CPropGrid, WDGrid)
|
||
|
||
BEGIN_MESSAGE_MAP(CPropGrid, WDGrid)
|
||
END_MESSAGE_MAP()
|
||
|
||
void CPropGrid::RemoveAllItem()
|
||
{
|
||
Clear();
|
||
while(GetColNum() > 0)
|
||
DelCol(GetColNum()-1);
|
||
}
|
||
|
||
void CPropGrid::ReCreate(TreeItemData *pItemData)
|
||
{
|
||
// ASSERT(pItemData != NULL);
|
||
|
||
RemoveAllItem();
|
||
pFrame->ClearSlideItem();
|
||
if (pItemData == NULL)
|
||
return;
|
||
switch (pItemData->GetType())
|
||
{
|
||
case eProj:
|
||
{ // 本工程,本图,冲突,未创建工程
|
||
CreateProj((TreeItemProj*)pItemData);
|
||
}
|
||
break;
|
||
case eDWG:
|
||
{ // 本工程,本图,冲突,未创建工程
|
||
CreateDWG((TreeItemDWG*)pItemData);
|
||
}
|
||
break;
|
||
case eNoProj:
|
||
{ // 本工程,本图,冲突,未创建工程
|
||
CreateNoProj((TreeItemNoProj*)pItemData);
|
||
}
|
||
break;
|
||
case eConflict:
|
||
{ // 本工程,本图,冲突,未创建工程
|
||
CreateConflict((TreeItemConflict*)pItemData);
|
||
}
|
||
break;
|
||
case eFloor:
|
||
{ // 本楼层
|
||
CreateFloor((TreeItemFloor*)pItemData);
|
||
}
|
||
break;
|
||
case eSameStyle:
|
||
{ // 某类型
|
||
CreateOneStyle((TreeItemSameStyle*)pItemData);
|
||
}
|
||
break;
|
||
case eSameName:
|
||
{ // 某名字
|
||
CreateOneName((TreeItemSameName*)pItemData);
|
||
}
|
||
break;
|
||
default:
|
||
ASSERT(0);
|
||
break;
|
||
}
|
||
}
|
||
|
||
void CPropGrid::CreateProj(TreeItemProj *pItem)
|
||
{
|
||
ASSERT(pItem != NULL);
|
||
|
||
AryEtype aryEType; // 工程中包含的门窗类型
|
||
AryEShowItem aryEShowItem; // 需要显示属性
|
||
pItem->pTable->FindETypeProj(aryEType);
|
||
if (NDoorWinCheck::IsEmpty(aryEType))
|
||
return;
|
||
SetGridColumn(aryEType, aryEShowItem);
|
||
|
||
if (pItem->bNeedFloor)
|
||
{ // 分楼层:
|
||
for (int iFloor = 0; iFloor < pItem->pTable->GetFloorNum(); iFloor++)
|
||
{ // 添加楼层
|
||
CGroup *pFloor = pItem->pTable->GetFloor(iFloor);
|
||
if (pFloor == NULL)
|
||
continue;
|
||
|
||
WDGridTreeRow *pNewRow = AddNewRow(NULL);
|
||
TreeItemData *pExtendData = new TreeItemFloor;
|
||
pNewRow->SetExtendData(pExtendData);
|
||
(*pNewRow)[0].SetText(pFloor->GetFloorName());
|
||
|
||
for (int iType = 0; iType < eDoorTypeNum; iType++)
|
||
{
|
||
AryWidItemPtr aryWidItem;
|
||
ItemPtrAry2Wid(pFloor->GetItemAry(EEntType(iType)), aryWidItem);
|
||
AddSameTypeItem(aryWidItem, EEntType(iType), pNewRow, aryEShowItem);
|
||
ClearAryWidItemPtr(aryWidItem);
|
||
}
|
||
} // end添加楼层
|
||
} // if (pItem->bNeedFloor)
|
||
else
|
||
{ // 不分楼层
|
||
AryWidItemPtr doors[eDoorTypeNum];
|
||
pItem->pTable->GetDataPNf(doors);
|
||
for (int iType = 0; iType < eDoorTypeNum; iType++)
|
||
{ // 添加门窗的类型列, 门,窗,弧窗...
|
||
AddSameTypeItem(doors[iType], EEntType(iType), NULL, aryEShowItem);
|
||
ClearAryWidItemPtr(doors[iType]);
|
||
} // 结束门窗类型列的添加
|
||
}
|
||
}
|
||
|
||
// 显示本图
|
||
void CPropGrid::CreateDWG(TreeItemDWG *pItem)
|
||
{
|
||
ASSERT(pItem != NULL);
|
||
|
||
AryEtype aryEType; // 工程中包含的门窗类型
|
||
AryEShowItem aryEShowItem; // 需要显示属性
|
||
pItem->pTable->FindETypeDwg(aryEType);
|
||
if (NDoorWinCheck::IsEmpty(aryEType))
|
||
return;
|
||
SetGridColumn(aryEType, aryEShowItem);
|
||
|
||
// 考虑是全部本图的,还是仅仅工程内本图的
|
||
if (pItem->bOnlyProj) // 工程内本图
|
||
{
|
||
if (pItem->bNeedFloor)
|
||
{ // 分楼层:
|
||
for (int iFloor = 0; iFloor < pItem->pTable->GetFloorNum(); iFloor++)
|
||
{ // 添加楼层
|
||
CGroup *pFloor = pItem->pTable->GetFloor(iFloor);
|
||
if (pFloor == NULL || !pFloor->IsCurrDoc())
|
||
continue;
|
||
|
||
WDGridTreeRow *pNewRow = AddNewRow(NULL);
|
||
TreeItemData *pExtendData = new TreeItemFloor;
|
||
pNewRow->SetExtendData(pExtendData);
|
||
(*pNewRow)[0].SetText(pFloor->GetFloorName());
|
||
|
||
for (int iType = 0; iType < eDoorTypeNum; iType++)
|
||
{
|
||
AryWidItemPtr aryWidItem;
|
||
ItemPtrAry2Wid(pFloor->GetItemAry(EEntType(iType)), aryWidItem);
|
||
AddSameTypeItem(aryWidItem, EEntType(iType), pNewRow, aryEShowItem);
|
||
ClearAryWidItemPtr(aryWidItem);
|
||
}
|
||
} // end添加楼层
|
||
} // if (pItem->bNeedFloor)
|
||
else
|
||
{ // 不分楼层
|
||
AryWidItemPtr doors[eDoorTypeNum];
|
||
pItem->pTable->GetCurrDPNf(doors);
|
||
for (int iType = 0; iType < eDoorTypeNum; iType++)
|
||
{ // 添加门窗的类型列, 门,窗,弧窗...
|
||
AddSameTypeItem(doors[iType], EEntType(iType), NULL, aryEShowItem);
|
||
ClearAryWidItemPtr(doors[iType]);
|
||
} // 结束门窗类型列的添加
|
||
}
|
||
}
|
||
else
|
||
{ // 全部本图:
|
||
AryWidItemPtr doors[eDoorTypeNum];
|
||
pItem->pTable->GetDataDNpNf(doors); // 全部本图的数据
|
||
for (int iType = 0; iType < eDoorTypeNum; iType++)
|
||
{ // 添加门窗的类型列, 门,窗,弧窗...
|
||
AddSameTypeItem(doors[iType], EEntType(iType), NULL, aryEShowItem);
|
||
ClearAryWidItemPtr(doors[iType]);
|
||
} // 结束门窗类型列的添加
|
||
}
|
||
|
||
}
|
||
void CPropGrid::CreateNoProj(TreeItemNoProj *pItem)
|
||
{
|
||
ASSERT(pItem != NULL);
|
||
|
||
AryEtype aryEType; // 工程中包含的门窗类型
|
||
AryEShowItem aryEShowItem; // 需要显示属性
|
||
pItem->pTable->FindETypeNoProj(aryEType);
|
||
if (NDoorWinCheck::IsEmpty(aryEType))
|
||
return;
|
||
SetGridColumn(aryEType, aryEShowItem);
|
||
|
||
{ // 不分楼层
|
||
AryWidItemPtr doors[eDoorTypeNum];
|
||
pItem->pTable->GetDataNp(doors);
|
||
for (int iType = 0; iType < eDoorTypeNum; iType++)
|
||
{ // 添加门窗的类型列, 门,窗,弧窗...
|
||
AddSameTypeItem(doors[iType], EEntType(iType), NULL, aryEShowItem);
|
||
ClearAryWidItemPtr(doors[iType]);
|
||
} // 结束门窗类型列的添加
|
||
}
|
||
}
|
||
void CPropGrid::CreateConflict(TreeItemConflict *pItem)
|
||
{
|
||
ASSERT(pItem != NULL);
|
||
|
||
// 冲突一共分为四种情况:
|
||
AryWidItemPtr doors[eDoorTypeNum];
|
||
if (pItem->nType == eConflictProj)
|
||
{
|
||
pItem->pTable->GetConflictProj(doors);
|
||
}
|
||
else if (pItem->nType == eConflictNoProj)
|
||
{
|
||
pItem->pTable->GetConflictNoProj(doors);
|
||
}
|
||
else if (pItem->nType == eConflictProjDWG)
|
||
{
|
||
pItem->pTable->GetConflictDP(doors);
|
||
}
|
||
else
|
||
{ // eConflictDWG,本图全部冲突
|
||
pItem->pTable->GetConflictDNp(doors);
|
||
}
|
||
|
||
AryEtype aryEType; // 工程中包含的门窗类型
|
||
AryEShowItem aryEShowItem; // 需要显示属性
|
||
CDataTable::FindEType(doors, aryEType);
|
||
|
||
if (NDoorWinCheck::IsEmpty(aryEType))
|
||
return;
|
||
SetGridColumn(aryEType, aryEShowItem);
|
||
|
||
{ // 不分楼层
|
||
for (int iType = 0; iType < eDoorTypeNum; iType++)
|
||
{ // 添加门窗的类型列, 门,窗,弧窗...
|
||
AddSameTypeItem(doors[iType], EEntType(iType), NULL, aryEShowItem);
|
||
ClearAryWidItemPtr(doors[iType]);
|
||
} // 结束门窗类型列的添加
|
||
}
|
||
}
|
||
void CPropGrid::CreateFloor(TreeItemFloor *pItem)
|
||
{
|
||
ASSERT(pItem != NULL);
|
||
|
||
AryEtype aryEType; // 工程中包含的门窗类型
|
||
AryEShowItem aryEShowItem; // 需要显示属性
|
||
pItem->pFloor->FindEType(aryEType);
|
||
|
||
if (NDoorWinCheck::IsEmpty(aryEType))
|
||
return;
|
||
SetGridColumn(aryEType, aryEShowItem);
|
||
|
||
{ // 不分楼层
|
||
for (int iType = 0; iType < eDoorTypeNum; iType++)
|
||
{ // 添加门窗的类型列, 门,窗,弧窗...
|
||
AryWidItemPtr aryWidItemPtr;
|
||
ItemPtrAry2Wid(pItem->pFloor->GetItemAry(EEntType(iType)), aryWidItemPtr);
|
||
AddSameTypeItem(aryWidItemPtr, EEntType(iType), NULL, aryEShowItem);
|
||
ClearAryWidItemPtr(aryWidItemPtr);
|
||
} // 结束门窗类型列的添加
|
||
}
|
||
}
|
||
|
||
|
||
void CPropGrid::CreateOneStyle(TreeItemSameStyle *pItem)
|
||
{
|
||
ASSERT(pItem != NULL);
|
||
|
||
AryEtype aryEType; // 工程中包含的门窗类型
|
||
AryEShowItem aryEShowItem; // 需要显示属性
|
||
FindEType(pItem->aryWidItemPtr, aryEType);
|
||
if (aryEType.GetSize() != 1)
|
||
return;
|
||
|
||
SetGridColumn(aryEType, aryEShowItem);
|
||
|
||
{ // 不分楼层
|
||
AddSameTypeItem(pItem->aryWidItemPtr, aryEType[0], NULL, aryEShowItem, FALSE);
|
||
}
|
||
}
|
||
|
||
|
||
void CPropGrid::CreateOneName(TreeItemSameName *pItem)
|
||
{
|
||
ASSERT(pItem != NULL);
|
||
|
||
AryEtype aryEType; // 工程中包含的门窗类型
|
||
AryEShowItem aryEShowItem; // 需要显示属性
|
||
FindEType(&pItem->widItem, aryEType);
|
||
if (aryEType.GetSize() != 1)
|
||
return;
|
||
|
||
SetGridColumn(aryEType, aryEShowItem);
|
||
|
||
{ // 不分楼层
|
||
AddSameNameItem(&pItem->widItem, NULL, aryEShowItem);
|
||
}
|
||
|
||
// 当创建同名标注的时候,展开这些项。便于观察
|
||
WDGridRow &pRow = GetRow(0);
|
||
WDGridTreeRow *pTreeRow = (WDGridTreeRow*)(&pRow);
|
||
pTreeRow->UnFold();
|
||
}
|
||
|
||
WDGridTreeRow* CPropGrid::AddNewRow(WDGridTreeRow *pParentRow)
|
||
{
|
||
WDGridTreeRow* pRowItem = NULL;
|
||
if (pParentRow != NULL)
|
||
{
|
||
pRowItem = new WDGridTreeRow(pParentRow); // 添加一个属性
|
||
pParentRow->AppendChild(pRowItem);
|
||
}
|
||
else
|
||
{
|
||
// 这里不应该进来
|
||
pRowItem = new WDGridTreeRow(*this);
|
||
AppendRow(pRowItem);
|
||
}
|
||
|
||
return pRowItem;
|
||
}
|
||
|
||
bool CPropGrid::AddSingleItem(CItem* pItem, int index, WDGridTreeRow *pParentRow,
|
||
AryEShowItem &aryShowItem, int nEntIndex, CStringArray &aryProp)
|
||
{
|
||
if (!IsCheckText() && pItem->aryProp[index].bText)
|
||
{
|
||
return false;
|
||
}
|
||
|
||
WDGridTreeRow *pRowItem = AddNewRow(pParentRow);
|
||
aryProp.RemoveAll();
|
||
aryProp.SetSize(aryShowItem.GetSize());
|
||
|
||
GridItemOneItem *pGridItem = new GridItemOneItem;
|
||
pGridItem->eEntType = pItem->eDoorWinType;
|
||
pGridItem->pItem = pItem;
|
||
pGridItem->nIndex = index;
|
||
pRowItem->SetExtendData(pGridItem);
|
||
|
||
// 编号
|
||
CString sLabelTemp;
|
||
sLabelTemp.Format(_T("(%d)%s"), nEntIndex, pItem->strLabel);
|
||
(*pRowItem)[0].SetText(sLabelTemp);
|
||
|
||
//add by lgy 20120228 从dwg中读取的参照中的实体,在grid中显示时仍然能编辑,实际要求不能编辑
|
||
if (pItem->aryProp[index].bExternBlock)
|
||
{
|
||
pRowItem->SetReadOnly(true);
|
||
}
|
||
|
||
// 根据当前需要显示的属性,把这些数据填入进去
|
||
for (int iShowType = eNewLabelIndex; iShowType < (int)aryShowItem.GetSize(); iShowType++)
|
||
{
|
||
EShowItem eShowItem = aryShowItem[iShowType];
|
||
if (pItem->eDoorWinType == eTC && eShowItem == eTypeProp)
|
||
eShowItem = eGeoTypeProp;
|
||
|
||
// if (CSetDlg::TestHasShowParam(pItem->eDoorWinType, eShowItem))
|
||
if (TestHasShowItem(pItem->eDoorWinType, pItem->aryProp[index].bText, eShowItem))
|
||
{
|
||
CString strShow = PropToString(pItem->aryProp[index], eShowItem);
|
||
(*pRowItem)[iShowType].SetText(strShow);
|
||
|
||
if (aryProp[iShowType].IsEmpty())
|
||
{
|
||
aryProp[iShowType] = strShow;
|
||
}
|
||
else
|
||
{
|
||
if (aryProp[iShowType].CompareNoCase(strShow) != 0)
|
||
{
|
||
aryProp[iShowType] = _T("冲突");
|
||
}
|
||
}
|
||
|
||
|
||
if (pItem->eDoorWinType == eZJC)
|
||
{ // 转角窗:
|
||
if (GetShowItemIndex(iShowType) == eWidProp)
|
||
(*pRowItem)[iShowType].SetReadOnly(true);
|
||
else if (!pItem->aryProp[index].bZJCTuChuang && GetShowItemIndex(iShowType) == eChutiaoProp)
|
||
{
|
||
(*pRowItem)[iShowType].SetReadOnly(true);
|
||
}
|
||
}
|
||
else if (pItem->eDoorWinType == eDXC)
|
||
{ // 带型窗
|
||
if (GetShowItemIndex(iShowType) == eWidProp)
|
||
(*pRowItem)[iShowType].SetReadOnly(true);
|
||
}
|
||
else if (pItem->eDoorWinType == eTC)
|
||
{
|
||
if (GetShowItemIndex(iShowType) == eTixingkuanProp)
|
||
{
|
||
if (pItem->aryProp[index].eProWinGeo != XBayWindow::BWS_TRAPEZIA)
|
||
{
|
||
(*pRowItem)[iShowType].SetText(_T(""));
|
||
(*pRowItem)[iShowType].SetReadOnly(true);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
else
|
||
{
|
||
(*pRowItem)[iShowType].SetReadOnly(true);
|
||
}
|
||
}
|
||
|
||
return true;
|
||
}
|
||
|
||
void CPropGrid::AddSameNameItem(CWidItem* pWidItem, WDGridTreeRow *pParentRow,
|
||
AryEShowItem &aryShowItem)
|
||
{
|
||
ASSERT(pWidItem != NULL);
|
||
if (pWidItem->GetEntNum(IsCheckText(), IsCheckBlock()) < 1)
|
||
return;
|
||
|
||
WDGridTreeRow *pRowSameName = AddNewRow(pParentRow);
|
||
TreeItemSameName *pItemDataSameName = new TreeItemSameName;
|
||
pItemDataSameName->widItem.CopyFrom(*pWidItem);
|
||
pRowSameName->SetExtendData(pItemDataSameName);
|
||
|
||
CStringArray aryItems; // 主编号的数据
|
||
aryItems.SetSize(aryShowItem.GetSize()); // 显示项的数目+编号+新编号;
|
||
aryItems[0] = pWidItem->GetItemName(IsCheckText(), IsCheckBlock());
|
||
int nEntIndex = 1;
|
||
for (int iItemAry = 0; iItemAry < (int)pWidItem->aryItem.GetSize(); iItemAry++)
|
||
{
|
||
CItem *pItem = pWidItem->aryItem[iItemAry];
|
||
for (int iItemIndex = 0; iItemIndex < (int)pItem->aryId.length(); iItemIndex++)
|
||
{
|
||
CStringArray aryProp;
|
||
if (!IsCheckText() && pItem->aryProp[iItemIndex].bText)
|
||
continue;
|
||
if (!IsCheckBlock() && pItem->aryProp[iItemIndex].bBlock)
|
||
continue;
|
||
//modify by lgy 20120228 注释的原因是即使是同名的块参照存在图纸中一个或者多个
|
||
//都要显示在wdgrid的子树中
|
||
// if (pWidItem->TestRepeatBlock(iItemAry, iItemIndex))
|
||
// continue;
|
||
|
||
if (!AddSingleItem(pItem, iItemIndex, pRowSameName, aryShowItem, nEntIndex, aryProp))
|
||
continue;
|
||
|
||
nEntIndex++;
|
||
for (int iProp = 1; iProp < (int)aryProp.GetSize(); iProp++)
|
||
{
|
||
if (aryItems[iProp].IsEmpty())
|
||
{
|
||
aryItems[iProp] = aryProp[iProp];
|
||
}
|
||
else
|
||
{
|
||
if (aryItems[iProp].CompareNoCase(aryProp[iProp]) != 0)
|
||
{
|
||
aryItems[iProp] = _T("冲突");
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
// 添加他的属性
|
||
for (int i = 0; i < (int)aryItems.GetSize(); i++)
|
||
{
|
||
(*pRowSameName)[i].SetText(aryItems[i]);
|
||
if (i > 2 && !NDoorWinCheck::IsEmpty(pWidItem->aryItem))
|
||
{
|
||
if (!CSetDlg::TestHasShowParam(pWidItem->aryItem[0]->eDoorWinType, GetShowItemIndex(i)))
|
||
{
|
||
(*pRowSameName)[i].SetReadOnly(true);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
void CPropGrid::AddSameTypeItem(AryWidItemPtr &aryWidItemPtr, EEntType eEntType, WDGridTreeRow *pParent,
|
||
AryEShowItem &aryShowItem, BOOL bShowType)
|
||
{
|
||
CDoorWinTreeView::SortWidItemAry(aryWidItemPtr);
|
||
|
||
// if (NDoorWinCheck::IsEmpty(aryWidItemPtr))
|
||
if (NDoorWinCheck::TestItemEmpty(aryWidItemPtr, IsCheckText(), IsCheckBlock()))
|
||
return;
|
||
|
||
WDGridTreeRow *pTypeRow = NULL;
|
||
if (bShowType)
|
||
{
|
||
pTypeRow = AddNewRow(pParent);
|
||
TreeItemSameStyle *pStyleData = new TreeItemSameStyle;
|
||
pTypeRow->SetExtendData(pStyleData);
|
||
(*pTypeRow)[0].SetText(Type2Name(eEntType));
|
||
pTypeRow->SetReadOnly(true);
|
||
}
|
||
|
||
for (int i = 0; i < (int)aryWidItemPtr.GetSize(); i++)
|
||
{
|
||
AddSameNameItem(aryWidItemPtr[i], bShowType ? pTypeRow : NULL, aryShowItem);
|
||
}
|
||
}
|
||
|
||
BOOL CPropGrid::TestHasShowItem(EEntType eEntTyp, bool bText, EShowItem eShowItem)
|
||
{
|
||
BOOL bTypeHas = CSetDlg::TestHasShowParam(eEntTyp, eShowItem);
|
||
if (!bText)
|
||
{
|
||
return bTypeHas;
|
||
}
|
||
else
|
||
{
|
||
return bTypeHas && IsTextShowItem(eShowItem);
|
||
}
|
||
}
|
||
|
||
EShowItem CPropGrid::GetShowItemIndex(int nCol)
|
||
{
|
||
int nStart = 0;
|
||
for (int i = 0; i < eDoorWinParmNum; i++)
|
||
{
|
||
if (CSetDlg::TestItemIsSet(GetShowItem(EShowItem(i)), m_flagShowProp))
|
||
{
|
||
if (nStart == nCol)
|
||
return GetShowItem(EShowItem(i));
|
||
nStart++;
|
||
}
|
||
}
|
||
|
||
return eDoorWinParmNum; // 返回一个没有的属性,这个情况是不会走到的
|
||
}
|
||
|
||
bool CPropGrid::HasModifiedData()
|
||
{
|
||
// 备注:因为是树表格,存在折叠的情况,因此不能仅仅遍历表格中当前的所有行,
|
||
// 遍历所有行,从所有行中,找到最根的行,然后遍历他们的子节点
|
||
for (long i = 0; i < GetRowNum(); i++)
|
||
{
|
||
WDGridRow &rowTemp = GetRow(i);
|
||
|
||
if (!rowTemp.IsTreeRow())
|
||
continue;
|
||
|
||
WDGridTreeRow *pRow = (WDGridTreeRow*)(&rowTemp);
|
||
if (pRow->Parent() != NULL)
|
||
continue; // 不是根,则会由树的分支走到
|
||
|
||
if (HasModifiedData(pRow))
|
||
{
|
||
return true;
|
||
}
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
bool CPropGrid::HasModifiedData(WDGridTreeRow *pRow)
|
||
{
|
||
if (pRow == NULL)
|
||
return false;
|
||
|
||
TreeItemData *pItemData = (TreeItemData*)pRow->GetExtendData();
|
||
if (pItemData == NULL)
|
||
return false;
|
||
|
||
if (pItemData->GetType() == eOneItem)
|
||
{
|
||
GridItemOneItem *pOneItem = (GridItemOneItem*)pItemData;
|
||
|
||
for (long iCol = 1; iCol < GetColNum(); iCol++)
|
||
{
|
||
CString strOriProp = PropToString(pOneItem->pItem->aryProp[pOneItem->nIndex],
|
||
GetShowItemIndex(iCol));
|
||
if (strOriProp.CompareNoCase((*pRow)[iCol].GetText()) != 0)
|
||
return true;
|
||
}
|
||
}
|
||
|
||
for (long i = 0; i < pRow->GetChildNum(); i++)
|
||
{
|
||
WDGridTreeRow &childRow = pRow->GetChild(i);
|
||
bool bRet = HasModifiedData(&childRow);
|
||
if (bRet)
|
||
return true;
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
void CPropGrid::OnBeforeRefresh(WDGridCell&cell)
|
||
{
|
||
if (!ValidData())
|
||
return;
|
||
if (EmptyGrid())
|
||
{
|
||
WDGrid::OnBeforeRefresh(cell);
|
||
return ;
|
||
}
|
||
|
||
CDC&dc=GetDC();
|
||
COLORREF colorBack = RGB(255, 255, 255);
|
||
COLORREF colorText = RGB(0, 0, 0);
|
||
|
||
WDGridRow &row = cell.GetRow();
|
||
|
||
TreeItemData *pItemData = (TreeItemData*)row.GetExtendData();
|
||
if (pItemData == NULL)
|
||
{
|
||
WDGrid::OnBeforeRefresh(cell);
|
||
return;
|
||
}// eProj = 0, eDWG, eNoProj, eConflict, eFloor, eSameStyle, eSameName, eOneItem, eOther
|
||
else if (pItemData->GetType() == eOneItem)
|
||
{
|
||
// 还需要判断几个数据:
|
||
GridItemOneItem *pItemDataOneItem = (GridItemOneItem*)pItemData;
|
||
BOOL bSet = FALSE;
|
||
|
||
//add by lgy 20120305 如果子编号对应的实体如果是块参照或外部参照中实体时需要灰显
|
||
if (pItemDataOneItem->pItem->aryProp[pItemDataOneItem->nIndex].bExternBlock)
|
||
{
|
||
bSet = TRUE;
|
||
colorBack = eReadOnlyColor;
|
||
}
|
||
|
||
if (pItemDataOneItem->pItem->eDoorWinType == eZJC)
|
||
{ // 转角窗:
|
||
if (GetShowItemIndex(cell.GetColIndex()) == eWidProp)
|
||
{
|
||
bSet = TRUE;
|
||
colorBack = eReadOnlyColor;
|
||
}
|
||
else if (!pItemDataOneItem->pItem->aryProp[pItemDataOneItem->nIndex].bZJCTuChuang &&
|
||
GetShowItemIndex(cell.GetColIndex()) == eChutiaoProp)
|
||
{
|
||
bSet = TRUE;
|
||
colorBack = eReadOnlyColor;
|
||
}
|
||
}
|
||
else if (pItemDataOneItem->pItem->eDoorWinType == eDXC)
|
||
{ // 带型窗
|
||
if (GetShowItemIndex(cell.GetColIndex()) == eWidProp)
|
||
{
|
||
bSet = TRUE;
|
||
colorBack = eReadOnlyColor;
|
||
}
|
||
}
|
||
else if (pItemDataOneItem->pItem->eDoorWinType == eTC)
|
||
{
|
||
if (GetShowItemIndex(cell.GetColIndex()) == eTixingkuanProp)
|
||
{
|
||
if (pItemDataOneItem->pItem->aryProp[pItemDataOneItem->nIndex].eProWinGeo != XBayWindow::BWS_TRAPEZIA)
|
||
{
|
||
bSet = TRUE;
|
||
colorBack = eReadOnlyColor;
|
||
}
|
||
}
|
||
}
|
||
|
||
|
||
if (!bSet && pItemDataOneItem->pItem->pGroup->IsCurrDoc())
|
||
{ // 当前图
|
||
AcDbObjectId id = pItemDataOneItem->pItem->aryId[pItemDataOneItem->nIndex];
|
||
BOOL bModifyTest = FALSE;
|
||
|
||
if (!IsCADClosed())
|
||
{
|
||
OPENOBJ_BEGIN(id, AcDb::kForRead, AcDbEntity, pEnt)
|
||
if (pEnt == NULL) // 打不开了,认为是被删除了
|
||
{
|
||
colorBack = GetGridColor(eRemovedColor);
|
||
colorText = GetGridColor(eRemovedTextColor);
|
||
}
|
||
else
|
||
{ // 检测是否临时编号,或者被修改的数据
|
||
if (pItemDataOneItem->pItem->aryProp[pItemDataOneItem->nIndex].strLabel.IsEmpty()
|
||
&& cell.GetColIndex() == 0) // 编号项
|
||
{ // 原始编号为空
|
||
colorText = GetGridColor(eTempLabelColor);
|
||
}
|
||
else
|
||
{ // 属性检测是否修改,如果修改则使用修改后的颜色
|
||
bModifyTest = TRUE;
|
||
}
|
||
}
|
||
OPENOBJ_END()
|
||
}
|
||
|
||
if (bModifyTest)
|
||
{
|
||
if (cell.GetColIndex() > 0)
|
||
{// 后面的这几个属性才是需要修改的
|
||
// 1、要知道该属性的类型
|
||
EShowItem eShowItem = GetShowItemIndex(cell.GetColIndex());
|
||
if (pItemDataOneItem->eEntType == eTC && eShowItem == eTypeProp)
|
||
eShowItem = eGeoTypeProp;
|
||
// 2、得到该属性的值
|
||
CString strValue = cell.GetText();
|
||
// 3、读取该数据,并且匹配对应的属性
|
||
if (!CSetDlg::TestHasShowParam(pItemDataOneItem->eEntType, eShowItem))
|
||
{
|
||
colorBack = GetGridColor(eOthersPropColor);
|
||
}
|
||
else
|
||
{
|
||
if (IsPropModify(id, eShowItem, strValue))
|
||
{
|
||
colorText = GetGridColor(eChangedColor);
|
||
}
|
||
else
|
||
{
|
||
WDGrid::OnBeforeRefresh(cell);
|
||
return;
|
||
}
|
||
}
|
||
}
|
||
else
|
||
{
|
||
WDGrid::OnBeforeRefresh(cell);
|
||
return;
|
||
}
|
||
}
|
||
}
|
||
else if (pItemData->GetType() == eOther)
|
||
{
|
||
colorBack = GetGridColor(eTypeColor);
|
||
}
|
||
else
|
||
{ // 其他图中的数据,灰显
|
||
colorBack = GetGridColor(eOtherDWGColor);
|
||
if (pItemDataOneItem->pItem->aryProp[pItemDataOneItem->nIndex].strLabel.IsEmpty()
|
||
&& cell.GetColIndex() == 0)
|
||
{
|
||
colorText = GetGridColor(eTempLabelColor);
|
||
}
|
||
}
|
||
}
|
||
else if (pItemData->GetType() == eFloor)
|
||
{
|
||
colorBack = GetGridColor(eFloorColor);
|
||
}
|
||
else if (pItemData->GetType() == eSameName)
|
||
{
|
||
//modify by lgy 20120305 主编号颜色修改成浅蓝色,为了跟其它只读子编号颜色区分
|
||
// 主编号背景色
|
||
//colorBack = GetGridColor(eMainLabelColor);
|
||
colorBack = RGB(51, 102, 205);
|
||
|
||
CString strCell = cell.GetText();
|
||
if (strCell.CompareNoCase(_T("冲突")) == 0)
|
||
colorText = GetGridColor(eRedConflictColor);
|
||
}
|
||
else if (pItemData->GetType() == eSameStyle)
|
||
{ // 类型
|
||
colorBack = GetGridColor(eTypeColor);
|
||
}
|
||
else
|
||
{
|
||
WDGrid::OnBeforeRefresh(cell);
|
||
return;
|
||
}
|
||
|
||
dc.SetBkColor(colorBack);
|
||
dc.SetTextColor(colorText);
|
||
dc.SetBkMode(TRANSPARENT);
|
||
}
|
||
|
||
|
||
void CPropGrid::SetGridColumn(AryEtype &aryEtype, AryEShowItem &aryEShowItem)
|
||
{
|
||
//add by lgy 20120416 每次重启软件后要记录上次退出之前设置的门窗检查参数
|
||
CSetDlg::LoadCurDoorMsg();
|
||
|
||
AryEShowItem aryEShowItemDump;
|
||
DWORD flagCheck = CSetDlg::GetCheckFlag(aryEtype, aryEShowItemDump);
|
||
if (CSetDlg::CheckParamFlag(flagCheck, eGeoTypeProp))
|
||
{
|
||
// 取消掉型式这一列,换成类型
|
||
CSetDlg::SetParamFlag(flagCheck, eTypeProp, TRUE);
|
||
CSetDlg::SetParamFlag(flagCheck, eGeoTypeProp, FALSE);
|
||
|
||
for (int i = 0; i < eDoorWinParmNum; i++)
|
||
{
|
||
if (CSetDlg::TestItemIsSet(GetShowItem(EShowItem(i)), flagCheck))
|
||
aryEShowItem.Add(GetShowItem(EShowItem(i)));
|
||
}
|
||
}
|
||
else
|
||
{
|
||
aryEShowItem.Append(aryEShowItemDump);
|
||
}
|
||
m_flagShowProp = flagCheck;
|
||
|
||
// 列设置
|
||
for (int index1 = 0; index1 < (int)aryEShowItem.GetSize(); index1++)
|
||
{
|
||
CString strTemp = ParamTypeToString(aryEShowItem[index1]);
|
||
if (aryEShowItem[index1] == eLabelProp)
|
||
AppendCol(strTemp, 100);
|
||
else
|
||
AppendCol(strTemp, 50);
|
||
}
|
||
|
||
GetCol(0).SetReadOnly(true);// (编号列)第一列只读
|
||
}
|
||
|
||
void CPropGrid::UpdateDWG()
|
||
{
|
||
TDPtrList<AcDbObjectId> ss;
|
||
for (long i = 0; i < GetRowNum(); i++)
|
||
{
|
||
WDGridRow &row = GetRow(i);
|
||
if (g_pData != NULL && g_pData->m_pDataTable != NULL)
|
||
g_pData->m_pDataTable->MakeDataOld();
|
||
|
||
TreeItemData *pItemTemp = (TreeItemData*)row.GetExtendData();
|
||
if ((pItemTemp == NULL) || (pItemTemp->GetType() != eOneItem))
|
||
continue;
|
||
|
||
GridItemOneItem *pItem = (GridItemOneItem*)pItemTemp;
|
||
AcDbObjectId id = pItem->pItem->aryId[pItem->nIndex];
|
||
SOpeningProp &sProp = pItem->pItem->aryProp[pItem->nIndex];
|
||
// 检测这个ID是否存在
|
||
bool bValid = id.isValid();
|
||
bool bErased = id.isErased();
|
||
if (bValid && !bErased)
|
||
{ // 有效的,并且当前图的
|
||
// 注意:在对一个某个Id写打开之前,需要确保锁定该文档,操作之后解锁
|
||
// 否则会产生eLockViolation打开错误
|
||
acDocManager->lockDocument(curDoc(),AcAp::kWrite,NULL,NULL,true);
|
||
//modify by lgy 20120229 打开上华实体对象为了方便以下改变实体样式
|
||
//OPENOBJ_BEGIN(id, AcDb::kForWrite, AcDbEntity, pEnt)
|
||
OPENOBJ_BEGIN(id, AcDb::kForWrite, TDbEntity, pEnt)
|
||
if (pEnt == NULL)
|
||
{
|
||
acDocManager->unlockDocument(curDoc());
|
||
continue;
|
||
}
|
||
|
||
//add by lgy 20120229 同时更新对话框选中的实体的样式到图纸实体中
|
||
UpdateEntStyle(pEnt, sProp.pItem->eDoorWinType, sProp.str2DShowStyle, true);
|
||
UpdateEntStyle(pEnt, sProp.pItem->eDoorWinType, sProp.str3DShowStyle, false);
|
||
|
||
AryEShowItem aryShowType;
|
||
CStringArray aryPropString;
|
||
long iCol;
|
||
// 包括编号也要执行更新
|
||
for (iCol = 1; iCol < GetColNum(); iCol++)
|
||
{
|
||
if ((pItem->eEntType == eTC && GetShowItemIndex(iCol) == eTypeProp) ||
|
||
CSetDlg::TestHasShowParam(pItem->eEntType, GetShowItemIndex(iCol)))
|
||
{
|
||
aryShowType.Add(GetShowItemIndex(iCol));
|
||
aryPropString.Add(row[iCol].GetText());
|
||
SetPropData(sProp, GetShowItemIndex(iCol), CString(row[iCol].GetText()));
|
||
}
|
||
}
|
||
|
||
UpdateProp2DWG(pEnt, pItem->eEntType, aryShowType, aryPropString);
|
||
|
||
ss.Append(new AcDbObjectId(id));
|
||
|
||
OPENOBJ_END()
|
||
|
||
acDocManager->unlockDocument(curDoc());
|
||
|
||
for (int iCol = 1; iCol < GetColNum(); iCol++)
|
||
{
|
||
row[iCol].Refresh();
|
||
}
|
||
}
|
||
}
|
||
|
||
UpdateGraphicAny(ss);
|
||
//
|
||
actrTransactionManager->flushGraphics();
|
||
acedUpdateDisplay();
|
||
}
|
||
|
||
void CPropGrid::RefreshGridContent()
|
||
{
|
||
// 备注:因为是树表格,存在折叠的情况,因此不能仅仅遍历表格中当前的所有行,
|
||
// 因为最外层的根节点肯定不会被折叠,遍历所有行,从所有行中,找到最根的行,然后遍历他们的子节点,
|
||
for (long i = 0; i < GetRowNum(); i++)
|
||
{
|
||
WDGridRow &rowTemp = GetRow(i);
|
||
|
||
if (!rowTemp.IsTreeRow())
|
||
continue;
|
||
|
||
WDGridTreeRow *pRow = (WDGridTreeRow*)(&rowTemp);
|
||
if (pRow->Parent() != NULL)
|
||
continue; // 不是根,则会由树的分支走到
|
||
|
||
RefreshGridTreeRow(pRow);
|
||
}
|
||
}
|
||
|
||
void CPropGrid::RefreshGridTreeRow(WDGridTreeRow *pRow)
|
||
{
|
||
if (pRow == NULL)
|
||
return;
|
||
|
||
TreeItemData *pItemData = (TreeItemData*)pRow->GetExtendData();
|
||
|
||
if (pItemData->GetType() == eSameName)
|
||
{
|
||
TreeItemSameName *pSameNameItem = (TreeItemSameName*)pItemData;
|
||
CWidItem *pWidItem = &(pSameNameItem->widItem);
|
||
for (long iCol = 1; iCol < (GetColNum()); iCol++)
|
||
{ // 所有的列
|
||
CString strItem = _T("");
|
||
for (int iItemAry = 0; iItemAry < (int)pWidItem->aryItem.GetSize(); iItemAry++)
|
||
{
|
||
CItem *pItem = pWidItem->aryItem[iItemAry];
|
||
for (int iItemIndex = 0; iItemIndex < (int)pItem->aryId.length(); iItemIndex++)
|
||
{
|
||
CString strTemp = PropToString(pItem->aryProp[iItemIndex], GetShowItemIndex(iCol));
|
||
if (strItem.IsEmpty())
|
||
{
|
||
strItem = strTemp;
|
||
}
|
||
else
|
||
{
|
||
if (strItem.CompareNoCase(strTemp) != 0)
|
||
strItem = _T("冲突");
|
||
}
|
||
}
|
||
}
|
||
(*pRow)[iCol].SetText(strItem);
|
||
|
||
}
|
||
}
|
||
else if (pItemData->GetType() == eOneItem)
|
||
{
|
||
GridItemOneItem *pOneItem = (GridItemOneItem*)pItemData;
|
||
|
||
for (long iCol = 1; iCol < GetColNum(); iCol++)
|
||
{
|
||
(*pRow)[iCol].SetText(PropToString(pOneItem->pItem->aryProp[pOneItem->nIndex],
|
||
GetShowItemIndex(iCol)));
|
||
}
|
||
}
|
||
|
||
for (long i = 0; i < pRow->GetChildNum(); i++)
|
||
{
|
||
WDGridTreeRow &childRow = pRow->GetChild(i);
|
||
RefreshGridTreeRow(&childRow);
|
||
}
|
||
}
|
||
|
||
bool CPropGrid::OnBeforeEdit(WDGridCell&cell,bool &bModified)
|
||
{
|
||
if (!ValidData())
|
||
return false;
|
||
if (EmptyGrid())
|
||
return false;
|
||
|
||
WDGridRow &row = cell.GetRow();
|
||
EShowItem eShowItem = GetShowItemIndex(cell.GetColIndex());
|
||
|
||
TreeItemData *pItemData = (TreeItemData *)row.GetExtendData();
|
||
if (pItemData->GetType() == eOneItem)
|
||
{
|
||
GridItemOneItem *pItemOneItem = (GridItemOneItem*)pItemData;
|
||
|
||
AcDbObjectId id = pItemOneItem->pItem->aryId[pItemOneItem->nIndex];
|
||
if (id.isValid() && !id.isErased())
|
||
{
|
||
OPENOBJ_BEGIN(id, AcDb::kForRead, AcDbEntity, pEnt)
|
||
{
|
||
if (pEnt == NULL)
|
||
return false;
|
||
}
|
||
OPENOBJ_END()
|
||
}
|
||
else
|
||
return false;
|
||
}
|
||
|
||
if (eShowItem == eWidProp)
|
||
{
|
||
if (pItemData->GetType() == eSameName)
|
||
{
|
||
TreeItemSameName *pSameNameItem = (TreeItemSameName*)pItemData;
|
||
if (pSameNameItem->GetEntType() == eZJC)
|
||
return false;
|
||
}
|
||
else if (pItemData->GetType() == eSameStyle)
|
||
{
|
||
TreeItemSameStyle *pStyle = (TreeItemSameStyle*)pItemData;
|
||
if (pStyle->GetEntType() == eZJC)
|
||
return false;
|
||
}
|
||
}
|
||
|
||
// 其他列的返回
|
||
if (eShowItem != eTypeProp)
|
||
{
|
||
return true;
|
||
}
|
||
|
||
//add by lgy 20120302 判断是否是主目录项,主目录项仍然要求可以显示门窗类型下拉列表
|
||
WDGridTreeRow *pTreeRow = (WDGridTreeRow*)&row;
|
||
if (pTreeRow->IsParentRow())
|
||
{
|
||
cell.GetCol().SetComboSel(true);
|
||
return true;
|
||
}
|
||
|
||
if (pItemData->GetType() == eOneItem)
|
||
{
|
||
GridItemOneItem *pItemOneItem = (GridItemOneItem*)pItemData;
|
||
|
||
if (pItemOneItem->eEntType == eTC ||
|
||
pItemOneItem->eEntType == eM ||
|
||
pItemOneItem->eEntType == eC ||
|
||
pItemOneItem->eEntType == eHC) // 凸窗
|
||
{
|
||
cell.GetCol().SetComboSel(true);
|
||
return true;
|
||
}
|
||
else return false;
|
||
|
||
}
|
||
else return false;
|
||
}
|
||
|
||
bool CPropGrid::OnModified(WDGridCell&cell,CString &text)
|
||
{
|
||
if (EmptyGrid())
|
||
return true;
|
||
|
||
WDGridRow &row = cell.GetRow();
|
||
EShowItem eShowItem = GetShowItemIndex(cell.GetColIndex());
|
||
|
||
if (cell.GetColIndex() == 1)
|
||
{ // 新编号
|
||
// 可以输入任意数值
|
||
}
|
||
else if (eShowItem == eEle)
|
||
{ // 底高
|
||
// 置空当做0处理,不能输入小于0的数
|
||
if (text.IsEmpty())
|
||
text = _T("0");
|
||
else
|
||
{
|
||
if (_ttoi(text) < 0)
|
||
{
|
||
MessageBox(_T("请输入大于等于0的数!"));
|
||
return false;
|
||
}
|
||
if (_ttoi(text) == 0)
|
||
text = _T("0");
|
||
}
|
||
}
|
||
else if (eShowItem == eTypeProp)
|
||
{
|
||
// 什么都可以。
|
||
}
|
||
else
|
||
{ // 其他
|
||
// 不能输入小于0的数
|
||
if (_ttoi(text) <= 0)
|
||
{
|
||
MessageBox(_T("请输入大于0的数!"));
|
||
return false;
|
||
}
|
||
}
|
||
|
||
TreeItemData *pItemData = (TreeItemData*)row.GetExtendData();
|
||
if (pItemData == NULL)
|
||
return true;
|
||
|
||
if (pItemData->GetType() == eSameName)
|
||
{ // 主编号数据的修改,连动修改子编号
|
||
if (row.IsTreeRow())
|
||
{
|
||
WDGridTreeRow *pTreeRow = (WDGridTreeRow*)&row;
|
||
if (pTreeRow->IsParentRow())
|
||
{
|
||
//add by lgy 20120302 为了实现改变主编号数据的时候相应的新编号项以及子项都跟着改变
|
||
// 新编号
|
||
CString strHead, strWid, strHei;
|
||
bool bModify = false; //保存是否联动修改子编号中新编号项, 默认不修改
|
||
if (eShowItem == eWidProp || eShowItem == eHeiProp || eShowItem == eTypeProp)
|
||
{
|
||
CString sNewLabel = (*pTreeRow)[1].GetText();
|
||
if (GetSize(sNewLabel, strHead, strHei, strWid))
|
||
{
|
||
// 补足四位长度。
|
||
CString strText = text;
|
||
while (strText.GetLength() < 4)
|
||
{
|
||
strText = _T("0") + strText;
|
||
}
|
||
strHei = (eShowItem == eHeiProp ? strText.Left(2) : strHei);
|
||
strWid = (eShowItem == eWidProp ? strText.Left(2) : strWid);
|
||
CString strType = GetItemSerial(text);
|
||
if (strType.GetLength() > 0)
|
||
{
|
||
strHead = strType;
|
||
}
|
||
(*pTreeRow)[1].SetText(strHead + strWid + strHei);
|
||
(*pTreeRow)[1].Refresh();
|
||
//add by lgy 20120413 主编号仍然需要更新
|
||
CString strText0 = (*pTreeRow)[0].GetText();
|
||
//modify by lgy 20120607 取字符串
|
||
//strText0 = strText0.Right(strText0.GetLength() - 5);
|
||
int nLocal = strText0.Find(_T("["));
|
||
strText0 = strText0.Right(strText0.GetLength()-nLocal);
|
||
|
||
(*pTreeRow)[0].SetText(strHead + strWid + strHei + strText0);
|
||
(*pTreeRow)[0].Refresh();
|
||
bModify = true;
|
||
}
|
||
}
|
||
|
||
for (long iTreeRow = 0; iTreeRow < pTreeRow->GetChildNum(); iTreeRow++)
|
||
{
|
||
WDGridTreeRow *pChildRow = &(pTreeRow->GetChild(iTreeRow));
|
||
if (pChildRow != NULL)
|
||
{
|
||
(*pChildRow)[cell.GetColIndex()].SetText(text);
|
||
(*pChildRow)[cell.GetColIndex()].Refresh();
|
||
//add by lgy 20120302 子编号中也需要跟着主编号更新数据
|
||
if (bModify)
|
||
{
|
||
(*pChildRow)[1].SetText(strHead + strWid + strHei);
|
||
(*pChildRow)[1].Refresh();
|
||
//add by lgy 20120413 新编号如果有变化,主编号应该跟着变化
|
||
CString strText0 = (*pChildRow)[0].GetText();
|
||
strText0 = strText0.Left(3);
|
||
(*pChildRow)[0].SetText(strText0 + strHead + strWid + strHei);
|
||
(*pChildRow)[0].Refresh();
|
||
}
|
||
//add by lgy 20120413 如果凸窗由梯形凸窗改为矩形凸窗之后梯形宽能否编辑有问题
|
||
if (eShowItem == eTypeProp)
|
||
{
|
||
for (int i = 3; i < GetColNum(); i++)
|
||
{
|
||
if (GetShowItemIndex(i) == eTixingkuanProp)
|
||
{
|
||
if (text == _T("梯形"))
|
||
{
|
||
(*pChildRow)[i].SetReadOnly(FALSE);
|
||
(*pTreeRow)[i].SetReadOnly(FALSE);
|
||
|
||
//add by lgy 20120607 如果为梯形,需要将主编号梯形宽设置到子编号中
|
||
(*pChildRow)[i].SetText((*pTreeRow)[i].GetText());
|
||
(*pChildRow)[i].Refresh();
|
||
}
|
||
else
|
||
{
|
||
(*pChildRow)[i].SetReadOnly(TRUE);
|
||
(*pTreeRow)[i].SetReadOnly(TRUE);
|
||
|
||
//add by lgy 20120607 如果不为梯形,子编号内容为空
|
||
(*pChildRow)[i].SetText(_T(""));
|
||
(*pChildRow)[i].Refresh();
|
||
}
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
else if (pItemData->GetType() == eOneItem)
|
||
{ // 单个编号的修改,确定
|
||
if (row.IsTreeRow())
|
||
{
|
||
WDGridTreeRow *pTreeRow = (WDGridTreeRow*)&row;
|
||
|
||
//modify by lgy 20120301 要加上如果改变了类型单元格,仍然需要修改新编号
|
||
//if (eShowItem == eWidProp || eShowItem == eHeiProp)
|
||
if (eShowItem == eWidProp || eShowItem == eHeiProp || eShowItem == eTypeProp)
|
||
{ // 新编号
|
||
CString strHead, strWid, strHei;
|
||
CString sNewLabel = (*pTreeRow)[1].GetText();
|
||
if (GetSize(sNewLabel, strHead, strHei, strWid))
|
||
{
|
||
// 补足四位长度。
|
||
CString strText = text;
|
||
while (strText.GetLength() < 4)
|
||
{
|
||
strText = _T("0") + strText;
|
||
}
|
||
strHei = (eShowItem == eHeiProp ? strText.Left(2) : strHei);
|
||
strWid = (eShowItem == eWidProp ? strText.Left(2) : strWid);
|
||
|
||
//add by lgy 20120301 要保证门窗类型也需要与编号实现联动
|
||
CString strType = GetItemSerial(text);
|
||
if (strType.GetLength() > 0)
|
||
{
|
||
strHead = strType;
|
||
}
|
||
|
||
(*pTreeRow)[1].SetText(strHead + strWid + strHei);
|
||
(*pTreeRow)[1].Refresh();
|
||
//add by lgy 20120413 如果修改了子编号,则相应的需要修改主编号
|
||
CString strText0 = (*pTreeRow)[0].GetText();
|
||
strText0 = strText0.Left(3);
|
||
(*pTreeRow)[0].SetText(strText0 +strHead + strWid + strHei);
|
||
(*pTreeRow)[0].Refresh();
|
||
}
|
||
}
|
||
|
||
//add by lgy 20120305 如果是梯形窗户,需要可以编辑梯形宽单元格
|
||
if (eShowItem == eTypeProp)
|
||
{
|
||
if (text == _T("梯形"))
|
||
{
|
||
for (int i = 3; i < GetColNum(); i++)
|
||
{
|
||
if (GetShowItemIndex(i) == eTixingkuanProp)
|
||
{
|
||
if (text == _T("梯形"))
|
||
{
|
||
(*pTreeRow)[i].SetReadOnly(FALSE);
|
||
}
|
||
else
|
||
{
|
||
(*pTreeRow)[i].SetReadOnly(TRUE);
|
||
}
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
//如果子编号只有一项,如果修改了子编号中的内容,则要同时修改其对应的主编号的内容
|
||
WDGridTreeRow &parentRow = pTreeRow->GetParent();
|
||
if (parentRow.GetChildNum() == 1)
|
||
{
|
||
parentRow[cell.GetColIndex()].SetText(text);
|
||
parentRow[cell.GetColIndex()].Refresh();
|
||
|
||
//add by lgy 20120606 如果主编号只有一个子项,改变子项内容后要修改主编号中的编号,新编号内容
|
||
CString strNewSerial;
|
||
strNewSerial = (*pTreeRow)[1].GetText();
|
||
parentRow[1].SetText(strNewSerial);
|
||
parentRow[1].Refresh();
|
||
|
||
CString strSerial = parentRow[0].GetText();
|
||
strSerial = strSerial.Right(3);
|
||
parentRow[0].SetText(strNewSerial+strSerial);
|
||
parentRow[0].Refresh();
|
||
}
|
||
}
|
||
}
|
||
return true;
|
||
}
|
||
|
||
void CPropGrid::OnDataChanged()
|
||
{
|
||
WDGrid::OnDataChanged();
|
||
if (HasModifiedData() && pFrame != NULL)
|
||
{
|
||
pFrame->SetTip(eCorrespondingTip, true);
|
||
}
|
||
else
|
||
{
|
||
pFrame->SetTip(eCorrespondingTip, false);
|
||
}
|
||
|
||
pFrame->ShowMessage();
|
||
}
|
||
|
||
|
||
void CPropGrid::OnCurChanged()
|
||
{
|
||
WDGrid::OnCurChanged();
|
||
// 查看当前的样式信息
|
||
if (GetCurRowIndex() != m_nCurRow && GetCurRowIndex() >= 0 && CSetDlg::IsShowImag())
|
||
{
|
||
WDGridRow &row = GetRow(GetCurRowIndex());
|
||
WDGridTreeRow *pRow = (WDGridTreeRow*)(&row);
|
||
TreeItemData *pItemData = (TreeItemData*)pRow->GetExtendData();
|
||
|
||
pFrame->SetSlideItem(pItemData);
|
||
if (pItemData == NULL)
|
||
{
|
||
pFrame->ClearSlideItem();
|
||
}
|
||
else if (pItemData->GetType() == eSameName)
|
||
{ // 检测如果没有冲突,则绘制
|
||
TreeItemSameName *pItemSameName = (TreeItemSameName*)pItemData;
|
||
if (!IsSlideType(pItemSameName->GetEntType()))
|
||
pFrame->ClearSlideItem();
|
||
else
|
||
{
|
||
pFrame->ShowSlide2d(pItemSameName->widItem.StyleString(TRUE));
|
||
pFrame->ShowSlide3d(pItemSameName->widItem.StyleString(FALSE));
|
||
}
|
||
}
|
||
else if (pItemData->GetType() == eSameStyle)
|
||
{
|
||
TreeItemSameStyle *pItemSameStyle = (TreeItemSameStyle*)pItemData;
|
||
AryWidItemPtr &aryWidItemPtr = pItemSameStyle->aryWidItemPtr;
|
||
|
||
if (IsSlideType(pItemSameStyle->GetEntType()))
|
||
{
|
||
CString strStyle2d = _T(""), strStyle3d = _T("");
|
||
int iWidItemIndex = 0;
|
||
for (iWidItemIndex = 0; iWidItemIndex < (int)aryWidItemPtr.GetSize(); iWidItemIndex++)
|
||
{
|
||
if (iWidItemIndex == 0)
|
||
{
|
||
strStyle2d = aryWidItemPtr[0]->StyleString(TRUE);
|
||
}
|
||
else if (strStyle2d.CompareNoCase(aryWidItemPtr[iWidItemIndex]->StyleString(TRUE)) != 0 )
|
||
{
|
||
strStyle2d = _T("");
|
||
break;
|
||
}
|
||
}
|
||
for (iWidItemIndex = 0; iWidItemIndex < (int)aryWidItemPtr.GetSize(); iWidItemIndex++)
|
||
{
|
||
if (iWidItemIndex == 0)
|
||
{
|
||
strStyle3d = aryWidItemPtr[0]->StyleString(FALSE);
|
||
}
|
||
else if (strStyle2d.CompareNoCase(aryWidItemPtr[iWidItemIndex]->StyleString(FALSE)) != 0 )
|
||
{
|
||
strStyle3d = _T("");
|
||
break;
|
||
}
|
||
}
|
||
|
||
pFrame->ShowSlide2d(strStyle2d);
|
||
pFrame->ShowSlide3d(strStyle3d);
|
||
}
|
||
else
|
||
pFrame->ClearSlideItem();
|
||
}
|
||
else if (pItemData->GetType() == eOneItem)
|
||
{
|
||
GridItemOneItem *pItem = (GridItemOneItem*)pItemData;
|
||
if (IsSlideType(pItem->eEntType))
|
||
{
|
||
pFrame->ShowSlide2d(pItem->pItem->aryProp[pItem->nIndex].str2DShowStyle);
|
||
pFrame->ShowSlide3d(pItem->pItem->aryProp[pItem->nIndex].str3DShowStyle);
|
||
}
|
||
else
|
||
{
|
||
pFrame->ClearSlideItem();
|
||
}
|
||
}
|
||
else
|
||
{
|
||
pFrame->ClearSlideItem();
|
||
}
|
||
}
|
||
|
||
// 移动到窗口中心,并且放大显示,或者仅仅移动实体到窗口中心
|
||
bool bBlockRet = false;
|
||
if (GetCurRowIndex() >= 0)
|
||
{
|
||
WDGridRow &row = GetRow(GetCurRowIndex());
|
||
WDGridTreeRow *pRow = (WDGridTreeRow*)(&row);
|
||
TreeItemData *pItemData = (TreeItemData*)pRow->GetExtendData();
|
||
if (pItemData != NULL && pItemData->GetType() == eOneItem)
|
||
{
|
||
GridItemOneItem *pOneItem = (GridItemOneItem*)pItemData;
|
||
AcDbObjectId id = pOneItem->pItem->aryId[pOneItem->nIndex];
|
||
bool bBlock = pOneItem->pItem->aryProp[pOneItem->nIndex].bBlock;
|
||
AcGePoint3d ptPosRef, ptBlkRecBase; // ref位置点,rec基点
|
||
AcGeMatrix3d matrixRef; // ref变换矩阵
|
||
bool bOneRef = false; // 只有一个引用
|
||
// 判断是否快内实体
|
||
if (bBlock)
|
||
{ // id -- >blockrec --> blockref -->matrix;
|
||
AcDbObjectId idBlock;
|
||
OPENOBJ_BEGIN(id, AcDb::kForRead, AcDbEntity, pEnt)
|
||
if (pEnt != NULL)
|
||
{
|
||
idBlock = pEnt->blockId();
|
||
}
|
||
OPENOBJ_END()
|
||
|
||
OPENOBJ_BEGIN(idBlock, AcDb::kForRead, AcDbBlockTableRecord, pBlkRec)
|
||
if (pBlkRec != NULL)
|
||
{
|
||
ptBlkRecBase = pBlkRec->origin();
|
||
AcDbObjectIdArray aryIdrefs;
|
||
//modify by lgy 20120228 如果同一个名字的块参照存在图纸中很多个
|
||
//仍然要求点取其中一个之后仍然会红框框选住选中的实体
|
||
//pBlkRec->getBlockReferenceIds(aryIdrefs);
|
||
//if (aryIdrefs.length() == 1)
|
||
pBlkRec->getBlockReferenceIds(aryIdrefs,false);
|
||
if (aryIdrefs.length() > 0)
|
||
{
|
||
//modify by lgy 20120228 为了显示出红框框选的实体是选中的,
|
||
//需要将打开的ID换成当前选中实体ID
|
||
//OPENOBJ_BEGIN(aryIdrefs[0], AcDb::kForRead, AcDbBlockReference, pBlkRef)
|
||
OPENOBJ_BEGIN(aryIdrefs[0], AcDb::kForRead, AcDbBlockReference, pBlkRef)
|
||
if (pBlkRef != NULL)
|
||
{
|
||
ptPosRef = pBlkRef->position();
|
||
matrixRef = pBlkRef->blockTransform();
|
||
bOneRef = true;
|
||
}
|
||
OPENOBJ_END() // end for block reference;
|
||
}
|
||
}
|
||
OPENOBJ_END() // end for block record
|
||
}
|
||
|
||
bBlockRet = (bBlockRet == bOneRef);
|
||
//modify by lgy 20120229 dwg参照中实体无法被定位
|
||
//if ((bBlock == bOneRef) && id.isValid() && id.database() == curDoc()->database() && !id.isErased())
|
||
if ((bBlock == bOneRef) && id.isValid() && !id.isErased())
|
||
{
|
||
OPENOBJ_BEGIN(id, AcDb::kForRead, AcDbEntity, pEnt)
|
||
if (pEnt == NULL)
|
||
return;
|
||
AcDbExtents extens;
|
||
pEnt->getGeomExtents(extens);
|
||
|
||
if (bBlock)
|
||
{
|
||
LGHTransform(extens, matrixRef, ptBlkRecBase, ptPosRef);
|
||
}
|
||
|
||
XPoint ptCent((extens.maxPoint().x + extens.minPoint().x)*0.5, (extens.maxPoint().y + extens.minPoint().y)*0.5);
|
||
if (CSetDlg::IsZoomDoorWin())
|
||
{ // 放缩显示
|
||
double dWidth = extens.maxPoint().x - extens.minPoint().x;
|
||
double dHei = extens.maxPoint().y - extens.minPoint().y;
|
||
const double dScale = 4.0; // 放缩比例,直接显示的话图形会充满整个窗口,不美观
|
||
ArxZoomTo(ptCent, dWidth *dScale, dHei * dScale);
|
||
}
|
||
else
|
||
{ // 仅仅移动实体到中心
|
||
NDoorWinCheck::MoveView(ptCent);
|
||
}
|
||
|
||
// 在实体周围绘制虚线框
|
||
XPoly2D poly;
|
||
poly.AppendNode(TADSGePoint3d(extens.minPoint()));
|
||
poly.AppendNode(TADSGePoint3d(extens.minPoint().x, extens.maxPoint().y, extens.minPoint().z));
|
||
poly.AppendNode(TADSGePoint3d(extens.maxPoint()));
|
||
poly.AppendNode(TADSGePoint3d(extens.maxPoint().x, extens.minPoint().y, extens.maxPoint().z));
|
||
poly.SetClosed();
|
||
poly.TransUCS(Groups(0), Groups(1));
|
||
|
||
RedDrawPoly(poly);
|
||
|
||
OPENOBJ_END()
|
||
}
|
||
}
|
||
}
|
||
|
||
// 准备提示信息
|
||
if (GetCurRowIndex() >= 0)
|
||
{
|
||
WDGridRow &row = GetRow(GetCurRowIndex());
|
||
WDGridTreeRow *pRow = (WDGridTreeRow*)(&row);
|
||
TreeItemData *pItemData = (TreeItemData*)pRow->GetExtendData();
|
||
if (pItemData != NULL && pItemData->GetType() == eOneItem)
|
||
{
|
||
GridItemOneItem *pOneItem = (GridItemOneItem*)pItemData;
|
||
pFrame->SetTip(eDataInOtherDWGTip, !pOneItem->pItem->pGroup->IsCurrDoc());
|
||
pFrame->SetTip(eBlockData, !bBlockRet);
|
||
pFrame->ShowMessage();
|
||
}
|
||
else
|
||
{
|
||
pFrame->SetTip(eDataInOtherDWGTip, false);
|
||
pFrame->SetTip(eBlockData, false);
|
||
pFrame->ShowMessage();
|
||
}
|
||
}
|
||
|
||
// 当前为空的时候,
|
||
if (GetCurRowIndex() < 0)
|
||
{ // 当前没有选择,
|
||
pFrame->SetTip(eDataInOtherDWGTip, false);
|
||
pFrame->SetTip(eBlockData, false);
|
||
pFrame->ShowMessage();
|
||
pFrame->ClearSlideItem();
|
||
}
|
||
}
|
||
|
||
|
||
// 准备combo中的数据
|
||
void CPropGrid::OnCellComboString(WDGridCell &cell,CComboBox&combo)
|
||
{
|
||
if (EmptyGrid())
|
||
{
|
||
WDGrid::OnBeforeRefresh(cell);
|
||
return ;
|
||
}
|
||
|
||
WDGridRow &row = cell.GetRow();
|
||
EShowItem eShowItem = GetShowItemIndex(cell.GetColIndex());
|
||
|
||
if (eShowItem != eTypeProp)
|
||
{
|
||
return;
|
||
}
|
||
|
||
TreeItemData *pItemData = (TreeItemData *)row.GetExtendData();
|
||
//modify by lgy 20120305 9.0要求主编号中的门窗类型需要可以编辑,并且是以下拉列表形式显示
|
||
//if (pItemData->GetType() == eOneItem)
|
||
if (pItemData->GetType() == eOneItem || pItemData->GetType() == eSameName)
|
||
{
|
||
GridItemOneItem *pItemOneItem = (GridItemOneItem*)pItemData;
|
||
CStringArray arSubType;
|
||
|
||
//add by lgy 20120305 主编号类型需要以下拉列表的形式能够编辑,修改的结果要同步到子编号中
|
||
TreeItemSameName *pSameName = (TreeItemSameName*)pItemData;
|
||
EEntType entSameNameType = pSameName->GetEntType();
|
||
|
||
//modify by lgy 20120305 修改一下if,else if是为了确定是否是主编号的门窗类型单元格
|
||
//if (pItemOneItem->eEntType == eTC) // 凸窗
|
||
if (pItemOneItem->eEntType == eTC || entSameNameType == eTC) // 凸窗
|
||
{
|
||
for (int i = XBayWindow::BWS_TRAPEZIA; i <= XBayWindow::BWS_RECT; i++)
|
||
{
|
||
combo.AddString(GeoType2String(XBayWindow::XBayWinStyle(i)));
|
||
}
|
||
}
|
||
//else if (pItemOneItem->eEntType == eM)
|
||
else if (pItemOneItem->eEntType == eM || entSameNameType == eM)
|
||
{
|
||
TOpeningLabelData().GetSubType(_T("Door"), arSubType);
|
||
}
|
||
//else if (pItemOneItem->eEntType == eC)
|
||
else if (pItemOneItem->eEntType == eC || entSameNameType == eC)
|
||
{
|
||
TOpeningLabelData().GetSubType(_T("Window"), arSubType);
|
||
}
|
||
//else if (pItemOneItem->eEntType == eHC)
|
||
else if (pItemOneItem->eEntType == eHC || entSameNameType == eHC)
|
||
{
|
||
TOpeningLabelData().GetSubType(_T("ArcWin"), arSubType);
|
||
}
|
||
|
||
for (int i = 0; i < arSubType.GetSize(); i++)
|
||
{
|
||
combo.AddString(arSubType[i]);
|
||
}
|
||
}
|
||
}
|
||
|
||
//add by lgy 20120301 解析选择的门窗类型之后生成对应的编号标记
|
||
CString CPropGrid::GetItemSerial(const CString strText)
|
||
{
|
||
CString strType = _T("");
|
||
if (strText == _T("甲级防火门"))
|
||
{
|
||
strType = _T("FM甲");
|
||
}
|
||
else if (strText == _T("乙级防火门"))
|
||
{
|
||
strType = _T("FM乙");
|
||
}
|
||
else if (strText == _T("丙级防火门"))
|
||
{
|
||
strType = _T("FM丙");
|
||
}
|
||
else if (strText == _T("防火卷帘"))
|
||
{
|
||
strType = _T("FJM");
|
||
}
|
||
else if (strText == _T("人防门"))
|
||
{
|
||
strType = _T("RFM");
|
||
}
|
||
else if (strText == _T("防火窗"))
|
||
{
|
||
strType = _T("FC");
|
||
}
|
||
//add by lgy 20120413 如果门窗样式由别的更改为普通门时,无法更新新编号
|
||
else if (strText == _T("普通门"))
|
||
{
|
||
strType = _T("M");
|
||
}
|
||
else if (strText == _T("普通窗"))
|
||
{
|
||
strType = _T("C");
|
||
}
|
||
return strType;
|
||
}
|
||
|
||
/////////////////////////////////////////////////////////////////////////////
|
||
// CGridView
|
||
IMPLEMENT_DYNCREATE(CGridView, CFormView)
|
||
|
||
CGridView::CGridView()
|
||
: CFormView(CGridView::IDD)
|
||
{
|
||
//{{AFX_DATA_INIT(CInputView)
|
||
//}}AFX_DATA_INIT
|
||
}
|
||
|
||
CGridView::~CGridView()
|
||
{
|
||
}
|
||
|
||
|
||
BEGIN_MESSAGE_MAP(CGridView, CFormView)
|
||
//{{AFX_MSG_MAP(CGridView)
|
||
ON_WM_SIZE()
|
||
//}}AFX_MSG_MAP
|
||
END_MESSAGE_MAP()
|
||
|
||
void CGridView::ReCreate(TreeItemData *pItemData)
|
||
{
|
||
m_grid.ReCreate(pItemData);
|
||
}
|
||
|
||
void CGridView::UpdateDWG()
|
||
{
|
||
m_grid.UpdateDWG();
|
||
}
|
||
|
||
void CGridView::RefreshGridContent()
|
||
{
|
||
m_grid.RefreshGridContent();
|
||
}
|
||
|
||
void CGridView::RefreshGrid()
|
||
{
|
||
m_grid.Refresh();
|
||
}
|
||
|
||
|
||
void CGridView::OnInitialUpdate()
|
||
{
|
||
CFormView::OnInitialUpdate();
|
||
|
||
CRect rect;
|
||
GetClientRect(&rect);
|
||
|
||
m_grid.Clear();
|
||
m_grid.SetTreeLine();
|
||
m_grid.SetColFixLength();
|
||
m_grid.SetColPosFix();
|
||
m_grid.SetSortEnable(false);
|
||
m_grid.SetRowPosFix(true);
|
||
m_grid.SetRowFixLength(true);
|
||
m_grid.SetNoAppendButton(true);
|
||
|
||
CAcModuleResourceOverride vTemp;
|
||
m_grid.Create(this, IDC_GRID_OP);
|
||
}
|
||
|
||
void CGridView::OnSize(UINT nType, int cx, int cy)
|
||
{
|
||
CFormView::OnSize(nType, cx, cy);
|
||
|
||
CRect rect;
|
||
GetWindowRect(&rect);
|
||
|
||
m_grid.SetWindowPos(&wndTop, 0, 0, rect.Width()+2, rect.Height(), 0);
|
||
m_grid.RecalcLayout();
|
||
}
|
||
|
||
//////////////////////////////////////////////////////////////////////////
|
||
// CDoorWinCheckTreeView
|
||
IMPLEMENT_DYNCREATE(CDoorWinTreeView, CTreeView)
|
||
|
||
BEGIN_MESSAGE_MAP(CDoorWinTreeView, CTreeView)
|
||
ON_WM_CREATE()
|
||
ON_NOTIFY_REFLECT(TVN_SELCHANGED, OnSelchanged)
|
||
END_MESSAGE_MAP()
|
||
|
||
CDoorWinTreeView::CDoorWinTreeView() : CTreeView()
|
||
{
|
||
|
||
}
|
||
|
||
CDoorWinTreeView::~CDoorWinTreeView()
|
||
{
|
||
|
||
}
|
||
|
||
void CDoorWinTreeView::SetNewStyle(long lStyleMask, BOOL bSetBits)
|
||
{
|
||
long lStyleOld;
|
||
|
||
lStyleOld = GetWindowLong(m_hWnd, GWL_STYLE);
|
||
lStyleOld &= ~lStyleMask;
|
||
if (bSetBits)
|
||
lStyleOld |= lStyleMask;
|
||
|
||
SetWindowLong(m_hWnd, GWL_STYLE, lStyleOld);
|
||
SetWindowPos(NULL, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER);
|
||
}
|
||
|
||
HTREEITEM CDoorWinTreeView::AddTreeItem(CTreeCtrl &tree, TV_INSERTSTRUCT &tvItem, CString &text, TreeItemData *pData, HTREEITEM hParent)
|
||
{
|
||
tvItem.hParent = hParent;
|
||
tvItem.item.pszText = text.GetBuffer(0);
|
||
HTREEITEM hItem = tree.InsertItem(&tvItem);
|
||
if (pData != NULL)
|
||
tree.SetItemData(hItem, (DWORD_PTR)pData);
|
||
|
||
text.ReleaseBuffer();
|
||
|
||
return hItem;
|
||
}
|
||
|
||
HTREEITEM CDoorWinTreeView::AddTreeItem(CItem *pItem, CTreeCtrl &tree, TV_INSERTSTRUCT &tvItem, HTREEITEM hParent)
|
||
{
|
||
if (pItem == NULL)
|
||
return NULL;
|
||
|
||
if (pItem->ItemNum(IsCheckText(), IsCheckBlock()))
|
||
{
|
||
TreeItemSameName *pWidItem = new TreeItemSameName;
|
||
pWidItem->widItem.AddItem(pItem);
|
||
return AddTreeItem(tree, tvItem, pItem->GetItemName(IsCheckText(), IsCheckBlock()), pWidItem, hParent);
|
||
}
|
||
|
||
return NULL;
|
||
}
|
||
|
||
void CDoorWinTreeView::AddWidItemAry(CTreeCtrl &tree, AryWidItemPtr widItem[eDoorTypeNum], HTREEITEM hItemParent)
|
||
{
|
||
TV_INSERTSTRUCT tvItemCurr;
|
||
tvItemCurr.hInsertAfter = TVI_LAST;
|
||
tvItemCurr.item.mask = TVIF_TEXT;
|
||
|
||
// 添加实体类型项:
|
||
for (int j = 0; j < eDoorTypeNum; j++)
|
||
{
|
||
AryWidItemPtr &aryCurrWidItem = widItem[j];
|
||
if (TestItemEmpty(aryCurrWidItem, IsCheckText(), IsCheckBlock()))
|
||
continue;
|
||
|
||
SortWidItemAry(aryCurrWidItem);// 每次都整理一下。
|
||
int nAllCountTemp = 0;
|
||
for (int nWidCount = 0; nWidCount < (int)aryCurrWidItem.GetSize(); nWidCount++)
|
||
{
|
||
nAllCountTemp += aryCurrWidItem[nWidCount]->GetEntNum(IsCheckText(), IsCheckBlock());
|
||
if (nAllCountTemp > 0)
|
||
break;
|
||
}
|
||
|
||
if (nAllCountTemp == 0)
|
||
continue;
|
||
|
||
TreeItemSameStyle *pTypeItemData = new TreeItemSameStyle;
|
||
pTypeItemData->aryWidItemPtr.Append(aryCurrWidItem);
|
||
HTREEITEM hCurrTypeItem = AddTreeItem(tree, tvItemCurr, Type2Name(EEntType(j)), pTypeItemData, hItemParent);
|
||
|
||
// 添加子编号。
|
||
for (int k = 0; k < (int)aryCurrWidItem.GetSize(); k++)
|
||
{
|
||
CWidItem *pItem = aryCurrWidItem[k];// 获取这个widItem
|
||
if (pItem == NULL)
|
||
continue;
|
||
|
||
if (pItem->GetEntNum(IsCheckText(), IsCheckBlock()) > 0)
|
||
{
|
||
TreeItemSameName *pNameItemData = new TreeItemSameName;
|
||
pNameItemData->widItem.CopyFrom(*pItem);
|
||
AddTreeItem(tree, tvItemCurr, pItem->GetItemName(IsCheckText(), IsCheckBlock()), pNameItemData, hCurrTypeItem);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
int WidItemCmp(const void *pWidItemTemp1, const void *pWidItemTemp2)
|
||
{
|
||
CWidItem **pWidItem1 = (CWidItem**)pWidItemTemp1;
|
||
CWidItem **pWidItem2 = (CWidItem**)pWidItemTemp2;
|
||
|
||
return (*pWidItem1)->strLabel.CompareNoCase((*pWidItem2)->strLabel);
|
||
}
|
||
|
||
void CDoorWinTreeView::SortWidItemAry(AryWidItemPtr &aryWidItemPtr)
|
||
{
|
||
CWidItem **pWidItem = aryWidItemPtr.GetData();
|
||
if (pWidItem != NULL)
|
||
{
|
||
qsort(pWidItem, aryWidItemPtr.GetSize(), sizeof(CWidItem*), WidItemCmp);
|
||
}
|
||
}
|
||
|
||
int ItemCmp(const void *pItemTemp1, const void *pItemTemp2)
|
||
{
|
||
CItem **pItem1 = (CItem**)pItemTemp1;
|
||
CItem **pItem2 = (CItem**)pItemTemp2;
|
||
|
||
return (*pItem1)->strLabel.CompareNoCase((*pItem2)->strLabel);
|
||
}
|
||
|
||
void CDoorWinTreeView::SortAryItem(AryItemPtr &aryItemPtr)
|
||
{
|
||
CItem **pItem = aryItemPtr.GetData();
|
||
|
||
if (pItem != NULL)
|
||
qsort(pItem, aryItemPtr.GetSize(), sizeof(CItem*), ItemCmp);
|
||
}
|
||
|
||
|
||
enum ETreeItemDir{
|
||
eProjAll_1 = 0,
|
||
eProjDWG_1,
|
||
eSel_1,
|
||
eCurrDWG_1,
|
||
eDocNotInProj_1,
|
||
eProjAllConflict_2,
|
||
eProjDWGConflict_2,
|
||
eSelConflict_2,
|
||
eCurrDWGConflict_2,
|
||
eDocNotInProjConflict_2,
|
||
eNoProj_3,
|
||
eNoProj_4,
|
||
eNone_5
|
||
};
|
||
ETreeItemDir GetTreeDir(int nFlag);
|
||
|
||
void CDoorWinTreeView::FillTreeView()
|
||
{
|
||
if (g_pData == NULL)
|
||
return;
|
||
|
||
CDataTable *pTable = g_pData->m_pDataTable;
|
||
if (pTable == NULL)
|
||
return;
|
||
if (pTable->IsCurrDocNotInProj() && IsCheckProj() && IsCheckDWG())
|
||
return;
|
||
|
||
BOOL bOnlyDWG = CSetDlg::CheckCurrDWG(), bOnlyProj = CSetDlg::CheckCurrProj(); // 仅绘制本图,仅绘制本工程
|
||
BOOL bNoProj = IsEmptyProject(); // 是否有工程
|
||
BOOL bHasNoProjData = g_pData->m_pDataTable->HasNoProjData(); // 是否包含不再工程内的数据,,,这个可能没用。
|
||
BOOL bAccordFloor = CSetDlg::AccordFloor();
|
||
g_pData->m_pDataTable->CalcConflictData();
|
||
int nConflictDataNum = 0;
|
||
CTreeCtrl &tree = GetTreeCtrl();
|
||
|
||
// 前两个肯定有,后两个不一定有。
|
||
HTREEITEM headItem[4];
|
||
memset(headItem, 0, sizeof(HTREEITEM)*4);
|
||
|
||
TV_INSERTSTRUCT tvItemCurr;
|
||
tvItemCurr.hInsertAfter = TVI_LAST;
|
||
tvItemCurr.item.mask = TVIF_TEXT;
|
||
tvItemCurr.hParent = TVI_ROOT;
|
||
CString strTemp = GetHeadItemName(0);
|
||
tvItemCurr.item.pszText = strTemp.GetBuffer(0);
|
||
headItem[0] = tree.InsertItem(&tvItemCurr);
|
||
tree.SetItemData(headItem[0], (DWORD_PTR)GetHeadItemData(0));
|
||
strTemp.ReleaseBuffer();
|
||
|
||
strTemp = GetHeadItemName(1);
|
||
tvItemCurr.item.pszText = strTemp.GetBuffer(0);
|
||
headItem[1] = tree.InsertItem(&tvItemCurr);
|
||
tree.SetItemData(headItem[1], (DWORD_PTR)GetHeadItemData(1));
|
||
strTemp.ReleaseBuffer();
|
||
|
||
if (!GetHeadItemName(2).IsEmpty() && !GetHeadItemName(3).IsEmpty())
|
||
{
|
||
headItem[2] = AddTreeItem(tree, tvItemCurr, GetHeadItemName(2), GetHeadItemData(2), TVI_ROOT);
|
||
headItem[3] = AddTreeItem(tree, tvItemCurr, GetHeadItemName(3), GetHeadItemData(3), TVI_ROOT);
|
||
}
|
||
|
||
HTREEITEM hCurrFloorItem = NULL;
|
||
HTREEITEM hCurrTypeItem = NULL;
|
||
|
||
ETreeItemDir eDir = GetTreeDir(0);
|
||
// 添加第一个分支,TPR(本DWG中|全部|框选)门窗
|
||
if (eSel_1 == eDir || eDocNotInProj_1 == eDir)
|
||
{ // 没有工程,不用分楼层
|
||
const CGroup *pDataNoProj = pTable->GetDataNp();
|
||
for (int iType = 0; iType < eDoorTypeNum; iType++)
|
||
{ // 遍历类型
|
||
const AryItemPtr &aryDoorCheckPtr = pDataNoProj->GetItemAry(EEntType(iType));
|
||
if (TestItemEmpty(aryDoorCheckPtr, IsCheckText(), IsCheckBlock()))
|
||
continue;
|
||
|
||
// 类型名字
|
||
TreeItemSameStyle *pItemOneStyle = new TreeItemSameStyle;
|
||
ItemPtrAry2Wid(aryDoorCheckPtr, pItemOneStyle->aryWidItemPtr);
|
||
hCurrTypeItem = AddTreeItem(tree, tvItemCurr, Type2Name(EEntType(iType)), pItemOneStyle, headItem[0]);
|
||
|
||
SortAryItem(const_cast<AryItemPtr&>(aryDoorCheckPtr));
|
||
for (int iItem = 0; iItem < aryDoorCheckPtr.GetSize(); iItem++)
|
||
{ // 遍历编号类型
|
||
CItem *pItem = aryDoorCheckPtr[iItem];
|
||
AddTreeItem(pItem, tree, tvItemCurr, hCurrTypeItem);
|
||
}
|
||
}
|
||
}
|
||
else if (eCurrDWG_1 == eDir)
|
||
{ // 显示本图全部,不管楼层:
|
||
AryWidItemPtr widItem[eDoorTypeNum];
|
||
pTable->GetDataDNpNf(widItem) ;
|
||
|
||
AddWidItemAry(tree, widItem, headItem[0]);
|
||
}
|
||
else if (eNone_5 != eDir)
|
||
{ // 存在当前工程,需要判断是否分楼层
|
||
if (CSetDlg::AccordFloor())
|
||
{ // 分楼层
|
||
AryAllData aryAllFloor;
|
||
if (eProjDWG_1 == eDir)
|
||
pTable->GetDataDPF(aryAllFloor);
|
||
else
|
||
pTable->GetDataPF(aryAllFloor);
|
||
|
||
for (int i = 0; i < aryAllFloor.GetSize(); i++)
|
||
{
|
||
CGroup *pFloor = aryAllFloor[i];
|
||
// 添加楼层项
|
||
TreeItemFloor *pFloorItemData = new TreeItemFloor;
|
||
pFloorItemData->pFloor = pFloor;
|
||
hCurrFloorItem = AddTreeItem(tree, tvItemCurr, pFloor->GetFloorName(), pFloorItemData, headItem[0]);
|
||
|
||
// 添加实体类型项:
|
||
for (int j = 0; j < eDoorTypeNum; j++)
|
||
{
|
||
if (TestItemEmpty(pFloor->GetItemAry(EEntType(j)), IsCheckText(), IsCheckBlock()))
|
||
continue;
|
||
|
||
TreeItemSameStyle *pTypeItemData = new TreeItemSameStyle;
|
||
ItemPtrAry2Wid(pFloor->GetItemAry(EEntType(j)), pTypeItemData->aryWidItemPtr);
|
||
hCurrTypeItem = AddTreeItem(tree, tvItemCurr, Type2Name(EEntType(j)), pTypeItemData, hCurrFloorItem);
|
||
|
||
SortAryItem(const_cast<AryItemPtr&>(pFloor->GetItemAry(EEntType(j))));
|
||
|
||
// 添加子编号。
|
||
for (int k = 0; k < (int)pFloor->GetItemAry(EEntType(j)).GetSize(); k++)
|
||
{
|
||
CItem *pItem = pFloor->GetItemAry(EEntType(j)).GetAt(k);
|
||
AddTreeItem(pItem, tree, tvItemCurr, hCurrTypeItem);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
else
|
||
{ // 不分楼层
|
||
AryWidItemPtr aryWidItemPtr[eDoorTypeNum];
|
||
if (eProjDWG_1 == eDir)
|
||
pTable->GetCurrDPNf(aryWidItemPtr);
|
||
else
|
||
pTable->GetDataPNf(aryWidItemPtr);
|
||
|
||
AddWidItemAry(tree, aryWidItemPtr, headItem[0]);
|
||
}
|
||
}
|
||
|
||
|
||
// TPR冲突门窗
|
||
eDir = GetTreeDir(1);
|
||
{
|
||
AryWidItemPtr aryWidItemConflict[eDoorTypeNum];
|
||
if (eSelConflict_2 == eDir || eDocNotInProjConflict_2 == eDir)
|
||
{ // 空工程...使用未创建工程的数据做冲突数据
|
||
pTable->GetConflictNoProj(aryWidItemConflict);
|
||
}
|
||
else if (eCurrDWGConflict_2 == eDir )
|
||
{
|
||
pTable->GetConflictDNp(aryWidItemConflict);
|
||
}
|
||
else if (eProjDWGConflict_2 == eDir)
|
||
{ // 本图的冲突
|
||
pTable->GetConflictDP(aryWidItemConflict);
|
||
}
|
||
else if (eNone_5 != eDir)
|
||
{ // 全部的冲突
|
||
pTable->GetConflictProj(aryWidItemConflict);
|
||
}
|
||
|
||
for (int i = 0; i < eDoorTypeNum; i++)
|
||
{
|
||
for (int j = 0; j < (int)aryWidItemConflict[i].GetSize(); j++)
|
||
{
|
||
nConflictDataNum += aryWidItemConflict[i][j]->GetEntNum(false, IsCheckBlock());
|
||
}
|
||
}
|
||
|
||
AddWidItemAry(tree, aryWidItemConflict, headItem[1]);
|
||
}
|
||
|
||
// 未创建工程门窗:
|
||
eDir = GetTreeDir(2);
|
||
{
|
||
if (eDir == eNoProj_3)
|
||
{
|
||
AryWidItemPtr aryWidItemNoProj[eDoorTypeNum];
|
||
pTable->GetDataNp(aryWidItemNoProj);
|
||
AddWidItemAry(tree, aryWidItemNoProj, headItem[2]);
|
||
}
|
||
}
|
||
|
||
// 未创建工程冲突门窗
|
||
eDir = GetTreeDir(3);
|
||
{
|
||
if (eDir == eNoProj_4)
|
||
{
|
||
AryWidItemPtr aryWidItemConflict[eDoorTypeNum];
|
||
pTable->GetConflictNoProj(aryWidItemConflict);
|
||
AddWidItemAry(tree, aryWidItemConflict, headItem[3]);
|
||
|
||
for (int i = 0; i < eDoorTypeNum; i++)
|
||
{
|
||
for (int j = 0; j < (int)aryWidItemConflict[i].GetSize(); j++)
|
||
{
|
||
nConflictDataNum += aryWidItemConflict[i][j]->GetEntNum(false, IsCheckBlock());
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
if (nConflictDataNum != 0)
|
||
{
|
||
if (pFrame)
|
||
{
|
||
pFrame->SetTip(eConflictTip, true);
|
||
pFrame->SetConflictDataNum(nConflictDataNum);
|
||
}
|
||
}
|
||
else
|
||
{
|
||
if (pFrame)
|
||
{
|
||
pFrame->SetTip(eConflictTip, false);
|
||
}
|
||
}
|
||
|
||
// 展开树的第一级目录:
|
||
if (headItem[0] != NULL)
|
||
tree.Expand(headItem[0], TVE_EXPAND);
|
||
if (headItem[1] != NULL)
|
||
tree.Expand(headItem[1], TVE_EXPAND);
|
||
if (headItem[2] != NULL)
|
||
tree.Expand(headItem[2], TVE_EXPAND);
|
||
if (headItem[3] != NULL)
|
||
tree.Expand(headItem[3], TVE_EXPAND);
|
||
|
||
// 设置树控件的样式
|
||
SetNewStyle(TVS_LINESATROOT, TRUE);
|
||
SetNewStyle(TVS_HASLINES, TRUE);
|
||
SetNewStyle(TVS_HASBUTTONS, TRUE);
|
||
}
|
||
|
||
bool IsSelData()
|
||
{
|
||
if (g_pData != NULL &&
|
||
g_pData->m_pDataTable != NULL)
|
||
return g_pData->m_pDataTable->IsSelData();
|
||
else
|
||
return FALSE;
|
||
}
|
||
|
||
// 1、工程名字 + (仅检查本DWG)?本DWG中:全部 + 门窗 === 如果没有工程,使用“本DWG全部”
|
||
// 2、工程名字 + 冲突门窗 (内容受是否仅检查本DWG控制)====如果没有工程,使用“本DWGXXX”
|
||
// 3、本DWG未创建工程门窗(是否勾选仅检查本DWG门窗)
|
||
// 4、本DWG未创建工程冲突门窗(是否勾选仅检查本DWG门窗)
|
||
CString CDoorWinTreeView::GetHeadItemName(int nFlag)
|
||
{
|
||
switch (GetTreeDir(nFlag))
|
||
{
|
||
case eProjAll_1:
|
||
return CString(XString(_T("%s全部门窗"), ProjectName()));
|
||
break;
|
||
case eProjAllConflict_2:
|
||
return CString(XString(_T("%s全部冲突门窗"), ProjectName()));
|
||
break;
|
||
case eProjDWG_1:
|
||
return CString(XString(_T("%s本DWG门窗"), ProjectName()));
|
||
break;
|
||
case eProjDWGConflict_2:
|
||
return CString(XString(_T("%s本DWG冲突门窗"), ProjectName()));
|
||
break;
|
||
case eSel_1:
|
||
return _T("框选门窗");
|
||
break;
|
||
case eSelConflict_2:
|
||
return _T("冲突门窗");
|
||
break;
|
||
case eCurrDWG_1:
|
||
return _T("本DWG全部门窗");
|
||
break;
|
||
case eCurrDWGConflict_2:
|
||
return _T("本DWG冲突门窗");
|
||
break;
|
||
case eDocNotInProj_1:
|
||
return _T("本DWG全部门窗");
|
||
break;
|
||
case eDocNotInProjConflict_2:
|
||
return _T("本DWG冲突门窗");
|
||
break;
|
||
case eNoProj_3:
|
||
return _T("本DWG未创建工程门窗");
|
||
break;
|
||
case eNoProj_4:
|
||
return _T("本DWG未创建工程冲突门窗");
|
||
break;
|
||
default:
|
||
return _T("");
|
||
break;
|
||
}
|
||
}
|
||
|
||
ETreeItemDir GetTreeDir(int nFlag)
|
||
{
|
||
if (IsSelData())
|
||
{
|
||
if (nFlag == 0)
|
||
return eSel_1;
|
||
else if (nFlag == 1)
|
||
return eSelConflict_2;
|
||
else return eNone_5;
|
||
}
|
||
|
||
if (IsEmptyProject())
|
||
{ // 空工程只能执行此路
|
||
if (nFlag == 0)
|
||
return eCurrDWG_1;
|
||
else if (nFlag == 1)
|
||
return eCurrDWGConflict_2;
|
||
else
|
||
return eNone_5;
|
||
}
|
||
else
|
||
{ // 有工程存在:本图+没勾本工程,本图+勾选本工程,没勾本图+勾本工程。
|
||
if (IsCheckDWG() && !IsCheckProj())
|
||
{
|
||
if (g_pData != NULL && g_pData->m_pDataTable != NULL && !g_pData->m_pDataTable->IsCurrDocNotInProj())
|
||
{// 有工程,勾选本图,未勾选本工程。。。显示TPR本图,TPR本图冲突,本图未创建,本图未创建冲突
|
||
if (nFlag == 0)
|
||
return eProjDWG_1;
|
||
else if (nFlag == 1)
|
||
return eProjDWGConflict_2;
|
||
else
|
||
{
|
||
if (g_pData->m_pDataTable->TestHasNoProjData(IsCheckText(), IsCheckBlock()))
|
||
{
|
||
if (nFlag == 2)
|
||
return eNoProj_3;
|
||
else if (nFlag == 3)
|
||
return eNoProj_4;
|
||
}
|
||
return eNone_5;
|
||
}
|
||
}
|
||
else
|
||
{ // 勾选本图,但是没勾选本工程,并且本图不在本工程内:
|
||
if (nFlag == 0)
|
||
return eCurrDWG_1;
|
||
else if (nFlag == 1)
|
||
return eCurrDWGConflict_2;
|
||
else
|
||
return eNone_5;
|
||
}
|
||
}
|
||
else if (IsCheckDWG() && IsCheckProj())
|
||
{ // 算作四个标签的:
|
||
if (g_pData != NULL && g_pData->m_pDataTable != NULL && g_pData->m_pDataTable->IsCurrDocNotInProj())
|
||
{ // 同时勾选,而且又冲突的
|
||
return eNone_5;
|
||
}
|
||
else
|
||
{
|
||
if (nFlag == 0)
|
||
return eProjDWG_1;
|
||
else if (nFlag == 1)
|
||
return eProjDWGConflict_2;
|
||
else // 因为勾选了本工程,则不需要显示本图冲突数据
|
||
return eNone_5;
|
||
}
|
||
|
||
}
|
||
else
|
||
{ // 没勾本图,勾了本工程:
|
||
if (nFlag == 0)
|
||
return eProjAll_1;
|
||
else if (nFlag == 1)
|
||
return eProjAllConflict_2;
|
||
else // 因为勾选了本工程,则不需要显示本图冲突数据
|
||
return eNone_5;
|
||
}
|
||
}
|
||
return eNone_5;
|
||
}
|
||
|
||
TreeItemData* CDoorWinTreeView::GetHeadItemData(int nFlag)
|
||
{
|
||
ETreeItemDir eDir = GetTreeDir(nFlag);
|
||
|
||
if (nFlag == 0)
|
||
{
|
||
if (eDir == eDocNotInProj_1 || eDir == eSel_1) // *******
|
||
{ // 没有工程
|
||
TreeItemNoProj *pItem = new TreeItemNoProj;
|
||
pItem->pTable = g_pData->m_pDataTable;
|
||
return pItem;
|
||
}
|
||
else if (eDir == eProjDWG_1 || eDir == eCurrDWG_1)
|
||
{
|
||
TreeItemDWG *pItem = new TreeItemDWG;
|
||
pItem->pTable = g_pData->m_pDataTable;
|
||
pItem->bNeedFloor = CSetDlg::AccordFloor();
|
||
pItem->bOnlyProj = (eDir == eProjDWG_1);
|
||
return pItem;
|
||
}
|
||
else if (eDir == eProjAll_1)
|
||
{
|
||
TreeItemProj *pItem = new TreeItemProj;
|
||
pItem->pTable = g_pData->m_pDataTable;
|
||
pItem->bNeedFloor = CSetDlg::AccordFloor();
|
||
return pItem;
|
||
}
|
||
else return NULL;
|
||
}
|
||
else if (nFlag == 1)
|
||
{
|
||
TreeItemConflict *pItem = new TreeItemConflict;
|
||
pItem->pTable = g_pData->m_pDataTable;
|
||
if (eDocNotInProjConflict_2 == eDir || eSelConflict_2 == eDir)
|
||
pItem->nType = eConflictNoProj; // 为创建工程数据的冲突。
|
||
else if (eCurrDWGConflict_2 == eDir)
|
||
pItem->nType = eConflictDWG;
|
||
else if (eProjDWGConflict_2 == eDir)
|
||
pItem->nType = eConflictProjDWG;
|
||
else if (eProjAllConflict_2 == eDir)
|
||
pItem->nType = eConflictProj;
|
||
else
|
||
{
|
||
delete pItem;
|
||
return NULL;
|
||
}
|
||
|
||
return pItem;
|
||
}
|
||
else if (nFlag == 2)
|
||
{
|
||
if (eNoProj_3)
|
||
{
|
||
TreeItemNoProj *pItem = new TreeItemNoProj;
|
||
pItem->pTable = g_pData->m_pDataTable;
|
||
return pItem;
|
||
}
|
||
else
|
||
return NULL;
|
||
|
||
}
|
||
else if (nFlag == 3)
|
||
{
|
||
if (eNoProj_4)
|
||
{
|
||
TreeItemConflict *pItem = new TreeItemConflict;
|
||
pItem->pTable = g_pData->m_pDataTable;
|
||
pItem->nType = eConflictNoProj;
|
||
return pItem;
|
||
}
|
||
else
|
||
return NULL;
|
||
}
|
||
else
|
||
return NULL;
|
||
}
|
||
|
||
TreeItemData* CDoorWinTreeView::GetHeadItemData1(int nFlag)
|
||
{
|
||
if (nFlag == 0)
|
||
{
|
||
if (IsEmptyProject())
|
||
{ // 没有工程
|
||
TreeItemNoProj *pItem = new TreeItemNoProj;
|
||
pItem->pTable = g_pData->m_pDataTable;
|
||
return pItem;
|
||
}
|
||
else
|
||
{
|
||
if (CSetDlg::CheckCurrDWG())
|
||
{
|
||
TreeItemDWG *pItem = new TreeItemDWG;
|
||
pItem->pTable = g_pData->m_pDataTable;
|
||
pItem->bNeedFloor = CSetDlg::AccordFloor();
|
||
return pItem;
|
||
}
|
||
else
|
||
{
|
||
TreeItemProj *pItem = new TreeItemProj;
|
||
pItem->pTable = g_pData->m_pDataTable;
|
||
pItem->bNeedFloor = CSetDlg::AccordFloor();
|
||
return pItem;
|
||
}
|
||
}
|
||
}
|
||
else if (nFlag == 1)
|
||
{
|
||
TreeItemConflict *pItem = new TreeItemConflict;
|
||
pItem->pTable = g_pData->m_pDataTable;
|
||
if (IsEmptyProject())
|
||
{ // 没有工程
|
||
pItem->nType = eConflictNoProj; // 为创建工程数据的冲突。
|
||
}
|
||
else
|
||
{
|
||
if (CSetDlg::CheckCurrDWG())
|
||
{
|
||
pItem->nType = eConflictDWG;
|
||
}
|
||
else
|
||
{
|
||
pItem->nType = eConflictProj;
|
||
}
|
||
}
|
||
|
||
return pItem;
|
||
}
|
||
else if (nFlag == 2)
|
||
{
|
||
if (g_pData->m_pDataTable->HasNoProjData() && !CSetDlg::CheckCurrProj() && !IsEmptyProject())
|
||
{
|
||
TreeItemNoProj *pItem = new TreeItemNoProj;
|
||
pItem->pTable = g_pData->m_pDataTable;
|
||
return pItem;
|
||
}
|
||
else
|
||
return NULL;
|
||
|
||
}
|
||
else if (nFlag == 3)
|
||
{
|
||
if (g_pData->m_pDataTable->HasNoProjData() && !CSetDlg::CheckCurrProj() && !IsEmptyProject())
|
||
{
|
||
TreeItemConflict *pItem = new TreeItemConflict;
|
||
pItem->pTable = g_pData->m_pDataTable;
|
||
pItem->nType = eConflictNoProj;
|
||
return pItem;
|
||
}
|
||
else
|
||
return NULL;
|
||
}
|
||
else
|
||
return NULL;
|
||
}
|
||
|
||
|
||
void CDoorWinTreeView::OnInitialUpdate()
|
||
{
|
||
// FillTreeView();
|
||
|
||
CTreeView::OnInitialUpdate();
|
||
}
|
||
|
||
void CDoorWinTreeView::ShowRootView() const
|
||
{
|
||
|
||
CTreeCtrl &tree = GetTreeCtrl();
|
||
HTREEITEM hItem = tree.GetRootItem();
|
||
if (hItem == NULL)
|
||
return;
|
||
tree.SelectItem(hItem);
|
||
// TreeItemData *pItemData = (TreeItemData*)tree.GetItemData(hItem);
|
||
// if (pItemData == NULL)
|
||
// return;
|
||
//
|
||
// g_pData->m_pGridView->ReCreate(pItemData);
|
||
}
|
||
|
||
void CDoorWinTreeView::Clear()
|
||
{
|
||
CTreeCtrl &tree = GetTreeCtrl();
|
||
tree.DeleteAllItems();
|
||
Invalidate();
|
||
UpdateWindow();
|
||
}
|
||
|
||
void CDoorWinTreeView::OnSelchanged(NMHDR* pNMHDR, LRESULT* pResult)
|
||
{
|
||
NM_TREEVIEW* pNMTreeView = (NM_TREEVIEW*)pNMHDR;
|
||
*pResult = 0;
|
||
|
||
// TODO: Add your control notification handler code here
|
||
if (!ValidData())
|
||
return;
|
||
|
||
HTREEITEM hItemNew = pNMTreeView->itemNew.hItem;
|
||
HTREEITEM hItemOld = pNMTreeView->itemOld.hItem;
|
||
|
||
CTreeCtrl &tree = GetTreeCtrl();
|
||
TreeItemData *pItemData = (TreeItemData*)tree.GetItemData(hItemNew);
|
||
if (pItemData == NULL)
|
||
return;
|
||
|
||
g_pData->m_pGridView->ReCreate(pItemData);
|
||
|
||
if (pItemData->GetType() == eSameName)
|
||
{ // 组名标注,
|
||
g_pData->m_pGridView->SelectRow(0);
|
||
}
|
||
}
|
||
|
||
int CDoorWinTreeView::OnCreate(LPCREATESTRUCT lpcs)
|
||
{
|
||
|
||
return CTreeView::OnCreate(lpcs);
|
||
}
|
||
void CDoorWinTreeView::OnDraw(CDC* pDC)
|
||
{
|
||
CTreeView::OnDraw(pDC);
|
||
}
|
||
|
||
//////////////////////////////////////////////////////////////////////////
|
||
// CSetDlg;
|
||
BOOL CSetDlg::m_bCheckCurrDWG = FALSE; // 检查本图门窗
|
||
BOOL CSetDlg::m_bCheckCurrProj = TRUE; // 检查本工程门窗
|
||
BOOL CSetDlg::m_bCheckBlock = TRUE; // 检查块参照和外部参照
|
||
BOOL CSetDlg::m_bCheckText = FALSE; // 检查门窗文字
|
||
BOOL CSetDlg::m_bAccordFloor = FALSE; // 分楼层显示
|
||
BOOL CSetDlg::m_bZoomDoorWin = TRUE; // 门窗放大显示
|
||
BOOL CSetDlg::m_bShowImg = TRUE; // 显示二维、三维样式
|
||
int CSetDlg::m_nCurrSel = -1;
|
||
CString CSetDlg::m_strCurrChose = _T("");
|
||
//{eM = 0, eMLC, eZMM, eZHMC, eC, eHC, eTC, eZJC, eDXC, eLHC, eDK, eDoorTypeNum};
|
||
//eType, eWidProp, eHeiProp, eEle ,eGeoTypeProp,eChutiaoProp,eTixingkuanProp
|
||
// 显示参数,是否选中
|
||
// etype, eWidProp, eHeiProp, eEle, eGeotype, eChuTiao, eTixingkuanProp, eNewLabel, eLabel
|
||
// 门,窗,弧窗
|
||
// 1 1 1 1 0 0 0 1 1
|
||
// 0 1 1 0 0 0 0 1 1
|
||
// 门连窗,子母门,组合门窗,洞口
|
||
// 0 1 1 1 0 0 0 1 1
|
||
// 0 1 1 0 0 0 0
|
||
// 凸窗
|
||
// 0 1 1 1 1 1 1 1 1
|
||
// 0 1 1 0 1 1 1 1 1
|
||
// 转角窗
|
||
// 0 1 1 1 0 1 0 1 1
|
||
// 0 1 1 0 0 1 0 1 1
|
||
// 带型窗
|
||
// 0 1 1 1 0 0 0 1 1
|
||
// 0 1 1 0 0 0 0 1 1
|
||
// 老虎窗
|
||
// 0 1 1 0 0 0 0 1 1
|
||
// 0 1 1 0 0 0 0 1 1
|
||
DWORD CSetDlg::m_flagShowParam1[eDoorTypeNum][2] =
|
||
{
|
||
0x18f, 0x186, //eM = 0,
|
||
0x18e, 0x186, // eMLC,
|
||
0x18e, 0x186, //eZMM,
|
||
0x18e, 0x186, //eZHMC,
|
||
0x18f, 0x186, //eC,
|
||
0x18f, 0x186, //eHC,
|
||
0x1fe, 0x1f6, //eTC,
|
||
0x1ae, 0x1a6, //eZJC,
|
||
0x18e, 0x186, //eDXC,
|
||
0x186, 0x186, //eLHC,
|
||
0x18e, 0x186 //eDK, eDoorTypeNum
|
||
};
|
||
|
||
BEGIN_MESSAGE_MAP(CSetDlg, GlwCAcUiDialog)
|
||
ON_CBN_SELCHANGE(IDC_CMB_TYPE_OP, OnSelCmbTypeChange)
|
||
ON_COMMAND(IDC_BTN_HELP, OnBtnHelpMsg)
|
||
ON_BN_CLICKED(IDC_CHK_GRACHK, OnClickDWG)
|
||
ON_BN_CLICKED(IDC_CHK_PROJ, OnClickProj)
|
||
ON_WM_DESTROY()
|
||
END_MESSAGE_MAP()
|
||
|
||
void CSetDlg::DoDataExchange(CDataExchange* pDX)
|
||
{
|
||
CDialog::DoDataExchange(pDX);
|
||
DDX_Control(pDX, IDC_CMB_TYPE_OP, m_cmbType);
|
||
DDX_Control(pDX, IDC_LST_SHOWPARAM, m_lstParm);
|
||
DDX_Check(pDX, IDC_CHK_GRACHK, m_bCheckCurrDWG);
|
||
DDX_Check(pDX, IDC_CHK_PROJ, m_bCheckCurrProj);
|
||
DDX_Check(pDX, IDC_CHK_BLOCK, m_bCheckBlock);
|
||
DDX_Check(pDX, IDC_CHK_TEXT, m_bCheckText);
|
||
DDX_Check(pDX, IDC_CHK_SCALE, m_bZoomDoorWin);
|
||
DDX_Check(pDX, IDC_CHK_SHOWIMG, m_bShowImg);
|
||
DDX_Check(pDX, IDC_CHK_PROJ, m_bCheckCurrProj);
|
||
DDX_Check(pDX, IDC_CHK_PROJ, m_bCheckCurrProj);
|
||
DDX_Check(pDX, IDC_CHK_FLOOR, m_bAccordFloor);
|
||
DDX_CBString(pDX, IDC_CMB_TYPE_OP, m_strCurrChose);
|
||
|
||
// 关联按钮。
|
||
DDX_Control(pDX, IDC_CHK_FLOOR, m_btnCheckFloor);
|
||
DDX_Control(pDX, IDC_CHK_TEXT, m_btnCheckText);
|
||
DDX_Control(pDX, IDC_CHK_BLOCK, m_btnCheckBlock);
|
||
DDX_Control(pDX, IDC_CHK_GRACHK, m_btnCheckDWG);
|
||
DDX_Control(pDX, IDC_CHK_PROJ, m_btnCheckProj);
|
||
DDX_Control(pDX, IDC_CHK_SHOWIMG, m_btnShowImg);
|
||
}
|
||
//add by wlw 20120305 门窗检查设置对话框中的信息需要从ini文件中读出来
|
||
void CSetDlg::LoadCurDoorMsg()
|
||
{
|
||
TCString strPath;
|
||
if (FindFile(_T("DoorWinCheckSet.ini"), strPath))
|
||
{
|
||
CString strValue;
|
||
CString strArray[] = {_T("Door"), _T("DoorWin"), _T("TwoDoor"), _T("GroupOpening"), _T("Window"), _T("ArcWin"), _T("BayWin"),
|
||
_T("CornerWin"), _T("BandWin"), _T("Dormer"), _T("Hole")};
|
||
|
||
for (int i = 0; i < 11; i++)
|
||
{
|
||
GetPrivateProfileString(strArray[i], _T("value"), _T(""), strValue.GetBuffer(MAX_PATH), MAX_PATH, strPath);//从INI文件中读数据
|
||
m_flagShowParam1[i][1] = _ttoi(strValue);
|
||
}
|
||
|
||
GetPrivateProfileString(_T("CheckBlock"), _T("value"), _T(""), strValue.GetBuffer(MAX_PATH), MAX_PATH, strPath);
|
||
m_bCheckBlock = _ttoi(strValue);
|
||
|
||
GetPrivateProfileString(_T("CheckText"), _T("value"), _T(""), strValue.GetBuffer(MAX_PATH), MAX_PATH, strPath);
|
||
m_bCheckText = _ttoi(strValue);
|
||
|
||
GetPrivateProfileString(_T("AccordFloor"), _T("value"), _T(""), strValue.GetBuffer(MAX_PATH), MAX_PATH, strPath);
|
||
m_bAccordFloor = _ttoi(strValue);
|
||
|
||
GetPrivateProfileString(_T("ZoomDoorWin"), _T("value"), _T(""), strValue.GetBuffer(MAX_PATH), MAX_PATH, strPath);
|
||
m_bZoomDoorWin = _ttoi(strValue);
|
||
|
||
GetPrivateProfileString(_T("ShowImg"), _T("value"), _T(""), strValue.GetBuffer(MAX_PATH), MAX_PATH, strPath);
|
||
m_bShowImg = _ttoi(strValue);
|
||
}
|
||
}
|
||
|
||
void CSetDlg::SaveCurDoorMsg()
|
||
{
|
||
CString csSysPath = g_sDwbPath;
|
||
//得到上华安装sys目录
|
||
CString strPath = csSysPath.Left(csSysPath.GetLength() - 5) + _T("\\sys\\DoorWinCheckSet.ini");
|
||
|
||
if (!FindFile(strPath))
|
||
{
|
||
CStdioFile file;
|
||
if (!file.Open(strPath, CFile::modeWrite | CFile::modeCreate))
|
||
return;
|
||
file.Close();
|
||
}
|
||
|
||
CString strValue;
|
||
CString strArray[] = {_T("Door"), _T("DoorWin"), _T("TwoDoor"), _T("GroupOpening"), _T("Window"), _T("ArcWin"), _T("BayWin"),
|
||
_T("CornerWin"), _T("BandWin"), _T("Dormer"), _T("Hole")};
|
||
for (int i = 0; i < 11; i++)
|
||
{
|
||
strValue.Format(_T("%d"), m_flagShowParam1[i][1]);
|
||
WritePrivateProfileString(strArray[i], _T("value"), strValue, strPath);//将值写入INI文件中
|
||
}
|
||
|
||
strValue.Format(_T("%d"), m_bCheckBlock);
|
||
WritePrivateProfileString(_T("CheckBlock"), _T("value"), strValue, strPath);//检查块参照和外部参照
|
||
|
||
strValue.Format(_T("%d"), m_bCheckText);
|
||
WritePrivateProfileString(_T("CheckText"), _T("value"), strValue, strPath);//检查门窗文字
|
||
|
||
strValue.Format(_T("%d"), m_bAccordFloor);
|
||
WritePrivateProfileString(_T("AccordFloor"), _T("value"), strValue, strPath);//分楼层显示
|
||
|
||
strValue.Format(_T("%d"), m_bZoomDoorWin);
|
||
WritePrivateProfileString(_T("ZoomDoorWin"), _T("value"), strValue, strPath);//门窗放大显示
|
||
|
||
strValue.Format(_T("%d"), m_bShowImg);
|
||
WritePrivateProfileString(_T("ShowImg"), _T("value"), strValue, strPath);//显示二维、三维样式
|
||
}
|
||
|
||
CSetDlg::CSetDlg(CWnd* pParent): GlwCAcUiDialog(CSetDlg::IDD, pParent)
|
||
{
|
||
m_bOldCheckDWG = m_bCheckCurrDWG;
|
||
m_bOldCheckProj = m_bCheckCurrProj;
|
||
//add by lgy 20120306 门窗检查设置对话框中的信息需要从文件中读出来
|
||
LoadCurDoorMsg();
|
||
|
||
memcpy(m_flagShowParam, m_flagShowParam1, sizeof(DWORD)*eDoorTypeNum*2);
|
||
}
|
||
|
||
BOOL CSetDlg::OnInitDialog()
|
||
{
|
||
CDialog::OnInitDialog();
|
||
|
||
if (IsEmptyProject())
|
||
{
|
||
GetDlgItem(IDC_CHK_PROJ)->EnableWindow(FALSE);
|
||
GetDlgItem(IDC_CHK_FLOOR)->EnableWindow(FALSE);
|
||
}
|
||
|
||
if (!IsCheckProj())
|
||
m_bCheckCurrDWG = TRUE;
|
||
|
||
int iIndex = 0;
|
||
// 组合框添加数据,并且设置当前项
|
||
for (iIndex = 0; iIndex < eDoorTypeNum; iIndex++)
|
||
{
|
||
m_cmbType.AddString(Type2Name(EEntType(iIndex)));
|
||
}
|
||
|
||
if (m_nCurrSel == -1)
|
||
m_nCurrSel = 0;
|
||
m_cmbType.SetCurSel(CurrSel());
|
||
|
||
CRect rect;
|
||
m_lstParm.GetClientRect(&rect);
|
||
// 列表框添加数据,
|
||
m_lstParm.SetExtendedStyle(LVS_EX_CHECKBOXES);
|
||
m_lstParm.InsertColumn(0, _T("显示类型"), LVCFMT_LEFT, rect.Width());
|
||
|
||
InitCheckParam(CurrSel());
|
||
UpdateData(FALSE);
|
||
return TRUE;
|
||
}
|
||
|
||
int CSetDlg::CurrSel() const
|
||
{
|
||
if (m_nCurrSel != -1)
|
||
return m_nCurrSel;
|
||
else
|
||
{
|
||
return 0;
|
||
}
|
||
}
|
||
|
||
|
||
void CSetDlg::OnDestroy()
|
||
{
|
||
CDialog::OnDestroy();
|
||
}
|
||
|
||
// 对话框选项的改变
|
||
void CSetDlg::OnSelCmbTypeChange()
|
||
{
|
||
if (m_nCurrSel != -1)
|
||
{
|
||
GetCheckParam(m_nCurrSel);
|
||
}
|
||
|
||
m_nCurrSel = m_cmbType.GetCurSel();
|
||
InitCheckParam(m_nCurrSel);
|
||
}
|
||
|
||
// 设置对话框在退出的时候,需要检测属性是否改变,然后相应的决定是否更新当前的显示:
|
||
// 需要检测的属性包括: 1、分层显示,2、是否检查文字,3、显示属性是否发生改变,4、是否显示二三维样式,5、本工程、本图
|
||
// 根据以上检测,当前显示内容的变化包括以下情形:
|
||
// 分层显示改变:重新生成树,重新生成grid;
|
||
// 是否检查文字:重新生成树,重新生成grid;
|
||
// 显示属性改变:重新生成Grid;
|
||
// 是否显示二三维样式:调整Frame中构件的位置。
|
||
void CSetDlg::OnOK()
|
||
{
|
||
// 获取图面上的数据。
|
||
if (m_nCurrSel != -1)
|
||
{
|
||
GetCheckParam(m_nCurrSel);
|
||
}
|
||
|
||
BOOL bAccordFloor = m_btnCheckFloor.GetCheck();
|
||
BOOL bCheckDWG = m_btnCheckDWG.GetCheck();
|
||
BOOL bCheckProj = m_btnCheckProj.GetCheck();
|
||
BOOL bCheckBlock = m_btnCheckBlock.GetCheck();
|
||
BOOL bCheckText = m_btnCheckText.GetCheck();
|
||
BOOL bCheckShowImag = m_btnShowImg.GetCheck();
|
||
|
||
BOOL bTreeReCreate = FALSE, bGridRecreate = FALSE, bFrameRedraw = FALSE;
|
||
if (bAccordFloor != m_bAccordFloor ||
|
||
bCheckDWG != m_bOldCheckDWG ||
|
||
bCheckProj != m_bOldCheckProj||
|
||
bCheckBlock != m_bCheckBlock ||
|
||
bCheckText != m_bCheckText)
|
||
{
|
||
bTreeReCreate = TRUE;
|
||
bGridRecreate = TRUE;
|
||
}
|
||
|
||
for (int i = 0; i < eDoorTypeNum; i++)
|
||
{
|
||
if (m_flagShowParam1[i][1] != m_flagShowParam[i][1])
|
||
{
|
||
bGridRecreate = TRUE;
|
||
break;
|
||
}
|
||
}
|
||
|
||
if (bCheckShowImag != m_bShowImg)
|
||
bFrameRedraw = TRUE;
|
||
|
||
UpdateData(TRUE);
|
||
|
||
memcpy(m_flagShowParam1, m_flagShowParam, sizeof(DWORD)*eDoorTypeNum*2);
|
||
SaveCurDoorMsg(); //add bywlw 20120912 保存设置的内容到dbf中
|
||
CDialog::OnOK();
|
||
|
||
// 更新显示:
|
||
if (bTreeReCreate)
|
||
{
|
||
if (g_pData != NULL && g_pData->m_pTreeView != NULL)
|
||
{
|
||
g_pData->m_pTreeView->Clear();
|
||
if (g_pData->m_pGridView != NULL)
|
||
g_pData->m_pGridView->Clear();
|
||
g_pData->m_pTreeView->FillTreeView();
|
||
g_pData->m_pTreeView->ShowRootView();
|
||
}
|
||
bGridRecreate = FALSE;
|
||
}
|
||
|
||
if (bGridRecreate)
|
||
{ // 根据当前的选择项,从新生成Grid;
|
||
if (g_pData != NULL && g_pData->m_pTreeView != NULL && g_pData->m_pGridView != NULL)
|
||
{
|
||
CTreeCtrl &tree = g_pData->m_pTreeView->GetTreeCtrl();
|
||
HTREEITEM hItem = tree.GetSelectedItem();
|
||
if (hItem != NULL)
|
||
{
|
||
TreeItemData *pItemData = (TreeItemData*)tree.GetItemData(hItem);
|
||
if (pItemData == NULL)
|
||
return;
|
||
|
||
g_pData->m_pGridView->ReCreate(pItemData);
|
||
}
|
||
else
|
||
{
|
||
g_pData->m_pGridView->ReCreate(NULL);
|
||
}
|
||
}
|
||
}
|
||
|
||
// if (bFrameRedraw)
|
||
{
|
||
if (pFrame != NULL)
|
||
pFrame->ReDrawWnd();
|
||
}
|
||
}
|
||
|
||
void CSetDlg::OnCancel()
|
||
{
|
||
CDialog::OnCancel();
|
||
}
|
||
|
||
// 显示提示信息
|
||
void CSetDlg::OnBtnHelpMsg()
|
||
{
|
||
CAcModuleResourceOverride vTemp;
|
||
CDialog dlg(IDD_DLG_DOORWINCHECK_WORD, this);
|
||
dlg.DoModal();
|
||
}
|
||
|
||
void CSetDlg::OnClickDWG()
|
||
{
|
||
if (!IsCheckProj())
|
||
{
|
||
m_bCheckCurrDWG = TRUE;
|
||
}
|
||
else
|
||
{
|
||
m_bCheckCurrDWG = !m_bCheckCurrDWG;
|
||
}
|
||
((CButton*)(GetDlgItem(IDC_CHK_GRACHK)))->SetCheck(m_bCheckCurrDWG);
|
||
}
|
||
|
||
void CSetDlg::OnClickProj()
|
||
{
|
||
if (!m_bCheckCurrDWG)
|
||
{
|
||
m_bCheckCurrProj = TRUE;
|
||
}
|
||
else
|
||
{
|
||
m_bCheckCurrProj = !m_bCheckCurrProj;
|
||
}
|
||
((CButton*)(GetDlgItem(IDC_CHK_PROJ)))->SetCheck(m_bCheckCurrProj);
|
||
}
|
||
|
||
|
||
// 检测某类型门窗的某种属性是否被选择了。
|
||
BOOL CSetDlg::TestItemChecked(EEntType eDoorWinCheckType, EShowItem eItem)
|
||
{
|
||
return (m_flagShowParam1[eDoorWinCheckType][1] & eItem);
|
||
}
|
||
|
||
// 检测某类型门窗的是否包含某种属性。
|
||
BOOL CSetDlg::TestHasShowParam(EEntType eDoorWinCheckType, EShowItem eItem)
|
||
{
|
||
DWORD dwValue = m_flagShowParam1[eDoorWinCheckType][0];
|
||
BOOL bHas = (dwValue & eItem);
|
||
return bHas;
|
||
}
|
||
|
||
// 测试该标记中是否选中该选项
|
||
BOOL CSetDlg::TestItemIsSet(EShowItem eItem, DWORD flagCheck)
|
||
{
|
||
return (eItem & flagCheck);
|
||
}
|
||
|
||
// 查看这几个类型都有哪几个参数需要显示
|
||
DWORD CSetDlg::GetCheckFlag(AryEtype &aryType, AryEShowItem &aryShowItem)
|
||
{
|
||
DWORD dwFlag = 0;
|
||
|
||
for (int iEntType = 0; iEntType < (int)aryType.GetSize(); iEntType++)
|
||
{
|
||
for (int iShowParam = 0; iShowParam < eDoorWinParmNum; iShowParam++)
|
||
{
|
||
if (TestItemChecked(aryType[iEntType], GetShowItem(EShowItem(iShowParam))))
|
||
SetParamFlag(dwFlag, GetShowItem(EShowItem(iShowParam)), TRUE);
|
||
}
|
||
}
|
||
|
||
for (int k = 0; k < eDoorWinParmNum; k++)
|
||
{
|
||
if (CheckParamFlag(dwFlag, GetShowItem(EShowItem(k))))
|
||
{
|
||
EShowItem eParam = GetShowItem(EShowItem(k));
|
||
aryShowItem.Add(eParam);
|
||
}
|
||
}
|
||
|
||
return dwFlag;
|
||
}
|
||
|
||
// 检测某类型门窗的某种属性是否被选择了。
|
||
BOOL CSetDlg::IsChecked(EEntType eDoorWinCheckType, EShowItem eItem) const
|
||
{
|
||
return (m_flagShowParam[eDoorWinCheckType][1] & eItem);
|
||
}
|
||
// 设置某类型门窗的某种属性被选择与否。
|
||
void CSetDlg::SetCheck(EEntType eDoorWinCheckType, int eItem, BOOL bCheck)
|
||
{
|
||
if (bCheck)
|
||
{
|
||
m_flagShowParam[eDoorWinCheckType][1] |= eItem;
|
||
}
|
||
else
|
||
{
|
||
m_flagShowParam[eDoorWinCheckType][1] &= ~eItem;
|
||
}
|
||
}
|
||
|
||
// 检测某类型门窗的是否包含某种属性。
|
||
BOOL CSetDlg::HasShowParam(EEntType eDoorWinCheckType, EShowItem eItem) const
|
||
{
|
||
DWORD dwValue = m_flagShowParam[eDoorWinCheckType][0];
|
||
BOOL bHas = (dwValue & eItem);
|
||
return bHas;
|
||
}
|
||
|
||
// 设置某类型门窗包含某种属性。
|
||
void CSetDlg::SetShowParam(EEntType eDoorWinCheckType, int eItem, BOOL bHas)
|
||
{
|
||
if (bHas)
|
||
{
|
||
m_flagShowParam[eDoorWinCheckType][0] |= eItem;
|
||
}
|
||
else
|
||
{
|
||
m_flagShowParam[eDoorWinCheckType][0] &= ~eItem;
|
||
}
|
||
}
|
||
|
||
void CSetDlg::SetParamFlag(DWORD &dwFlag, int eItem, BOOL bCheck)
|
||
{
|
||
if (bCheck)
|
||
{
|
||
dwFlag |= eItem;
|
||
}
|
||
else
|
||
{
|
||
dwFlag &= ~eItem;
|
||
}
|
||
}
|
||
|
||
BOOL CSetDlg::CheckParamFlag(DWORD &dwFlag, int eItem)
|
||
{
|
||
BOOL bHas = (dwFlag & eItem);
|
||
return bHas;
|
||
}
|
||
|
||
void CSetDlg::GetCheckParam(int nSel)
|
||
{
|
||
int iIndex = 0;
|
||
#define SET_CHECK(eDoorWinShowType)\
|
||
{\
|
||
if (HasShowParam(EEntType(nSel), eDoorWinShowType))\
|
||
{\
|
||
if (iIndex < (int)m_lstParm.GetItemCount())\
|
||
{\
|
||
SetCheck(EEntType(nSel), eDoorWinShowType, m_lstParm.GetCheck(iIndex++));\
|
||
}\
|
||
}\
|
||
}
|
||
|
||
SET_CHECK(eTypeProp);
|
||
SET_CHECK(eGeoTypeProp);
|
||
SET_CHECK(eWidProp);
|
||
SET_CHECK(eHeiProp);
|
||
SET_CHECK(eEle);
|
||
SET_CHECK(eChutiaoProp);
|
||
SET_CHECK(eTixingkuanProp);
|
||
}
|
||
|
||
void CSetDlg::InitCheckParam(int nSel)
|
||
{
|
||
m_lstParm.DeleteAllItems();
|
||
|
||
#define ADD_LST_ITEM(eItemType, _iIndex)\
|
||
{\
|
||
if (HasShowParam(EEntType(nSel), eItemType))\
|
||
{\
|
||
m_lstParm.InsertItem(_iIndex++, ParamTypeToString(eItemType));\
|
||
m_lstParm.SetCheck(_iIndex-1, IsChecked(EEntType(nSel), eItemType));\
|
||
}\
|
||
}
|
||
|
||
int iIndex = 0;
|
||
ADD_LST_ITEM(eTypeProp, iIndex);
|
||
ADD_LST_ITEM(eGeoTypeProp, iIndex);
|
||
ADD_LST_ITEM(eWidProp, iIndex);
|
||
ADD_LST_ITEM(eHeiProp, iIndex);
|
||
ADD_LST_ITEM(eEle, iIndex);
|
||
ADD_LST_ITEM(eChutiaoProp, iIndex);
|
||
ADD_LST_ITEM(eTixingkuanProp, iIndex);
|
||
};
|
||
|
||
|
||
// 读取数据,如果当前没有数据 -- 新读取数据,
|
||
// 如果当前有数据,读取数据,跟原有数据匹配,判断数据是否发生改变
|
||
void CDoorWinFrame::ReadDWG()
|
||
{
|
||
if (m_dataCenter.m_pDataTable == NULL)
|
||
return ;
|
||
#ifndef NDEBUG
|
||
DWORD d1 = GetTickCount();
|
||
#endif
|
||
if (m_dataCenter.m_pDataTable->IsEmptyTable())
|
||
{ // 原本是空的,直接读
|
||
GetOpeningDataTable(*(m_dataCenter.m_pDataTable));
|
||
|
||
#ifndef NDEBUG
|
||
DWORD d2 = GetTickCount();
|
||
ads_printf(XString(_T("\n直接读取数据的时间:%d"), d2 - d1));
|
||
#endif
|
||
|
||
CDoorWinTreeView *pTree = m_dataCenter.m_pTreeView;
|
||
if (pTree != NULL)
|
||
{
|
||
pTree->Clear();
|
||
pTree->FillTreeView();
|
||
pTree->ShowRootView();
|
||
}
|
||
|
||
#ifndef NDEBUG
|
||
ads_printf(XString(_T("\n处理显示花费的时间:%d"), GetTickCount() - d2));
|
||
#endif
|
||
|
||
}
|
||
else if (!m_dataCenter.m_pDataTable->IsSelData())
|
||
{ // 如果不是框选结果,才重新比对
|
||
CDataTable *pDataTable = new CDataTable;
|
||
GetOpeningDataTable(*pDataTable); // 新读取dataTable, 并且比较是否有更新
|
||
|
||
#ifndef NDEBUG
|
||
DWORD d2 = GetTickCount();
|
||
ads_printf(XString(_T("\n直接读取数据的时间:%d"), d2 - d1));
|
||
#endif
|
||
DWORD dwChange = 0;
|
||
if (!m_dataCenter.m_pDataTable->IsOldData())
|
||
{
|
||
dwChange = m_dataCenter.m_pDataTable->Compare(*pDataTable);
|
||
}
|
||
|
||
#ifndef NDEBUG
|
||
DWORD d3 = GetTickCount();
|
||
ads_printf(XString(_T("\n与老数据比较的时间:%d"), d3 - d2));
|
||
#endif
|
||
if (m_dataCenter.m_pDataTable->IsOldData() ||
|
||
CDataTable::TestDataChange(dwChange, CDataTable::eProjChange) ||
|
||
CDataTable::TestDataChange(dwChange, CDataTable::eDocChange) ||
|
||
CDataTable::TestDataChange(dwChange, CDataTable::eLabelChange) ||
|
||
CDataTable::TestDataChange(dwChange, CDataTable::eIdAdd) ||
|
||
CDataTable::TestDataChange(dwChange, CDataTable::eIdDel) ||
|
||
CDataTable::TestDataChange(dwChange, CDataTable::ePropChange))
|
||
{
|
||
// 需要重新生成树和grid
|
||
CDataTable *pOldDataTable = m_dataCenter.m_pDataTable;
|
||
m_dataCenter.m_pDataTable = pDataTable;
|
||
|
||
CDoorWinTreeView *pTree = m_dataCenter.m_pTreeView;
|
||
pTree->Clear();
|
||
pTree->FillTreeView();
|
||
pTree->ShowRootView();
|
||
delete pOldDataTable;
|
||
}
|
||
else
|
||
{ // 如果没有数据发生改变
|
||
m_dataCenter.m_pGridView->RefreshGrid();
|
||
delete pDataTable;
|
||
pDataTable = NULL;
|
||
}
|
||
#ifndef NDEBUG
|
||
ads_printf(XString(_T("\n处理显示花费的时间:%d"), GetTickCount() - d3));
|
||
#endif
|
||
}
|
||
|
||
GetDataTip(m_dataCenter.m_pDataTable);
|
||
pFrame->SetTip(eCorrespondingTip, false);
|
||
ShowMessage();
|
||
}
|
||
}; |