4356 lines
132 KiB
C++
4356 lines
132 KiB
C++
// SanitaryDlg.cpp : implementation file
|
|
//
|
|
|
|
#include "stdafx.h"
|
|
#include "SanitaryDlg.h"
|
|
#include "SaniFittingAttrDlg.h"
|
|
#include "BathAttrDlg.h"
|
|
#include "FloorDrainAttrDlg.h"
|
|
#include "DecorateSaniFittingDlg.h"
|
|
#include "DecorateBathDlg.h"
|
|
#include "TArchCmdReactor.h"
|
|
// [1/15/2008 nsh]
|
|
//--------------begin----------------
|
|
#include "dbents.h"
|
|
#include "dbjig.h"
|
|
#include "dbcurve.h"
|
|
//---------------end-----------------
|
|
|
|
#ifdef _DEBUG
|
|
#define new DEBUG_NEW
|
|
#undef THIS_FILE
|
|
static char THIS_FILE[] = __FILE__;
|
|
#endif
|
|
|
|
int AddSaniwareToLibrary(const TCHAR *szBlock, PickSet &ss, XPoint &basePt);
|
|
int ReplaceSaniware(const CSaniFittingAttr &data);
|
|
int PlaceSaniWare1(CDecorateSaniFittingDlg &dlg, CSaniFittingAttr &data);
|
|
int PlaceSaniWare2(CDecorateBathTubDlg &dlg, CSaniFittingAttr &data);
|
|
void PlaceSaniWare3(const CSaniFittingAttr &data);
|
|
void PlaceSaniWare4(const CSaniFittingAttr &data);
|
|
int SelectWallSideOrComponent(XPoint &ptFrom, double * nPlaceDirection, double *nNormalAngle);
|
|
void DrawPlatNew(XPointDir2d insertPoint//洁具的插入点用于判断洁具布置与墙的法线方向
|
|
,const XDirectionCurve &cvTemp,//布置洁具的墙体曲线
|
|
BOOL bRever,//曲线是否反向
|
|
double dPlatLength,//平台初始长度
|
|
double dPlatWidth//平台初始宽度
|
|
);
|
|
//GEOAPI BOOL arxWBlock(PickSet &ss, const TCHAR* szFileName, XPoint ptIns);
|
|
// [1/15/2008 nsh]
|
|
//--------------------------------------begin---------------------------------------
|
|
//函数声明
|
|
int DrawSantitary( CDecorateSaniFittingDlg &dlg,CSaniFittingAttr &data);
|
|
int DrawSantitary1(const CSaniFittingAttr &data);
|
|
int DrawSantitary2(CDecorateBathTubDlg &dlg, CSaniFittingAttr &data);
|
|
class TSanitaryJig;
|
|
//---------------------------------------end----------------------------------------
|
|
|
|
inline XLine Ucs2Wcs(XLine ln)
|
|
{
|
|
XLine lnRet=ln;
|
|
lnRet.StartPoint()=Ucs2Wcs(ln.StartPoint());
|
|
lnRet.EndPoint()=Ucs2Wcs(ln.EndPoint());
|
|
return lnRet;
|
|
}
|
|
|
|
inline XLine Wcs2Ucs(XLine ln)
|
|
{
|
|
XLine lnRet=ln;
|
|
lnRet.StartPoint()=Wcs2Ucs(ln.StartPoint());
|
|
lnRet.EndPoint()=Wcs2Ucs(ln.EndPoint());
|
|
return lnRet;
|
|
}
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
// CSanitaryDlg dialog
|
|
|
|
IMPLEMENT_DYNAMIC(CSanitaryDlg, CTKImageDlg)
|
|
CSanitaryDlg::CSanitaryDlg(CWnd* pParent /*=NULL*/)
|
|
: CTKImageDlg(CSanitaryDlg::IDD, pParent)
|
|
{
|
|
//{{AFX_DATA_INIT(CSanitaryDlg)
|
|
// NOTE: the ClassWizard will add member initialization here
|
|
//}}AFX_DATA_INIT
|
|
m_nOpenMode = 0;
|
|
LoadStatus();
|
|
m_hOldItem = 0;
|
|
|
|
if(!ReadFile()) {
|
|
AfxMessageBox(_T("读取文件错误,请判断文件是否存在或为只读状态。"));
|
|
}
|
|
}
|
|
|
|
|
|
void CSanitaryDlg::DoDataExchange(CDataExchange* pDX)
|
|
{
|
|
CTKImageDlg::DoDataExchange(pDX);
|
|
//{{AFX_DATA_MAP(CSanitaryDlg)
|
|
// NOTE: the ClassWizard will add DDX and DDV calls here
|
|
//}}AFX_DATA_MAP
|
|
}
|
|
|
|
|
|
BEGIN_MESSAGE_MAP(CSanitaryDlg, CTKImageDlg)
|
|
//{{AFX_MSG_MAP(CSanitaryDlg)
|
|
ON_NOTIFY(TVN_SELCHANGED, IDC_TK_TREE, OnSelchangedTkTree)
|
|
ON_WM_LBUTTONDOWN()
|
|
ON_NOTIFY(LVN_ITEMCHANGED, IDC_TK_LIST, OnItemchangedTkList)
|
|
ON_COMMAND(ID_BLK_DEL, OnBlkDel)
|
|
ON_NOTIFY(TBN_DROPDOWN, IDR_SANITARY, OnToolbarDropDown)
|
|
ON_COMMAND(ID_BLK_LAYOUT, OnBlkLayout)
|
|
ON_COMMAND(ID_BLK_PROPERTIES, OnBlkProperties)
|
|
ON_COMMAND(ID_BLK_NEWDWG, OnBlkNewdwg)
|
|
ON_COMMAND(ID_BLK_REBUILD, OnBlkRebuild)
|
|
ON_COMMAND(ID_BLK_REPLACE, OnBlkReplace)
|
|
ON_WM_CONTEXTMENU()
|
|
ON_NOTIFY(LVN_ENDLABELEDIT, IDC_TK_LIST, OnEndlabeleditTkList)
|
|
ON_COMMAND(ID_BLK_RENAME, OnBlkRename)
|
|
ON_NOTIFY(LVN_BEGINLABELEDIT, IDC_TK_LIST, OnBeginlabeleditTkList)
|
|
ON_NOTIFY(NM_CLICK, IDC_TK_TREE, OnClickTkTree)
|
|
ON_WM_CLOSE()
|
|
//}}AFX_MSG_MAP
|
|
|
|
END_MESSAGE_MAP()
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
// CSanitaryDlg message handlers
|
|
|
|
void CSanitaryDlg::OnClose()
|
|
{
|
|
SaveStatus();
|
|
CTKImageDlg::OnClose();
|
|
}
|
|
BOOL CSanitaryDlg::OnInitDialog()
|
|
{
|
|
CTKImageDlg::OnInitDialog();
|
|
SetWindowText(_T("上华洁具"));
|
|
CTemporaryResourceOverride vTmp;
|
|
m_imageTree.Create( IDB_TREE, 14, 1, RGB(255,255,255) );
|
|
m_treeCtrl.SetImageList( &m_imageTree, TVSIL_NORMAL );
|
|
m_imageList.Create( IDB_LIST, 14, 1, RGB(255,255,255) );
|
|
m_listCtrl.SetImageList( &m_imageList, LVSIL_SMALL);
|
|
|
|
SetupTreeView();
|
|
|
|
//add by xlc on 080828
|
|
if(m_nOpenMode == 0)
|
|
{
|
|
m_menu.LoadMenu(IDR_MENU_SANIT);
|
|
SetMenu(&m_menu);
|
|
}
|
|
else if(m_nOpenMode == 1)
|
|
{
|
|
m_menu.LoadMenu(IDR_MENU_SANIT);
|
|
SetMenu(&m_menu);
|
|
}
|
|
|
|
InitToolBar();
|
|
SetStateText(_T("初始化完毕!"));
|
|
SetListHighLight();
|
|
|
|
m_treeCtrl.Expand(m_treeCtrl.GetRootItem(), TVE_EXPAND);
|
|
return FALSE; // return TRUE unless you set the focus to a control
|
|
}
|
|
|
|
void CSanitaryDlg::SetupListView()
|
|
{
|
|
int n=1;
|
|
HTREEITEM myhtree;
|
|
m_listCtrl.DeleteAllItems();
|
|
myhtree = m_treeCtrl.GetSelectedItem();
|
|
m_csCurGroup = m_treeCtrl.GetItemText(myhtree);
|
|
ReadFile();
|
|
int len = m_lstComponents.Length();
|
|
for(int i=0; i<len ; i++)
|
|
{
|
|
m_listCtrl.InsertItem(i, m_lstComponents[i]->m_csDescName);
|
|
}
|
|
}
|
|
|
|
void CSanitaryDlg::OnToolbarDropDown(NMHDR* pnmtb, LRESULT *plr)
|
|
{
|
|
OnBlkLayout();
|
|
}
|
|
|
|
void CSanitaryDlg::OnBlkLayout()
|
|
{
|
|
CWnd *pWnd = &m_ToolBar;
|
|
CMenu menu;
|
|
CMenu* pPopup, *pPopupLayout;
|
|
CMenu popupMenu;
|
|
CRect rc;
|
|
pWnd->SendMessage(TB_GETRECT, ID_BLK_LAYOUT, (LPARAM)&rc);
|
|
pWnd->ClientToScreen(&rc);
|
|
|
|
{
|
|
CTemporaryResourceOverride vTemp;//加载菜单
|
|
menu.LoadMenu(IDR_MENU_IMAGELAYOUT);
|
|
}
|
|
pPopup = menu.GetSubMenu(0);
|
|
pPopupLayout = pPopup->GetSubMenu(8);
|
|
|
|
pPopupLayout->TrackPopupMenu( TPM_LEFTALIGN | TPM_LEFTBUTTON | TPM_VERTICAL,
|
|
rc.left, rc.bottom, this, &rc);
|
|
|
|
}
|
|
|
|
|
|
void CSanitaryDlg::InitToolBar()
|
|
{
|
|
CTemporaryResourceOverride vTmp;
|
|
if(m_nOpenMode == 0){
|
|
int ButtonID[]={ ID_BLK_NEWDWG, ID_BLK_REBUILD ,ID_BLK_PROPERTIES,
|
|
ID_BLK_DEL, 0, ID_BLK_LAYOUT, ID_BLK_PAGEUP,
|
|
ID_BLK_PAGEDOWN, 0, ID_BLK_REPLACE,IDOK,};
|
|
m_ToolBar.InitToolBar(ButtonID, 11, IDR_SANITARY, this);
|
|
}
|
|
else if(m_nOpenMode == 1) {
|
|
int ButtonID[]={ ID_BLK_PROPERTIES,
|
|
ID_BLK_DEL, 0, ID_BLK_LAYOUT, ID_BLK_PAGEUP,
|
|
ID_BLK_PAGEDOWN, 0, IDOK,};
|
|
m_ToolBar.InitToolBar(ButtonID, 8, IDR_SANITARY1, this);
|
|
}
|
|
m_ToolBar.SetStyle(ID_BLK_LAYOUT, TBSTYLE_DROPDOWN);
|
|
}
|
|
|
|
void CSanitaryDlg::SetupTreeView()
|
|
{
|
|
m_bIsDelTree = TRUE;
|
|
m_treeCtrl.DeleteAllItems();
|
|
m_bIsDelTree = FALSE;
|
|
HTREEITEM hHead= m_treeCtrl.InsertItem(_T("洁具"), 0, 1);
|
|
HTREEITEM hTemp=NULL, hFilter=NULL;
|
|
int lenTree = m_lstKindNames.Length();
|
|
|
|
|
|
for(int i=0; i<lenTree; i++) {
|
|
CString csNode = m_lstKindNames[i];
|
|
hTemp = m_treeCtrl.InsertItem(m_lstKindNames[i], 0, 1, hHead);
|
|
if(csNode == m_csCurGroup)
|
|
hFilter = hTemp; // !!! 记住默认树节点句柄
|
|
}
|
|
if(hFilter) {
|
|
ASSERT(hFilter); // add ZJQ
|
|
m_treeCtrl.SelectItem(hFilter);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
// 设置nIndex个图像/幻灯
|
|
void CSanitaryDlg::SetupNthImage(int nIndex, CImageDC *pImg)
|
|
{
|
|
BOOL bValid = IsValid(nIndex);
|
|
XString sFile(256);
|
|
if (bValid) {
|
|
sFile << g_sDwbPath << _T("lvtry(") << (const TCHAR *)m_lstComponents[nIndex]->m_csBlockName
|
|
<< _T(")");
|
|
}
|
|
|
|
if(!bValid) {
|
|
//pImg->Fill(RGB(192,192,192));
|
|
pImg->PaintSlide(NULL);
|
|
} else {
|
|
pImg->PaintSlide(sFile);
|
|
}
|
|
}
|
|
|
|
|
|
// 读取文件, 建立数据列表
|
|
BOOL CSanitaryDlg::ReadFile()
|
|
{
|
|
m_lstComponents.Reset();
|
|
m_lstKindNames.Reset();
|
|
|
|
XString sFile(256);
|
|
sFile << g_sDwbPath << _T("lvtry.dbf");
|
|
if(!FindFile(sFile))
|
|
return FALSE;
|
|
CodeBase db;
|
|
db.read_only = 1;
|
|
XDbfTable *pTable = db.Open(sFile);
|
|
if(!pTable)
|
|
return FALSE;
|
|
BOOL bFilter=(!m_csCurGroup.IsEmpty() && _tcscmp(m_csCurGroup, _T(""))!=0);
|
|
for(pTable->MoveFirst(); !pTable->IsEOF(); pTable->MoveNext()) {
|
|
CSaniFittingAttr *pData=new CSaniFittingAttr(pTable);
|
|
if(m_lstKindNames.Index(pData->m_csKindName, 0)<0)
|
|
m_lstKindNames.Append(tstrnew(pData->m_csKindName));
|
|
|
|
if(pData->m_csKindName==m_csCurGroup)
|
|
m_lstComponents.Append(pData);
|
|
else
|
|
delete pData;
|
|
}
|
|
|
|
m_lstComponents.QuickSort(CSaniFittingAttr::CompareForSortByKindName);
|
|
return TRUE;
|
|
}
|
|
|
|
void CSanitaryDlg::OnClickTkTree(NMHDR* pNMHDR, LRESULT* pResult)
|
|
{
|
|
//m_nIndex = 0; // 为了使每次改变类型时 当前图块设置为第一个。
|
|
*pResult = 0;
|
|
}
|
|
|
|
|
|
void CSanitaryDlg::OnSelchangedTkTree(NMHDR* pNMHDR, LRESULT* pResult)
|
|
{
|
|
if(m_bIsDelTree) return;
|
|
|
|
NM_TREEVIEW* pNMTreeView = (NM_TREEVIEW*)pNMHDR;
|
|
HTREEITEM myhtree;
|
|
myhtree = m_treeCtrl.GetSelectedItem();
|
|
|
|
m_treeCtrl.SetItemState(myhtree, TVIS_BOLD ,TVIS_BOLD);
|
|
SetupListView(); // 立即更新LISTVIEW
|
|
InitVSBar();
|
|
SetupImage(TRUE);
|
|
if(!IsValid(m_nIndex))
|
|
m_nIndex=0;
|
|
ASSERT(m_nIndex>=0);
|
|
|
|
if(m_hOldItem) {
|
|
m_treeCtrl.SetItemState(m_hOldItem, 0, TVIS_BOLD); // 让上一个节点字型恢复
|
|
if(m_lstComponents.Length() != 0) // 保证根目录选中时不执行
|
|
{
|
|
|
|
SelectIndex(m_nIndex);
|
|
SetListHighLight();
|
|
m_listCtrl.SetHotItem(m_nIndex);
|
|
}
|
|
}
|
|
SelectIndex(m_nIndex);
|
|
m_hOldItem = myhtree;
|
|
ResetStateText();
|
|
*pResult = 0;
|
|
}
|
|
|
|
int CSanitaryDlg::GetTotalRecords() //取得当前链表的节点个数
|
|
{
|
|
return m_lstComponents.Length();
|
|
}
|
|
|
|
void CSanitaryDlg::OnLButtonDown(UINT nFlags, CPoint point)
|
|
{
|
|
if(IsPointOnImage(point) && (!m_bBiginEdit))
|
|
SelectPageIndex(GetPageIndex(point));
|
|
else {
|
|
CTKImageDlg::OnLButtonDown(nFlags, point);
|
|
return;
|
|
}
|
|
|
|
ResetStateText();
|
|
|
|
CTKImageDlg::OnLButtonDown(nFlags, point);
|
|
}
|
|
|
|
void CSanitaryDlg::OnItemchangedTkList(NMHDR* pNMHDR, LRESULT* pResult)
|
|
{
|
|
NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR;
|
|
int nSel = m_listCtrl.GetNextItem(-1, LVNI_SELECTED);
|
|
if(nSel < 0)
|
|
return;
|
|
SelectIndex(nSel);
|
|
m_listCtrl.SetHotItem(nSel);
|
|
|
|
*pResult = 0;
|
|
ResetStateText();
|
|
}
|
|
|
|
|
|
|
|
|
|
// 取当前选中的数据
|
|
CSaniFittingAttr * CSanitaryDlg::GetCurrentSelection()
|
|
{
|
|
if(!IsCurrentValid())
|
|
return NULL;
|
|
return m_lstComponents[m_nIndex];
|
|
}
|
|
|
|
void CSanitaryDlg::OnBlkDel()
|
|
{
|
|
if(!IsCurrentValid()){
|
|
SetStateText(_T("请正确选择需要删除的洁具!"));
|
|
return;
|
|
}
|
|
|
|
if (AfxMessageBox(_T("真的删除当前项?"), MB_YESNO|MB_ICONEXCLAMATION|MB_DEFBUTTON2)==IDYES) {
|
|
CodeBase db;
|
|
XDbfTable *pTable=db.Open(XString(_T("%slvtry.DBF"), g_sDwbPath));
|
|
if(!pTable) {
|
|
AfxMessageBox(_T("你没有删除的权限!"));
|
|
return;
|
|
}
|
|
CSaniFittingAttr *pData = GetCurrentSelection();
|
|
if(pTable->MoveTo(_T("block"), pData->m_csBlockName, FALSE)) {
|
|
pTable->Delete();
|
|
}
|
|
pTable->Close();
|
|
|
|
XString sDwb(256), sSlb(256);
|
|
sDwb << g_sDwbPath << _T("lvtry.DWB");
|
|
sSlb << g_sDwbPath << _T("lvtry.SLB");
|
|
XDrawingLib dwb(sDwb);
|
|
XSlideLib slb(sSlb);
|
|
if(!(!dwb)) dwb.Remove(pData->m_csBlockName);
|
|
if(!(!slb)) slb.Remove(pData->m_csBlockName);
|
|
|
|
// Update View
|
|
ReadFile();
|
|
if(!IsCurrentValid()) {
|
|
m_nIndex --;
|
|
}
|
|
SetupTreeView();
|
|
SetupImage(TRUE);
|
|
ASSERT(IsCurrentValid());
|
|
SelectIndex(m_nIndex);
|
|
|
|
}
|
|
}
|
|
|
|
|
|
// 查看/更改洁具属性, 参数绘制的不能查询和更改
|
|
|
|
void CSanitaryDlg::OnBlkProperties()
|
|
{
|
|
if(!IsValid(m_nIndex)) {
|
|
SetStateText(_T("请正确选择洁具!"));
|
|
return;
|
|
}
|
|
CSaniFittingAttr *pData=GetCurrentSelection();
|
|
ASSERT(pData);
|
|
|
|
|
|
CSaniFittingAttrBaseDlg *pDlg=NULL;
|
|
if(pData->m_nPlaceFlag<=1) {
|
|
CSaniFittingAttrDlg *dlg1 = new CSaniFittingAttrDlg(this);
|
|
if(dlg1->SetFromSaniWare(*pData, FALSE)!=TRUE) {
|
|
delete dlg1;
|
|
return;
|
|
}
|
|
pDlg = dlg1;
|
|
} else if(pData->m_nPlaceFlag==2) {
|
|
CBathAttrDlg *dlg2 = new CBathAttrDlg(this);
|
|
if(dlg2->SetFromSaniWare(*pData, FALSE)!=TRUE) {
|
|
delete dlg2;
|
|
return;
|
|
}
|
|
pDlg = dlg2;
|
|
} else if(pData->m_nPlaceFlag==3) {
|
|
CFloorDrainAttrDlg *dlg3 = new CFloorDrainAttrDlg(this);
|
|
if(dlg3->SetFromSaniWare(*pData, FALSE)!=TRUE) {
|
|
delete dlg3;
|
|
return;
|
|
}
|
|
pDlg = dlg3;
|
|
} else {
|
|
return;
|
|
}
|
|
|
|
CTemporaryResourceOverride vTemp;
|
|
if(pDlg->DoModal()==IDOK) {
|
|
pDlg->WriteToSaniWare(*pData);
|
|
CodeBase db;
|
|
XString sDbfName(256);
|
|
sDbfName << g_sDwbPath << _T("lvtry.DBF");
|
|
XDbfTable *pTable=db.Open(sDbfName);
|
|
if(pTable) {
|
|
if(pTable->MoveTo(_T("block"), pData->m_csBlockName, FALSE)) {
|
|
pData->WriteToTable(pTable);
|
|
}
|
|
pTable->Close();
|
|
SetupTreeView();
|
|
ASSERT(IsValid(m_nIndex));
|
|
SelectIndex(m_nIndex);
|
|
UpdateData(FALSE);
|
|
}
|
|
}
|
|
delete pDlg;
|
|
}
|
|
|
|
void CSanitaryDlg::OnBlkNewdwg()
|
|
{
|
|
if(!IsCurrentValid()) {
|
|
SetStateText(_T("请先选择洁具类型!"));
|
|
return;
|
|
}
|
|
|
|
HideDialog(TRUE);
|
|
AddOrReplaceSaniWare(0);
|
|
HideDialog(FALSE);
|
|
|
|
}
|
|
|
|
void CSanitaryDlg::OnBlkRebuild()
|
|
{
|
|
if(!IsCurrentValid()) {
|
|
SetStateText(_T("请先选择洁具类型!"));
|
|
return;
|
|
}
|
|
|
|
HideDialog(TRUE);
|
|
AddOrReplaceSaniWare(1);
|
|
HideDialog(FALSE);
|
|
|
|
}
|
|
|
|
void CSanitaryDlg::OnBlkRename()
|
|
{
|
|
m_listCtrl.SetFocus();
|
|
ASSERT(IsValid(m_nIndex));
|
|
m_listCtrl.EditLabel(m_nIndex);
|
|
}
|
|
|
|
void CSanitaryDlg::OnBlkReplace()
|
|
{
|
|
if(IsValid(m_nIndex))
|
|
EndDialog(ID_BLK_REPLACE);
|
|
}
|
|
|
|
void CSanitaryDlg::OnEndlabeleditTkList(NMHDR* pNMHDR, LRESULT* pResult)
|
|
{
|
|
LV_DISPINFO* pDispInfo = (LV_DISPINFO*)pNMHDR;
|
|
if((pDispInfo->item.pszText != NULL)&&(pDispInfo->item.iItem != -1))
|
|
{
|
|
CSaniFittingAttr *pData=GetCurrentSelection();
|
|
ASSERT(pData);
|
|
pData->m_csDescName = pDispInfo->item.pszText;
|
|
|
|
CodeBase db;
|
|
XString sDbfName(256);
|
|
sDbfName << g_sDwbPath << _T("lvtry.DBF");
|
|
XDbfTable *pTable=db.Open(sDbfName);
|
|
if(pTable) {
|
|
if(pTable->MoveTo(_T("block"), pData->m_csBlockName, FALSE)) {
|
|
pData->WriteToTable(pTable);
|
|
}
|
|
pTable->Close();
|
|
SetupTreeView();
|
|
ASSERT(IsValid(m_nIndex));
|
|
SelectIndex(m_nIndex);
|
|
UpdateData(FALSE);
|
|
}
|
|
|
|
}
|
|
|
|
m_bBiginEdit = FALSE;
|
|
*pResult = 0;
|
|
}
|
|
|
|
|
|
// 新增加或替换一种洁具
|
|
BOOL CSanitaryDlg::AddOrReplaceSaniWare(int nButtonType) //nButtonType=0 ADDNEW 1 MODIFY
|
|
{
|
|
CSaniFittingAttr *pData=GetCurrentSelection();
|
|
if(!pData) return FALSE;
|
|
XPoint basePt;
|
|
ads_real sx, sy, sz;
|
|
|
|
PickSet ss(SS_FREE);
|
|
if(ss.Get()!=RTNORM) {
|
|
if(nButtonType==1 && YesNoQuestion(_T("\n是否改幻灯"))==Q_YES) {
|
|
if(XGetPoint(NULL, _T("\n请标识基点"), basePt)==RTNORM)
|
|
AddSaniwareToLibrary(pData->m_csBlockName, ss, basePt);
|
|
}
|
|
return TRUE;
|
|
}
|
|
{
|
|
XPoint ptCen;
|
|
int rc=ss.GetExtend(ptCen, &sx, &sy, &sz);
|
|
if(rc!=RTNORM) {
|
|
adsout << _T("\n不能判断出物体范围!");
|
|
return FALSE;
|
|
}
|
|
ptCen.z -= sz/2.0;
|
|
|
|
// 建立辅助线
|
|
//TCHAR clayer[80]=_T("");
|
|
InitLayer(LAY_TEMP);
|
|
XPushVarStr clayer(_T("CLAYER"), LAY_TEMP);
|
|
//xg_getvar(_T("clayer"), clayer);
|
|
#if 0
|
|
ads_command(RTSTR, _T("-layer"), RTSTR, _T("m"), RTSTR, LAY_TEMP, RTSTR, _T("color"),
|
|
RTSTR, _T("1"), RTSTR, _T("_aux"), RTSTR, _T(""), NULL);
|
|
#endif
|
|
PickSet auxSet(SS_CREATE|SS_FREE);
|
|
auxSet.IncludeBegin();
|
|
XRectAngle box(ptCen, sx, sy);
|
|
XPoint cpt1(ptCen.x, ptCen.y-sy/2.0, ptCen.z),
|
|
cpt2(ptCen.x, ptCen.y+sy/2.0, ptCen.z);
|
|
if(pData->m_nPlaceFlag==3)
|
|
cpt2=ptCen;
|
|
|
|
int pdMode;
|
|
xg_getvar(_T("PDMODE"), &pdMode); xg_setvar(_T("PDMODE"), 3);
|
|
//box.Make(_T("_aux"));
|
|
MakeEntity(RTDXF0, _T("POINT"), 10, &cpt2.x, NULL);
|
|
auxSet.IncludeEnd();
|
|
|
|
adsout << _T("\n请输入基点") << Wcs2Ucs(cpt2) << _T(": ");
|
|
int nRetCode=ads_getpoint(Wcs2Ucs(cpt2), _T(""), basePt);
|
|
if(nRetCode==RTNONE)
|
|
basePt=Wcs2Ucs(cpt2);
|
|
else if(nRetCode!=RTNORM)
|
|
return FALSE;
|
|
//auxSet.Redraw(3);
|
|
|
|
auxSet.Erase();
|
|
//xg_setvar(_T("clayer"), clayer);
|
|
xg_setvar(_T("pdmode"), pdMode);
|
|
}
|
|
|
|
|
|
CSaniFittingAttrBaseDlg *pDlg=NULL;
|
|
if(pData->m_nPlaceFlag<=1) {
|
|
CSaniFittingAttrDlg *dlg1 = new CSaniFittingAttrDlg(acedGetAcadFrame());
|
|
if(dlg1->SetFromSaniWare(*pData, nButtonType==0? TRUE : FALSE)!=TRUE) {
|
|
delete dlg1;
|
|
return FALSE;
|
|
}
|
|
dlg1->m_dOrigenalSizeX = sx;
|
|
dlg1->m_dOrigenalSizeY = sy;
|
|
pDlg = dlg1;
|
|
} else if(pData->m_nPlaceFlag==2) {
|
|
CBathAttrDlg *dlg2 = new CBathAttrDlg(acedGetAcadFrame());
|
|
if(dlg2->SetFromSaniWare(*pData, nButtonType==0? TRUE : FALSE)!=TRUE) {
|
|
delete dlg2;
|
|
return FALSE;
|
|
}
|
|
dlg2->m_nOrigenalSizeX = AS_INT(sx);
|
|
dlg2->m_nOrigenalSizeY = AS_INT(sy);
|
|
pDlg = dlg2;
|
|
} else if(pData->m_nPlaceFlag==3) {
|
|
CFloorDrainAttrDlg *dlg3 = new CFloorDrainAttrDlg(acedGetAcadFrame());
|
|
if(dlg3->SetFromSaniWare(*pData, nButtonType==0? TRUE : FALSE)!=TRUE) {
|
|
delete dlg3;
|
|
return FALSE;
|
|
}
|
|
dlg3->m_nOrigenalSizeX = AS_INT(sx);
|
|
dlg3->m_nOrigenalSizeY = AS_INT(sy);
|
|
pDlg = dlg3;
|
|
} else {
|
|
return FALSE;
|
|
}
|
|
|
|
// pDlg==NULL作为逐点插入的类型
|
|
CTemporaryResourceOverride vTemp;
|
|
if(pDlg->DoModal()==IDOK) {
|
|
CSaniFittingAttr data;
|
|
pDlg->WriteToSaniWare(data);
|
|
CodeBase db;
|
|
XString sDbfName(256);
|
|
sDbfName << g_sDwbPath << _T("lvtry.DBF");
|
|
XDbfTable *pTable=db.Open(sDbfName);
|
|
|
|
if(pTable && AddSaniwareToLibrary(pDlg->m_csBlockName, ss, basePt)==RTNORM) {
|
|
if(nButtonType==0) {
|
|
pTable->AppendBegin();
|
|
data.WriteToTable(pTable);
|
|
pTable->AppendEnd();
|
|
} else {
|
|
if(pTable->MoveTo(_T("block"), data.m_csBlockName, FALSE)) {
|
|
data.WriteToTable(pTable);
|
|
}
|
|
}
|
|
pTable->Close();
|
|
|
|
ReadFile();
|
|
SetupTreeView();
|
|
SetCurrentItem(data, FALSE);
|
|
}
|
|
delete pDlg;
|
|
return TRUE;
|
|
}
|
|
delete pDlg;
|
|
return FALSE;
|
|
}
|
|
|
|
// 设置当前项, 并可选改变类别, 在对话框启动之前
|
|
BOOL CSanitaryDlg::SetCurrentItem(const CSaniFittingAttr &data, BOOL bSetGroup)
|
|
{
|
|
if(bSetGroup) {
|
|
if(_tcsicmp(data.m_csKindName, m_csCurGroup)!=0){
|
|
m_csCurGroup = data.m_csKindName;
|
|
ReadFile();
|
|
}
|
|
}
|
|
for(int i=0; i<m_lstComponents.Length(); i++) {
|
|
if(m_lstComponents[i]->m_csBlockName == data.m_csBlockName) {
|
|
m_nIndex = i;
|
|
return TRUE;
|
|
}
|
|
}
|
|
return FALSE;
|
|
}
|
|
// 往图库增加图块
|
|
// basePt--UCS
|
|
int AddSaniwareToLibrary(const TCHAR *szBlock, PickSet &ss, XPoint &basePt)
|
|
{
|
|
XString fullSld(256), fullDwg(256);
|
|
TCHAR szTempPath[256]=_T("");
|
|
GetTempPath(255, szTempPath);
|
|
if(szTempPath[_tcslen(szTempPath)-1]!=_T('\\'))
|
|
_tcscat(szTempPath, _T("\\"));
|
|
_tcscat(szTempPath, _T("SRTEMP\\"));
|
|
MakeDir(szTempPath);
|
|
|
|
|
|
//建幻灯
|
|
fullSld << szTempPath << szBlock << _T(".sld");
|
|
_tremove(fullSld);
|
|
{
|
|
XPushVar<int> pdMode(_T("PDMODE"), 3);
|
|
Entity eMarkPt;
|
|
XPoint ptWcs=Ucs2Wcs(basePt);
|
|
MakeEntity(RTDXF0, _T("POINT"), 10, &ptWcs, 62, 2, NULL);
|
|
eMarkPt.GetLast();
|
|
if(YesNoQuestion(_T("\n制作幻灯"))!=Q_YES) {
|
|
eMarkPt.Delete();
|
|
return RTERROR;
|
|
}
|
|
SHads_command(RTSTR, _T("MSLIDE"), RTSTR, (TCHAR *)fullSld, RTNONE);
|
|
eMarkPt.Delete();
|
|
}
|
|
XString slbFile(256);
|
|
slbFile << g_sDwbPath << _T("lvtry.SLB");
|
|
XSlideLib slb(slbFile);
|
|
if(!slb) {
|
|
adsout << _T("\nCan not open SLB file!");
|
|
return RTERROR;
|
|
}
|
|
slb.Append(fullSld);
|
|
_tremove(fullSld);
|
|
|
|
|
|
|
|
if(!ss) //只是改幻灯
|
|
return RTNORM;
|
|
fullDwg << szTempPath << szBlock << _T(".dwg");
|
|
_tremove(fullDwg);
|
|
|
|
/*
|
|
XPushVar<int> expert(_T("EXPERT"), 5);
|
|
XPushVar<int> vOsMode(_T("OSMODE"), 0);
|
|
ads_command(RTSTR, _T("WBLOCK"), RTSTR, (TCHAR *)fullDwg, RTSTR, _T(""),
|
|
RT3DPOINT, &basePt.x, RTPICKS, (long *)ss, RTSTR, _T(""), NULL);
|
|
ads_command(RTSTR, _T("OOPS"), NULL);
|
|
*/
|
|
if(!arxWBlock(ss, fullDwg, Ucs2Wcs(basePt)))
|
|
return RTERROR;
|
|
|
|
|
|
XString sLibFile(128);
|
|
sLibFile << g_sDwbPath << _T("lvtry.DWB");
|
|
XDrawingLib dwb(sLibFile);
|
|
if(!dwb) {
|
|
adsout << _T("\nCan not open DWB file!");
|
|
return RTERROR;
|
|
}
|
|
dwb.Append(fullDwg);
|
|
_tremove(fullDwg);
|
|
|
|
return RTNORM;
|
|
}
|
|
|
|
|
|
// 重载对话框的启动方法
|
|
INT_PTR CSanitaryDlg::DoModal()
|
|
{
|
|
INT_PTR nRetCode = CTKImageDlg::DoModal();
|
|
return nRetCode;
|
|
}
|
|
|
|
|
|
// 保存当前图标的排列
|
|
|
|
|
|
|
|
void CSanitaryDlg::SaveStatus()
|
|
{
|
|
XString strRoot;
|
|
_tcscat(strRoot, GetRegLocation());
|
|
_tcscat(strRoot, _T("\\Settings"));
|
|
CRegProperty regProp(strRoot, _T("lvtry"));
|
|
|
|
regProp.SetTopRootKey(HKEY_CURRENT_USER);
|
|
regProp.SetValue(_T("SanPageRow"), m_nPageRow);
|
|
regProp.SetValue(_T("SanPageColmn"), m_nPageColumn);
|
|
regProp.SetValue(_T("SanType"), m_csCurGroup);
|
|
regProp.SetValue(_T("SanIndex"), m_nIndex);
|
|
|
|
}
|
|
|
|
void CSanitaryDlg::ResetStateText()
|
|
{
|
|
CString csMsg, csRecord;
|
|
if(m_lstComponents.Length() == 0) return;
|
|
ASSERT(IsValid(m_nIndex));
|
|
csRecord = m_lstComponents[m_nIndex]->m_csBlockName;
|
|
csMsg.Format(_T("记录号:%s 页号:%d/%d 总数: %d"), (const TCHAR *)csRecord, CurPage() + 1, TotalPages(), GetTotalRecords());
|
|
SetStateText(csMsg);
|
|
}
|
|
|
|
|
|
void CSanitaryDlg::LoadStatus()
|
|
{
|
|
XString strRoot;
|
|
_tcscat(strRoot, GetRegLocation());
|
|
_tcscat(strRoot, _T("\\Settings"));
|
|
CRegProperty regProp(strRoot, _T("lvtry"));
|
|
regProp.SetTopRootKey(HKEY_CURRENT_USER);
|
|
int nRow=3, nColumn=2;
|
|
if(regProp.GetValue(_T("SanPageRow"), nRow) &&
|
|
regProp.GetValue(_T("SanPageColmn"), nColumn)) {
|
|
ASSERT(nRow>0 && nColumn>0);
|
|
}
|
|
regProp.GetValue(_T("SanType"), m_csCurGroup);
|
|
regProp.GetValue(_T("SanIndex"), m_nIndex);
|
|
|
|
SetPageSize(nRow, nColumn);
|
|
|
|
}
|
|
|
|
void CSanitaryDlg::OnContextMenu(CWnd* pWnd, CPoint point)
|
|
{
|
|
CMenu menu;
|
|
{
|
|
CTemporaryResourceOverride vTemp;//加载菜单
|
|
menu.LoadMenu(IDR_MENU_SANITARY);
|
|
}
|
|
if(IsInRect(IDC_PIC_IMAGE, point))
|
|
{
|
|
|
|
CMenu *pSubMenu = menu.GetSubMenu(0);
|
|
if(m_nOpenMode == 1) {
|
|
pSubMenu->DeleteMenu(1, MF_BYPOSITION);
|
|
pSubMenu->DeleteMenu(1, MF_BYPOSITION);
|
|
pSubMenu->DeleteMenu(1, MF_BYPOSITION);
|
|
pSubMenu->DeleteMenu(1, MF_BYPOSITION);
|
|
}
|
|
if(pSubMenu)
|
|
pSubMenu->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON,
|
|
point.x, point.y, this, NULL);
|
|
}
|
|
if(IsInRect(IDC_TK_LIST, point))
|
|
{
|
|
|
|
CMenu *pSubMenu = menu.GetSubMenu(0);
|
|
pSubMenu->DeleteMenu(8, MF_BYPOSITION);
|
|
pSubMenu->DeleteMenu(8, MF_BYPOSITION);
|
|
if(m_nOpenMode == 2) {
|
|
pSubMenu->DeleteMenu(1, MF_BYPOSITION);
|
|
pSubMenu->DeleteMenu(1, MF_BYPOSITION);
|
|
pSubMenu->DeleteMenu(1, MF_BYPOSITION);
|
|
pSubMenu->DeleteMenu(1, MF_BYPOSITION);
|
|
}
|
|
if(pSubMenu)
|
|
pSubMenu->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON,
|
|
point.x, point.y, this, NULL);
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
void CSanitaryDlg::OnBeginlabeleditTkList(NMHDR* pNMHDR, LRESULT* pResult)
|
|
{
|
|
LV_DISPINFO* pDispInfo = (LV_DISPINFO*)pNMHDR;
|
|
m_bBiginEdit = TRUE;
|
|
*pResult = 0;
|
|
}
|
|
|
|
|
|
void CSanitaryDlg::OnOK()
|
|
{
|
|
if(!IsCurrentValid()) {
|
|
SetStateText(_T("请正确选择洁具!"));
|
|
return;
|
|
}
|
|
SaveStatus();
|
|
CTKImageDlg::OnOK();
|
|
}
|
|
|
|
int TSanitaryDlg()
|
|
{
|
|
//AsureWCS();
|
|
InitLayer(LAY_SANIWARE);
|
|
XPushVarStr vLayer(_T("CLAYER"), LAY_SANIWARE);
|
|
CWnd *pWnd=acedGetAcadFrame();
|
|
CSaniFittingAttr data;
|
|
|
|
{ //选择一种洁具
|
|
CSanitaryDlg dlg(pWnd);
|
|
dlg.m_nOpenMode = 0;
|
|
INT_PTR nRet;
|
|
{
|
|
CTemporaryResourceOverride vTemp1;
|
|
nRet = dlg.DoModal();
|
|
}
|
|
if(nRet==IDCANCEL)
|
|
return 0;
|
|
data=*dlg.GetCurrentSelection();
|
|
if(nRet==ID_BLK_REPLACE) {
|
|
ReplaceSaniware(data);
|
|
return 1;
|
|
} else if(nRet!=IDOK) {
|
|
return 1;
|
|
}
|
|
}
|
|
|
|
lab_ChoseSaniWare:
|
|
if(data.m_nPlaceFlag<=1)
|
|
{ //单个或多个布置的洁具
|
|
CDecorateSaniFittingDlg dlg1(pWnd);
|
|
dlg1.SetFromSaniWare(data);
|
|
{
|
|
CTemporaryResourceOverride vTemp1;
|
|
dlg1.Create(dlg1.IDD, pWnd);
|
|
}
|
|
pWnd->SetFocus();
|
|
int nRet=PlaceSaniWare1(dlg1, data);
|
|
dlg1.DestroyWindow();
|
|
if(nRet==1)
|
|
goto lab_ChoseSaniWare;
|
|
}
|
|
else if(data.m_nPlaceFlag==2)
|
|
{ //布置浴缸
|
|
CDecorateBathTubDlg dlg1(pWnd);
|
|
dlg1.SetFromSaniWare(data);
|
|
{
|
|
CTemporaryResourceOverride vTemp1;
|
|
dlg1.Create(dlg1.IDD, pWnd);
|
|
}
|
|
pWnd->SetFocus();
|
|
int nRet=PlaceSaniWare2(dlg1, data);
|
|
dlg1.DestroyWindow();
|
|
if(nRet==1)
|
|
goto lab_ChoseSaniWare;
|
|
}
|
|
else if(data.m_nPlaceFlag==3)
|
|
{ //逐点: 如地漏
|
|
PlaceSaniWare3(data);
|
|
}
|
|
else if(data.m_nPlaceFlag==4)
|
|
{ //参数绘图: 小便池和舆洗盆
|
|
PlaceSaniWare4(data);
|
|
}
|
|
return 1;
|
|
}
|
|
|
|
// COMMAND: 布置洁具
|
|
|
|
|
|
// 替换图面上的图块
|
|
int ReplaceSaniware(const CSaniFittingAttr &data)
|
|
{
|
|
if(data.m_nPlaceFlag==4)
|
|
return RTERROR;
|
|
// 从图库中加载图块
|
|
XString sBlockName(256);
|
|
XString sDwbName(256);
|
|
sDwbName << g_sDwbPath << _T("lvtry.DWB");
|
|
if(LoadDwbBlock(sDwbName, data.m_csBlockName, sBlockName)!=RTNORM)
|
|
return 0;
|
|
|
|
XDbBlockTableRec objBlock(sBlockName, AcDb::kForRead);
|
|
ASSERT(!!objBlock);
|
|
AcDbObjectId idBlock = objBlock.m_pBlockTableRec->objectId();
|
|
objBlock.Close();
|
|
|
|
RBList mask(RTDXF0, _T("INSERT,AEC_BLOCK_INSERT"), NULL);
|
|
Entity ent;
|
|
while(ent.FilterSelect(_T("\n选择要被替换的图块: "), mask)==RTNORM) {
|
|
XDbObject obj(ent, AcDb::kForWrite);
|
|
if(!obj) continue;
|
|
AcDbBlockReference *pBlk = AcDbBlockReference::cast(obj.m_pObject);
|
|
ASSERT(pBlk);
|
|
XPoint ptInsert, ptCen;
|
|
double nRot, nSizeX, nSizeY, nSizeZ, nSizeX1, nSizeY1;
|
|
if(GetBlockRefSizeInfo(pBlk, ptInsert, &nRot,
|
|
ptCen, &nSizeX, &nSizeY, &nSizeZ)!=RTNORM)
|
|
continue;
|
|
pBlk->setBlockTableRecord(idBlock);
|
|
|
|
if(GetBlockRefSizeInfo(pBlk, ptInsert, &nRot,
|
|
ptCen, &nSizeX1, &nSizeY1, &nSizeZ)!=RTNORM)
|
|
continue;
|
|
AcGeScale3d scale=pBlk->scaleFactors();
|
|
scale[0] *= nSizeX/nSizeX1;
|
|
scale[1] *= nSizeY/nSizeY1;
|
|
pBlk->setScaleFactors(scale);
|
|
}
|
|
return RTNORM;
|
|
}
|
|
|
|
|
|
// 布置第一类洁具: 洗脸盆等
|
|
// 返回: 0--结束; 1--选择其他构件
|
|
|
|
// [1/15/2008 nsh]
|
|
//-------------------------------------------begin------------------------------------------------------
|
|
int PlaceSaniWare1(CDecorateSaniFittingDlg &dlg, CSaniFittingAttr &data)
|
|
{
|
|
// [1/15/2008 nsh]
|
|
//----------------------------------begin---------------------------------
|
|
//double nDeriveAngle=0,nNormalAngel=0;
|
|
////读取图块
|
|
//XString sBlockName(256);
|
|
//XString sDwbName(256);
|
|
//sDwbName<<g_sDwbPath<<_T("lvtry.DWB");
|
|
//if(LoadDwbBlock(sDwbName, data.m_csBlockName, sBlockName)!=RTNORM)
|
|
// return 0;
|
|
//double sx=dlg.g_nSizeX/data.m_dOrigenalSizeX,
|
|
// sy=dlg.g_nSizeY/data.m_dOrigenalSizeY; // 确定插入比例
|
|
//TDbBlockInsert * pBlock=new TDbBlockInsert;
|
|
//AcDbObjectId oID=InitBlock(sBlockName);
|
|
//pBlock->setBlockTableRecord(oID);
|
|
//pBlock->setScaleFactors(AcGeScale3d(sx, sy, 1.0));
|
|
//pBlock->setRotation(nDeriveAngle);
|
|
//int rt=DrawSantitary(pBlock);
|
|
//AddToCurrentSpace(pBlock,TRUE);
|
|
int rt=DrawSantitary(dlg,data);
|
|
//SelectWallSideOrComponent();
|
|
//-----------------------------------end----------------------------------
|
|
// [1/15/2008 nsh]
|
|
//-----------------------------------------begin----------------------------------------
|
|
// double nDeriveAngle=0, nNormalAngle=0;
|
|
// int nRetCode=RTNORM;
|
|
// XPoint ptInitStart;
|
|
// double nPlacePathDirection=0.0;
|
|
//lab_NextRoom:
|
|
//
|
|
// if((nRetCode=SelectWallSideOrComponent(ptInitStart, &nPlacePathDirection, &nNormalAngle))!=RTNORM)
|
|
// return 0;
|
|
//
|
|
// XCurveSegment selCurve;
|
|
// selCurve = XLine(ptInitStart, nPlacePathDirection);
|
|
// nDeriveAngle = CT_std_angle(nNormalAngle+PI/2.0); //切向
|
|
// dlg.UpdateData(); //更新对话框数据,以便获得最新的数据
|
|
//
|
|
//
|
|
// // 从图库中加载图块
|
|
// XString sBlockName(256);
|
|
// XString sDwbName(256);
|
|
// sDwbName << g_sDwbPath << _T("lvtry.DWB");
|
|
// if(LoadDwbBlock(sDwbName, data.m_csBlockName, sBlockName)!=RTNORM)
|
|
// return 0;
|
|
//
|
|
// //确定布置的开始位置和布置方向
|
|
// XPoint ptFrom=ptInitStart; //selCurve.NearPoint(ptLoc);
|
|
// // 插入第一个洁具
|
|
// double sx=dlg.g_nSizeX/data.m_dOrigenalSizeX,
|
|
// sy=dlg.g_nSizeY/data.m_dOrigenalSizeY; // 确定插入比例
|
|
// XPoint ptInsert;
|
|
// ads_polar(ptFrom, nPlacePathDirection, dlg.g_nInitSpace, ptInsert);
|
|
// XPoint ptOnSide; //插入点在墙面上的投影
|
|
// if(selCurve.ProjectToMe(ptInsert, ptOnSide)==RTNORM) {
|
|
// ads_polar(ptOnSide, nNormalAngle, dlg.g_nDistToWall, ptInsert);
|
|
// }
|
|
// ptFrom=ptInsert;
|
|
// MakeTBlockInsert(sBlockName, ptInsert, sx, sy, 1.0, nDeriveAngle);
|
|
//
|
|
//
|
|
// double nPlatLength=dlg.g_nInitSpace*2, nPlatWidth=600; //台面长度和台面宽度
|
|
// BOOL bChangeComponent=FALSE;
|
|
// while((dlg.g_bMultiPlace || bChangeComponent) && ads_initget(0, _T("R"))==RTNORM &&
|
|
// (nRetCode=ads_getpoint(Wcs2Ucs(ptFrom), _T("\n下一个<退出>: "), XPoint()))==RTNORM ||
|
|
// nRetCode==RTKWORD) {
|
|
// double nDistToLast = bChangeComponent? dlg.g_nInitSpace : dlg.g_nComponentSpace;
|
|
// if(nRetCode==RTKWORD) {
|
|
// CTemporaryResourceOverride vTemp1;
|
|
// CSanitaryDlg dlgChose(&dlg);
|
|
// dlgChose.m_nOpenMode = 1;
|
|
//
|
|
// dlgChose.SetCurrentItem(data, TRUE);
|
|
// if(dlgChose.DoModal()==IDOK) {
|
|
// CSaniFittingAttr *pData=dlgChose.GetCurrentSelection();
|
|
// data=*pData;
|
|
// if(pData->m_nPlaceFlag<=1) {
|
|
// if(LoadDwbBlock(sDwbName, data.m_csBlockName, sBlockName)!=RTNORM)
|
|
// return 0;
|
|
// ads_polar(ptFrom, nPlacePathDirection, dlg.g_nSizeX/2.0, ptInitStart);
|
|
// ptFrom=ptInitStart; //由于更换了设备所以初始点变化了
|
|
//
|
|
// dlg.SetFromSaniWare(data);
|
|
// dlg.UpdateData(FALSE);
|
|
// dlg.UpdateSlide();
|
|
//
|
|
// nPlatLength=dlg.g_nInitSpace*2;
|
|
// bChangeComponent=TRUE;
|
|
// continue;
|
|
// } else {
|
|
// return 1;
|
|
// }
|
|
// } else { //取消换取设备
|
|
// continue;
|
|
// }
|
|
// } else {
|
|
// bChangeComponent=FALSE;
|
|
// }
|
|
//
|
|
// dlg.UpdateData();
|
|
//
|
|
// // 布置洁具
|
|
// sx=dlg.g_nSizeX/data.m_dOrigenalSizeX;
|
|
// sy=dlg.g_nSizeY/data.m_dOrigenalSizeY;
|
|
// ads_polar(ptFrom, nPlacePathDirection, nDistToLast, ptInsert);
|
|
// if(selCurve.ProjectToMe(ptInsert, ptOnSide)==RTNORM) {
|
|
// ads_polar(ptOnSide, nNormalAngle, dlg.g_nDistToWall, ptInsert);
|
|
// }
|
|
// MakeTBlockInsert(sBlockName, ptInsert, sx, sy, 1.0, nDeriveAngle);
|
|
// ptFrom = ptInsert;
|
|
// nPlatLength += dlg.g_nComponentSpace;
|
|
// }
|
|
// //禁止点取_T("更换设备按钮")
|
|
//// pWndChange=dlg.GetDlgItem(IDC_BUTTON_CHCOMPONENT);
|
|
// // if(pWndChange) pWndChange->EnableWindow(FALSE);
|
|
//
|
|
//
|
|
// if(data.m_csKindName==_T("台式洗脸盆")) {
|
|
// double nInitPlatLength=nPlatLength;
|
|
// XPoint ptMid;
|
|
// ads_polar(ptInitStart, nPlacePathDirection, nPlatLength/2.0, ptMid);
|
|
// if(XGetDist(Wcs2Ucs(ptInitStart), _T("\n台面宽度"), nPlatWidth, RSG_NONEG)==RTCAN)
|
|
// return 0;
|
|
// if(XGetDist(Wcs2Ucs(ptInitStart), _T("\n台面长度"), nPlatLength, RSG_NONEG)==RTCAN)
|
|
// return 0;
|
|
// XPoint pt1, pt2, pt3, pt4;
|
|
// if(nPlatLength<nInitPlatLength+_DIST_SNAP) { //对中布置
|
|
// ads_polar(ptMid, nPlacePathDirection+PI, nPlatLength/2.0, pt1);
|
|
// ads_polar(ptMid, nPlacePathDirection, nPlatLength/2.0, pt2);
|
|
// } else {
|
|
// pt1 = ptInitStart;
|
|
// ads_polar(pt1, nPlacePathDirection, nPlatLength, pt2);
|
|
// }
|
|
// ads_polar(pt2, nNormalAngle, nPlatWidth, pt3);
|
|
// ads_polar(pt1, nNormalAngle, nPlatWidth, pt4);
|
|
//
|
|
// XPoly2D rect(1);
|
|
// rect.AppendNode(pt1);
|
|
// rect.AppendNode(pt2);
|
|
// rect.AppendNode(pt3);
|
|
// rect.AppendNode(pt4);
|
|
// XWcsStream dc;
|
|
// dc << rect;
|
|
// }
|
|
//
|
|
// if(dlg.g_bNextRoom)
|
|
// goto lab_NextRoom;
|
|
//-------------------------------------------------end----------------------------------------------
|
|
return 0;
|
|
}
|
|
//----------------------------------------end----------------------------------------
|
|
// 选择墙边线
|
|
// ptLoc(OUT) -- 点取位置; selCuve(OUT)--边线; nNormalAngle(OUT)--法向
|
|
int SelectWallSideCurve(XPoint &ptLoc, XCurveSegment &selCurve, double *nNormalAngle)
|
|
{
|
|
double nDeriveAngle=0.0;
|
|
Entity ent;
|
|
int nRetCode;
|
|
if((nRetCode=SelectWallSide(ent, ptLoc, &nDeriveAngle))!=RTNORM)
|
|
return nRetCode;
|
|
XDbObject objWall(ent, AcDb::kForRead);
|
|
ASSERT(!!objWall);
|
|
TDbWall *pWall=TDbWall::cast(objWall.m_pObject);
|
|
ASSERT(pWall);
|
|
XCurveSegment lCurve, rCurve;
|
|
pWall->GetSideCurve(lCurve, rCurve);
|
|
objWall.Close();
|
|
|
|
XPoint ptLeft, ptRight; //在左右两侧的投影
|
|
if(lCurve.ProjectToMe(ptLoc, ptLeft)!=RTNORM ||
|
|
rCurve.ProjectToMe(ptLoc, ptRight)!=RTNORM)
|
|
return RTERROR;
|
|
if(ptLoc.Distance(ptLeft)<ptLoc.Distance(ptRight))
|
|
selCurve=lCurve;
|
|
else selCurve=rCurve;
|
|
*nNormalAngle = CT_std_angle(nDeriveAngle-PI/2.0);
|
|
return RTNORM;
|
|
}
|
|
|
|
// 布置第一类洁具: 浴缸
|
|
int PlaceSaniWare2(CDecorateBathTubDlg &dlg, CSaniFittingAttr &data)
|
|
{
|
|
int rt=DrawSantitary2(dlg,data);
|
|
// XCurveSegment selCurve;
|
|
// XPoint ptLoc;
|
|
// double nDeriveAngle=0, nNormalAngle=0;
|
|
// int nRetCode=RTNORM;
|
|
//lab_NextRoom:
|
|
// ads_initget(0, _T("R"));
|
|
// if((nRetCode=SelectWallSideCurve(ptLoc, selCurve, &nNormalAngle))!=RTNORM && nRetCode!=RTKWORD)
|
|
// return 0;
|
|
//
|
|
// if(nRetCode==RTKWORD) { //改其他设备
|
|
// CSanitaryDlg dlgChose(&dlg);
|
|
// dlgChose.m_nOpenMode = 1;
|
|
//
|
|
// dlgChose.SetCurrentItem(data, TRUE);
|
|
// if(dlgChose.DoModal()==IDOK) {
|
|
// CSaniFittingAttr *pData=dlgChose.GetCurrentSelection();
|
|
// data=*pData;
|
|
// if(pData->m_nPlaceFlag==2) {
|
|
// dlg.SetFromSaniWare(data);
|
|
// dlg.UpdateData(FALSE);
|
|
// dlg.UpdateSlide();
|
|
// } else {
|
|
// return 1;
|
|
// }
|
|
// }
|
|
// goto lab_NextRoom;
|
|
// }
|
|
//
|
|
// dlg.UpdateData(); //更新对话框数据,以便获得最新的数据
|
|
//
|
|
// XPoint ptFrom=selCurve.NearPoint(ptLoc); //布置的开始位置
|
|
// double nPlacePathDirection=ads_angle(ptFrom, selCurve.FarPoint(ptLoc));
|
|
//
|
|
// nDeriveAngle=CT_std_angle(nNormalAngle+PI/2.0); //切向;
|
|
//
|
|
// XPoint ptInsert;
|
|
// ads_polar(ptFrom, nPlacePathDirection, dlg.g_nWidth/2.0, ptInsert);
|
|
// XString sBlockName(256);
|
|
// XString sDwbName(256);
|
|
// sDwbName << g_sDwbPath << _T("lvtry.DWB");
|
|
// if(LoadDwbBlock(sDwbName, data.m_csBlockName, sBlockName)!=RTNORM)
|
|
// return 0;
|
|
//
|
|
// double sx=dlg.g_nWidth/data.m_dOrigenalSizeX, sy=dlg.g_nLength/data.m_dOrigenalSizeY;
|
|
// MakeTBlockInsert(sBlockName, ptInsert, sx, sy, 1.0, nDeriveAngle);
|
|
//
|
|
// if(dlg.g_bNextRoom)
|
|
// goto lab_NextRoom;
|
|
return 0;
|
|
}
|
|
|
|
|
|
|
|
// 布置第三类洁具: 逐点布置地漏
|
|
void PlaceSaniWare3(const CSaniFittingAttr &data)
|
|
{
|
|
XString sBlockName(256);
|
|
XString sDwbName(256);
|
|
sDwbName << g_sDwbPath << _T("lvtry.DWB");
|
|
if(LoadDwbBlock(sDwbName, data.m_csBlockName, sBlockName)!=RTNORM)
|
|
return;
|
|
|
|
XPoint ptLoc;
|
|
while(XGetPoint(NULL, _T("\n点取插入点"), ptLoc)==RTNORM) {
|
|
ptLoc=Ucs2Wcs(ptLoc);
|
|
MakeTBlockInsert(sBlockName, ptLoc, 1.0, 1.0, 1.0, 0.0, 0);
|
|
}
|
|
}
|
|
// 布置第四类洁具: 参数绘图
|
|
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
//关于洗衣槽和小便池的绘制
|
|
void PlaceSaniWare4(const CSaniFittingAttr &data)
|
|
{
|
|
// [2/26/2008 nsh]
|
|
//新添加处理的函数
|
|
int rt=DrawSantitary1(data);
|
|
return;
|
|
//------------------end--------------
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
//以下的程序都不在执行的范围内
|
|
Entity ent;
|
|
XPoint ptLoc;
|
|
double nDeriveAngle=0, nNormalAngle=0;
|
|
if(SelectWallSide(ent, ptLoc, &nDeriveAngle)!=RTNORM)
|
|
return;
|
|
nNormalAngle=CT_std_angle(nDeriveAngle-PI/2.0); //法向;
|
|
|
|
//确定起始点
|
|
XDbObject objWall(ent, AcDb::kForRead);
|
|
ASSERT(!!objWall);
|
|
TDbWall *pWall=TDbWall::cast(objWall.m_pObject);
|
|
ASSERT(pWall);
|
|
XCurveSegment lCurve, rCurve, selCurve;
|
|
if(pWall->Is(CURVE_ARC)) {
|
|
adsout << _T("\n请选择直线墙!");
|
|
return;
|
|
}
|
|
pWall->GetSideCurve(lCurve, rCurve);
|
|
objWall.Close();
|
|
|
|
XPoint ptLeft, ptRight; //在左右两侧的投影
|
|
if(lCurve.ProjectToMe(ptLoc, ptLeft)!=RTNORM ||
|
|
rCurve.ProjectToMe(ptLoc, ptRight)!=RTNORM)
|
|
return;
|
|
if(ptLoc.Distance(ptLeft)<ptLoc.Distance(ptRight))
|
|
selCurve=lCurve;
|
|
else selCurve=rCurve;
|
|
|
|
XPoint ptFrom=selCurve.NearPoint(ptLoc); //布置的开始位置
|
|
double nDirection=ads_angle(ptFrom, selCurve.FarPoint(ptLoc));
|
|
BOOL bFromLeftToRight=CT_IsExactSameDrt(nDeriveAngle, nDirection, _angSnap);
|
|
if(data.m_csKindName==_T("小便池")) {
|
|
static double nInitSpace=0, nLength=3000, nWidth=400, nStepWidth=250, nGap=60;
|
|
int nRet=XGetDist(Wcs2Ucs(ptFrom), _T("\n小便池离墙角的距离"), nInitSpace, RSG_NONEG);
|
|
if(nRet==RTCAN)
|
|
return;
|
|
XPoint ptUpLeft, ptUpRight;
|
|
ads_polar(ptFrom, nDirection, nInitSpace, ptUpLeft);
|
|
if(XGetDist(Wcs2Ucs(ptUpLeft), _T("\n小便池的长度"), nLength, RSG_NONEG)==RTCAN)
|
|
return;
|
|
ads_polar(ptUpLeft, nDirection, nLength, ptUpRight);
|
|
if(XGetDist(Wcs2Ucs(ptUpLeft), _T("\n小便池的宽度"), nWidth, RSG_NONEG)==RTCAN)
|
|
return;
|
|
|
|
XLine lnLeftSideExt, lnLeftSideInt, lnRightSideExt, lnRightSideInt;
|
|
|
|
lnLeftSideExt.EndPoint() = ptUpLeft;
|
|
ads_polar(ptUpLeft, nNormalAngle, nWidth, lnLeftSideExt.StartPoint());
|
|
lnLeftSideInt=lnLeftSideExt.Offset(bFromLeftToRight? nGap:-nGap);
|
|
|
|
lnRightSideExt.EndPoint() = ptUpRight;
|
|
ads_polar(ptUpRight, nNormalAngle, nWidth, lnRightSideExt.StartPoint());
|
|
lnRightSideInt=lnRightSideExt.Offset(bFromLeftToRight? -nGap:nGap);
|
|
|
|
XLine lnStepExt(lnLeftSideExt.StartPoint(), lnRightSideExt.StartPoint());
|
|
|
|
XScreenDc dc;
|
|
dc << Wcs2Ucs(lnLeftSideExt)
|
|
<< Wcs2Ucs(lnLeftSideInt)
|
|
<< Wcs2Ucs(lnRightSideInt)
|
|
<< Wcs2Ucs(lnRightSideExt)
|
|
<< Wcs2Ucs(lnStepExt);
|
|
|
|
XPoint pt1, pt2;
|
|
ads_polar(lnStepExt.StartPoint(), nDirection, nGap, pt1);
|
|
ads_polar(lnStepExt.EndPoint(), nDirection+PI, nGap, pt2);
|
|
|
|
lab_InputStepWidth:
|
|
if(XGetDist(Wcs2Ucs(pt1), _T("\n台阶宽度"), nStepWidth, RSG_NONEG)==RTCAN)
|
|
return;
|
|
if(nStepWidth>=nWidth) {
|
|
adsout << _T("\n台阶宽度应当小于小便池的宽度, 重新输入!");
|
|
goto lab_InputStepWidth;
|
|
}
|
|
|
|
XLine lnStepInt;
|
|
ads_polar(pt1, nNormalAngle+PI, nStepWidth, lnStepInt.StartPoint());
|
|
ads_polar(pt2, nNormalAngle+PI, nStepWidth, lnStepInt.EndPoint());
|
|
|
|
XWcsStream wcsDc;
|
|
wcsDc << lnLeftSideExt << lnLeftSideInt << lnRightSideInt
|
|
<< lnRightSideExt << lnStepExt << lnStepInt;
|
|
} else {
|
|
static double nInitSpace=0, nLength=5300, nWidth=690, nWidth1=100, nGap=60;
|
|
int nRet=XGetDist(Wcs2Ucs(ptFrom), _T("\n盥洗槽离墙角的距离"), nInitSpace, RSG_NONEG);
|
|
if(nRet==RTCAN)
|
|
return;
|
|
XPoint ptUpLeft, ptUpRight, ptLowLeft, ptLowRight;
|
|
ads_polar(ptFrom, nDirection, nInitSpace, ptUpLeft);
|
|
if(XGetDist(Wcs2Ucs(ptUpLeft), _T("\n盥洗槽的长度"), nLength, RSG_NONEG)==RTCAN)
|
|
return;
|
|
if(XGetDist(Wcs2Ucs(ptUpLeft), _T("\n盥洗槽的宽度"), nWidth, RSG_NONEG)==RTCAN)
|
|
return;
|
|
|
|
ads_polar(ptUpLeft, nDirection, nLength, ptUpRight);
|
|
ads_polar(ptUpRight, nNormalAngle, nWidth, ptLowRight);
|
|
ads_polar(ptUpLeft, nNormalAngle, nWidth, ptLowLeft);
|
|
XPoly2D polyOut(1), polyIn(1);
|
|
polyOut.AppendNode(ptLowLeft);
|
|
polyOut.AppendNode(ptLowRight);
|
|
polyOut.AppendNode(ptUpRight);
|
|
polyOut.AppendNode(ptUpLeft);
|
|
double nPathArea=polyOut.PathArea();
|
|
polyOut.QuickOffset(nPathArea<0? -nGap : nGap, polyIn);
|
|
|
|
XScreenDc dc;
|
|
XPoly2D polyUcs1(polyIn), polyUcs2(polyOut);
|
|
polyUcs1.TransUCS(Groups(0), Groups(1));
|
|
dc << polyUcs1 << polyUcs2;
|
|
|
|
lab_InputWasherWidth:
|
|
if(XGetDist(Wcs2Ucs(*polyIn[3]), _T("\n排水沟宽度"), nWidth1, RSG_NONEG)==RTCAN)
|
|
return;
|
|
if(nWidth1+2*nGap>=nWidth) {
|
|
adsout << _T("\n排水宽度应当小于小便池的宽度, 重新输入!");
|
|
goto lab_InputWasherWidth;
|
|
}
|
|
|
|
int nOutletNum=AS_INT((nLength-2*nGap)/700.0);
|
|
adsout << _T("\n请输入水龙头的数目<") << nOutletNum << _T(">: ");
|
|
ads_initget(RSG_NONEG, NULL);
|
|
if(ads_getint(_T(""), &nOutletNum)==RTCAN)
|
|
return;
|
|
|
|
XLine lnStepInt;
|
|
ads_polar(*polyIn[3], nNormalAngle, nWidth1, lnStepInt.StartPoint());
|
|
ads_polar(*polyIn[2], nNormalAngle, nWidth1, lnStepInt.EndPoint());
|
|
|
|
XString sBlockName(256);
|
|
XString sDwbName(256);
|
|
sDwbName << g_sDwbPath << _T("lvtry.DWB");
|
|
if(nOutletNum>0 && LoadDwbBlock(sDwbName, _T("00000000"), sBlockName)==RTNORM) {
|
|
double nDistOutlet=(nLength-2*nGap)/nOutletNum;
|
|
XPoint ptFrom;
|
|
ads_polar(*polyIn[3], nNormalAngle-PI, nGap/2.0, ptFrom);
|
|
ads_polar(XPoint(ptFrom), nDirection, nDistOutlet/2.0, ptFrom);
|
|
for(int i=0; i<nOutletNum; i++) {
|
|
XPoint ptInsert;
|
|
ads_polar(ptFrom, nDirection, i*nDistOutlet, ptInsert);
|
|
MakeTBlockInsert(sBlockName, ptInsert, 1.0, 1.0, 1.0, nNormalAngle+PI/2, 0);
|
|
}
|
|
}
|
|
XWcsStream wcsDc;
|
|
wcsDc << polyIn << polyOut << lnStepInt;
|
|
}
|
|
ads_redraw(NULL,0);
|
|
}
|
|
|
|
|
|
Entity GetNextWallLine(Entity entWall, XPoint ptPick)
|
|
{
|
|
if(!entWall.Is(_T("LINE")))
|
|
return Entity();
|
|
RBList rbMask = ads_buildlist(RTDXF0, _T("LINE"), 8, _T("WALL"), NULL);
|
|
double nMaxlen = 300;
|
|
PickSet ssSel(SS_FREE);
|
|
XPoint ptTemp1, ptTemp2;
|
|
ptTemp1.x = ptPick.x - nMaxlen;
|
|
ptTemp1.y = ptPick.y + nMaxlen;
|
|
ptTemp2.x = ptPick.x + nMaxlen;
|
|
ptTemp2.y = ptPick.y - nMaxlen;
|
|
ssSel.Get(_T("C"), ptTemp1, ptTemp2, rbMask);
|
|
long len = ssSel.Length();
|
|
if(len < 2)
|
|
return Entity();
|
|
ssSel -= entWall;
|
|
for(long i=0;i<len;i++){
|
|
Entity ent = ssSel[i];
|
|
if(ent.Is(_T("LINE"))){
|
|
XLine l1(entWall, 1);
|
|
XLine l2(ent, 1);
|
|
if(l2.GetLength() < nMaxlen) //接门窗墙
|
|
continue;
|
|
double ang1 = ads_angle(l1.StartPoint(), l1.EndPoint());
|
|
double ang2 = ads_angle(l2.StartPoint(), l2.EndPoint());
|
|
if((l1.StartPoint() & l2 ) == PR_EXTEND)
|
|
continue;
|
|
if(fabs(ang1 - ang2) < 0.01 || fabs(fabs(ang1 - ang2) - PI) < 0.01 || fabs(fabs(ang1 - ang2) - PI*2) < 0.01)
|
|
return ent;
|
|
}
|
|
}
|
|
return Entity();
|
|
}
|
|
|
|
// 选择墙的一侧或已有的洁具
|
|
// ptFrom(OUT) -- 布置起点
|
|
// nPlaceDirection(OUT) -- 布置方向
|
|
// nNormalAngle(OUT) -- 墙面法向
|
|
int SelectWallSideOrComponent(XPoint &ptFrom, double * nPlaceDirection, double *nNormalAngle)
|
|
{
|
|
int nOldOsnap=DocGetWallOsnapType();
|
|
DocSetWallOsnapType(1);
|
|
Entity ent;
|
|
RBList mask(RTDXF0, _T("ATS_WALL,INSERT,AEC_BLOCK_INSERT,LINE"), NULL);
|
|
XPoint ptPick;
|
|
lab_Select:
|
|
int nRetCode=RTNORM;
|
|
if((nRetCode=ent.FilterSelect1(100.0, _T("\n请点取墙体边线或选择已有洁具: "), mask, ptPick))!=RTNORM) {
|
|
DocSetWallOsnapType(nOldOsnap);
|
|
return nRetCode;
|
|
}
|
|
DocSetWallOsnapType(nOldOsnap);
|
|
ptPick=Ucs2Wcs(ptPick);
|
|
if(ent.Is(_T("LINE"))){
|
|
Entity entNext = GetNextWallLine(ent, ptPick);
|
|
if(!entNext){
|
|
adsout << _T("\n请正确点取!");
|
|
goto lab_Select;
|
|
}
|
|
XCurveSegment segPick(ent);
|
|
XCurveSegment seg(entNext);
|
|
double angleWall = ads_angle(segPick.StartPoint(), segPick.EndPoint());
|
|
double angleWall1 = angleWall;
|
|
double angleWall2 = ads_angle(seg.StartPoint(), seg.EndPoint());
|
|
double dn = fabs(angleWall2 - angleWall1);
|
|
if(fabs(dn - PI) < 0.001){
|
|
XLine line(seg.EndPoint(), seg.StartPoint(), 1);
|
|
if(line.OnWhichSide(ptPick) == OFFSET_RIGHT)
|
|
angleWall = angleWall + PI;
|
|
}
|
|
else if(seg.OnWhichSide(ptPick) == OFFSET_RIGHT)
|
|
angleWall = angleWall + PI;
|
|
if(angleWall > PI*2)
|
|
angleWall -= PI*2;
|
|
ptFrom = segPick.NearPoint(ptPick);
|
|
|
|
*nPlaceDirection = ads_angle(ptFrom, ptPick);
|
|
*nNormalAngle = angleWall + PI/2;
|
|
return RTNORM;
|
|
}
|
|
XDbObject obj(ent, AcDb::kForWrite);
|
|
if(!obj) return RTERROR;
|
|
TDbWall *pWall=TDbWall::cast(obj.m_pObject);
|
|
if(!pWall) { //INSERT
|
|
AcDbBlockReference *pInsert=AcDbBlockReference::cast(obj.m_pObject);
|
|
double nSizeX, nSizeY, nSizeZ, nRot;
|
|
XPoint ptBase, ptCen;
|
|
if(!pInsert || GetBlockRefSizeInfo(pInsert, ptBase, &nRot, ptCen,
|
|
&nSizeX, &nSizeY, &nSizeZ)!=RTNORM)
|
|
return RTERROR;
|
|
*nNormalAngle = CT_std_angle(nRot-PI/2.0);
|
|
XLine ln(ptBase, *nNormalAngle);
|
|
XPoint ptOnLine;
|
|
VERIFY(ptPick.Project(&ln, ptOnLine)==RTNORM);
|
|
*nPlaceDirection = ads_angle(ptOnLine, ptPick);
|
|
ads_polar(ptBase, *nPlaceDirection, nSizeX/2.0, ptFrom);
|
|
} else {
|
|
if(!pWall->Is(CURVE_LINE)) {
|
|
adsout << _T("\n请选择直线墙体!");
|
|
goto lab_Select;
|
|
}
|
|
|
|
TDbWall &wall = *pWall;
|
|
//int bSide=wall.OnWhichSide(ptPick);
|
|
XCurveSegment lCurve, rCurve, selCurve;
|
|
|
|
//modified by whl on 051125
|
|
//wall.GetSideCurve(lCurve, rCurve);
|
|
wall.GetSideCurve(lCurve, rCurve,0,TRUE);
|
|
|
|
XPoint ptLeft, ptRight; //在左右两侧的投影
|
|
if(lCurve.ProjectToMe(ptPick, ptLeft)!=RTNORM ||
|
|
rCurve.ProjectToMe(ptPick, ptRight)!=RTNORM)
|
|
return RTERROR;
|
|
// [12/28/2007 nsh]
|
|
//----------------------------------begin--------------------------------
|
|
double x=ptPick.Distance(ptLeft);
|
|
double y=ptPick.Distance(ptRight);
|
|
//-----------------------------------end---------------------------------
|
|
if(ptPick.Distance(ptLeft)<ptPick.Distance(ptRight))
|
|
selCurve=lCurve;
|
|
else selCurve=rCurve;
|
|
|
|
|
|
XPoint ptOnBase, ptOnSide;
|
|
// [12/28/2007 nsh]
|
|
if(selCurve==rCurve)
|
|
{
|
|
if(lCurve.ProjectToMe(ptPick, ptOnBase)!=RTNORM || // [12/28/2007 nsh]
|
|
selCurve.ProjectToMe(ptPick, ptOnSide)!=RTNORM) {
|
|
adsout << _T("\n请正确点取!");
|
|
goto lab_Select;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if(rCurve.ProjectToMe(ptPick, ptOnBase)!=RTNORM || // [12/28/2007 nsh]
|
|
selCurve.ProjectToMe(ptPick, ptOnSide)!=RTNORM) {
|
|
adsout << _T("\n请正确点取!");
|
|
goto lab_Select;
|
|
}
|
|
}
|
|
//-----------------------------end-------------------------------
|
|
ptFrom = selCurve.NearPoint(ptOnSide);
|
|
*nPlaceDirection = ads_angle(ptFrom, selCurve.FarPoint(ptOnSide));
|
|
XPoint mmm=selCurve.FarPoint(ptOnSide);
|
|
*nNormalAngle=ads_angle(ptOnBase, ptOnSide);
|
|
}
|
|
return RTNORM;
|
|
}
|
|
//############################################################################################################################################
|
|
// [1/15/2008 nsh]
|
|
//--------------------------------------------------------------begin------------------------------------------------------------------
|
|
//以下为拖动用的Jig
|
|
// 函数声明块
|
|
Array<XPointDir2d> _cdecl GetArrayPoint(const XDirectionCurve &cv,UINT nPart,int dDisToWall,double WidthofWall);
|
|
UINT GetMaxInsert(double WidthSan,const XDirectionCurve & cv);//直线
|
|
UINT GetMaxInsert(double WidthSan,const XDirectionCurve &cv,const double &DistToWall,const int &SanWidth,BOOL bDirction);//圆弧
|
|
XCurveSegment GetSuCurve(const XCurveSegment & cvTemp,XPointDir2d ptstart,XPointDir2d ptend);//从圆弧得到子圆弧
|
|
XDirectionCurve GetSubDirCurve(const XDirectionCurve &cvTemp,XPointDir2d ptstart,XPointDir2d ptend);
|
|
double GetChordHeight(double dRadius,double chordLength);
|
|
int DrawFlat(const XDirectionCurve &cvTemp);//台式洗脸盆的平台拖动函数
|
|
|
|
//以下为实现台式洗脸盆平台的Jig
|
|
class TDrawFlatJig :public AcEdJig
|
|
{
|
|
public:
|
|
TDrawFlatJig();
|
|
TDrawFlatJig(AcDbPolyline *pPolyline,XDirectionCurve cv);
|
|
~TDrawFlatJig();
|
|
int doIt();
|
|
DragStatus sampler();
|
|
Adesk::Boolean update();
|
|
AcDbEntity *entity() const;
|
|
void SetPrompt(const TCHAR *pTemp);
|
|
int GetRetCode() const;
|
|
public:
|
|
AcDbPolyline *m_pPolyline;
|
|
CString m_szPrompt;//提示信息
|
|
int m_iRetCode;//状态返回码
|
|
XCurveSegment m_cv;//传入选取的Seg
|
|
BOOL m_bFirst; //是否是点取了第一点
|
|
XPoly2D m_poly2d;
|
|
//
|
|
XPointDir2d m_ptFirst;//通过离墙一端距离得到的第一个点。
|
|
XPointDir2d m_ptSecond;//第二点 以上两个点的作用是确定平台的起始点
|
|
XPoint m_ptPoint;//最终确定的点
|
|
double m_dDist;//平台距离墙一端的距离
|
|
double m_dWidth;//平台的宽度
|
|
// [3/21/2008 nsh]
|
|
/////////////////////////////////
|
|
DList<ads_real> bulges;
|
|
DList<XPoint> Pointlist;
|
|
double dTemp;
|
|
double dle1,dle2;
|
|
|
|
};
|
|
TDrawFlatJig::TDrawFlatJig(){}
|
|
TDrawFlatJig::TDrawFlatJig(AcDbPolyline *pPolyline,XDirectionCurve cv):m_pPolyline(pPolyline),m_cv(cv),m_poly2d(1)
|
|
{
|
|
dTemp=0.0;
|
|
m_bFirst=TRUE;
|
|
}
|
|
TDrawFlatJig::~TDrawFlatJig()
|
|
{}
|
|
int TDrawFlatJig::doIt()
|
|
{
|
|
m_iRetCode=drag();
|
|
int iRet=GetRetCode();
|
|
return iRet;
|
|
}
|
|
AcEdJig::DragStatus TDrawFlatJig::sampler()
|
|
{
|
|
DragStatus stat=AcEdJig::kCancel;//Init the stat
|
|
setUserInputControls((UserInputControls)
|
|
(AcEdJig::kAccept3dCoordinates|AcEdJig::kNullResponseAccepted));
|
|
{//判断是否对点进行交换操作
|
|
if(m_cv.Is(CURVE_LINE))
|
|
{//这个地方的处理上还是有问题,
|
|
if(m_cv.StartPoint().Distance(m_ptFirst)>m_cv.StartPoint().Distance(m_ptSecond))
|
|
{
|
|
XPointDir2d pt=m_ptFirst;
|
|
m_ptFirst=m_ptSecond;
|
|
m_ptSecond=pt;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
double angle1,angle2,angle3;
|
|
XArc arc=m_cv.GetArc();
|
|
angle1=ads_angle(m_ptFirst,arc.GetCenterPt());
|
|
angle2=ads_angle(m_ptSecond,arc.GetCenterPt());
|
|
angle3=ads_angle(m_cv.StartPoint(),arc.GetCenterPt());
|
|
angle1-=angle3;
|
|
angle2-=angle3;
|
|
if(CT_std_angle(angle1)>CT_std_angle(angle2))
|
|
{
|
|
XPointDir2d pt=m_ptFirst;
|
|
m_ptFirst=m_ptSecond;
|
|
m_ptSecond=pt;
|
|
}
|
|
}
|
|
}
|
|
stat=acquirePoint(m_ptPoint,m_ptSecond);
|
|
if(stat==AcEdJig::kNormal)
|
|
{
|
|
static XPoint PointTemp;
|
|
if (PointTemp!=m_ptPoint)
|
|
{
|
|
PointTemp=m_ptPoint;
|
|
}
|
|
else
|
|
return AcEdJig::kNoChange;
|
|
}
|
|
return stat;
|
|
}
|
|
Adesk::Boolean TDrawFlatJig::update()
|
|
{
|
|
XPointDir2d ptTemp4;
|
|
double dDist=m_ptFirst.Distance(m_ptSecond);
|
|
XCurveSegment cv1,cv2,cv3,cv4;
|
|
//以下为获取子曲线
|
|
if(m_cv.Is(CURVE_ARC) || m_cv.Is(CURVE_CIRCLE))
|
|
{
|
|
|
|
XArc arc1=m_cv.GetArc(), arc;
|
|
XPoint ptCenter=arc1.GetCenterPt();//获取中心点
|
|
XCurveSegment xcv(ptCenter,m_ptSecond,LS_INFINITE);
|
|
XPoint ptMid;
|
|
XLine lineTemp=XLine(m_ptFirst,m_ptSecond);//
|
|
ptMid = lineTemp.MidPoint();
|
|
XPoint ptMidSave=ptMid;//保留的原始的线上的终点
|
|
XLine linetemp2(ptMid,ptCenter);
|
|
XPoint pt3,pt4;
|
|
arc1.Intersection(&linetemp2,pt3,pt4);
|
|
m_cv.ProjectToMe(ptMid,ptMid);
|
|
ptMid=pt4==XPoint(0,0,0)?pt3:pt4;
|
|
// int rc;
|
|
if(m_cv.GetLineFlag()==LS_INFINITE)
|
|
XCircle(arc1.GetCenterPt(), arc1.GetRadius()).GetSubArc(ptMid, dDist, arc);
|
|
else
|
|
arc1.GetSubArc(ptMid, dDist, arc);
|
|
XPoint pt1,pt2;
|
|
//arc.GetPoints(pt1,pt2);
|
|
arc.GetStartPoint(pt1);
|
|
arc.GetEndPoint(pt2);
|
|
cv1.StartPoint()=m_ptFirst;
|
|
cv1.EndPoint()=m_ptSecond;
|
|
if(ptMidSave.Distance(ptMid)>arc.GetRadius())
|
|
cv1.SetBulge(2*PI-arc.Bulge());
|
|
else
|
|
{
|
|
cv1.SetBulge(arc.Bulge());//原始算法
|
|
//cv1.bulge=2*PI-arc.Bulge();
|
|
}
|
|
|
|
|
|
//double dd=arc.Bulge();//测试这个地方的值的大小
|
|
//以上为求的一段圆弧
|
|
//以下为求cv2;
|
|
dDist=m_ptPoint.Distance(ptCenter);
|
|
xcv.Polar(dDist,ptTemp4);
|
|
dDist=m_ptPoint.Distance(m_ptSecond);//此处的功能是用户输入的数值与平台的宽度相等
|
|
if(m_cv.OnWhichSide(m_ptPoint))
|
|
{
|
|
cv2=cv1.Offset(dDist,1);
|
|
}
|
|
else
|
|
{
|
|
cv2=cv1.Offset(-dDist,1);
|
|
}
|
|
XPointDir2d ptTemp1,ptTemp2;
|
|
cv2.ProjectToMe(m_ptFirst,ptTemp1);
|
|
cv2.ProjectToMe(m_ptSecond,ptTemp2);//为输入等值所用
|
|
cv3.SetPoints(m_ptFirst,ptTemp1);
|
|
cv4.SetPoints(ptTemp2,m_ptSecond);
|
|
}
|
|
else
|
|
{//在处理直线的情况下还存在问题
|
|
dDist=m_ptPoint.Distance(m_ptSecond);
|
|
cv1.SetPoints(m_ptFirst,m_ptSecond);
|
|
cv2=m_cv.OnWhichSide(m_ptPoint)?cv1.Offset(dDist,1):cv1.Offset(-dDist,1);
|
|
XPoint ptTemp1;
|
|
cv2.ProjectToMe(m_ptFirst,ptTemp1);
|
|
cv2.ProjectToMe(m_ptSecond,ptTemp4);
|
|
cv3.SetPoints(m_ptFirst,ptTemp1);
|
|
cv4.SetPoints(ptTemp4,m_ptSecond);
|
|
}
|
|
m_poly2d.Reset();
|
|
m_poly2d.AppendSegment(cv1,1,0);
|
|
m_poly2d.AppendSegment(cv3);
|
|
m_poly2d.AppendSegment(cv2,0,0);
|
|
m_poly2d.AppendSegment(cv4,0,1);
|
|
m_poly2d.Compress(FALSE);
|
|
//上面是对XPoly2D的操作,估计可以不用改,谁知道呢,也许要改的。晕!
|
|
//-------------------------------------------------------------------------------------------------------------------
|
|
// [3/21/2008 nsh]
|
|
//--------------------------------------------------------------------------------------------
|
|
//这个地方全面的重写
|
|
XPoint Pointlist[4];
|
|
double bulges[4];
|
|
for(int i=0;i<4;i++)
|
|
bulges[i]=0.0;
|
|
Pointlist[0]=cv1.StartPoint();
|
|
Pointlist[1]=cv2.StartPoint();
|
|
Pointlist[2]=cv2.EndPoint();
|
|
Pointlist[3]=cv1.EndPoint();
|
|
bulges[0]=dTemp;
|
|
if(!cv1.Is(CURVE_LINE))
|
|
{
|
|
XArc arc=cv1.GetArc();
|
|
dle1=-(arc.GetStarAngle()-arc.GetEndAngle());
|
|
bulges[1]=dle1;
|
|
}
|
|
else
|
|
bulges[1]=dTemp;
|
|
bulges[2]=dTemp;
|
|
if(!cv2.Is(CURVE_LINE))
|
|
{
|
|
XArc arc=cv2.GetArc();
|
|
dle2=arc.GetStarAngle()-arc.GetEndAngle();
|
|
bulges[3]=dle2;
|
|
}
|
|
else
|
|
bulges[3]=dTemp;
|
|
//bulges[3]=dTemp;
|
|
for(int j=0; j<m_poly2d.Length(); j++)
|
|
{
|
|
ads_real nBuge=tan(bulges[j]/4.0);
|
|
m_pPolyline->removeVertexAt(j);
|
|
m_pPolyline->addVertexAt(j, (Pointlist[j]).AsAcGePoint2d(), nBuge);
|
|
}
|
|
if(m_poly2d.Length()>0)
|
|
m_pPolyline->setElevation(0);
|
|
m_pPolyline->setClosed(Adesk::kTrue);
|
|
//--------------------------------------------------------------------------------------------
|
|
return Adesk::kTrue;
|
|
}
|
|
AcDbEntity * TDrawFlatJig::entity() const
|
|
{
|
|
return (AcDbEntity*)m_pPolyline;
|
|
}
|
|
void TDrawFlatJig::SetPrompt(const TCHAR *pTemp)
|
|
{
|
|
m_szPrompt=pTemp;
|
|
acutPrintf(m_szPrompt);
|
|
}
|
|
int TDrawFlatJig::GetRetCode() const
|
|
{
|
|
int ret = m_iRetCode;
|
|
if (ret == AcEdJig::kCancel)
|
|
ret = RTCAN;
|
|
else if(ret == AcEdJig::kNull)
|
|
ret = RTNONE;
|
|
else if (ret == AcEdJig::kNormal)
|
|
ret = RTNORM;
|
|
else
|
|
{
|
|
ret = RTKWORD;
|
|
}
|
|
return ret;
|
|
}
|
|
//以下为点取画洁具的Jig
|
|
class TSanitaryJig:public AcEdJig
|
|
{
|
|
public:
|
|
TSanitaryJig(TDbBlockInsert *pEntBR,CDecorateSaniFittingDlg *dlg,const CSaniFittingAttr data);//适应于其他的非浴缸和小便池及盥洗槽的操作
|
|
TSanitaryJig(TDbBlockInsert *pEntBR,CDecorateBathTubDlg *dlg,const CSaniFittingAttr data);//适应于浴缸的操作
|
|
~TSanitaryJig();
|
|
int doIt();
|
|
virtual AcEdJig::DragStatus sampler();
|
|
virtual Adesk::Boolean update();
|
|
virtual AcDbEntity* entity() const;
|
|
void SetPrompt(const TCHAR *pTemp);
|
|
int GetRetCode() const;
|
|
void SetKeyword(const TCHAR *pszKeyword);
|
|
public:
|
|
TDbBlockInsert *m_pSan;//保存洁具的图块参考
|
|
CDecorateSaniFittingDlg *m_dlg;//得到对话窗的信息除浴缸和小便池,盥洗槽,地漏等用到的对话窗
|
|
CDecorateBathTubDlg *m_dlgBath;//浴缸操作用到的对话窗
|
|
CSaniFittingAttr m_data;//洁具的信息
|
|
int m_nRetCode; //返回码
|
|
CString m_pszPrompt;
|
|
CString m_pszKeyword;
|
|
AcGePoint3d m_point; //获取的点
|
|
XPoint m_ptPoint; //插入点
|
|
BOOL m_bRot; //是否旋转
|
|
XPoint m_pOffset; //偏移的距离
|
|
/*static*/ double m_RotAngle; //旋转角度
|
|
double m_dangle;//当在单击旋转的情况下保存上一次的角度
|
|
XPoint m_pInsertPoint;//插入洁具的位置
|
|
AcGeMatrix3d m_mat;//图块要变换的矩阵
|
|
double m_dRotateAngle;
|
|
AcGeVector3d m_vecOffSet;//基点偏移向量
|
|
};
|
|
//double TSanitaryJig::m_RotAngle=0.0;
|
|
TSanitaryJig::TSanitaryJig(TDbBlockInsert *pEntBR,CDecorateSaniFittingDlg *dlg,const CSaniFittingAttr data):m_pSan(pEntBR),m_dlg(dlg),m_data(data),m_pOffset(0,0,0)
|
|
{
|
|
m_dlgBath=NULL;
|
|
m_bRot=FALSE;
|
|
m_RotAngle=0.0;
|
|
m_dRotateAngle =0;
|
|
}
|
|
TSanitaryJig::TSanitaryJig(TDbBlockInsert *pEntBR,CDecorateBathTubDlg *dlg,const CSaniFittingAttr data):m_pSan(pEntBR),m_dlgBath(dlg),m_data(data),m_pOffset(0,0,0)
|
|
{
|
|
m_dlg=NULL;
|
|
m_bRot=FALSE;
|
|
m_RotAngle=0.0;
|
|
m_dRotateAngle =0;
|
|
}
|
|
TSanitaryJig::~TSanitaryJig()
|
|
{
|
|
}
|
|
AcEdJig::DragStatus TSanitaryJig::sampler()
|
|
{
|
|
DragStatus stat;
|
|
setUserInputControls((UserInputControls)
|
|
(AcEdJig::kAccept3dCoordinates|AcEdJig::kNullResponseAccepted));
|
|
if(m_bRot)
|
|
{//当有快捷键单击是旋转的情况下
|
|
double dAng = 0;//临时保存旋转的角度
|
|
DragStatus ds=acquireAngle(m_dRotateAngle,m_ptPoint);
|
|
if(ds==kNormal)
|
|
{
|
|
static double compareAngle=0.0;
|
|
if(fabs(compareAngle-m_dRotateAngle)>1e-6)
|
|
{
|
|
compareAngle=m_dRotateAngle;
|
|
}
|
|
else
|
|
return AcEdJig::kNoChange;
|
|
}
|
|
return ds;
|
|
}
|
|
else
|
|
{
|
|
if(m_pszKeyword)
|
|
setKeywordList(m_pszKeyword);
|
|
stat=acquirePoint(m_ptPoint);
|
|
if(stat==AcEdJig::kNormal)
|
|
{
|
|
static XPoint PointTemp;
|
|
if (PointTemp!=m_ptPoint)
|
|
{
|
|
PointTemp=m_ptPoint;
|
|
}
|
|
else
|
|
return AcEdJig::kNoChange;
|
|
}
|
|
}
|
|
return stat;
|
|
}
|
|
Adesk::Boolean TSanitaryJig::update()
|
|
{
|
|
|
|
double nAix=Ucs2Wcs((0));
|
|
double objectRot=nAix+m_RotAngle;//洁具的转角
|
|
double sx,sy;
|
|
if(m_dlg!=NULL)
|
|
{
|
|
m_dlg->UpdateData(TRUE);
|
|
sx=m_dlg->g_nSizeX/m_data.m_dOrigenalSizeX;
|
|
sy=m_dlg->g_nSizeY/m_data.m_dOrigenalSizeY;
|
|
}
|
|
else if(m_dlgBath!=NULL)
|
|
{
|
|
m_dlgBath->UpdateData(TRUE);
|
|
sx=m_dlgBath->g_nWidth/m_data.m_dOrigenalSizeX;
|
|
sy=m_dlgBath->g_nLength/m_data.m_dOrigenalSizeY;
|
|
}
|
|
|
|
if(m_bRot)
|
|
{
|
|
XPoint ptTem = m_pInsertPoint;
|
|
AcGePoint3d ptInsert=m_pInsertPoint.AsAcGePoint3d();
|
|
double dWcsAngle = Ucs2Wcs(m_dRotateAngle);
|
|
while (GreatEqual(dWcsAngle,2*PI))
|
|
{
|
|
dWcsAngle -=2*PI;
|
|
}
|
|
while (LessEqual(dWcsAngle,-2*PI))
|
|
{
|
|
dWcsAngle +=2*PI;
|
|
}
|
|
if (Equal(dWcsAngle,0,0.000001))
|
|
{
|
|
ptInsert.rotateBy(dWcsAngle,AcGeVector3d::kZAxis,m_ptPoint.AsAcGePoint3d());
|
|
m_pSan->setRotation(Ucs2Wcs(m_RotAngle));
|
|
}
|
|
else
|
|
{
|
|
ptInsert.rotateBy(/*m_RotAngle+*/dWcsAngle,AcGeVector3d::kZAxis,m_ptPoint.AsAcGePoint3d());
|
|
m_pSan->setRotation(Ucs2Wcs(m_RotAngle)+dWcsAngle);
|
|
}
|
|
m_pOffset.x = m_ptPoint.x - ptInsert.x;
|
|
m_pOffset.y = m_ptPoint.y - ptInsert.y;
|
|
ptTem = m_ptPoint - m_pOffset;
|
|
m_pSan->setPosition(ptTem);
|
|
m_pSan->setScaleFactors(AcGeScale3d(sx, sy, 1.0));
|
|
}
|
|
else
|
|
{
|
|
m_pInsertPoint = m_ptPoint - m_pOffset;
|
|
m_pSan->setRotation(objectRot);
|
|
m_pSan->setPosition(m_pInsertPoint);
|
|
m_pSan->setScaleFactors(AcGeScale3d(sx, sy, 1.0));
|
|
}
|
|
return Adesk::kTrue;
|
|
}
|
|
AcDbEntity * TSanitaryJig::entity() const
|
|
{
|
|
return (AcDbEntity *)m_pSan;
|
|
}
|
|
int TSanitaryJig::doIt()
|
|
{
|
|
if(m_bRot) //旋转
|
|
{
|
|
m_nRetCode = drag();
|
|
}
|
|
else
|
|
{
|
|
INITGET_BEG(0,m_pszKeyword);
|
|
m_nRetCode = drag();
|
|
INITGET_END();
|
|
}
|
|
|
|
int nRet = GetRetCode();
|
|
return nRet;
|
|
}
|
|
void TSanitaryJig::SetPrompt(const TCHAR *pTemp)
|
|
{
|
|
m_pszPrompt =pTemp;
|
|
acutPrintf(m_pszPrompt);
|
|
}
|
|
int TSanitaryJig::GetRetCode() const
|
|
{
|
|
int ret = m_nRetCode;
|
|
if (ret == AcEdJig::kCancel)
|
|
ret = RTCAN;
|
|
else if(ret == AcEdJig::kNull)
|
|
ret = RTNONE;
|
|
else if (ret == AcEdJig::kNormal)
|
|
ret = RTNORM;
|
|
else
|
|
{
|
|
ret = RTKWORD;
|
|
}
|
|
return ret;
|
|
}
|
|
void TSanitaryJig::SetKeyword(const TCHAR *pszKeyword)
|
|
{
|
|
m_pszKeyword = pszKeyword;
|
|
}
|
|
//以下为控制函数
|
|
int DrawSantitary( CDecorateSaniFittingDlg &dlg,CSaniFittingAttr &data)
|
|
{
|
|
while(1)
|
|
{
|
|
//选择操控的方式
|
|
XString sKeyword;
|
|
double nDeriveAngle=0,nNormalAngel=0;
|
|
//读取图块
|
|
XString sBlockName(256);
|
|
XString sDwbName(256);
|
|
sDwbName<<g_sDwbPath<<_T("lvtry.DWB");
|
|
if(LoadDwbBlock(sDwbName, data.m_csBlockName, sBlockName)!=RTNORM)
|
|
return 0;
|
|
double sx=dlg.g_nSizeX/data.m_dOrigenalSizeX,
|
|
sy=dlg.g_nSizeY/data.m_dOrigenalSizeY; // 确定插入比例
|
|
TDbBlockInsert * pBlock=new TDbBlockInsert;
|
|
AcDbObjectId oID=InitBlock(sBlockName);
|
|
pBlock->setBlockTableRecord(oID);
|
|
pBlock->setScaleFactors(AcGeScale3d(sx, sy, 1.0));
|
|
pBlock->setRotation(nDeriveAngle);
|
|
switch(CDecorateSaniFittingDlg::m_iBarCheck)
|
|
{
|
|
case 0:
|
|
{//点取方式
|
|
double dRotAngle = 0;//旋转角度zzg
|
|
TSanitaryJig jig(pBlock,&dlg,data);
|
|
while(1)
|
|
{
|
|
jig.SetPrompt(_T("\n点取位置或 [转90度(A)/左右翻(S)/上下翻(D)/对齐(F)/改转角(R)/改基点(T)/参考点(Q)]<退出>:"));
|
|
jig.SetKeyword(_T("A S D F R T Q Z"));//其中Z为新加选项,用于处理弹出构件库
|
|
int nRet=jig.doIt();
|
|
dRotAngle = jig.m_RotAngle;
|
|
if(nRet ==RTNORM)
|
|
{
|
|
pBlock=(TDbBlockInsert*)jig.entity();
|
|
TDbBlockInsert *pIns=(TDbBlockInsert*)pBlock->clone();
|
|
{//判断此处是不是已经有洁具了
|
|
XPoint pLow(0,0,0),pTop(0,0,0);
|
|
pIns->GetExtents2d(pLow,pTop);
|
|
PickSet ss(SS_FREE);
|
|
RBList rbMask;
|
|
resbuf * rLayer=ads_buildlist(8,_T("LVTRY"),NULL);
|
|
rbMask.Append(rLayer);
|
|
int rt=ss.Get(_T("C"),Wcs2Ucs(pLow),Wcs2Ucs(pTop),rbMask);
|
|
if(rt==RTNORM)
|
|
{
|
|
delete pIns;
|
|
acutPrintf(_T("\n当前位置已有洁具!"));
|
|
}
|
|
else
|
|
{
|
|
AddToCurrentSpace(pIns,Adesk::kTrue);
|
|
pIns->close();
|
|
}
|
|
}
|
|
if(!dlg.g_bMultiPlace)//如果是单个布置洁具的情况下则退出系统
|
|
break;
|
|
TArchCmdReactor::UpdateCorners();
|
|
TArchCmdReactor::ResetAll();
|
|
}
|
|
else if(nRet ==RTKWORD)
|
|
{//处理jig中返回关键字的情况
|
|
ads_printf(_T("%c%c%c"), 8,8,8); //消除回答的字符
|
|
switch(jig.m_nRetCode)
|
|
{
|
|
case 1:
|
|
{//转90度
|
|
jig.m_RotAngle+=PI/2;
|
|
dRotAngle = jig.m_RotAngle;
|
|
AcGeMatrix3d mat3;
|
|
XVector3D xv(0,0,1);
|
|
XPoint PointTemp=jig.m_pInsertPoint+jig.m_pOffset;
|
|
mat3.setToRotation(PI/2,xv.AsAcGeVector3d(),PointTemp.AsAcGePoint3d());
|
|
jig.m_pInsertPoint.TransformBy(mat3);
|
|
jig.m_pOffset=PointTemp-jig.m_pInsertPoint;
|
|
jig.m_mat=mat3;
|
|
break;
|
|
}
|
|
case 2:
|
|
{//左右翻转
|
|
XPoint CurrentPoint=jig.m_pInsertPoint+jig.m_pOffset;//获取当前的鼠标点
|
|
AcGePoint2d pt(Wcs2Ucs(CurrentPoint).AsAcGePoint2d());
|
|
XVector3D xv(0,1,0);
|
|
AcGeLine2d geline2d(pt,xv.AsAcGeVector2d());
|
|
AcGePoint2d PointTemp=Wcs2Ucs(jig.m_pInsertPoint);
|
|
PointTemp=PointTemp.mirror(geline2d);
|
|
jig.m_pOffset=CurrentPoint-Ucs2Wcs(PointTemp);
|
|
jig.m_RotAngle*=-1;
|
|
dRotAngle = jig.m_RotAngle;
|
|
break;
|
|
}
|
|
case 3:
|
|
{//上下翻转
|
|
XPoint CurrentPoint=jig.m_pInsertPoint+jig.m_pOffset;//获取当前的鼠标点
|
|
AcGePoint2d pt(Wcs2Ucs(CurrentPoint).AsAcGePoint2d());
|
|
XVector3D xv(1,0,0);
|
|
AcGeLine2d geline2d(pt,xv.AsAcGeVector2d());
|
|
AcGePoint2d PointTemp=Wcs2Ucs(jig.m_pInsertPoint);
|
|
PointTemp=PointTemp.mirror(geline2d);
|
|
jig.m_pOffset=CurrentPoint-Ucs2Wcs(PointTemp);
|
|
jig.m_RotAngle=PI-jig.m_RotAngle;
|
|
dRotAngle = jig.m_RotAngle;
|
|
break;
|
|
}
|
|
case 4:
|
|
{//对齐
|
|
int nOsMode=0;
|
|
xg_getvar(_T("OSMODE"), &nOsMode);
|
|
nOsMode &= ~0x4000;
|
|
nOsMode&=~OS_NOD&~OS_END &~OS_MID&~OS_CEN&~OS_NOD&~OS_QUA&~OS_INT&~OS_INS&~OS_PER&~OS_TAN&~OS_NEA&~OS_QUI&~OS_APP;
|
|
nOsMode |= OS_INT|OS_NEA|OS_PER|OS_END|OS_MID|OS_CEN;
|
|
XPushVar<int> vOsMode(_T("OSMODE"), nOsMode);
|
|
|
|
TDbBlockInsert *pTempEnt=(TDbBlockInsert *)pBlock->clone();
|
|
AcDbObjectId idTemp=AddToCurrentSpace(pTempEnt, Adesk::kTrue);
|
|
|
|
XPoint pt1, pt2, qt1, qt2;
|
|
if(ads_getpoint(NULL, _T("\n对齐参考点:"), pt1)==RTNORM &&
|
|
ads_getpoint(pt1, _T("\n对齐参考轴:"), pt2)==RTNORM &&
|
|
ads_getpoint(NULL, _T("\n对齐目标点:"), qt1)==RTNORM &&
|
|
ads_getpoint(qt1, _T("\n对齐目标轴:"), qt2)==RTNORM)
|
|
{
|
|
pt1=Ucs2Wcs(pt1);
|
|
pt2=Ucs2Wcs(pt2);
|
|
qt1=Ucs2Wcs(qt1);
|
|
qt2=Ucs2Wcs(qt2);
|
|
|
|
double nRot=CT_std_angle(ads_angle(qt1, qt2)-ads_angle(pt1, pt2));
|
|
ads_matrix matMov, matRot;
|
|
pt1.GetMoveMatrix(qt1, matMov);
|
|
qt1.GetRotationMatrix(nRot, matRot);
|
|
XPoint pLow,pTop;
|
|
TDbBlockInsert *pNew = NULL;
|
|
OPENOBJ_BEGIN(idTemp, AcDb::kForWrite, AcDbEntity, pEnt);
|
|
if(pEnt)
|
|
{
|
|
pEnt->transformBy(AsAcGeMatrix3d(matMov));
|
|
pEnt->transformBy(AsAcGeMatrix3d(matRot));
|
|
}
|
|
OPENOBJ_END();
|
|
pTempEnt->GetExtents2d(pLow,pTop);
|
|
PickSet ss(SS_FREE);
|
|
RBList rbMask;
|
|
resbuf * rLayer=ads_buildlist(8,_T("LVTRY"),NULL);
|
|
rbMask.Append(rLayer);
|
|
int rt=ss.Get(_T("C"),pLow,pTop,rbMask);
|
|
if(rt==RTNORM)
|
|
{
|
|
OPENOBJ_BEGIN(idTemp, AcDb::kForWrite, AcDbEntity, pEnt);
|
|
if(pEnt)
|
|
{
|
|
pEnt->erase();
|
|
}
|
|
OPENOBJ_END();
|
|
acutPrintf(_T("\n当前位置已有洁具!"));
|
|
}
|
|
else
|
|
{
|
|
AddToCurrentSpace(pTempEnt,Adesk::kTrue);
|
|
pTempEnt->close();
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
case 5:
|
|
{//改转角
|
|
//确定为改转角
|
|
pBlock=(TDbBlockInsert*)jig.entity();
|
|
TSanitaryJig jig1(pBlock,&dlg,data);
|
|
jig1.m_bRot=TRUE;
|
|
jig1.m_ptPoint=(jig.m_ptPoint);
|
|
jig1.m_RotAngle = jig.m_RotAngle;
|
|
jig1.m_dRotateAngle = jig.m_dRotateAngle;
|
|
jig1.m_pInsertPoint = jig.m_pInsertPoint;
|
|
jig1.SetPrompt(_T("\n请输入旋转的角度:"));
|
|
int rt=jig1.doIt();
|
|
if(rt==RTNORM)
|
|
{
|
|
AcGePoint3d ptInsert=jig1.m_pInsertPoint.AsAcGePoint3d();
|
|
ptInsert.rotateBy(jig1.m_dRotateAngle,AcGeVector3d::kZAxis,jig1.m_ptPoint.AsAcGePoint3d());
|
|
jig.m_pOffset.x = jig1.m_ptPoint.x - ptInsert.x;
|
|
jig.m_pOffset.y = jig1.m_ptPoint.y - ptInsert.y;
|
|
jig1.m_RotAngle += jig1.m_dRotateAngle;
|
|
jig.m_RotAngle=jig1.m_RotAngle;
|
|
jig.m_dRotateAngle = jig1.m_dRotateAngle;
|
|
jig.m_pInsertPoint = jig.m_ptPoint-jig.m_pOffset;
|
|
}
|
|
break;
|
|
}
|
|
case 6:
|
|
{//改基点
|
|
pBlock=(TDbBlockInsert*)jig.entity();
|
|
TDbBlockInsert *pIns=(TDbBlockInsert*)pBlock->clone();
|
|
AcDbObjectId idTemp=AddToCurrentSpace(pIns,Adesk::kTrue);
|
|
XPoint pt;
|
|
int rt=XGetPoint(NULL, _T("\n输入插入点"),pt);
|
|
if(rt==RTNORM)
|
|
{
|
|
pt=Ucs2Wcs(pt);
|
|
jig.m_pOffset=pt-jig.m_pInsertPoint;
|
|
dlg.UpdateData(FALSE);
|
|
}
|
|
|
|
OPENOBJ_BEGIN(idTemp, AcDb::kForWrite, AcDbEntity, pEnt);
|
|
if(pEnt) pEnt->erase();
|
|
OPENOBJ_END();
|
|
break;
|
|
}
|
|
case 7:
|
|
{//选定参考点
|
|
//以下代码是设置对象选择
|
|
int nOsMode=0;
|
|
xg_getvar(_T("OSMODE"), &nOsMode);
|
|
nOsMode &= ~0x4000;
|
|
nOsMode&=~OS_NOD&~OS_END &~OS_MID&~OS_CEN&~OS_NOD&~OS_QUA&~OS_INT&~OS_INS&~OS_PER&~OS_TAN&~OS_NEA&~OS_QUI&~OS_APP;
|
|
nOsMode |= OS_INT|OS_NEA|OS_PER|OS_END|OS_MID|OS_CEN;
|
|
XPushVar<int> vOsMode(_T("OSMODE"), nOsMode);
|
|
XPoint xtemp;
|
|
XPoint xInsert;
|
|
ads_getpoint(NULL,_T("\n请选取参考点:"),xtemp);
|
|
ads_getpoint(xtemp,_T("\n请输入插入点:"),xInsert);
|
|
TDbBlockInsert *pTempEnt=(TDbBlockInsert *)pBlock->clone();
|
|
|
|
//改基点后参考插入点按原来基点插入 modify by xlc on 090723
|
|
//pTempEnt->setPosition(Ucs2Wcs(xInsert));
|
|
XPoint ptLoc=Ucs2Wcs(xInsert)-jig.m_pOffset;
|
|
pTempEnt->setPosition((ptLoc));
|
|
|
|
pTempEnt->setScaleFactors(AcGeScale3d(sx, sy, 1.0));
|
|
AddToCurrentSpace(pTempEnt,true);
|
|
pTempEnt->close();
|
|
pTempEnt=NULL;
|
|
break;
|
|
}
|
|
case 8:
|
|
{//这里处理IDC_SLIDE发送的快捷方式,改变选中的组件
|
|
CTemporaryResourceOverride vTemp1;
|
|
CSanitaryDlg dlgChose(&dlg);
|
|
dlgChose.m_nOpenMode = 1;
|
|
|
|
dlgChose.SetCurrentItem(data, TRUE);
|
|
if(dlgChose.DoModal()==IDOK)
|
|
{
|
|
CSaniFittingAttr *pData=dlgChose.GetCurrentSelection();
|
|
data=*pData;
|
|
if(pData->m_nPlaceFlag<=1)
|
|
{
|
|
LoadDwbBlock(sDwbName, data.m_csBlockName, sBlockName);
|
|
dlg.SetFromSaniWare(data);
|
|
dlg.UpdateData(FALSE);
|
|
dlg.UpdateSlide();
|
|
|
|
oID=InitBlock(sBlockName);
|
|
pBlock->setBlockTableRecord(oID);
|
|
pBlock->setScaleFactors(AcGeScale3d(sx, sy, 1.0));
|
|
pBlock->setRotation(nDeriveAngle);
|
|
jig.m_pSan=pBlock;
|
|
jig.m_data=data;
|
|
continue;
|
|
}
|
|
else if(pData->m_nPlaceFlag==2)
|
|
{
|
|
dlg.DestroyWindow();
|
|
CWnd *pWnd=acedGetAcadFrame();
|
|
CDecorateBathTubDlg *dlg1=new CDecorateBathTubDlg(pWnd);
|
|
double sx=CDecorateSaniFittingDlg::g_nSizeX/data.m_dOrigenalSizeX,
|
|
sy=CDecorateSaniFittingDlg::g_nSizeY/data.m_dOrigenalSizeY; // 确定插入比例
|
|
dlg1->SetFromSaniWare(data);
|
|
dlg1->Create(dlg1->IDD,pWnd);
|
|
DrawSantitary2(*dlg1,data);
|
|
return 0;
|
|
}
|
|
else
|
|
{
|
|
return 1;
|
|
}
|
|
}
|
|
else
|
|
{ //取消换取设备
|
|
continue;
|
|
}
|
|
}
|
|
break;
|
|
}//end switch
|
|
}
|
|
else
|
|
{
|
|
if(dlg.m_bESC)
|
|
{
|
|
dlg.m_bESC=FALSE;
|
|
break;
|
|
}
|
|
else
|
|
{
|
|
dlg.DestroyWindow();//新加入
|
|
return 0;
|
|
}
|
|
|
|
}//end if
|
|
}
|
|
}
|
|
break;
|
|
case 1:
|
|
{//均匀分布
|
|
{//对洁具数据操作的恢复
|
|
dlg.GetDlgItem(IDC_EDIT_SIZEX)->EnableWindow(TRUE);
|
|
dlg.GetDlgItem(IDC_EDIT_SIZEY)->EnableWindow(TRUE);
|
|
dlg.GetDlgItem(IDC_EDIT_DISTWALL)->EnableWindow(TRUE);
|
|
}
|
|
int iRet=0;
|
|
RBList rmask;
|
|
Entity ent;
|
|
XPoint SidePoint;
|
|
resbuf * rb=ads_buildlist(RTDXF0,_T("ATS_WALL,ARC,LINE"),0);
|
|
rmask.Append(rb);
|
|
INITGET_BEG(0,_T("D Z"))//修改过
|
|
iRet=SelectEntity1(_T("\n请选择要均布洁具的对象或 [两点间均布(D)]<退出>:"),ent,SidePoint,rmask);
|
|
INITGET_END()
|
|
if(iRet!=RTNORM && iRet!=RTKWORD)
|
|
{
|
|
if(dlg.m_bESC)
|
|
{
|
|
dlg.m_bESC=FALSE;
|
|
break;
|
|
}
|
|
else
|
|
{
|
|
return 0;
|
|
}
|
|
}
|
|
else if(iRet==RTNORM)
|
|
{
|
|
XScreenDc dc(1,1);
|
|
OPENOBJ_BEGIN(ent,AcDb::kForRead,AcDbEntity,pEnt)
|
|
TEntityBase *pTEnt=TEntityBase::Cast(pEnt);
|
|
XDirectionCurve cv;
|
|
XDirectionCurve cvTemp;
|
|
XDirectionCurve cvWallLeft,cvWallRight;//保存墙的左右的Curve
|
|
int xTemp;
|
|
int rt;//返回
|
|
int iSide;
|
|
double ChordHeight;
|
|
BOOL bRiLe;
|
|
XCurveSegment seg;
|
|
UINT MaxNumber;//可插入洁具的最大数目
|
|
if(pTEnt!=NULL)
|
|
{
|
|
TDbWall *pWall=TDbWall::cast(pEnt);
|
|
seg=pWall->OffsetGeomCenter();
|
|
pWall->GetSideCurve(cvWallLeft,cvWallRight);// [3/5/2008 nsh]
|
|
}
|
|
else
|
|
{
|
|
seg=XCurveSegment(ent,LS_INFINITE);
|
|
}
|
|
(XCurveSegment &)cv=seg;
|
|
if(pTEnt==NULL)
|
|
{
|
|
rt=ads_getpoint(NULL,_T("\n请选择插入的一侧 <退出>:"),SidePoint);
|
|
if(rt!=RTNORM)
|
|
return 0;
|
|
}
|
|
iSide=cv.OnWhichSide(Ucs2Wcs(SidePoint));
|
|
dlg.UpdateData(TRUE);
|
|
{//限制用户再次修改洁具的数据
|
|
dlg.GetDlgItem(IDC_EDIT_SIZEX)->EnableWindow(FALSE);
|
|
dlg.GetDlgItem(IDC_EDIT_SIZEY)->EnableWindow(FALSE);
|
|
dlg.GetDlgItem(IDC_EDIT_DISTWALL)->EnableWindow(FALSE);
|
|
}
|
|
if(cv.Is(CURVE_LINE))
|
|
{
|
|
MaxNumber=GetMaxInsert(CDecorateSaniFittingDlg::g_nSizeX,cv);
|
|
if(iSide==0)
|
|
{
|
|
cvTemp=pTEnt!=NULL?cvWallLeft:cv;
|
|
xTemp=-CDecorateSaniFittingDlg::g_nDistToWall;
|
|
}
|
|
else if(iSide==1)
|
|
{
|
|
cvTemp=pTEnt!=NULL?cvWallRight:cv;
|
|
xTemp=CDecorateSaniFittingDlg::g_nDistToWall;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if(iSide==0)
|
|
{
|
|
cvTemp=pTEnt!=NULL?cvWallLeft:cv;
|
|
xTemp=-CDecorateSaniFittingDlg::g_nDistToWall;
|
|
XArc ar=cv.GetArc();
|
|
ChordHeight=GetChordHeight(ar.GetRadius(),CDecorateSaniFittingDlg::g_nSizeX);
|
|
if(ChordHeight>=CDecorateSaniFittingDlg::g_nDistToWall)
|
|
{
|
|
xTemp=-ChordHeight;
|
|
}
|
|
bRiLe=TRUE;
|
|
}
|
|
else if(iSide==1)
|
|
{
|
|
cvTemp=pTEnt!=NULL?cvWallRight:cv;
|
|
xTemp=CDecorateSaniFittingDlg::g_nDistToWall;
|
|
bRiLe=FALSE;
|
|
}
|
|
MaxNumber=GetMaxInsert(CDecorateSaniFittingDlg::g_nSizeX,cvTemp,xTemp,CDecorateSaniFittingDlg::g_nSizeY,bRiLe);
|
|
}
|
|
CString stemp;
|
|
stemp.Format(_T("%i"),MaxNumber);
|
|
CString proptem=_T("\n请输入要插入洁具的数量< <最大插入洁具数 =") + stemp +_T(">:");
|
|
int PutNumber=0;
|
|
while(1)
|
|
{
|
|
int ret=ads_getint(proptem,&PutNumber);
|
|
if(ret==RTNORM)
|
|
{//如果得到数量返回正常
|
|
if(PutNumber<=MaxNumber)break;
|
|
}
|
|
else if(ret==RTNONE)
|
|
{
|
|
PutNumber=MaxNumber;
|
|
break;
|
|
}
|
|
else
|
|
{
|
|
return 0;
|
|
}
|
|
}
|
|
Array<XPointDir2d> arrayTemp=GetArrayPoint(cvTemp,PutNumber,xTemp,0);
|
|
for(long i=0;i<arrayTemp.GetLength();i++)
|
|
{
|
|
TDbBlockInsert *pInsert=(TDbBlockInsert*)pBlock->clone();
|
|
pInsert->setPosition(arrayTemp[i]);
|
|
if(iSide==0)
|
|
pInsert->setRotation(arrayTemp[i].nDirection+PI);
|
|
else if(iSide==1)
|
|
pInsert->setRotation(arrayTemp[i].nDirection);
|
|
AddToCurrentSpace(pInsert,true);
|
|
pInsert->close();
|
|
pInsert=NULL;
|
|
}
|
|
if(data.m_csKindName==_T("台式洗脸盆"))
|
|
{
|
|
DrawFlat(cvTemp);
|
|
}
|
|
OPENOBJ_END()
|
|
}
|
|
else if(iRet==RTKWORD)
|
|
{
|
|
TCHAR buf[256];
|
|
acedGetInput(buf);
|
|
double nAix=Ucs2Wcs((0));
|
|
if(buf[0]==_T('Z'))
|
|
{//处理更改洁具图形
|
|
CTemporaryResourceOverride vTemp1;
|
|
CSanitaryDlg dlgChose(&dlg);
|
|
dlgChose.m_nOpenMode = 1;
|
|
|
|
dlgChose.SetCurrentItem(data, TRUE);
|
|
if(dlgChose.DoModal()==IDOK)
|
|
{
|
|
CSaniFittingAttr *pData=dlgChose.GetCurrentSelection();
|
|
data=*pData;
|
|
if(pData->m_nPlaceFlag<=1)
|
|
{
|
|
LoadDwbBlock(sDwbName, data.m_csBlockName, sBlockName);
|
|
dlg.SetFromSaniWare(data);
|
|
dlg.UpdateData(FALSE);
|
|
dlg.UpdateSlide();
|
|
continue;
|
|
}
|
|
else if(pData->m_nPlaceFlag==2)
|
|
{
|
|
dlg.DestroyWindow();
|
|
CWnd *pWnd=acedGetAcadFrame();
|
|
CDecorateBathTubDlg *dlg1=new CDecorateBathTubDlg(pWnd);
|
|
double sx=CDecorateSaniFittingDlg::g_nSizeX/data.m_dOrigenalSizeX,
|
|
sy=CDecorateSaniFittingDlg::g_nSizeY/data.m_dOrigenalSizeY; // 确定插入比例
|
|
dlg1->SetFromSaniWare(data);
|
|
dlg1->Create(dlg1->IDD,pWnd);
|
|
DrawSantitary2(*dlg1,data);
|
|
return 0;
|
|
}
|
|
else
|
|
{
|
|
return 1;
|
|
}
|
|
}
|
|
else
|
|
{ //取消换取设备
|
|
continue;
|
|
}
|
|
}
|
|
XPoint pFirst;
|
|
XPoint pSecond;
|
|
XScreenDc dc(1,1);
|
|
XDirectionCurve cvTemp;// [8/19/2008 nsh]
|
|
XDirectionCurve seg;//两点之间的线段
|
|
double p2Dist;//两点之间的距离
|
|
Array<XPointDir2d> arraypoint;
|
|
int rt1=ads_getpoint(NULL,_T("\n请输入第一点 <结束>:"),pFirst);
|
|
pFirst=Ucs2Wcs(pFirst);
|
|
int rt2;
|
|
if(rt1==RTNORM)
|
|
{
|
|
rt2=ads_getpoint(Wcs2Ucs(pFirst),_T("\n请输入第二点 <结束>:"),pSecond);
|
|
pSecond=Ucs2Wcs(pSecond);
|
|
}
|
|
if(rt1==RTNORM && rt2==RTNORM)
|
|
{
|
|
|
|
p2Dist=pFirst.Distance(pSecond);
|
|
cvTemp.SetPoints(pFirst,pSecond);
|
|
seg.SetPoints(Wcs2Ucs(pFirst),Wcs2Ucs(pSecond));
|
|
double nDirction=((XLine &)cvTemp).Direction();//得到角度
|
|
dc<<seg;//显示红色虚线
|
|
XPoint DirPoint;//方向点
|
|
//-------------------------
|
|
{//限制用户再次修改洁具的数据
|
|
dlg.GetDlgItem(IDC_EDIT_SIZEX)->EnableWindow(FALSE);
|
|
dlg.GetDlgItem(IDC_EDIT_SIZEY)->EnableWindow(FALSE);
|
|
dlg.GetDlgItem(IDC_EDIT_DISTWALL)->EnableWindow(FALSE);
|
|
}
|
|
UINT MaxNumber=GetMaxInsert(CDecorateSaniFittingDlg::g_nSizeX,seg);
|
|
CString stemp;
|
|
stemp.Format(_T("%i"),MaxNumber);
|
|
CString proptem=_T("\n请输入要插入洁具的数量< <最大插入洁具数 =") + stemp +_T(">:");
|
|
int PutNumber=0;
|
|
while(1)
|
|
{
|
|
int ret=ads_getint(proptem,&PutNumber);
|
|
if(ret==RTNORM)
|
|
{//如果得到数量返回正常
|
|
if(PutNumber<=MaxNumber)break;
|
|
}
|
|
else if(ret==RTNONE)
|
|
{
|
|
PutNumber=MaxNumber;
|
|
break;
|
|
}
|
|
else
|
|
{
|
|
return 0;
|
|
}
|
|
}
|
|
|
|
int rt3=ads_getpoint(NULL,_T("\n请选择要绘制洁具的一侧 <退出>:"),DirPoint);
|
|
if(rt3==RTNORM)
|
|
{
|
|
//用户坐标系下出错 modify by xlc on 090723
|
|
//int dirwhich=seg.OnWhichSide(DirPoint);
|
|
int dirwhich=seg.OnWhichSide(Ucs2Wcs(DirPoint));
|
|
|
|
dlg.UpdateData(TRUE);//更新
|
|
double sx=dlg.g_nSizeX/data.m_dOrigenalSizeX,
|
|
sy=dlg.g_nSizeY/data.m_dOrigenalSizeY; // 确定插入比例
|
|
TDbBlockInsert * pBlock=new TDbBlockInsert;
|
|
AcDbObjectId oID=InitBlock(sBlockName);
|
|
pBlock->setBlockTableRecord(oID);
|
|
pBlock->setScaleFactors(AcGeScale3d(sx, sy, 1.0));
|
|
pBlock->setRotation(nDeriveAngle);
|
|
dlg.UpdateData(TRUE);
|
|
Array<XPointDir2d> arrayTemp=dirwhich==0?GetArrayPoint(seg,PutNumber,-CDecorateSaniFittingDlg::g_nDistToWall,0.0):GetArrayPoint(seg,PutNumber,CDecorateSaniFittingDlg::g_nDistToWall,0.0);
|
|
for(long i=0;i<arrayTemp.GetLength();i++)
|
|
{
|
|
TDbBlockInsert *pInsert=(TDbBlockInsert*)pBlock->clone();
|
|
pInsert->setPosition(Ucs2Wcs(arrayTemp[i]));
|
|
pInsert->setRotation(dirwhich==0?(PI+nDirction):nDirction);
|
|
AddToCurrentSpace(pInsert,true);
|
|
pInsert->close();
|
|
pInsert=NULL;
|
|
}
|
|
|
|
if(data.m_csKindName==_T("台式洗脸盆"))
|
|
{
|
|
AcDbLine * pDbline=new AcDbLine;
|
|
pDbline->setStartPoint(cvTemp.StartPoint());
|
|
pDbline->setEndPoint(cvTemp.EndPoint());
|
|
AddToCurrentSpace(pDbline,true);
|
|
pDbline->close();
|
|
DrawFlat(cvTemp);
|
|
OPENOBJ_BEGIN(pDbline->id() ,AcDb::kForWrite, AcDbLine, pline);
|
|
if(pline)
|
|
pline->erase(Adesk::kTrue);
|
|
OPENOBJ_END();
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if(dlg.m_bESC)
|
|
{
|
|
dlg.m_bESC=FALSE;
|
|
break;
|
|
}
|
|
else
|
|
{
|
|
return 0;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
break;
|
|
case 2:
|
|
/**********/ {//沿墙绘制----------------------------------------------------------------------------------------
|
|
//这个地方修改,加一个 请选择洁具布置基点(墙角点)~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
{//恢复对话窗的输入功能
|
|
dlg.GetDlgItem(IDC_EDIT_ISPACE)->EnableWindow(TRUE);
|
|
}
|
|
RBList rmask;
|
|
resbuf * rs=ads_buildlist(RTDXF0,_T("ATS_WALL,ARC,LINE"),0);
|
|
rmask.Append(rs);
|
|
Entity ent;
|
|
XPoint PickPoint;//在墙上拾取的点
|
|
TDbWall *pWall=NULL;
|
|
int iSide;
|
|
int distwall;
|
|
//添加处理快捷键的功能
|
|
int Ret;
|
|
INITGET_BEG(0,_T("Z"))//修改过
|
|
Ret=SelectEntity1(_T("\n请选择沿墙边线 <退出>:"),ent,PickPoint,rmask);
|
|
INITGET_END()
|
|
if(Ret==RTNORM)
|
|
{
|
|
XCurveSegment cvs;
|
|
XDirectionCurve cdc;
|
|
XDirectionCurve cvTemp;
|
|
XDirectionCurve cvTempSave;//保存原始的操作
|
|
XDirectionCurve cvLoop;
|
|
XDirectionCurve cvWallLeft,cvWallRight;//墙的左右边线
|
|
double rotangle;
|
|
BOOL bRever=FALSE;//判断曲线是否翻转
|
|
static double polarDist;
|
|
double dPlatLength=CDecorateSaniFittingDlg::g_nInitSpace*2, dPlatWidth=600; //台面长度和台面宽度
|
|
polarDist=0.0;
|
|
XPointDir2d insertPoint,
|
|
ptPlatStart;//当为平台洗脸盆时有用 为平台起始点
|
|
OPENOBJ_BEGIN(ent,AcDb::kForRead,AcDbEntity,pEnt)
|
|
//TEntityBase *pTEnt=TEntityBase::Cast(pEnt);
|
|
pWall=TDbWall::cast(pEnt);
|
|
cvs=pWall!=NULL?pWall->OffsetGeomCenter():XCurveSegment(ent,LS_INFINITE);
|
|
//if(pWall!=NULL)pWall->GetSideCurve(cvWallLeft,cvWallRight);// [3/5/2008 nsh]
|
|
if(pWall!=NULL)pWall->GetSideCurve(cvWallLeft,cvWallRight,0,TRUE);
|
|
(XCurveSegment &)cdc=cvs;
|
|
iSide=cdc.OnWhichSide(Ucs2Wcs(PickPoint));
|
|
cvTemp=pWall!=NULL?(iSide==0?cvWallLeft:cvWallRight):cdc;
|
|
if(pWall==NULL)
|
|
{
|
|
XPoint pt;
|
|
int iRet=ads_getpoint(NULL,_T("\n请选择要布置洁具的一侧 <退出>:"),pt);
|
|
if(iRet==RTNORM)
|
|
{
|
|
int itemp=cvTemp.OnWhichSide(Ucs2Wcs(pt));
|
|
iSide=itemp;
|
|
}
|
|
else return 0;
|
|
}
|
|
// [7/25/2008 nsh]
|
|
//---------------------------------------------------------------
|
|
//对沿墙布置洁具功能扩展
|
|
//添加选择墙角点的操作
|
|
int iReturn;
|
|
INITGET_BEG(0,_T("B"))//修改过
|
|
XPointDir2d pt;
|
|
if(cvTemp.StartPoint().Distance(Ucs2Wcs(PickPoint))> cvTemp.EndPoint().Distance(Ucs2Wcs(PickPoint)))
|
|
{
|
|
iReturn=ads_getpoint(Wcs2Ucs(cvTemp.EndPoint()),_T("\n插入第一个洁具[插入基点(B)] <退出>:"),(XPoint &)pt);
|
|
}
|
|
else
|
|
{
|
|
iReturn=ads_getpoint(Wcs2Ucs(cvTemp.StartPoint()),_T("\n插入第一个洁具[插入基点(B)] <退出>:"),(XPoint &)pt);
|
|
}
|
|
INITGET_END()
|
|
if(iReturn==RTNORM)
|
|
{//不做任何处理
|
|
if(cvTemp.StartPoint().Distance(Ucs2Wcs(PickPoint))> cvTemp.EndPoint().Distance(Ucs2Wcs(PickPoint)))
|
|
{
|
|
cvTemp.Reverse();
|
|
bRever=TRUE;
|
|
}
|
|
cvTempSave=cvTemp;
|
|
cvTempSave.Polar(0,ptPlatStart,TRUE);//平台起始点赋值
|
|
}
|
|
else if(iReturn==RTKWORD)
|
|
{
|
|
XPointDir2d ptBase;
|
|
int nOsMode=0;
|
|
xg_getvar(_T("OSMODE"), &nOsMode);
|
|
nOsMode &= ~0x4000;
|
|
nOsMode&=~OS_NOD&~OS_END &~OS_MID&~OS_CEN&~OS_NOD&~OS_QUA&~OS_INT&~OS_INS&~OS_PER&~OS_TAN&~OS_NEA&~OS_QUI&~OS_APP;
|
|
nOsMode |=OS_NEA | OS_INT|OS_END;
|
|
XPushVar<int> vOsMode(_T("OSMODE"), nOsMode);
|
|
int iRet=ads_getpoint(NULL,_T("\n请选择洁具布置基点(墙角点):"),ptBase);
|
|
if(iRet!=RTNORM)
|
|
{
|
|
return 0;
|
|
}
|
|
if(cvTemp.StartPoint().Distance(Ucs2Wcs(PickPoint))> cvTemp.EndPoint().Distance(Ucs2Wcs(PickPoint)))
|
|
{
|
|
cvTemp.Reverse();
|
|
bRever=TRUE;
|
|
}
|
|
double toStart,toEnd;
|
|
XPoint pointStart,pointEnd;
|
|
/*double / *toStart1,* /toEnd1;*/
|
|
toStart=Ucs2Wcs(ptBase).Distance(cvTemp.StartPoint());
|
|
toEnd=Ucs2Wcs(ptBase).Distance(cvTemp.EndPoint());
|
|
//toStart=ptBase.Distance(cvTemp.startPoint);
|
|
//toEnd=ptBase.Distance(cvTemp.endPoint);
|
|
pointStart=cvTemp.StartPoint();
|
|
pointEnd=cvTemp.EndPoint();
|
|
//判断选择点
|
|
|
|
//mpdify by xlc on 090723 基点和拾取点分别靠近不同的顶点,改变基点后插入位置不正确
|
|
//if(cvTemp.Is(CURVE_LINE))
|
|
//{
|
|
//if(toStart<toEnd)
|
|
//{
|
|
// cvTemp.SetPoints(Ucs2Wcs(ptBase),pointEnd);
|
|
//}
|
|
//else
|
|
// cvTemp.SetPoints(pointStart,Ucs2Wcs(ptBase));
|
|
|
|
//}
|
|
//else
|
|
//{
|
|
//if(toStart>toEnd)
|
|
//{
|
|
// cvTemp.SetPoints(pointEnd,Ucs2Wcs(ptBase));
|
|
//}
|
|
//else
|
|
// cvTemp.SetPoints(Ucs2Wcs(ptBase),pointStart);
|
|
//}
|
|
cvTemp.SetPoints(Ucs2Wcs(ptBase),pointEnd);
|
|
|
|
cvTempSave=cvTemp;//保存原始操作
|
|
}
|
|
else
|
|
{
|
|
return 1;
|
|
}
|
|
|
|
//-------------------------------------------------------------------------------
|
|
dlg.UpdateData(TRUE);
|
|
cvLoop=cvTemp;//其中cvLoop是在循环中控制的实现绘制的方法
|
|
distwall=bRever==TRUE?(iSide==0?-CDecorateSaniFittingDlg::g_nDistToWall:CDecorateSaniFittingDlg::g_nDistToWall):(iSide==0?-CDecorateSaniFittingDlg::g_nDistToWall:CDecorateSaniFittingDlg::g_nDistToWall);
|
|
//此处要增加一个判断,来说明是否为圆弧的情况,如果是圆弧的情况则在iSide为0的情况下,
|
|
{
|
|
if(!cvTemp.Is(CURVE_LINE))
|
|
{
|
|
XArc arc;
|
|
arc=cvTemp.GetArc();
|
|
double radius=arc.GetRadius();
|
|
double ChordHeight=GetChordHeight(radius,CDecorateSaniFittingDlg::g_nSizeX);
|
|
if(distwall<=0 && fabs((float)distwall)<=ChordHeight && iSide==0)
|
|
cvTemp=cvTemp.Offset(bRever==TRUE?ChordHeight:-ChordHeight,1);
|
|
else
|
|
cvTemp=cvTemp.Offset(bRever==TRUE?-distwall:distwall,1);
|
|
}
|
|
else
|
|
{
|
|
cvTemp=cvTemp.Offset(bRever==TRUE?-distwall:distwall,1);
|
|
}
|
|
}
|
|
//判断结束
|
|
//XPointDir2d ptIns = Wcs2Ucs(insertPoint);
|
|
// insertPoint = ptIns;
|
|
cvTemp.Polar(CDecorateSaniFittingDlg::g_nInitSpace,insertPoint,TRUE);
|
|
dPlatLength=CDecorateSaniFittingDlg::g_nInitSpace*2;
|
|
rotangle=bRever==TRUE?(iSide==0?insertPoint.nDirection:insertPoint.nDirection+PI):(iSide==0?insertPoint.nDirection+PI:insertPoint.nDirection);
|
|
//dlg.UpdateData(TRUE);//更新
|
|
double sx=dlg.g_nSizeX/data.m_dOrigenalSizeX,
|
|
sy=dlg.g_nSizeY/data.m_dOrigenalSizeY; // 确定插入比例
|
|
TDbBlockInsert * pBlock=new TDbBlockInsert;
|
|
AcDbObjectId oID=InitBlock(sBlockName);
|
|
pBlock->setBlockTableRecord(oID);
|
|
pBlock->setScaleFactors(AcGeScale3d(sx, sy, 1.0));
|
|
pBlock->setRotation(rotangle);
|
|
pBlock->setPosition(insertPoint);
|
|
AddToCurrentSpace(pBlock,Adesk::kTrue);
|
|
polarDist=CDecorateSaniFittingDlg::g_nInitSpace;
|
|
{//限定用户的输入
|
|
dlg.GetDlgItem(IDC_EDIT_ISPACE)->EnableWindow(FALSE);
|
|
}
|
|
while(1)
|
|
{
|
|
cvTemp=cvLoop;//恢复到原始状态
|
|
XPointDir2d pt;
|
|
polarDist+=CDecorateSaniFittingDlg::g_nComponentSpace;
|
|
int rt=ads_getpoint(Wcs2Ucs(insertPoint),_T("\n下一个 <结束>:"),(XPoint &)pt);
|
|
if(rt==RTNORM)
|
|
{
|
|
dlg.UpdateData(TRUE);
|
|
distwall=bRever==TRUE?(iSide==0?-CDecorateSaniFittingDlg::g_nDistToWall:CDecorateSaniFittingDlg::g_nDistToWall):(iSide==0?-CDecorateSaniFittingDlg::g_nDistToWall:CDecorateSaniFittingDlg::g_nDistToWall);
|
|
{
|
|
if(!cvTemp.Is(CURVE_LINE))
|
|
{
|
|
XArc arc;
|
|
arc=cvTemp.GetArc();
|
|
double radius=arc.GetRadius();
|
|
double ChordHeight=GetChordHeight(radius,CDecorateSaniFittingDlg::g_nSizeX);
|
|
if(distwall<=0 && fabs((float)distwall)<=ChordHeight && iSide==0)
|
|
cvTemp=cvTemp.Offset(bRever==TRUE?ChordHeight:-ChordHeight,1);
|
|
else
|
|
cvTemp=cvTemp.Offset(bRever==TRUE?-distwall:distwall,1);
|
|
}
|
|
else
|
|
{
|
|
cvTemp=cvTemp.Offset(bRever==TRUE?-distwall:distwall,1);
|
|
}
|
|
}
|
|
double sx=dlg.g_nSizeX/data.m_dOrigenalSizeX,
|
|
sy=dlg.g_nSizeY/data.m_dOrigenalSizeY; // 确定插入比例
|
|
cvTemp.Polar(polarDist,insertPoint,TRUE);
|
|
rotangle=bRever==TRUE?(iSide==0?insertPoint.nDirection:insertPoint.nDirection+PI):(iSide==0?insertPoint.nDirection+PI:insertPoint.nDirection);
|
|
TDbBlockInsert *pIns=(TDbBlockInsert*)pBlock->clone();
|
|
pIns->setRotation(rotangle);
|
|
pIns->setPosition(insertPoint);
|
|
pIns->setScaleFactors(AcGeScale3d(sx, sy, 1.0));
|
|
AddToCurrentSpace(pIns,Adesk::kTrue);
|
|
dPlatLength += dlg.g_nComponentSpace;
|
|
|
|
}
|
|
else
|
|
{
|
|
break;
|
|
}
|
|
}
|
|
OPENOBJ_END()
|
|
if(data.m_csKindName==_T("台式洗脸盆"))
|
|
{
|
|
DrawPlatNew(insertPoint,cvTempSave,bRever,dPlatLength,dPlatWidth);
|
|
}
|
|
}
|
|
else if(Ret==RTKWORD)
|
|
{
|
|
CTemporaryResourceOverride vTemp1;
|
|
CSanitaryDlg dlgChose(&dlg);
|
|
dlgChose.m_nOpenMode = 1;
|
|
|
|
dlgChose.SetCurrentItem(data, TRUE);
|
|
if(dlgChose.DoModal()==IDOK)
|
|
{
|
|
CSaniFittingAttr *pData=dlgChose.GetCurrentSelection();
|
|
data=*pData;
|
|
if(pData->m_nPlaceFlag<=1)
|
|
{
|
|
LoadDwbBlock(sDwbName, data.m_csBlockName, sBlockName);
|
|
dlg.SetFromSaniWare(data);
|
|
dlg.UpdateData(FALSE);
|
|
dlg.UpdateSlide();
|
|
continue;
|
|
}
|
|
else if(pData->m_nPlaceFlag==2)
|
|
{
|
|
dlg.DestroyWindow();
|
|
CWnd *pWnd=acedGetAcadFrame();
|
|
CDecorateBathTubDlg *dlg1=new CDecorateBathTubDlg(pWnd);
|
|
double sx=CDecorateSaniFittingDlg::g_nSizeX/data.m_dOrigenalSizeX,
|
|
sy=CDecorateSaniFittingDlg::g_nSizeY/data.m_dOrigenalSizeY; // 确定插入比例
|
|
dlg1->SetFromSaniWare(data);
|
|
dlg1->Create(dlg1->IDD,pWnd);
|
|
DrawSantitary2(*dlg1,data);
|
|
return 0;
|
|
}
|
|
else
|
|
{
|
|
return 1;
|
|
}
|
|
}
|
|
else
|
|
{ //取消换取设备
|
|
continue;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if(dlg.m_bESC)
|
|
{
|
|
dlg.m_bESC=FALSE;
|
|
break;
|
|
}
|
|
else
|
|
{
|
|
return 1;
|
|
}
|
|
}
|
|
}//沿墙绘制结束
|
|
break;
|
|
case 3:
|
|
{//选择已有的洁具
|
|
{//
|
|
dlg.GetDlgItem(IDC_EDIT_ISPACE)->EnableWindow(FALSE);
|
|
//dlg.GetDlgItem(IDC_EDIT_DISTWALL)->SetWindowText(_T("0"));
|
|
}
|
|
RBList rmask;
|
|
//resbuf *rb=ads_buildlist(8,_T("LVTRY"),0);
|
|
//resbuf *rb1=ads_buildlist(RTDXF0,_T("AEC_BLOCK_INSERT"),0);
|
|
//rmask.Append(rb);
|
|
resbuf *rb1=ads_buildlist(-4,_T("<OR"),RTDXF0,_T("INSERT"),RTDXF0,_T("AEC_BLOCK_INSERT"),-4,_T("OR>"),0);
|
|
rmask.Append(rb1);
|
|
Entity ent;
|
|
double rotangle;
|
|
double dlineangle;
|
|
XPoint ptSidePoint;
|
|
XPoint insertPoint;
|
|
XPoint pointTemp;
|
|
XPoint basePoint;//已有的洁具的插入点
|
|
AcGePoint3d gepoint;
|
|
double SelectWidth;
|
|
AcDbObjectId oID=InitBlock(sBlockName);
|
|
int iRet;
|
|
INITGET_BEG(0,_T("Z"))
|
|
iRet=SelectEntity1(_T("\n请选择已有洁具 <结束>:"),ent,ptSidePoint,rmask);
|
|
INITGET_END()
|
|
if(iRet==RTNORM)
|
|
{
|
|
OPENOBJ_BEGIN(ent,AcDb::kForRead,AcDbBlockReference,pEnt)
|
|
rotangle=pEnt->rotation();
|
|
gepoint=pEnt->position();
|
|
basePoint=XPoint(gepoint);
|
|
TBlockGeomInfo tginfo;//pEnt->GetGeomInfo();
|
|
tginfo.SetFromInsert(pEnt);
|
|
SelectWidth=tginfo.GetSizeX()/2;
|
|
OPENOBJ_END()
|
|
|
|
dlg.UpdateData(TRUE);
|
|
//这个地方要重新设置宽度离墙的距离
|
|
dlg.g_nInitSpace=dlg.g_nComponentSpace-SelectWidth;
|
|
CString strInitSpace;
|
|
strInitSpace.Format(_T("%d"),dlg.g_nInitSpace);
|
|
dlg.GetDlgItem(IDC_EDIT_ISPACE)->SetWindowText(strInitSpace);
|
|
//
|
|
XLine xl(basePoint,rotangle+PI/2);
|
|
int iSide=xl.OnWhichSide(Ucs2Wcs(ptSidePoint));
|
|
dlineangle=iSide==0?(rotangle+PI):rotangle;
|
|
ads_polar(basePoint,dlineangle,CDecorateSaniFittingDlg::g_nInitSpace+SelectWidth,insertPoint);
|
|
pointTemp=insertPoint;
|
|
ads_polar(insertPoint,rotangle-PI/2,CDecorateSaniFittingDlg::g_nDistToWall,pointTemp);
|
|
double sx=dlg.g_nSizeX/data.m_dOrigenalSizeX,
|
|
sy=dlg.g_nSizeY/data.m_dOrigenalSizeY; // 确定插入比例
|
|
TDbBlockInsert * pBlock=new TDbBlockInsert;
|
|
pBlock->setBlockTableRecord(oID);
|
|
pBlock->setScaleFactors(AcGeScale3d(sx, sy, 1.0));
|
|
pBlock->setRotation(rotangle);
|
|
pBlock->setPosition(pointTemp);
|
|
AddToCurrentSpace(pBlock,Adesk::kTrue);
|
|
pBlock->close();
|
|
pBlock=NULL;
|
|
pointTemp=insertPoint;
|
|
{//控制用户的输入操作
|
|
dlg.GetDlgItem(IDC_EDIT_ISPACE)->EnableWindow(FALSE);
|
|
}
|
|
while (1)
|
|
{
|
|
XPoint xTemp;
|
|
int iRet=ads_getpoint(Wcs2Ucs(pointTemp),_T("\n下一个 <结束>:"),xTemp);
|
|
if(iRet==RTNORM)
|
|
{
|
|
dlg.UpdateData(TRUE);
|
|
|
|
ads_polar(insertPoint,dlineangle,CDecorateSaniFittingDlg::g_nComponentSpace,insertPoint);
|
|
pointTemp=insertPoint;
|
|
ads_polar(insertPoint,rotangle-PI/2,CDecorateSaniFittingDlg::g_nDistToWall,pointTemp);
|
|
double sx=dlg.g_nSizeX/data.m_dOrigenalSizeX,
|
|
sy=dlg.g_nSizeY/data.m_dOrigenalSizeY; // 确定插入比例
|
|
TDbBlockInsert * pBlock=new TDbBlockInsert;
|
|
pBlock->setBlockTableRecord(oID);
|
|
pBlock->setScaleFactors(AcGeScale3d(sx, sy, 1.0));
|
|
pBlock->setRotation(rotangle);
|
|
pBlock->setPosition(pointTemp);
|
|
AddToCurrentSpace(pBlock,Adesk::kTrue);
|
|
pBlock->close();
|
|
pBlock=NULL;
|
|
}
|
|
else
|
|
break;
|
|
}
|
|
//----------------------------------------------------台式洗脸盆要修改-----------------------------------------------------------------
|
|
//#######################################################################################################################################
|
|
if(data.m_csKindName==_T("台式洗脸盆"))
|
|
{
|
|
XDirectionCurve cvTemp;
|
|
//TAcDbPolyline * pPolyline=new TAcDbPolyline;
|
|
AcDbPolyline *pPolyline=new AcDbPolyline;
|
|
XPointDir2d pt1,pt2;
|
|
//以下实现对象捕捉
|
|
//----------------------
|
|
int nOsMode=0;
|
|
xg_getvar(_T("OSMODE"), &nOsMode);
|
|
nOsMode &= ~0x4000;
|
|
nOsMode&=~OS_NOD&~OS_END &~OS_MID&~OS_CEN&~OS_NOD&~OS_QUA&~OS_INT&~OS_INS&~OS_PER&~OS_TAN&~OS_NEA&~OS_QUI&~OS_APP;
|
|
nOsMode|= OS_INT|OS_NEA|OS_PER|OS_END|OS_MID|OS_CEN;
|
|
XPushVar<int> vOsMode(_T("OSMODE"), nOsMode);
|
|
//-----------------------
|
|
while(1)
|
|
{
|
|
int iRet=ads_getpoint(NULL,_T("\n请输入平台的起点 <结束>:"),pt1);
|
|
if(iRet==RTNORM)
|
|
{
|
|
int iRt=ads_getpoint(pt1,_T("\n请输入平台的终点 <结束>:"),pt2);
|
|
if(iRt==RTNORM)break;
|
|
else return 0;
|
|
}
|
|
else return 0;
|
|
}
|
|
cvTemp.SetPoints(Ucs2Wcs(pt1),Ucs2Wcs(pt2));
|
|
TDrawFlatJig jig1(pPolyline,cvTemp);
|
|
jig1.SetPrompt(_T("\n请输入平台的宽度:"));
|
|
jig1.m_ptFirst=(XPointDir2d &)Ucs2Wcs(pt1);
|
|
jig1.m_ptSecond=(XPointDir2d &)Ucs2Wcs(pt2);
|
|
int iRet=jig1.doIt();
|
|
if(iRet==RTNORM)
|
|
{
|
|
pPolyline=(AcDbPolyline*)jig1.entity();
|
|
AcDbPolyline *pPolylineInsert=(AcDbPolyline*)pPolyline->clone();
|
|
AddToCurrentSpace(pPolylineInsert,Adesk::kTrue);
|
|
pPolylineInsert->close();
|
|
pPolylineInsert=NULL;
|
|
|
|
}
|
|
}
|
|
}
|
|
else if(iRet==RTKWORD)
|
|
{
|
|
CTemporaryResourceOverride vTemp1;
|
|
CSanitaryDlg dlgChose(&dlg);
|
|
dlgChose.m_nOpenMode = 1;
|
|
|
|
dlgChose.SetCurrentItem(data, TRUE);
|
|
if(dlgChose.DoModal()==IDOK)
|
|
{
|
|
CSaniFittingAttr *pData=dlgChose.GetCurrentSelection();
|
|
data=*pData;
|
|
if(pData->m_nPlaceFlag<=1)
|
|
{
|
|
LoadDwbBlock(sDwbName, data.m_csBlockName, sBlockName);
|
|
dlg.SetFromSaniWare(data);
|
|
dlg.UpdateData(FALSE);
|
|
dlg.UpdateSlide();
|
|
continue;
|
|
}
|
|
else if(pData->m_nPlaceFlag==2)
|
|
{
|
|
dlg.DestroyWindow();
|
|
CWnd *pWnd=acedGetAcadFrame();
|
|
CDecorateBathTubDlg *dlg1=new CDecorateBathTubDlg(pWnd);
|
|
double sx=CDecorateSaniFittingDlg::g_nSizeX/data.m_dOrigenalSizeX,
|
|
sy=CDecorateSaniFittingDlg::g_nSizeY/data.m_dOrigenalSizeY; // 确定插入比例
|
|
dlg1->SetFromSaniWare(data);
|
|
dlg1->Create(dlg1->IDD,pWnd);
|
|
DrawSantitary2(*dlg1,data);
|
|
return 0;
|
|
}
|
|
else
|
|
{
|
|
return 1;
|
|
}
|
|
}
|
|
else
|
|
{ //取消换取设备
|
|
continue;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if(dlg.m_bESC)
|
|
{
|
|
dlg.m_bESC=FALSE;
|
|
break;
|
|
}
|
|
else
|
|
{
|
|
dlg.DestroyWindow();//新加入
|
|
return 0;
|
|
}
|
|
}
|
|
}
|
|
break;
|
|
default:
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
return 0;
|
|
}
|
|
//////////////////////////////////////////////////////////////////////////
|
|
//以下的方式是对小便池和盥洗槽的操作
|
|
//基本的情况不变,主要是对圆弧墙的操作
|
|
int DrawSantitary1(const CSaniFittingAttr &data)
|
|
{
|
|
XString sBlockName(256);
|
|
XString sDwbName(256);
|
|
sDwbName << g_sDwbPath << _T("lvtry.DWB");
|
|
LoadDwbBlock(sDwbName, _T("00000000"), sBlockName);
|
|
TDbBlockInsert * pBlock=new TDbBlockInsert;
|
|
AcDbObjectId oID=InitBlock(sBlockName);
|
|
pBlock->setBlockTableRecord(oID);
|
|
pBlock->setScaleFactors(AcGeScale3d(1, 1, 1.0));
|
|
Entity ent;//选择的实体对象
|
|
XPoint ptPostion;//选择的对象所在的插入点
|
|
XDirectionCurve cvb,cvTemp;//从选择的对象中取得的线
|
|
double dWallWidth;//墙的宽度
|
|
double dAng;//旋转角度
|
|
int iRet;//操作的返回标记 RTNORM RTKEYWORD etc
|
|
int iSide=-1;//判断是选中了哪一边的墙体
|
|
RBList rmask;
|
|
TDbWall *pWall=NULL;
|
|
//以下为洁具的相关数据
|
|
double dDistToWallCorner;//距离墙角的距离
|
|
// double dWidth;//洁具宽度
|
|
// double dLength;//洁具的长度
|
|
// double dWidth1;//台阶的宽度
|
|
XPointDir2d ptstart;//开始点
|
|
XPointDir2d ptend;//结束点
|
|
resbuf *rb=ads_buildlist(RTDXF0,_T("ATS_WALL,ARC,LINE"),0);
|
|
rmask.Append(rb);
|
|
while(1)
|
|
{
|
|
while(1)
|
|
{
|
|
iRet=SelectEntity1(_T("\n请选择布置洁具的墙线 <退出>:"),ent,ptPostion,rmask);
|
|
if(iRet==RTNORM)
|
|
{
|
|
break;
|
|
}
|
|
else
|
|
{
|
|
return 0;
|
|
}
|
|
}
|
|
OPENOBJ_BEGIN(ent,AcDb::kForRead,AcDbEntity,pEnt)
|
|
pWall=TDbWall::cast(pEnt);
|
|
XCurveSegment cvSave;
|
|
XDirectionCurve cvWallLeft,cvWallRight;
|
|
cvSave=pWall!=NULL?pWall->OffsetGeomCenter():XCurveSegment(ent,LS_INFINITE);
|
|
//if(pWall!=NULL)pWall->GetSideCurve(cvWallLeft,cvWallRight);
|
|
if(pWall!=NULL)pWall->GetSideCurve(cvWallLeft,cvWallRight,0,TRUE);
|
|
(XCurveSegment &)cvb=cvSave;
|
|
if(pWall!=NULL)
|
|
{
|
|
iSide=cvb.OnWhichSide(Ucs2Wcs(ptPostion));
|
|
dWallWidth=pWall->GetWidth(4)/2;
|
|
cvTemp=iSide==0?cvWallLeft:cvWallRight;
|
|
dAng=iSide==0?cvTemp.Direction(Ucs2Wcs(ptPostion))+PI:cvTemp.Direction(Ucs2Wcs(ptPostion));
|
|
}
|
|
else
|
|
{
|
|
cvTemp=cvb;
|
|
XPoint ptTemp;
|
|
int rt=ads_getpoint(NULL,_T("\n选择插入洁具的一侧 <退出>:"),ptTemp);
|
|
if(rt==RTNORM)
|
|
{
|
|
//用户坐标系下不起作用 modify by xlc on 090723
|
|
ptTemp=Ucs2Wcs(ptTemp);
|
|
|
|
iSide=cvTemp.OnWhichSide(ptTemp);
|
|
dAng=iSide==0?cvTemp.Direction(ptPostion)+PI:cvTemp.Direction(ptPostion);
|
|
}
|
|
else return 0;
|
|
}
|
|
if(cvTemp.StartPoint().Distance(Ucs2Wcs(ptPostion))> cvTemp.EndPoint().Distance(Ucs2Wcs(ptPostion)))
|
|
{
|
|
ptPostion=cvTemp.EndPoint();
|
|
}
|
|
else
|
|
ptPostion=cvTemp.StartPoint();
|
|
OPENOBJ_END()
|
|
|
|
if(data.m_csKindName==_T("小便池"))
|
|
{//对小便池的操作
|
|
//参数说明:
|
|
//cvBase为选择的墙线上取的曲线,cvBaseOffset为正对的偏移
|
|
XCurveSegment cvBase,cvBaseOffset,cvBaseSub,cvInsideLeft,cvInsideRight,cvOutLeft,cvOutRight,cvFlat;
|
|
static double dDist(_AS_SYS_UNIT(600)),dDist1(_AS_SYS_UNIT(100)),dDist2(_AS_SYS_UNIT(3000));
|
|
XPoint ptcvtemp;//保留原始的cvTemp的开始点
|
|
static double nInitSpace=_AS_SYS_UNIT(0), nLength=_AS_SYS_UNIT(3000), nWidth=_AS_SYS_UNIT(600),
|
|
nStepWidth=_AS_SYS_UNIT(300), nGap=_AS_SYS_UNIT(60);//小便池的基本数据
|
|
//以下实现对象捕捉
|
|
//----------------------
|
|
int nOsMode=0;
|
|
xg_getvar(_T("OSMODE"), &nOsMode);
|
|
nOsMode &= ~0x4000;
|
|
nOsMode&=~OS_NOD&~OS_END &~OS_MID&~OS_CEN&~OS_NOD&~OS_QUA&~OS_INT&~OS_INS&~OS_PER&~OS_TAN&~OS_NEA&~OS_QUI&~OS_APP;
|
|
nOsMode |=OS_NEA | OS_INT|OS_END;
|
|
XPushVar<int> vOsMode(_T("OSMODE"), nOsMode);
|
|
//-----------------------
|
|
//dDist1 = 100;
|
|
//iRet=ads_getdist(Wcs2Ucs(ptPostion),_T("\n请输入小便池离墙角的距离 <100>:"),&dDist1);
|
|
CString strPrompt,strVal;
|
|
strVal=Dist2Str(dDist1);
|
|
strPrompt.Format(_T("\n请输入小便池离墙角的距离 <%s>:"),strVal);
|
|
iRet=ads_getdist(Wcs2Ucs(ptPostion),strPrompt,&dDist1);
|
|
|
|
if(iRet!=RTCAN)
|
|
{
|
|
//以下通过输入的长度转化为点
|
|
if(ptPostion==cvTemp.EndPoint())
|
|
{
|
|
cvTemp.Polar(cvTemp.GetLength()-dDist1,ptstart);
|
|
|
|
}
|
|
else if(ptPostion==cvTemp.StartPoint())
|
|
{
|
|
cvTemp.Polar(dDist1,ptstart);
|
|
}
|
|
dDistToWallCorner=cvTemp.PathDistance(ptstart,1);
|
|
//dDist2 = 3000;
|
|
strVal=Dist2Str(dDist2);
|
|
strPrompt.Format(_T("\n请输入小便池长度 <%s>:"),strVal);
|
|
iRet=ads_getdist(Wcs2Ucs(ptstart),strPrompt,&dDist2);
|
|
if(iRet!=RTCAN)
|
|
{
|
|
if(ptPostion==cvTemp.EndPoint())
|
|
{
|
|
cvTemp.Polar(cvTemp.GetLength()-dDist1-dDist2,ptend);
|
|
|
|
}
|
|
else if(ptPostion==cvTemp.StartPoint())
|
|
{
|
|
cvTemp.Polar(dDist1+dDist2,ptend);
|
|
}
|
|
if(!cvTemp.Is(CURVE_LINE))
|
|
{//当为圆弧和圆的情况下
|
|
cvBase=GetSuCurve(cvTemp,ptstart,ptend);
|
|
}
|
|
else cvBase.SetPoints(ptstart,ptend);
|
|
|
|
strVal=Dist2Str(nWidth);
|
|
strPrompt.Format(_T("\n请输入小便池的宽度 <%s>:"),strVal);
|
|
iRet=ads_getdist(Wcs2Ucs(ptend),strPrompt,&nWidth);
|
|
if(iRet!=RTCAN)
|
|
{
|
|
if(iRet==RTNONE)
|
|
nWidth=_tstof(strVal);
|
|
|
|
double dToWall=nWidth;//小便池的边沿距墙的距离,这个以后要用作算小便池台阶的宽度
|
|
if(cvBase.Is(CURVE_LINE))
|
|
{
|
|
if(cvTemp.StartPoint().Distance(ptstart) > cvTemp.StartPoint().Distance(ptend))
|
|
cvBase.Reverse();
|
|
}
|
|
cvBaseOffset=iSide==0?cvBase.Offset(-nWidth,1):cvBase.Offset(nWidth,1);
|
|
dDist=cvBase.GetLength();
|
|
XPointDir2d pt1,pt2,pt3,pt4;
|
|
cvBase.Polar(nGap,pt1);
|
|
cvBase.Polar(dDist-nGap,pt2);
|
|
cvBaseSub=GetSuCurve(cvBase,pt1,pt2);
|
|
cvBaseOffset.ProjectToMe(pt1,pt3);
|
|
cvBaseOffset.ProjectToMe(pt2,pt4);
|
|
cvInsideLeft.SetPoints(pt1,pt3);
|
|
cvInsideRight.SetPoints(pt2,pt4);
|
|
cvBaseOffset.ProjectToMe(ptstart,pt3);
|
|
cvBaseOffset.ProjectToMe(ptend,pt4);
|
|
cvOutLeft.SetPoints(ptstart,pt3);
|
|
cvOutRight.SetPoints(ptend,pt4);
|
|
AddToCurrentSpace((AcDbLine*)(cvBaseOffset.AsAcDbCurve())->clone(),Adesk::kTrue);
|
|
AddToCurrentSpace((AcDbLine*)(cvInsideLeft.AsAcDbCurve())->clone(),Adesk::kTrue);
|
|
AddToCurrentSpace((AcDbLine*)(cvInsideRight.AsAcDbCurve())->clone(),Adesk::kTrue);
|
|
AddToCurrentSpace((AcDbLine*)(cvOutLeft.AsAcDbCurve())->clone(),Adesk::kTrue);
|
|
AddToCurrentSpace((AcDbLine*)(cvOutRight.AsAcDbCurve())->clone(),Adesk::kTrue);
|
|
|
|
strVal=Dist2Str(nStepWidth);
|
|
strPrompt.Format(_T("\n请输入小便池台阶的宽度 <%s>:"),strVal);
|
|
iRet=ads_getdist(pt3,strPrompt,&nStepWidth);
|
|
/*dDist=dToWall-dDist;*/
|
|
if(iRet!=RTCAN)
|
|
{
|
|
if(iRet==RTNONE)
|
|
nStepWidth=_tstof(strVal);
|
|
double dist=dToWall-nStepWidth;
|
|
cvFlat=iSide==0?cvBaseSub.Offset(-dist,1):cvBaseSub.Offset(dist,1);
|
|
AddToCurrentSpace((AcDbLine*)(cvFlat.AsAcDbCurve())->clone(),Adesk::kTrue);
|
|
}
|
|
}
|
|
else return 0;
|
|
}
|
|
}
|
|
|
|
}
|
|
else if((!data.m_csKindName.CompareNoCase(_T("舆洗槽")))||(!data.m_csKindName.CompareNoCase(_T("盥洗槽"))))
|
|
{//对盥洗槽的操作
|
|
//cvBase为选择的墙线上取的曲线,cvBaseOffset为正对的偏移
|
|
XCurveSegment cvBase,cvBaseOffset,cvBaseSub,cvInsideLeft,cvInsideRight,cvOutLeft,cvOutRight,cvFlat;
|
|
static double nInitSpace=_AS_SYS_UNIT(0), nLength=_AS_SYS_UNIT(5300), nWidth=_AS_SYS_UNIT(690),
|
|
nWidth1=_AS_SYS_UNIT(100), nGap=_AS_SYS_UNIT(60);
|
|
XDirectionCurve cv1;
|
|
//AcDbPolyline * pPolyline=new AcDbPolyline;
|
|
static double dDist(_AS_SYS_UNIT(690)),dDist1(_AS_SYS_UNIT(0)),dDist2(_AS_SYS_UNIT(5300));
|
|
XPoint ptcvtemp;//保留原始的cvTemp的开始点
|
|
//while(1)
|
|
//{
|
|
//以下实现对象捕捉
|
|
//----------------------
|
|
int nOsMode=0;
|
|
xg_getvar(_T("OSMODE"), &nOsMode);
|
|
nOsMode &= ~0x4000;
|
|
nOsMode&=~OS_NOD&~OS_END &~OS_MID&~OS_CEN&~OS_NOD&~OS_QUA&~OS_INT&~OS_INS&~OS_PER&~OS_TAN&~OS_NEA&~OS_QUI&~OS_APP;
|
|
nOsMode |=OS_NEA | OS_INT|OS_END;
|
|
XPushVar<int> vOsMode(_T("OSMODE"), nOsMode);
|
|
//-----------------------
|
|
//dDist1 = 0;
|
|
//iRet=ads_getdist(Wcs2Ucs(ptPostion),_T("\n盥洗槽离墙角的距离 <0>:"),&dDist1);
|
|
CString strPrompt,strVal;
|
|
strVal=Dist2Str(dDist1);
|
|
strPrompt.Format(_T("\n盥洗槽离墙角的距离 <%s>:"),strVal);
|
|
iRet=ads_getdist(Wcs2Ucs(ptPostion),strPrompt,&dDist1);
|
|
|
|
if(iRet!=RTCAN)
|
|
{
|
|
if (iRet==RTNONE)
|
|
{
|
|
dDist1=_tstof(strVal);
|
|
}
|
|
//以下通过输入的长度转化为点
|
|
if(ptPostion==cvTemp.EndPoint())
|
|
{
|
|
cvTemp.Polar(cvTemp.GetLength()-dDist1,ptstart);
|
|
|
|
}
|
|
else if(ptPostion==cvTemp.StartPoint())
|
|
{
|
|
cvTemp.Polar(dDist1,ptstart);
|
|
}
|
|
dDistToWallCorner=cvTemp.PathDistance(ptstart,1);
|
|
|
|
//dDist2 = 5300;
|
|
//iRet=ads_getdist(Wcs2Ucs(ptstart),_T("\n盥洗槽的长度 <5300>:"),&dDist2);
|
|
strVal=Dist2Str(dDist2);
|
|
strPrompt.Format(_T("\n盥洗槽的长度 <%s>:"),strVal);
|
|
iRet=ads_getdist(Wcs2Ucs(ptstart),strPrompt,&dDist2);
|
|
|
|
if(iRet!=RTCAN)
|
|
{
|
|
if (iRet==RTNONE)
|
|
{
|
|
dDist2=_tstof(strVal);
|
|
}
|
|
if(ptPostion==cvTemp.EndPoint())
|
|
{
|
|
cvTemp.Polar(cvTemp.GetLength()-dDist1-dDist2,ptend);
|
|
|
|
}
|
|
else if(ptPostion==cvTemp.StartPoint())
|
|
{
|
|
cvTemp.Polar(dDist1+dDist2,ptend);
|
|
}
|
|
if(!cvTemp.Is(CURVE_LINE))
|
|
{//当为圆弧和圆的情况下
|
|
cvBase=GetSuCurve(cvTemp,ptstart,ptend);
|
|
}
|
|
else cvBase.SetPoints(ptstart,ptend);
|
|
|
|
//iRet=ads_getdist(Wcs2Ucs(ptend),_T("\n请输入盥洗槽的宽度 <690>:"),&dDist);
|
|
strVal=Dist2Str(nWidth);
|
|
strPrompt.Format(_T("\n请输入盥洗槽的宽度 <%s>:"),strVal);
|
|
iRet=ads_getdist(Wcs2Ucs(ptend),strPrompt,&nWidth);
|
|
|
|
if(iRet!=RTCAN)
|
|
{
|
|
if(iRet==RTNONE)
|
|
nWidth=_tstof(strVal);
|
|
|
|
double dToWall=nWidth;//小便池的边沿距墙的距离,这个以后要用作算小便池台阶的宽度
|
|
if(cvBase.Is(CURVE_LINE))
|
|
{
|
|
if(cvTemp.StartPoint().Distance(ptstart) > cvTemp.StartPoint().Distance(ptend))
|
|
cvBase.Reverse();
|
|
}
|
|
XCurveSegment cvBaseOffsetTem,cvInsideOffsetTem,cvInsideBottom;
|
|
cvBaseOffset=iSide==0?cvBase.Offset(-nWidth,1):cvBase.Offset(nWidth,1);
|
|
cvBaseOffsetTem = iSide==0?cvBase.Offset(-nWidth+nGap,1):cvBase.Offset(nWidth-nGap,1);
|
|
cvInsideBottom = iSide==0?cvBase.Offset(-nGap,1):cvBase.Offset(nGap,1);
|
|
dDist=cvBase.GetLength();
|
|
XPointDir2d pt1,pt2,pt3,pt4,pt5,pt6;
|
|
cvBase.Polar(nGap,pt1);
|
|
cvBase.Polar(dDist-nGap,pt2);
|
|
dDist=cvInsideBottom.GetLength();
|
|
cvInsideBottom.Polar(nGap,pt5);
|
|
cvInsideBottom.Polar(dDist-nGap,pt6);
|
|
|
|
cvBaseSub=GetSuCurve(cvBase,pt1,pt2);
|
|
cvBaseOffsetTem.ProjectToMe(pt1,pt3);
|
|
cvBaseOffsetTem.ProjectToMe(pt2,pt4);
|
|
|
|
cvInsideLeft.SetPoints(pt5,pt3);
|
|
cvInsideRight.SetPoints(pt6,pt4);
|
|
|
|
//modify by xlc on 090722 洁具内侧线为直线
|
|
//cvInsideOffsetTem.SetPoints(pt3,pt4);
|
|
cvInsideOffsetTem=GetSuCurve(cvBaseOffsetTem,pt3,pt4);
|
|
|
|
cvInsideBottom.SetPoints(pt5,pt6);
|
|
cvBaseOffset.ProjectToMe(ptstart,pt3);
|
|
cvBaseOffset.ProjectToMe(ptend,pt4);
|
|
cvOutLeft.SetPoints(ptstart,pt3);
|
|
cvOutRight.SetPoints(ptend,pt4);
|
|
AddToCurrentSpace((AcDbLine*)(cvInsideOffsetTem.AsAcDbCurve())->clone(),Adesk::kTrue);
|
|
AddToCurrentSpace((AcDbLine*)(cvInsideBottom.AsAcDbCurve())->clone(),Adesk::kTrue);
|
|
AddToCurrentSpace((AcDbLine*)(cvBaseOffset.AsAcDbCurve())->clone(),Adesk::kTrue);
|
|
AddToCurrentSpace((AcDbLine*)(cvInsideLeft.AsAcDbCurve())->clone(),Adesk::kTrue);
|
|
AddToCurrentSpace((AcDbLine*)(cvInsideRight.AsAcDbCurve())->clone(),Adesk::kTrue);
|
|
AddToCurrentSpace((AcDbLine*)(cvOutLeft.AsAcDbCurve())->clone(),Adesk::kTrue);
|
|
AddToCurrentSpace((AcDbLine*)(cvOutRight.AsAcDbCurve())->clone(),Adesk::kTrue);
|
|
//dDist = dDist+dToWall;
|
|
|
|
static double dChannel(_AS_SYS_UNIT(100));//水槽的宽度
|
|
|
|
strVal=Dist2Str(dChannel);
|
|
strPrompt.Format(_T("\n请输入水沟的宽度 <%s>:"),strVal);
|
|
iRet=ads_getdist(pt5,strPrompt,&dChannel);
|
|
int iNumber;//水龙头的个数
|
|
/*dDist=dToWall-dDist;*/
|
|
if(iRet!=RTCAN)
|
|
{
|
|
XDirectionCurve cv1,cv2,cv3;
|
|
if(iRet==RTNONE)
|
|
dChannel=_tstof(strVal);
|
|
(XCurveSegment&)cv1=GetSuCurve(cvTemp,ptstart,ptend);
|
|
cv1.Polar(nGap,pt3);
|
|
cv1.Polar(cv1.GetLength()-nGap,pt4);
|
|
double dChannelWidth = dChannel +nGap;
|
|
if(!cv1.Is(CURVE_LINE))
|
|
(XCurveSegment&)cv2=GetSuCurve(cv1,pt3,pt4);
|
|
else
|
|
{
|
|
cv2.SetPoints(pt3,pt4);
|
|
if(cvTemp.StartPoint().Distance(pt3) > cvTemp.StartPoint().Distance(pt4))
|
|
cv2.Reverse();
|
|
}
|
|
cv3=iSide==0?cv2.Offset(-dChannelWidth,1):cv2.Offset(dChannelWidth,1);
|
|
AddToCurrentSpace((AcDbLine*)(cv1.AsAcDbCurve())->clone(),Adesk::kTrue);
|
|
AddToCurrentSpace((AcDbLine*)(cv3.AsAcDbCurve())->clone(),Adesk::kTrue);
|
|
iNumber=(int)(cv1.GetLength()/700);//求出默认的个数
|
|
CString strShow;
|
|
strShow.Format(_T("\n请输入水龙头的个数 <%i>:"),iNumber);
|
|
iRet=ads_getint(strShow,&iNumber);
|
|
if(iRet==RTNORM || iRet==RTNONE)
|
|
{
|
|
cv2=iSide==0?cv2.Offset(-nGap/2,1):cv2.Offset(nGap/2,1);
|
|
Array<XPointDir2d> arraypt;
|
|
arraypt=GetArrayPoint(cv2,iNumber,0,0);
|
|
for(long i=0;i<arraypt.GetLength();i++)
|
|
{
|
|
TDbBlockInsert *pInsert=(TDbBlockInsert*)pBlock->clone();
|
|
pInsert->setPosition(arraypt[i]);
|
|
if(iSide==0)
|
|
pInsert->setRotation(arraypt[i].nDirection+PI);
|
|
else if(iSide==1)
|
|
pInsert->setRotation(arraypt[i].nDirection);
|
|
AddToCurrentSpace(pInsert,true);
|
|
pInsert->close();
|
|
pInsert=NULL;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
else return 0;
|
|
//}
|
|
/*iRet=ads_getdist(Wcs2Ucs(ptstart),_T("\n请插入盥洗槽的终点 <结束>:"),&dDist2);
|
|
if(iRet==RTNORM)
|
|
{
|
|
if(ptPostion==cvTemp.endPoint)
|
|
{
|
|
cvTemp.Polar(cvTemp.Length()-dDist1-dDist2,ptend);
|
|
|
|
}
|
|
else if(ptPostion==cvTemp.startPoint)
|
|
{
|
|
cvTemp.Polar(dDist1+dDist2,ptend);
|
|
}
|
|
break;
|
|
}
|
|
else return 0;*/
|
|
}
|
|
else return 0;
|
|
}
|
|
/*TDrawFlatJig jig1(pPolyline,cvTemp);
|
|
jig1.SetPrompt(_T("\n请输入盥洗槽的宽度 <结束>:"));
|
|
jig1.m_ptFirst=ptstart;
|
|
jig1.m_ptSecond=ptend;
|
|
int iRet=jig1.doIt();
|
|
if(iRet==RTNORM)
|
|
{//
|
|
XDirectionCurve cv1,cv2,cv3;
|
|
XPointDir2d pt3,pt4;//用于保存在内测的segment
|
|
pPolyline=(AcDbPolyline*)jig1.entity();
|
|
AcDbPolyline *pPolylineInsert=(AcDbPolyline*)pPolyline->clone();
|
|
AcDbObjectId polyid=AddToCurrentSpace(pPolylineInsert,Adesk::kTrue);
|
|
Entity entTemp;
|
|
XPoly2D polyinside;
|
|
ads_name polyname;
|
|
acdbGetAdsName(polyname,polyid);
|
|
entTemp=Entity(polyname);
|
|
XPoly2D poly2d(entTemp);
|
|
poly2d.Compress(TRUE);
|
|
polyinside=poly2d;
|
|
BOOL bFalse;
|
|
if(iSide==0)bFalse=Offset(60,polyinside);
|
|
else bFalse=Offset(-60,polyinside);
|
|
AcDbCurve *pPolylineInside=(AcDbCurve*)polyinside.AsAcDbCurve()->clone();
|
|
AddToCurrentSpace(pPolylineInside,Adesk::kTrue);
|
|
double dChannel;//水槽的宽度
|
|
int iNumber;//水龙头的个数
|
|
iRet=ads_getdist(Wcs2Ucs(ptstart),_T("\n请输入水沟的宽度 <200>:"),&dChannel);
|
|
if(iRet==RTNONE)
|
|
dChannel=_AS_SYS_UNIT(200);
|
|
(XCurveSegment&)cv1=GetSuCurve(cvTemp,ptstart,ptend);
|
|
cv1.Polar(nGap,pt3);
|
|
cv1.Polar(cv1.Length()-nGap,pt4);
|
|
if(!cv1.Is(CURVE_LINE))
|
|
(XCurveSegment&)cv2=GetSuCurve(cv1,pt3,pt4);
|
|
else
|
|
{
|
|
cv2.SetPoints(pt3,pt4);
|
|
if(cvTemp.startPoint.Distance(pt3) > cvTemp.startPoint.Distance(pt4))
|
|
cv2.Reverse();
|
|
}
|
|
cv3=iSide==0?cv2.Offset(-dChannel,1):cv2.Offset(dChannel,1);
|
|
AddToCurrentSpace((AcDbLine*)(cv3.AsAcDbCurve())->clone(),Adesk::kTrue);
|
|
iNumber=(int)(cv1.Length()/700);//求出默认的个数
|
|
CString strShow;
|
|
strShow.Format(_T("\n请输入水龙头的个数 <%i>:"),iNumber);
|
|
iRet=ads_getint(strShow,&iNumber);
|
|
if(iRet==RTNORM || iRet==RTNONE)
|
|
{
|
|
cv2=iSide==0?cv2.Offset(-nGap/2,1):cv2.Offset(nGap/2,1);
|
|
Array<XPointDir2d> arraypt;
|
|
arraypt=GetArrayPoint(cv2,iNumber,0,0);
|
|
for(long i=0;i<arraypt.GetLength();i++)
|
|
{
|
|
TDbBlockInsert *pInsert=(TDbBlockInsert*)pBlock->clone();
|
|
pInsert->setPosition(arraypt[i]);
|
|
if(iSide==0)
|
|
pInsert->setRotation(arraypt[i].nDirection+PI);
|
|
else if(iSide==1)
|
|
pInsert->setRotation(arraypt[i].nDirection);
|
|
AddToCurrentSpace(pInsert,true);
|
|
pInsert->close();
|
|
pInsert=NULL;
|
|
}
|
|
}
|
|
|
|
}*/
|
|
}
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
//////////////////////////////////////////////////////////////////////////
|
|
//以下是对浴缸的处理操作
|
|
//对浴缸的操作分两布,在命令行下对浴缸的操作分为点插入和沿墙插入
|
|
int DrawSantitary2(CDecorateBathTubDlg &dlg, CSaniFittingAttr &data)
|
|
{
|
|
XString sBlockName(256);
|
|
XString sDwbName(256);
|
|
sDwbName<<g_sDwbPath<<_T("lvtry.DWB");
|
|
if(LoadDwbBlock(sDwbName, data.m_csBlockName, sBlockName)!=RTNORM)
|
|
return 0;
|
|
double sx=dlg.g_nWidth/data.m_dOrigenalSizeX, sy=dlg.g_nLength/data.m_dOrigenalSizeY;
|
|
TDbBlockInsert * pBlock=new TDbBlockInsert;
|
|
AcDbObjectId oID=InitBlock(sBlockName);
|
|
pBlock->setBlockTableRecord(oID);
|
|
pBlock->setScaleFactors(AcGeScale3d(sx, sy, 1.0));
|
|
XCurveSegment cvb;//基础的曲线
|
|
XCurveSegment cvTemp;//变化后的临时曲线
|
|
XPointDir2d ptPostion;
|
|
TDbWall *pWall=NULL;
|
|
// double dWallWidth;//墙的宽度
|
|
double dAng;//角度问题
|
|
// double dirction;//洁具的方向
|
|
int iRet;
|
|
int iSide;//方向问题
|
|
Entity ent;
|
|
RBList rmask;
|
|
// TCHAR retkey;
|
|
resbuf *rb=ads_buildlist(RTDXF0,_T("ATS_WALL,ARC,LINE"),0);
|
|
rmask.Append(rb);
|
|
while(1)
|
|
{
|
|
INITGET_BEG(0,_T("D Z"))//新加入处理洁具改变洁具的操作
|
|
iRet=SelectEntity1(_T("\n请选择布置洁具沿线位置 [点取方式布置(D)]:"),ent,ptPostion,rmask);
|
|
INITGET_END()
|
|
/*iRet=SelectEntity(_T("\n请选择布置洁具沿线位置 [点取方式布置(D)]:"),ent,ptPostion,rmask,_T("D"),retkey);*/
|
|
if(iRet==RTKWORD)
|
|
{
|
|
TCHAR buf[256];
|
|
acedGetInput(buf);
|
|
if(buf[0]==_T('Z'))
|
|
{//处理改变洁具
|
|
CTemporaryResourceOverride vTemp1;
|
|
CSanitaryDlg dlgChose(&dlg);
|
|
dlgChose.m_nOpenMode = 1;
|
|
|
|
dlgChose.SetCurrentItem(data, TRUE);
|
|
if(dlgChose.DoModal()==IDOK)
|
|
{
|
|
CSaniFittingAttr *pData=dlgChose.GetCurrentSelection();
|
|
data=*pData;
|
|
if(pData->m_nPlaceFlag==2)
|
|
{
|
|
LoadDwbBlock(sDwbName, data.m_csBlockName, sBlockName);
|
|
dlg.SetFromSaniWare(data);
|
|
dlg.UpdateData(FALSE);
|
|
dlg.UpdateSlide();
|
|
|
|
//modify by xlc on 090723 浴缸修改后无法插入当前显示的
|
|
oID=InitBlock(sBlockName);
|
|
pBlock->setBlockTableRecord(oID);
|
|
sx=dlg.g_nWidth/data.m_dOrigenalSizeX;
|
|
sy=dlg.g_nLength/data.m_dOrigenalSizeY;
|
|
pBlock->setScaleFactors(AcGeScale3d(sx,sy,1.0));
|
|
|
|
continue;
|
|
}
|
|
else if(pData->m_nPlaceFlag==1)
|
|
{
|
|
dlg.DestroyWindow();
|
|
CWnd *pWnd=acedGetAcadFrame();
|
|
CDecorateSaniFittingDlg *dlg1=new CDecorateSaniFittingDlg(pWnd);
|
|
dlg1->SetFromSaniWare(data);
|
|
dlg1->Create(dlg1->IDD,pWnd);
|
|
DrawSantitary(*dlg1,data);
|
|
dlg1->DestroyWindow();
|
|
break;
|
|
|
|
}
|
|
else
|
|
{
|
|
continue;
|
|
}
|
|
}
|
|
else
|
|
{ //取消换取设备
|
|
continue;
|
|
}
|
|
}
|
|
TSanitaryJig jig(pBlock,&dlg,data);
|
|
while(1)
|
|
{
|
|
jig.SetPrompt(_T("\n点取位置或 [转90度(A)/左右翻(S)/上下翻(D)/对齐(F)/改转角(R)/改基点(T)/参考点(Q)]<退出>:"));
|
|
jig.SetKeyword(_T("A S D F R T Q Z"));
|
|
int nRet=jig.doIt();
|
|
if(nRet ==RTNORM)
|
|
{
|
|
pBlock=(TDbBlockInsert*)jig.entity();
|
|
TDbBlockInsert *pIns=(TDbBlockInsert*)pBlock->clone();
|
|
{//判断此处是不是已经有洁具了
|
|
XPoint pLow(0,0,0),pTop(0,0,0);
|
|
pIns->GetExtents2d(pLow,pTop);
|
|
PickSet ss(SS_FREE);
|
|
RBList rbMask;
|
|
resbuf * rLayer=ads_buildlist(8,_T("LVTRY"),NULL);
|
|
rbMask.Append(rLayer);
|
|
int rt=ss.Get(_T("C"),Wcs2Ucs(pLow),Wcs2Ucs(pTop),rbMask);
|
|
if(rt==RTNORM)
|
|
{
|
|
delete pIns;
|
|
acutPrintf(_T("\n当前位置已有洁具!"));
|
|
}
|
|
else
|
|
{
|
|
AddToCurrentSpace(pIns,Adesk::kTrue);
|
|
pIns->close();
|
|
}
|
|
}
|
|
TArchCmdReactor::UpdateCorners();
|
|
TArchCmdReactor::ResetAll();
|
|
}
|
|
else if(nRet ==RTKWORD)
|
|
{//处理jig中返回关键字的情况
|
|
ads_printf(_T("%c%c%c"), 8,8,8);
|
|
switch(jig.m_nRetCode)
|
|
{
|
|
case 1:
|
|
{//转90度
|
|
jig.m_RotAngle+=PI/2;
|
|
AcGeMatrix3d mat3;
|
|
XVector3D xv(0,0,1);
|
|
XPoint PointTemp=jig.m_pInsertPoint+jig.m_pOffset;
|
|
mat3.setToRotation(PI/2,xv.AsAcGeVector3d(),PointTemp.AsAcGePoint3d());
|
|
jig.m_pInsertPoint.TransformBy(mat3);
|
|
jig.m_pOffset=PointTemp-jig.m_pInsertPoint;
|
|
jig.m_mat=mat3;
|
|
break;
|
|
}
|
|
case 2:
|
|
{//左右翻转
|
|
XPoint CurrentPoint=jig.m_pInsertPoint+jig.m_pOffset;//获取当前的鼠标点
|
|
AcGePoint2d pt(Wcs2Ucs(CurrentPoint).AsAcGePoint2d());
|
|
XVector3D xv(0,1,0);
|
|
AcGeLine2d geline2d(pt,xv.AsAcGeVector2d());
|
|
AcGePoint2d PointTemp=Wcs2Ucs(jig.m_pInsertPoint);
|
|
PointTemp=PointTemp.mirror(geline2d);
|
|
jig.m_pOffset=CurrentPoint-Ucs2Wcs(PointTemp);
|
|
jig.m_RotAngle*=-1;
|
|
break;
|
|
}
|
|
case 3:
|
|
{//上下翻转
|
|
XPoint CurrentPoint=jig.m_pInsertPoint+jig.m_pOffset;//获取当前的鼠标点
|
|
AcGePoint2d pt(Wcs2Ucs(CurrentPoint).AsAcGePoint2d());
|
|
XVector3D xv(1,0,0);
|
|
AcGeLine2d geline2d(pt,xv.AsAcGeVector2d());
|
|
AcGePoint2d PointTemp=Wcs2Ucs(jig.m_pInsertPoint);
|
|
PointTemp=PointTemp.mirror(geline2d);
|
|
jig.m_pOffset=CurrentPoint-Ucs2Wcs(PointTemp);
|
|
jig.m_RotAngle=PI-jig.m_RotAngle;
|
|
break;
|
|
}
|
|
case 4:
|
|
{//对齐
|
|
int nOsMode=0;
|
|
xg_getvar(_T("OSMODE"), &nOsMode);
|
|
nOsMode &= ~0x4000;
|
|
nOsMode&=~OS_NOD&~OS_END &~OS_MID&~OS_CEN&~OS_NOD&~OS_QUA&~OS_INT&~OS_INS&~OS_PER&~OS_TAN&~OS_NEA&~OS_QUI&~OS_APP;
|
|
nOsMode |= OS_INT|OS_NEA|OS_PER|OS_END|OS_MID|OS_CEN;
|
|
XPushVar<int> vOsMode(_T("OSMODE"), nOsMode);
|
|
|
|
TDbBlockInsert *pTempEnt=(TDbBlockInsert *)pBlock->clone();
|
|
AcDbObjectId idTemp=AddToCurrentSpace(pTempEnt, Adesk::kTrue);
|
|
|
|
XPoint pt1, pt2, qt1, qt2;
|
|
if(ads_getpoint(NULL, _T("\n对齐参考点:"), pt1)==RTNORM &&
|
|
ads_getpoint(pt1, _T("\n对齐参考轴:"), pt2)==RTNORM &&
|
|
ads_getpoint(NULL, _T("\n对齐目标点:"), qt1)==RTNORM &&
|
|
ads_getpoint(qt1, _T("\n对齐目标轴:"), qt2)==RTNORM)
|
|
{
|
|
pt1=Ucs2Wcs(pt1);
|
|
pt2=Ucs2Wcs(pt2);
|
|
qt1=Ucs2Wcs(qt1);
|
|
qt2=Ucs2Wcs(qt2);
|
|
|
|
double nRot=CT_std_angle(ads_angle(qt1, qt2)-ads_angle(pt1, pt2));
|
|
ads_matrix matMov, matRot;
|
|
pt1.GetMoveMatrix(qt1, matMov);
|
|
qt1.GetRotationMatrix(nRot, matRot);
|
|
|
|
OPENOBJ_BEGIN(idTemp, AcDb::kForWrite, AcDbEntity, pEnt);
|
|
if(pEnt)
|
|
{
|
|
pEnt->transformBy(AsAcGeMatrix3d(matMov));
|
|
pEnt->transformBy(AsAcGeMatrix3d(matRot));
|
|
}
|
|
|
|
TDbBlockInsert *pNew = (TDbBlockInsert *)pEnt->clone();
|
|
XPoint pLow,pTop;
|
|
pTempEnt->GetExtents2d(pLow,pTop);
|
|
PickSet ss(SS_FREE);
|
|
RBList rbMask;
|
|
resbuf * rLayer=ads_buildlist(8,_T("LVTRY"),NULL);
|
|
rbMask.Append(rLayer);
|
|
int rt=ss.Get(_T("C"),pLow,pTop,rbMask);
|
|
if(rt==RTNORM)
|
|
{
|
|
delete pTempEnt;
|
|
acutPrintf(_T("\n当前位置已有洁具!"));
|
|
}
|
|
else
|
|
{
|
|
AddToCurrentSpace(pTempEnt,Adesk::kTrue);
|
|
pTempEnt->close();
|
|
}
|
|
OPENOBJ_END();
|
|
|
|
}
|
|
break;
|
|
}
|
|
case 5:
|
|
{//改转角
|
|
////确定为改转角
|
|
//确定为改转角
|
|
pBlock=(TDbBlockInsert*)jig.entity();
|
|
|
|
//modify by xlc on 090722 低平台高亮显示崩溃
|
|
//TDbBlockInsert *pIns=(TDbBlockInsert*)pBlock->clone();
|
|
//AcDbObjectId idTemp=AddToCurrentSpace(pIns,Adesk::kTrue);
|
|
//OPENOBJ_BEGIN(idTemp, AcDb::kForWrite, AcDbEntity, pEnt);
|
|
//pEnt->highlight(kNullSubent,true);
|
|
|
|
TSanitaryJig jig1(pBlock,&dlg,data);
|
|
jig1.m_bRot=TRUE;
|
|
jig1.m_ptPoint=(jig.m_ptPoint);
|
|
jig1.m_RotAngle = jig.m_RotAngle;
|
|
jig1.m_dRotateAngle = jig.m_dRotateAngle;
|
|
jig1.m_pInsertPoint = jig.m_pInsertPoint;
|
|
jig1.SetPrompt(_T("\n请输入旋转的角度:"));
|
|
int rt=jig1.doIt();
|
|
if(rt==RTNORM)
|
|
{
|
|
AcGePoint3d ptInsert=jig1.m_pInsertPoint.AsAcGePoint3d();
|
|
ptInsert.rotateBy(jig1.m_dRotateAngle,AcGeVector3d::kZAxis,jig1.m_ptPoint.AsAcGePoint3d());
|
|
jig.m_pOffset.x = jig1.m_ptPoint.x - ptInsert.x;
|
|
jig.m_pOffset.y = jig1.m_ptPoint.y - ptInsert.y;
|
|
jig1.m_RotAngle += jig1.m_dRotateAngle;
|
|
jig.m_RotAngle=jig1.m_RotAngle;
|
|
jig.m_dRotateAngle = jig1.m_dRotateAngle;
|
|
jig.m_pInsertPoint = jig.m_ptPoint-jig.m_pOffset;
|
|
}
|
|
//if(pEnt) pEnt->erase();
|
|
//OPENOBJ_END();
|
|
break;
|
|
}
|
|
case 6:
|
|
{//改基点
|
|
pBlock=(TDbBlockInsert*)jig.entity();
|
|
TDbBlockInsert *pIns=(TDbBlockInsert*)pBlock->clone();
|
|
AcDbObjectId idTemp=AddToCurrentSpace(pIns,Adesk::kTrue);
|
|
XPoint pt;
|
|
int rt=XGetPoint(NULL, _T("\n输入插入点"),pt);
|
|
if(rt==RTNORM)
|
|
{
|
|
pt=Ucs2Wcs(pt);
|
|
jig.m_pOffset=pt-jig.m_pInsertPoint;
|
|
dlg.UpdateData(FALSE);
|
|
}
|
|
|
|
OPENOBJ_BEGIN(idTemp, AcDb::kForWrite, AcDbEntity, pEnt);
|
|
if(pEnt) pEnt->erase();
|
|
OPENOBJ_END();
|
|
break;
|
|
}
|
|
case 7:
|
|
{//选定参考点
|
|
int nOsMode=0;
|
|
xg_getvar(_T("OSMODE"), &nOsMode);
|
|
nOsMode &= ~0x4000;
|
|
nOsMode&=~OS_NOD&~OS_END &~OS_MID&~OS_CEN&~OS_NOD&~OS_QUA&~OS_INT&~OS_INS&~OS_PER&~OS_TAN&~OS_NEA&~OS_QUI&~OS_APP;
|
|
nOsMode |= OS_INT|OS_NEA|OS_PER|OS_END|OS_MID|OS_CEN;
|
|
XPushVar<int> vOsMode(_T("OSMODE"), nOsMode);
|
|
XPoint xtemp;
|
|
XPoint xInsert;
|
|
ads_getpoint(NULL,_T("\n请选取参考点:"),xtemp);
|
|
ads_getpoint(xtemp,_T("\n请输入插入点:"),xInsert);
|
|
TDbBlockInsert *pInsertBlock=(TDbBlockInsert*)pBlock->clone();
|
|
|
|
//改基点后参考插入点按原来基点插入 modify by xlc on 090723
|
|
//pTempEnt->setPosition(Ucs2Wcs(xInsert));
|
|
XPoint ptLoc=Ucs2Wcs(xInsert)-jig.m_pOffset;
|
|
pInsertBlock->setPosition(ptLoc);
|
|
|
|
pInsertBlock->setScaleFactors(AcGeScale3d(sx, sy, 1.0));
|
|
AddToCurrentSpace(pInsertBlock,Adesk::kTrue);
|
|
pInsertBlock->close();
|
|
break;
|
|
}
|
|
case 8:
|
|
{
|
|
CTemporaryResourceOverride vTemp1;
|
|
CSanitaryDlg dlgChose(&dlg);
|
|
dlgChose.m_nOpenMode = 1;
|
|
|
|
dlgChose.SetCurrentItem(data, TRUE);
|
|
if(dlgChose.DoModal()==IDOK)
|
|
{
|
|
CSaniFittingAttr *pData=dlgChose.GetCurrentSelection();
|
|
data=*pData;
|
|
if(pData->m_nPlaceFlag==2)
|
|
{
|
|
LoadDwbBlock(sDwbName, data.m_csBlockName, sBlockName);
|
|
dlg.SetFromSaniWare(data);
|
|
dlg.UpdateData(FALSE);
|
|
dlg.UpdateSlide();
|
|
continue;
|
|
}
|
|
else if(pData->m_nPlaceFlag==1)
|
|
{
|
|
dlg.DestroyWindow();
|
|
CWnd *pWnd=acedGetAcadFrame();
|
|
CDecorateSaniFittingDlg *dlg1=new CDecorateSaniFittingDlg(pWnd);
|
|
dlg1->SetFromSaniWare(data);
|
|
dlg1->Create(dlg1->IDD,pWnd);
|
|
DrawSantitary(*dlg1,data);
|
|
break;
|
|
|
|
}
|
|
else
|
|
{
|
|
continue;
|
|
}
|
|
}
|
|
else
|
|
{ //取消换取设备
|
|
continue;
|
|
}
|
|
}
|
|
break;
|
|
}//end switch
|
|
}
|
|
else
|
|
{
|
|
break;
|
|
|
|
}//end if
|
|
}
|
|
}
|
|
else if(iRet==RTNORM)
|
|
{
|
|
|
|
OPENOBJ_BEGIN(ent,AcDb::kForRead,AcDbEntity,pEnt)
|
|
XCurveSegment cvWallleft,cvWallright;
|
|
pWall=TDbWall::cast(pEnt);
|
|
cvb=pWall!=NULL?pWall->OffsetGeomCenter():XCurveSegment(ent,LS_INFINITE);
|
|
if(pWall!=NULL)
|
|
{
|
|
pWall->GetSideCurve(cvWallleft,cvWallright);
|
|
iSide=cvb.OnWhichSide(Ucs2Wcs(ptPostion));
|
|
cvTemp=iSide==0?cvWallleft:cvWallright;
|
|
dAng=iSide==0?cvTemp.Direction(Ucs2Wcs(ptPostion))+PI:cvTemp.Direction(Ucs2Wcs(ptPostion));
|
|
}
|
|
else
|
|
{
|
|
cvTemp=cvb;
|
|
XPoint ptTemp;
|
|
int rt=ads_getpoint(NULL,_T("\n选择插入方向:"),ptTemp);
|
|
if(rt==RTNORM)
|
|
{
|
|
iSide=cvTemp.OnWhichSide(Ucs2Wcs(ptTemp));
|
|
dAng=iSide==0?cvTemp.Direction(Ucs2Wcs(ptPostion))+PI:cvTemp.Direction(Ucs2Wcs(ptPostion));
|
|
}
|
|
else
|
|
break;
|
|
}
|
|
TDbBlockInsert *pInsertBlock=(TDbBlockInsert*)pBlock->clone();
|
|
dlg.UpdateData(TRUE);
|
|
sx=dlg.g_nWidth/data.m_dOrigenalSizeX, sy=dlg.g_nLength/data.m_dOrigenalSizeY;
|
|
pInsertBlock->setRotation(dAng);
|
|
pInsertBlock->setPosition(Ucs2Wcs(ptPostion));
|
|
pInsertBlock->setScaleFactors(AcGeScale3d(sx, sy, 1.0));
|
|
AddToCurrentSpace(pInsertBlock,Adesk::kTrue);
|
|
pInsertBlock->close();
|
|
OPENOBJ_END()
|
|
}
|
|
else
|
|
{
|
|
|
|
dlg.DestroyWindow();//新加入~
|
|
break;
|
|
}
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
//////////////////////////////////////////////////////////////////////////
|
|
//台式洗脸盆的平台拖动函数
|
|
int DrawFlat(const XDirectionCurve &cvTemp)
|
|
{
|
|
AcDbPolyline * pPolyline=new AcDbPolyline;
|
|
TDrawFlatJig jig1(pPolyline,cvTemp);
|
|
XPointDir2d pt1,pt2;
|
|
while(1)
|
|
{
|
|
//以下实现对象捕捉
|
|
//----------------------
|
|
int nOsMode=0;
|
|
xg_getvar(_T("OSMODE"), &nOsMode);
|
|
nOsMode &= ~0x4000;
|
|
nOsMode&=~OS_NOD&~OS_END &~OS_MID&~OS_CEN&~OS_NOD&~OS_QUA&~OS_INT&~OS_INS&~OS_PER&~OS_TAN&~OS_NEA&~OS_QUI&~OS_APP;
|
|
nOsMode |=OS_NEA | OS_INT|OS_END;
|
|
XPushVar<int> vOsMode(_T("OSMODE"), nOsMode);
|
|
//-----------------------
|
|
int iRet=ads_getpoint(NULL,_T("\n请输入平台的起点:"),pt1);
|
|
if(iRet==RTNORM)
|
|
{
|
|
int iRt=ads_getpoint(NULL,_T("\n请输入平台的终点:"),pt2);
|
|
if(iRt==RTNORM)
|
|
{
|
|
//允许选中端点 modify by xlc on 090723
|
|
//if(cvTemp.HitTest2d(Ucs2Wcs(pt1))<5 ||cvTemp.HitTest2d(Ucs2Wcs(pt2))<5)
|
|
if(cvTemp.HitTest2d(Ucs2Wcs(pt1))<3 ||cvTemp.HitTest2d(Ucs2Wcs(pt2))<3)
|
|
acutPrintf(_T("\n请点取平台相邻的墙线上的点:"));
|
|
else
|
|
{
|
|
jig1.m_ptFirst=(XPointDir2d &)Ucs2Wcs(pt1);
|
|
jig1.m_ptSecond=(XPointDir2d &)Ucs2Wcs(pt2);
|
|
break;
|
|
}
|
|
}
|
|
else return 0;
|
|
}
|
|
else return 0;
|
|
}
|
|
jig1.SetPrompt(_T("\n请输入平台的宽度:"));
|
|
int iRet=jig1.doIt();
|
|
if(iRet==RTNORM)
|
|
{
|
|
pPolyline=(AcDbPolyline*)jig1.entity();
|
|
AcDbPolyline *pPolylineInsert=(AcDbPolyline*)pPolyline->clone();
|
|
AddToCurrentSpace(pPolylineInsert,Adesk::kTrue);
|
|
pPolylineInsert->close();
|
|
pPolylineInsert=NULL;
|
|
|
|
}
|
|
return 0;
|
|
}
|
|
//////////////////////////////////////////////////////////////////////////
|
|
XCurveSegment GetSuCurve(const XCurveSegment & cvTemp,XPointDir2d ptstart,XPointDir2d ptend)
|
|
{
|
|
XCurveSegment cv1;
|
|
double dDist;
|
|
if(cvTemp.Is(CURVE_LINE))
|
|
{
|
|
cv1.SetPoints(ptstart,ptend);
|
|
return cv1;
|
|
}
|
|
if(!cvTemp.Is(CURVE_LINE))
|
|
{
|
|
double angle1,angle2,angle3;
|
|
XArc arc=cvTemp.GetArc();
|
|
angle1=ads_angle(ptstart,arc.GetCenterPt());
|
|
angle2=ads_angle(ptend,arc.GetCenterPt());
|
|
angle3=ads_angle(cvTemp.StartPoint(),arc.GetCenterPt());
|
|
angle1-=angle3;
|
|
angle2-=angle3;
|
|
if(CT_std_angle(angle1)>CT_std_angle(angle2))
|
|
{
|
|
XPointDir2d pt=ptstart;
|
|
ptstart=ptend;
|
|
ptend=pt;
|
|
}
|
|
}
|
|
XArc arc1=cvTemp.GetArc(), arc;
|
|
XPoint ptCenter=arc1.GetCenterPt();//获取中心点
|
|
XCurveSegment xcv(ptCenter,ptend,LS_INFINITE);
|
|
XPoint ptMid;
|
|
XLine lineTemp=XLine(ptstart,ptend);
|
|
ptMid = lineTemp.MidPoint();
|
|
XPoint ptMidSave=ptMid;//保留的原始的线上的终点
|
|
XLine linetemp2(ptMid,ptCenter);
|
|
XPoint pt3,pt4;
|
|
arc1.Intersection(&linetemp2,pt3,pt4);
|
|
cvTemp.ProjectToMe(ptMid,ptMid);
|
|
ptMid=pt4==XPoint(0,0,0)?pt3:pt4;
|
|
dDist=ptstart.Distance(ptend);
|
|
|
|
if(cvTemp.GetLineFlag()==LS_INFINITE)
|
|
XCircle(arc1.GetCenterPt(), arc1.GetRadius()).GetSubArc(ptMid, dDist, arc);
|
|
else
|
|
arc1.GetSubArc(ptMid, dDist, arc);
|
|
XPoint pt1,pt2;
|
|
//arc.GetPoints(pt1,pt2);
|
|
arc.GetStartPoint(pt1);
|
|
arc.GetEndPoint(pt2);
|
|
cv1.StartPoint()=ptstart;
|
|
cv1.EndPoint()=ptend;
|
|
if(ptMidSave.Distance(ptMid)>arc.GetRadius())
|
|
cv1.SetBulge(2*PI-arc.Bulge());
|
|
else cv1.SetBulge(arc.Bulge());
|
|
|
|
return cv1;
|
|
|
|
}
|
|
XDirectionCurve GetSubDirCurve(const XDirectionCurve &cvTemp,XPointDir2d ptstart,XPointDir2d ptend)
|
|
{
|
|
XDirectionCurve cv1;
|
|
double dDist;
|
|
if(cvTemp.Is(CURVE_LINE))
|
|
{
|
|
cv1.SetPoints(ptstart,ptend);
|
|
return cv1;
|
|
}
|
|
if(!cvTemp.Is(CURVE_LINE))
|
|
{
|
|
double angle1,angle2,angle3;
|
|
XArc arc=cvTemp.GetArc();
|
|
angle1=ads_angle(ptstart,arc.GetCenterPt());
|
|
angle2=ads_angle(ptend,arc.GetCenterPt());
|
|
angle3=ads_angle(cvTemp.StartPoint(),arc.GetCenterPt());
|
|
/*angle1=CT_std_angle(angle1)-CT_std_angle(angle3);
|
|
angle2=CT_std_angle(angle2)-CT_std_angle(angle3);*/
|
|
angle1-=angle3;
|
|
angle2-=angle3;
|
|
if(CT_std_angle(angle1)>CT_std_angle(angle2))
|
|
{
|
|
XPointDir2d pt=ptstart;
|
|
ptstart=ptend;
|
|
ptend=pt;
|
|
}
|
|
if(angle1>angle2)
|
|
{
|
|
XPointDir2d pt=ptstart;
|
|
ptstart=ptend;
|
|
ptend=pt;
|
|
}
|
|
}
|
|
XArc arc1=cvTemp.GetArc(), arc;
|
|
XPoint ptCenter=arc1.GetCenterPt();//获取中心点
|
|
XDirectionCurve xcv(ptCenter,ptend,LS_INFINITE);
|
|
XPointDir2d ptMid;
|
|
XPoint ptTemp;
|
|
XLine lineTemp=XLine(ptstart,ptend);
|
|
//lineTemp.MidPoint(ptMid); zyu modify on 100315
|
|
ptTemp = lineTemp.MidPoint();
|
|
ptMid.x = ptTemp.x;
|
|
ptMid.y = ptTemp.y;
|
|
|
|
XPointDir2d ptMidSave=ptMid;//保留的原始的线上的终点
|
|
XLine linetemp2(ptMid,ptCenter);
|
|
XPointDir2d pt3,pt4;
|
|
arc1.Intersection(&linetemp2,pt3,pt4);
|
|
cvTemp.ProjectToMe(ptMid,ptMid);
|
|
ptMid=pt4==XPoint(0,0,0)?pt3:pt4;
|
|
dDist=ptstart.Distance(ptend);
|
|
|
|
if(cvTemp.GetLineFlag()==LS_INFINITE)
|
|
XCircle(arc1.GetCenterPt(), arc1.GetRadius()).GetSubArc(ptMid, dDist, arc);
|
|
else
|
|
arc1.GetSubArc(ptMid, dDist, arc);
|
|
XPointDir2d pt1,pt2;
|
|
//arc.GetPoints(pt1,pt2);
|
|
arc.GetStartPoint(pt1);
|
|
arc.GetEndPoint(pt2);
|
|
cv1.StartPoint()=ptstart;
|
|
cv1.EndPoint()=ptend;
|
|
if(ptMidSave.Distance(ptMid)>arc.GetRadius())
|
|
cv1.SetBulge(2*PI-arc.Bulge());
|
|
else cv1.SetBulge(arc.Bulge());
|
|
|
|
return cv1;
|
|
}
|
|
inline double GetChordHeight(double dRadius,double chordLength)
|
|
{//得到弦高,得到的是小弧的高度
|
|
return dRadius - sqrt(dRadius*dRadius-(chordLength/2)*(chordLength/2));
|
|
}
|
|
inline double GetArcLen(double chordLength,double dRadius)
|
|
{//由弦长得到弧长,得到的小弧的长度
|
|
ASSERT(chordLength!=0 && dRadius!=0);
|
|
double ArcAngle=2*asin((chordLength/2)/dRadius);
|
|
return ArcAngle*dRadius;
|
|
}
|
|
Array<XPointDir2d> _cdecl GetArrayPoint(const XDirectionCurve &cv,UINT nPart,int dDisToWall,double WidthofWall=0.0)
|
|
//参数说明:nPart分成的份数,dDistToWall离墙的距离
|
|
{
|
|
Array<XPointDir2d> arrayY;
|
|
XDirectionCurve cvTemp;
|
|
UINT NumsubSection=nPart*2;
|
|
arrayY.Realloc(nPart,true);
|
|
cvTemp=cv.Offset(dDisToWall,1);
|
|
double cvLength=cvTemp.GetLength();
|
|
double perLength=cvLength/NumsubSection;
|
|
for(int i=0;i<arrayY.GetLength();i++)
|
|
{
|
|
XPointDir2d pointTemp;
|
|
cvTemp.Polar((2*i+1)*perLength,pointTemp,true);
|
|
arrayY[i]=pointTemp;
|
|
}
|
|
return arrayY;
|
|
}
|
|
inline UINT GetMaxInsert(double WidthSan,const XDirectionCurve & cv)
|
|
{//返回最多能插入的洁具数目,只适合于直线的情况
|
|
UINT number=0;
|
|
number=(UINT)(cv.GetLength()/WidthSan);
|
|
return number;
|
|
}
|
|
UINT GetMaxInsert(double WidthSan,const XDirectionCurve &cv,const double &DistToWall,const int &SanWidth,BOOL bDirction)
|
|
{//返回最多能插入的洁具数目,适应于求圆弧或是圆的情况,bDirction为标记方向,当在弧右测的时候为TRUE,为左侧的时候为FALSE
|
|
UINT number=0;
|
|
XDirectionCurve cvTemp;
|
|
XArc xarc=cv.GetArc();
|
|
if(bDirction)
|
|
{
|
|
double ChordHeight=GetChordHeight(xarc.GetRadius(),WidthSan);
|
|
if(ChordHeight>=fabs(DistToWall))
|
|
{
|
|
cvTemp=cv.Offset(-ChordHeight-SanWidth,1);
|
|
}
|
|
else
|
|
{
|
|
cvTemp=cv.Offset(DistToWall-SanWidth,1);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
cvTemp=cv.Offset(DistToWall,1);
|
|
}
|
|
|
|
if(!cv.Is(CURVE_LINE))
|
|
{
|
|
xarc=cvTemp.GetArc();
|
|
number=(UINT)(cvTemp.GetLength()/GetArcLen(WidthSan,xarc.GetRadius()));
|
|
}
|
|
else
|
|
number=(UINT)(cvTemp.GetLength()/WidthSan);
|
|
return number;
|
|
|
|
}
|
|
|
|
void DrawPlatNew(XPointDir2d insertPoint//洁具的插入点用于判断洁具布置与墙的法线方向
|
|
,const XDirectionCurve &cvTemp,//布置洁具的墙体曲线
|
|
BOOL bRever,//曲线是否反向
|
|
double dPlatLength,//平台初始长度
|
|
double dPlatWidth//平台初始宽度
|
|
)
|
|
{
|
|
/*double dle1,dle2;*/
|
|
if(cvTemp.Is(CURVE_ARC) || cvTemp.Is(CURVE_CIRCLE))
|
|
{
|
|
double dInitPlatLength=dPlatLength;
|
|
if(XGetDist(Wcs2Ucs(cvTemp.StartPoint()), _T("\n台面宽度"), dPlatWidth, RSG_NONEG)==RTCAN)
|
|
return ;
|
|
if(XGetDist(Wcs2Ucs(cvTemp.StartPoint()), _T("\n台面弧长"), dPlatLength, RSG_NONEG)==RTCAN)
|
|
return ;
|
|
XPointDir2d ptTemp4;
|
|
XCurveSegment cv1,cv2,cv3,cv4;
|
|
//XPoint ;
|
|
XPointDir2d ptFirst,ptSecond;
|
|
if (dPlatLength<dInitPlatLength)
|
|
{ //对中布置
|
|
cvTemp.Polar((dInitPlatLength-dPlatLength)/2.0,ptFirst,TRUE);
|
|
cvTemp.Polar((dInitPlatLength+dPlatLength)/2.0,ptSecond,TRUE);
|
|
}
|
|
else
|
|
{
|
|
cvTemp.Polar(0,ptFirst,TRUE);
|
|
cvTemp.Polar(dPlatLength,ptSecond,TRUE);
|
|
}
|
|
XArc arc1=cvTemp.GetArc(), arc;
|
|
XPoint ptCenter=arc1.GetCenterPt();//获取中心点
|
|
XCurveSegment xcv(ptCenter,ptSecond,LS_INFINITE);
|
|
XPoint ptMid;
|
|
XLine lineTemp=XLine(ptFirst,ptSecond);//
|
|
ptMid = lineTemp.MidPoint();
|
|
XPoint ptMidSave=ptMid;//保留的原始的线上的终点
|
|
XLine linetemp2(ptMid,ptCenter);
|
|
XPoint pt3,pt4;
|
|
arc1.Intersection(&linetemp2,pt3,pt4);
|
|
cvTemp.ProjectToMe(ptMid,ptMid);
|
|
ptMid=pt4==XPoint(0,0,0)?pt3:pt4;
|
|
// int rc;
|
|
if(cvTemp.GetLineFlag()==LS_INFINITE)
|
|
XCircle(arc1.GetCenterPt(), arc1.GetRadius()).GetSubArc(ptMid, dPlatLength, arc);
|
|
else
|
|
arc1.GetSubArc(ptMid, dPlatLength, arc);
|
|
XPoint pt1,pt2;
|
|
//arc.GetPoints(pt1,pt2);
|
|
arc.GetStartPoint(pt1);
|
|
arc.GetEndPoint(pt2);
|
|
if (bRever)
|
|
{
|
|
cv1.StartPoint()=ptSecond;
|
|
cv1.EndPoint()=ptFirst;
|
|
}
|
|
else
|
|
{
|
|
cv1.StartPoint()=ptFirst;
|
|
cv1.EndPoint()=ptSecond;
|
|
}
|
|
cv1.SetBulge(arc.Bulge());//原始算法
|
|
if(cvTemp.OnWhichSide(insertPoint))
|
|
{
|
|
if (bRever)
|
|
{
|
|
cv2=cv1.Offset(-dPlatWidth,1);
|
|
}
|
|
else
|
|
{
|
|
cv2=cv1.Offset(dPlatWidth,1);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (bRever)
|
|
{
|
|
cv2=cv1.Offset(dPlatWidth,1);
|
|
}
|
|
else
|
|
{
|
|
cv2=cv1.Offset(-dPlatWidth,1);
|
|
}
|
|
}
|
|
XPointDir2d ptTemp1,ptTemp2;
|
|
if (bRever)
|
|
{
|
|
cv2.ProjectToMe(ptSecond,ptTemp1);
|
|
cv2.ProjectToMe(ptFirst,ptTemp2);//为输入等值所用
|
|
cv3.SetPoints(ptSecond,ptTemp1);
|
|
cv4.SetPoints(ptTemp2,ptFirst);
|
|
}
|
|
else
|
|
{
|
|
cv2.ProjectToMe(ptFirst,ptTemp1);
|
|
cv2.ProjectToMe(ptSecond,ptTemp2);//为输入等值所用
|
|
cv3.SetPoints(ptFirst,ptTemp1);
|
|
cv4.SetPoints(ptTemp2,ptSecond);
|
|
}
|
|
XPoly2D rect;
|
|
rect.Reset();
|
|
rect.AppendSegment(cv1,1,0);
|
|
rect.AppendSegment(cv3);
|
|
rect.AppendSegment(cv2,0,0);
|
|
rect.AppendSegment(cv4,0,1);
|
|
rect.Compress(FALSE);
|
|
XWcsStream dc;
|
|
dc << rect;
|
|
}
|
|
else
|
|
{
|
|
double dInitPlatLength=dPlatLength;
|
|
XPoint ptMid;
|
|
ads_polar(cvTemp.StartPoint(),insertPoint.nDirection, dPlatLength/2.0, ptMid);
|
|
if(XGetDist(Wcs2Ucs(cvTemp.StartPoint()), _T("\n台面宽度"), dPlatWidth, RSG_NONEG)==RTCAN)
|
|
return ;
|
|
if(XGetDist(Wcs2Ucs(cvTemp.StartPoint()), _T("\n台面长度"), dPlatLength, RSG_NONEG)==RTCAN)
|
|
return ;
|
|
XPointDir2d pt1, pt2, pt3, pt4;
|
|
|
|
if(dPlatLength<dInitPlatLength)
|
|
{ //对中布置
|
|
cvTemp.Polar((dInitPlatLength-dPlatLength)/2.0,pt1,TRUE);
|
|
cvTemp.Polar((dInitPlatLength+dPlatLength)/2.0,pt2,TRUE);
|
|
}
|
|
else
|
|
{
|
|
cvTemp.Polar(0,pt1,TRUE);
|
|
cvTemp.Polar(dPlatLength,pt2,TRUE);
|
|
}
|
|
if(cvTemp.OnWhichSide(insertPoint))
|
|
{
|
|
if (bRever)
|
|
{
|
|
//cv2=cv1.Offset(-dPlatWidth,1);
|
|
ads_polar(pt2, pt2.nDirection-PI/2, dPlatWidth, pt3);
|
|
ads_polar(pt1, pt1.nDirection-PI/2, dPlatWidth, pt4);
|
|
}
|
|
else
|
|
{
|
|
//cv2=cv1.Offset(dPlatWidth,1);
|
|
ads_polar(pt2, pt2.nDirection-PI/2, dPlatWidth, pt3);
|
|
ads_polar(pt1, pt1.nDirection-PI/2, dPlatWidth, pt4);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (bRever)
|
|
{
|
|
//cv2=cv1.Offset(dPlatWidth,1);
|
|
ads_polar(pt2, pt2.nDirection+PI/2, dPlatWidth, pt3);
|
|
ads_polar(pt1, pt1.nDirection+PI/2, dPlatWidth, pt4);
|
|
}
|
|
else
|
|
{
|
|
//cv2=cv1.Offset(-dPlatWidth,1);
|
|
ads_polar(pt2, pt2.nDirection+PI/2, dPlatWidth, pt3);
|
|
ads_polar(pt1, pt1.nDirection+PI/2, dPlatWidth, pt4);
|
|
}
|
|
}
|
|
XPoly2D rect(1);
|
|
rect.AppendNode(pt1);
|
|
rect.AppendNode(pt2);
|
|
rect.AppendNode(pt3);
|
|
rect.AppendNode(pt4);
|
|
XWcsStream dc;
|
|
dc << rect;
|
|
}
|
|
}
|
|
//---------------------------------------------------------------end-------------------------------------------------------------------
|