PageRenderTime 58ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 0ms

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

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