Revision: 41552
http://brlcad.svn.sourceforge.net/brlcad/?rev=41552&view=rev
Author: starseeker
Date: 2010-12-07 22:55:59 +0000 (Tue, 07 Dec 2010)
Log Message:
-----------
Revert preview to the state of commit 37421 (plus a local definition of
MAXARGS) - will need more work after release.
Modified Paths:
--------------
brlcad/trunk/src/libged/preview.c
Modified: brlcad/trunk/src/libged/preview.c
===================================================================
--- brlcad/trunk/src/libged/preview.c 2010-12-07 22:01:16 UTC (rev 41551)
+++ brlcad/trunk/src/libged/preview.c 2010-12-07 22:55:59 UTC (rev 41552)
@@ -44,7 +44,10 @@
static int preview_currentframe;
static int preview_tree_walk_needed;
+#define MAXARGS 9000 /* restore locally until preview command is sorted out */
+static char rt_cmd_storage[MAXARGS*9];
+
int
ged_cm_anim(int argc, char **argv)
{
@@ -52,7 +55,7 @@
if (_ged_current_gedp->ged_wdbp->dbip == DBI_NULL)
return 0;
- if (db_parse_anim(_ged_current_gedp->ged_wdbp->dbip, argc, (const char
**)argv) < 0) {
+ if ( db_parse_anim( _ged_current_gedp->ged_wdbp->dbip, argc, (const char
**)argv ) < 0 ) {
bu_vls_printf(&_ged_current_gedp->ged_result_str, "cm_anim: %s %s
failed\n", argv[1], argv[2]);
return -1; /* BAD */
}
@@ -62,14 +65,13 @@
return 0;
}
-
int
-ged_cm_clean(int UNUSED(argc), char **UNUSED(argv))
+ged_cm_clean(int argc, char **argv)
{
if (_ged_current_gedp->ged_wdbp->dbip == DBI_NULL)
return 0;
- /*f_zap((ClientData)NULL, interp, 0, (char **)0);*/
+ /*f_zap( (ClientData)NULL, interp, 0, (char **)0 );*/
/* Free animation structures */
db_free_anim(_ged_current_gedp->ged_wdbp->dbip);
@@ -78,25 +80,24 @@
return 0;
}
-
int
-ged_cm_end(int UNUSED(argc), char **UNUSED(argv))
+ged_cm_end(int argc, char **argv)
{
- vect_t xlate;
- vect_t new_cent;
- vect_t xv, yv; /* view x, y */
- vect_t xm, ym; /* model x, y */
- struct bu_list *vhead = &preview_vbp->head[0];
+ vect_t xlate;
+ vect_t new_cent;
+ vect_t xv, yv; /* view x, y */
+ vect_t xm, ym; /* model x, y */
+ struct bu_list *vhead = &preview_vbp->head[0];
/* Only display the frames the user is interested in */
- if (preview_currentframe < preview_desiredframe) return 0;
- if (preview_finalframe && preview_currentframe > preview_finalframe)
return 0;
+ if ( preview_currentframe < preview_desiredframe ) return 0;
+ if ( preview_finalframe && preview_currentframe > preview_finalframe )
return 0;
/* Record eye path as a polyline. Move, then draws */
- if (BU_LIST_IS_EMPTY(vhead)) {
- RT_ADD_VLIST(vhead, _ged_eye_model, BN_VLIST_LINE_MOVE);
+ if ( BU_LIST_IS_EMPTY( vhead ) ) {
+ RT_ADD_VLIST( vhead, _ged_eye_model, BN_VLIST_LINE_MOVE );
} else {
- RT_ADD_VLIST(vhead, _ged_eye_model, BN_VLIST_LINE_DRAW);
+ RT_ADD_VLIST( vhead, _ged_eye_model, BN_VLIST_LINE_DRAW );
}
/* First step: put eye at view center (view 0, 0, 0) */
@@ -117,8 +118,8 @@
RT_ADD_VLIST(vhead, ym, BN_VLIST_LINE_DRAW);
RT_ADD_VLIST(vhead, _ged_eye_model, BN_VLIST_LINE_MOVE);
- /* Second step: put eye at view 0, 0, 1.
- * For eye to be at 0, 0, 1, the old 0, 0, -1 needs to become 0, 0, 0.
+ /* Second step: put eye at view 0, 0, 1.
+ * For eye to be at 0, 0, 1, the old 0, 0, -1 needs to become 0, 0, 0.
*/
VSET(xlate, 0.0, 0.0, -1.0); /* correction factor */
MAT4X3PNT(new_cent, _ged_current_gedp->ged_gvp->gv_view2model, xlate);
@@ -126,13 +127,13 @@
ged_view_update(_ged_current_gedp->ged_gvp);
/* If new treewalk is needed, get new objects into view. */
- if (preview_tree_walk_needed) {
+ if ( preview_tree_walk_needed ) {
const char *av[2];
av[0] = "zap";
av[1] = NULL;
- (void)ged_zap(_ged_current_gedp, 1, av);
+ (void)ged_zap(_ged_current_gedp, 1, av );
_ged_drawtrees(_ged_current_gedp,
_ged_current_gedp->ged_gdp->gd_rt_cmd_len, (const char
**)_ged_current_gedp->ged_gdp->gd_rt_cmd, preview_mode, (struct
_ged_client_data *)0);
ged_color_soltab(&_ged_current_gedp->ged_gdp->gd_headDisplay);
}
@@ -140,7 +141,7 @@
if (_ged_current_gedp->ged_refresh_handler !=
GED_REFRESH_CALLBACK_PTR_NULL)
(*_ged_current_gedp->ged_refresh_handler)(_ged_current_gedp->ged_refresh_clientdata);
- if (preview_delay > 0) {
+ if ( preview_delay > 0 ) {
struct timeval tv;
fd_set readfds;
@@ -148,20 +149,18 @@
FD_SET(fileno(stdin), &readfds);
tv.tv_sec = (long)preview_delay;
tv.tv_usec = (long)((preview_delay - tv.tv_sec) * 1000000);
- select(fileno(stdin)+1, &readfds, (fd_set *)0, (fd_set *)0, &tv);
+ select( fileno(stdin)+1, &readfds, (fd_set *)0, (fd_set *)0, &tv );
}
return 0;
}
-
int
-ged_cm_multiview(int UNUSED(argc), char **UNUSED(argv))
+ged_cm_multiview(int argc, char **argv)
{
return -1;
}
-
int
ged_cm_start(int argc, char **argv)
{
@@ -173,15 +172,16 @@
return 0;
}
-
int
ged_cm_tree(int argc, char **argv)
{
+ int i = 1;
+ char *cp = rt_cmd_storage;
- int i = 1;
-
- for (i = 1; i < argc; i++) {
- _ged_current_gedp->ged_gdp->gd_rt_cmd[i] = bu_strdup(argv[i]);
+ for ( i = 1; i < argc && i < MAXARGS; i++ ) {
+ bu_strlcpy(cp, argv[i], MAXARGS*9);
+ _ged_current_gedp->ged_gdp->gd_rt_cmd[i] = cp;
+ cp += strlen(cp) + 1;
}
_ged_current_gedp->ged_gdp->gd_rt_cmd[i] = (char *)0;
_ged_current_gedp->ged_gdp->gd_rt_cmd_len = i;
@@ -191,7 +191,24 @@
return 0;
}
+void
+_ged_setup_rt(struct ged *gedp, char **vp, int printcmd)
+{
+ _ged_current_gedp->ged_gdp->gd_rt_cmd_len = vp -
_ged_current_gedp->ged_gdp->gd_rt_cmd;
+ _ged_current_gedp->ged_gdp->gd_rt_cmd_len += ged_build_tops(gedp,
+ vp,
&_ged_current_gedp->ged_gdp->gd_rt_cmd[MAXARGS]);
+ if (printcmd) {
+ /* Print out the command we are about to run */
+ vp = &_ged_current_gedp->ged_gdp->gd_rt_cmd[0];
+ while (*vp)
+ bu_vls_printf(&gedp->ged_result_str, "%s ", *vp++);
+
+ bu_vls_printf(&gedp->ged_result_str, "\n");
+ }
+}
+
+
struct command_tab ged_preview_cmdtab[] = {
{"start", "frame number", "start a new frame",
ged_cm_start, 2, 2},
@@ -210,46 +227,40 @@
{"multiview", "", "produce stock set of views",
ged_cm_multiview, 1, 1},
{"anim", "path type args", "specify articulation animation",
- ged_cm_anim, 4, 99999},
+ ged_cm_anim, 4, 999},
{"tree", "treetop(s)", "specify alternate list of tree tops",
- ged_cm_tree, 1, 99999},
+ ged_cm_tree, 1, 999},
{"clean", "", "clean articulation from previous frame",
ged_cm_clean, 1, 1},
{"set", "", "show or set parameters",
- _ged_cm_set, 1, 99999},
+ _ged_cm_set, 1, 999},
{"ae", "azim elev", "specify view as azim and elev, in degrees",
_ged_cm_null, 3, 3},
{"opt", "-flags", "set flags, like on command line",
- _ged_cm_null, 2, 99999},
+ _ged_cm_null, 2, 999},
{(char *)0, (char *)0, (char *)0,
0, 0, 0} /* END */
};
-
/**
- * Preview a new style RT animation script.
- * Note that the RT command parser code is used, rather than the
- * MGED command parser, because of the differences in format.
- * The RT parser expects command handlers of the form "ged_cm_xxx()",
- * and all communications are done via global variables.
+ * Preview a new style RT animation script.
+ * Note that the RT command parser code is used, rather than the
+ * MGED command parser, because of the differences in format.
+ * The RT parser expects command handlers of the form "ged_cm_xxx()",
+ * and all communications are done via global variables.
*
- * For the moment, the only preview mode is the normal one,
- * moving the eyepoint as directed.
- * However, as a bonus, the eye path is left behind as a vector plot.
+ * For the moment, the only preview mode is the normal one,
+ * moving the eyepoint as directed.
+ * However, as a bonus, the eye path is left behind as a vector plot.
*/
int
ged_preview(struct ged *gedp, int argc, const char *argv[])
{
- static const char *usage = "[-v] [-d sec_delay] [-D start frame] [-K last
frame] rt_script_file";
-
- size_t i;
FILE *fp;
char *cmd;
- int c;
+ int c;
vect_t temp;
- const char *argv0 = NULL;
- size_t args = 0;
- char **vp;
+ static const char *usage = "[-v] [-d sec_delay] [-D start frame] [-K last
frame] rt_script_file";
GED_CHECK_DATABASE_OPEN(gedp, GED_ERROR);
GED_CHECK_DRAWABLE(gedp, GED_ERROR);
@@ -278,7 +289,7 @@
/* Parse options */
bu_optind = 1; /* re-init bu_getopt() */
while ((c=bu_getopt(argc, (char * const *)argv, "d:vD:K:")) != EOF) {
- switch (c) {
+ switch (c) {
case 'd':
preview_delay = atof(bu_optarg);
break;
@@ -292,18 +303,17 @@
preview_mode = 3; /* Like "ev" */
break;
default:
- {
- bu_vls_printf(&gedp->ged_result_str, "option '%c'
unknown\n", c);
- bu_vls_printf(&gedp->ged_result_str, " -d#
inter-frame delay\n");
- bu_vls_printf(&gedp->ged_result_str, " -v
polygon rendering (visual)\n");
- bu_vls_printf(&gedp->ged_result_str, " -D#
desired starting frame\n");
- bu_vls_printf(&gedp->ged_result_str, " -K# final
frame\n");
- }
+ {
+ bu_vls_printf(&gedp->ged_result_str, "option '%c' unknown\n",
c);
+ bu_vls_printf(&gedp->ged_result_str, " -d#
inter-frame delay\n");
+ bu_vls_printf(&gedp->ged_result_str, " -v polygon
rendering (visual)\n");
+ bu_vls_printf(&gedp->ged_result_str, " -D# desired
starting frame\n");
+ bu_vls_printf(&gedp->ged_result_str, " -K# final
frame\n");
+ }
- break;
+ break;
}
}
- argv0 = argv[0]; /* temp stash */
argc -= bu_optind-1;
argv += bu_optind-1;
@@ -312,13 +322,8 @@
return GED_ERROR;
}
- args = argc + 2 + ged_count_tops(gedp);
- gedp->ged_gdp->gd_rt_cmd = (char **)bu_calloc(args, sizeof(char *), "alloc
gd_rt_cmd");
- vp = &gedp->ged_gdp->gd_rt_cmd[0];
- *vp++ = bu_strdup(argv0);
-
/* Build list of top-level objects in view, in
_ged_current_gedp->ged_gdp->gd_rt_cmd[] */
- _ged_current_gedp->ged_gdp->gd_rt_cmd_len = ged_build_tops(gedp, vp,
&_ged_current_gedp->ged_gdp->gd_rt_cmd[args]);
+ _ged_setup_rt(gedp, _ged_current_gedp->ged_gdp->gd_rt_cmd, 1);
preview_vbp = rt_vlblock_init();
@@ -348,18 +353,6 @@
fclose(fp);
fp = NULL;
- /* free any strings stashed */
- for (i = 0; i < args; i++) {
- if (gedp->ged_gdp->gd_rt_cmd[i] != NULL) {
- bu_free(gedp->ged_gdp->gd_rt_cmd[i], "free gd_rt_cmd[i]");
- gedp->ged_gdp->gd_rt_cmd[i] = NULL;
- }
- }
-
- /* free the array */
- bu_free(gedp->ged_gdp->gd_rt_cmd, "free gd_rt_cmd");
- gedp->ged_gdp->gd_rt_cmd = NULL;;
-
_ged_cvt_vlblock_to_solids(gedp, preview_vbp, "EYE_PATH", 0);
if (preview_vbp) {
rt_vlblock_free(preview_vbp);
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
What happens now with your Lotus Notes apps - do you make another costly
upgrade, or settle for being marooned without product support? Time to move
off Lotus Notes and onto the cloud with Force.com, apps are easier to build,
use, and manage than apps on traditional platforms. Sign up for the Lotus
Notes Migration Kit to learn more. http://p.sf.net/sfu/salesforce-d2d
_______________________________________________
BRL-CAD Source Commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-commits