Revision: 76299 http://sourceforge.net/p/brlcad/code/76299 Author: brlcad Date: 2020-07-10 05:14:48 +0000 (Fri, 10 Jul 2020) Log Message: ----------- as they appear to be undocumented and not user-facing, move the is_region flag and four following idents to the end of the put_comb and get_comb list. this makes it possible to deconditionalize the put_comb call, and further simplifying the code all around.
Modified Paths: -------------- brlcad/trunk/src/libged/ged_private.h brlcad/trunk/src/libged/get_comb.c brlcad/trunk/src/libged/put_comb.c brlcad/trunk/src/tclscripts/lib/Ged.tcl brlcad/trunk/src/tclscripts/mged/comb.tcl brlcad/trunk/src/tclscripts/mged/helpdevel.tcl Modified: brlcad/trunk/src/libged/ged_private.h =================================================================== --- brlcad/trunk/src/libged/ged_private.h 2020-07-10 05:10:16 UTC (rev 76298) +++ brlcad/trunk/src/libged/ged_private.h 2020-07-10 05:14:48 UTC (rev 76299) @@ -279,10 +279,6 @@ struct directory **dpp, int skip_first); -/* defined in get_comb.c */ -extern void _ged_vls_print_matrix(struct bu_vls *vls, - matp_t matrix); - extern int _ged_get_obj_bounds2(struct ged *gedp, int argc, const char *argv[], Modified: brlcad/trunk/src/libged/get_comb.c =================================================================== --- brlcad/trunk/src/libged/get_comb.c 2020-07-10 05:10:16 UTC (rev 76298) +++ brlcad/trunk/src/libged/get_comb.c 2020-07-10 05:14:48 UTC (rev 76299) @@ -32,6 +32,31 @@ #include "./ged_private.h" +static void +get_comb_print_matrix(struct bu_vls *vls, matp_t matrix) +{ + int k; + char buf[64]; + fastf_t tmp; + + if (!matrix) + return; + + if (bn_mat_is_identity(matrix)) + return; + + for (k = 0; k < 16; k++) { + sprintf(buf, "%g", matrix[k]); + tmp = atof(buf); + if (ZERO(tmp - matrix[k])) + bu_vls_printf(vls, " %g", matrix[k]); + else + bu_vls_printf(vls, " %.12e", matrix[k]); + if ((k&3)==3) bu_vls_printf(vls, " "); + } +} + + int ged_get_comb(struct ged *gedp, int argc, const char *argv[]) { @@ -62,7 +87,6 @@ return GED_ERROR; } - dp = db_lookup(gedp->ged_wdbp->dbip, argv[1], LOOKUP_QUIET); if (dp != RT_DIR_NULL) { @@ -104,12 +128,6 @@ } bu_vls_printf(gedp->ged_result_str, "%s", dp->d_namep); - if (comb->region_flag) { - bu_vls_printf(gedp->ged_result_str, " Yes %ld %ld %ld %ld", - comb->region_id, comb->aircode, comb->GIFTmater, comb->los); - } else { - bu_vls_printf(gedp->ged_result_str, " No"); - } if (comb->rgb_valid) { bu_vls_printf(gedp->ged_result_str, " {%d %d %d}", V3ARGS(comb->rgb)); @@ -144,14 +162,22 @@ } bu_vls_printf(gedp->ged_result_str, " %c %s\t", op, rt_tree_array[i].tl_tree->tr_l.tl_name); - _ged_vls_print_matrix(gedp->ged_result_str, rt_tree_array[i].tl_tree->tr_l.tl_mat); + get_comb_print_matrix(gedp->ged_result_str, rt_tree_array[i].tl_tree->tr_l.tl_mat); bu_vls_printf(gedp->ged_result_str, "\n"); db_free_tree(rt_tree_array[i].tl_tree, &rt_uniresource); } bu_vls_printf(gedp->ged_result_str, "}"); + + if (comb->region_flag) { + bu_vls_printf(gedp->ged_result_str, " Yes %ld %ld %ld %ld", + comb->region_id, comb->aircode, comb->GIFTmater, comb->los); + } else { + bu_vls_printf(gedp->ged_result_str, " No"); + } + } else { - bu_vls_printf(gedp->ged_result_str, "%s Yes %d %d %d %d {} {} No {}", + bu_vls_printf(gedp->ged_result_str, "%s {} {} No {} Yes %d %d %d %d", argv[1], gedp->ged_wdbp->wdb_item_default, gedp->ged_wdbp->wdb_air_default, @@ -163,31 +189,6 @@ } -void -_ged_vls_print_matrix(struct bu_vls *vls, matp_t matrix) -{ - int k; - char buf[64]; - fastf_t tmp; - - if (!matrix) - return; - - if (bn_mat_is_identity(matrix)) - return; - - for (k = 0; k < 16; k++) { - sprintf(buf, "%g", matrix[k]); - tmp = atof(buf); - if (ZERO(tmp - matrix[k])) - bu_vls_printf(vls, " %g", matrix[k]); - else - bu_vls_printf(vls, " %.12e", matrix[k]); - if ((k&3)==3) bu_vls_printf(vls, " "); - } -} - - /* * Local Variables: * tab-width: 8 Modified: brlcad/trunk/src/libged/put_comb.c =================================================================== --- brlcad/trunk/src/libged/put_comb.c 2020-07-10 05:10:16 UTC (rev 76298) +++ brlcad/trunk/src/libged/put_comb.c 2020-07-10 05:14:48 UTC (rev 76299) @@ -471,9 +471,9 @@ int ged_put_comb(struct ged *gedp, int argc, const char *argv[]) { - static const char *usage = "comb_name is_region [ regionID airID materialID los% ] color shader inherit boolean_expr"; - static const char *noregionusage = "comb_name n color shader inherit boolean_expr"; - static const char *regionusage = "comb_name y regionID airID materialID los% color shader inherit boolean_expr"; + static const char *usage = "comb_name color shader inherit boolean_expr is_region [ regionID airID materialID los% ]"; + static const char *noregionusage = "comb_name color shader inherit boolean_expr n"; + static const char *regionusage = "comb_name color shader inherit boolean_expr y regionID airID materialID los%"; const char *cmd_name = argv[0]; const char *comb_name = argv[1]; @@ -485,7 +485,6 @@ const char *inherit = NULL; const char *expression = NULL; - int offset = 0; int save_comb_flag = 0; struct directory *dp = NULL; struct rt_comb_internal *comb = NULL; @@ -543,8 +542,13 @@ RT_COMB_INTERNAL_INIT(comb); } + color = argv[2]; + shader = argv[3]; + inherit = argv[4]; + expression = argv[5]; + /* if is_region */ - if (bu_str_true(argv[2])) { + if (bu_str_true(argv[6])) { if (argc != 11) { bu_vls_printf(gedp->ged_result_str, "region_flag is set, incorrect number of arguments supplied.\n"); bu_vls_printf(gedp->ged_result_str, "Usage: %s %s", cmd_name, regionusage); @@ -552,12 +556,10 @@ } comb->region_flag = 1; - comb->region_id = atoi(argv[3]); - comb->aircode = atoi(argv[4]); - comb->GIFTmater = atoi(argv[5]); - comb->los = atoi(argv[6]); - - offset = 6; + comb->region_id = atoi(argv[7]); + comb->aircode = atoi(argv[8]); + comb->GIFTmater = atoi(argv[9]); + comb->los = atoi(argv[10]); } else { if (argc != 7) { bu_vls_printf(gedp->ged_result_str, "region_flag not set, incorrect number of arguments supplied.\n"); @@ -566,14 +568,8 @@ } comb->region_flag = 0; - offset = 2; } - color = argv[offset + 1]; - shader = argv[offset + 2]; - inherit = argv[offset + 3]; - expression = argv[offset + 4]; - put_rgb_into_comb(comb, color); bu_vls_strcpy(&comb->shader, shader); Modified: brlcad/trunk/src/tclscripts/lib/Ged.tcl =================================================================== --- brlcad/trunk/src/tclscripts/lib/Ged.tcl 2020-07-10 05:10:16 UTC (rev 76298) +++ brlcad/trunk/src/tclscripts/lib/Ged.tcl 2020-07-10 05:14:48 UTC (rev 76299) @@ -6386,7 +6386,7 @@ $help add postscript {{[-f font] [-t title] [-c creator] [-s size in inches] [-l linewidth] file} {creates a postscript file of the current view}} $help add push {{object[s]} {pushes object's path transformations to solids}} $help add put {{object data} {creates an object}} - $help add put_comb {{comb_name is_Region id air material los color shader inherit boolean_expr} {create a combination}} + $help add put_comb {{comb_name color shader inherit boolean_expr is_region regionID airID materialID los%} {create a combination}} $help add putmat {{a/b I|m0 m1 ... m15} {put the specified matrix on a/b}} $help add qray {{subcommand} {get/set query_ray characteristics}} $help add quat {{[a b c d]} {get/set the view orientation as a quaternion}} @@ -6401,7 +6401,7 @@ $help add quat_exp {{quat} {}} $help add quat_log {{quat} {}} $help add qvrot {{x y z angle} {set the view given a direction vector and an angle of rotation}} - $help add r {{region <operation solid>} {create or extend a Region combination}} + $help add r {{region <operation solid>} {create or extend a region combination}} $help add rcodes {{file} {read codes from file}} $help add red {{comb} {edit comb}} $help add regdef {{item air los mat} {get/set region defaults}} Modified: brlcad/trunk/src/tclscripts/mged/comb.tcl =================================================================== --- brlcad/trunk/src/tclscripts/mged/comb.tcl 2020-07-10 05:10:16 UTC (rev 76298) +++ brlcad/trunk/src/tclscripts/mged/comb.tcl 2020-07-10 05:14:48 UTC (rev 76299) @@ -890,6 +890,13 @@ } } + # get color + if {$comb_control($id,color) == ""} { + set color "" + } else { + set color [getRGB $top.colorMB $comb_control($id,color)] + } + if {$comb_control($id,isRegion)} { # this is a region @@ -924,55 +931,15 @@ return 1 } } - - # get color - if {$comb_control($id,color) == ""} { - set color "" - } else { - set color [getRGB $top.colorMB $comb_control($id,color)] - } - - # actually apply the edits to the combination on disk - set ret [catch {put_comb $comb_control($id,name) $comb_control($id,isRegion) \ - $comb_control($id,id) $comb_control($id,air) $comb_control($id,material) \ - $comb_control($id,los) $color $comb_control($id,shader) \ - $comb_control($id,inherit) $comb_control($id,comb)} comb_error] - - if {$ret} { - cad_dialog $::tk::Priv(cad_dialog) $mged_gui($id,screen) \ - "comb_apply: Error"\ - $comb_error\ - "" 0 OK - } - - # set any attributes that we have saved - set ret [catch {eval attr set $comb_control($id,name) $comb_control($id,attrs) } comb_error ] - - if {$ret} { - cad_dialog $::tk::Priv(cad_dialog) $mged_gui($id,screen) \ - "comb_apply: Error"\ - $comb_error\ - "" 0 OK - } - - return $ret } - - - # this is not a region - - # get the color - if {$comb_control($id,color) == ""} { - set color "" - } else { - set color [getRGB $top.colorMB $comb_control($id,color)] + + # actually apply the edits to the combination on disk + set ret [catch {put_comb $comb_control($id,name) $color $comb_control($id,shader) \ + $comb_control($id,inherit) $comb_control($id,comb) $comb_control($id,isRegion) \ + $comb_control($id,id) $comb_control($id,air) $comb_control($id,material) $comb_control($id,los) \ + } comb_error] } - # actually apply the edits to the combination on disk - set ret [catch {put_comb $comb_control($id,name) $comb_control($id,isRegion)\ - $color $comb_control($id,shader) $comb_control($id,inherit)\ - $comb_control($id,comb)} comb_error] - if {$ret} { cad_dialog $::tk::Priv(cad_dialog) $mged_gui($id,screen) \ "comb_apply: Error"\ @@ -1065,37 +1032,28 @@ # save the attributes set comb_control($id,attrs) $tmp_comb_attrs - set comb_control($id,isRegion) [lindex $comb_defs 1] # set all our data variables for the editor + set comb_control($id,color) [lindex $comb_defs 1] + set comb_control($id,shader) [lindex $comb_defs 2] + set comb_control($id,inherit) [lindex $comb_defs 3] + set comb_control($id,comb) [lindex $comb_defs 4] + + set comb_control($id,isRegion) [lindex $comb_defs 5] if {$comb_control($id,isRegion) == "Yes"} { if {$result == 2} { # get default values for ident, air, los, and material set defaults [regdef] - set default_ident [lindex $defaults 1] - set default_air [lindex $defaults 3] - set default_los [lindex $defaults 5] - set default_material [lindex $defaults 7] - - set comb_control($id,id) $default_ident - set comb_control($id,air) $default_air - set comb_control($id,material) $default_material - set comb_control($id,los) $default_los + set comb_control($id,id) [lindex $defaults 1] + set comb_control($id,air) [lindex $defaults 3] + set comb_control($id,material) [lindex $defaults 7] + set comb_control($id,los) [lindex $defaults 5] } else { - set comb_control($id,id) [lindex $comb_defs 2] - set comb_control($id,air) [lindex $comb_defs 3] - set comb_control($id,material) [lindex $comb_defs 4] - set comb_control($id,los) [lindex $comb_defs 5] + set comb_control($id,id) [lindex $comb_defs 6] + set comb_control($id,air) [lindex $comb_defs 7] + set comb_control($id,material) [lindex $comb_defs 8] + set comb_control($id,los) [lindex $comb_defs 9] } - set comb_control($id,color) [lindex $comb_defs 6] - set comb_control($id,shader) [lindex $comb_defs 7] - set comb_control($id,inherit) [lindex $comb_defs 8] - set comb_control($id,comb) [lindex $comb_defs 9] - } else { - set comb_control($id,color) [lindex $comb_defs 2] - set comb_control($id,shader) [lindex $comb_defs 3] - set comb_control($id,inherit) [lindex $comb_defs 4] - set comb_control($id,comb) [lindex $comb_defs 5] } if {$comb_control($id,color) == ""} { Modified: brlcad/trunk/src/tclscripts/mged/helpdevel.tcl =================================================================== --- brlcad/trunk/src/tclscripts/mged/helpdevel.tcl 2020-07-10 05:10:16 UTC (rev 76298) +++ brlcad/trunk/src/tclscripts/mged/helpdevel.tcl 2020-07-10 05:14:48 UTC (rev 76299) @@ -52,7 +52,7 @@ set mged_helpdevel_data(model2view_lu) {{mx my mz} {convert point in model coords (local units) to view coords (local units)}} set mged_helpdevel_data(oed_reset) {{} {reset the parameters for the currently edited matrix}} set mged_helpdevel_data(output_hook) {{[hook_cmd]} {set up to have output from bu_log sent to hook_cmd}} -set mged_helpdevel_data(put_comb) {{comb_name is_Region id air material los color shader inherit boolean_expr} {set combination}} +set mged_helpdevel_data(put_comb) {{comb_name color shader inherit boolean_expr is_region regionID airID materialID los%} {set combination}} set mged_helpdevel_data(put_sed) {{solid parameters} {put the solid parameters into the in-memory (i.e. es_int) solid currently being edited.}} set mged_helpdevel_data(sed_reset) {{} {reset the parameters for the currently edited solid (i.e. es_int)}} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. _______________________________________________ BRL-CAD Source Commits mailing list brlcad-commits@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/brlcad-commits