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

📄 programadoc.cpp

📁 CAM控制软件源代码 非常好的一个程序
💻 CPP
字号:
// ProgramaDoc.cpp : implementation of the CProgramaDoc class
//

#include "stdafx.h"
#include "Programa.h"

#include "ProgramaDoc.h"
#include "CargarTocho.h"
#include "CargarTochoFresa.h"
#include "VelocidadUSR.h"
#include "Posicion.h"
#include "Cuchilla.h"
#include "Broca.h"


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

/////////////////////////////////////////////////////////////////////////////
// CProgramaDoc

IMPLEMENT_DYNCREATE(CProgramaDoc, CDocument)

BEGIN_MESSAGE_MAP(CProgramaDoc, CDocument)
	//{{AFX_MSG_MAP(CProgramaDoc)
	ON_COMMAND(ID_FILE_OPEN, OnFileOpen)
	ON_COMMAND(ID_SIMULACION_EJECUTAR, OnSimulacionEjecutar)
	ON_COMMAND(ID_SIMULACIN_DURACIN_TIEMPOUSUARIO, OnSimulacinDuracinTiempousuario)
	ON_COMMAND(ID_HERRAMIENTA_CUCHILLA, OnHerramientaCuchilla)
	ON_COMMAND(ID_HERRAMIENTA_POSICIN, OnHerramientaPosicin)
	ON_COMMAND(ID_HERRAMIENTA_BROCA, OnHerramientaBroca)
	ON_COMMAND(ID_PIEZA_CARGARTOCHO_ENELTORNO, OnPiezaCargartochoEneltorno)
	ON_COMMAND(ID_PIEZA_CARGARTOCHO_ENLAFRESA, OnPiezaCargartochoEnlafresa)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CProgramaDoc construction/destruction

CProgramaDoc::CProgramaDoc()
{
	presentar = 0;
	simular = 0;
	cargarTor = 0;
	cargarFre = 0;
//	grilla = 0;
	torno = 0;
	fresa = 0;
	rpm = 0;
	cuchilla = 0;
	broca = 0;
	XPos = YPos = 0;
	Inicio = 0;
}

CProgramaDoc::~CProgramaDoc()
{
}

BOOL CProgramaDoc::OnNewDocument()
{
	if (!CDocument::OnNewDocument())
		return FALSE;

	presentar = 0;
	simular = 0;
	cargarTor = 0;
	cargarFre = 0;
//	grilla = 0;
	torno = 0;
	fresa = 0;
	rpm = 0;
	cuchilla = 0;
	broca = 0;
	XPos = YPos = 0;
	Inicio = 0;

	return TRUE;
}



/////////////////////////////////////////////////////////////////////////////
// CProgramaDoc serialization

void CProgramaDoc::Serialize(CArchive& ar)
{
	if (ar.IsStoring())
	{
		// TODO: add storing code here
	}
	else
	{
		// TODO: add loading code here
	}
}

/////////////////////////////////////////////////////////////////////////////
// CProgramaDoc diagnostics

#ifdef _DEBUG
void CProgramaDoc::AssertValid() const
{
	CDocument::AssertValid();
}

void CProgramaDoc::Dump(CDumpContext& dc) const
{
	CDocument::Dump(dc);
}
#endif //_DEBUG

/////////////////////////////////////////////////////////////////////////////
// CProgramaDoc commands

