evolve4src/src/evolve/evolveView.cpp
void CevolveView::OnView3D()
{
	CevolveDoc *doc;
	CString str;
	CWinApp *app;
	UNIVERSE *u;
	char cwd[1000], *p;
	char tmp_filename[1000], *tp;
	char args[1000];
	char errbuf[1000];
	char tmp_path[1000];
	char buf[1000];
	int n;

	doc = GetDocument();
	u = doc->universe;

	app = AfxGetApp();
	str = app->GetProfileString("evolve3d", "program");

	strcpy(cwd, str);

	p = strrchr(cwd, '\\');
	if( p == NULL ) {
		p = strrchr(cwd, '/');
	}

	if( p != NULL ) {
		*p = '\0';
	}

	n = GetTempPath(1000, tmp_path);
	if( n == 0 ) {
		sprintf(buf, "Unable to get TempPath");
		str = buf;
		AfxMessageBox(str, MB_OK, 0);
		return;
	}

	tp = _tempnam(tmp_path, "evolve3d_");
	if( tp != NULL ) {
		strcpy(tmp_filename, tp);
		strcat(tmp_filename, ".evolve");

		n = Universe_Write(u, tmp_filename, errbuf);
		if( !n ) {
			sprintf(buf, "%s", errbuf);
			str = buf;
			AfxMessageBox(str, MB_OK, 0);
			return;
		}
	} else {
		sprintf(buf, "Cannot create a unique filename\n" );
		str = buf;
		AfxMessageBox(str, MB_OK, 0);
		return;
	}

	sprintf(args, "%s /d", tmp_filename);

	ShellExecute(m_hWnd, "open",
		str,
		args,
		cwd,
		SW_SHOWNORMAL);

}
/***********************************************************************
 * Launch the 3D explorer program
 *
 * TODO:
 * 	1. Write simulation universe to a temporary file
 *	2. use that filename as argument to program
 *	3. How to cleanup on exit???? (pass -d flag to program)
 */
Launch the 3D explorer program
TODO:
1. Write simulation universe to a temporary file
2. use that filename as argument to program
3.
Launch the 3D explorer program TODO : 1 . Write simulation universe to a temporary file 2 . use that filename as argument to program 3 .
void CevolveView::OnView3D()
{
	CevolveDoc *doc;
	CString str;
	CWinApp *app;
	UNIVERSE *u;
	char cwd[1000], *p;
	char tmp_filename[1000], *tp;
	char args[1000];
	char errbuf[1000];
	char tmp_path[1000];
	char buf[1000];
	int n;
	doc = GetDocument();
	u = doc->universe;
	app = AfxGetApp();
	str = app->GetProfileString("evolve3d", "program");
	strcpy(cwd, str);
	p = strrchr(cwd, '\\');
	if( p == NULL ) {
		p = strrchr(cwd, '/');
	}
	if( p != NULL ) {
		*p = '\0';
	}
	n = GetTempPath(1000, tmp_path);
	if( n == 0 ) {
		sprintf(buf, "Unable to get TempPath");
		str = buf;
		AfxMessageBox(str, MB_OK, 0);
		return;
	}
	tp = _tempnam(tmp_path, "evolve3d_");
	if( tp != NULL ) {
		strcpy(tmp_filename, tp);
		strcat(tmp_filename, ".evolve");
		n = Universe_Write(u, tmp_filename, errbuf);
		if( !n ) {
			sprintf(buf, "%s", errbuf);
			str = buf;
			AfxMessageBox(str, MB_OK, 0);
			return;
		}
	} else {
		sprintf(buf, "Cannot create a unique filename\n" );
		str = buf;
		AfxMessageBox(str, MB_OK, 0);
		return;
	}
	sprintf(args, "%s /d", tmp_filename);
	ShellExecute(m_hWnd, "open",
		str,
		args,
		cwd,
		SW_SHOWNORMAL);
}
void CevolveView :: OnView3D ( ) { CevolveDoc * doc ; CString str ; CWinApp * app ; UNIVERSE * u ; char cwd [ 1000 ] , * p ; char tmp_filename [ 1000 ] , * tp ; char args [ 1000 ] ; char errbuf [ 1000 ] ; char tmp_path [ 1000 ] ; char buf [ 1000 ] ; int n ; doc = GetDocument ( ) ; u = doc -> universe ; app = AfxGetApp ( ) ; str = app -> GetProfileString ( " " , " " ) ; strcpy ( cwd , str ) ; p = strrchr ( cwd , ' \\ ' ) ; if ( p == NULL ) { p = strrchr ( cwd , ' ' ) ; } if ( p != NULL ) { * p = ' \0 ' ; } n = GetTempPath ( 1000 , tmp_path ) ; if ( n == 0 ) { sprintf ( buf , " " ) ; str = buf ; AfxMessageBox ( str , MB_OK , 0 ) ; return ; } tp = _tempnam ( tmp_path , " " ) ; if ( tp != NULL ) { strcpy ( tmp_filename , tp ) ; strcat ( tmp_filename , " " ) ; n = Universe_Write ( u , tmp_filename , errbuf ) ; if ( ! n ) { sprintf ( buf , " " , errbuf ) ; str = buf ; AfxMessageBox ( str , MB_OK , 0 ) ; return ; } } else { sprintf ( buf , " \n " ) ; str = buf ; AfxMessageBox ( str , MB_OK , 0 ) ; return ; } sprintf ( args , " " , tmp_filename ) ; ShellExecute ( m_hWnd , " " , str , args , cwd , SW_SHOWNORMAL ) ; }
Launch the 3D explorer program
 TODO:
      1.
Launch the 3D explorer program TODO : 1 .