⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 yuanzhu.cpp

📁 基于UG平台
💻 CPP
📖 第 1 页 / 共 3 页
字号:
// yuanzhu.cpp : implementation file
//

#include "stdafx.h"
#include "Code.h"
#include "yuanzhu.h"
#include "main.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// Cyuanzhu dialog


Cyuanzhu::Cyuanzhu(CWnd* pParent /*=NULL*/)
	: CDialog(Cyuanzhu::IDD, pParent)
{
	//{{AFX_DATA_INIT(Cyuanzhu)
	m_D = 0.0;
	m_d1 = 0.0;
	m_b = 0.0;
	m_d2 = 0.0;
	m_D2 = 0.0;
	m_r = 0.0;
	//}}AFX_DATA_INIT
}


void Cyuanzhu::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(Cyuanzhu)
	DDX_Control(pDX, IDC_LIST2, m_listctrl2);
	DDX_Control(pDX, IDC_LIST1, m_listctrl1);
	DDX_Control(pDX, IDC_COMBO1, m_list);
	DDX_Text(pDX, IDC_EDIT1, m_D);
	DDX_Text(pDX, IDC_EDIT2, m_d1);
	DDX_Text(pDX, IDC_EDIT3, m_b);
	DDX_Text(pDX, IDC_EDIT4, m_d2);
	DDX_Text(pDX, IDC_EDIT5, m_D2);
	DDX_Text(pDX, IDC_EDIT6, m_r);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(Cyuanzhu, CDialog)
	//{{AFX_MSG_MAP(Cyuanzhu)
	ON_NOTIFY(NM_CLICK, IDC_LIST1, OnClickList1)
	ON_NOTIFY(NM_CLICK, IDC_LIST2, OnClickList2)
	ON_BN_CLICKED(IDOK2, OnHelpBtn)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// Cyuanzhu message handlers


BOOL Cyuanzhu::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	m_list.InsertString(0,"N000系列");
	m_list.InsertString(1,"NF000系列");
	m_list.InsertString(2,"NJ0000、HJ0000");
	m_list.InsertString(3,"NU0000系列");
	m_list.InsertString(4,"NJ0000系列");
	m_list.InsertString(5,"NUP0000 系列");
	m_list.SetCurSel(0);

		try{	
		m_ADODatabase.SetConnectionString(_T("Provider=SQLOLEDB.1;Password=00;User ID=david;Initial Catalog=chuandong;Data Source=acer"));
		m_ADODatabase.Open();
		BOOL b = m_ADODatabase.IsOpen(); 
	    this->m_ADORecordset.Open(this->m_ADODatabase.GetActiveConnection(), _T("select * from ZGB_d where [Z_yuanzhu] like 'Z_yuanzhu'"));

		CString d1;
	    int i=0;
		m_listctrl1.InsertColumn(0,_T("d"),LVCFMT_LEFT,50);
		m_listctrl2.InsertColumn(0,_T("型号"),LVCFMT_LEFT,50);
		 m_listctrl2.InsertColumn(1,_T("dd"),LVCFMT_LEFT,50);
	    m_listctrl2.InsertColumn(2,_T("D"),LVCFMT_LEFT,50);       	
        m_listctrl2.InsertColumn(3,_T("B"),LVCFMT_LEFT,50);
	    m_listctrl2.InsertColumn(4,_T("d2"),LVCFMT_LEFT,50);
	    m_listctrl2.InsertColumn(5,_T("D2"),LVCFMT_LEFT,50);
	    m_listctrl2.InsertColumn(6,_T("r"),LVCFMT_LEFT,50);
		
	 
	      
     
		while(!this->m_ADORecordset.IsEof())
		{
			this->m_ADORecordset.GetFieldValue("d", d1);	
       		m_listctrl1.InsertItem(i,d1);
			this->m_ADORecordset.MoveNext();
			i=i+1;
		}
   }
	catch (_com_error e)
		{
		AfxMessageBox(CString(e.ErrorMessage()));
		}
   		UpdateData(false);	
    

	
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}


double Cyuanzhu::strtodouble(CString pp1)
	{
		double xpp;
		char   *pszTemp=pp1.GetBuffer(0);
		int   nLength   =   strlen(pszTemp);  
		char   *xp   =   new   char[nLength   +   1]; 
		strcpy(xp,   pszTemp);  
		xp[nLength]   =   '\0';
		xpp=atof(xp);
		return xpp;
	}

