Revision: 77183
http://sourceforge.net/p/brlcad/code/77183
Author: starseeker
Date: 2020-09-19 13:57:12 +0000 (Sat, 19 Sep 2020)
Log Message:
-----------
Replace hardcoded ged command listings with ged_exec
Modified Paths:
--------------
brlcad/trunk/src/qged/cadapp.cpp
brlcad/trunk/src/qged/cadcommands.cpp
Modified: brlcad/trunk/src/qged/cadapp.cpp
===================================================================
--- brlcad/trunk/src/qged/cadapp.cpp 2020-09-19 02:22:22 UTC (rev 77182)
+++ brlcad/trunk/src/qged/cadapp.cpp 2020-09-19 13:57:12 UTC (rev 77183)
@@ -181,6 +181,9 @@
char *lcmd = NULL;
char **largv = NULL;
int largc = 0;
+ const char *ccmd = NULL;
+ int edist = 0;
+ struct bu_vls rmsg = BU_VLS_INIT_ZERO;
if (ged_pointer != GED_NULL && command && command->length() > 0) {
@@ -195,8 +198,7 @@
(*(preprocess_cmd_itr.value()))(&lcommand, (CADApp *)qApp);
}
- ged_cmd_itr = cmd_map.find(cargv0);
- if (ged_cmd_itr != cmd_map.end()) {
+ if (!ged_cmd_valid(cargv0.toLocal8Bit().constData(), NULL)) {
// Prepare libged arguments
lcmd = bu_strdup(lcommand.toLocal8Bit());
largv = (char **)bu_calloc(lcommand.length()/2+1, sizeof(char *),
"cmd_eval argv");
@@ -210,7 +212,7 @@
// text output quite a lot. However, view commands should return
while allowing long
// drawing routines to execute in the background - using something
like Z or B should
// abort drawing and clear the view, but otherwise let it
complete...
- ret = (*(ged_cmd_itr.value()))(ged_pointer, largc, (const char
**)largv);
+ ret = ged_exec(ged_pointer, largc, (const char **)largv);
if (result && bu_vls_strlen(ged_pointer->ged_result_str) > 0) {
*result =
QString(QLatin1String(bu_vls_addr(ged_pointer->ged_result_str)));
@@ -227,6 +229,7 @@
goto postprocess;
}
+ // Not a valid GED command - see if it's an application level command
gui_cmd_itr = gui_cmd_map.find(cargv0);
if (gui_cmd_itr != gui_cmd_map.end()) {
QString args(lcommand);
@@ -235,6 +238,15 @@
goto postprocess;
}
+ // If we didn't find the command either as a ged command or a gui
command,
+ // see if libged has a suggestion.
+ edist = ged_cmd_lookup(&ccmd, cargv0.toLocal8Bit().constData());
+ if (edist <= cargv0.length()/2) {
+ bu_vls_sprintf(&rmsg, "Command \"%s\" not found, did you mean
\"%s\"?\n", cargv0.toLocal8Bit().constData(), ccmd);
+ *result = QString(QLatin1String(bu_vls_cstr(&rmsg)));
+ ret = 1;
+ }
+
postprocess:
// Take care of any results post-processing needed
postprocess_cmd_itr = postprocess_cmd_map.find(cargv0);
@@ -245,6 +257,8 @@
if (ret == -1)
*result = QString("command not found");
}
+
+ bu_vls_free(&rmsg);
return ret;
}
Modified: brlcad/trunk/src/qged/cadcommands.cpp
===================================================================
--- brlcad/trunk/src/qged/cadcommands.cpp 2020-09-19 02:22:22 UTC (rev
77182)
+++ brlcad/trunk/src/qged/cadcommands.cpp 2020-09-19 13:57:12 UTC (rev
77183)
@@ -38,258 +38,6 @@
void cad_register_commands(CADApp *app)
{
- // Geometry Editing (libged) commands
- app->register_command(QString("3ptarb"), ged_3ptarb); //
cmd_ged_more_wrapper
- app->register_command(QString("adc"), ged_adc); // to_view_func
- app->register_command(QString("adjust"), ged_adjust);
- app->register_command(QString("ae"), ged_aet); //
cmd_ged_view_wrapper
- app->register_command(QString("aet"), ged_aet); //
cmd_ged_view_wrapper
- app->register_command(QString("ae2dir"), ged_ae2dir);
- app->register_command(QString("analyze"), ged_analyze); //
cmd_ged_info_wrapper
- app->register_command(QString("annotate"), ged_annotate);
- app->register_command(QString("arb"), ged_arb);
- app->register_command(QString("arced"), ged_arced);
- app->register_command(QString("arot"), ged_arot); //
to_view_func_plus
- app->register_command(QString("attr"), ged_attr);
- app->register_command(QString("bb"), ged_bb);
- app->register_command(QString("bev"), ged_bev);
- app->register_command(QString("bo"), ged_bo);
- app->register_command(QString("bot"), ged_bot);
- app->register_command(QString("bot_condense"), ged_bot_condense);
- app->register_command(QString("bot_decimate"), ged_bot_decimate);
- app->register_command(QString("bot_dump"), ged_bot_dump);
- app->register_command(QString("bot_face_fuse"), ged_bot_face_fuse);
- app->register_command(QString("bot_face_sort"), ged_bot_face_sort);
- app->register_command(QString("bot_flip"), ged_bot_flip);
- app->register_command(QString("bot_fuse"), ged_bot_fuse);
- app->register_command(QString("bot_merge"), ged_bot_merge);
- app->register_command(QString("bot_smooth"), ged_bot_smooth);
- app->register_command(QString("bot_split"), ged_bot_split);
- app->register_command(QString("bot_sync"), ged_bot_sync);
- app->register_command(QString("bot_vertex_fuse"), ged_bot_vertex_fuse);
- app->register_command(QString("brep"), ged_brep); // cmd_ged_view_wrapper
- app->register_command(QString("c"), ged_comb_std);
- app->register_command(QString("cat"), ged_cat); // cmd_ged_info_wrapper
- app->register_command(QString("cc"), ged_cc);
- app->register_command(QString("clone"), ged_clone); // cmd_ged_edit_wrapper
- app->register_command(QString("coil"), ged_coil);
- app->register_command(QString("color"), ged_color);
- app->register_command(QString("comb"), ged_comb);
- app->register_command(QString("comb_color"), ged_comb_color);
- app->register_command(QString("combmem"), ged_combmem);
- app->register_command(QString("constraint"), ged_constraint);
- app->register_command(QString("copyeval"), ged_copyeval);
- app->register_command(QString("copymat"), ged_copymat);
- app->register_command(QString("cp"), ged_copy);
- app->register_command(QString("cpi"), ged_cpi);
- app->register_command(QString("d"), ged_erase); // cmd_ged_erase_wrapper
- app->register_command(QString("db_glob"), ged_glob);
- app->register_command(QString("dbconcat"), ged_concat);
- app->register_command(QString("dbfind"), ged_find); // cmd_ged_info_wrapper
- app->register_command(QString("dbip"), ged_dbip);
- app->register_command(QString("dbversion"), ged_version);
- app->register_command(QString("dbot_dump"), ged_dbot_dump);
- app->register_command(QString("debugbu"), ged_debugbu);
- app->register_command(QString("debugdir"), ged_debugdir);
- app->register_command(QString("debuglib"), ged_debuglib);
- app->register_command(QString("debugnmg"), ged_debugnmg);
- app->register_command(QString("decompose"), ged_decompose);
- app->register_command(QString("delay"), ged_delay);
- app->register_command(QString("dir2ae"), ged_dir2ae);
- app->register_command(QString("draw"), ged_draw); // to_autoview_func
- app->register_command(QString("dump"), ged_dump);
- app->register_command(QString("dup"), ged_dup);
- app->register_command(QString("E"), ged_E); // to_autoview_func
- app->register_command(QString("e"), ged_draw); // to_autoview_func
- app->register_command(QString("eac"), ged_eac); // cmd_ged_view_wrapper
- app->register_command(QString("echo"), ged_echo);
- app->register_command(QString("edarb"), ged_edarb); // to_more_args_func
- app->register_command(QString("edcodes"), ged_edcodes);
- app->register_command(QString("edcolor"), ged_edcolor);
- app->register_command(QString("edcomb"), ged_edcomb);
- app->register_command(QString("edit"), ged_edit);
- app->register_command(QString("edmater"), ged_edmater);
- app->register_command(QString("erase"), ged_erase); //
to_pass_through_and_refresh_func
- app->register_command(QString("ev"), ged_ev); // to_autoview_func
- app->register_command(QString("expand"), ged_expand);
- app->register_command(QString("exists"), ged_exists);
- app->register_command(QString("eye"), ged_eye); // cmd_ged_view_wrapper
- app->register_command(QString("eye_pos"), ged_eye_pos); //
cmd_ged_view_wrapper
- app->register_command(QString("eye_pt"), ged_eye); // cmd_ged_view_wrapper
- app->register_command(QString("facetize"), ged_facetize);
- app->register_command(QString("fb2pix"), ged_fb2pix); // to_view_func
- app->register_command(QString("fbclear"), ged_fbclear); // to_view_func
- app->register_command(QString("form"), ged_form);
- app->register_command(QString("fracture"), ged_fracture);
- app->register_command(QString("g"), ged_group);
- app->register_command(QString("gdiff"), ged_gdiff);
- app->register_command(QString("get"), ged_get);
- app->register_command(QString("get_autoview"), ged_get_autoview);
- app->register_command(QString("get_bot_edges"), ged_get_bot_edges);
- app->register_command(QString("get_comb"), ged_get_comb);
- app->register_command(QString("get_dbip"), ged_dbip);
- app->register_command(QString("get_eyemodel"), ged_get_eyemodel);
- app->register_command(QString("get_type"), ged_get_type);
- app->register_command(QString("glob"), ged_glob);
- app->register_command(QString("gqa"), ged_gqa); // cmd_ged_gqa
- app->register_command(QString("graph"), ged_graph);
- app->register_command(QString("grid"), ged_grid);
- app->register_command(QString("grid2model_lu"), ged_grid2model_lu); //
to_view_func_less
- app->register_command(QString("grid2view_lu"), ged_grid2view_lu); //
to_view_func_less
- app->register_command(QString("group"), ged_group);
- app->register_command(QString("hide"), ged_hide);
- app->register_command(QString("how"), ged_how);
- app->register_command(QString("human"), ged_human);
- app->register_command(QString("i"), ged_instance);
- app->register_command(QString("idents"), ged_tables);
- app->register_command(QString("illum"), ged_illum); //
to_pass_through_and_refresh_func
- app->register_command(QString("importFg4Section"), ged_importFg4Section);
- app->register_command(QString("in"), ged_in); //cmd_ged_in
- app->register_command(QString("inside"), ged_inside); //cmd_ged_inside //
to_more_args_func
- app->register_command(QString("item"), ged_item);
- app->register_command(QString("isize"), ged_isize); //to_view_func
- app->register_command(QString("joint"), ged_joint);
- app->register_command(QString("joint2"), ged_joint2);
- app->register_command(QString("keep"), ged_keep);
- app->register_command(QString("keypoint"), ged_keypoint); // to_view_func
- app->register_command(QString("kill"), ged_kill); // cmd_ged_erase_wrapper
- app->register_command(QString("killall"), ged_killall); //
cmd_ged_erase_wrapper
- app->register_command(QString("killrefs"), ged_killrefs); //
cmd_ged_erase_wrapper
- app->register_command(QString("killtree"), ged_killtree); //
cmd_ged_erase_wrapper
- app->register_command(QString("l"), ged_list); // cmd_ged_info_wrapper
- app->register_command(QString("listeval"), ged_pathsum);
- app->register_command(QString("loadview"), ged_loadview); //
cmd_ged_view_wrapper
- app->register_command(QString("lod"), ged_lod);
- app->register_command(QString("log"), ged_log);
- app->register_command(QString("lookat"), ged_lookat); //
cmd_ged_view_wrapper
- app->register_command(QString("ls"), ged_ls);
- app->register_command(QString("lt"), ged_lt);
- app->register_command(QString("m2v_point"), ged_m2v_point);
- app->register_command(QString("make_name"), ged_make_name);
- app->register_command(QString("make_pnts"), ged_make_pnts); //
cmd_ged_more_wrapper
- app->register_command(QString("match"), ged_match);
- app->register_command(QString("mater"), ged_mater);
- app->register_command(QString("mirror"), ged_mirror); // libtclcad calls
to_mirror??
- app->register_command(QString("model2grid_lu"), ged_model2grid_lu);
- app->register_command(QString("model2view"), ged_model2view);
- app->register_command(QString("model2view_lu"), ged_model2view_lu);
- app->register_command(QString("move_arb_edge"), ged_move_arb_edge);
- app->register_command(QString("move_arb_face"), ged_move_arb_face);
- app->register_command(QString("mv"), ged_move);
- app->register_command(QString("mvall"), ged_move_all);
- app->register_command(QString("nirt"), ged_nirt);
- app->register_command(QString("nmg_collapse"), ged_nmg_collapse);
- app->register_command(QString("nmg_fix_normals"), ged_nmg_fix_normals);
- app->register_command(QString("nmg_simplify"), ged_nmg_simplify);
- app->register_command(QString("ocenter"), ged_ocenter);
- app->register_command(QString("open"), ged_reopen); //
to_pass_through_and_refresh_func
- app->register_command(QString("orientation"), ged_orient); //
cmd_ged_view_wrapper
- app->register_command(QString("orotate"), ged_orotate);
- app->register_command(QString("oscale"), ged_oscale);
- app->register_command(QString("otranslate"), ged_otranslate);
- app->register_command(QString("overlay"), ged_overlay); //to_autoview_func
- app->register_command(QString("pathlist"), ged_pathlist);
- app->register_command(QString("paths"), ged_pathsum);
- app->register_command(QString("perspective"), ged_perspective);
- app->register_command(QString("pix2fb"), ged_pix2fb); // to_view_func
- app->register_command(QString("plot"), ged_plot);
- app->register_command(QString("png"), ged_png); // also a to_png in
libtclcad...
- app->register_command(QString("pngwf"), ged_png); // to_view_func
- app->register_command(QString("pov"), ged_pmat);
- app->register_command(QString("prcolor"), ged_prcolor);
- app->register_command(QString("prefix"), ged_prefix);
- app->register_command(QString("preview"), ged_preview); //
cmd_ged_dm_wrapper
- app->register_command(QString("protate"), ged_protate);
- app->register_command(QString("ps"), ged_ps);
- app->register_command(QString("pscale"), ged_pscale);
- app->register_command(QString("pset"), ged_pset);
- app->register_command(QString("ptranslate"), ged_ptranslate);
- app->register_command(QString("pull"), ged_pull);
- app->register_command(QString("push"), ged_push);
- app->register_command(QString("put"), ged_put);
- app->register_command(QString("put_comb"), ged_put_comb);
- app->register_command(QString("putmat"), ged_putmat);
- app->register_command(QString("qray"), ged_qray);
- app->register_command(QString("quat"), ged_quat);
- app->register_command(QString("qvrot"), ged_qvrot); // cmd_ged_view_wrapper
- app->register_command(QString("r"), ged_region);
- app->register_command(QString("rect"), ged_rect);
- app->register_command(QString("red"), ged_red);
- app->register_command(QString("rcodes"), ged_rcodes);
- app->register_command(QString("regdef"), ged_regdef);
- app->register_command(QString("regions"), ged_tables);
- app->register_command(QString("rfarb"), ged_rfarb);
- app->register_command(QString("rm"), ged_remove); //
to_pass_through_and_refresh_func
- app->register_command(QString("rmap"), ged_rmap);
- app->register_command(QString("rmat"), ged_rmat); // to_view_func
- app->register_command(QString("rmater"), ged_rmater);
- app->register_command(QString("rot"), ged_rot); // to_view_func_plus
- app->register_command(QString("rot_about"), ged_rotate_about); //
to_view_func
- app->register_command(QString("rot_point"), ged_rot_point); // to_view_func
- app->register_command(QString("rotate_arb_face"), ged_rotate_arb_face);
- app->register_command(QString("rrt"), ged_rrt); // to_view_func
- app->register_command(QString("rselect"), ged_rselect); // to_view_func
- app->register_command(QString("rt"), ged_rt); // to_view_func
- app->register_command(QString("rtabort"), ged_rtabort);
- app->register_command(QString("rtarea"), ged_rt); // to_view_func
- app->register_command(QString("rtcheck"), ged_rtcheck); // to_view_func
- app->register_command(QString("rtedge"), ged_rt); // to_view_func
- app->register_command(QString("rtweight"), ged_rt); // to_view_func
- app->register_command(QString("rtwizard"), ged_rtwizard); // to_view_func
- app->register_command(QString("savekey"), ged_savekey);
- app->register_command(QString("saveview"), ged_saveview);
- app->register_command(QString("sca"), ged_scale); // to_view_func_plus
- app->register_command(QString("screengrab"), ged_screen_grab); //
cmd_ged_dm_wrapper
- app->register_command(QString("search"), ged_search);
- app->register_command(QString("select"), ged_select); //to_view_func
- app->register_command(QString("set_output_script"), ged_set_output_script);
- app->register_command(QString("set_transparency"), ged_set_transparency);
- app->register_command(QString("set_uplotOutputMode"),
ged_set_uplotOutputMode);
- app->register_command(QString("setview"), ged_setview); //to_view_func_plus
- app->register_command(QString("shaded_mode"), ged_shaded_mode);
- app->register_command(QString("shader"), ged_shader);
- app->register_command(QString("shells"), ged_shells);
- app->register_command(QString("showmats"), ged_showmats);
- app->register_command(QString("size"), ged_size);
- app->register_command(QString("simulate"), ged_simulate); //
cmd_ged_simulate_wrapper
- app->register_command(QString("slew"), ged_slew);
- app->register_command(QString("solid_report"), ged_solid_report);
- app->register_command(QString("solids"), ged_tables);
- app->register_command(QString("solids_on_ray"), ged_solids_on_ray);
- app->register_command(QString("summary"), ged_summary);
- app->register_command(QString("sync"), ged_sync);
- app->register_command(QString("t"), ged_ls);
- app->register_command(QString("tire"), ged_tire);
- app->register_command(QString("title"), ged_title);
- app->register_command(QString("tol"), ged_tol);
- app->register_command(QString("tops"), ged_tops);
- app->register_command(QString("tree"), ged_tree);
- app->register_command(QString("unhide"), ged_unhide);
- app->register_command(QString("units"), ged_units);
- app->register_command(QString("v2m_point"), ged_v2m_point);
- app->register_command(QString("vdraw"), ged_vdraw); //
to_pass_through_and_refresh_func
- app->register_command(QString("version"), ged_version);
- app->register_command(QString("view"), ged_view_func); // to_view_func_plus
- app->register_command(QString("view2grid_lu"), ged_view2grid_lu);
- app->register_command(QString("view2model"), ged_view2model); //
to_view_func_less
- app->register_command(QString("view2model_lu"), ged_view2model_lu); //
to_view_func_less
- app->register_command(QString("view2model_vec"), ged_view2model_vec); //
to_view_func_less
- app->register_command(QString("viewdir"), ged_viewdir);
- app->register_command(QString("vnirt"), ged_vnirt); // to_view_func
- app->register_command(QString("voxelize"), ged_voxelize);
- app->register_command(QString("wcodes"), ged_wcodes);
- app->register_command(QString("whatid"), ged_whatid);
- app->register_command(QString("which_shader"), ged_which_shader);
- app->register_command(QString("whichair"), ged_which);
- app->register_command(QString("whichid"), ged_which);
- app->register_command(QString("who"), ged_who);
- app->register_command(QString("wmater"), ged_wmater);
- app->register_command(QString("x"), ged_solid_report);
- app->register_command(QString("xpush"), ged_xpush);
- app->register_command(QString("ypr"), ged_ypr);
- app->register_command(QString("zap"), ged_zap); //
to_pass_through_and_refresh_func
- app->register_command(QString("zoom"), ged_zoom); //
to_pass_through_and_refresh_func
-
// GUI commands
app->register_gui_command(QString("man"), cad_man_view);
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
_______________________________________________
BRL-CAD Source Commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-commits