Exemplo n.º 1
0
//-----------------------------------------------------------------------------
void ArgsDialog::putArguments()
{
	int len=0;
	for(int i=0;i<10;i++)
			if(a[i]->text().length()>len)
				len = a[i]->text().length();
	wchar_t *str = new wchar_t[len+2];
	for(int i=0;i<10;i++)
	{
		QString s = a[i]->text();
		int j, n = s.length();
		for(j=0;j<n;j++)	str[j] = (s[j]).unicode();
		str[j] = 0;
		parser.AddParam(i, str);
	}
	delete []str;	accept();
}
Exemplo n.º 2
0
//-----------------------------------------------------------------------------
int main(int argc, char **argv)
{
	char ch, iname[256]="";
	mgl_suppress_warn(true);
	while(1)
	{
		ch = getopt(argc, argv, "1:2:3:4:5:6:7:8:9:hL:s:");
		if(ch>='1' && ch<='9')	p.AddParam(ch-'0', optarg);
		else if(ch=='s')
		{
			setlocale(LC_CTYPE, "");
			FILE *fp = fopen(optarg,"r");
			if(fp)
			{
				wchar_t ch;
				while((ch=fgetwc(fp))!=WEOF)	opt.push_back(ch);
				fclose(fp);
			}
		}
		else if(ch=='L')	setlocale(LC_CTYPE, optarg);
		else if(ch=='h' || (ch==-1 && optind>=argc))
		{
			printf("mglview show plot from MGL script or MGLD file.\nCurrent version is 2.%g\n",MGL_VER2);
			printf("Usage:\tmglview [parameter(s)] scriptfile\n");
			printf(
				"\t-1 str       set str as argument $1 for script\n"
				"\t...          ...\n"
				"\t-9 str       set str as argument $9 for script\n"
				"\t-s opt       set MGL script for setting up the plot\n"
				"\t-L loc       set locale to loc\n"
				"\t-            get script from standard input\n"
				"\t-h           print this message\n" );
			ch = 'h';	break;
		}
		else if(ch==-1 && optind<argc)
		{	strncpy(iname, argv[optind][0]=='-'?"":argv[optind],256);	break;	}
	}
	if(ch=='h')	return 0;

	bool mgld=(*iname && iname[strlen(iname)-1]=='d');
	if(!mgld)
	{
		str = opt + L"\n";
		setlocale(LC_CTYPE, "");
		FILE *fp = *iname?fopen(iname,"r"):stdin;
		if(fp)
		{
			wchar_t ch;
			while((ch=fgetwc(fp))!=WEOF)	str.push_back(ch);
			fclose(fp);
		}
		else	{	printf("No file for MGL script\n");	return 0;	}
	}

	mgl_ask_func = mgl_ask_gets;
	mgl_ask_func = mgl_ask_qt;
	mglQT gr(mgld?NULL:show, *iname?iname:"mglview");
	if(mgld)
	{
		gr.Setup(false);
		gr.NewFrame();	setlocale(LC_NUMERIC, "C");
		if(!opt.empty())
		{
			p.Execute(&gr,opt.c_str());
			printf("Setup script: %s\n",gr.Message());
			gr.ImportMGLD(iname,true);
		}
		else	gr.ImportMGLD(iname);
		setlocale(LC_NUMERIC, "");	gr.EndFrame();
		gr.Update();
	}
	if(!mglGlobalMess.empty())	printf("%s",mglGlobalMess.c_str());
	return gr.Run();
}