void Cyuanzhu::OnClickList1(NMHDR* pNMHDR, LRESULT* pResult) 
{
	CString D,daihao,dd1,D1,B1,dd21,D21,r1,dda1,Da1,ra1,Cr1,C0r1,Dw1,Z1,d,b;
    int j=0,k;
	int  nItemCount=m_listctrl2.GetItemCount();
	for(k=nItemCount-1;k>=0;k--)
	{
        m_listctrl2.DeleteItem(k);  
	}
    	int list=m_list.GetCurSel();//
	for(int i=0;i<m_listctrl1.GetItemCount();i++)
	{
		if(m_listctrl1.GetItemState(i,LVIS_SELECTED)==LVIS_SELECTED)
		{
            D=m_listctrl1.GetItemText(i,0);	
	         if(list==0) 
		   {
		    this->m_ADORecordset.Open(this->m_ADODatabase.GetActiveConnection(), _T("select * from Z_yuanzhu2 where dd like '"+D+"'and [N] is not NULL"));
            while(!this->m_ADORecordset.IsEof()) 
			{
               	this->m_ADORecordset.GetFieldValue("N", daihao);	
				
				this->m_ADORecordset.GetFieldValue("dd", dd1);	
				this->m_ADORecordset.GetFieldValue("D", D1);	
				this->m_ADORecordset.GetFieldValue("B", B1);	
				this->m_ADORecordset.GetFieldValue("dd2", dd21);	
				this->m_ADORecordset.GetFieldValue("D2", D21);	
				this->m_ADORecordset.GetFieldValue("r", r1);	
	
				
	
             	m_listctrl2.InsertItem(j,daihao);
			    m_listctrl2.SetItemText(j,2,D1);
				m_listctrl2.SetItemText(j,3,B1);
			    m_listctrl2.SetItemText(j,4,dd21);	
				m_listctrl2.SetItemText(j,5,D21);
		    	m_listctrl2.SetItemText(j,6,r1);
		        m_listctrl2.SetItemText(j,1,dd1);

		    	this->m_ADORecordset.MoveNext();
				j=j+1;
			} 
		   }
		  if(list==1) 
		   {
		    this->m_ADORecordset.Open(this->m_ADODatabase.GetActiveConnection(), _T("select * from Z_yuanzhu2 where dd like '"+D+"'and [NF] is not NULL"));
            while(!this->m_ADORecordset.IsEof()) 
			{
               	this->m_ADORecordset.GetFieldValue("NF", daihao);	
				
				this->m_ADORecordset.GetFieldValue("dd", dd1);	
				this->m_ADORecordset.GetFieldValue("D", D1);	
				this->m_ADORecordset.GetFieldValue("B", B1);	
				this->m_ADORecordset.GetFieldValue("dd2", dd21);	
				this->m_ADORecordset.GetFieldValue("D2", D21);	
				this->m_ADORecordset.GetFieldValue("r", r1);	
	
				
				
             	m_listctrl2.InsertItem(j,daihao);
			    m_listctrl2.SetItemText(j,2,D1);
				m_listctrl2.SetItemText(j,3,B1);
			    m_listctrl2.SetItemText(j,4,dd21);	
				m_listctrl2.SetItemText(j,5,D21);
		    	m_listctrl2.SetItemText(j,6,r1);
		        m_listctrl2.SetItemText(j,1,dd1);

		    	this->m_ADORecordset.MoveNext();
				j=j+1;
			} 
		   }
		 if(list==2) 
		   {
		    this->m_ADORecordset.Open(this->m_ADODatabase.GetActiveConnection(), _T("select * from Z_yuanzhu2 where dd like '"+D+"'and [NH] is not NULL"));
            while(!this->m_ADORecordset.IsEof()) 
			{
               	this->m_ADORecordset.GetFieldValue("NH", daihao);	
				
				this->m_ADORecordset.GetFieldValue("dd", dd1);	
				this->m_ADORecordset.GetFieldValue("D", D1);	
				this->m_ADORecordset.GetFieldValue("B", B1);	
				this->m_ADORecordset.GetFieldValue("dd2", dd21);	
				this->m_ADORecordset.GetFieldValue("D2", D21);	
				this->m_ADORecordset.GetFieldValue("r", r1);	
	
				
             	m_listctrl2.InsertItem(j,daihao);
			    m_listctrl2.SetItemText(j,2,D1);
				m_listctrl2.SetItemText(j,3,B1);
			    m_listctrl2.SetItemText(j,4,dd21);	
				m_listctrl2.SetItemText(j,5,D21);
		    	m_listctrl2.SetItemText(j,6,r1);
		        m_listctrl2.SetItemText(j,1,dd1);

		    	this->m_ADORecordset.MoveNext();
				j=j+1;
			} 
		   }
			  if(list==3) 
		   {
		    this->m_ADORecordset.Open(this->m_ADODatabase.GetActiveConnection(), _T("select * from Z_yuanzhu1 where dd like '"+D+"'and [NU] is not NULL"));
            while(!this->m_ADORecordset.IsEof()) 
			{
               	this->m_ADORecordset.GetFieldValue("NU", daihao);	
				
				this->m_ADORecordset.GetFieldValue("dd", dd1);	
				this->m_ADORecordset.GetFieldValue("D", D1);	
				this->m_ADORecordset.GetFieldValue("B", B1);	
				this->m_ADORecordset.GetFieldValue("dd2", dd21);	
				this->m_ADORecordset.GetFieldValue("D2", D21);	
				this->m_ADORecordset.GetFieldValue("r", r1);	
	
				
				
             	m_listctrl2.InsertItem(j,daihao);
			    m_listctrl2.SetItemText(j,2,D1);
				m_listctrl2.SetItemText(j,3,B1);
			    m_listctrl2.SetItemText(j,4,dd21);	
				m_listctrl2.SetItemText(j,5,D21);
		    	m_listctrl2.SetItemText(j,6,r1);
		        m_listctrl2.SetItemText(j,1,dd1);

		    	this->m_ADORecordset.MoveNext();
				j=j+1;
			} 
		   }
			   if(list==4) 
		   {
		    this->m_ADORecordset.Open(this->m_ADODatabase.GetActiveConnection(), _T("select * from Z_yuanzhu1 where dd like '"+D+"'and [NJ] is not NULL"));
            while(!this->m_ADORecordset.IsEof()) 
			{
               	this->m_ADORecordset.GetFieldValue("NJ", daihao);	
				this->m_ADORecordset.GetFieldValue("dd", dd1);	
				this->m_ADORecordset.GetFieldValue("D", D1);	
				this->m_ADORecordset.GetFieldValue("B", B1);	
				this->m_ADORecordset.GetFieldValue("dd2", dd21);	
				this->m_ADORecordset.GetFieldValue("D2", D21);	
				this->m_ADORecordset.GetFieldValue("r", r1);	
	
		
			

             	m_listctrl2.InsertItem(j,daihao);
			    m_listctrl2.SetItemText(j,2,D1);
				m_listctrl2.SetItemText(j,3,B1);
			    m_listctrl2.SetItemText(j,4,dd21);	
				m_listctrl2.SetItemText(j,5,D21);
		    	m_listctrl2.SetItemText(j,6,r1);
		        m_listctrl2.SetItemText(j,1,dd1);

		    	this->m_ADORecordset.MoveNext();
				j=j+1;
			} 
		   }
			    if(list==5) 
		   {
		    this->m_ADORecordset.Open(this->m_ADODatabase.GetActiveConnection(), _T("select * from Z_yuanzhu1 where dd like '"+D+"'and [NUP] is not NULL"));
            while(!this->m_ADORecordset.IsEof()) 
			{
               	this->m_ADORecordset.GetFieldValue("NUP", daihao);	
				
				this->m_ADORecordset.GetFieldValue("dd", dd1);	
				this->m_ADORecordset.GetFieldValue("D", D1);	
				this->m_ADORecordset.GetFieldValue("B", B1);	
				this->m_ADORecordset.GetFieldValue("dd2", dd21);	
				this->m_ADORecordset.GetFieldValue("D2", D21);	
				this->m_ADORecordset.GetFieldValue("r", r1);	
	
				
			
             	m_listctrl2.InsertItem(j,daihao);
			    m_listctrl2.SetItemText(j,2,D1);
				m_listctrl2.SetItemText(j,3,B1);
			    m_listctrl2.SetItemText(j,4,dd21);	
				m_listctrl2.SetItemText(j,5,D21);
		    	m_listctrl2.SetItemText(j,6,r1);
		        m_listctrl2.SetItemText(j,1,dd1);

		    	this->m_ADORecordset.MoveNext();
				j=j+1;
			} 
		   }
		  
		}
	}

  	 UpdateData(false);

	
	*pResult = 0;
}



