diff --git a/Fltk/fileDialogs.cpp b/Fltk/fileDialogs.cpp index 57946f56ccc78ca66b0b1f38b9472ca16c309378..ebe2ecafab524990737208c296b4272a11e7b6f4 100644 --- a/Fltk/fileDialogs.cpp +++ b/Fltk/fileDialogs.cpp @@ -954,12 +954,81 @@ int generic_mesh_dialog(const char *name, const char *title, int format, return 0; } - #if defined(HAVE_LIBCGNS) -struct CGNSWriteDialog; +// Forward declarations of some callbacks +void cgnsw_gc_location_cb(Fl_Widget *widget, void *data); +void cgnsw_write_dummy_bc_cb(Fl_Widget *widget, void *data); +void cgnsw_bc_location_cb(Fl_Widget *widget, void *data); +void cgnsw_write_normals_cb(Fl_Widget *widget, void *data); +void cgnsw_normal_source_cb(Fl_Widget *widget, void *data); + +// Pointers to required widgets +struct CGNSWriteDialog +{ + Fl_Window *window; + Fl_Choice *choiceZoneDef; + Fl_Input *inputBaseName; + Fl_Input *inputZoneName; + Fl_Input *inputInterfaceName; + Fl_Input *inputPatchName; + Fl_Round_Button *roundButton0GCatVertex; + Fl_Round_Button *roundButton1GCatFace; + Fl_Check_Button *checkButtonWriteBC; + Fl_Round_Button *roundButton0BCatVertex; + Fl_Round_Button *roundButton1BCatFace; + Fl_Check_Button *checkButtonWriteNormals; + Fl_Round_Button *roundButton0NormalGeo; + Fl_Round_Button *roundButton1NormalElem; + Fl_Choice *choiceVecDim; + Fl_Check_Button *checkButtonUnknownUserDef; + const char *filename; + int status; + void write_all_options() + { + opt_mesh_zone_definition(0, GMSH_SET | GMSH_GUI, choiceZoneDef->value()); + CTX.mesh.cgns_options.baseName = inputBaseName->value(); + CTX.mesh.cgns_options.zoneName = inputZoneName->value(); + CTX.mesh.cgns_options.interfaceName = inputInterfaceName->value(); + CTX.mesh.cgns_options.patchName = inputPatchName->value(); + CTX.mesh.cgns_options.gridConnectivityLocation = + roundButton1GCatFace->value(); + CTX.mesh.cgns_options.writeBC = checkButtonWriteBC->value(); + CTX.mesh.cgns_options.bocoLocation = roundButton1BCatFace->value(); + CTX.mesh.cgns_options.normalSource = (checkButtonWriteNormals->value()) ? + roundButton1NormalElem->value() + 1 : 0; + CTX.mesh.cgns_options.vectorDim = choiceVecDim->value() + 2; + CTX.mesh.cgns_options.writeUserDef = checkButtonUnknownUserDef->value(); + } + void read_all_options() + { + choiceZoneDef->value(CTX.mesh.zone_definition); + inputBaseName->value(CTX.mesh.cgns_options.baseName.c_str()); + inputZoneName->value(CTX.mesh.cgns_options.zoneName.c_str()); + inputInterfaceName->value(CTX.mesh.cgns_options.interfaceName.c_str()); + inputPatchName->value(CTX.mesh.cgns_options.patchName.c_str()); + checkButtonWriteBC->value(CTX.mesh.cgns_options.writeBC); + checkButtonWriteNormals->value(CTX.mesh.cgns_options.normalSource); + choiceVecDim->value(CTX.mesh.cgns_options.vectorDim - 2); + checkButtonUnknownUserDef->value(CTX.mesh.cgns_options.writeUserDef); + + // Call all callbacks to ensure consistent options + cgnsw_gc_location_cb + ((CTX.mesh.cgns_options.gridConnectivityLocation) ? + roundButton1GCatFace : roundButton0GCatVertex, this); + // The order of the next 4 is important + cgnsw_normal_source_cb + ((CTX.mesh.cgns_options.normalSource == 2) ? + roundButton1NormalElem : roundButton0NormalGeo, this); + cgnsw_write_normals_cb(checkButtonWriteNormals, this); + cgnsw_bc_location_cb + ((CTX.mesh.cgns_options.bocoLocation) ? + roundButton1BCatFace : roundButton0BCatVertex, this); + cgnsw_write_dummy_bc_cb(checkButtonWriteBC, this); + } +}; -static void cgnsw_gc_location_cb(Fl_Widget *widget, void *data) +void cgnsw_gc_location_cb(Fl_Widget *widget, void *data) { CGNSWriteDialog *dlg = static_cast<CGNSWriteDialog*>(data); if(widget == dlg->roundButton0GCatVertex) { @@ -972,7 +1041,7 @@ static void cgnsw_gc_location_cb(Fl_Widget *widget, void *data) } } -static void cgnsw_write_dummy_bc_cb(Fl_Widget *widget, void *data) +void cgnsw_write_dummy_bc_cb(Fl_Widget *widget, void *data) { CGNSWriteDialog *dlg = static_cast<CGNSWriteDialog*>(data); if(dlg->checkButtonWriteBC->value()) { @@ -994,7 +1063,7 @@ static void cgnsw_write_dummy_bc_cb(Fl_Widget *widget, void *data) } } -static void cgnsw_bc_location_cb(Fl_Widget *widget, void *data) +void cgnsw_bc_location_cb(Fl_Widget *widget, void *data) { CGNSWriteDialog *dlg = static_cast<CGNSWriteDialog*>(data); if(widget == dlg->roundButton0BCatVertex) { @@ -1012,7 +1081,7 @@ static void cgnsw_bc_location_cb(Fl_Widget *widget, void *data) } } -static void cgnsw_write_normals_cb(Fl_Widget *widget, void *data) +void cgnsw_write_normals_cb(Fl_Widget *widget, void *data) { CGNSWriteDialog *dlg = static_cast<CGNSWriteDialog*>(data); if(dlg->checkButtonWriteNormals->value()) { @@ -1026,7 +1095,7 @@ static void cgnsw_write_normals_cb(Fl_Widget *widget, void *data) } } -static void cgnsw_normal_source_cb(Fl_Widget *widget, void *data) +void cgnsw_normal_source_cb(Fl_Widget *widget, void *data) { CGNSWriteDialog *dlg = static_cast<CGNSWriteDialog*>(data); if(widget == dlg->roundButton0NormalGeo) { @@ -1039,14 +1108,14 @@ static void cgnsw_normal_source_cb(Fl_Widget *widget, void *data) } } -static void cgnsw_defaults_cb(Fl_Widget *widget, void *data) +void cgnsw_defaults_cb(Fl_Widget *widget, void *data) { CGNSWriteDialog *dlg = static_cast<CGNSWriteDialog*>(data); CTX.mesh.cgns_options.setDefaults(); dlg->read_all_options(); } -static void cgnsw_write_cb(Fl_Widget *widget, void *data) +void cgnsw_write_cb(Fl_Widget *widget, void *data) { CGNSWriteDialog *dlg = static_cast<CGNSWriteDialog*>(data); @@ -1059,78 +1128,13 @@ static void cgnsw_write_cb(Fl_Widget *widget, void *data) dlg->status = 1; } -static void cgnsw_cancel_cb(Fl_Widget *widget, void *data) +void cgnsw_cancel_cb(Fl_Widget *widget, void *data) { CGNSWriteDialog *dlg = static_cast<CGNSWriteDialog*>(data); dlg->window->hide(); dlg->status = 0; } -// Pointers to required widgets -struct CGNSWriteDialog -{ - Fl_Window *window; - Fl_Choice *choiceZoneDef; - Fl_Input *inputBaseName; - Fl_Input *inputZoneName; - Fl_Input *inputInterfaceName; - Fl_Input *inputPatchName; - Fl_Round_Button *roundButton0GCatVertex; - Fl_Round_Button *roundButton1GCatFace; - Fl_Check_Button *checkButtonWriteBC; - Fl_Round_Button *roundButton0BCatVertex; - Fl_Round_Button *roundButton1BCatFace; - Fl_Check_Button *checkButtonWriteNormals; - Fl_Round_Button *roundButton0NormalGeo; - Fl_Round_Button *roundButton1NormalElem; - Fl_Choice *choiceVecDim; - Fl_Check_Button *checkButtonUnknownUserDef; - const char *filename; - int status; - void write_all_options() - { - opt_mesh_zone_definition(0, GMSH_SET | GMSH_GUI, choiceZoneDef->value()); - CTX.mesh.cgns_options.baseName = inputBaseName->value(); - CTX.mesh.cgns_options.zoneName = inputZoneName->value(); - CTX.mesh.cgns_options.interfaceName = inputInterfaceName->value(); - CTX.mesh.cgns_options.patchName = inputPatchName->value(); - CTX.mesh.cgns_options.gridConnectivityLocation = - roundButton1GCatFace->value(); - CTX.mesh.cgns_options.writeBC = checkButtonWriteBC->value(); - CTX.mesh.cgns_options.bocoLocation = roundButton1BCatFace->value(); - CTX.mesh.cgns_options.normalSource = (checkButtonWriteNormals->value()) ? - roundButton1NormalElem->value() + 1 : 0; - CTX.mesh.cgns_options.vectorDim = choiceVecDim->value() + 2; - CTX.mesh.cgns_options.writeUserDef = checkButtonUnknownUserDef->value(); - } - void read_all_options() - { - choiceZoneDef->value(CTX.mesh.zone_definition); - inputBaseName->value(CTX.mesh.cgns_options.baseName.c_str()); - inputZoneName->value(CTX.mesh.cgns_options.zoneName.c_str()); - inputInterfaceName->value(CTX.mesh.cgns_options.interfaceName.c_str()); - inputPatchName->value(CTX.mesh.cgns_options.patchName.c_str()); - checkButtonWriteBC->value(CTX.mesh.cgns_options.writeBC); - checkButtonWriteNormals->value(CTX.mesh.cgns_options.normalSource); - choiceVecDim->value(CTX.mesh.cgns_options.vectorDim - 2); - checkButtonUnknownUserDef->value(CTX.mesh.cgns_options.writeUserDef); - - // Call all callbacks to ensure consistent options - cgnsw_gc_location_cb - ((CTX.mesh.cgns_options.gridConnectivityLocation) ? - roundButton1GCatFace : roundButton0GCatVertex, this); - // The order of the next 4 is important - cgnsw_normal_source_cb - ((CTX.mesh.cgns_options.normalSource == 2) ? - roundButton1NormalElem : roundButton0NormalGeo, this); - cgnsw_write_normals_cb(checkButtonWriteNormals, this); - cgnsw_bc_location_cb - ((CTX.mesh.cgns_options.bocoLocation) ? - roundButton1BCatFace : roundButton0BCatVertex, this); - cgnsw_write_dummy_bc_cb(checkButtonWriteBC, this); - } -}; - int cgns_write_dialog(const char *filename) { static CGNSWriteDialog dlg;