// PumpBaseDlg.cpp : implementation file // #include "stdafx.h" #include //#include #include "SelectPumpDlg.h" #include "PumpBaseDlg.h" #include "twt_pump.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // 水泵基础 ///////////////////////////////////////////////////////////////////////////// void InitDoteLayer() { InitDoteLayer(LAY_TWT_DOTE); } void DoPumpDimension(XPoint pt1, XPoint pt2, double nDist, int iScale) { InitLayer(LAY_DIM); TDbDimension2 *pDim = new TDbDimension2; pDim->setLayer(LAY_DIM); pDim->SetDist2DimLine(0); pDim->SetLocation(pt1); pDim->SetRotation(ads_angle(pt1, pt2)); pDim->AddSegment(pt2); pDim->SetStyleId(InitDimStyle(DS_LINEAR)); pDim->SetDist2DimLine(-nDist, FALSE); XString xsText = pDim->GetText(0); double nNew = _tstof(xsText)/ iScale; pDim->SetTextContent(0, XString(_T("%.0f"), nNew)); AcDbObjectId idDim = pDim->AddToMSpace(Adesk::kTrue); } void DrawPumpBaseCmd() { CTemporaryResourceOverride vTemp; CPumpBaseDlg dlg; if(dlg.DoModal() != IDOK) return; InitLayer(LAY_TWT_PUMP); InitDoteLayer(); XPushVarStr clayer(_T("CLAYER"), LAY_TWT_PUMP); XPushVar vOsMode(_T("OSMODE"), 0); XPoint ptIns, pt1, pt2, pt3, ptS, ptE; double nRadius = 100 * dlg.m_iMultiple; XPoly2D polyOutline; xg_getvar(_T("VIEWCTR"), ptIns); ptIns = Ucs2Wcs(ptIns); PickSet ss(SS_FREE); ss.IncludeBegin(); //平面 ads_polar(ptIns, PI/2, dlg.m_nB, pt1); ads_polar(pt1, 0, dlg.m_nL, pt2); XRectAngle rect(ptIns, pt2); rect.Make(); DoPumpDimension(pt1, ptIns, 7*nRadius, dlg.m_iMultiple); DoPumpDimension(ptIns, rect.GetLowRight(), 6*nRadius, dlg.m_iMultiple); ads_polar(ptIns, 0, dlg.m_nL1, pt1); ads_polar(pt1, PI/2, (dlg.m_nB-dlg.m_nB1)/2, pt1); XRectAngle(pt1, nRadius, nRadius).Make();//平面螺栓孔 ads_polar(pt1, 0, -dlg.m_nL1, ptS); DoPumpDimension(ptS, pt1, 4*nRadius, dlg.m_iMultiple); ptS = pt1; ads_polar(pt1, PI/2, dlg.m_nB1, pt2); XRectAngle(pt2, nRadius, nRadius).Make();//平面螺栓孔 DoPumpDimension(pt2, pt1, 4*nRadius, dlg.m_iMultiple); ads_polar(pt2, 0, dlg.m_nL2, pt2); XRectAngle(pt2, nRadius, nRadius).Make();//平面螺栓孔 { XPushVarStr clayer(_T("CLAYER"), LAY_TWT_DOTE); XRectAngle rect3(pt1, pt2); rect3.Make(); } ads_polar(pt1, 0, dlg.m_nL2, pt2); XRectAngle(pt2, nRadius, nRadius).Make();//平面螺栓孔 ptE = pt2; DoPumpDimension(ptS, ptE, 4*nRadius, dlg.m_iMultiple); //剖面 if(dlg.m_bDamping){ ads_polar(ptIns, PI/2, dlg.m_nB*2, pt1); ads_polar(pt1, PI/2, dlg.m_nH, pt2); DoPumpDimension(pt2, pt1, 7*nRadius, dlg.m_iMultiple); ads_polar(pt2, 0, dlg.m_nL, pt2); XRectAngle rect2(pt1, pt2); rect2.Make(); ads_polar(pt1, PI/2, -nRadius/2, ptS); ads_polar(ptS, PI, 6*nRadius, ptS); ads_polar(ptS, 0, 12*nRadius + dlg.m_nL, ptE); DrawLine(ptS, ptE); //绘制地面线 XPoint ptTmp = ptE; for(int i=0;i<8;i++){ ads_polar(ptS, 0, nRadius/2, ptS); ads_polar(ptS, PI/2, -nRadius/2, ptE); ads_polar(ptE, PI, nRadius/2, ptE); DrawLine(ptS, ptE); } ptE = ptTmp; for(i=0;i<8;i++){ ads_polar(ptE, PI, nRadius/2, ptE); ads_polar(ptE, PI/2, -nRadius/2, ptS); ads_polar(ptS, PI, nRadius/2, ptS); DrawLine(ptE, ptS); } //减震垫(左) ads_polar(rect2.GetLowLeft(), PI/2, -nRadius/2, ptS); DrawLine(rect2.GetLowLeft(), ptS); ads_polar(rect2.GetLowLeft(), 0, nRadius, pt1); ads_polar(pt1, PI/2, -nRadius/2, ptE); DrawLine(ptE, pt1); ads_polar(rect2.GetLowLeft(), PI/2, -nRadius/4, ptS); ads_polar(pt1, PI/2, -nRadius/4, ptE); DrawLine(ptE, ptS); //减震垫(右) ads_polar(rect2.GetLowRight(), PI/2, -nRadius/2, ptS); DrawLine(rect2.GetLowRight(), ptS); ads_polar(rect2.GetLowRight(), PI, nRadius, pt1); ads_polar(pt1, PI/2, -nRadius/2, ptE); DrawLine(ptE, pt1); ads_polar(rect2.GetLowRight(), PI/2, -nRadius/4, ptS); ads_polar(pt1, PI/2, -nRadius/4, ptE); DrawLine(ptE, ptS); //螺栓孔中心线 ads_polar(rect2.GetUpLeft(), 0, dlg.m_nL1, ptS); ads_polar(ptS, PI/2, -nRadius/2-dlg.m_nH, ptE); ads_polar(ptS, PI/2, nRadius/2, ptS); { XPushVarStr clayer(_T("CLAYER"), LAY_TWT_DOTE); DrawLine(ptE, ptS); } ads_polar(ptS, 0, dlg.m_nL2, ptS); ads_polar(ptE, 0, dlg.m_nL2, ptE); { XPushVarStr clayer(_T("CLAYER"), LAY_TWT_DOTE); DrawLine(ptE, ptS); } } else{ ads_polar(ptIns, PI/2, dlg.m_nB*2, pt1); polyOutline.AppendNode(pt1); ads_polar(pt1, PI/2, dlg.m_nH, pt2); polyOutline.AppendNode(pt2); ads_polar(pt2, 0, dlg.m_nL1, pt3); ads_polar(pt3, PI/2, nRadius, ptS); ads_polar(pt3, PI/2, -dlg.m_nH-nRadius, ptE); { XPushVarStr clayer(_T("CLAYER"), LAY_TWT_DOTE); DrawLine(ptS, ptE); } ads_polar(pt3, PI/2, -dlg.m_nH2/2, pt3); XRectAngle rect3(pt3, nRadius, dlg.m_nH2); rect3.Make();//剖面螺栓孔 DoPumpDimension(rect3.GetUpLeft(), rect3.GetLowLeft(), 5*nRadius, dlg.m_iMultiple); polyOutline.AppendNode(rect3.GetUpLeft()); polyOutline.AppendNode(rect3.GetLowLeft()); polyOutline.AppendNode(rect3.GetLowRight()); polyOutline.AppendNode(rect3.GetUpRight()); ads_polar(pt2, 0, (dlg.m_nL1 + dlg.m_nL2), pt3); ads_polar(pt3, PI/2, nRadius, ptS); ads_polar(pt3, PI/2, -dlg.m_nH-nRadius, ptE); { XPushVarStr clayer(_T("CLAYER"), LAY_TWT_DOTE); DrawLine(ptS, ptE); } ads_polar(pt3, PI/2, -dlg.m_nH2/2, pt3); XRectAngle rect4(pt3, nRadius, dlg.m_nH2); rect4.Make();//剖面螺栓孔 polyOutline.AppendNode(rect4.GetUpLeft()); polyOutline.AppendNode(rect4.GetLowLeft()); polyOutline.AppendNode(rect4.GetLowRight()); polyOutline.AppendNode(rect4.GetUpRight()); DoPumpDimension(pt2, pt1, 7*nRadius, dlg.m_iMultiple); ads_polar(pt2, 0, dlg.m_nL, pt2); XRectAngle rect2(pt1, pt2); rect2.Make(); polyOutline.AppendNode(rect2.GetUpRight()); polyOutline.AppendNode(rect2.GetLowRight()); polyOutline.AppendNode(rect2.GetLowLeft()); //混凝土填充 AcDbHatch *pHatch = new AcDbHatch(); pHatch = NewHatchFromPoly2D(polyOutline, _T("AN33C"), 500); if(pHatch != NULL) PostToDb(pHatch, TRUE); } ss.IncludeEnd(); ptIns = Wcs2Ucs(ptIns); int nRet = DragPickSet1(ss, ptIns); if(nRet != RTNORM){ ss.Erase(); return; } } ///////////////////////////////////////////////////////////////////////////// // CPumpBaseDlg dialog CPumpBaseDlg::CPumpBaseDlg(CWnd* pParent /*=NULL*/) : CDialog(CPumpBaseDlg::IDD, pParent) { //{{AFX_DATA_INIT(CPumpBaseDlg) m_bDamping = FALSE; m_nB = 600; m_nB1 = 320; m_nH = 350; m_nH2 = 250; m_nL = 810; m_nL1 = 200; m_nL2 = 440; m_iMultiple = 4; //}}AFX_DATA_INIT } void CPumpBaseDlg::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(CPumpBaseDlg) DDX_Check(pDX, IDC_CHECK_DAMP, m_bDamping); DDX_Text(pDX, IDC_EDIT_B, m_nB); DDX_Text(pDX, IDC_EDIT_B1, m_nB1); DDX_Text(pDX, IDC_EDIT_H, m_nH); DDX_Text(pDX, IDC_EDIT_H2, m_nH2); DDX_Text(pDX, IDC_EDIT_L, m_nL); DDX_Text(pDX, IDC_EDIT_L1, m_nL1); DDX_Text(pDX, IDC_EDIT_L2, m_nL2); DDX_Text(pDX, IDC_EDIT_MULTIPLE, m_iMultiple); //}}AFX_DATA_MAP } BEGIN_MESSAGE_MAP(CPumpBaseDlg, CDialog) //{{AFX_MSG_MAP(CPumpBaseDlg) ON_WM_PAINT() ON_BN_CLICKED(IDC_CHECK_DAMP, OnCheckDamp) ON_BN_CLICKED(IDC_BUTTON_SELECT, OnButtonSelect) //}}AFX_MSG_MAP END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CPumpBaseDlg message handlers BOOL CPumpBaseDlg::OnInitDialog() { CDialog::OnInitDialog(); return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE } void CPumpBaseDlg::OnPaint() { CPaintDC dc(this); // device context for painting OpenSlide(); } void CPumpBaseDlg::OpenSlide() { int iMode = 1; if(m_bDamping) iMode = 2; CWnd *pWnd = GetDlgItem(IDC_STATIC_PREVIEW); CString csTmp; csTmp.Format(_T("TWT(PUMP%d)"), iMode); DrawSlide(csTmp, pWnd); } void CPumpBaseDlg::OnCheckDamp() { UpdateData(TRUE); CWnd *pWnd2 = GetDlgItem(IDC_EDIT_H2); if(m_bDamping){ pWnd2->EnableWindow(FALSE); } else{ pWnd2->EnableWindow(TRUE); } OpenSlide(); } void CPumpBaseDlg::OnOK() { UpdateData(TRUE); if(m_nB1 > m_nB || m_nH2 > m_nH || m_nL2 > m_nL || m_nL1 > m_nL) MessageBox(_T("边距大于总长度,输入不合理!")); m_nB = m_nB*m_iMultiple; m_nB1 = m_nB1*m_iMultiple; m_nH = m_nH*m_iMultiple; m_nH2 = m_nH2*m_iMultiple; m_nL = m_nL*m_iMultiple; m_nL1 = m_nL1*m_iMultiple; m_nL2 = m_nL2*m_iMultiple; UpdateData(FALSE); CDialog::OnOK(); } void CPumpBaseDlg::OnButtonSelect() { CTemporaryResourceOverride vTemp; CSelectPumpDlg dlg; if(dlg.DoModal() != IDOK) return; m_nL = dlg.m_iLenght; m_nB = dlg.m_iWidth; m_nB1 = dlg.m_nRetL2; m_nL2 = dlg.m_nRetB1; m_nL1 = (m_nL - m_nL2) / 2; m_nH2 = dlg.m_nDeep; m_nH = m_nH2 + 100; UpdateData(FALSE); }