PageRenderTime 85ms CodeModel.GetById 15ms RepoModel.GetById 0ms app.codeStats 1ms

/brlcad/tags/rel-7-0-2/src/mged/chgview.c

https://bitbucket.org/vrrm/brl-cad-copy-for-fast-history-browsing-in-git
C | 2056 lines | 1498 code | 359 blank | 199 comment | 336 complexity | 0e8844ad888158a4901a41d39b50ef7c MD5 | raw file
Possible License(s): GPL-2.0, LGPL-2.0, LGPL-2.1, Apache-2.0, AGPL-3.0, LGPL-3.0, GPL-3.0, MPL-2.0-no-copyleft-exception, CC-BY-SA-3.0, 0BSD, BSD-3-Clause
  1. /* C H G V I E W . C
  2. * BRL-CAD
  3. *
  4. * Copyright (c) 1985-2004 United States Government as represented by
  5. * the U.S. Army Research Laboratory.
  6. *
  7. * This program is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU General Public License as
  9. * published by the Free Software Foundation; either version 2 of the
  10. * License, or (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful, but
  13. * WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this file; see the file named COPYING for more
  19. * information.
  20. */
  21. /** @file chgview.c
  22. *
  23. * Functions -
  24. * f_center (DEBUG) force view center
  25. * f_vrot (DEBUG) force view rotation
  26. * f_view (DEBUG) force view size
  27. * f_blast zap the display, then edit anew
  28. * f_edit edit something (add to visible display)
  29. * f_evedit Evaluated edit something (add to visible display)
  30. * f_delobj delete an object or several from the display
  31. * f_debug (DEBUG) print solid info?
  32. * f_regdebug toggle debugging state
  33. * cmd_list list object information
  34. * f_zap zap the display -- everything dropped
  35. * f_status print view info
  36. * f_fix fix display processor after hardware error
  37. * eraseobj Drop an object from the visible list
  38. * pr_schain Print info about visible list
  39. * f_ill illuminate the named object
  40. * f_sed simulate pressing "solid edit" then illuminate
  41. * f_knob simulate knob twist
  42. * f_slewview Slew the view
  43. * slewview guts for f_setview
  44. * f_setview Set the current view
  45. * setview guts for f_setview
  46. * usejoy Apply joystick to viewing perspective
  47. * absview_v Absolute view rotation about view center
  48. * f_vrot_center Set the center of rotation -- not ready yet
  49. * cmd_getknob returns knob/slider value
  50. * f_svbase Set view base references (i.e. i_Viewscale and orig_pos)
  51. * mged_svbase Guts for f_svbase
  52. * mged_tran Guts for f_tran
  53. * f_qvrot Set view from direction vector and twist angle
  54. * f_orientation Set current view direction from a quaternion
  55. * f_zoom zoom view
  56. * mged_zoom guts for f_zoom
  57. * abs_zoom absolute zoom
  58. * f_tol set or display tolerance
  59. * knob_tran handle translations for f_knob
  60. * f_aetview set view using azimuth, elevation and twist angles
  61. *
  62. * Author -
  63. * Michael John Muuss
  64. *
  65. * Source -
  66. * SECAD/VLD Computing Consortium, Bldg 394
  67. * The U. S. Army Ballistic Research Laboratory
  68. * Aberdeen Proving Ground, Maryland 21005
  69. */
  70. #ifndef lint
  71. static const char RCSid[] = "@(#)$Header$ (BRL)";
  72. #endif
  73. #include "common.h"
  74. #include <stdio.h>
  75. #ifdef HAVE_STRING_H
  76. #include <string.h>
  77. #else
  78. #include <strings.h>
  79. #endif
  80. #include <signal.h>
  81. #include <math.h>
  82. #include "machine.h"
  83. #include "bu.h"
  84. #include "vmath.h"
  85. #include "bn.h"
  86. #include "mater.h"
  87. #include "raytrace.h"
  88. #include "nmg.h"
  89. #include "./sedit.h"
  90. #include "./ged.h"
  91. #include "./mged_solid.h"
  92. #include "./mged_dm.h"
  93. #include "./cmd.h"
  94. #include "../librt/debug.h" /* XXX */
  95. extern struct db_tree_state mged_initial_tree_state; /* dodraw.c */
  96. extern void color_soltab(void);
  97. extern void set_absolute_tran(void); /* defined in set.c */
  98. extern void set_absolute_view_tran(void); /* defined in set.c */
  99. extern void set_absolute_model_tran(void); /* defined in set.c */
  100. void solid_list_callback(void);
  101. void knob_update_rate_vars(void);
  102. int mged_svbase(void);
  103. int mged_vrot(char origin, fastf_t *newrot);
  104. int mged_zoom(double val);
  105. void mged_center(fastf_t *center);
  106. static void abs_zoom(void);
  107. void usejoy(double xangle, double yangle, double zangle);
  108. int knob_rot(vect_t rvec, char origin, int mf, int vf, int ef);
  109. int knob_tran(fastf_t *tvec, int model_flag, int view_flag, int edit_flag);
  110. int mged_etran(struct view_obj *vop, Tcl_Interp *interp, char coords, vect_t tvec);
  111. int mged_mtran(const fastf_t *tvec);
  112. int mged_otran(const fastf_t *tvec);
  113. int mged_vtran(const fastf_t *tvec);
  114. int mged_tran(fastf_t *tvec);
  115. #ifndef M_SQRT2
  116. #define M_SQRT2 1.41421356237309504880
  117. #endif
  118. #ifndef M_SQRT2_DIV2
  119. #define M_SQRT2_DIV2 0.70710678118654752440
  120. #endif
  121. extern vect_t curr_e_axes_pos; /* from edsol.c */
  122. extern long nvectors; /* from dodraw.c */
  123. extern struct bn_tol mged_tol; /* from ged.c */
  124. extern vect_t e_axes_pos;
  125. fastf_t ar_scale_factor = GED_MAX / ABS_ROT_FACTOR;
  126. fastf_t rr_scale_factor = GED_MAX / RATE_ROT_FACTOR;
  127. fastf_t adc_angle_scale_factor = GED_MAX / ADC_ANGLE_FACTOR;
  128. vect_t edit_absolute_model_rotate;
  129. vect_t edit_absolute_object_rotate;
  130. vect_t edit_absolute_view_rotate;
  131. vect_t last_edit_absolute_model_rotate;
  132. vect_t last_edit_absolute_object_rotate;
  133. vect_t last_edit_absolute_view_rotate;
  134. vect_t edit_rate_model_rotate;
  135. vect_t edit_rate_object_rotate;
  136. vect_t edit_rate_view_rotate;
  137. int edit_rateflag_model_rotate;
  138. int edit_rateflag_object_rotate;
  139. int edit_rateflag_view_rotate;
  140. vect_t edit_absolute_model_tran;
  141. vect_t edit_absolute_view_tran;
  142. vect_t last_edit_absolute_model_tran;
  143. vect_t last_edit_absolute_view_tran;
  144. vect_t edit_rate_model_tran;
  145. vect_t edit_rate_view_tran;
  146. int edit_rateflag_model_tran;
  147. int edit_rateflag_view_tran;
  148. fastf_t edit_absolute_scale;
  149. fastf_t edit_rate_scale;
  150. int edit_rateflag_scale;
  151. char edit_rate_model_origin;
  152. char edit_rate_object_origin;
  153. char edit_rate_view_origin;
  154. char edit_rate_coords;
  155. struct dm_list *edit_rate_mr_dm_list;
  156. struct dm_list *edit_rate_or_dm_list;
  157. struct dm_list *edit_rate_vr_dm_list;
  158. struct dm_list *edit_rate_mt_dm_list;
  159. struct dm_list *edit_rate_vt_dm_list;
  160. struct bu_vls edit_info_vls;
  161. struct bu_vls edit_rate_model_tran_vls[3];
  162. struct bu_vls edit_rate_view_tran_vls[3];
  163. struct bu_vls edit_rate_model_rotate_vls[3];
  164. struct bu_vls edit_rate_object_rotate_vls[3];
  165. struct bu_vls edit_rate_view_rotate_vls[3];
  166. struct bu_vls edit_rate_scale_vls;
  167. struct bu_vls edit_absolute_model_tran_vls[3];
  168. struct bu_vls edit_absolute_view_tran_vls[3];
  169. struct bu_vls edit_absolute_model_rotate_vls[3];
  170. struct bu_vls edit_absolute_object_rotate_vls[3];
  171. struct bu_vls edit_absolute_view_rotate_vls[3];
  172. struct bu_vls edit_absolute_scale_vls;
  173. double mged_abs_tol;
  174. double mged_rel_tol = 0.01; /* 1%, by default */
  175. double mged_nrm_tol; /* normal ang tol, radians */
  176. /* Delete an object or several objects from the display */
  177. /* Format: d object1 object2 .... objectn */
  178. int
  179. cmd_erase(ClientData clientData,
  180. Tcl_Interp *interp,
  181. int argc,
  182. char **argv)
  183. {
  184. #if 1
  185. int ret;
  186. CHECK_DBI_NULL;
  187. ret = dgo_erase_cmd(dgop, interp, argc, argv);
  188. solid_list_callback();
  189. update_views = 1;
  190. return ret;
  191. #else
  192. CHECK_DBI_NULL;
  193. if (argc < 2) {
  194. struct bu_vls vls;
  195. bu_vls_init(&vls);
  196. bu_vls_printf(&vls, "help %s", argv[0]);
  197. Tcl_Eval(interp, bu_vls_addr(&vls));
  198. bu_vls_free(&vls);
  199. return TCL_ERROR;
  200. }
  201. eraseobjpath(interp, argc-1, argv+1, LOOKUP_NOISY, 0);
  202. solid_list_callback();
  203. return TCL_OK;
  204. #endif
  205. }
  206. int
  207. cmd_erase_all(ClientData clientData,
  208. Tcl_Interp *interp,
  209. int argc,
  210. char **argv)
  211. {
  212. #if 1
  213. int ret;
  214. CHECK_DBI_NULL;
  215. ret = dgo_erase_all_cmd(dgop, interp, argc, argv);
  216. solid_list_callback();
  217. update_views = 1;
  218. return ret;
  219. #else
  220. CHECK_DBI_NULL;
  221. if(argc < 2){
  222. struct bu_vls vls;
  223. bu_vls_init(&vls);
  224. bu_vls_printf(&vls, "help %s", argv[0]);
  225. Tcl_Eval(interp, bu_vls_addr(&vls));
  226. bu_vls_free(&vls);
  227. return TCL_ERROR;
  228. }
  229. eraseobjpath(interp, argc-1, argv+1, LOOKUP_NOISY, 1);
  230. solid_list_callback();
  231. return TCL_OK;
  232. #endif
  233. }
  234. /* DEBUG -- force view center */
  235. /* Format: C x y z */
  236. int
  237. cmd_center(ClientData clientData,
  238. Tcl_Interp *interp,
  239. int argc,
  240. char **argv)
  241. {
  242. int ret;
  243. CHECK_DBI_NULL;
  244. if ((ret = vo_center_cmd(view_state->vs_vop, interp, argc, argv)) == TCL_OK && argc > 1)
  245. (void)mged_svbase();
  246. return ret;
  247. }
  248. void
  249. mged_center(point_t center)
  250. {
  251. vo_center(view_state->vs_vop, interp, center);
  252. (void)mged_svbase();
  253. }
  254. /* DEBUG -- force viewsize */
  255. /* Format: view size */
  256. int
  257. cmd_size(ClientData clientData,
  258. Tcl_Interp *interp,
  259. int argc,
  260. char **argv)
  261. {
  262. int ret;
  263. CHECK_DBI_NULL;
  264. if ((ret = vo_size_cmd(view_state->vs_vop, interp, argc, argv)) == TCL_OK && argc > 1) {
  265. view_state->vs_absolute_scale = 1.0 - view_state->vs_vop->vo_scale / view_state->vs_i_Viewscale;
  266. if (view_state->vs_absolute_scale < 0.0)
  267. view_state->vs_absolute_scale /= 9.0;
  268. if (view_state->vs_absolute_tran[X] != 0.0 ||
  269. view_state->vs_absolute_tran[Y] != 0.0 ||
  270. view_state->vs_absolute_tran[Z] != 0.0)
  271. set_absolute_tran();
  272. }
  273. return ret;
  274. }
  275. #if 0
  276. /* XXX until NMG support is complete,
  277. * XXX the old Big-E command is retained in all its glory in
  278. * XXX the file proc_reg.c, including the command processing.
  279. */
  280. /*
  281. * F _ E V E D I T
  282. *
  283. * The "Big E" command.
  284. * Evaluated Edit something (add to visible display)
  285. * Usage: E object(s)
  286. */
  287. int
  288. f_evedit(clientData, interp, argc, argv)
  289. ClientData clientData;
  290. Tcl_Interp *interp;
  291. int argc;
  292. char **argv;
  293. {
  294. if(argc < 2){
  295. struct bu_vls vls;
  296. bu_vls_init(&vls);
  297. bu_vls_printf(&vls, "help E");
  298. Tcl_Eval(interp, bu_vls_addr(&vls));
  299. bu_vls_free(&vls);
  300. return TCL_ERROR;
  301. }
  302. return edit_com( argc, argv, 2, 1 );
  303. }
  304. #endif
  305. /*
  306. * S I Z E _ R E S E T
  307. *
  308. * Reset view size and view center so that all solids in the solid table
  309. * are in view.
  310. * Caller is responsible for calling new_mats().
  311. */
  312. void
  313. size_reset(void)
  314. {
  315. dgo_autoview(dgop, view_state->vs_vop, interp);
  316. view_state->vs_i_Viewscale = view_state->vs_vop->vo_scale;
  317. }
  318. /*
  319. * E D I T _ C O M
  320. *
  321. * B and e commands use this area as common
  322. */
  323. int
  324. edit_com(int argc,
  325. char **argv,
  326. int kind,
  327. int catch_sigint)
  328. {
  329. register struct dm_list *dmlp;
  330. register struct dm_list *save_dmlp;
  331. register struct cmd_list *save_cmd_list;
  332. int ret;
  333. int initial_blank_screen;
  334. int attr_flag=0;
  335. int oflag=1;
  336. int i;
  337. int last_opt=0;
  338. struct bu_vls vls;
  339. CHECK_DBI_NULL;
  340. initial_blank_screen = BU_LIST_IS_EMPTY(&dgop->dgo_headSolid);
  341. /* check args for "-A" (attributes) and "-o" */
  342. bu_vls_init( &vls );
  343. bu_vls_strcpy( &vls, argv[0] );
  344. for( i=1 ; i<argc ; i++ ) {
  345. char *ptr_A=NULL;
  346. char *ptr_o=NULL;
  347. char *c;
  348. if( *argv[i] != '-' ) break;
  349. if( (ptr_A=strchr( argv[i], 'A' )) ) attr_flag = 1;
  350. if( (ptr_o=strchr( argv[i], 'o' )) ) oflag = 2;
  351. last_opt = i;
  352. if( !ptr_A && !ptr_o ) {
  353. bu_vls_putc( &vls, ' ' );
  354. bu_vls_strcat( &vls, argv[i] );
  355. continue;
  356. }
  357. if( strlen( argv[i] ) == (1 + (ptr_A != NULL) + (ptr_o != NULL))) {
  358. /* argv[i] is just a "-A" or "-o" */
  359. continue;
  360. }
  361. /* copy args other than "-A" or "-o" */
  362. bu_vls_putc( &vls, ' ' );
  363. c = argv[i];
  364. while( *c != '\0' ) {
  365. if( *c != 'A' && *c != 'o' ) {
  366. bu_vls_putc( &vls, *c );
  367. }
  368. c++;
  369. }
  370. }
  371. if( attr_flag ) {
  372. /* args are attribute name/value pairs */
  373. struct bu_attribute_value_set avs;
  374. int max_count=0;
  375. int remaining_args=0;
  376. int new_argc=0;
  377. char **new_argv=NULL;
  378. struct bu_ptbl *tbl;
  379. remaining_args = argc - last_opt - 1;;
  380. if( remaining_args < 2 || remaining_args%2 ) {
  381. bu_log( "Error: must have even number of arguments (name/value pairs)\n" );
  382. return TCL_ERROR;
  383. }
  384. bu_avs_init( &avs, (argc - last_opt)/2, "edit_com avs" );
  385. i = 1;
  386. while( i < argc ) {
  387. if( *argv[i] == '-' ) {
  388. i++;
  389. continue;
  390. }
  391. /* this is a name/value pair */
  392. if( oflag == 2 ) {
  393. bu_avs_add_nonunique( &avs, argv[i], argv[i+1] );
  394. } else {
  395. bu_avs_add( &avs, argv[i], argv[i+1] );
  396. }
  397. i += 2;
  398. }
  399. tbl = db_lookup_by_attr( dbip, DIR_REGION | DIR_SOLID | DIR_COMB, &avs, oflag );
  400. bu_avs_free( &avs );
  401. if( !tbl ) {
  402. bu_log( "Error: db_lookup_by_attr() failed!!\n" );
  403. bu_vls_free( &vls );
  404. return TCL_ERROR;
  405. }
  406. for( i=0 ; i<BU_PTBL_LEN( tbl ) ; i++ ) {
  407. struct directory *dp;
  408. dp = (struct directory *)BU_PTBL_GET( tbl, i );
  409. bu_vls_putc( &vls, ' ' );
  410. bu_vls_strcat( &vls, dp->d_namep );
  411. }
  412. max_count = BU_PTBL_LEN( tbl ) + last_opt + 2;
  413. bu_ptbl_free( tbl );
  414. bu_free( (char *)tbl, "edit_com ptbl" );
  415. new_argv = (char **)bu_calloc( max_count, sizeof( char *), "edit_com new_argv" );
  416. new_argc = bu_argv_from_string( new_argv, max_count, bu_vls_addr( &vls ) );
  417. if ((ret = dgo_draw_cmd(dgop, interp, new_argc, new_argv, kind)) != TCL_OK) {
  418. bu_vls_free( &vls );
  419. bu_free( (char *)new_argv, "edit_com new_argv" );
  420. return ret;
  421. }
  422. bu_vls_free( &vls );
  423. bu_free( (char *)new_argv, "edit_com new_argv" );
  424. } else {
  425. bu_vls_free( &vls );
  426. if ((ret = dgo_draw_cmd(dgop, interp, argc, argv, kind)) != TCL_OK)
  427. return ret;
  428. }
  429. update_views = 1;
  430. save_dmlp = curr_dm_list;
  431. save_cmd_list = curr_cmd_list;
  432. FOR_ALL_DISPLAYS(dmlp, &head_dm_list.l) {
  433. curr_dm_list = dmlp;
  434. if (curr_dm_list->dml_tie)
  435. curr_cmd_list = curr_dm_list->dml_tie;
  436. else
  437. curr_cmd_list = &head_cmd_list;
  438. /* If we went from blank screen to non-blank, resize */
  439. if (mged_variables->mv_autosize && initial_blank_screen &&
  440. BU_LIST_NON_EMPTY(&dgop->dgo_headSolid)) {
  441. struct view_ring *vrp;
  442. dgo_autoview(dgop, view_state->vs_vop, interp);
  443. (void)mged_svbase();
  444. for (BU_LIST_FOR(vrp, view_ring, &view_state->vs_headView.l))
  445. vrp->vr_scale = view_state->vs_vop->vo_scale;
  446. }
  447. }
  448. curr_dm_list = save_dmlp;
  449. curr_cmd_list = save_cmd_list;
  450. return TCL_OK;
  451. }
  452. int
  453. emuves_com( int argc, char **argv )
  454. {
  455. int i;
  456. struct bu_ptbl *tbl;
  457. struct bu_attribute_value_set avs;
  458. char **objs;
  459. int ret;
  460. int num_opts=0;
  461. CHECK_DBI_NULL;
  462. if( argc < 2 ) {
  463. struct bu_vls vls;
  464. bu_vls_init(&vls);
  465. bu_vls_printf(&vls, "help %s", argv[0]);
  466. Tcl_Eval(interp, bu_vls_addr(&vls));
  467. bu_vls_free(&vls);
  468. return TCL_ERROR;
  469. }
  470. for( i=1 ; i<argc ; i++ ) {
  471. if( *argv[i] == '-' ) {
  472. num_opts++;
  473. } else {
  474. break;
  475. }
  476. }
  477. bu_avs_init( &avs, argc/2, "muves_avs" );
  478. for( i=1 ; i<argc ; i++ ) {
  479. bu_avs_add_nonunique( &avs, "MUVES_Component", argv[i] );
  480. }
  481. tbl = db_lookup_by_attr( dbip, DIR_REGION, &avs, 2 );
  482. bu_avs_free( &avs );
  483. if( !tbl ) {
  484. return TCL_OK;
  485. }
  486. if( BU_PTBL_LEN( tbl ) < 1 ) {
  487. bu_free( (char *)tbl, "tbl returned by wdb_get_by_attr" );
  488. return TCL_OK;
  489. }
  490. objs = (char **)bu_calloc( (BU_PTBL_LEN( tbl ) + 1 + num_opts), sizeof( char *), "emuves_com objs" );
  491. for( i=0 ; i<=num_opts ; i++ ) {
  492. objs[i] = argv[i];
  493. }
  494. for( i=0 ; i<BU_PTBL_LEN( tbl ) ; i++ ) {
  495. struct directory *dp;
  496. dp = (struct directory *)BU_PTBL_GET( tbl, i );
  497. objs[i+num_opts+1] = dp->d_namep;
  498. }
  499. ret = edit_com( (BU_PTBL_LEN( tbl ) + 1), objs, 1, 1 );
  500. bu_ptbl_free( tbl );
  501. bu_free( (char *)tbl, "tbl returned by wdb_get_by_attr" );
  502. bu_free( (char *)objs, "emuves_com objs" );
  503. return( ret );
  504. }
  505. int
  506. cmd_autoview(ClientData clientData,
  507. Tcl_Interp *interp,
  508. int argc,
  509. char **argv)
  510. {
  511. register struct dm_list *dmlp;
  512. register struct dm_list *save_dmlp;
  513. register struct cmd_list *save_cmd_list;
  514. if (argc != 1) {
  515. struct bu_vls vls;
  516. bu_vls_init(&vls);
  517. bu_vls_printf(&vls, "help autoview");
  518. Tcl_Eval(interp, bu_vls_addr(&vls));
  519. bu_vls_free(&vls);
  520. return TCL_ERROR;
  521. }
  522. save_dmlp = curr_dm_list;
  523. save_cmd_list = curr_cmd_list;
  524. FOR_ALL_DISPLAYS(dmlp, &head_dm_list.l) {
  525. struct view_ring *vrp;
  526. curr_dm_list = dmlp;
  527. if (curr_dm_list->dml_tie)
  528. curr_cmd_list = curr_dm_list->dml_tie;
  529. else
  530. curr_cmd_list = &head_cmd_list;
  531. dgo_autoview(dgop, view_state->vs_vop, interp);
  532. (void)mged_svbase();
  533. for (BU_LIST_FOR(vrp, view_ring, &view_state->vs_headView.l))
  534. vrp->vr_scale = view_state->vs_vop->vo_scale;
  535. }
  536. curr_dm_list = save_dmlp;
  537. curr_cmd_list = save_cmd_list;
  538. return TCL_OK;
  539. }
  540. int
  541. cmd_get_autoview(ClientData clientData,
  542. Tcl_Interp *interp,
  543. int argc,
  544. char **argv)
  545. {
  546. return dgo_get_autoview_cmd(dgop, interp, argc, argv);
  547. }
  548. void
  549. solid_list_callback(void)
  550. {
  551. struct bu_vls vls;
  552. Tcl_Obj *save_obj;
  553. /* save result */
  554. save_obj = Tcl_GetObjResult(interp);
  555. Tcl_IncrRefCount(save_obj);
  556. bu_vls_init(&vls);
  557. bu_vls_strcpy(&vls, "solid_list_callback");
  558. (void)Tcl_Eval(interp, bu_vls_addr(&vls));
  559. bu_vls_free(&vls);
  560. /* restore result */
  561. Tcl_SetObjResult(interp, save_obj);
  562. Tcl_DecrRefCount(save_obj);
  563. }
  564. /*
  565. * F _ D E B U G
  566. *
  567. * Print information about solid table, and per-solid VLS
  568. */
  569. int
  570. cmd_solid_report(ClientData clientData,
  571. Tcl_Interp *interp,
  572. int argc,
  573. char **argv)
  574. {
  575. CHECK_DBI_NULL;
  576. return dgo_report_cmd(dgop, interp, argc, argv);
  577. }
  578. /*
  579. * F _ R E G D E B U G
  580. *
  581. * Display-manager specific "hardware register" debugging.
  582. */
  583. int
  584. f_regdebug(ClientData clientData, Tcl_Interp *interp, int argc, char **argv)
  585. {
  586. static int regdebug = 0;
  587. static char debug_str[10];
  588. if(argc < 1 || 2 < argc){
  589. struct bu_vls vls;
  590. bu_vls_init(&vls);
  591. bu_vls_printf(&vls, "help regdebug");
  592. Tcl_Eval(interp, bu_vls_addr(&vls));
  593. bu_vls_free(&vls);
  594. return TCL_ERROR;
  595. }
  596. if( argc == 1 )
  597. regdebug = !regdebug; /* toggle */
  598. else
  599. regdebug = atoi( argv[1] );
  600. sprintf( debug_str, "%d", regdebug );
  601. Tcl_AppendResult(interp, "regdebug=", debug_str, "\n", (char *)NULL);
  602. DM_DEBUG(dmp, regdebug);
  603. return TCL_OK;
  604. }
  605. /*
  606. * F _ D E B U G B U
  607. *
  608. * Provide user-level access to LIBBU debug bit vector.
  609. */
  610. int
  611. f_debugbu(ClientData clientData,
  612. Tcl_Interp *interp,
  613. int argc,
  614. char **argv)
  615. {
  616. struct bu_vls vls;
  617. bu_vls_init(&vls);
  618. if (argc < 1 || 2 < argc) {
  619. bu_vls_printf(&vls, "help debugbu");
  620. Tcl_Eval(interp, bu_vls_addr(&vls));
  621. bu_vls_free(&vls);
  622. return TCL_ERROR;
  623. }
  624. if( argc >= 2 ) {
  625. sscanf( argv[1], "%x", (unsigned int *)&bu_debug );
  626. } else {
  627. bu_vls_printb(&vls, "Possible flags", 0xffffffffL, BU_DEBUG_FORMAT );
  628. bu_vls_printf(&vls, "\n");
  629. }
  630. bu_vls_printb(&vls, "bu_debug", bu_debug, BU_DEBUG_FORMAT );
  631. bu_vls_printf(&vls, "\n");
  632. Tcl_AppendResult(interp, bu_vls_addr(&vls), (char *)NULL);
  633. bu_vls_free(&vls);
  634. return TCL_OK;
  635. }
  636. /*
  637. * F _ D E B U G L I B
  638. *
  639. * Provide user-level access to LIBRT debug bit vector
  640. */
  641. int
  642. f_debuglib(ClientData clientData,
  643. Tcl_Interp *interp,
  644. int argc,
  645. char **argv)
  646. {
  647. struct bu_vls vls;
  648. bu_vls_init(&vls);
  649. if (argc < 1 || 2 < argc) {
  650. bu_vls_printf(&vls, "help debuglib");
  651. Tcl_Eval(interp, bu_vls_addr(&vls));
  652. bu_vls_free(&vls);
  653. return TCL_ERROR;
  654. }
  655. if (argc >= 2) {
  656. sscanf(argv[1], "%x", (unsigned int *)&rt_g.debug);
  657. if (RT_G_DEBUG) bu_debug |= BU_DEBUG_COREDUMP;
  658. } else {
  659. bu_vls_printb(&vls, "Possible flags", 0xffffffffL, DEBUG_FORMAT);
  660. bu_vls_printf(&vls, "\n");
  661. }
  662. bu_vls_printb(&vls, "librt RT_G_DEBUG", RT_G_DEBUG, DEBUG_FORMAT);
  663. bu_vls_printf(&vls, "\n");
  664. Tcl_AppendResult(interp, bu_vls_addr(&vls), (char *)NULL);
  665. bu_vls_free(&vls);
  666. return TCL_OK;
  667. }
  668. /*
  669. * F _ D E B U G M E M
  670. *
  671. * Provide user-level access to LIBBU bu_prmem() routine.
  672. * Must be used in concert with BU_DEBUG_MEM_CHECK flag.
  673. */
  674. int
  675. f_debugmem(ClientData clientData,
  676. Tcl_Interp *interp,
  677. int argc,
  678. char **argv)
  679. {
  680. if (argc < 1 || 1 < argc) {
  681. struct bu_vls vls;
  682. bu_vls_init(&vls);
  683. bu_vls_printf(&vls, "help debugmem");
  684. Tcl_Eval(interp, bu_vls_addr(&vls));
  685. bu_vls_free(&vls);
  686. return TCL_ERROR;
  687. }
  688. if( setjmp( jmp_env ) == 0 )
  689. (void)signal( SIGINT, sig3 ); /* allow interupts */
  690. else
  691. return TCL_OK;
  692. bu_prmem("Invoked via MGED command");
  693. (void)signal(SIGINT, SIG_IGN);
  694. return TCL_OK;
  695. }
  696. /*
  697. * F _ D E B U G N M G
  698. *
  699. * Provide user-level access to LIBRT NMG_debug flags.
  700. */
  701. int
  702. f_debugnmg(ClientData clientData,
  703. Tcl_Interp *interp,
  704. int argc,
  705. char **argv)
  706. {
  707. struct bu_vls vls;
  708. bu_vls_init(&vls);
  709. if (argc < 1 || 2 < argc) {
  710. bu_vls_printf(&vls, "help debugnmg");
  711. Tcl_Eval(interp, bu_vls_addr(&vls));
  712. bu_vls_free(&vls);
  713. return TCL_ERROR;
  714. }
  715. if (argc >= 2) {
  716. sscanf(argv[1], "%x", (unsigned int *)&rt_g.NMG_debug);
  717. } else {
  718. bu_vls_printb(&vls, "possible flags", 0xffffffffL, NMG_DEBUG_FORMAT);
  719. bu_vls_printf(&vls, "\n");
  720. }
  721. bu_vls_printb(&vls, "librt rt_g.NMG_debug", rt_g.NMG_debug, NMG_DEBUG_FORMAT);
  722. bu_vls_printf(&vls, "\n");
  723. Tcl_AppendResult(interp, bu_vls_addr(&vls), (char *)NULL);
  724. bu_vls_free(&vls);
  725. return TCL_OK;
  726. }
  727. /*
  728. * D O _ L I S T
  729. */
  730. void
  731. do_list(struct bu_vls *outstrp, register struct directory *dp, int verbose)
  732. {
  733. int id;
  734. struct rt_db_internal intern;
  735. if(dbip == DBI_NULL)
  736. return;
  737. if( (id = rt_db_get_internal( &intern, dp, dbip, (fastf_t *)NULL, &rt_uniresource )) < 0 ) {
  738. Tcl_AppendResult(interp, "rt_db_get_internal(", dp->d_namep,
  739. ") failure\n", (char *)NULL );
  740. return;
  741. }
  742. bu_vls_printf( outstrp, "%s: ", dp->d_namep );
  743. if( rt_functab[id].ft_describe( outstrp, &intern,
  744. verbose, base2local, &rt_uniresource, dbip ) < 0 )
  745. Tcl_AppendResult(interp, dp->d_namep, ": describe error\n", (char *)NULL);
  746. rt_db_free_internal( &intern, &rt_uniresource );
  747. }
  748. /*
  749. * To return all the free "struct bn_vlist" and "struct solid" items
  750. * lurking on their respective freelists, back to bu_malloc().
  751. * Primarily as an aid to tracking memory leaks.
  752. * WARNING: This depends on knowledge of the macro GET_SOLID in mged/solid.h
  753. * and RT_GET_VLIST in h/raytrace.h.
  754. */
  755. void
  756. mged_freemem(void)
  757. {
  758. register struct solid *sp;
  759. register struct bn_vlist *vp;
  760. FOR_ALL_SOLIDS(sp,&FreeSolid.l){
  761. GET_SOLID(sp,&FreeSolid.l);
  762. bu_free((genptr_t)sp, "mged_freemem: struct solid");
  763. }
  764. while( BU_LIST_NON_EMPTY( &rt_g.rtg_vlfree ) ) {
  765. vp = BU_LIST_FIRST( bn_vlist, &rt_g.rtg_vlfree );
  766. BU_LIST_DEQUEUE( &(vp->l) );
  767. bu_free( (genptr_t)vp, "mged_freemem: struct bn_vlist" );
  768. }
  769. }
  770. /* ZAP the display -- everything dropped */
  771. /* Format: Z */
  772. int
  773. cmd_zap(ClientData clientData,
  774. Tcl_Interp *interp,
  775. int argc,
  776. char **argv)
  777. {
  778. CHECK_DBI_NULL;
  779. update_views = 1;
  780. /* FIRST, reject any editing in progress */
  781. if (state != ST_VIEW)
  782. button(BE_REJECT);
  783. #ifdef DO_DISPLAY_LISTS
  784. freeDListsAll(BU_LIST_FIRST(solid, &dgop->dgo_headSolid)->s_dlist,
  785. BU_LIST_LAST(solid, &dgop->dgo_headSolid)->s_dlist -
  786. BU_LIST_FIRST(solid, &dgop->dgo_headSolid)->s_dlist + 1);
  787. #endif
  788. dgo_zap_cmd(dgop, interp);
  789. /* Keeping freelists improves performance. When debugging, give mem back */
  790. if (RT_G_DEBUG)
  791. mged_freemem();
  792. (void)chg_state(state, state, "zap");
  793. solid_list_callback();
  794. return TCL_OK;
  795. }
  796. int
  797. f_status(ClientData clientData, Tcl_Interp *interp, int argc, char **argv)
  798. {
  799. struct bu_vls vls;
  800. CHECK_DBI_NULL;
  801. if (argc < 1 || 2 < argc) {
  802. struct bu_vls vls;
  803. bu_vls_init(&vls);
  804. bu_vls_printf(&vls, "help status");
  805. Tcl_Eval(interp, bu_vls_addr(&vls));
  806. bu_vls_free(&vls);
  807. return TCL_ERROR;
  808. }
  809. if (argc == 1) {
  810. bu_vls_init(&vls);
  811. bu_vls_printf(&vls, "STATE=%s, ", state_str[state] );
  812. bu_vls_printf(&vls, "Viewscale=%f (%f mm)\n",
  813. view_state->vs_vop->vo_scale*base2local, view_state->vs_vop->vo_scale);
  814. bu_vls_printf(&vls, "base2local=%f\n", base2local);
  815. Tcl_AppendResult(interp, bu_vls_addr(&vls), (char *)NULL);
  816. bu_vls_free(&vls);
  817. bn_tcl_mat_print(interp, "toViewcenter", view_state->vs_vop->vo_center);
  818. bn_tcl_mat_print(interp, "Viewrot", view_state->vs_vop->vo_rotation);
  819. bn_tcl_mat_print(interp, "model2view", view_state->vs_vop->vo_model2view);
  820. bn_tcl_mat_print(interp, "view2model", view_state->vs_vop->vo_view2model);
  821. if (state != ST_VIEW) {
  822. bn_tcl_mat_print(interp, "model2objview", view_state->vs_model2objview);
  823. bn_tcl_mat_print(interp, "objview2model", view_state->vs_objview2model);
  824. }
  825. return TCL_OK;
  826. }
  827. if (!strcmp(argv[1], "state")) {
  828. Tcl_AppendResult(interp, state_str[state], (char *)NULL);
  829. return TCL_OK;
  830. }
  831. if (!strcmp(argv[1], "Viewscale")) {
  832. bu_vls_init(&vls);
  833. bu_vls_printf(&vls, "%f", view_state->vs_vop->vo_scale*base2local);
  834. Tcl_AppendResult(interp, bu_vls_addr(&vls), (char *)NULL);
  835. bu_vls_free(&vls);
  836. return TCL_OK;
  837. }
  838. if (!strcmp(argv[1], "base2local")) {
  839. bu_vls_init(&vls);
  840. bu_vls_printf(&vls, "%f", base2local);
  841. Tcl_AppendResult(interp, bu_vls_addr(&vls), (char *)NULL);
  842. bu_vls_free(&vls);
  843. return TCL_OK;
  844. }
  845. if (!strcmp(argv[1], "local2base")) {
  846. bu_vls_init(&vls);
  847. bu_vls_printf(&vls, "%f", local2base);
  848. Tcl_AppendResult(interp, bu_vls_addr(&vls), (char *)NULL);
  849. bu_vls_free(&vls);
  850. return TCL_OK;
  851. }
  852. if (!strcmp(argv[1], "toViewcenter")) {
  853. bn_tcl_mat_print(interp, "toViewcenter", view_state->vs_vop->vo_center);
  854. return TCL_OK;
  855. }
  856. if (!strcmp(argv[1], "Viewrot")) {
  857. bn_tcl_mat_print(interp, "Viewrot", view_state->vs_vop->vo_rotation);
  858. return TCL_OK;
  859. }
  860. if (!strcmp(argv[1], "model2view")) {
  861. bn_tcl_mat_print(interp, "model2view", view_state->vs_vop->vo_model2view);
  862. return TCL_OK;
  863. }
  864. if (!strcmp(argv[1], "view2model")) {
  865. bn_tcl_mat_print(interp, "view2model", view_state->vs_vop->vo_view2model);
  866. return TCL_OK;
  867. }
  868. if (!strcmp(argv[1], "model2objview")) {
  869. bn_tcl_mat_print(interp, "model2objview", view_state->vs_model2objview);
  870. return TCL_OK;
  871. }
  872. if (!strcmp(argv[1], "objview2model")) {
  873. bn_tcl_mat_print(interp, "objview2model", view_state->vs_objview2model);
  874. return TCL_OK;
  875. }
  876. bu_vls_init(&vls);
  877. bu_vls_printf(&vls, "help status");
  878. Tcl_Eval(interp, bu_vls_addr(&vls));
  879. bu_vls_free(&vls);
  880. if (!strcmp(argv[1], "help"))
  881. return TCL_OK;
  882. return TCL_ERROR;
  883. }
  884. int
  885. f_view(ClientData clientData, Tcl_Interp *interp, int argc, char **argv)
  886. {
  887. int n;
  888. point_t pt;
  889. mat_t mat;
  890. struct bu_vls vls;
  891. CHECK_DBI_NULL;
  892. if (argc < 1 || 6 < argc) {
  893. bu_vls_init(&vls);
  894. bu_vls_printf(&vls, "help view");
  895. Tcl_Eval(interp, bu_vls_addr(&vls));
  896. bu_vls_free(&vls);
  897. return TCL_ERROR;
  898. }
  899. if (argc == 1) {
  900. bu_vls_init(&vls);
  901. bu_vls_printf(&vls, "help view");
  902. Tcl_Eval(interp, bu_vls_addr(&vls));
  903. bu_vls_free(&vls);
  904. return TCL_OK;
  905. }
  906. if (!strcmp(argv[1], "quat")) {
  907. quat_t quat;
  908. /* return Viewrot as a quaternion */
  909. if (argc == 2) {
  910. quat_mat2quat(quat, view_state->vs_vop->vo_rotation);
  911. bu_vls_init(&vls);
  912. bu_vls_printf(&vls, "%.12g %.12g %.12g %.12g", V4ARGS(quat));
  913. Tcl_AppendResult(interp, bu_vls_addr(&vls), (char *)NULL);
  914. bu_vls_free(&vls);
  915. return TCL_OK;
  916. }
  917. if (argc != 6) {
  918. bu_vls_init(&vls);
  919. bu_vls_printf(&vls, "view: quat requires four parameters");
  920. Tcl_AppendResult(interp, bu_vls_addr(&vls), (char *)NULL);
  921. bu_vls_free(&vls);
  922. return TCL_ERROR;
  923. }
  924. /* attempt to set Viewrot given a quaternion */
  925. n = sscanf(argv[2], "%lf", quat);
  926. n += sscanf(argv[3], "%lf", quat+1);
  927. n += sscanf(argv[4], "%lf", quat+2);
  928. n += sscanf(argv[5], "%lf", quat+3);
  929. if (n < 4) {
  930. bu_vls_init(&vls);
  931. bu_vls_printf(&vls, "view quat: bad value detected - %s %s %s %s",
  932. argv[2], argv[3], argv[4], argv[5]);
  933. Tcl_AppendResult(interp, bu_vls_addr(&vls), (char *)NULL);
  934. bu_vls_free(&vls);
  935. return TCL_ERROR;
  936. }
  937. quat_quat2mat(view_state->vs_vop->vo_rotation, quat);
  938. new_mats();
  939. return TCL_OK;
  940. }
  941. if (!strcmp(argv[1], "ypr")) {
  942. vect_t ypr;
  943. /* return Viewrot as yaw, pitch and roll */
  944. if (argc == 2) {
  945. bn_mat_trn(mat, view_state->vs_vop->vo_rotation);
  946. anim_v_unpermute(mat);
  947. n = anim_mat2ypr(pt, mat);
  948. if (n == 2) {
  949. Tcl_AppendResult(interp, "mat2ypr - matrix is not a rotation matrix", (char *)NULL);
  950. return TCL_ERROR;
  951. }
  952. VSCALE(pt, pt, bn_radtodeg);
  953. bu_vls_init(&vls);
  954. bu_vls_printf(&vls, "%.12g %.12g %.12g", V3ARGS(pt));
  955. Tcl_AppendResult(interp, bu_vls_addr(&vls), (char *)NULL);
  956. bu_vls_free(&vls);
  957. return TCL_OK;
  958. }
  959. if (argc != 5) {
  960. bu_vls_init(&vls);
  961. bu_vls_printf(&vls, "view: ypr requires 3 parameters");
  962. Tcl_AppendResult(interp, bu_vls_addr(&vls), (char *)NULL);
  963. bu_vls_free(&vls);
  964. return TCL_ERROR;
  965. }
  966. /* attempt to set Viewrot given yaw, pitch and roll */
  967. n = sscanf(argv[2], "%lf", ypr);
  968. n += sscanf(argv[3], "%lf", ypr+1);
  969. n += sscanf(argv[4], "%lf", ypr+2);
  970. if (n < 3) {
  971. bu_vls_init(&vls);
  972. bu_vls_printf(&vls, "view ypr: bad value detected - %s %s %s",
  973. argv[2], argv[3], argv[4]);
  974. Tcl_AppendResult(interp, bu_vls_addr(&vls), (char *)NULL);
  975. bu_vls_free(&vls);
  976. return TCL_ERROR;
  977. }
  978. anim_dy_p_r2mat(mat, V3ARGS(ypr));
  979. anim_v_permute(mat);
  980. bn_mat_trn(view_state->vs_vop->vo_rotation, mat);
  981. new_mats();
  982. return TCL_OK;
  983. }
  984. if (!strcmp(argv[1], "aet")) {
  985. vect_t aet;
  986. /* return Viewrot as azimuth, elevation and twist */
  987. if (argc == 2){
  988. bu_vls_init(&vls);
  989. bn_encode_vect(&vls, view_state->vs_vop->vo_aet);
  990. Tcl_AppendResult(interp, bu_vls_addr(&vls), (char *)NULL);
  991. bu_vls_free(&vls);
  992. return TCL_OK;
  993. }
  994. if(argc != 5){
  995. bu_vls_init(&vls);
  996. bu_vls_printf(&vls, "view: aet requires 3 parameters");
  997. Tcl_AppendResult(interp, bu_vls_addr(&vls), (char *)NULL);
  998. bu_vls_free(&vls);
  999. return TCL_ERROR;
  1000. }
  1001. /* attempt to set Viewrot given azimuth, elevation and twist */
  1002. n = sscanf(argv[2], "%lf", aet);
  1003. n += sscanf(argv[3], "%lf", aet+1);
  1004. n += sscanf(argv[4], "%lf", aet+2);
  1005. if (n < 3) {
  1006. bu_vls_init(&vls);
  1007. bu_vls_printf(&vls, "view aet: bad value detected - %s %s %s",
  1008. argv[2], argv[3], argv[4]);
  1009. Tcl_AppendResult(interp, bu_vls_addr(&vls), (char *)NULL);
  1010. bu_vls_free(&vls);
  1011. return TCL_ERROR;
  1012. }
  1013. VMOVE(view_state->vs_vop->vo_aet, aet);
  1014. vo_mat_aet(view_state->vs_vop);
  1015. new_mats();
  1016. return TCL_OK;
  1017. }
  1018. if (!strcmp(argv[1], "center")) {
  1019. point_t center;
  1020. /* return view center */
  1021. if (argc == 2) {
  1022. MAT_DELTAS_GET_NEG(center, view_state->vs_vop->vo_center);
  1023. VSCALE(center, center, base2local);
  1024. bu_vls_init(&vls);
  1025. bn_encode_vect(&vls, center);
  1026. Tcl_AppendResult(interp, bu_vls_addr(&vls), (char *)NULL);
  1027. bu_vls_free(&vls);
  1028. return TCL_OK;
  1029. }
  1030. if (argc != 5) {
  1031. bu_vls_init(&vls);
  1032. bu_vls_printf(&vls, "view: center requires 3 parameters");
  1033. Tcl_AppendResult(interp, bu_vls_addr(&vls), (char *)NULL);
  1034. bu_vls_free(&vls);
  1035. return TCL_ERROR;
  1036. }
  1037. /* attempt to set the view center */
  1038. n = sscanf(argv[2], "%lf", center);
  1039. n += sscanf(argv[3], "%lf", center+1);
  1040. n += sscanf(argv[4], "%lf", center+2);
  1041. if (n < 3) {
  1042. bu_vls_init(&vls);
  1043. bu_vls_printf(&vls, "view center: bad value detected - %s %s %s",
  1044. argv[2], argv[3], argv[4]);
  1045. Tcl_AppendResult(interp, bu_vls_addr(&vls), (char *)NULL);
  1046. bu_vls_free(&vls);
  1047. return TCL_ERROR;
  1048. }
  1049. vo_center(view_state->vs_vop, interp, center);
  1050. return TCL_OK;
  1051. }
  1052. if (!strcmp(argv[1], "eye")) {
  1053. point_t eye;
  1054. vect_t dir;
  1055. /* return the eye point */
  1056. if (argc == 2) {
  1057. VSET(pt, 0.0, 0.0, 1.0);
  1058. MAT4X3PNT(eye, view_state->vs_vop->vo_view2model, pt);
  1059. VSCALE(eye, eye, base2local);
  1060. bu_vls_init(&vls);
  1061. bn_encode_vect(&vls, eye);
  1062. Tcl_AppendResult(interp, bu_vls_addr(&vls), (char *)NULL);
  1063. bu_vls_free(&vls);
  1064. return TCL_OK;
  1065. }
  1066. if (argc != 5) {
  1067. bu_vls_init(&vls);
  1068. bu_vls_printf(&vls, "view: eye requires 3 parameters");
  1069. Tcl_AppendResult(interp, bu_vls_addr(&vls), (char *)NULL);
  1070. bu_vls_free(&vls);
  1071. return TCL_ERROR;
  1072. }
  1073. /* attempt to set view center given the eye point */
  1074. n = sscanf(argv[2], "%lf", eye);
  1075. n += sscanf(argv[3], "%lf", eye+1);
  1076. n += sscanf(argv[4], "%lf", eye+2);
  1077. if (n < 3) {
  1078. bu_vls_init(&vls);
  1079. bu_vls_printf(&vls, "view eye: bad value detected - %s %s %s",
  1080. argv[2], argv[3], argv[4]);
  1081. Tcl_AppendResult(interp, bu_vls_addr(&vls), (char *)NULL);
  1082. bu_vls_free(&vls);
  1083. return TCL_ERROR;
  1084. }
  1085. VSCALE(eye, eye, local2base);
  1086. VSET(pt, 0.0, 0.0, view_state->vs_vop->vo_scale);
  1087. bn_mat_trn(mat, view_state->vs_vop->vo_rotation);
  1088. MAT4X3PNT(dir, mat, pt);
  1089. VSUB2(pt, dir, eye);
  1090. MAT_DELTAS_VEC(view_state->vs_vop->vo_center, pt);
  1091. new_mats();
  1092. return TCL_OK;
  1093. }
  1094. if (!strcmp(argv[1], "size")) {
  1095. fastf_t size;
  1096. /* return the view size */
  1097. if (argc == 2) {
  1098. bu_vls_init(&vls);
  1099. bu_vls_printf(&vls, "%.12g", view_state->vs_vop->vo_size * base2local);
  1100. Tcl_AppendResult(interp, bu_vls_addr(&vls), (char *)NULL);
  1101. bu_vls_free(&vls);
  1102. return TCL_OK;
  1103. }
  1104. if (argc != 3) {
  1105. bu_vls_init(&vls);
  1106. bu_vls_printf(&vls, "view: size requires 1 parameter");
  1107. Tcl_AppendResult(interp, bu_vls_addr(&vls), (char *)NULL);
  1108. bu_vls_free(&vls);
  1109. return TCL_ERROR;
  1110. }
  1111. if (sscanf(argv[2], "%lf", &size) != 1) {
  1112. bu_vls_init(&vls);
  1113. bu_vls_printf(&vls, "view size: bad value detected - %s", argv[2]);
  1114. Tcl_AppendResult(interp, bu_vls_addr(&vls), (char *)NULL);
  1115. bu_vls_free(&vls);
  1116. return TCL_ERROR;
  1117. }
  1118. vo_size(view_state->vs_vop, interp, size);
  1119. return TCL_OK;
  1120. }
  1121. bu_vls_init(&vls);
  1122. bu_vls_printf(&vls, "help view");
  1123. Tcl_Eval(interp, bu_vls_addr(&vls));
  1124. bu_vls_free(&vls);
  1125. return TCL_ERROR;
  1126. }
  1127. int
  1128. f_refresh(ClientData clientData, Tcl_Interp *interp, int argc, char **argv)
  1129. {
  1130. if(argc < 1 || 1 < argc){
  1131. struct bu_vls vls;
  1132. bu_vls_init(&vls);
  1133. bu_vls_printf(&vls, "help refresh");
  1134. Tcl_Eval(interp, bu_vls_addr(&vls));
  1135. bu_vls_free(&vls);
  1136. return TCL_ERROR;
  1137. }
  1138. view_state->vs_flag = 1; /* causes refresh() */
  1139. return TCL_OK;
  1140. }
  1141. #if 0
  1142. int
  1143. mged_aetview(int iflag,
  1144. fastf_t azim,
  1145. fastf_t elev,
  1146. fastf_t twist)
  1147. {
  1148. int status = TCL_OK;
  1149. fastf_t o_twist;
  1150. fastf_t o_arz;
  1151. fastf_t o_larz;
  1152. struct bu_vls vls;
  1153. /* grab old twist angle before it's lost */
  1154. o_twist = view_state->vs_vop->vo_aet[BN_TWIST];
  1155. o_arz = view_state->vs_absolute_rotate[Z];
  1156. o_larz = view_state->vs_last_absolute_rotate[Z];
  1157. /* set view using azimuth and elevation angles */
  1158. if(iflag)
  1159. setview(270.0 + elev + view_state->vs_vop->vo_aet[BN_ELEVATION],
  1160. 0.0,
  1161. 270.0 - azim - view_state->vs_vop->vo_aet[BN_AZIMUTH]);
  1162. else
  1163. setview(270.0 + elev, 0.0, 270.0 - azim );
  1164. bu_vls_init(&vls);
  1165. if(iflag)
  1166. bu_vls_printf(&vls, "knob -i -v az %f", -o_twist - twist);
  1167. else
  1168. bu_vls_printf(&vls, "knob -i -v az %f", -twist);
  1169. status = Tcl_Eval(interp, bu_vls_addr(&vls));
  1170. bu_vls_free(&vls);
  1171. view_state->vs_absolute_rotate[Z] = o_arz;
  1172. view_state->vs_last_absolute_rotate[Z] = o_larz;
  1173. return status;
  1174. }
  1175. #endif
  1176. /* set view using azimuth, elevation and twist angles */
  1177. int
  1178. cmd_aetview(ClientData clientData,
  1179. Tcl_Interp *interp,
  1180. int argc,
  1181. char **argv)
  1182. {
  1183. #if 1
  1184. return vo_aet_cmd(view_state->vs_vop, interp, argc, argv);
  1185. #else
  1186. int iflag = 0;
  1187. fastf_t twist = 0.0; /* assumed to be 0.0 ---- unless supplied by user */
  1188. if(argc < 3 || 5 < argc){
  1189. struct bu_vls vls;
  1190. bu_vls_init(&vls);
  1191. bu_vls_printf(&vls, "help ae");
  1192. Tcl_Eval(interp, bu_vls_addr(&vls));
  1193. bu_vls_free(&vls);
  1194. return TCL_ERROR;
  1195. }
  1196. /* Check for -i option */
  1197. if(argv[1][0] == '-' && argv[1][1] == 'i'){
  1198. iflag = 1; /* treat arguments as incremental values */
  1199. ++argv;
  1200. --argc;
  1201. }
  1202. if (argc < 3) {
  1203. struct bu_vls vls;
  1204. bu_vls_init(&vls);
  1205. bu_vls_printf(&vls, "help ae");
  1206. Tcl_Eval(interp, bu_vls_addr(&vls));
  1207. bu_vls_free(&vls);
  1208. return TCL_ERROR;
  1209. }
  1210. if(argc == 4) /* twist angle supplied */
  1211. twist = atof(argv[3]);
  1212. return mged_aetview(iflag, atof(argv[1]), atof(argv[2]), twist);
  1213. #endif
  1214. }
  1215. /*
  1216. * E R A S E O B J A L L
  1217. *
  1218. * This routine goes through the solid table and deletes all solids
  1219. * from the solid list which contain the specified object anywhere in their 'path'
  1220. */
  1221. void
  1222. eraseobjall(register struct directory **dpp)
  1223. /* this is a partial path spec. XXX should be db_full_path? */
  1224. {
  1225. register struct directory **tmp_dpp;
  1226. register struct solid *sp;
  1227. register struct solid *nsp;
  1228. struct db_full_path subpath;
  1229. if (dbip == DBI_NULL)
  1230. return;
  1231. update_views = 1;
  1232. db_full_path_init(&subpath);
  1233. for (tmp_dpp = dpp; *tmp_dpp != DIR_NULL; ++tmp_dpp) {
  1234. RT_CK_DIR(*tmp_dpp);
  1235. db_add_node_to_full_path(&subpath, *tmp_dpp);
  1236. }
  1237. sp = BU_LIST_NEXT(solid, &dgop->dgo_headSolid);
  1238. while (BU_LIST_NOT_HEAD(sp, &dgop->dgo_headSolid)) {
  1239. nsp = BU_LIST_PNEXT(solid, sp);
  1240. if( db_full_path_subset( &sp->s_fullpath, &subpath ) ) {
  1241. #ifdef DO_DISPLAY_LISTS
  1242. freeDListsAll(sp->s_dlist, 1);
  1243. #endif
  1244. if (state != ST_VIEW && illump == sp)
  1245. button(BE_REJECT);
  1246. BU_LIST_DEQUEUE(&sp->l);
  1247. FREE_SOLID(sp, &FreeSolid.l);
  1248. }
  1249. sp = nsp;
  1250. }
  1251. if ((*dpp)->d_addr == RT_DIR_PHONY_ADDR) {
  1252. if (db_dirdelete(dbip, *dpp) < 0) {
  1253. Tcl_AppendResult(interp, "eraseobjall: db_dirdelete failed\n", (char *)NULL);
  1254. }
  1255. }
  1256. db_free_full_path(&subpath);
  1257. }
  1258. /*
  1259. * E R A S E O B J
  1260. *
  1261. * This routine goes through the solid table and deletes all solids
  1262. * from the solid list which contain the specified object at the
  1263. * beginning of their 'path'
  1264. */
  1265. void
  1266. eraseobj(register struct directory **dpp)
  1267. /* this is a partial path spec. XXX should be db_full_path? */
  1268. {
  1269. register struct directory **tmp_dpp;
  1270. register struct solid *sp;
  1271. register struct solid *nsp;
  1272. struct db_full_path subpath;
  1273. if (dbip == DBI_NULL)
  1274. return;
  1275. if (*dpp == DIR_NULL)
  1276. return;
  1277. update_views = 1;
  1278. db_full_path_init(&subpath);
  1279. for (tmp_dpp = dpp; *tmp_dpp != DIR_NULL; ++tmp_dpp) {
  1280. RT_CK_DIR(*tmp_dpp);
  1281. db_add_node_to_full_path(&subpath, *tmp_dpp);
  1282. }
  1283. sp = BU_LIST_FIRST(solid, &dgop->dgo_headSolid);
  1284. while (BU_LIST_NOT_HEAD(sp, &dgop->dgo_headSolid)) {
  1285. nsp = BU_LIST_PNEXT(solid, sp);
  1286. if( db_full_path_subset( &sp->s_fullpath, &subpath ) ) {
  1287. #ifdef DO_DISPLAY_LISTS
  1288. freeDListsAll(sp->s_dlist, 1);
  1289. #endif
  1290. if (state != ST_VIEW && illump == sp)
  1291. button( BE_REJECT );
  1292. BU_LIST_DEQUEUE(&sp->l);
  1293. FREE_SOLID(sp, &FreeSolid.l);
  1294. }
  1295. sp = nsp;
  1296. }
  1297. if ((*dpp)->d_addr == RT_DIR_PHONY_ADDR ) {
  1298. if (db_dirdelete(dbip, *dpp) < 0) {
  1299. Tcl_AppendResult(interp, "eraseobj: db_dirdelete failed\n", (char *)NULL);
  1300. }
  1301. }
  1302. db_free_full_path(&subpath);
  1303. }
  1304. /*
  1305. * P R _ S C H A I N
  1306. *
  1307. * Given a pointer to a member of the circularly linked list of solids
  1308. * (typically the head), chase the list and print out the information
  1309. * about each solid structure.
  1310. */
  1311. void
  1312. pr_schain(struct solid *startp, int lvl)
  1313. /* debug level */
  1314. {
  1315. register struct solid *sp;
  1316. register struct bn_vlist *vp;
  1317. int nvlist;
  1318. int npts;
  1319. struct bu_vls vls;
  1320. if(dbip == DBI_NULL)
  1321. return;
  1322. bu_vls_init(&vls);
  1323. if( setjmp( jmp_env ) == 0 )
  1324. (void)signal( SIGINT, sig3);
  1325. else{
  1326. bu_vls_free(&vls);
  1327. return;
  1328. }
  1329. FOR_ALL_SOLIDS(sp, &startp->l){
  1330. if (lvl <= -2) {
  1331. /* print only leaves */
  1332. bu_vls_printf(&vls, "%s ", LAST_SOLID(sp)->d_namep );
  1333. continue;
  1334. }
  1335. if( lvl != -1 )
  1336. bu_vls_printf(&vls, "%s", sp->s_flag == UP ? "VIEW " : "-no- ");
  1337. db_path_to_vls(&vls, &sp->s_fullpath);
  1338. if(( lvl != -1 ) && ( sp->s_iflag == UP ))
  1339. bu_vls_printf(&vls, " ILLUM");
  1340. bu_vls_printf(&vls, "\n");
  1341. if( lvl <= 0 ) continue;
  1342. /* convert to the local unit for printing */
  1343. bu_vls_printf(&vls, " cent=(%.3f,%.3f,%.3f) sz=%g ",
  1344. sp->s_center[X]*base2local,
  1345. sp->s_center[Y]*base2local,
  1346. sp->s_center[Z]*base2local,
  1347. sp->s_size*base2local );
  1348. bu_vls_printf(&vls, "reg=%d\n",sp->s_regionid );
  1349. bu_vls_printf(&vls, " basecolor=(%d,%d,%d) color=(%d,%d,%d)%s%s%s\n",
  1350. sp->s_basecolor[0],
  1351. sp->s_basecolor[1],
  1352. sp->s_basecolor[2],
  1353. sp->s_color[0],
  1354. sp->s_color[1],
  1355. sp->s_color[2],
  1356. sp->s_uflag?" U":"",
  1357. sp->s_dflag?" D":"",
  1358. sp->s_cflag?" C":"");
  1359. if( lvl <= 1 ) continue;
  1360. /* Print the actual vector list */
  1361. nvlist = 0;
  1362. npts = 0;
  1363. for( BU_LIST_FOR( vp, bn_vlist, &(sp->s_vlist) ) ) {
  1364. register int i;
  1365. register int nused = vp->nused;
  1366. register int *cmd = vp->cmd;
  1367. register point_t *pt = vp->pt;
  1368. BN_CK_VLIST( vp );
  1369. nvlist++;
  1370. npts += nused;
  1371. if( lvl <= 2 ) continue;
  1372. for( i = 0; i < nused; i++,cmd++,pt++ ) {
  1373. bu_vls_printf(&vls, " %s (%g, %g, %g)\n",
  1374. rt_vlist_cmd_descriptions[*cmd],
  1375. V3ARGS( *pt ) );
  1376. }
  1377. }
  1378. bu_vls_printf(&vls, " %d vlist structures, %d pts\n", nvlist, npts );
  1379. bu_vls_printf(&vls, " %d pts (via rt_ck_vlist)\n", rt_ck_vlist( &(sp->s_vlist) ) );
  1380. }
  1381. Tcl_AppendResult(interp, bu_vls_addr(&vls), (char *)NULL);
  1382. bu_vls_free(&vls);
  1383. (void)signal( SIGINT, SIG_IGN );
  1384. }
  1385. static char ** path_parse (char *path);
  1386. /* Illuminate the named object */
  1387. int
  1388. f_ill(ClientData clientData, Tcl_Interp *interp, int argc, char **argv)
  1389. {
  1390. register struct directory *dp;
  1391. register struct solid *sp;
  1392. struct solid *lastfound = SOLID_NULL;
  1393. register int i, j;
  1394. int nmatch;
  1395. int c;
  1396. int ri = 0;
  1397. int nm_pieces;
  1398. int illum_only = 0;
  1399. char **path_piece = 0;
  1400. char *basename;
  1401. char *sname;
  1402. CHECK_DBI_NULL;
  1403. if (argc < 2 || 5 < argc) {
  1404. struct bu_vls vls;
  1405. bu_vls_init(&vls);
  1406. bu_vls_printf(&vls, "help ill");
  1407. Tcl_Eval(interp, bu_vls_addr(&vls));
  1408. bu_vls_free(&vls);
  1409. return TCL_ERROR;
  1410. }
  1411. bu_optind = 1;
  1412. while ((c = bu_getopt(argc, argv, "i:n")) != EOF) {
  1413. switch (c) {
  1414. case 'n':
  1415. illum_only = 1;
  1416. break;
  1417. case 'i':
  1418. sscanf(bu_optarg, "%d", &ri);
  1419. if (ri <= 0) {
  1420. Tcl_AppendResult(interp,
  1421. "the reference index must be greater than 0\n",
  1422. (char *)NULL);
  1423. return TCL_ERROR;
  1424. }
  1425. break;
  1426. default:
  1427. case 'h':
  1428. {
  1429. struct bu_vls vls;
  1430. bu_vls_init(&vls);
  1431. bu_vls_printf(&vls, "help ill");
  1432. Tcl_Eval(interp, bu_vls_addr(&vls));
  1433. bu_vls_free(&vls);
  1434. return TCL_ERROR;
  1435. }
  1436. }
  1437. }
  1438. argc -= (bu_optind - 1);
  1439. argv += (bu_optind - 1);
  1440. if(argc != 2){
  1441. struct bu_vls vls;
  1442. bu_vls_init(&vls);
  1443. bu_vls_printf(&vls, "help ill");
  1444. Tcl_Eval(interp, bu_vls_addr(&vls));
  1445. bu_vls_free(&vls);
  1446. return TCL_ERROR;
  1447. }
  1448. if(state != ST_S_PICK && state != ST_O_PICK){
  1449. state_err("keyboard illuminate pick");
  1450. goto bail_out;
  1451. }
  1452. path_piece = path_parse(argv[1]);
  1453. for (nm_pieces = 0; path_piece[nm_pieces] != 0; ++nm_pieces)
  1454. ;
  1455. if(nm_pieces == 0){
  1456. Tcl_AppendResult(interp, "Bad solid path: '", argv[1], "'\n", (char *)NULL);
  1457. goto bail_out;
  1458. }
  1459. basename = path_piece[nm_pieces - 1];
  1460. if( (dp = db_lookup( dbip, basename, LOOKUP_NOISY )) == DIR_NULL )
  1461. goto bail_out;
  1462. nmatch = 0;
  1463. if(!(dp -> d_flags & DIR_SOLID)){
  1464. Tcl_AppendResult(interp, basename, " is not a solid\n", (char *)NULL);
  1465. goto bail_out;
  1466. }
  1467. FOR_ALL_SOLIDS(sp, &dgop->dgo_headSolid){
  1468. int a_new_match;
  1469. /* XXX Could this make use of db_full_path_subset()? */
  1470. if (nmatch == 0 || nmatch != ri) {
  1471. i = sp -> s_fullpath.fp_len-1;
  1472. if (DB_FULL_PATH_GET(&sp->s_fullpath,i) == dp) {
  1473. a_new_match = 1;
  1474. j = nm_pieces - 1;
  1475. for (; a_new_match && (i >= 0) && (j >= 0); --i, --j) {
  1476. sname = DB_FULL_PATH_GET(&sp->s_fullpath,i)->d_namep;
  1477. if ((*sname != *(path_piece[j]))
  1478. || strcmp(sname, path_piece[j]))
  1479. a_new_match = 0;
  1480. }
  1481. if (a_new_match && ((i >= 0) || (j < 0))) {
  1482. lastfound = sp;
  1483. ++nmatch;
  1484. }
  1485. }
  1486. }
  1487. sp->s_iflag = DOWN;
  1488. }
  1489. if (nmatch == 0) {
  1490. Tcl_AppendResult(interp, argv[1], " not being displayed\n", (char *)NULL);
  1491. goto bail_out;
  1492. }
  1493. /* preserve same old behavior */
  1494. if (nmatch > 1 && ri == 0) {
  1495. Tcl_AppendResult(interp, argv[1], " multiply referenced\n", (char *)NULL);
  1496. goto bail_out;
  1497. } else if (ri != 0 && ri != nmatch) {
  1498. Tcl_AppendResult(interp,
  1499. "the reference index must be less than the number of references\n",
  1500. (char *)NULL);
  1501. goto bail_out;
  1502. }
  1503. /* Make the specified solid the illuminated solid */
  1504. illump = lastfound;
  1505. illump->s_iflag = UP;
  1506. if(!illum_only){
  1507. if( state == ST_O_PICK ) {
  1508. ipathpos = 0;
  1509. (void)chg_state( ST_O_PICK, ST_O_PATH, "Keyboard illuminate");
  1510. } else {
  1511. /* Check details, Init menu, set state=ST_S_EDIT */
  1512. init_sedit();
  1513. }
  1514. }
  1515. update_views = 1;
  1516. if (path_piece)
  1517. {
  1518. for (i = 0; path_piece[i] != 0; ++i)
  1519. bu_free((genptr_t)path_piece[i], "f_ill: char *");
  1520. bu_free((genptr_t) path_piece, "f_ill: char **");
  1521. }
  1522. return TCL_OK;
  1523. bail_out:
  1524. if(state != ST_VIEW){
  1525. struct bu_vls vls;
  1526. bu_vls_init(&vls);
  1527. bu_vls_printf(&vls, "%s", interp->result);
  1528. button(BE_REJECT);
  1529. Tcl_ResetResult(interp);
  1530. Tcl_AppendResult(interp, bu_vls_addr(&vls), (char *)NULL);
  1531. bu_vls_free(&vls);
  1532. }
  1533. if (path_piece)
  1534. {
  1535. for (i = 0; path_piece[i] != 0; ++i)
  1536. bu_free((genptr_t)path_piece[i], "f_ill: char *");
  1537. bu_free((genptr_t) path_piece, "f_ill: char **");
  1538. }
  1539. return TCL_ERROR;
  1540. }
  1541. /* Simulate pressing "Solid Edit" and doing an ILLuminate command */
  1542. int
  1543. f_sed(
  1544. ClientData clientData,
  1545. Tcl_Interp *interp,
  1546. int argc,
  1547. char **argv)
  1548. {
  1549. CHECK_DBI_NULL;
  1550. CHECK_READ_ONLY;
  1551. if (argc < 2 || 5 < argc) {
  1552. struct bu_vls vls;
  1553. bu_vls_init(&vls);
  1554. bu_vls_printf(&vls, "help sed");
  1555. Tcl_Eval(interp, bu_vls_addr(&vls));
  1556. bu_vls_free(&vls);
  1557. return TCL_ERROR;
  1558. }
  1559. if( not_state( ST_VIEW, "keyboard solid edit start") )
  1560. return TCL_ERROR;
  1561. if(BU_LIST_IS_EMPTY(&dgop->dgo_headSolid)){
  1562. Tcl_AppendResult(interp, "no solids being displayed\n", (char *)NULL);
  1563. return TCL_ERROR;
  1564. }
  1565. update_views = 1;
  1566. button(BE_S_ILLUMINATE); /* To ST_S_PICK */
  1567. argv[0] = "ill";
  1568. /* Illuminate named solid --> ST_S_EDIT */
  1569. if (f_ill(clientData, interp, argc, argv) == TCL_ERROR) {
  1570. Tcl_Obj *save_result;
  1571. save_result = Tcl_GetObjResult(interp);
  1572. Tcl_IncrRefCount(save_result);
  1573. button(BE_REJECT);
  1574. Tcl_SetObjResult(interp, save_result);
  1575. Tcl_DecrRefCount(save_result);
  1576. return TCL_ERROR;
  1577. }
  1578. return TCL_OK;
  1579. }
  1580. void
  1581. check_nonzero_rates(void)
  1582. {
  1583. if( view_state->vs_rate_model_rotate[X] != 0.0 ||
  1584. view_state->vs_rate_model_rotate[Y] != 0.0 ||
  1585. view_state->vs_rate_model_rotate[Z] != 0.0 )
  1586. view_state->vs_rateflag_model_rotate = 1;
  1587. else
  1588. view_state->vs_rateflag_model_rotate = 0;
  1589. if( view_state->vs_rate_model_tran[X] != 0.0 ||
  1590. view_state->vs_rate_model_tran[Y] != 0.0 ||
  1591. view_state->vs_rate_model_tran[Z] != 0.0 )
  1592. view_state->vs_rateflag_model_tran = 1;
  1593. else
  1594. view_state->vs_rateflag_model_tran = 0;
  1595. if( view_state->vs_rate_rotate[X] != 0.0 ||
  1596. view_state->vs_rate_rotate[Y] != 0.0 ||
  1597. view_state->vs_rate_rotate[Z] != 0.0 )
  1598. view_state->vs_rateflag_rotate = 1;
  1599. else
  1600. view_state->vs_rateflag_rotate = 0;
  1601. if( view_state->vs_rate_tran[X] != 0.0 ||
  1602. view_state->vs_rate_tran[Y] != 0.0 ||
  1603. view_state->vs_rate_tran[Z] != 0.0 )
  1604. view_state->vs_rateflag_tran = 1;
  1605. else
  1606. view_state->vs_rateflag_tran = 0;
  1607. if( view_state->vs_rate_scale != 0.0 )
  1608. view_state->vs_rateflag_scale = 1;
  1609. else
  1610. view_state->vs_rateflag_scale = 0;
  1611. if( edit_rate_model_tran[X] != 0.0 ||
  1612. edit_rate_model_tran[Y] != 0.0 ||
  1613. edit_rate_model_tran[Z] != 0.0 )
  1614. edit_rateflag_model_tran = 1;
  1615. else
  1616. edit_rateflag_model_tran = 0;
  1617. if( edit_rate_view_tran[X] != 0.0 ||
  1618. edit_rate_view_tran[Y] != 0.0 ||
  1619. edit_rate_view_tran[Z] != 0.0 )
  1620. edit_rateflag_view_tran = 1;
  1621. else
  1622. edit_rateflag_view_tran = 0;
  1623. if( edit_rate_model_rotate[X] != 0.0 ||
  1624. edit_rate_model_rotate[Y] != 0.0 ||
  1625. edit_rate_model_rotate[Z] != 0.0 )
  1626. edit_rateflag_model_rotate = 1;
  1627. else
  1628. edit_rateflag_model_rotate = 0;
  1629. if( edit_rate_object_rotate[X] != 0.0 ||
  1630. edit_rate_object_rotate[Y] != 0.0 ||
  1631. edit_rate_object_rotate[Z] != 0.0 )
  1632. edit_rateflag_object_rotate = 1;
  1633. else
  1634. edit_rateflag_object_rotate = 0;
  1635. if( edit_rate_view_rotate[X] != 0.0 ||
  1636. edit_rate_view_rotate[Y] != 0.0 ||
  1637. edit_rate_view_rotate[Z] != 0.0 )
  1638. edit_rateflag_view_rotate = 1;
  1639. else
  1640. edit_rateflag_view_rotate = 0;
  1641. if( edit_rate_scale )
  1642. edit_rateflag_scale = 1;
  1643. else
  1644. edit_rateflag_scale = 0;
  1645. view_state->vs_flag = 1; /* values changed so update faceplate */
  1646. }
  1647. void
  1648. knob_update_rate_vars(void)
  1649. {
  1650. if(!mged_variables->mv_rateknobs)
  1651. return;
  1652. }
  1653. int
  1654. mged_print_knobvals(Tcl_Interp *interp)
  1655. {
  1656. struct bu_vls vls;
  1657. bu_vls_init(&vls);
  1658. if(mged_variables->mv_rateknobs){
  1659. if(es_edclass == EDIT_CLASS_ROTATE && mged_variables->mv_transform == 'e'){
  1660. bu_vls_printf(&vls, "x = %f\n", edit_rate_model_rotate[X]);
  1661. bu_vls_printf(&vls, "y = %f\n", edit_rate_model_rotate[Y]);
  1662. bu_vls_printf(&vls, "z = %f\n", edit_rate_model_rotate[Z]);
  1663. }else{
  1664. bu_vls_printf(&vls, "x = %f\n", view_state->vs_rate_rotate[X]);
  1665. bu_vls_printf(&vls, "y = %f\n", view_state->vs_rate_rotate[Y]);
  1666. bu_vls_printf(&vls, "z = %f\n", view_state->vs_rate_rotate[Z]);
  1667. }
  1668. if(es_edclass == EDIT_CLASS_SCALE && mged_variables->mv_transform == 'e')
  1669. bu_vls_printf(&vls, "S = %f\n", edit_rate_scale);
  1670. else
  1671. bu_vls_printf(&vls, "S = %f\n", view_state->vs_rate_scale);
  1672. if(es_edclass == EDIT_CLASS_TRAN && mged_variables->mv_transform == 'e'){
  1673. bu_vls_printf(&vls, "X = %f\n", edit_rate_model_tran[X]);
  1674. bu_vls_printf(&vls, "Y = %f\n", edit_rate_model_tran[Y]);
  1675. bu_vls_printf(&vls, "Z = %f\n", edit_rate_model_tran[Z]);
  1676. }else{
  1677. bu_vls_printf(&vls, "X = %f\n", view_state->vs_rate_tran[X]);
  1678. bu_vls_printf(&vls, "Y = %f\n", view_state->vs_rate_tran[Y]);
  1679. bu_vls_printf(&vls, "Z = %f\n", view_state->vs_rate_tran[Z]);
  1680. }
  1681. }else{
  1682. if(es_edclass == EDIT_CLASS_ROTATE && mged_variables->mv_transform == 'e'){
  1683. bu_vls_printf(&vls, "ax = %f\n", edit_absolute_model_rotate[X]);
  1684. bu_vls_printf(&vls, "ay = %f\n", edit_absolute_model_rotate[Y]);
  1685. bu_vls_printf(&vls, "az = %f\n", edit_absolute_model_rotate[Z]);
  1686. }else{
  1687. bu_vls_printf(&vls, "ax = %f\n", view_state->vs_absolute_rotate[X]);
  1688. bu_vls_printf(&vls, "ay = %f\n", view_state->vs_absolute_rotate[Y]);
  1689. bu_vls_printf(&vls, "az = %f\n", view_state->vs_absolute_rotate[Z]);
  1690. }
  1691. if(es_edclass == EDIT_CLASS_SCALE && mged_variables->mv_transform == 'e')
  1692. bu_vls_printf(&vls, "aS = %f\n", edit_absolute_scale);
  1693. else
  1694. bu_vls_printf(&vls, "aS = %f\n", view_state->vs_absolute_scale);
  1695. if(es_edclass == EDIT_CLASS_TRAN && mged_variables->mv_transform == 'e'){
  1696. bu_vls_printf(&vls, "aX = %f\n", edit_absolute_model_tran[X]);
  1697. bu_vls_printf(&vls, "aY = %