void CProgramaDoc::OnFileOpen() 
{
	CString fichero="archivo de C骴igo G",temp;

	CFileDialog archivos(true,NULL,fichero,OFN_ALLOWMULTISELECT,"Codigo G (*.tap)|*.tap|Codigo G (*.act)|*.act||",NULL);

	if (archivos.DoModal() == FALSE) return;
	fichero=archivos.GetPathName();

	CFile cfFile (fichero, CFile::modeNoTruncate | CFile::modeRead);
	CArchive ar (&cfFile, CArchive::load); 

	if(!ar.ReadString(temp))  return;

	nl=0;
	do
	{
		if(temp.GetLength() == 0) continue;
		strcpy(linea[nl],temp);
		nl++;

	}while(ar.ReadString(temp));    

	
	// SEPARANDO COORDENADAS

	int i,j,k,d,sp;
	char aux[30];

	for ( i=0; i<5000; i++)
	{
		x[i] = y[i] = z[i] = 0;
	}	

	kn=0;
	for (i=0;i<nl;i++)
	{
		
		if (linea[i][0]=='S');
		{
			Inicio=1;
		}
		
		if (linea[i][0]=='M');
		{
		sp = 0;
		k = 0;
		d = strlen(linea[i]);

		for (j=0;j<d;j++)
		{
			if ((linea[i][j]=='-')|(isdigit(linea[i][j]))|(linea[i][j]=='.'))
			{
				aux[k] = linea[i][j];
				k++;
				continue;
			}

			if (linea[i][j]==' ')
			{
				sp++;
				if (sp==1) continue;

				aux[k]=0;

				if (sp==2)
					if ((aux[0]=='-')|(isdigit(aux[0]))|(aux[0]=='.'))
						x[kn] = atof(aux);
					else
						x[kn] = x[kn-1];

				if (sp==3) 
					if ((aux[0]=='-')|(isdigit(aux[0]))|(aux[0]=='.')) 
						y[kn] = atof(aux);
					else
						y[kn] = y[kn-1];

				if (sp==4)
					if ((aux[0]=='-')|(isdigit(aux[0]))|(aux[0]=='.')) 
						z[kn] = atof(aux);
					else
						z[kn] = z[kn-1];

				k = 0;
				continue;
			}
			
		}

		kn++;
		j = d;
		}
	}
	
	presentar = 1;

	//	VERIFICANDO TORNO O FRESA

	sumz = 0;
	for (i=0; i<nl; i++)
	{
		sumz += abs(z[i]);
	}

	if (sumz == 0)
		torno = 1;
	else
		fresa = 1;

	UpdateAllViews(NULL);
	
}

void CProgramaDoc::OnSimulacionEjecutar() 
{
	simular = 1;
	UpdateAllViews(NULL);
}

void CProgramaDoc::OnSimulacinDuracinTiempousuario() 
{
	rpm = 1;	

	CVelocidadUSR dlg;
	dlg.DoModal();

	velocidad = dlg.vel;

	UpdateAllViews(NULL);
}

void CProgramaDoc::OnHerramientaCuchilla() 
{
	cuchilla=1;

	CCuchilla cu;

	acNo1 = cu.m_acNo1 = 40;
	altcNo1 = cu.m_altcNo1 = 150;
	angcNo1 = cu.m_angcNo1= 60;
	ang2cNo1 = cu.m_ang2cNo1= 0;
	ANo1 = cu.m_ANo1= 30;

	if (cu.DoModal())
	{
		acNo1 = cu.m_acNo1;
		altcNo1 = cu.m_altcNo1;
		angcNo1 = cu.m_angcNo1;
		ang2cNo1 = cu.m_ang2cNo1;
		ANo1 = cu.m_ANo1;
	}

	UpdateAllViews(NULL);
}

void CProgramaDoc::OnHerramientaPosicin() 
{
	// TODO: Add your command handler code here
	CPosicion dlg;
	XPos=dlg.m_dPosX=0;
	YPos=dlg.m_dPosY=0;

	if (dlg.DoModal())
	{
	XPos=dlg.m_dPosX;
	YPos=dlg.m_dPosY;
	}
	
}

void CProgramaDoc::OnHerramientaBroca() 
{
	broca = 1;

	CBroca dlg;
	diamBro = dlg.m_dDiamBroca = 4;
	larBro = dlg.m_dLarBroca = 20;

	if (dlg.DoModal())
	{
		diamBro = dlg.m_dDiamBroca;
		larBro = dlg.m_dLarBroca;
	}

	UpdateAllViews(NULL);

}

void CProgramaDoc::OnPiezaCargartochoEneltorno() 
{
	cargarTor = 1;

	CCargarTocho ct;

	diametro = ct.m_dDiametro = 20;
	largo = ct.m_dLargo = 50;
	material = ct.m_nMaterial = 0;

	if (ct.DoModal())
	{
		diametro = ct.m_dDiametro;
		largo = ct.m_dLargo;
		material = ct.m_nMaterial;
	}

	UpdateAllViews(NULL);
}

void CProgramaDoc::OnPiezaCargartochoEnlafresa() 
{
	cargarFre = 1;

	CCargarTochoFresa ctf;

	altof = ctf.m_dAltoF = 20;
	anchof = ctf.m_dAnchoF = 40;
	largof = ctf.m_dLargoF = 60;
	materialf = ctf.m_nMaterialF = 0;

	if (ctf.DoModal())
	{
		altof = ctf.m_dAltoF;
		anchof = ctf.m_dAnchoF;
		largof = ctf.m_dLargoF;
		materialf = ctf.m_nMaterialF;
	}

	UpdateAllViews(NULL);
}

⌨️ 快捷键说明

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