void Cyuanzhu::OnClickList2(NMHDR* pNMHDR, LRESULT* pResult) 
{
	 m_listctrl2.SetExtendedStyle(LVS_EX_FULLROWSELECT); 
  for(int m=0;m<m_listctrl2.GetItemCount();m++)
  {
    if(m_listctrl2.GetItemState(m,LVIS_SELECTED)==LVIS_SELECTED)
	{
      m_D=strtodouble(m_listctrl2.GetItemText(m,2));
	  m_d1=strtodouble(m_listctrl2.GetItemText(m,1));
	  m_b=strtodouble(m_listctrl2.GetItemText(m,3));
	  m_d2=strtodouble(m_listctrl2.GetItemText(m,4));
	  m_D2=strtodouble(m_listctrl2.GetItemText(m,5));
	  m_r=strtodouble(m_listctrl2.GetItemText(m,6));
	 
	}
  }	
    UpdateData(false);	
	
	*pResult = 0;
}


void Cyuanzhu::OnOK() 
{
	int err=UF_initialize();
 	int nlist=m_list.GetCurSel();
	double m_d=m_D,m_dd=m_d1,m_i=12;	
	double dd=3.1415926*2/m_i;	
	double aa;
	int i;
    aa=(m_d-m_dd)/2;
	double r1=m_dd/2+aa/2;
	double x=(m_b/2-aa/4)*0.267949;
	UF_MODL_SWEEP_TRIM_object_p_t trim_date=NULL;
	UF_FEATURE_SIGN mode_sign=UF_NULLSIGN,sign1=UF_NEGATIVE;
	char *limit[2]={"0.0","360.0"};
    char *offset[2]={"0.0","0.0"};
	double origin[3]={0.0,0.0,0.0};
    double axis[3]={0.0,0.0,0.0};
    double direction[3]={1.0,0.0,0.0};
	int num;
	tag_t *ob;
    
//N000系列	
	if(err==0&&nlist==0)
	{
tag_t sum[8],n1,n2,n3,n4,n5,n6,n7,n8,n9,n10,n11,n12,n13,n14,n15,sum1[6];
 
UF_CURVE_line_t kn1,kn2,kn3,kn4,kn5,kn6,kn7,kn8,kn9,kn10,kn11,kn12,kn13,kn14,kn15;

kn1.start_point[0]=m_b/2;
kn1.start_point[1]=m_dd/2;
kn1.start_point[2]=0.0;
kn1.end_point[0]=-m_b/2;
kn1.end_point[1]=m_dd/2;
kn1.end_point[2]=0.0;
UF_CURVE_create_line(&kn1,&n1);
 UF_CURVE_ask_line_data(n1,&kn1);

kn2.start_point[0]=m_b/2;
kn2.start_point[1]=m_dd/2;
kn2.start_point[2]=0.0;
kn2.end_point[0]=m_b/2;
kn2.end_point[1]=m_dd/2+3*aa/8;
kn2.end_point[2]=0.0;
UF_CURVE_create_line(&kn2,&n2);
UF_CURVE_ask_line_data(n2,&kn2);

kn3.start_point[0]=m_b/2;
kn3.start_point[1]=m_dd/2+3*aa/8;
kn3.start_point[2]=0.0;
kn3.end_point[0]=aa/4;
kn3.end_point[1]=m_dd/2+3*aa/8;
kn3.end_point[2]=0.0;
UF_CURVE_create_line(&kn3,&n3);
UF_CURVE_ask_line_data(n3,&kn3);

kn4.start_point[0]=aa/4;
kn4.start_point[1]=m_dd/2+3*aa/8;
kn4.start_point[2]=0.0;
kn4.end_point[0]=aa/4;
kn4.end_point[1]=m_dd/2+aa/4;
kn4.end_point[2]=0.0;
UF_CURVE_create_line(&kn4,&n4);
UF_CURVE_ask_line_data(n4,&kn4);

kn5.start_point[0]=aa/4;
kn5.start_point[1]=m_dd/2+aa/4;
kn5.start_point[2]=0.0;
kn5.end_point[0]=-aa/4;
kn5.end_point[1]=m_dd/2+aa/4;
kn5.end_point[2]=0.0;
UF_CURVE_create_line(&kn5,&n5);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -