mirror of
https://github.com/NGSolve/netgen.git
synced 2024-11-11 16:49:16 +05:00
move mesh export formats from ngappinit to Tcl-script
This commit is contained in:
parent
a73594b738
commit
b1ea81b401
@ -244,6 +244,8 @@ loadmeshinifile;
|
||||
}
|
||||
|
||||
|
||||
set meshexportformats [Ng_GetExportFormats]
|
||||
|
||||
.ngmenu.file add command -label "Export Mesh..." \
|
||||
-command {
|
||||
|
||||
@ -261,8 +263,11 @@ loadmeshinifile;
|
||||
} elseif { $exportfiletype == "OpenFOAM 1.5+ Compressed"} {
|
||||
set file [file nativename [tk_chooseDirectory -title "OpenFOAM 1.5+ Mesh Export - Select Case Directory"]]
|
||||
} else {
|
||||
# set file [tk_getSaveFile -filetypes "{ \"$exportfiletype\" {$extension} }" ]
|
||||
set file [tk_getSaveFile -filetypes "{ \"$exportfiletype\" {*}}" ]
|
||||
# set file [tk_getSaveFile -filetypes "{ \"$exportfiletype\" {$extension} }" ]
|
||||
# set file [tk_getSaveFile -filetypes "{ \"$exportfiletype\" {*}}" ]
|
||||
set file [tk_getSaveFile -filetypes $meshexportformats -typevariable exportfiletype]
|
||||
puts "type = $exportfiletype"
|
||||
puts "filename = $file"
|
||||
}
|
||||
|
||||
if {$file != ""} {
|
||||
@ -271,9 +276,12 @@ loadmeshinifile;
|
||||
}
|
||||
|
||||
.ngmenu.file add cascade -label "Export Filetype" -menu .ngmenu.file.filetype
|
||||
|
||||
menu .ngmenu.file.filetype
|
||||
|
||||
foreach exportformat $meshexportformats {
|
||||
.ngmenu.file.filetype add radio -label [lindex $exportformat 0] -variable exportfiletype -command { .ngmenu.file invoke "Export Mesh..." }
|
||||
}
|
||||
|
||||
|
||||
.ngmenu.file add separator
|
||||
|
||||
|
@ -250,7 +250,7 @@ int main(int argc, char ** argv)
|
||||
exit (1);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
// lookup user file formats and insert into format list:
|
||||
NgArray<const char*> userformats;
|
||||
NgArray<const char*> extensions;
|
||||
@ -262,13 +262,13 @@ int main(int argc, char ** argv)
|
||||
for (int i = 1; i <= userformats.Size(); i++)
|
||||
{
|
||||
fstr << ".ngmenu.file.filetype add radio -label \""
|
||||
<< userformats.Get(i) << "\" -variable exportfiletype\n";
|
||||
<< userformats.Get(i) << "\" -variable exportfiletype -command { .ngmenu.file invoke \"Export Mesh...\" } \n";
|
||||
fstr << "lappend meshexportformats { {" << userformats.Get(i) << "} {" << extensions.Get(i) << "} }\n";
|
||||
}
|
||||
|
||||
Tcl_Eval (myinterp, (char*)fstr.str().c_str());
|
||||
Tcl_Eval (myinterp, (char*)fstr.str().c_str());
|
||||
Tcl_SetVar (myinterp, "exportfiletype", exportft, 0);
|
||||
|
||||
*/
|
||||
|
||||
#ifdef SOCKETS
|
||||
Ng_ServerSocketManagerRun();
|
||||
|
20
ng/ngpkg.cpp
20
ng/ngpkg.cpp
@ -346,7 +346,21 @@ namespace netgen
|
||||
}
|
||||
|
||||
|
||||
|
||||
int Ng_GetExportFormats (ClientData clientData,
|
||||
Tcl_Interp * interp,
|
||||
int argc, tcl_const char *argv[])
|
||||
{
|
||||
NgArray<const char*> userformats;
|
||||
NgArray<const char*> extensions;
|
||||
RegisterUserFormats (userformats, extensions);
|
||||
|
||||
ostringstream fstr;
|
||||
for (int i = 1; i <= userformats.Size(); i++)
|
||||
fstr << "{ {" << userformats.Get(i) << "} {" << extensions.Get(i) << "} }\n";
|
||||
|
||||
Tcl_SetResult (interp, const_cast<char*>(fstr.str().c_str()), TCL_VOLATILE);
|
||||
return TCL_OK;
|
||||
}
|
||||
|
||||
|
||||
int Ng_ExportMesh (ClientData clientData,
|
||||
@ -2815,6 +2829,10 @@ void PlayAnimFile(const char* name, int speed, int maxcnt)
|
||||
(ClientData)NULL,
|
||||
(Tcl_CmdDeleteProc*) NULL);
|
||||
|
||||
Tcl_CreateCommand (interp, "Ng_GetExportFormats", Ng_GetExportFormats,
|
||||
(ClientData)NULL,
|
||||
(Tcl_CmdDeleteProc*) NULL);
|
||||
|
||||
Tcl_CreateCommand (interp, "Ng_ExportMesh", Ng_ExportMesh,
|
||||
(ClientData)NULL,
|
||||
(Tcl_CmdDeleteProc*) NULL);
|
||||
|
@ -872,6 +872,7 @@ const char * ngscript[] = {""
|
||||
,"Ng_ReadStatus;\n"
|
||||
,"}\n"
|
||||
,"}\n"
|
||||
,"set meshexportformats [Ng_GetExportFormats]\n"
|
||||
,".ngmenu.file add command -label \"Export Mesh...\" \\\n"
|
||||
,"-command {\n"
|
||||
,"foreach exportformat $meshexportformats {\n"
|
||||
@ -886,7 +887,9 @@ const char * ngscript[] = {""
|
||||
,"} elseif { $exportfiletype == \"OpenFOAM 1.5+ Compressed\"} {\n"
|
||||
,"set file [file nativename [tk_chooseDirectory -title \"OpenFOAM 1.5+ Mesh Export - Select Case Directory\"]]\n"
|
||||
,"} else {\n"
|
||||
,"set file [tk_getSaveFile -filetypes \"{ \\\"$exportfiletype\\\" {*}}\" ]\n"
|
||||
,"set file [tk_getSaveFile -filetypes $meshexportformats -typevariable exportfiletype]\n"
|
||||
,"puts \"type = $exportfiletype\"\n"
|
||||
,"puts \"filename = $file\"\n"
|
||||
,"}\n"
|
||||
,"if {$file != \"\"} {\n"
|
||||
,"Ng_ExportMesh $file $exportfiletype\n"
|
||||
@ -894,6 +897,9 @@ const char * ngscript[] = {""
|
||||
,"}\n"
|
||||
,".ngmenu.file add cascade -label \"Export Filetype\" -menu .ngmenu.file.filetype\n"
|
||||
,"menu .ngmenu.file.filetype\n"
|
||||
,"foreach exportformat $meshexportformats {\n"
|
||||
,".ngmenu.file.filetype add radio -label [lindex $exportformat 0] -variable exportfiletype -command { .ngmenu.file invoke \"Export Mesh...\" }\n"
|
||||
,"}\n"
|
||||
,".ngmenu.file add separator\n"
|
||||
,".ngmenu.file add command -label \"Save Solution...\" \\\n"
|
||||
,"-command {\n"
|
||||
|
Loading…
Reference in New Issue
Block a user