972 lines
24 KiB
C++
972 lines
24 KiB
C++
#include "stdafx.h"
|
||||
|
|
#include "SinglePlaceTreeDlg.h"
|
|||
|
|
#include "rxregsvc.h"
|
|||
|
|
#include <ctype.h>
|
|||
|
|
#include <time.h>
|
|||
|
|
#include "GlwGlobalVariable.h"
|
|||
|
|
#include "GlwPlaceTreeDataManage.h"
|
|||
|
|
//#include "GlwUIDefine.h"
|
|||
|
|
//#define UIFRAME_API __declspec( dllimport )
|
|||
|
|
//#include "GlwUtility.h"
|
|||
|
|
|
|||
|
|
#if ADS < 18
|
|||
|
|
#define DBL_MAX 1.7976931348623158e+308
|
|||
|
|
#endif
|
|||
|
|
|
|||
|
|
#ifdef _DEBUG
|
|||
|
|
#define new DEBUG_NEW
|
|||
|
|
#undef THIS_FILE
|
|||
|
|
static char THIS_FILE[] = __FILE__;
|
|||
|
|
#endif
|
|||
|
|
|
|||
|
|
|
|||
|
|
// 原始圆图片elev(00001730)
|
|||
|
|
# define SYS_CIRCLETREE _T("TARCH(MULTPLACETREE01)")
|
|||
|
|
|
|||
|
|
extern AcDbObjectId InsertBlock(CString &csBlkName, int &iTreeType);
|
|||
|
|
|
|||
|
|
double GetRandomSize(double dOrigRad)
|
|||
|
|
{
|
|||
|
|
double dRand = 0;
|
|||
|
|
dRand = (((double) rand() / (double) RAND_MAX) * dOrigRad + dOrigRad*0.5);
|
|||
|
|
return dRand;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
CSinglePlaceTreeDlg::CSinglePlaceTreeDlg(CWnd* pParent /*=NULL*/)
|
|||
|
|
: CModelessDialog(CSinglePlaceTreeDlg::IDD, pParent)
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
if(!GET_GLOBAL_VARIABLE(GlwPlaceTreeDataManage))
|
|||
|
|
SET_GLOBAL_VARIABLE(GlwPlaceTreeDataManage, new GlwPlaceTreeDataManage);
|
|||
|
|
GlwPlaceTreeDataManage *pDataManage = GET_GLOBAL_VARIABLE(GlwPlaceTreeDataManage);
|
|||
|
|
|
|||
|
|
m_iTreeType = pDataManage->GetTreeType();
|
|||
|
|
m_iDrawStyle = pDataManage->GetDrawType();
|
|||
|
|
m_csRad = GetFormatData(pDataManage->GetTreeRad(FALSE));
|
|||
|
|
m_csDis = GetFormatData(pDataManage->GetTreeDis());
|
|||
|
|
m_csOffset = GetFormatData(pDataManage->GetTreeOffset());
|
|||
|
|
m_bIsRandSize = pDataManage->GetIsSetRandomSize();
|
|||
|
|
m_bIsRotation = pDataManage->GetIsSetRotation();
|
|||
|
|
m_bIsSetDis = pDataManage->GetIsSetDis();
|
|||
|
|
m_idTreeStyle = pDataManage->GetTreeId();
|
|||
|
|
m_hIcon = NULL;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// 根据需求修改编辑框中数据的显示格式
|
|||
|
|
CString CSinglePlaceTreeDlg::GetFormatData(double dData)
|
|||
|
|
{
|
|||
|
|
CString csTemp;
|
|||
|
|
if (DocGetMeterUnitDraw())
|
|||
|
|
{
|
|||
|
|
csTemp.Format(_T("%.3f"), dData);
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
csTemp.Format(_T("%.0f"), dData);
|
|||
|
|
}
|
|||
|
|
return csTemp;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
namespace
|
|||
|
|
{
|
|||
|
|
enum GlwEnum
|
|||
|
|
{
|
|||
|
|
eLayerName = 0,
|
|||
|
|
eLayerOpen,
|
|||
|
|
eLayerFrozen,
|
|||
|
|
eLayerLocked,
|
|||
|
|
eLayerColor,
|
|||
|
|
eLayerLType,
|
|||
|
|
eLayerLWeight,
|
|||
|
|
eLayerPlottable,
|
|||
|
|
eLayerDesc,
|
|||
|
|
eWinVerOld,
|
|||
|
|
eWinVerXp,
|
|||
|
|
eWinVerVista,
|
|||
|
|
eWinVerWin7,
|
|||
|
|
eWinVerWin8,
|
|||
|
|
eCADVer2007,
|
|||
|
|
eCADVer2008,
|
|||
|
|
eCADVer2009,
|
|||
|
|
eCADVer2010,
|
|||
|
|
eCADVer2011,
|
|||
|
|
eCADVer2012,
|
|||
|
|
eCADVer2013,
|
|||
|
|
eCADVer2014,
|
|||
|
|
eCADVer2015,
|
|||
|
|
eCADVer2016,
|
|||
|
|
eCADVerUnknow,
|
|||
|
|
EV_TOP, // 俯视
|
|||
|
|
EV_BOTTOM, // 仰视
|
|||
|
|
EV_LEFT, // 左视
|
|||
|
|
EV_RIGHT, // 右视
|
|||
|
|
EV_FORNT, // 前视
|
|||
|
|
EV_BACK, // 后视
|
|||
|
|
EV_WS, // 西南
|
|||
|
|
EV_ES, // 东南
|
|||
|
|
EV_EN, // 东北
|
|||
|
|
EV_WN, // 西北
|
|||
|
|
EV_NONE, // 啥也不是
|
|||
|
|
};
|
|||
|
|
GlwEnum GetCadVer()
|
|||
|
|
{
|
|||
|
|
TCHAR strVer[20];
|
|||
|
|
TGGetVar(_T("ACADVER"), strVer);
|
|||
|
|
|
|||
|
|
CString str = strVer;
|
|||
|
|
str = str.Left(4);
|
|||
|
|
if (_T("17.0") == str)
|
|||
|
|
return eCADVer2007;
|
|||
|
|
else if (_T("17.1") == str)
|
|||
|
|
return eCADVer2008;
|
|||
|
|
else if (_T("17.2") == str)
|
|||
|
|
return eCADVer2009;
|
|||
|
|
else if (_T("18.0") == str)
|
|||
|
|
return eCADVer2010;
|
|||
|
|
else if (_T("18.1") == str)
|
|||
|
|
return eCADVer2011;
|
|||
|
|
else if (_T("18.2") == str)
|
|||
|
|
return eCADVer2012;
|
|||
|
|
else if (_T("19.0") == str)
|
|||
|
|
return eCADVer2013;
|
|||
|
|
else if (_T("19.1") == str)
|
|||
|
|
return eCADVer2014;
|
|||
|
|
else if (_T("20.0") == str)
|
|||
|
|
return eCADVer2015;
|
|||
|
|
else if (_T("20.1") == str)
|
|||
|
|
return eCADVer2016;
|
|||
|
|
|
|||
|
|
return eCADVerUnknow;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//add by yyc 增加打开的图纸和当前打开的CAD版本对比,图纸版本比CAD版本低的进行提示
|
|||
|
|
//AC1015:CAD2000版 AC1018:CAD2004版 AC1021:CAD2007版
|
|||
|
|
//AC1027:CAD2013版 AC1024:CAD2010版
|
|||
|
|
BOOL JudgeVersion(CString strFile)//判断版本
|
|||
|
|
{
|
|||
|
|
CStdioFile file;
|
|||
|
|
file.Open(strFile, CFile::modeRead);
|
|||
|
|
CString strFileVersion;
|
|||
|
|
file.ReadString(strFileVersion);
|
|||
|
|
file.Close();
|
|||
|
|
strFileVersion = strFileVersion.Mid(0, 6);
|
|||
|
|
if (strFileVersion.IsEmpty())
|
|||
|
|
return FALSE;
|
|||
|
|
if (GetCadVer() == eCADVer2007 && (strFileVersion != _T("AC1027") && strFileVersion != _T("AC1024")))
|
|||
|
|
return TRUE;
|
|||
|
|
else if (GetCadVer() == eCADVer2008 && (strFileVersion != _T("AC1027") && strFileVersion != _T("AC1024")))
|
|||
|
|
return TRUE;
|
|||
|
|
else if (GetCadVer() == eCADVer2009 && (strFileVersion != _T("AC1027") && strFileVersion != _T("AC1024")))
|
|||
|
|
return TRUE;
|
|||
|
|
else if (GetCadVer() == eCADVer2010 && strFileVersion != _T("AC1027"))
|
|||
|
|
return TRUE;
|
|||
|
|
else if (GetCadVer() == eCADVer2011 && strFileVersion != _T("AC1027"))
|
|||
|
|
return TRUE;
|
|||
|
|
else if (GetCadVer() == eCADVer2012 && strFileVersion != _T("AC1027"))
|
|||
|
|
return TRUE;
|
|||
|
|
else if (GetCadVer() == eCADVer2013 )
|
|||
|
|
return TRUE;
|
|||
|
|
else if (GetCadVer() == eCADVer2014)
|
|||
|
|
return TRUE;
|
|||
|
|
else if (GetCadVer() == eCADVer2015)
|
|||
|
|
return TRUE;
|
|||
|
|
else if (GetCadVer() == eCADVer2016)
|
|||
|
|
return TRUE;
|
|||
|
|
else
|
|||
|
|
return FALSE;
|
|||
|
|
}
|
|||
|
|
CSinglePlaceTreeDlg::~CSinglePlaceTreeDlg()
|
|||
|
|
{
|
|||
|
|
// 按钮图标销毁
|
|||
|
|
if (m_hIcon)
|
|||
|
|
{
|
|||
|
|
::DestroyIcon(m_hIcon);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// 保存数据mm单位
|
|||
|
|
if(!GET_GLOBAL_VARIABLE(GlwPlaceTreeDataManage))
|
|||
|
|
SET_GLOBAL_VARIABLE(GlwPlaceTreeDataManage, new GlwPlaceTreeDataManage);
|
|||
|
|
GlwPlaceTreeDataManage *pDataManage = GET_GLOBAL_VARIABLE(GlwPlaceTreeDataManage);
|
|||
|
|
|
|||
|
|
pDataManage->SetTreeType(m_iTreeType);
|
|||
|
|
pDataManage->SetDrawType(m_iDrawStyle);
|
|||
|
|
pDataManage->SetTreeRad(_tstof(m_csRad));
|
|||
|
|
pDataManage->SetTreeDis(_tstof(m_csDis));
|
|||
|
|
pDataManage->SetTreeOffset(_tstof(m_csOffset));
|
|||
|
|
pDataManage->SetIsSetRotation(m_bIsRotation);
|
|||
|
|
pDataManage->SetIsSetRandSize(m_bIsRandSize);
|
|||
|
|
pDataManage->SetIsSetDis(m_bIsSetDis);
|
|||
|
|
pDataManage->SetTreeId(m_idTreeStyle);
|
|||
|
|
m_PreviewCtrl.clearAll();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void CSinglePlaceTreeDlg::DoDataExchange(CDataExchange* pDX)
|
|||
|
|
{
|
|||
|
|
CModelessDialog::DoDataExchange(pDX);
|
|||
|
|
//{{AFX_DATA_MAP(CSinglePlaceTreeDlg)
|
|||
|
|
DDX_Radio(pDX, IDC_RAD_FROMBLK, m_iTreeType);
|
|||
|
|
DDX_Radio(pDX, IDC_RAD_POINT, m_iDrawStyle);
|
|||
|
|
DDX_Text(pDX, IDC_EDT_RAD, m_csRad);
|
|||
|
|
DDX_Text(pDX, IDC_EDT_DIS, m_csDis);
|
|||
|
|
DDX_Text(pDX, IDC_EDT_OFFSET, m_csOffset);
|
|||
|
|
//DDV_MinMaxDouble(pDX, m_dOffset, 0, DBL_MAX );
|
|||
|
|
DDX_Check(pDX, IDC_CHK_ROTATION, m_bIsRotation);
|
|||
|
|
DDX_Check(pDX, IDC_CHK_SETDIS, m_bIsSetDis);
|
|||
|
|
DDX_Check(pDX, IDC_CHK_RAND_SIZE, m_bIsRandSize);
|
|||
|
|
//}}AFX_DATA_MAP
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
BEGIN_MESSAGE_MAP(CSinglePlaceTreeDlg, CModelessDialog)
|
|||
|
|
//{{AFX_MSG_MAP(CMultPlaceTreeDlg)
|
|||
|
|
ON_BN_CLICKED(IDC_BUT_PICK, OnBnClickedButPick)
|
|||
|
|
ON_BN_CLICKED(IDC_BUT_RAD, OnBnClickedButRad)
|
|||
|
|
ON_BN_CLICKED(IDC_BUT_DIS, OnBnClickedButDis)
|
|||
|
|
ON_BN_CLICKED(IDC_CHK_RAND_SIZE, OnChkRandSize)
|
|||
|
|
ON_BN_CLICKED(IDC_CHK_ROTATION, OnChkRotation)
|
|||
|
|
ON_BN_CLICKED(IDC_CHK_SETDIS, OnChkSetDis)
|
|||
|
|
|
|||
|
|
ON_WM_PAINT()
|
|||
|
|
ON_WM_CLOSE()
|
|||
|
|
ON_BN_CLICKED(IDC_RAD_POINT, OnBnClickedDrawStyle)
|
|||
|
|
ON_BN_CLICKED(IDC_RAD_JIG, OnBnClickedDrawStyle)
|
|||
|
|
ON_BN_CLICKED(IDC_RAD_PATH, OnBnClickedDrawStyle)
|
|||
|
|
ON_BN_CLICKED(IDC_RAD_AREA_LAYOUT, OnBnClickedDrawStyle)
|
|||
|
|
ON_BN_CLICKED(IDC_RAD_FROMBLK, OnBnClickedTreeFormSelect)
|
|||
|
|
ON_BN_CLICKED(IDC_RAD_FROMGALLERY, OnBnClickedTreeFormSelect)
|
|||
|
|
ON_BN_CLICKED(IDC_RAD_FROMFILE, OnBnClickedTreeFormSelect)
|
|||
|
|
|
|||
|
|
//}}AFX_MSG_MAP
|
|||
|
|
//ON_BN_CLICKED(IDC_BUT_OFFSET, OnBnClickedButOffset)
|
|||
|
|
ON_EN_CHANGE(IDC_EDT_OFFSET, OnEnChangeEdtOffset)
|
|||
|
|
ON_EN_CHANGE(IDC_EDT_RAD, OnEnChangeEdtRad)
|
|||
|
|
ON_EN_CHANGE(IDC_EDT_DIS, OnEnChangeEdtDis)
|
|||
|
|
|
|||
|
|
END_MESSAGE_MAP()
|
|||
|
|
|
|||
|
|
BOOL CSinglePlaceTreeDlg::OnInitDialog()
|
|||
|
|
{
|
|||
|
|
CModelessDialog::OnInitDialog();
|
|||
|
|
UpdateData(FALSE);
|
|||
|
|
UpdateData(TRUE);
|
|||
|
|
|
|||
|
|
// 按钮图标
|
|||
|
|
m_hIcon = AfxGetApp()->LoadIcon(IDI_ICON_PICK);
|
|||
|
|
if (!m_hIcon)
|
|||
|
|
{
|
|||
|
|
AfxMessageBox(_T("无法找到指定ICON文件。"));
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
((CButton*)GetDlgItem(IDC_BUT_PICK))->SetIcon(m_hIcon);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// 获取当前的绘图单位,对话框标题设置
|
|||
|
|
if (DocGetMeterUnitDraw())
|
|||
|
|
{
|
|||
|
|
this->SetWindowText(_T("任意布树(单位:M)"));
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
this->SetWindowText(_T("任意布树(单位:mm)"));
|
|||
|
|
}
|
|||
|
|
AcDbObjectId idBlk;
|
|||
|
|
int n = 0;
|
|||
|
|
CString csBlkName = _T("tree1");
|
|||
|
|
while(!m_idTreeStyle.isValid())// 用户没有设值新的树形,使用默认值
|
|||
|
|
{
|
|||
|
|
m_idTreeStyle = InsertBlock(csBlkName, n);
|
|||
|
|
}
|
|||
|
|
// add by xly on 110329 解决图纸切换时,发生崩溃
|
|||
|
|
if (m_idTreeStyle.database()!=curDoc()->database())
|
|||
|
|
{
|
|||
|
|
m_idTreeStyle = InsertBlock(csBlkName, n);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
AcDbBlockTableRecord *pBTRecord = NULL;
|
|||
|
|
if(acdbOpenObject(pBTRecord, m_idTreeStyle, AcDb::kForRead) != Acad::eOk)
|
|||
|
|
{
|
|||
|
|
m_idTreeStyle = InsertBlock(csBlkName, n);
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
pBTRecord->close();
|
|||
|
|
|
|||
|
|
GetDlgItem(IDC_CHK_SETDIS)->EnableWindow(m_iDrawStyle==2);
|
|||
|
|
GetDlgItem(IDC_BUT_DIS)->EnableWindow(!(m_iDrawStyle==0 || m_iDrawStyle==3));
|
|||
|
|
GetDlgItem(IDC_EDT_DIS)->EnableWindow(!(m_iDrawStyle==0 || m_iDrawStyle==3));
|
|||
|
|
|
|||
|
|
UpdateControlState();
|
|||
|
|
GetDlgItem(IDC_BUT_PICK)->SetFocus();
|
|||
|
|
|
|||
|
|
// 预览
|
|||
|
|
if (!m_PreviewCtrl.SubclassDlgItem(IDC_STATIC_PREVIEW, this))
|
|||
|
|
return FALSE;
|
|||
|
|
m_PreviewCtrl.SetOrbitFlag(OBF_ZOOM|OBF_PAN);
|
|||
|
|
|
|||
|
|
// add by xly on 110325 设置显示方式
|
|||
|
|
UpdatePreview();
|
|||
|
|
|
|||
|
|
UpdateData(FALSE);
|
|||
|
|
return TRUE;
|
|||
|
|
}
|
|||
|
|
Adesk::Boolean acedPostCommand(const TCHAR * );
|
|||
|
|
void CSinglePlaceTreeDlg::OnClose()
|
|||
|
|
{
|
|||
|
|
m_bUseEsc = true;
|
|||
|
|
if (m_bModeless)
|
|||
|
|
{
|
|||
|
|
acedPostCommand(_T("\33\33"));
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
CModelessDialog::OnClose();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// 调用构件库
|
|||
|
|
BOOL InvokeTkwMan(const TCHAR *pszLib, BOOL bSelOnly, XString &sBlockName)
|
|||
|
|
{
|
|||
|
|
if (!AT_loaded(_T("wfB")))
|
|||
|
|
{
|
|||
|
|
#ifndef ZWCAD
|
|||
|
|
int nRet = acrxLoadModule(_T("wfB.arx"), Adesk::kTrue, true);
|
|||
|
|
#else
|
|||
|
|
int nRet = acrxLoadModule(_T("wfB.zrx"), Adesk::kTrue, true);
|
|||
|
|
#endif
|
|||
|
|
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;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
extern AcDbObjectId InsertBlock(CString &csBlkName, int &iTreeType);
|
|||
|
|
|
|||
|
|
// 获得天正图库中图块的ID
|
|||
|
|
AcDbObjectId CSinglePlaceTreeDlg::GetTgTreeBlockId(XString sBlockName)
|
|||
|
|
{
|
|||
|
|
AcDbObjectId idBlock;
|
|||
|
|
AcDbBlockTable *pBlockTab = NULL;
|
|||
|
|
if (acdbCurDwg()->getSymbolTable(pBlockTab, AcDb::kForWrite) != Acad::eOk) // 获得块表
|
|||
|
|
{
|
|||
|
|
return idBlock;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (pBlockTab->getAt(sBlockName, idBlock, false) == Acad::eOk) // 检查块是否存
|
|||
|
|
{
|
|||
|
|
pBlockTab->close();
|
|||
|
|
return idBlock;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
AcDbBlockTableRecord* pBlkRecord = new AcDbBlockTableRecord;
|
|||
|
|
pBlkRecord->setName(sBlockName);
|
|||
|
|
if (pBlockTab->add(idBlock, pBlkRecord) != Acad::eOk)
|
|||
|
|
{
|
|||
|
|
pBlockTab->close();
|
|||
|
|
delete pBlkRecord;
|
|||
|
|
return AcDbObjectId::kNull;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
pBlkRecord->close();
|
|||
|
|
pBlockTab->close();
|
|||
|
|
return idBlock;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// 树的绘制类型
|
|||
|
|
int CSinglePlaceTreeDlg::GetDrawType()
|
|||
|
|
{
|
|||
|
|
UpdateData(true);
|
|||
|
|
return m_iDrawStyle;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// 窗口重绘消息.
|
|||
|
|
void CSinglePlaceTreeDlg::OnPaint()
|
|||
|
|
{
|
|||
|
|
UpdateData(TRUE);
|
|||
|
|
|
|||
|
|
CPaintDC dc(this);
|
|||
|
|
CRect rcClip, rcImage;
|
|||
|
|
dc.GetClipBox(&rcClip);
|
|||
|
|
|
|||
|
|
CWnd *pImageBox = GetDlgItem(IDC_STATIC_PREVIEW);
|
|||
|
|
if (pImageBox)
|
|||
|
|
{
|
|||
|
|
pImageBox->GetWindowRect(&rcImage);
|
|||
|
|
ScreenToClient(&rcImage);
|
|||
|
|
if (!rcImage.IntersectRect(&rcImage, &rcClip))
|
|||
|
|
return;
|
|||
|
|
|
|||
|
|
CDC *pDC = pImageBox->GetDC();
|
|||
|
|
m_imgPreview.SetDC(pDC);
|
|||
|
|
m_imgPreview.Redraw();
|
|||
|
|
m_imgPreview.SetDC(NULL);
|
|||
|
|
pImageBox->ReleaseDC(pDC);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// 设置幻灯片
|
|||
|
|
void CSinglePlaceTreeDlg::SetPicture(CString &csFile)
|
|||
|
|
{
|
|||
|
|
UpdateData(TRUE);
|
|||
|
|
|
|||
|
|
XString sFilePath(256);
|
|||
|
|
sFilePath << csFile;
|
|||
|
|
|
|||
|
|
// 获得图片控件
|
|||
|
|
CWnd* pWndBmp = GetDlgItem(IDC_STATIC_PREVIEW);
|
|||
|
|
ASSERT(pWndBmp);
|
|||
|
|
|
|||
|
|
// 获得图片区域
|
|||
|
|
CDC *pDC = pWndBmp->GetDC();
|
|||
|
|
CRect rect;
|
|||
|
|
pWndBmp->GetClientRect(rect);
|
|||
|
|
|
|||
|
|
m_imgPreview.InitDC(pDC, rect, GetAcadBackColor());
|
|||
|
|
m_imgPreview.PaintSlide(sFilePath);
|
|||
|
|
m_imgPreview.SetDC(NULL);
|
|||
|
|
pWndBmp->ReleaseDC(pDC);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// 获得块的预览
|
|||
|
|
void CSinglePlaceTreeDlg::UpdatePreview()
|
|||
|
|
{
|
|||
|
|
UpdateData(TRUE);
|
|||
|
|
m_PreviewCtrl.clearAll();
|
|||
|
|
m_PreviewCtrl.init(true);
|
|||
|
|
|
|||
|
|
// 锁定当前文档
|
|||
|
|
acDocManager->lockDocument(curDoc());
|
|||
|
|
|
|||
|
|
// 块表记录
|
|||
|
|
AcDbBlockTableRecord *pBTRecord = NULL;
|
|||
|
|
if(acdbOpenObject(pBTRecord, m_idTreeStyle, AcDb::kForRead) != Acad::eOk)
|
|||
|
|
{
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// 定义本数据库的块表记录
|
|||
|
|
AcDbBlockTableRecordIterator *pItor = NULL;
|
|||
|
|
pBTRecord->newIterator(pItor);
|
|||
|
|
|
|||
|
|
// 预览数据库
|
|||
|
|
AcDbBlockTable *pBlockTab = NULL;
|
|||
|
|
Acad::ErrorStatus es = m_PreviewDb.getSymbolTable(pBlockTab, AcDb::kForWrite);
|
|||
|
|
if( es !=Acad::eOk)
|
|||
|
|
return;
|
|||
|
|
|
|||
|
|
// 定义预览数据库的块记录
|
|||
|
|
AcDbBlockTableRecord *pBlockTabRecord = new AcDbBlockTableRecord;
|
|||
|
|
pBlockTabRecord->setName(_T("*U"));
|
|||
|
|
|
|||
|
|
// 将块表中实体添加到新的数据库的块表记录中
|
|||
|
|
AcDbEntity *pClone = NULL,
|
|||
|
|
*pEnt = NULL;
|
|||
|
|
for (; !pItor->done(); pItor->step())
|
|||
|
|
{
|
|||
|
|
es = pItor->getEntity(pEnt,AcDb::kForRead,false);
|
|||
|
|
if (es != Acad::eOk)
|
|||
|
|
{
|
|||
|
|
delete pBlockTabRecord;
|
|||
|
|
pBlockTab->close();
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
pClone = (AcDbEntity*)pEnt->clone();
|
|||
|
|
es = pBlockTabRecord->appendAcDbEntity(pClone);
|
|||
|
|
if (es != Acad::eOk)
|
|||
|
|
{
|
|||
|
|
delete pBlockTabRecord;
|
|||
|
|
pBlockTab->close();
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
pClone->close();
|
|||
|
|
pEnt->close();
|
|||
|
|
}
|
|||
|
|
delete pItor;
|
|||
|
|
pBTRecord->close();
|
|||
|
|
|
|||
|
|
AcDbBlockReference *pRef = new AcDbBlockReference(AcGePoint3d(0,0,0), m_idTreeStyle);
|
|||
|
|
|
|||
|
|
// 获得块的包围盒
|
|||
|
|
AcDbExtents extents;
|
|||
|
|
pRef->getGeomExtents(extents);
|
|||
|
|
|
|||
|
|
// 块的外包盒的角点
|
|||
|
|
AcGePoint3d ptLow, ptUp;
|
|||
|
|
|
|||
|
|
// 获得图块的大小
|
|||
|
|
ptLow = extents.minPoint();
|
|||
|
|
ptUp = extents.maxPoint();
|
|||
|
|
double dXWidth = (ptUp.x-ptLow.x),
|
|||
|
|
dYHeigh = (ptUp.y-ptLow.y);
|
|||
|
|
|
|||
|
|
//pBlockTab->add(pBlockTabRecord);
|
|||
|
|
pBlockTab->close();
|
|||
|
|
pBlockTabRecord->close();
|
|||
|
|
|
|||
|
|
// 设置观察位置
|
|||
|
|
AcGePoint3d ptIns(extents.minPoint()/2 +extents.maxPoint()/2),
|
|||
|
|
target = ptIns;
|
|||
|
|
AcGePoint3d position(target.x, target.y, 1);
|
|||
|
|
m_PreviewCtrl.view()->setView(position, target, AcGeVector3d(0, 1, 0),dXWidth *2, dYHeigh*2);
|
|||
|
|
m_PreviewCtrl.view()->add(pBTRecord,m_PreviewCtrl.model());
|
|||
|
|
|
|||
|
|
m_PreviewCtrl.Invalidate();
|
|||
|
|
|
|||
|
|
acDocManager->unlockDocument(curDoc());
|
|||
|
|
UpdateData(FALSE);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// 设置对话框隐藏
|
|||
|
|
void CSinglePlaceTreeDlg::SetWindowHide(bool bHide)
|
|||
|
|
{
|
|||
|
|
if (bHide) // 隐藏
|
|||
|
|
{
|
|||
|
|
GetParent()->EnableWindow(TRUE);
|
|||
|
|
GetParent()->SetFocus();
|
|||
|
|
GetParent()->SetActiveWindow();
|
|||
|
|
ShowWindow(SW_HIDE);
|
|||
|
|
}
|
|||
|
|
else // 显示
|
|||
|
|
{
|
|||
|
|
GetParent()->EnableWindow(FALSE);
|
|||
|
|
EnableWindow(TRUE);
|
|||
|
|
SetActiveWindow();
|
|||
|
|
ShowWindow(SW_SHOW);
|
|||
|
|
GetParent()->EnableWindow(TRUE);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// 点取拾取按钮实现
|
|||
|
|
void CSinglePlaceTreeDlg::OnBnClickedButPick()
|
|||
|
|
{
|
|||
|
|
UpdateData(TRUE);
|
|||
|
|
|
|||
|
|
// 图块的ID
|
|||
|
|
AcDbObjectId endId;
|
|||
|
|
AcApDocument *pDoc = acDocManager->curDocument();
|
|||
|
|
|
|||
|
|
// 选择不同的树形选择方式
|
|||
|
|
switch(m_iTreeType)
|
|||
|
|
{
|
|||
|
|
case 0: // 点取本图图块
|
|||
|
|
{
|
|||
|
|
SetWindowHide(true);
|
|||
|
|
|
|||
|
|
// 选择图块
|
|||
|
|
Entity ent;
|
|||
|
|
int iRet;
|
|||
|
|
TADSGePoint3d ptPick;
|
|||
|
|
RBList rbList(RTDXF0, _T("INSERT,TCH_BLOCK_INSERT"), NULL);
|
|||
|
|
iRet = SelectEntity1(_T("\n请选择要布置的图块<返回>:"), ent,ptPick,rbList);
|
|||
|
|
while(iRet == RTERROR)
|
|||
|
|
{
|
|||
|
|
iRet = SelectEntity1(_T("\n请选择要布置的图块<返回>:"), ent, ptPick,rbList);
|
|||
|
|
/*if(iRet == RTNORM)
|
|||
|
|
{
|
|||
|
|
break;
|
|||
|
|
}*/
|
|||
|
|
}
|
|||
|
|
if(iRet == RTNORM) // 获取图块成功
|
|||
|
|
{
|
|||
|
|
// 锁定文档
|
|||
|
|
//acDocManager->lockDocument(pDoc);
|
|||
|
|
|
|||
|
|
// 获得块表记录的ID
|
|||
|
|
OPENOBJ_BEGIN(ent, AcDb::kForRead, AcDbBlockReference, pBlkRef);
|
|||
|
|
m_idTreeStyle = pBlkRef->blockTableRecord();
|
|||
|
|
OPENOBJ_END();
|
|||
|
|
//acDocManager->unlockDocument(pDoc);
|
|||
|
|
|
|||
|
|
// 预览块
|
|||
|
|
UpdatePreview();
|
|||
|
|
}
|
|||
|
|
/*else if (iRet!=RTNONE)//delete by xly on 110325 退出时返回对话框
|
|||
|
|
{
|
|||
|
|
return;
|
|||
|
|
}*/
|
|||
|
|
SetWindowHide(false);
|
|||
|
|
|
|||
|
|
acedGetAcadDwgView()->SetFocus();
|
|||
|
|
|
|||
|
|
// add by xly on 110327 更新命令行提示
|
|||
|
|
if (m_iDrawStyle==0)
|
|||
|
|
{
|
|||
|
|
acutPrintf(_T("\n请点取插入点<退出>:"));
|
|||
|
|
}
|
|||
|
|
else if (m_iDrawStyle==1)
|
|||
|
|
{
|
|||
|
|
acutPrintf(_T("\n请输入起始点<退出>:"));
|
|||
|
|
}
|
|||
|
|
else if(m_iDrawStyle==2)
|
|||
|
|
{
|
|||
|
|
acutPrintf(_T("\n请选择作为路径的曲线(直线、圆弧、多段线)<退出>:"));
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
break;
|
|||
|
|
case 1: // 从图库选择
|
|||
|
|
{
|
|||
|
|
// 找到sys路径下的dwg文件
|
|||
|
|
CString szFileName = _T("植物.TKW"),
|
|||
|
|
sLibFile = g_sDwbPath;
|
|||
|
|
sLibFile = sLibFile.Left(sLibFile.GetLength() - 5) + _T("\\DWB\\") + szFileName;
|
|||
|
|
|
|||
|
|
XString sBlockName;
|
|||
|
|
|
|||
|
|
// modify by xly on 110325 修改默认值
|
|||
|
|
//sBlockName= m_csTreeStyle;
|
|||
|
|
sBlockName = _T("植物(00000092)");
|
|||
|
|
if (InvokeTkwMan(sLibFile, TRUE, sBlockName))
|
|||
|
|
{
|
|||
|
|
szFileName = (const TCHAR *)(XPathParser(sBlockName).m_sFileName);
|
|||
|
|
sLibFile = g_sDwbPath;
|
|||
|
|
CString csPath = sLibFile.Left(sLibFile.GetLength() - 5) + _T("\\DWB\\");
|
|||
|
|
csPath += szFileName;
|
|||
|
|
|
|||
|
|
// 锁定文档
|
|||
|
|
acDocManager->lockDocument(pDoc);
|
|||
|
|
|
|||
|
|
int nRet = LoadDwbBlock(csPath,sBlockName);
|
|||
|
|
if(nRet == RTNORM)
|
|||
|
|
{
|
|||
|
|
m_idTreeStyle = InitBlock(sBlockName);
|
|||
|
|
//m_csTreeStyle = csPath;
|
|||
|
|
}
|
|||
|
|
acDocManager->unlockDocument(pDoc);
|
|||
|
|
|
|||
|
|
UpdatePreview();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
break;
|
|||
|
|
case 2: // 从文件选取
|
|||
|
|
{
|
|||
|
|
// 定义打开文件对话框
|
|||
|
|
CString csFilter = _T("CAD图形文件(*.dwg)|*.dwg");
|
|||
|
|
CFileDialog dlg(TRUE, NULL, NULL, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,
|
|||
|
|
csFilter, NULL);
|
|||
|
|
|
|||
|
|
// 设置对话框默认呈现的路径
|
|||
|
|
CString sLibFile = g_sDwbPath;
|
|||
|
|
sLibFile = sLibFile.Left(sLibFile.GetLength() - 5);
|
|||
|
|
dlg.m_ofn.lpstrInitialDir = sLibFile;
|
|||
|
|
|
|||
|
|
if (dlg.DoModal() != IDOK)
|
|||
|
|
return;
|
|||
|
|
|
|||
|
|
// 获得文件名
|
|||
|
|
CString strFilePath = dlg.GetPathName();
|
|||
|
|
if (strFilePath.IsEmpty())
|
|||
|
|
return;
|
|||
|
|
//判断图纸版本和当前CAD版本是否匹配
|
|||
|
|
if (!JudgeVersion(strFilePath))
|
|||
|
|
{
|
|||
|
|
acutPrintf(_T("不能打开此 DWG 文件,因为它是使用更新版本的 AutoCAD 创建的。"));
|
|||
|
|
acutPrintf(_T("请从 Autodesk 下载 DWG TrueConvert 工具,已将 DWG 文件转换为不同版本"));
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
// 锁定文档
|
|||
|
|
acDocManager->lockDocument(pDoc);
|
|||
|
|
|
|||
|
|
// 打开dwg文件
|
|||
|
|
AcDbDatabase *pXrefDb = new AcDbDatabase(Adesk::kFalse);
|
|||
|
|
#if ADS < 21
|
|||
|
|
Acad::ErrorStatus es = pXrefDb->readDwgFile(strFilePath,_SH_DENYNO, false);
|
|||
|
|
#else
|
|||
|
|
Acad::ErrorStatus es = pXrefDb->readDwgFile(strFilePath, AcDbDatabase::kForReadAndAllShare, false);
|
|||
|
|
#endif
|
|||
|
|
if (es != Acad::eOk)
|
|||
|
|
{
|
|||
|
|
delete pXrefDb;
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// 将树形文件以块的形式插入数据库
|
|||
|
|
if (acdbCurDwg()->insert(m_idTreeStyle, _T("*UT"), pXrefDb, true) != Acad::eOk)
|
|||
|
|
{
|
|||
|
|
delete pXrefDb;
|
|||
|
|
return ;
|
|||
|
|
}
|
|||
|
|
delete pXrefDb;
|
|||
|
|
acDocManager->unlockDocument(pDoc);
|
|||
|
|
|
|||
|
|
// 预览dwg图纸
|
|||
|
|
UpdatePreview();
|
|||
|
|
}
|
|||
|
|
break;
|
|||
|
|
default:
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if(!GET_GLOBAL_VARIABLE(GlwPlaceTreeDataManage))
|
|||
|
|
SET_GLOBAL_VARIABLE(GlwPlaceTreeDataManage, new GlwPlaceTreeDataManage);
|
|||
|
|
GlwPlaceTreeDataManage *pDataManage = GET_GLOBAL_VARIABLE(GlwPlaceTreeDataManage);
|
|||
|
|
pDataManage->SetTreeId(m_idTreeStyle);
|
|||
|
|
UpdateData(FALSE);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// 切换绘制方式
|
|||
|
|
void CSinglePlaceTreeDlg::OnBnClickedDrawStyle()
|
|||
|
|
{
|
|||
|
|
if(!GET_GLOBAL_VARIABLE(GlwPlaceTreeDataManage))
|
|||
|
|
SET_GLOBAL_VARIABLE(GlwPlaceTreeDataManage, new GlwPlaceTreeDataManage);
|
|||
|
|
GlwPlaceTreeDataManage *pDataManage = GET_GLOBAL_VARIABLE(GlwPlaceTreeDataManage);
|
|||
|
|
UpdateData(TRUE);
|
|||
|
|
GetDlgItem(IDC_CHK_SETDIS)->EnableWindow(m_iDrawStyle==2);
|
|||
|
|
|
|||
|
|
// add by xly on 110324 任意绘制时树间距不可用
|
|||
|
|
if (m_iDrawStyle==0 || m_iDrawStyle==3)
|
|||
|
|
GetDlgItem(IDC_BUT_DIS)->EnableWindow(false);
|
|||
|
|
if (m_iDrawStyle==0 || m_iDrawStyle==3)
|
|||
|
|
{
|
|||
|
|
GetDlgItem(IDC_BUT_DIS)->EnableWindow(FALSE);
|
|||
|
|
GetDlgItem(IDC_EDT_DIS)->EnableWindow(FALSE);
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
GetDlgItem(IDC_BUT_DIS)->EnableWindow(TRUE);
|
|||
|
|
GetDlgItem(IDC_EDT_DIS)->EnableWindow(TRUE);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
UpdateControlState();
|
|||
|
|
pDataManage->SetDrawType(m_iDrawStyle);
|
|||
|
|
m_bUseEsc = false;
|
|||
|
|
acedPostCommand(_T("\33"));
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void CSinglePlaceTreeDlg::OnBnClickedTreeFormSelect()
|
|||
|
|
{
|
|||
|
|
UpdateData(TRUE);
|
|||
|
|
if(!GET_GLOBAL_VARIABLE(GlwPlaceTreeDataManage))
|
|||
|
|
SET_GLOBAL_VARIABLE(GlwPlaceTreeDataManage, new GlwPlaceTreeDataManage);
|
|||
|
|
GlwPlaceTreeDataManage *pDataManage = GET_GLOBAL_VARIABLE(GlwPlaceTreeDataManage);
|
|||
|
|
pDataManage->SetTreeType(m_iTreeType);
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
void CSinglePlaceTreeDlg::OnBnClickedButRad()
|
|||
|
|
{
|
|||
|
|
UpdateData(TRUE);
|
|||
|
|
if(!GET_GLOBAL_VARIABLE(GlwPlaceTreeDataManage))
|
|||
|
|
SET_GLOBAL_VARIABLE(GlwPlaceTreeDataManage, new GlwPlaceTreeDataManage);
|
|||
|
|
GlwPlaceTreeDataManage *pDataManage = GET_GLOBAL_VARIABLE(GlwPlaceTreeDataManage);
|
|||
|
|
GetDis(m_csRad, true);
|
|||
|
|
pDataManage->SetTreeRad(_tstof(m_csRad));
|
|||
|
|
UpdateData(FALSE);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void CSinglePlaceTreeDlg::OnBnClickedButDis()
|
|||
|
|
{
|
|||
|
|
UpdateData(TRUE);
|
|||
|
|
if(!GET_GLOBAL_VARIABLE(GlwPlaceTreeDataManage))
|
|||
|
|
SET_GLOBAL_VARIABLE(GlwPlaceTreeDataManage, new GlwPlaceTreeDataManage);
|
|||
|
|
GlwPlaceTreeDataManage *pDataManage = GET_GLOBAL_VARIABLE(GlwPlaceTreeDataManage);
|
|||
|
|
GetDis(m_csDis, false);
|
|||
|
|
pDataManage->SetTreeDis(_tstof(m_csDis));
|
|||
|
|
UpdateData(FALSE);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void CSinglePlaceTreeDlg::OnChkRandSize()
|
|||
|
|
{
|
|||
|
|
UpdateData(TRUE);
|
|||
|
|
if(!GET_GLOBAL_VARIABLE(GlwPlaceTreeDataManage))
|
|||
|
|
SET_GLOBAL_VARIABLE(GlwPlaceTreeDataManage, new GlwPlaceTreeDataManage);
|
|||
|
|
GlwPlaceTreeDataManage *pDataManage = GET_GLOBAL_VARIABLE(GlwPlaceTreeDataManage);
|
|||
|
|
pDataManage->SetIsSetRandSize(m_bIsRandSize);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void CSinglePlaceTreeDlg::OnChkRotation()
|
|||
|
|
{
|
|||
|
|
UpdateData(TRUE);
|
|||
|
|
if(!GET_GLOBAL_VARIABLE(GlwPlaceTreeDataManage))
|
|||
|
|
SET_GLOBAL_VARIABLE(GlwPlaceTreeDataManage, new GlwPlaceTreeDataManage);
|
|||
|
|
GlwPlaceTreeDataManage *pDataManage = GET_GLOBAL_VARIABLE(GlwPlaceTreeDataManage);
|
|||
|
|
pDataManage->SetIsSetRotation(m_bIsRotation);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void CSinglePlaceTreeDlg::OnChkSetDis()
|
|||
|
|
{
|
|||
|
|
UpdateData(TRUE);
|
|||
|
|
if(!GET_GLOBAL_VARIABLE(GlwPlaceTreeDataManage))
|
|||
|
|
SET_GLOBAL_VARIABLE(GlwPlaceTreeDataManage, new GlwPlaceTreeDataManage);
|
|||
|
|
GlwPlaceTreeDataManage *pDataManage = GET_GLOBAL_VARIABLE(GlwPlaceTreeDataManage);
|
|||
|
|
pDataManage->SetIsSetDis(m_bIsSetDis);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void CSinglePlaceTreeDlg::OnEnChangeEdtRad()
|
|||
|
|
{
|
|||
|
|
UpdateData(TRUE);
|
|||
|
|
if(!GET_GLOBAL_VARIABLE(GlwPlaceTreeDataManage))
|
|||
|
|
SET_GLOBAL_VARIABLE(GlwPlaceTreeDataManage, new GlwPlaceTreeDataManage);
|
|||
|
|
GlwPlaceTreeDataManage *pDataManage = GET_GLOBAL_VARIABLE(GlwPlaceTreeDataManage);
|
|||
|
|
|
|||
|
|
pDataManage->SetTreeRad(_tstof(m_csRad));
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void CSinglePlaceTreeDlg::OnEnChangeEdtDis()
|
|||
|
|
{
|
|||
|
|
UpdateData(TRUE);
|
|||
|
|
if(!GET_GLOBAL_VARIABLE(GlwPlaceTreeDataManage))
|
|||
|
|
SET_GLOBAL_VARIABLE(GlwPlaceTreeDataManage, new GlwPlaceTreeDataManage);
|
|||
|
|
GlwPlaceTreeDataManage *pDataManage = GET_GLOBAL_VARIABLE(GlwPlaceTreeDataManage);
|
|||
|
|
|
|||
|
|
pDataManage->SetTreeDis(_tstof(m_csDis));
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// 获取点取的距离
|
|||
|
|
void CSinglePlaceTreeDlg::GetDis(CString &csLength, bool isRadOrDis)
|
|||
|
|
{
|
|||
|
|
double nHeight = _tstof(csLength);
|
|||
|
|
|
|||
|
|
CString csPrompt = isRadOrDis ? _T("\n请点取树半径") : _T("\n请点取树间距");
|
|||
|
|
|
|||
|
|
BeginEditorCommand();
|
|||
|
|
if (GetDist(csPrompt, nHeight, RSG_NOZERO|RSG_NONEG) == RTNORM)
|
|||
|
|
{
|
|||
|
|
csLength = GetFormatData(nHeight);
|
|||
|
|
}
|
|||
|
|
CompleteEditorCommand();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/*
|
|||
|
|
void CSinglePlaceTreeDlg::OnBnClickedButOffset()
|
|||
|
|
{
|
|||
|
|
UpdateData(TRUE);
|
|||
|
|
if(!GET_GLOBAL_VARIABLE(GlwPlaceTreeDataManage))
|
|||
|
|
SET_GLOBAL_VARIABLE(GlwPlaceTreeDataManage, new GlwPlaceTreeDataManage);
|
|||
|
|
GlwPlaceTreeDataManage *pDataManage = GET_GLOBAL_VARIABLE(GlwPlaceTreeDataManage);
|
|||
|
|
SetWindowHide(TRUE);
|
|||
|
|
ads_real dDist;
|
|||
|
|
double dOffset = _tstof(m_csOffset);
|
|||
|
|
int i=0;
|
|||
|
|
CString strTip = _T("");
|
|||
|
|
strTip.Format(_T("请点取偏移距离<%d>:"), dOffset);
|
|||
|
|
if (acedGetDist(NULL, strTip, &dDist) == RTNORM)
|
|||
|
|
{
|
|||
|
|
dOffset = dDist;
|
|||
|
|
}
|
|||
|
|
m_csOffset = GetFormatData(dOffset);
|
|||
|
|
pDataManage->SetTreeOffset(_tstof(m_csOffset));
|
|||
|
|
UpdateData(FALSE);
|
|||
|
|
SetWindowHide(FALSE);
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
*/
|
|||
|
|
|
|||
|
|
int is_digit(WCHAR *str)
|
|||
|
|
{
|
|||
|
|
size_t len = wcslen(str);
|
|||
|
|
size_t lenPre = len;
|
|||
|
|
bool bDoubleFlag = false;
|
|||
|
|
while(len > 0)
|
|||
|
|
{
|
|||
|
|
if (len != lenPre && *str == '.' && bDoubleFlag == false)//判断是否是double值
|
|||
|
|
{
|
|||
|
|
bDoubleFlag = true;
|
|||
|
|
}
|
|||
|
|
else if (*str < '0' || *str > '9') {
|
|||
|
|
return -1;
|
|||
|
|
}
|
|||
|
|
str++;
|
|||
|
|
len--;
|
|||
|
|
}
|
|||
|
|
return 0;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void CSinglePlaceTreeDlg::OnEnChangeEdtOffset()
|
|||
|
|
{
|
|||
|
|
if(!GET_GLOBAL_VARIABLE(GlwPlaceTreeDataManage))
|
|||
|
|
SET_GLOBAL_VARIABLE(GlwPlaceTreeDataManage, new GlwPlaceTreeDataManage);
|
|||
|
|
GlwPlaceTreeDataManage *pDataManage = GET_GLOBAL_VARIABLE(GlwPlaceTreeDataManage);
|
|||
|
|
CString strOffset = _T("");
|
|||
|
|
BOOL bIsNum = FALSE;
|
|||
|
|
GetDlgItem(IDC_EDT_OFFSET)->GetWindowText(strOffset);
|
|||
|
|
if (strOffset.GetLength() > 0)
|
|||
|
|
{
|
|||
|
|
if (strOffset.GetAt(0) < '0' || strOffset.GetAt(0) > '9')
|
|||
|
|
{
|
|||
|
|
AfxMessageBox(_T("请输入≥0的数值!"));
|
|||
|
|
UpdateData(FALSE);
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
if (strOffset.GetLength() >= 2)
|
|||
|
|
{
|
|||
|
|
if (strOffset.GetAt(0) == '0')
|
|||
|
|
{
|
|||
|
|
if (strOffset.GetAt(1) == '.')
|
|||
|
|
{
|
|||
|
|
CString strTemp;
|
|||
|
|
strTemp = strOffset.Right(1);
|
|||
|
|
WCHAR *wch = (WCHAR*)strTemp.GetBuffer(strTemp.GetLength());
|
|||
|
|
if (strOffset.GetLength() > 2)
|
|||
|
|
{
|
|||
|
|
if (is_digit(wch) == -1)
|
|||
|
|
{
|
|||
|
|
AfxMessageBox(_T("请输入≥0的数值!"));
|
|||
|
|
UpdateData(FALSE);
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
UpdateData(TRUE);
|
|||
|
|
pDataManage->SetTreeOffset(_tstof(m_csOffset));
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
AfxMessageBox(_T("请输入≥0的数值!"));
|
|||
|
|
UpdateData(FALSE);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
WCHAR *wch = (WCHAR*)strOffset.GetBuffer(strOffset.GetLength());
|
|||
|
|
strOffset.ReleaseBuffer(strOffset.GetLength());
|
|||
|
|
//关于小数点的问题
|
|||
|
|
if (is_digit(wch) == -1)
|
|||
|
|
{
|
|||
|
|
AfxMessageBox(_T("请输入≥0的数值!"));
|
|||
|
|
UpdateData(FALSE);
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
UpdateData(TRUE);
|
|||
|
|
pDataManage->SetTreeOffset(_tstof(m_csOffset));
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
UpdateData(TRUE);
|
|||
|
|
pDataManage->SetTreeOffset(_tstof(m_csOffset));
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void CSinglePlaceTreeDlg::UpdateControlState()
|
|||
|
|
{
|
|||
|
|
GetDlgItem(IDC_CHK_RAND_SIZE)->EnableWindow(m_iDrawStyle == 0 || m_iDrawStyle == 3);
|
|||
|
|
//GetDlgItem(IDC_BUT_OFFSET)->EnableWindow(m_iDrawStyle == 1 || m_iDrawStyle == 2);
|
|||
|
|
GetDlgItem(IDC_EDT_OFFSET)->EnableWindow(m_iDrawStyle == 1 || m_iDrawStyle == 2);
|
|||
|
|
}
|